0

この問題を解決する方法がわかりません。呼び出す一致する関数がないと言い続け、引数1の「Npc **」から「Npc *」への既知の変換がないと言い続けます

具体的には、handleDialogueTwo(&nonplayer); に問題があると言っています。and 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";
        }
    }     
}
4

1 に答える 1