Change value for card

I've managed to change the players ace score 11 to 1, so when a player twists and there score will exceed 21 if there next card is an ace, the ace will change to a 1 rather than being 11. However, if the player is dealt two aces to begin with, their score ends up being 2, but it should be 12 because one ace should be 11 and the other should be 1, how can I change this?

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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
  void Deal()

{

    Playerscard[0] = Pack[0];

    cout << "Players first card " << SUIT_STRING[Playerscard[0].suit] << Playerscard[0].score << endl;

    if (Playerscard[0].score == 10) {

        cout << VALUE_STRING[Playerscard[0].value] << endl;

    }

    if (Playerscard[0].score == 11) {

        cout << VALUE_STRING[Playerscard[0].value] << endl;

    }

    cout << endl;

    Dealercard[0] = Pack[1];

    cout << "Dealers first card " << SUIT_STRING[Dealercard[0].suit] << Dealercard[0].score << endl;

    if (Dealercard[0].score == 10) {

        cout << VALUE_STRING[Dealercard[0].value] << endl;

    }

    if (Dealercard[0].score == 11) {

        cout << VALUE_STRING[Dealercard[0].value] << endl;

    }

    cout << endl;

    Playerscard[1] = Pack[2];

    cout << "Players second card " << SUIT_STRING[Playerscard[1].suit] << Playerscard[1].score << endl;

    if (Playerscard[1].score == 10)

        cout << VALUE_STRING[Playerscard[1].value] << endl;

    if (Playerscard[1].score == 11)

        cout << VALUE_STRING[Playerscard[1].value] << endl;

    cout << endl;

    Dealercard[1] = Pack[3];

    cout << "Dealers second card " << SUIT_STRING[Dealercard[1].suit] << Dealercard[1].score << endl;

    if (Dealercard[1].score == 10)

        cout << VALUE_STRING[Dealercard[1].value] << endl;

    if (Dealercard[1].score == 11)

        cout << VALUE_STRING[Dealercard[1].value] << endl;

    cout << endl;

    int TestPlayerScore = PlayerScore + Playerscard[0].score + Playerscard[1].score; cout << endl;

    if (TestPlayerScore > 21) {

        CheckAce();

        PlayerScore = PlayerScore + Playerscard[0].score + Playerscard[1].score; cout << endl;

    }

    else {

        PlayerScore = PlayerScore + Playerscard[0].score + Playerscard[1].score; cout << endl;

    }

    int TestDealerScore = Dealercard[0].score + Dealercard[1].score; cout << endl;

    if (TestDealerScore > 21) {

        CheckAce();

        TestDealerScore =  Dealercard[0].score + Dealercard[1].score; cout << endl;

    }

 

    cout << "Players score is: " << PlayerScore << endl;

    DealerScore = DealerScore + Dealercard[0].score + Dealercard[1].score; cout << endl;

    cout << "Dealers score is: " << DealerScore << endl;

}


void CheckAce() //changes value of the ace

{

    for (int P = 0; P < 5; P++) //searches the hand

    {

        if (Playerscard[P].score == 11) //if player score is 11, change to 1

        {

            Playerscard[P].score = 1;


        }

        if (Dealercard[P].score == 11)

        {

            Dealercard[P].score = 1;

        }

    }

}
Last edited on
Why not place an if statement to check to see if there are 2 aces. If theres two aces the second ace's value is 21
but the dealer will go bust if i do that. I need 1 ace to be 11 and the other to be 1
Topic archived. No new replies allowed.