def __init_weapon__(self): init_dict = { 'name': card_def['name'], 'mana': card_def['mana'], 'rarity': CARD_RARITY.from_str(card_def['rarity']) } if 'character_class' in card_def: init_dict['character_class'] = CHARACTER_CLASS.from_str( card_def['character_class']) if 'battlecry' in card_def: init_dict['battlecry'] = Battlecry.from_json( **card_def['battlecry']) if 'combo' in card_def: init_dict['combo'] = Battlecry.from_json(**card_def['combo']) if 'overload' in card_def: init_dict['overload'] = card_def['overload'] if 'buffs' in card_def: init_dict['buffs'] = [ Buff.from_json(**buff) for buff in card_def['buffs'] ] if 'auras' in card_def: init_dict['auras'] = [ Aura.from_json(**aura) for aura in card_def['auras'] ] if 'effects' in card_def: init_dict['effects'] = [ Effect.from_json(**effect) for effect in card_def['effects'] ] WeaponCard.__init__(self, **init_dict)
def create_minion(self, player): create_dict = { 'attack': card_def['attack'], 'health': card_def['health'] } if 'effects' in card_def: create_dict['effects'] = [ Effect.from_json(player.game, **effect) for effect in card_def['effects'] ] if 'auras' in card_def: create_dict['auras'] = [ Aura.from_json(**aura) for aura in card_def['auras'] ] if 'enrage' in card_def: create_dict['enrage'] = [ Action.from_json(**action) for action in card_def['enrage'] ] if 'deathrattle' in card_def: create_dict['deathrattle'] = Deathrattle.from_json( **card_def['deathrattle']) return Minion(**create_dict)
def create_minion(self, player): create_dict = { 'attack': card_def['attack'], 'health': card_def['health'] } if "impl" in card_def: impl = card_def['impl'] if 'effects' in impl: create_dict['effects'] = [ Effect.from_json(**effect) for effect in impl['effects'] ] if 'auras' in impl: create_dict['auras'] = [ Aura.from_json(**aura) for aura in impl['auras'] ] if 'buffs' in impl: create_dict['buffs'] = [ Buff.from_json(**buff) for buff in impl['buffs'] ] if 'enrage' in card_def: create_dict['enrage'] = [ Aura.from_json(**enrage) for enrage in card_def['enrage'] ] if 'deathrattle' in card_def: create_dict['deathrattle'] = [ Deathrattle.from_json(**deathrattle) for deathrattle in card_def['deathrattle'] ] return Minion(**create_dict)
def create_weapon(self, player): create_dict = { 'attack_power': card_def['attack'], 'durability': card_def['durability'] } if "impl" in card_def: impl = card_def['impl'] if 'effects' in impl: create_dict['effects'] = [ Effect.from_json(**effect) for effect in impl['effects'] ] if 'auras' in impl: create_dict['auras'] = [ Aura.from_json(**aura) for aura in impl['auras'] ] if 'buffs' in impl: create_dict['buffs'] = [ Buff.from_json(**buff) for buff in impl['buffs'] ] if 'deathrattle' in card_def: create_dict['deathrattle'] = Deathrattle.from_json( **card_def['deathrattle']) return Weapon(**create_dict)
def __init_weapon__(self): init_dict = { 'name': card_def['name'], 'mana': card_def['mana'], 'rarity': CARD_RARITY.from_str(card_def['rarity']) } if 'character_class' in card_def: init_dict['character_class'] = CHARACTER_CLASS.from_str(card_def['character_class']) if 'battlecry' in card_def: init_dict['battlecry'] = Battlecry.from_json(**card_def['battlecry']) if 'combo' in card_def: init_dict['combo'] = Battlecry.from_json(**card_def['combo']) if 'overload' in card_def: init_dict['overload'] = card_def['overload'] if 'buffs' in card_def: init_dict['buffs'] = [Buff.from_json(**buff) for buff in card_def['buffs']] if 'auras' in card_def: init_dict['auras'] = [Aura.from_json(**aura) for aura in card_def['auras']] if 'effects' in card_def: init_dict['effects'] = [Effect.from_json(**effect) for effect in card_def['effects']] WeaponCard.__init__(self, **init_dict)
def __init__(self): init_dict = { 'name': card_def['name'], 'mana': card_def['mana'], 'rarity': CARD_RARITY.from_str(card_def['rarity']) } if 'character_class' in card_def: init_dict['character_class'] = CHARACTER_CLASS.from_str(card_def['character_class']) if 'minion_type' in card_def: init_dict['minion_type'] = MINION_TYPE.from_str(card_def['minion_type']) if 'battlecry' in card_def: init_dict['battlecry'] = tuple(Battlecry.from_json(**battlecry) for battlecry in card_def['battlecry']) if 'choices' in card_def: init_dict['choices'] = [Choice.from_json(**choice) for choice in card_def['choices']] if 'combo' in card_def: init_dict['combo'] = Battlecry.from_json(**card_def['combo']) if 'overload' in card_def: init_dict['overload'] = card_def['overload'] if 'buffs' in card_def: init_dict['buffs'] = [Buff.from_json(**buff) for buff in card_def['buffs']] if 'auras' in card_def: init_dict['auras'] = [Aura.from_json(**aura) for aura in card_def['auras']] if 'effects' in card_def: init_dict['effects'] = [Effect.from_json(**effect) for effect in card_def['effects']] MinionCard.__init__(self, **init_dict)
def __from_json__(self, auras=None, effects=None): if effects: # To allow for give to work with effects as well, we check at load time effects = [Effect.from_json(**effect) for effect in effects] return GiveEffect(effects) self.auras = [] for aura in auras: if "until" in aura: self.auras.append(AuraUntil.from_json(**aura)) else: self.auras.append(Aura.from_json(**aura)) return self
def __from_json__(minion, effects=None, auras=None, buffs=None, **kwargs): if effects: minion.effects = [Effect.from_json(**effect) for effect in effects] else: minion.effects = [] if auras: minion.auras = [AuraUntil.from_json(**aura) if 'until' in aura else Aura.from_json(**aura) for aura in auras] else: minion.auras = [] if buffs: minion.buffs = [BuffUntil.from_json(**buff) if 'until' in buff else Buff.from_json(**buff) for buff in buffs] else: minion.buffs = []
def __init__(self): init_dict = { 'name': card_def['name'], 'mana': card_def['mana'], 'rarity': CARD_RARITY.from_str(card_def['rarity']) } if 'character_class' in card_def: init_dict['character_class'] = CHARACTER_CLASS.from_str( card_def['character_class']) if 'minion_type' in card_def: init_dict['minion_type'] = MINION_TYPE.from_str( card_def['minion_type']) if 'battlecry' in card_def: init_dict['battlecry'] = tuple( Battlecry.from_json(**battlecry) for battlecry in card_def['battlecry']) if 'choices' in card_def: init_dict['choices'] = [ Choice.from_json(**choice) for choice in card_def['choices'] ] if 'combo' in card_def: init_dict['combo'] = Battlecry.from_json(**card_def['combo']) if 'overload' in card_def: init_dict['overload'] = card_def['overload'] if 'buffs' in card_def: init_dict['buffs'] = [ Buff.from_json(**buff) for buff in card_def['buffs'] ] if 'auras' in card_def: init_dict['auras'] = [ Aura.from_json(**aura) for aura in card_def['auras'] ] if 'effects' in card_def: init_dict['effects'] = [ Effect.from_json(**effect) for effect in card_def['effects'] ] MinionCard.__init__(self, **init_dict)
def create_weapon(self, player): create_dict = { 'attack_power': card_def['attack'], 'durability': card_def['durability'] } if 'effects' in card_def: create_dict['effects'] = [Effect.from_json(**effect) for effect in card_def['effects']] if 'auras' in card_def: create_dict['auras'] = [Aura.from_json(**aura) for aura in card_def['auras']] if 'buffs' in card_def: create_dict['buffs'] = [Buff.from_json(**buff) for buff in card_def['buffs']] if 'deathrattle' in card_def: create_dict['deathrattle'] = Deathrattle.from_json(**card_def['deathrattle']) return Weapon(**create_dict)
def create_minion(self, player): create_dict = { 'attack': card_def['attack'], 'health': card_def['health'] } if 'effects' in card_def: create_dict['effects'] = [Effect.from_json(player.game, **effect) for effect in card_def['effects']] if 'auras' in card_def: create_dict['auras'] = [Aura.from_json(**aura) for aura in card_def['auras']] if 'enrage' in card_def: create_dict['enrage'] = [Action.from_json(**action) for action in card_def['enrage']] if 'deathrattle' in card_def: create_dict['deathrattle'] = Deathrattle.from_json(**card_def['deathrattle']) return Minion(**create_dict)
def __from_json__(d, agents): new_game = Game.__new__(Game) new_game._all_cards_played = [] new_game.minion_counter = d["current_sequence_id"] new_game._turns_passed = d['turn_count'] new_game.delayed_minions = set() new_game.game_ended = False new_game.random_func = random.randint new_game.events = {} new_game.players = [ Player.__from_json__(pd, new_game, None) for pd in d["players"] ] new_game._has_turn_ended = False if d["active_player"] == 1: new_game.current_player = new_game.players[0] new_game.other_player = new_game.players[1] new_game.current_player.opponent = new_game.players[1] new_game.other_player.opponent = new_game.players[0] else: new_game.current_player = new_game.players[1] new_game.other_player = new_game.players[0] new_game.current_player.opponent = new_game.players[0] new_game.other_player.opponent = new_game.players[1] index = 0 for player in new_game.players: player.agent = agents[index] for effect_json in d['players'][index]['effects']: player.add_effect(Effect.from_json(**effect_json)) player.player_auras = [] for aura_json in d['players'][index]['auras']: player.add_aura(AuraUntil.from_json(**aura_json)) player.hero.attach(player.hero, player) if player.weapon: player.weapon.attach(player.weapon, player) for minion in player.minions: minion.attach(minion, player) if minion.health != minion.calculate_max_health(): minion.enraged = True index += 1 return new_game
def create_minion(self, player): create_dict = { 'attack': card_def['attack'], 'health': card_def['health'] } if 'effects' in card_def: create_dict['effects'] = [Effect.from_json(**effect) for effect in card_def['effects']] if 'auras' in card_def: create_dict['auras'] = [Aura.from_json(**aura) for aura in card_def['auras']] if 'buffs' in card_def: create_dict['buffs'] = [Buff.from_json(**buff) for buff in card_def['buffs']] if 'enrage' in card_def: create_dict['enrage'] = Enrage.from_json(**card_def['enrage']) if 'deathrattle' in card_def: create_dict['deathrattle'] = Deathrattle.from_json(**card_def['deathrattle']) return Minion(**create_dict)
def __from_json__(minion, effects=None, auras=None, buffs=None, **kwargs): if effects: minion.effects = [Effect.from_json(**effect) for effect in effects] else: minion.effects = [] if auras: minion.auras = [ AuraUntil.from_json( **aura) if 'until' in aura else Aura.from_json(**aura) for aura in auras ] else: minion.auras = [] if buffs: minion.buffs = [ BuffUntil.from_json( **buff) if 'until' in buff else Buff.from_json(**buff) for buff in buffs ] else: minion.buffs = []
def __from_json__(d, agents): new_game = Game.__new__(Game) new_game._all_cards_played = [] new_game.minion_counter = d["current_sequence_id"] new_game.delayed_minions = set() new_game.game_ended = False new_game.random_func = random.randint new_game.events = {} new_game.players = [Player.__from_json__(pd, new_game, None) for pd in d["players"]] new_game._has_turn_ended = False if d["active_player"] == 1: new_game.current_player = new_game.players[0] new_game.other_player = new_game.players[1] new_game.current_player.opponent = new_game.players[1] new_game.other_player.opponent = new_game.players[0] else: new_game.current_player = new_game.players[1] new_game.other_player = new_game.players[0] new_game.current_player.opponent = new_game.players[0] new_game.other_player.opponent = new_game.players[1] index = 0 for player in new_game.players: player.agent = agents[index] for effect_json in d['players'][index]['effects']: player.add_effect(Effect.from_json(**effect_json)) player.player_auras = [] for aura_json in d['players'][index]['auras']: player.add_aura(AuraUntil.from_json(**aura_json)) player.hero.attach(player.hero, player) if player.hero.weapon: player.hero.weapon.attach(player.hero, player) for minion in player.minions: minion.attach(minion, player) if minion.health != minion.calculate_max_health(): minion.enraged = True minion._do_enrage() index += 1 return new_game
def create_minion(self, player): create_dict = { 'attack': card_def['attack'], 'health': card_def['health'] } if "impl" in card_def: impl = card_def['impl'] if 'effects' in impl: create_dict['effects'] = [Effect.from_json(**effect) for effect in impl['effects']] if 'auras' in impl: create_dict['auras'] = [Aura.from_json(**aura) for aura in impl['auras']] if 'buffs' in impl: create_dict['buffs'] = [Buff.from_json(**buff) for buff in impl['buffs']] if 'enrage' in card_def: create_dict['enrage'] = [Aura.from_json(**enrage) for enrage in card_def['enrage']] if 'deathrattle' in card_def: create_dict['deathrattle'] = [Deathrattle.from_json(**deathrattle) for deathrattle in card_def['deathrattle']] return Minion(**create_dict)
def __from_json__(self, effects): self.effects = [Effect.from_json(**effect) for effect in effects] return self