ちょっと基本的に私は2つの機能を持っています:
void Inventory:: showInventory()
{
char input[80];
cin >> input;
char inventoryRequest[] = "i";
//compare the player input to inventoryRequest (i) to see if they want to
//look at inventory.
int invent = strcmp (input,inventoryRequest);
if(invent == 0) {
//vector<string> inventory;
cout << "You have " << inventory.size() << " items.\n";
cout << "\n******Inventory******";
cout << "\nYour items:\n";
for (int i= 0; i< inventory.size(); ++i) {
cout<< inventory[i] << endl;
}
}
}
void Inventory :: displayInventory(const string str) {
char input = 0;
do
{
cout << str << endl;
cin >> input;
}
while((input != 'i') && (input != 'I') && (input != 'n') && (input != 'N'));
showInventory();
//return input;
}
showInventory はプレーヤーの入力を i と比較します。在庫を表示すると、ユーザーは i または n を押すことができます。i でインベントリを表示し、n でスキップします。しかし、私が押されたとき。二重線の原因となります。
つまり、インベントリを表示するには、i を 2 回押す必要があります。
これが起こらないようにするために、私は多くのことを試みました。しかし、私は成功しておらず、ほとんどの場合、インベントリをまったく表示できません。
誰でもこれで私を助けることができますか?前もって感謝します。