import es

import wcs
from wcs import wcs

wcs.Item('Cloak Of Shadows I').registerItem('enhancement', 2000, 'Become 75% Visible', True)
wcs.Item('Cloak Of Shadows II').registerItem('enhancement', 3500, 'Become 50% Visible', True)

def item_bought(ev):
    userid = ev['userid']
    if ev['item'] == 'Cloak Of Shadows I':
        command = wcs.Command(userid)
        command.Fade(int(command['Alpha'] * 0.75), 5)
    elif ev['item'] == 'Cloak Of Shadows II':
        command = wcs.Command(userid)
        command.Fade(int(command['Alpha'] * 0.5), 5)

def player_spawn(ev):
    count = wcs.Command(ev['userid']).GetItemCount('Cloak Of Shadows I')
    while count:
        count -= 1
        command = wcs.Comand(ev['userid'])
        command.Fade(int(command['Alpha'] * .75), 5)
        
    count = wcs.Command(ev['userid']).GetItemCount('Cloak Of Shadows II')
    while count:
        count -= 1
        command = wcs.Comand(ev['userid'])
        command.Fade(int(command['Alpha'] * .75), 5)
			
def player_death(ev):
    wcs.Command(ev['userid']).RemoveItem('Cloak Of Shadows I')
    wcs.Command(ev['userid']).RemoveItem('Cloak Of Shadows II')
