# blackjackView

*PL '<table width="100%"><tr><td>'
*PL '<u>Dealer</u>'
if ARGS[0] = 0:
	*P '<img src="<<$deckImg[dealerHand[0]]>>">'
	*PL '<img src="images/locations/city/industrial/casino/cards/back.jpg">'
else
	numAces = 0
	dealerPoints = 0
	i = 0
	:loop1
	*P '<img src="<<$deckImg[dealerHand[i]]>>">'
	if deckFace[dealerHand[i]] = 1:
		dealerPoints += 11
		numAces += 1
	elseif deckFace[dealerHand[i]] > 9:
		dealerPoints += 10
	else
		dealerPoints += deckFace[dealerHand[i]]
	end
	i += 1
	if dealerHand[i] ! 0: jump 'loop1'
	:loop2
	if dealerPoints > 21 and numAces > 0:
		dealerPoints -= 10
		numAces -= 1
		jump 'loop2'
	end
	if dealerPoints > 21:
		*P '<br>BUST!'
	elseif dealerPoints = 21 and dealerHand[2] = 0:
		*P '<br>BLACKJACK!'
	else
		*P '<br><<dealerPoints>> points'
	end
end

*PL '<br><br><u>Player</u>'
i = 0
:loop3
numAces = 0
playerPoints[i] = 0
if numHands > 1: *PL 'Hand #<<i + 1>>:'
j = 0
:loop4
if playerHand[i * 16 + j] ! 0:
	*P '<img src="<<$deckImg[playerHand[i * 16 + j]]>>">'
	if deckFace[playerHand[i * 16 + j]] = 1:
		playerPoints[i] += 11
		numAces += 1
	elseif deckFace[playerHand[i * 16 + j]] > 9:
		playerPoints[i] += 10
	else
		playerPoints[i] += deckFace[playerHand[i * 16 + j]]
	end
	j += 1
	jump 'loop4'
end
:loop5
if playerPoints[i] > 21 and numAces > 0:
	playerPoints[i] -= 10
	numAces -= 1
	jump 'loop5'
end
if playerPoints[i] > 21:
	*P '<br>BUST!'
elseif playerPoints[i] = 21 and playerHand[2] = 0 and numHands = 1:
	*P '<br>BLACKJACK!'
else
	*P '<br><<playerPoints[i]>> points |'
end
*P ' Bet = <<playerBets[i]>> <b>₽</b><br><br>'
i += 1
if i < numHands: jump 'loop3'
*PL '</td><td valign="top"><div align="right"><img src="images/locations/city/industrial/casino/cartbd.jpg"></div></td></tr></table>'

--- blackjackView ---------------------------------

