Hi all,
I am making a text game in c++ and i am trying to get the player's attack to ba a random number between 1 and 7, but when i try to compile it, it gives me this error:
49 C:\Documents and Settings\Games\Desktop\C++ Tutorial\Combat\main.cpp void value not ignored as it ought to be
heres the code:
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
class Badguy {
private:
int health, defense, damage;
char name;
public:
Badguy();
friend class Player;
friend void damageCalc(Badguy Brutus, Player Popeye);
};
class Player {
private:
string name;
int attack, attack1, attack2, attack3;
public:
Player ();
friend void damageCalc(Badguy Brutus, Player Popeye);
};
void damageCalc(Badguy Brutus, Player Popeye){
Brutus.damage = Popeye.attack - Brutus.defense;
if (Brutus.damage > Brutus.defense) {
cout << "You damaged the orc!" << endl;
Brutus.health -= Brutus.damage;
cout << "The orc's health is: " << Brutus.health << endl;
}
else if (Brutus.damage < Brutus.defense) {
cout << "You did'nt do any damage..." << endl;
}
}
Badguy::Badguy(){
health = 100;
defense = 3;
};
Player::Player(){
name = "Tom";
attack1 = 1; //
attack2 = 7; //
attack3 = random_shuffle(attack1, attack2); //Here is the part i am talking about
attack = attack3; //
};
int main() {
int loop = 1;
string choice;
Player p;
Badguy b;
cout << "Do you want to attack the orc:";
getline (cin, choice);
while (loop == 1){
if (choice == "yes"){
damageCalc(b,p);
cout << "Do you want to attack again:";
getline(cin, choice);
}
else if (choice == "no"){
loop = 0;
}
}
}
Any ideas?