I am making a command-line game (if that makes any sense). I currently have it to where if you make the move "DEBUG", it will call an enemy attack. However, the attack announcement isn't showing up.
After picking a difficulty from 1-5, the getPlayerChoice() function is correctly called. However, selecting the DEBUG option isn't running the attack() function properly. Is there something wrong with converting the input to uppercase (calling the uppercase() function on the string)? Is there something wrong with the attack() function itself?
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <algorithm>
#include <locale>
usingnamespace std;
int IRand(int ir_min,int ir_max)
{
{
int ir_res = ir_min+(rand() % (ir_max-ir_min));
return ir_res;
}
}
void attack(string bot,string wpn,int damage,int rate,int accuracy,string wpn2 = "",int rate2 = 0)
{
cout << bot << " attacks with " << wpn << "!\n";
//TODO factor in difficulty
int acc = 8; //TODO add a real formula that makes sense
}
void getPlayerChoice()
{
cout << "What would you like to do?\n";
string act;
cin >> act;
if (act == "debug")
{
attack("TestBot","Laser Lvl. 1",4,4,5);
}
}
int main()
{
srand(time(0));
int diff = 0;
while (diff < 1 || diff > 5)
{
cout << "Please select difficulty, from 1 (Trainee) to 5 (Insane):\n";
cin >> diff;
if (diff < 1 || diff > 5)
cout << "Invalid difficulty! ";
}
getPlayerChoice();
}
I now want to know if there is a way to do what I was trying to do. I found a method earlier, but it appears to only work when printing - basically that "G" thing you found for each letter.