BlackJack Scoring

A buddy and I have been working together to try and create a blackjack game for a project we are doing, and while we have a couple of issues we are trying to get worked out, for some reason we are perplexed as to how we can keep score.
Right now, it keeps score but it doesn't reset when it adds a card. So if you had 14 and you hit, and added 3; you would have 31 instead of 17.
Any help to point us in the right direction would be appreciated, I'm a complete C++ noob.

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
// initialize players and hands
	srand(static_cast<unsigned int>(time(0)));
	GetPlayerInfo(players);

	do
	{
		int score = 0;
		bool busted = (score > 21);
		ShuffledDeck(deck);
		DealHands(deck, players, 2);
		// show the cards
		cout << players[0].id << ":\n";
		for (unsigned int i = 0; i < players[0].hand.size(); ++i)
		{
			WriteCard(players[0].hand[i]);
			cout << endl;
			score += Value(players[0].hand[i]);
		}
		cout << "Current Score: " << score << endl;

		if (busted)
		{
			cout << players[0].id << " busted.\n";
			return;
		}
		
	
		selection = (GetValidChoice("Enter (H)it or (S)tand: ", "HhSs"));

		//add switch case  
		//stand calls evaluate hand function
		// wasn't able to get the hit option to deal or write new card to hand
		
		switch (selection)
		{
		case 'h':
			DealHands(deck, players, 1);
			cout << players[0].id << ":\n";
			for (unsigned int i = 0; i < players[0].hand.size(); ++i)
			{
				WriteCard(players[0].hand[i]);
				cout << endl;
				score += Value(players[0].hand[i]);
			}
			cout << "Current Score: " << score << endl;
			DisplayResults(players);
			break;
		case 's':
			DisplayResults(players);
		default:
			break;
		}
		
		// asks to play again at end of hand
		cout << "Do you want to play another hand? (Y)es or (N)o?\n";
		cin >> playagain;

		if (playagain == 'y')
		{
			PlayTheGame();
			reset = true;
		}
		else
		{
			reset;
		}
	} while (reset);

	return HoldConsole();
}
Your for loop on line 39 starts at the 0th card in player 1's hand, causing the loop to readd the original two cards dealt before adding the value of the third. Compare that for loop to the one on line 13 (where you total the value of the player's first two cards) for a bit more clarification.
Thanks for the insight!
Topic archived. No new replies allowed.