def __from_json__(self, auras): 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__(self, auras): 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__(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__(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 __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 __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