<s> """<STR_LIT>""" <EOL> from mockito import mock <EOL> from pyherc . data import Character , cooldown <EOL> from pyherc . data . effects import EffectsCollection <EOL> class CharacterBuilder ( ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> """<STR_LIT>""" <EOL> super ( ) . __init__ ( ) <EOL> self . hit_points = <NUM_LIT:10> <EOL> self . max_hp = <NUM_LIT:10> <EOL> self . spirit = <NUM_LIT:5> <EOL> self . max_spirit = <NUM_LIT:5> <EOL> self . model = mock ( ) <EOL> self . speed = <NUM_LIT:1> <EOL> self . tick = <NUM_LIT:0> <EOL> self . attack = <NUM_LIT:1> <EOL> self . body = <NUM_LIT:1> <EOL> self . mind = <NUM_LIT:1> <EOL> self . finesse = <NUM_LIT:1> <EOL> self . name = '<STR_LIT>' <EOL> self . level = None <EOL> self . location = ( ) <EOL> self . items = [ ] <EOL> self . weapon = None <EOL> self . effect_handles = [ ] <EOL> self . effects = [ ] <EOL> self . effects_collection = EffectsCollection ( ) <EOL> self . player_character = False <EOL> self . listeners = [ ] <EOL> self . update_listeners = [ ] <EOL> self . domains = { } <EOL> self . spell_entries = [ ] <EOL> self . cooldowns = { } <EOL> def as_player_character ( self ) : <EOL> """<STR_LIT>""" <EOL> self . player_character = True <EOL> return self <EOL> def with_model ( self , model ) : <EOL> """<STR_LIT>""" <EOL> self . model = model <EOL> return self <EOL> def with_effect_handle ( self , handle ) : <EOL> """<STR_LIT>""" <EOL> if hasattr ( handle , '<STR_LIT>' ) : <EOL> self . effect_handles . append ( handle . build ( ) ) <EOL> else : <EOL> self . effect_handles . append ( handle ) <EOL> return self <EOL> def with_effect ( self , effect ) : <EOL> """<STR_LIT>""" <EOL> if hasattr ( effect , '<STR_LIT>' ) : <EOL> self . effects . append ( effect . build ( ) ) <EOL> else : <EOL> self . effects . append ( effect ) <EOL> return self <EOL> def with_hit_points ( self , hit_points ) : <EOL> """<STR_LIT>""" <EOL> self . hit_points = hit_points <EOL> return self <EOL> def with_max_hp ( self , max_hp ) : <EOL> """<STR_LIT>""" <EOL> self . max_hp = max_hp <EOL> return self <EOL> def with_spirit ( self , spirit ) : <EOL> """<STR_LIT>""" <EOL> self . spirit = spirit <EOL> return self <EOL> def with_max_spirit ( self , max_spirit ) : <EOL> """<STR_LIT>""" <EOL> self . max_spirit = max_spirit <EOL> return self <EOL> def with_speed ( self , speed ) : <EOL> """<STR_LIT>""" <EOL> self . speed = speed <EOL> return self <EOL> def with_mind ( self , mind ) : <EOL> """<STR_LIT>""" <EOL> self . mind = mind <EOL> return self <EOL> def with_tick ( self , tick ) : <EOL> """<STR_LIT>""" <EOL> self . tick = tick <EOL> return self <EOL> def with_attack ( self , attack ) : <EOL> """<STR_LIT>""" <EOL> self . attack = attack <EOL> return self <EOL> def with_body ( self , body ) : <EOL> """<STR_LIT>""" <EOL> self . body = body <EOL> return self <EOL> def with_level ( self , level ) : <EOL> """<STR_LIT>""" <EOL> self . level = level <EOL> return self <EOL> def with_location ( self , location ) : <EOL> """<STR_LIT>""" <EOL> self . location = location <EOL> return self <EOL> def with_name ( self , name ) : <EOL> """<STR_LIT>""" <EOL> self . name = name <EOL> return self <EOL> def with_event_listener ( self , listener ) : <EOL> """<STR_LIT>""" <EOL> self . listeners . append ( listener ) <EOL> return self <EOL> def with_update_listener ( self , listener ) : <EOL> """<STR_LIT>""" <EOL> self . update_listeners . append ( listener ) <EOL> return self <EOL> def with_item ( self , item ) : <EOL> """<STR_LIT>""" <EOL> if hasattr ( item , '<STR_LIT>' ) : <EOL> self . items . append ( item . build ( ) ) <EOL> else : <EOL> self . items . append ( item ) <EOL> return self <EOL> def with_weapon ( self , weapon ) : <EOL> """<STR_LIT>""" <EOL> if hasattr ( weapon , '<STR_LIT>' ) : <EOL> self . weapon = weapon . build ( ) <EOL> else : <EOL> self . weapon = weapon <EOL> return self <EOL> def with_finesse ( self , finesse ) : <EOL> """<STR_LIT>""" <EOL> self . finesse = finesse <EOL> return self <EOL> def with_domain ( self , domain , level ) : <EOL> """<STR_LIT>""" <EOL> self . domains [ domain ] = level <EOL> return self <EOL> def with_spell_entry ( self , entry ) : <EOL> """<STR_LIT>""" <EOL> self . spell_entries . append ( entry ) <EOL> return self <EOL> def with_cooldown ( self , skill , cooldown ) : <EOL> """<STR_LIT>""" <EOL> self . cooldowns [ skill ] = cooldown <EOL> return self <EOL> def build ( self ) : <EOL> """<STR_LIT>""" <EOL> character = Character ( self . model ) <EOL> if self . player_character : <EOL> self . model . player = character <EOL> character . name = self . name <EOL> character . hit_points = self . hit_points <EOL> character . max_hp = self . max_hp <EOL> character . spirit = self . spirit <EOL> character . max_spirit = self . max_spirit <EOL> character . mind = self . mind <EOL> character . body = self . body <EOL> character . finesse = self . finesse <EOL> character . attack = self . attack <EOL> character . speed = self . speed <EOL> character . tick = self . tick <EOL> character . level = self . level <EOL> character . location = self . location <EOL> character . inventory . weapon = self . weapon <EOL> for item in self . items : <EOL> character . inventory . append ( item ) <EOL> for handle in self . effect_handles : <EOL> character . add_effect_handle ( handle ) <EOL> for effect in self . effects : <EOL> character . add_effect ( effect ) <EOL> for listener in self . listeners : <EOL> character . register_event_listener ( listener ) <EOL> for listener in self . update_listeners : <EOL> character . register_for_updates ( listener ) <EOL> for domain , level in self . domains . items ( ) : <EOL> character . add_domain_level ( domain , level ) <EOL> for entry in self . spell_entries : <EOL> character . add_spell_entry ( entry ) <EOL> for skill , limit in self . cooldowns . items ( ) : <EOL> cooldown ( character , skill , limit ) <EOL> return character </s>
