def setup(self): """ Setup test cases """ self.level = LevelBuilder().build() self.character = (CharacterBuilder() .with_level(self.level) .with_location((5, 5)) .build()) self.spell_generator = SpellGeneratorBuilder().build()
def __call__(self, caster): """ Performs the casting :param caster: character doing the casting :type caster: Character """ add_history_value(caster, 'hit_points') spell_factory = SpellGeneratorBuilder().build() effects_factory = get_effect_creator({ 'heal medium wounds': { 'type': Heal, 'duration': None, 'frequency': None, 'tick': 0, 'healing': 10, 'icon': None, 'title': 'Heal medium wounds', 'description': 'Heals medium amount of damage' }, # noqa 'cause wound': { 'type': DamageEffect, 'duration': None, 'frequency': None, 'tick': 0, 'damage': 5, 'damage_type': 'magic', 'icon': None, 'title': 'Cause minor wound', 'description': 'Causes minor amount of damage' }, # noqa 'fire': { 'type': DamageEffect, 'duration': 30, 'frequency': 5, 'tick': 0, 'damage': 3, 'damage_type': 'fire', 'icon': None, 'title': 'Fire', 'description': 'You are on fire!' } }) spell_casting_factory = ( SpellCastingFactoryBuilder().with_spell_factory( spell_factory).with_effects_factory(effects_factory).build()) set_action_factory(ActionFactoryBuilder().with_spellcasting_factory( spell_casting_factory).build() ) # TODO: mutating global state is bad if self.target: direction = find_direction(caster.location, self.target.location) else: direction = 1 cast(caster, direction=direction, spell_name=self.spell_name)
class TestSpellTargetingSingle(): """ Tests for spells targeting single character """ def __init__(self): """ Default constructor """ super().__init__() self.level = None self.character = None self.spell_generator = None def setup(self): """ Setup test cases """ self.level = LevelBuilder().build() self.character = (CharacterBuilder() .with_level(self.level) .with_location((5, 5)) .build()) self.spell_generator = SpellGeneratorBuilder().build() def test_target_single(self): """ Targeting a single character should be possible """ spell = self.spell_generator.create_spell(spell_name = 'healing wind', targets = [self.character]) assert_that(self.character, is_in(spell.targets))
def setup(self): """ Setup test cases """ self.level = LevelBuilder().build() self.character = CharacterBuilder().with_level(self.level).with_location((5, 5)).build() self.spell_generator = SpellGeneratorBuilder().build()