Esempio n. 1
0
    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)))
Esempio n. 2
0
    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)))
Esempio n. 3
0
    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)
Esempio n. 4
0
    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)))
Esempio n. 5
0
    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)