123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- # blackjackPlay
- minut += 1
- gs 'stat'
- if $ARGS[0] = 'new':
- killvar 'dealerHand'
- killvar 'playerHand'
- killvar 'playerBets'
- killvar 'playerPoints'
- dealerHand[] = 0
- dealerHand[] = 1
- playerHand[] = 2
- playerHand[] = 3
- cardsDealt = 4
- numHands = 1
- currentHand = 0
- handLosses = 0
- numAces = 0
- dealerPoints = 0
- insurance = 0
- betTotal = 0
- doubleBet = 0
- minBet = 10
- maxBet = 500
- *PL '<center><img <<$set_imgh>> src="images/locations/city/industrial/casino/stolbd.jpg"></center>'
- *PL 'You are sitting at the blackjack table.'
- act 'Bet' : gt 'blackjackPlay', 'bet'
- act 'Rules' : gt 'blackjackPlay', 'rules'
- act 'Leave' : gt 'cards'
- end
- if $ARGS[0] = 'rules':
- *PL '<center><img <<$set_imgh>> src="images/locations/city/industrial/casino/crupbd.jpg"></center>'
- *PL '<h2><u>Blackjack Rules:</u></h2>'
- *P '<ol><li>The player and dealer are each dealt 2 cards after initial bets (<<minBet>> <b>₽</b> - <<maxBet>> <b>₽</b>). The dealer will have 1 face-up card and 1 face-down card.</li>'
- *P '<li>Face cards are worth 10 points, aces can double as either 11 or 1, and all other cards are worth their numeric value.</li>'
- *P '<li>After the player finishes drawing, the dealer must continue to draw until he has 17 points or more.</li>'
- *P '<li>To win, the player must score more points than the dealer, have the dealer bust, or get a blackjack.</li>'
- *P '<li>Getting over 21 points is known as a bust, and an automatic loss.</li>'
- *P '<li>Getting an ace and a 10 point card in the first 2 cards is known as a blackjack, and is an automatic win which pays 3 : 2.</li>'
- *P '<li>If the dealer''s face-up card is an ace, the player can make a side-bet called "insurance" that pays 2 : 1 if the dealer has a blackjack.</li>'
- *P '<li>At any time, the player can choose to double his/her bet, which gives the player 1 more card but prevents further draws on that hand.</li>'
- *P '<li>If the player''s hand only consists of two cards of equal value, he/she can split them into 2 hands. Each hand must be covered by an amount equal to the original bet.</li>'
- *P '<li>The player cannot score a blackjack using a split hand.</li>'
- act 'Return' : gt 'blackjackPlay', 'new'
- end
- if $ARGS[0] = 'bet':
- *PL '<center><img <<$set_imgh>> src="images/locations/city/industrial/casino/stavkabd.jpg"></center>'
- playerBets[0] = INPUT('Place your bet.')
- if money < playerBets[0]:
- MSG 'You don''t have enough money for that bet.'
- gt 'blackjackPlay', 'new'
- elseif playerBets[0] < minBet:
- MSG 'There is a minimum bet of <<minBet>> <b>₽</b>.'
- gt 'blackjackPlay', 'new'
- elseif playerBets[0] > maxBet:
- MSG 'There is a maximum bet of <<maxBet>> <b>₽</b>.'
- gt 'blackjackPlay', 'new'
- end
- betTotal = playerBets[0]
- gs 'deckShuffle'
- if (deckFace[playerHand[0]] = 1 and deckFace[playerHand[1]] > 9) or (deckFace[playerHand[0]] > 9 and deckFace[playerHand[1]] = 1):
- gt 'blackjackPlay', 'blackjack'
- elseif deckFace[dealerHand[0]] > 9 and deckFace[dealerHand[1]] = 1:
- gt 'blackjackPlay', 'blackjack'
- elseif deckFace[dealerCards[0]] = 1:
- gt 'blackjackPlay', 'insurance1'
- else
- gt 'blackjackPlay', 'player'
- end
- end
- if $ARGS[0] = 'blackjack':
- gs 'blackjackView', 1
- if playerPoints[0] = 21 and dealerPoints = 21:
- *PL 'DRAW GAME'
- *PL 'You retrieve your bet.'
- elseif playerPoints[0] = 21:
- *PL 'PLAYER WINS'
- *PL 'You receive <<playerBets[0] * 3 / 2>> <b>₽</b> in winnings.'
- money += playerBets[0] * 3 / 2
- else
- *PL 'DEALER WINS'
- *PL 'The dealer takes your <<playerBets[0]>> <b>₽</b> bet.'
- money -= playerBets[0]
- end
- act 'Continue' : gt 'blackjackPlay', 'new'
- end
- if $ARGS[0] = 'insurance1':
- gs 'blackjackView'
- *PL 'The dealer has an ace showing. Would you like to place a bet for insurance?'
- insurance = 0
- act 'Bet insurance' :
- insurance = INPUT('Place your bet.')
- if money < insurance:
- MSG 'You don''t have enough money for that bet.'
- gt 'blackjackPlay', 'insurance1'
- elseif insurance < 0:
- MSG 'You cannot bet a negative amount of money.'
- gt 'blackjackPlay', 'insurance1'
- elseif insurance > playerBets[0] / 2:
- MSG 'Insurance cannot exceed half the original bet.'
- gt 'blackjackPlay', 'insurance1'
- else
- gt 'blackjackPlay', 'insurance2'
- end
- end
- act 'No insurance' : gt 'blackjackPlay', 'insurance2'
- end
- if $ARGS[0] = 'insurance2':
- if deckFace[dealerCards[1]] > 9: gs 'blackjackView', 1
- if deckFace[dealerCards[1]] < 10: gs 'blackjackView'
- if dealerPoints = 21:
- *PL 'DEALER WINS'
- *P 'The dealer takes your <<playerBets[0]>> <b>₽</b> bet'
- if insurance > 0: *P ' but also gives you <<insurance>> <b>₽</b> for your side bet'
- *P '.'
- money -= playerBets[0]
- money += insurance
- act 'Continue' : gt 'blackjackPlay', 'new'
- else
- *PL 'The dealer takes a peek at his hole card; no blackjack.'
- if insurance > 0: *P 'He relieves you of <<insurance>> <b>₽</b> for your side bet.'
- money -= insurance
- act 'Continue' :
- CLA
- wait 500
- gt 'blackjackPlay', 'player'
- end
- end
- end
- if $ARGS[0] = 'player':
- gs 'blackjackView'
- if playerPoints[currentHand] > 21: currentHand += 1 & handLosses += 1 & doubleBet = 0
- if playerPoints[currentHand] = 21 or doubleBet = 1: currentHand += 1 & doubleBet = 0
- if handLosses = numHands:
- *PL 'DEALER WINS'
- *P 'The dealer relieves you of <<betTotal>> <b>₽</b>.'
- money -= betTotal
- act 'Continue' : gt 'blackjackPlay', 'new'
- elseif currentHand >= numHands:
- *PL 'You can take no further actions.'
- act 'Continue' :
- CLA
- wait 500
- gt 'blackjackPlay', 'dealer'
- end
- else
- if numHands = 1:
- *PL 'You are considering actions for your hand.'
- $text = ''
- else
- *PL 'You are considering your actions for <b>hand #<<currentHand + 1>></b>.'
- $text = 'Hand #<<currentHand + 1>>: '
- end
- act '<<$text>>Hit' :
- i = currentHand * 16 + 2
- :loop1
- if playerHand[i] ! 0: i += 1 & jump 'loop1'
- playerHand[i] = cardsDealt
- cardsDealt += 1
- *CLR & CLA
- *PL '<center><img <<$set_imgh>> src="images/locations/city/industrial/casino/cartbde.jpg"></center>'
- wait 750
- gt 'blackjackPlay', 'player'
- end
- if money >= betTotal + playerBets[currentHand]:
- act '<<$text>>Double' :
- doubleBet = 1
- betTotal += playerBets[currentHand]
- playerBets[currentHand] += playerBets[currentHand]
- i = currentHand * 16 + 2
- :loop2
- if playerHand[i] ! 0: i += 1 & jump 'loop2'
- playerHand[i] = cardsDealt
- cardsDealt += 1
- *CLR & CLA
- *PL '<center><img <<$set_imgh>> src="images/locations/city/industrial/casino/cartbde.jpg"></center>'
- wait 750
- gt 'blackjackPlay', 'player'
- end
- if playerHand[currentHand * 16 + 2] = 0 and ((deckFace[playerHand[currentHand * 16]] > 9 and deckFace[playerHand[currentHand * 16 + 1]] > 9) or deckFace[playerHand[currentHand * 16]] = deckFace[playerHand[currentHand * 16 + 1]]):
- act '<<$text>>Split' :
- betTotal += playerBets[currentHand]
- playerBets[numHands] = playerBets[currentHand]
- numHands += 1
- i = (currentHand + 1) * 16
- :loop3
- if playerHand[i] ! 0: i += 16 & jump 'loop3'
- playerHand[i] = playerHand[currentHand * 16 + 1]
- playerHand[currentHand * 16 + 1] = cardsDealt
- cardsDealt += 1
- playerHand[i + 1] = cardsDealt
- cardsDealt += 1
- *CLR & CLA
- *PL '<center><img <<$set_imgh>> src="images/locations/city/industrial/casino/cartbde.jpg"></center>'
- wait 750
- gt 'blackjackPlay', 'player'
- end
- end
- end
- act '<<$text>>Stay' :
- currentHand += 1
- CLA
- wait 500
- if currentHand < numHands: gt 'blackjackPlay', 'player'
- if currentHand >= numHands: gt 'blackjackPlay', 'dealer'
- end
- end
- end
- if $ARGS[0] = 'dealer':
- gs 'blackjackView', 1
- if dealerPoints < 17:
- act 'Continue' :
- i = 2
- :loop4
- if dealerHand[i] ! 0: i += 1 & jump 'loop4'
- dealerHand[i] = cardsDealt
- cardsDealt += 1
- *CLR & CLA
- *PL '<center><img <<$set_imgh>> src="images/locations/city/industrial/casino/cartbde.jpg"></center>'
- wait 750
- gt 'blackjackPlay', 'dealer'
- end
- elseif dealerPoints > 21:
- betTotal = 0
- i = 0
- :loop5
- if playerPoints[i] <= 21: betTotal += playerBets[i]
- i += 1
- if i < numHands: jump 'loop5'
- *PL 'PLAYER WINS'
- *P 'You receive <<betTotal>> <b>₽</b> in winnings.'
- money += betTotal
- act 'Continue' : gt 'blackjackPlay', 'new'
- else
- betTotal = 0
- i = 0
- :loop6
- if playerPoints[i] > 21:
- betTotal -= playerBets[i]
- elseif playerPoints[i] < dealerPoints:
- betTotal -= playerBets[i]
- elseif playerpoints[i] > dealerPoints:
- betTotal += playerBets[i]
- end
- i += 1
- if i < numHands: jump 'loop6'
- if betTotal = 0:
- *PL 'DRAW GAME'
- if numHands = 1: *P 'You retrieve your bet.'
- if numHands > 1: *P 'You retrieve your bets.'
- elseif betTotal < 0:
- *PL 'DEALER WINS'
- if numHands > 1: *P 'After taking into account all the hands, you have lost. '
- *P 'The dealer relieves you of <<0 - betTotal>> <b>₽</b>.'
- else
- *PL 'PLAYER WINS'
- if numHands > 1: *P 'After taking into account all the hands, you have won. '
- *P 'You receive <<betTotal>> <b>₽</b> in winnings.'
- end
- money += betTotal
- act 'Continue' : gt 'blackjackPlay', 'new'
- end
- end
- --- blackjackPlay ---------------------------------
|