Skip to content

Commit

Permalink
WAGE: Implement printPlayerCondition()
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Feb 14, 2016
1 parent 43df45d commit 8769859
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
4 changes: 0 additions & 4 deletions engines/wage/entities.cpp
Expand Up @@ -439,8 +439,4 @@ const char *Chr::getDefiniteArticle(bool capitalize) {
return "";
}

void Chr::printPlayerCondition() {
warning("STUB: printPlayerCondition()");
}

} // End of namespace Wage
1 change: 0 additions & 1 deletion engines/wage/entities.h
Expand Up @@ -222,7 +222,6 @@ class Chr : public Designed {
WeaponArray *getWeapons(bool includeMagic);
ObjArray *getMagicalObjects();
const char *getDefiniteArticle(bool capitalize);
void printPlayerCondition();

public:
bool hasNativeWeapon1() {
Expand Down
33 changes: 32 additions & 1 deletion engines/wage/script.cpp
Expand Up @@ -1039,7 +1039,7 @@ void Script::handleRestCommand() {
_callbacks->_commandWasQuick = true;
} else {
_callbacks->regen();
_world->_player->printPlayerCondition();
printPlayerCondition(_world->_player);
}
}

Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions engines/wage/script.h
Expand Up @@ -191,6 +191,9 @@ class Script {

Common::Array<ScriptText *> _scriptText;
void convertToText();

void printPlayerCondition(Chr *player);
const char *getPercentMessage(double percent);
};

} // End of namespace Wage
Expand Down

0 comments on commit 8769859

Please sign in to comment.