from direct.showbase.ShowBase import ShowBase
from panda3d.core import TransparencyAttrib

base = ShowBase()
colors = {
    'w': (0.8, 0.8, 0.8, 1),
    'r': (1.0, 0.396, 0.337, 1),
    'o': (0.95, 0.707, 0.384, 1),
    'y': (0.91, 0.902, 0.329, 1),
    'g': (0.604, 0.922, 0.408, 1),
    'b': (0.396, 0.875, 1.0, 1),
    'i': (0.306, 0.475, 0.91, 1),
    'v': (0.651, 0.443, 0.91, 1),
    '?': (0.15, 0.15, 0.15, 1),
}

collisions = {
    ('r', 'y'): 'o',
    ('y', 'b'): 'g',
    ('b', 'i'): 'i',
    ('b', 'r'): 'v',
}
safe = []  # safe pairs will not eat each other
for k, v in dict(collisions).items():
    k = (k[1], k[0])
    collisions[k] = v
    safe.append((k[0], v))
    safe.append((k[1], v))

for a, b in list(safe):
    safe.append((b, a))

kaushan = base.loader.load_font('kaushanscript.ttf', color=(1, 1, 1, 1))
anonymous = base.loader.load_font('anonymous_pro.ttf', color=(1, 1, 1, 1))


def button_style(b):
    b['text_font'] = kaushan
    b['relief'] = None
    b['image'] = "img/button_bg.png"
    b['image_scale'] = (2, 0, 0.5)
    b['image_pos'] = (0, 0, 0.25)
    b.set_transparency(TransparencyAttrib.MAlpha)


door_open_sfx = base.loader.load_sfx('sfx/door_open.wav')
door_close_sfx = base.loader.load_sfx('sfx/door_close.wav')
place_wall_sfx = base.loader.load_sfx('sfx/place_wall.wav')
merge_sfx = base.loader.load_sfx('sfx/merge.wav')
place_wall_sfx.set_volume(0.2)
merge_sfx.set_volume(0.2)
