-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpellCasterAtack.cpp
57 lines (46 loc) · 1.39 KB
/
SpellCasterAtack.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// Created by Alex on 09.09.18.
//
#include "SpellCasterAtack.h"
SpellCasterAtack::SpellCasterAtack()
{
bookHlSp = new BookOfHealingSpell();
bookDmSp = new DamageSpellBook();
};
SpellCasterAtack::~SpellCasterAtack()
{
bookHlSp = new BookOfHealingSpell();
bookDmSp = new DamageSpellBook();
}
void SpellCasterAtack::heal(UnitAtack *attackerAtack, UnitState *attackerState, UnitAtack *victimAtack, UnitState *victimState, HealingSpellList spell)
{
if ( attackerState->ensureIsAlive() )
{
int tmpNeedMana = bookHlSp->getNeedMana(spell);
if ( attackerState->getManaReserve() >= tmpNeedMana )
{
victimState->addHp(bookHlSp->getAmountRestoreHp(spell));
attackerState->takeMana(tmpNeedMana);
}
}
}
void SpellCasterAtack::magicAtack(UnitAtack *attackerAtack, UnitState *attackerState, UnitAtack *victimAtack, UnitState *victimState, DamageSpellList spell)
{
if ( attackerState->ensureIsAlive() )
{
int tmpNeedMana = bookDmSp->getNeedMana(spell);
if ( attackerState->getManaReserve() >= tmpNeedMana )
{
victimState->takeMagicDamage(bookDmSp->getDamage(spell));
attackerState->takeMana(tmpNeedMana);
}
}
}
BookOfHealingSpell *SpellCasterAtack::getBookHlSp() const
{
return bookHlSp;
}
DamageSpellBook *SpellCasterAtack::getBookDmSp() const
{
return bookDmSp;
}