def test_casting_spell_raises_spirit_changed_event(self): """ Since casting spells uses spirit, an appropriate event should be raised """ spell = (SpellBuilder() .with_spirit(10) .build()) caster = (CharacterBuilder() .with_spirit(20) .build()) listener = EventListener() caster.register_for_updates(listener) effects_factory = mock() action = SpellCastingAction(caster = caster, spell = spell, effects_factory = effects_factory) action.execute() events = [event for event in listener.events if e_event_type(event) == 'spirit points changed'] assert_that(len(events), is_(equal_to(1)))
def setup(self): """ Setup test cases """ self.character = (CharacterBuilder() .with_hit_points(10) .with_max_hp(20) .build()) effect_config = {'healing wind': {'type': Heal, 'duration': 0, 'frequency': 0, 'tick': 0, 'healing': 1, 'icon': 'icon', 'title': 'Cure minor wounds', 'description': 'Cures small amount of damage'}} self.effects = get_effect_creator(effect_config) self.effect_handle = EffectHandle(trigger = 'on spell hit', effect = 'healing wind', parameters = {}, charges = 1) self.spell = (SpellBuilder() .with_effect_handle(self.effect_handle) .with_target(self.character) .build())
def test_casting_spell_uses_spirit(self): """ Casting a spell should use spirit energy """ spell = (SpellBuilder() .with_spirit(10) .build()) caster = (CharacterBuilder() .with_spirit(20) .build()) effects_factory = mock() action = SpellCastingAction(caster = caster, spell = spell, effects_factory = effects_factory) action.execute() assert_that(caster.spirit, is_(equal_to(10)))