From 87698593db098cd906a5b8f7f19eb7f6db5a6e7a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 16 Jan 2016 13:42:32 +0100 Subject: [PATCH] WAGE: Implement printPlayerCondition() --- engines/wage/entities.cpp | 4 ---- engines/wage/entities.h | 1 - engines/wage/script.cpp | 33 ++++++++++++++++++++++++++++++++- engines/wage/script.h | 3 +++ 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp index e229daf2fb48..7f40353ba8b1 100644 --- a/engines/wage/entities.cpp +++ b/engines/wage/entities.cpp @@ -439,8 +439,4 @@ const char *Chr::getDefiniteArticle(bool capitalize) { return ""; } -void Chr::printPlayerCondition() { - warning("STUB: printPlayerCondition()"); -} - } // End of namespace Wage diff --git a/engines/wage/entities.h b/engines/wage/entities.h index 0a3fa28e9fc7..6a97abf39ea0 100644 --- a/engines/wage/entities.h +++ b/engines/wage/entities.h @@ -222,7 +222,6 @@ class Chr : public Designed { WeaponArray *getWeapons(bool includeMagic); ObjArray *getMagicalObjects(); const char *getDefiniteArticle(bool capitalize); - void printPlayerCondition(); public: bool hasNativeWeapon1() { diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp index 0b38f3757962..c4567a55dfb7 100644 --- a/engines/wage/script.cpp +++ b/engines/wage/script.cpp @@ -1039,7 +1039,7 @@ void Script::handleRestCommand() { _callbacks->_commandWasQuick = true; } else { _callbacks->regen(); - _world->_player->printPlayerCondition(); + printPlayerCondition(_world->_player); } } @@ -1282,4 +1282,35 @@ void Script::convertToText() { delete scr; } +const char *Script::getPercentMessage(double percent) { + if (percent < 0.40) { + return "very bad"; + } else if (percent < 0.55) { + return "bad"; + } else if (percent < 0.70) { + return "average"; + } else if (percent < 0.85) { + return "good"; + } else if (percent <= 1.00) { + return "very good"; + } else { + return "enhanced"; + } +} + +void Script::printPlayerCondition(Chr *player) { + double physicalPercent = (double)player->_context._statVariables[PHYS_HIT_CUR] / player->_context._statVariables[PHYS_HIT_BAS]; + double spiritualPercent = (double)player->_context._statVariables[SPIR_HIT_CUR] / player->_context._statVariables[SPIR_HIT_BAS]; + + Common::String msg = "Your physical condition is "; + msg += getPercentMessage(physicalPercent); + msg += "."; + appendText(msg); + + msg = "Your spiritual condition is "; + msg += getPercentMessage(spiritualPercent); + msg += "."; + appendText(msg); +} + } // End of namespace Wage diff --git a/engines/wage/script.h b/engines/wage/script.h index 529efa8bf4c0..ed2772568ffb 100644 --- a/engines/wage/script.h +++ b/engines/wage/script.h @@ -191,6 +191,9 @@ class Script { Common::Array _scriptText; void convertToText(); + + void printPlayerCondition(Chr *player); + const char *getPercentMessage(double percent); }; } // End of namespace Wage