too few arguments to function `std::string player1(std::string, int, int, int, std::s
Hi!
I got this code:
Code:
#include <cstdlib>
#include <iostream>
using namespace std;
string newgame();
void help();
string makeplayers(string n1, int s1, string n2, int s2);
string player1(string name, int money, int army, int level, string name2, int money2, int army2, int level2);
string player2(string name, int money, int army, int level, string name2, int money2, int army2, int level2);
int main()
{
string choose;
cout << "Hi! Welcome to Conq. Conq is a multiplayer game.\n";
cout << "[N]ew game - [H]elp - [E]xit | ";
cin >> choose;
if (choose == "n" || choose == "N") {
newgame();
}
if (choose == "h" || choose == "H") {
help();
cin.get();
}
if (choose == "e" || choose == "E") {
}
}
string newgame()
{
// Player 1
string name;
int sort;
// Player 2
string name2;
int sort2;
// Player 1's name and type
cout << "\n\nPlayer 1\n";
cout << "Name: ";
cin >> name;
cout << "Type: ";
cin >> sort;
cout << "\n\nPlayer 2\nName: ";
cin >> name2;
cout << "Type: ";
cin >> sort2;
makeplayers(name, sort, name2, sort2);
cin.get();
}
void help()
{
cout << "\n\nThere are 2 different types.\n1. Money\n2. Army\nMoney:If you choose money, you will get more money but less armies.Army:\nIf you choose army, you will get more armies but less money.\n\n";
cin.get();
}
string makeplayers(string n1, int s1, string n2, int s2)
{
// Player 1 (n1)
int army;
int money;
int level;
// Player 2 (n2)
int army2;
int money2;
int level2;
// Define Player 1's settings
if (s1 == 1) {
money = 400;
army = 5;
} else {
money = 200;
army = 10;
}
level = 0;
// Define Player 2's settings
if (s2 == 1) {
money2 = 400;
army2 = 5;
} else {
money2 = 200;
army2 = 10;
}
level2 = 0;
// Player 1's turn
player1(n1, money, army, level);
}
string player1(string name, int money, int army, int level, string name2, int money2, int army2, int level2)
{
string doo;
string buy;
int moess;
cout << "\n-------------------\n" << name << "'s turn\nMoney: " << money << "\nArmy: " << army << "\nLevel: " << level << "\n";
cout << "\nWhat do you want to do?\n[A]ttack - [G]ather money - [B]uy troops | ";
cin >> doo;
if (doo == "a" || doo == "A") {
if (army > army2) {
army = army-1;
army2 = army2-2;
cout << "You've now got " << army << " troop(s)\n";
cout << name2 << " now got " << army2 << " troop(s)\n\n";
player2(name, money, army, level, name2, money2, army2, level2);
} else {
army = army-2;
army2 = army2-1;
cout << "You've now got " << army << " troop(s)\n";
cout << name2 << " now got " << army2 << " troop(s)\n\n";
player2(name, money, army, level, name2, money2, army2, level2);
}
}
if (doo == "g" || doo == "G") {
money = money + 20;
cout << "You've gathered 20 money!\n\n";
player2(name, money, army, level, name2, money2, army2, level2);
}
if (doo == "b" || doo == "B") {
cout << "1 troop = 40\n5 troops = 200\nHow many do you want to buy? ";
cin >> buy;
moess = buy*40;
if (moess <= money) {
cout << "You've bought " << buy << " troop(s)!\n\n";
player2(name, money, army, level, name2, money2, army2, level2);
} else {
cout << "You cannot buy " << buy << " troop(s)!\n\n";
player2(name, money, army, level, name2, money2, army2, level2);
}
}
}
string player2(string name, int money, int army, int level, string name2, int money2, int army2, int level2)
{
string doo;
string buy;
int moess;
cout << "\n-------------------\n" << name << "'s turn\nMoney: " << money2 << "\nArmy: " << army2 << "\nLevel: " << level2 << "\n";
cout << "\nWhat do you want to do?\n[A]ttack - [G]ather money - [B]uy troops | ";
cin >> doo;
if (doo == "a" || doo == "A") {
if (army2 > army) {
army = army-1;
army2 = army2-2;
cout << "You've now got " << army2 << " troop(s)\n";
cout << name << " now got " << army << " troop(s)\n\n";
player2(name, money, army, level, name2, money2, army2, level2);
} else {
army = army-2;
army2 = army2-1;
cout << "You've now got " << army2 << " troop(s)\n";
cout << name << " now got " << army << " troop(s)\n\n";
player2(name, money, army, level, name2, money2, army2, level2);
}
}
if (doo == "g" || doo == "G") {
money2 = money2 + 20;
cout << "You've gathered 20 money!\n\n";
player2(name, money, army, level, name2, money2, army2, level2);
}
if (doo == "b" || doo == "B") {
cout << "1 troop = 40\n5 troops = 200\nHow many do you want to buy? ";
cin >> buy;
moess = buy*40;
if (moess <= money2) {
cout << "You've bought " << buy << " troop(s)!\n\n";
player2(name, money, army, level, name2, money2, army2, level2);
} else {
cout << "You cannot buy " << buy << " troop(s)!\n\n";
player2(name, money, army, level, name2, money2, army2, level2);
}
}
}
And i'm getting errors. Why? Test to compile it!