Need help creating a card game similar to Rock Paper Scissors but with different objectives

Hello,
I seek assistance in creating this game it is similar to RPS(Rock,Paper,Scissors) but with different objectives.
==============================
Card | Beats | Loses To
==============================
Peasants >| Serf >| King
King >| Peasants >| Serf
Serf >| KIng >| Serf
==============================
the player and the Ai are given 5 cards. 4 of which are Peasants. The remaining one is either a King or a Serf, depending on which side the player is playing.

A player can only be on one of the 2 sides in each round. The game starts with determining which side a player is on. The round ends whenever the king or Serf card is played. The objective of the game depends on which side you are on.

If you are on the King side, your goal is to hide your King within the Peasants and play it when you feel the opponent will play the Peasants card.

If you are on the Serf side, your goal is to kill the King. If you fail to predict the opponent’s hand, the Serf will be killed by the Peasants. This denies the opportunity of the Serf side from winning, hence you lose.

this is what I have started

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;

void deckBuilder(vector<string>& deck, int &round)
{
	vector<int> kingNums = { 1, 2, 3, 7, 8, 9 };
	vector<int> serfNums = { 4, 5, 6, 10, 11, 12 };
	int i;
	for (i = 0; i < deck.size(); i++)
	{
		kingNums[i];
		serfNums[i];

	}
	if (kingNums[i] == round)
	{
		deck.push_back("Emperor Card");
		deck.push_back("Citizen Card");
		deck.push_back("Citizen Card");
		deck.push_back("Citizen Card");
		deck.push_back("Citizen Card\n");
	}
	else if (serfNums[i] == round)
	{
		deck.push_back("Slave Card");
		deck.push_back("Citizen Card");
		deck.push_back("Citizen Card");
		deck.push_back("Citizen Card");
		deck.push_back("Citizen Card\n");
	}
}


void printDeck(const vector<string> deck)
{
	for (int i = 0; i < deck.size(); i++)
	{
		cout << " -"<< deck[i] << "\n";
	}
}



void playRound(int &round, int $mmleft, int moneyEarned)
{
	vector<string> deck;
	cout << "Round: " << round << "\n";
	deckBuilder(deck, round);
	printDeck(deck);

}

int main()
{

	srand(unsigned int(time(NULL)));

	int round = 1;
	int mmLeft = 30;
	int moneyEarned = 0;

	
	while (round < 13)
	{

		playRound(round, mmLeft, moneyEarned);
		round++;
	}

	cout << "\n\n";
	return 0;
}
}


my issue is that for some reason the deckBuilder function is NOT doing what wanted it to do.

OUTPUT:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Round: 1
Round: 2
 -Emperor Card
 -Citizen Card
 -Citizen Card
 -Citizen Card
 -Citizen Card

Round: 3
Round: 4
Round: 5
 -Slave Card
 -Citizen Card
 -Citizen Card
 -Citizen Card
 -Citizen Card

Round: 6
Round: 7
Round: 8
Round: 9
Round: 10
Round: 11
Round: 12

i wanted that in a specific round (max round = 12) it should push.back either the King deck or the Serf deck in this in round order(King=1,2,3,7,8,9 Serf=4,5,6,10,11,12) but it doesn't do that, Can you help me out.
Last edited on

Edit... that will go out of bounds... der.. give me a second

1
2
3
4
5
6
int i; 	
for (i = 0; i <6; i++) 	{ 	
	if(kingNums[i]==round || serfNums[i]==round)
             break;
	} 	
if (kingNums[i] == round){//do whatever  


That should work.
Last edited on
the line 13 loop does not do anything at all. What did you want it to do? The if statements after depend on i but are not in the loop.

that aside,
is this what you want (not code, is logic):

bool iskinground[] {1,1,1,0,0,0,1,1,1,0,0,0};
for(int i = 0; i < 12; i++)
{
if(iskinground[i]) ... pushback king deck
else pushback serf deck
}
Last edited on
Thanks Markyrocks, I see where I went wrong.
and
jonnin Thanks for the bool tip, never came to my mind that way.

I think Botched it up, didn't think this through.
I was supposed to print out the deck for one round and let the player pick from it then the function to delete a chosen card from the vector/deck then print it out the updated deck/vector....

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;


void deckBuilder(vector<string>& deck, int &round)
{
	vector<int> kingNums = { 1, 2, 3, 7, 8, 9 };
	vector<int> serfNums = { 4, 5, 6, 10, 11, 12 };
	int i;
	for (i = 0; i < 6; i++)
	{
		if (kingNums[i] == round || serfNums[i] == round)
			break;
	}

	cout << "Round: " << round << "\n========================";
	if (kingNums[i] == round)
	{
		cout << "\nKing Deck:\n";
		deck.push_back("King Card");
		deck.push_back("Peasant Card");
		deck.push_back("Peasant Card");
		deck.push_back("Peasant Card");
		deck.push_back("Peasant Card\n");
	}
}

void printDeck(const vector<string>& deck)
{
	for (int i = 0; i < deck.size(); i++)
	{
		cout << " -" << deck[i] << "\n";
	}
}

void cardDelete(vector<string>& deck, string playerPicked)
{
	int indecated = -1;
	for (int i = 0; i < deck.size(); i++)
	{
		if (playerPicked == deck[i])
		{
			indecated = i;
			break;
		}
	}
	if (indecated > 0)
	{
		deck.erase(deck.begin() + indecated);
	}
}

void playerPlay(vector<string> &deck)
{
	string search;
	cout << "What card would like to play: ";
	cin >> search;
	cardDelete(deck, search);

}

void playRound(int &round, int $mmleft, int moneyEarned)
{
	vector<string> deck;
	deckBuilder(deck, round);
	printDeck(deck);
	playerPlay(deck);
	printDeck(deck);
	system("pause");
}

int main()
{

	srand(unsigned int(time(NULL)));

	int round = 1;


	
	while (round < 13)
	{
		playRound(round);
		round++;
	}

	cout << "\n\n";
	return 0;
}
Topic archived. No new replies allowed.