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 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)))
def test_spell_is_cast(self): """ When spell casting action is executed, the linked spell should be cast """ spell = mock(Spell) spell.spirit = 2 caster = CharacterBuilder().with_spirit(10).build() effects_factory = mock() action = SpellCastingAction(caster=caster, spell=spell, effects_factory=effects_factory) action.execute() verify(spell).cast(effects_factory=effects_factory)
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)))
def test_spell_is_cast(self): """ When spell casting action is executed, the linked spell should be cast """ spell = mock(Spell) spell.spirit = 2 caster = (CharacterBuilder() .with_spirit(10) .build()) effects_factory = mock() action = SpellCastingAction(caster = caster, spell = spell, effects_factory = effects_factory) action.execute() verify(spell).cast(effects_factory = effects_factory)
def get_action(self, parameters): """ Create a spell casting action :param parameters: parameters used to control creation :type parameters: SpellCastingParameters """ spell = self.spell_factory.create_spell( spell_name=parameters.spell_name, targets=self._get_spell_targets(parameters)) return SpellCastingAction(caster=parameters.caster, spell=spell, effects_factory=self.effects_factory)