diff options
author | Sebastian Leonhardt <sebastian.leonhardt@web.de> | 2019-01-30 23:17:19 +0100 |
---|---|---|
committer | Sebastian Leonhardt <sebastian.leonhardt@web.de> | 2019-02-01 19:58:46 +0100 |
commit | 60c9df0b1211a4f519201b46ffd77e36bafe1759 (patch) | |
tree | e2f35305379c8fee5f8e08b377379251fe2171bb /apps | |
parent | fe95127c45bcb330d54c701b937a497649082a4d (diff) | |
download | rockbox-60c9df0b1211a4f519201b46ffd77e36bafe1759.tar.gz rockbox-60c9df0b1211a4f519201b46ffd77e36bafe1759.zip |
blackjack: various fixes
- fix double down wins/looses too much money
- fix splitting doubles lost/won amount of first split
- fix insurance pays out too litle
- fix splitting allows to overdraw account
- fix insurance allows to overdraw account
Change-Id: Ib58954d6b960fb2a78f5b4d29496974b7c58fb65
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/blackjack.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/apps/plugins/blackjack.c b/apps/plugins/blackjack.c index 27881bf6e9..52881f0af2 100644 --- a/apps/plugins/blackjack.c +++ b/apps/plugins/blackjack.c | |||
@@ -1336,8 +1336,8 @@ static unsigned int insurance(struct game_context* bj) { | |||
1336 | 1336 | ||
1337 | insurance = blackjack_get_yes_no("Buy Insurance?"); | 1337 | insurance = blackjack_get_yes_no("Buy Insurance?"); |
1338 | bj->asked_insurance = true; | 1338 | bj->asked_insurance = true; |
1339 | max_amount = bj->current_bet < (unsigned int)bj->player_money ? | 1339 | max_amount = bj->current_bet/2 < (unsigned int)bj->player_money-bj->current_bet ? |
1340 | bj->current_bet/2 : (unsigned int)bj->player_money; | 1340 | bj->current_bet/2 : (unsigned int)bj->player_money-bj->current_bet; |
1341 | if (insurance != 0) return 0; | 1341 | if (insurance != 0) return 0; |
1342 | 1342 | ||
1343 | insurance = blackjack_get_amount("How much?", 0, max_amount, 0); | 1343 | insurance = blackjack_get_amount("How much?", 0, max_amount, 0); |
@@ -1522,7 +1522,7 @@ static int blackjack(struct game_context* bj) { | |||
1522 | temp_var = insurance(bj); | 1522 | temp_var = insurance(bj); |
1523 | if (bj->dealer_total == 21) { | 1523 | if (bj->dealer_total == 21) { |
1524 | rb->splash(HZ, "Dealer has blackjack"); | 1524 | rb->splash(HZ, "Dealer has blackjack"); |
1525 | bj->player_money += temp_var; | 1525 | bj->player_money += temp_var * 2; |
1526 | bj->end_hand = true; | 1526 | bj->end_hand = true; |
1527 | breakout = true; | 1527 | breakout = true; |
1528 | redraw_board(bj); | 1528 | redraw_board(bj); |
@@ -1538,12 +1538,19 @@ static int blackjack(struct game_context* bj) { | |||
1538 | } | 1538 | } |
1539 | if(!bj->end_hand && bj->split_status == 0 && | 1539 | if(!bj->end_hand && bj->split_status == 0 && |
1540 | bj->player_cards[0][0].num == bj->player_cards[0][1].num) { | 1540 | bj->player_cards[0][0].num == bj->player_cards[0][1].num) { |
1541 | split(bj); | 1541 | if((signed int)bj->current_bet * 2 <= bj->player_money) { |
1542 | redraw_board(bj); | 1542 | split(bj); |
1543 | rb->lcd_update_rect(0, LCD_HEIGHT/2, LCD_WIDTH, LCD_HEIGHT/2); | 1543 | redraw_board(bj); |
1544 | if (bj->split_status == 2) { | 1544 | rb->lcd_update_rect(0, LCD_HEIGHT/2, LCD_WIDTH, LCD_HEIGHT/2); |
1545 | todo++; | 1545 | if (bj->split_status == 2) { |
1546 | player_x = bj->num_player_cards[0] * 10 + 4; | 1546 | todo++; |
1547 | player_x = bj->num_player_cards[0] * 10 + 4; | ||
1548 | } | ||
1549 | } | ||
1550 | else { | ||
1551 | rb->splash(HZ, "Not enough money to split."); | ||
1552 | redraw_board(bj); | ||
1553 | rb->lcd_update(); | ||
1547 | } | 1554 | } |
1548 | } | 1555 | } |
1549 | 1556 | ||
@@ -1583,10 +1590,8 @@ static int blackjack(struct game_context* bj) { | |||
1583 | bj->num_player_cards[0]==2 && todo==1) { | 1590 | bj->num_player_cards[0]==2 && todo==1) { |
1584 | double_down(bj); | 1591 | double_down(bj); |
1585 | dbl_down = true; | 1592 | dbl_down = true; |
1586 | if (bj->player_total < 22) { | 1593 | if (bj->player_total < 22) |
1587 | bj->end_hand = true; | 1594 | bj->end_hand = true; |
1588 | finish_game(bj); | ||
1589 | } | ||
1590 | } | 1595 | } |
1591 | else if((signed int)bj->current_bet * 2 > | 1596 | else if((signed int)bj->current_bet * 2 > |
1592 | bj->player_money){ | 1597 | bj->player_money){ |
@@ -1608,10 +1613,8 @@ static int blackjack(struct game_context* bj) { | |||
1608 | bj->player_cards[done][temp].is_soft_ace = false; | 1613 | bj->player_cards[done][temp].is_soft_ace = false; |
1609 | bj->player_total -= 10; | 1614 | bj->player_total -= 10; |
1610 | update_total(bj); | 1615 | update_total(bj); |
1611 | if (dbl_down) { | 1616 | if (dbl_down) |
1612 | bj->end_hand = true; | 1617 | bj->end_hand = true; |
1613 | finish_game(bj); | ||
1614 | } | ||
1615 | } | 1618 | } |
1616 | else | 1619 | else |
1617 | bj->end_hand = true; | 1620 | bj->end_hand = true; |
@@ -1624,13 +1627,13 @@ static int blackjack(struct game_context* bj) { | |||
1624 | temp = bj->player_total; | 1627 | temp = bj->player_total; |
1625 | bj->player_total = temp_var; | 1628 | bj->player_total = temp_var; |
1626 | temp_var = temp; | 1629 | temp_var = temp; |
1630 | bj->current_bet /= 2; | ||
1627 | finish_game(bj); | 1631 | finish_game(bj); |
1628 | rb->lcd_getstringsize(" Split 1 ", &w, &h); | 1632 | rb->lcd_getstringsize(" Split 1 ", &w, &h); |
1629 | rb->lcd_putsxy(LCD_WIDTH/2-w/2, LCD_HEIGHT/2-3*h/2, | 1633 | rb->lcd_putsxy(LCD_WIDTH/2-w/2, LCD_HEIGHT/2-3*h/2, |
1630 | " Split 1 "); | 1634 | " Split 1 "); |
1631 | rb->lcd_update_rect(LCD_WIDTH/2-w/2, LCD_HEIGHT/2-3*h/2, | 1635 | rb->lcd_update_rect(LCD_WIDTH/2-w/2, LCD_HEIGHT/2-3*h/2, |
1632 | w,h); | 1636 | w,h); |
1633 | bj->current_bet /= 2; | ||
1634 | rb->lcd_update_rect(LCD_WIDTH/2-w/2, LCD_HEIGHT/2-3*h/2, | 1637 | rb->lcd_update_rect(LCD_WIDTH/2-w/2, LCD_HEIGHT/2-3*h/2, |
1635 | w,h); | 1638 | w,h); |
1636 | rb->sleep(HZ*2); | 1639 | rb->sleep(HZ*2); |