forked from mayeusebio/eng6finalProj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dealerPlay.m
46 lines (41 loc) · 1.84 KB
/
dealerPlay.m
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
function dealerPlay(app)
dealerhits = 0;
app.numCardsDealt = app.numCardsDealt + 1;
app.Image2_3.ImageSource = app.shuffledCards{app.numCardsDealt,3}; %replace facedown image (dealer card image 2) with next card in deck
app.Label_3.Text = num2str(str2double(app.Label_3.Text) + str2double(app.shuffledCards{app.numCardsDealt,2}));
while 1
app.numCardsDealt = app.numCardsDealt + 1;
app.Label_3.Text = num2str(str2double(app.Label_3.Text) + str2double(app.shuffledCards{app.numCardsDealt,2}));
switch dealerhits
case 0
app.Image3_3.Visible = 'on'; %card image turns on
app.Image3_3.ImageSource = app.shuffledCards{app.numCardsDealt,3}; %adds image for 3rd card
case 1
app.Image4_3.Visible = 'on'; %card image turns on
app.Image4_3.ImageSource = app.shuffledCards{app.numCardsDealt,3}; %adds image for 4th card
case 2
app.Image5_3.Visible = 'on'; %card image turns on
app.Image5_3.ImageSource = app.shuffledCards{app.numCardsDealt,3}; %adds image for 5th card
case 3
app.Image6_3.Visible = 'on'; %card image turns on
app.Image6_3.ImageSource = app.shuffledCards{app.numCardsDealt,3}; %adds image for 6th card
otherwise
app.Image6_3.Visible = 'on'; %card image turns on
app.Image6_3.ImageSource = app.shuffledCards{app.numCardsDealt,3}; %updates image 6 slot for over 6 cards in rare cases
end
score3 = str2double(app.Label_3.Text);
if (score3 < 17)
app.dealerturn = 1;
dealerhits = dealerhits + 1;
elseif (score3 >= 17)
app.dealerturn = 0;
break
else
app.ErrorLabel.Visible = 'on';
end
end
% update the balance once the dealer plays, calling another function
updateBalanceTest(app);
% Show the playAgain Button
playAgain(app);
end