diff options
Diffstat (limited to 'frontend/Player.cpp')
-rw-r--r-- | frontend/Player.cpp | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/frontend/Player.cpp b/frontend/Player.cpp deleted file mode 100644 index fdd2dc3..0000000 --- a/frontend/Player.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "GameData.h" -#include "strings.h" -#include "Player.h" - -#include "backend/WeaponObject.h" -#include "backend/Dungeon.h" - -using namespace std; - -Player::Player(Dungeon & dungeon) : - dungeon(dungeon), - location(*dungeon.get_start_location()) - { - cmdset_default(); - this->weapon = unique_ptr<WeaponObject>(static_cast<WeaponObject *>(GameData::get_instance().create_object("Dolk"))); -} - -void Player::cmdset_default() { - this->cmds["Kijk"] = &Player::cmd_query; - this->cmds["Zoek"] = &Player::cmd_search; - this->cmds["Ga"] = &Player::cmd_go; - this->cmds["Pak"] = &Player::cmd_get; - this->cmds["Leg"] = &Player::cmd_put; - this->cmds["Bekijk"] = &Player::cmd_view; - this->cmds["Sla"] = &Player::cmd_hit; - this->cmds["Draag"] = &Player::cmd_equip; - this->cmds["Wacht"] = &Player::cmd_wait; - this->cmds["Consumeer"] = &Player::cmd_use; - this->cmds["Help"] = &Player::cmd_help; - this->cmds["Godmode"] = &Player::cmd_cheat; - this->cmds["Quit"] = &Player::cmd_quit; -} - -void Player::cmdset_death() { - this->cmds["Help"] = &Player::cmd_help; - this->cmds["Quit"] = &Player::cmd_quit; - this->cmds["Opnieuw"] = &Player::cmd_restart; -} - -FollowupAction Player::cmd(string & argv) { - if (argv.size() == 0) return FollowupAction::NONE; - string cmd = str_title(str_consume_arg(argv)); - - if (this->cmds.contains(cmd)) - return (this->*cmds.at(cmd))(argv); - - str_print(strings::UNKNOWN_CMD); - - return FollowupAction::NONE; -} - -float Player::get_attack() const { - if (this->cheating) return 1.f; - return this->attack_chance; -} - -unsigned Player::get_health() const { - return this->health_points; -} - -void Player::take_damage(unsigned int dmg) { - if (this->cheating) return; - - dmg = min(dmg, this->health_points); - this->health_points -= dmg; - - if (this->health_points == 0) { - this->cmdset_death(); - } -} - -Location & Player::get_location() const { - return this->location; -} - |