blob: c2bb4469b75ec53d17447fef60ac86df35d9a178 (
plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#include "Weapon.hpp"
#include "MeleeWeapon.hpp"
#include "Actor.hpp"
#include <string>
#include <stdexcept>
MeleeWeapon::MeleeWeapon(Weapon::Class weaponClass, const std::string &name, bool throwable)
: Weapon(Item::Type::MELEEWEAPON, weaponClass, name), _throwable(throwable)
{
if (!(weaponClass == Weapon::Class::SWORD
|| weaponClass == Weapon::Class::AXE
|| weaponClass == Weapon::Class::LANCE)) {
throw std::invalid_argument("Invalid class type for MeleeWeapon");
}
}
bool MeleeWeapon::use(Actor &user, Actor &actor)
{
//TODO implements attack probability
//TODO balance advantages
int bonus = 0;
MeleeWeapon *userWeapon = dynamic_cast<MeleeWeapon*>(user.weapon());
// MeleeWeapon *actorWeapon = dynamic_cast<MeleeWeapon*>(actor.weapon());
if (userWeapon == nullptr) {
return false;
}
// if (user.skill(userWeapon->weaponClass) <= _requiredLevel) {
// return false;
// }
/*
if (actorWeapon != nullptr) {
switch (userWeapon->weaponType) {
case MeleeWeapon::Type::AXE:
switch (actorWeapon->weaponType) {
case MeleeWeapon::Type::AXE:
bonus = 0;
break;
case MeleeWeapon::Type::LANCE:
bonus = 10;
break;
case MeleeWeapon::Type::SWORD:
bonus = -10;
break;
}
break;
case MeleeWeapon::Type::LANCE:
switch (actorWeapon->weaponType) {
case MeleeWeapon::Type::AXE:
bonus = -10;
break;
case MeleeWeapon::Type::LANCE:
bonus = 0;
break;
case MeleeWeapon::Type::SWORD:
bonus = 10;
break;
}
break;
case MeleeWeapon::Type::SWORD:
switch (actorWeapon->weaponType) {
case MeleeWeapon::Type::AXE:
bonus = 10;
break;
case MeleeWeapon::Type::LANCE:
bonus = -10;
break;
case MeleeWeapon::Type::SWORD:
bonus = 0;
break;
}
break;
}
}
*/
actor.damage(_damage
+ user.stat(Actor::Stat::ATTACK)
- actor.stat(Actor::Stat::DEFENCE) + bonus
);
return true;
}
|