optimize adjust wrapOut for hp
This commit is contained in:
parent
019cac44c6
commit
30ff3004a5
19
main.cpp
19
main.cpp
@ -232,13 +232,20 @@ void gameLoop() {
|
||||
break;
|
||||
}
|
||||
|
||||
wrapOut("Current HP: " + std::to_string(currentState->getHP()));
|
||||
wrapEndPara();
|
||||
|
||||
/* The first word of a command would normally be the verb. The first word is the text before the first
|
||||
* space, or if there is no space, the whole string. */
|
||||
auto endOfVerb = static_cast<uint8_t>(commandBuffer.find(' '));
|
||||
|
||||
if (commandBuffer.compare(0, endOfVerb, "hp") == 0) {
|
||||
wrapOut("Current HP: " + std::to_string(currentState->getHP()));
|
||||
wrapEndPara();
|
||||
commandOk = true;
|
||||
} else {
|
||||
wrapOut("Current HP: " + std::to_string(currentState->getHP()));
|
||||
wrapEndPara();
|
||||
}
|
||||
|
||||
|
||||
/* We could copy the verb to another string but there's no reason to, we'll just compare it in place. */
|
||||
/* Command to go north. */
|
||||
if ((commandBuffer.compare(0, endOfVerb, "north") == 0) || (commandBuffer.compare(0, endOfVerb, "n") == 0)) {
|
||||
@ -297,12 +304,6 @@ void gameLoop() {
|
||||
}
|
||||
}
|
||||
|
||||
if (commandBuffer.compare(0, endOfVerb, "hp") == 0) {
|
||||
wrapOut("Current HP: " + std::to_string(currentState->getHP()));
|
||||
wrapEndPara();
|
||||
commandOk = true;
|
||||
}
|
||||
|
||||
// check get <keyword>, drop <keyword>, eat <keyword>
|
||||
if (!commandOk) {
|
||||
std::vector<std::string> words = split(commandBuffer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user