我不知道你如何解决这个问题。它一直告诉我我没有要调用的匹配函数,并且一直说参数 1 从 'Npc**' 到 'Npc* 没有已知的转换
具体来说,它是说 handleDialogueTwo(&nonplayer); 存在问题 和handleDialogueThree(&nonplayer);
我敢肯定这是一个愚蠢的解决方案,但我一直在摸索它,并且现在已经有好几个小时了。请帮忙
void Dungeon::handleRoomWithNpc(Room * room) {
Npc nonplayer = room->nonplayer.front();
cout << "Inside, you see a " << nonplayer.name << ".\n";
string actions[] = {
"a: Talk to " + nonplayer.name,
"b: Fight " + nonplayer.name,
"c: Leave",
};
while(true) {
printActions(3, actions);
string input;
cin >> input;
if (input == "a") {
handleDialogueOne(&nonplayer);
return;
} else if (input == "b") {
int damage = player.takeDamage(nonplayer.attack);
cout << nonplayer.name << " hits you for " << damage << " damage! \n";
if (player.checkIsDead()){
return;
};
} else if (input == "c") {
player.changeRooms(player.previousRoom);
enterRoom(player.currentRoom);
return;
} else {
cout << "Wrongo, Bucko.\n";
}
}
}
void Dungeon::handleDialogueOne(Npc * nonplayer) {
cout << nonplayer->dialogueOne;
string actions[] = {
"a: continue",
"b: die",
"c: fight",
};
while(true) {
printActions(3, actions);
string input;
cin >> input;
if (input == "a") {
handleDialogueTwo(&nonplayer);
return;
} else if (input == "b") {
int damage = player.takeDamage(nonplayer->attack);
cout << nonplayer->name << " hits you for " << damage << " damage! \n";
if (player.checkIsDead()){
return;
}
} else if (input == "c") {
int damage = player.takeDamage(nonplayer->attack);
cout << nonplayer->name << " hits you for " << damage << " damage! \n";
if (player.checkIsDead()){
return;
};
} else {
cout << "Wrongo, Bucko!\n";
}
}
}
void Dungeon::handleDialogueTwo(Npc * nonplayer) {
cout << nonplayer->dialogueTwo;
string actions[] = {
"a: continue",
"b: die",
"c: fight",
};
while(true) {
printActions(3, actions);
string input;
cin >> input;
if (input == "a") {
handleDialogueThree(&nonplayer);
return;
} else if (input == "b") {
int damage = player.takeDamage(nonplayer->attack);
cout << nonplayer->name << " hits you for " << damage << " damage! \n";
if (player.checkIsDead()){
return;
}
} else if (input == "c") {
int damage = player.takeDamage(nonplayer->attack);
cout << nonplayer->name << " hits you for " << damage << " damage! \n";
if (player.checkIsDead()){
return;
};
} else {
cout << "Wrongo, Bucko!\n";
}
}
}
void Dungeon::handleDialogueThree(Npc * nonplayer) {
cout << nonplayer->dialogueThree;
string actions[] = {
"a: continue",
"b: die",
"c: win",
};
while(true) {
printActions(3, actions);
string input;
cin >> input;
if (input == "a") {
handleDialogueTwo(&nonplayer);
return;
} else if (input == "b") {
int damage = player.takeDamage(nonplayer->attack);
cout << nonplayer->name << " hits you for " << damage << " damage! \n";
if (player.checkIsDead()){
return;
};
} else if (input == "c") {
nonplayer->currentHealth = 0;
return;
} else {
cout << "Wrongo, Bucko!\n";
}
}
}