我已经搜索过这个错误,但似乎没有人和我有同样的问题。我正在尝试用 C++ 制作一个基于文本的基本 RPG 游戏来学习,我希望用户能够输入他们想要做的事情,例如,如果他们输入ATTACK
他们会攻击怪物,但我的 if 语句:
if((current_move == "ATTACK") || (current_move == "attack"))
返回假!
下面是完整的功能:
while(monster_health > 0)
{
std::cin >> current_move;
std::cout << current_move;
if((current_move == "ATTACK") || (current_move == "attack"))
{
std::cout << "You attacked the monster!\n";
double damage = return_level(xp) * 1.2;
std::cout << "You did " << damage << " damage!\n";
monster_health -= damage;
if(monster_health < 0)
{
monster_health = 0;
break_out = true;
}
}
else if(current_move == "FLEE")
{
std::cout << "You ran away...\n";
break_out = true;
}
else
{
std::cout << "Sorry, I didn't understand, what will you do? ATTACK or FLEE?\n";
}
}
我只是不断收到“对不起,我不明白”的消息;
请让我知道任何其他错误或不良做法,因为我才刚刚开始学习:)