aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/cpp/Bullet.cpp11
-rw-r--r--src/main/cpp/MeleeWeapon.cpp64
-rw-r--r--src/main/cpp/RangedWeapon.cpp29
-rw-r--r--src/main/cpp/Stick.cpp11
4 files changed, 104 insertions, 11 deletions
diff --git a/src/main/cpp/Bullet.cpp b/src/main/cpp/Bullet.cpp
new file mode 100644
index 0000000..c856213
--- /dev/null
+++ b/src/main/cpp/Bullet.cpp
@@ -0,0 +1,11 @@
+#include "Bullet.hpp"
+
+bool Bullet::decreaseAmount(int qnt)
+{
+ if (_amount >= qnt) {
+ _amount = _amount - qnt;
+ return true;
+ } else {
+ return false;
+ }
+}
diff --git a/src/main/cpp/MeleeWeapon.cpp b/src/main/cpp/MeleeWeapon.cpp
index 92c7632..8c7ffce 100644
--- a/src/main/cpp/MeleeWeapon.cpp
+++ b/src/main/cpp/MeleeWeapon.cpp
@@ -1,15 +1,71 @@
+#include "Weapon.hpp"
#include "MeleeWeapon.hpp"
#include "Actor.hpp"
#include <string>
-MeleeWeapon::MeleeWeapon(Type t, const std::string &name)
-: Weapon(name), type(t)
+MeleeWeapon::MeleeWeapon(Type t, const std::string &name, bool throwable)
+: Weapon(Item::Type::MELEEWEAPON, name), type(t), _throwable(throwable)
{
}
bool MeleeWeapon::use(Actor &user, Actor &actor)
{
- //TODO implement attack probability
- //actor.damage(_damage);
+ //TODO implements attack probability
+ //TODO balance advantages
+ MeleeWeapon* weapon = dynamic_cast <MeleeWeapon*> (user.weapon());
+ int bonus;
+
+ if (MeleeWeapon* enemyWeapon = dynamic_cast <MeleeWeapon*> (actor.weapon())) {
+ switch (weapon->type) {
+ case MeleeWeapon::Type::AXE:
+ switch (enemyWeapon->type) {
+ 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 (enemyWeapon->type) {
+ 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 (enemyWeapon->type) {
+ case MeleeWeapon::Type::AXE:
+ bonus = 10;
+ break;
+ case MeleeWeapon::Type::LANCE:
+ bonus = -10;
+ break;
+ case MeleeWeapon::Type::SWORD:
+ bonus = 0;
+ break;
+ }
+ break;
+ }
+ } else {
+ bonus = 0;
+ }
+
+ if (actor.levelAxe() <= _requiredLevel) {
+ actor.damage(_damage + user.attack() - actor.defence() + bonus);
+ return true;
+ } else {
+ return false;
+ }
}
diff --git a/src/main/cpp/RangedWeapon.cpp b/src/main/cpp/RangedWeapon.cpp
index eb33780..21feae4 100644
--- a/src/main/cpp/RangedWeapon.cpp
+++ b/src/main/cpp/RangedWeapon.cpp
@@ -1,12 +1,9 @@
#include "RangedWeapon.hpp"
#include "Actor.hpp"
-
-#include <string>
-#include <algorithm>
-#include <vector>
+#include "Bullet.hpp"
RangedWeapon::RangedWeapon(const std::string &name)
-: Weapon(name)
+: Weapon(Item::Type::RANGEDWEAPON, name)
{
}
@@ -19,7 +16,25 @@ bool RangedWeapon::use(Actor &user, Actor &actor)
}
}
-void RangedWeapon::reload(Actor &actor)
+bool RangedWeapon::reload(Actor &actor)
{
- //std::vector<Item> bullet = actor.bullet();
+ //TODO add bullet type
+ std::list<Item*> inventory = actor.inventory();
+ for (Item* item : inventory) {
+ if (item->type == Item::Type::BULLET) {
+ //TODO get the bullet
+ //Bullet* bullet = dynamic_cast <Bullet*> (item);
+ break;
+ }
+ }
+
+ /*
+ if (bullet->decreaseAmount(1)) {
+ _charged = true;
+ return true;
+ } else {
+ return false;
+ }
+ */
+
}
diff --git a/src/main/cpp/Stick.cpp b/src/main/cpp/Stick.cpp
new file mode 100644
index 0000000..bc67ccb
--- /dev/null
+++ b/src/main/cpp/Stick.cpp
@@ -0,0 +1,11 @@
+#include "Stick.hpp"
+
+Stick::Stick(const std::string &name, int maxUses) : Item(Item::Type::STICK, name), _maxUses(maxUses)
+{
+ _remainingUses = _maxUses;
+}
+
+bool Stick::use(Actor &user, Actor &actor)
+{
+
+}