<s> import hearthbreaker . game_objects <EOL> __author__ = '<STR_LIT>' <EOL> class Move : <EOL> def __init__ ( self ) : <EOL> super ( ) . __init__ ( ) <EOL> self . random_numbers = [ ] <EOL> def play ( self , game ) : <EOL> pass <EOL> @ staticmethod <EOL> def from_json ( name , random = [ ] , ** json ) : <EOL> cls = None <EOL> if name == '<STR_LIT>' : <EOL> cls = PlayMove <EOL> elif name == '<STR_LIT>' : <EOL> cls = AttackMove <EOL> elif name == '<STR_LIT>' : <EOL> cls = PowerMove <EOL> elif name == '<STR_LIT:end>' : <EOL> cls = TurnEndMove <EOL> elif name == '<STR_LIT:start>' : <EOL> cls = TurnStartMove <EOL> elif name == '<STR_LIT>' : <EOL> cls = ConcedeMove <EOL> obj = cls . __new__ ( cls ) <EOL> cls . __from_json__ ( obj , ** json ) <EOL> obj . random_numbers = [ ] <EOL> for num in random : <EOL> if isinstance ( num , dict ) : <EOL> obj . random_numbers . append ( hearthbreaker . proxies . ProxyCharacter . from_json ( ** num ) ) <EOL> else : <EOL> obj . random_numbers . append ( num ) <EOL> return obj <EOL> def __to_json__ ( self ) : <EOL> pass <EOL> def __update_json__ ( self , json ) : <EOL> if len ( self . random_numbers ) > <NUM_LIT:0> : <EOL> json . update ( { <EOL> '<STR_LIT>' : self . random_numbers <EOL> } ) <EOL> return json <EOL> class PlayMove ( Move ) : <EOL> def __init__ ( self , card , index = - <NUM_LIT:1> , target = None ) : <EOL> super ( ) . __init__ ( ) <EOL> self . card = card <EOL> self . index = index <EOL> if target is not None : <EOL> self . target = hearthbreaker . proxies . ProxyCharacter ( target ) <EOL> else : <EOL> self . target = None <EOL> def play ( self , game ) : <EOL> if self . target is not None : <EOL> game . current_player . agent . next_target = self . target . resolve ( game ) <EOL> game . current_player . agent . next_index = self . index <EOL> game . play_card ( self . card . resolve ( game ) ) <EOL> game . current_player . agent . nextIndex = - <NUM_LIT:1> <EOL> def to_output_string ( self ) : <EOL> if self . index > - <NUM_LIT:1> : <EOL> if self . target is not None : <EOL> return '<STR_LIT>' . format ( self . card . to_output ( ) , self . index , self . target . to_output ( ) ) <EOL> return '<STR_LIT>' . format ( self . card . to_output ( ) , self . index ) <EOL> else : <EOL> if self . target is not None : <EOL> return '<STR_LIT>' . format ( self . card . to_output ( ) , self . target . to_output ( ) ) <EOL> return '<STR_LIT>' . format ( self . card . to_output ( ) ) <EOL> def __to_json__ ( self ) : <EOL> if self . target is not None : <EOL> if self . index > - <NUM_LIT:1> : <EOL> json = { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . card , <EOL> '<STR_LIT:index>' : self . index , <EOL> '<STR_LIT:target>' : self . target , <EOL> } <EOL> else : <EOL> json = { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . card , <EOL> '<STR_LIT:target>' : self . target , <EOL> } <EOL> else : <EOL> if self . index > - <NUM_LIT:1> : <EOL> json = { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . card , <EOL> '<STR_LIT:index>' : self . index , <EOL> } <EOL> else : <EOL> json = { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . card , <EOL> } <EOL> return self . __update_json__ ( json ) <EOL> def __from_json__ ( self , card , index = - <NUM_LIT:1> , target = None ) : <EOL> self . card = hearthbreaker . proxies . ProxyCard . from_json ( ** card ) <EOL> self . index = index <EOL> if target : <EOL> self . target = hearthbreaker . proxies . ProxyCharacter . from_json ( ** target ) <EOL> else : <EOL> self . target = None <EOL> class AttackMove ( Move ) : <EOL> def __init__ ( self , character , target ) : <EOL> super ( ) . __init__ ( ) <EOL> self . character = hearthbreaker . proxies . ProxyCharacter ( character ) <EOL> self . target = hearthbreaker . proxies . ProxyCharacter ( target ) <EOL> def to_output_string ( self ) : <EOL> return '<STR_LIT>' . format ( self . character . to_output ( ) , self . target . to_output ( ) ) <EOL> def play ( self , game ) : <EOL> game . current_player . agent . next_target = self . target . resolve ( game ) <EOL> self . character . resolve ( game ) . attack ( ) <EOL> game . current_player . agent . next_target = None <EOL> def __to_json__ ( self ) : <EOL> return self . __update_json__ ( { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . character , <EOL> '<STR_LIT:target>' : self . target , <EOL> } ) <EOL> def __from_json__ ( self , character , target ) : <EOL> self . character = hearthbreaker . proxies . ProxyCharacter . from_json ( ** character ) <EOL> self . target = hearthbreaker . proxies . ProxyCharacter . from_json ( ** target ) <EOL> class PowerMove ( Move ) : <EOL> def __init__ ( self , target = None ) : <EOL> super ( ) . __init__ ( ) <EOL> self . target = target <EOL> if target is not None : <EOL> self . target = hearthbreaker . proxies . ProxyCharacter ( target ) <EOL> else : <EOL> self . target = None <EOL> def to_output_string ( self ) : <EOL> if self . target is not None : <EOL> return '<STR_LIT>' . format ( self . target . to_output ( ) ) <EOL> else : <EOL> return '<STR_LIT>' <EOL> def play ( self , game ) : <EOL> if self . target is not None : <EOL> game . current_player . agent . next_target = self . target . resolve ( game ) <EOL> game . current_player . hero . power . use ( ) <EOL> game . current_player . agent . next_target = None <EOL> def __to_json__ ( self ) : <EOL> if self . target : <EOL> json = { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT:target>' : self . target , <EOL> } <EOL> else : <EOL> json = { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> } <EOL> return self . __update_json__ ( json ) <EOL> def __from_json__ ( self , target = None ) : <EOL> if target is not None : <EOL> self . target = hearthbreaker . proxies . ProxyCharacter . from_json ( ** target ) <EOL> else : <EOL> self . target = None <EOL> class TurnEndMove ( Move ) : <EOL> def __init__ ( self ) : <EOL> super ( ) . __init__ ( ) <EOL> pass <EOL> def to_output_string ( self ) : <EOL> return '<STR_LIT>' <EOL> def play ( self , game ) : <EOL> pass <EOL> def __to_json__ ( self ) : <EOL> return self . __update_json__ ( { <EOL> '<STR_LIT:name>' : '<STR_LIT:end>' , <EOL> } ) <EOL> def __from_json__ ( self ) : <EOL> pass <EOL> class TurnStartMove ( Move ) : <EOL> def __init__ ( self ) : <EOL> super ( ) . __init__ ( ) <EOL> def to_output_string ( self ) : <EOL> return '<STR_LIT>' <EOL> def play ( self , game ) : <EOL> pass <EOL> def __to_json__ ( self ) : <EOL> return self . __update_json__ ( { <EOL> '<STR_LIT:name>' : '<STR_LIT:start>' , <EOL> } ) <EOL> def __from_json__ ( self ) : <EOL> pass <EOL> class ConcedeMove ( Move ) : <EOL> def __init__ ( self ) : <EOL> super ( ) . __init__ ( ) <EOL> def to_output_string ( self ) : <EOL> return "<STR_LIT>" <EOL> def play ( self , game ) : <EOL> game . current_player . hero . die ( None ) <EOL> game . current_player . hero . activate_delayed ( ) <EOL> def __to_json__ ( self ) : <EOL> return self . __update_json__ ( { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> } ) <EOL> def __from_json__ ( self ) : <EOL> pass </s>
