From 07796bea15a2d5f43766f062379b63fc9e9e1b5d Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 1 Nov 2024 22:47:42 +0100 Subject: WIP consumables --- backend/Player.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'backend/Player.cpp') diff --git a/backend/Player.cpp b/backend/Player.cpp index 2de5632..5e3e030 100644 --- a/backend/Player.cpp +++ b/backend/Player.cpp @@ -43,6 +43,7 @@ Location & Player::get_location() const { } void Player::set_location(Location & location) { this->location = &location; + lprtf("Je staat nu bij de locatie %s.\n", location.get_name().c_str()); } void Player::equip(WeaponObject * weapon) { @@ -69,3 +70,20 @@ void Player::equip(ArmorObject * armor) { lprtf("doet %s aan.\n", this->armor->get_name().c_str()); } +void Player::add_health(unsigned int bonus) { + if (this->is_dead()) return; + this->health_points += bonus; + lprtf("Je hebt %d levenspunt%s erbij gekregen.\n", bonus, bonus == 1 ? "" : "en"); +} + +void Player::add_attack(float bonus) { + float max_bonus = 0.90f - this->attack_chance; + if (max_bonus < 0.f) { + lprtf("Je aanvalskans is niet verder verhoogd.\n"); + return; + } + bonus = min(max_bonus, bonus); + this->attack_chance += bonus; + lprtf("Je aanvalskans is verhoogd met %.1f%%.\n", bonus * 100); +} + -- cgit v1.2.3