diff --git a/main.cpp b/main.cpp index c503b3f..22d226e 100644 --- a/main.cpp +++ b/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(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 , drop , eat if (!commandOk) { std::vector words = split(commandBuffer);