# igrkart2
clr
minut += 5
gs 'stat'

if turn1 = 0:
	cla
	'<right><img <<$set_imgh>> src="images/locations/city/industrial/casino/stavkacw.jpg"></right>'
	' Place your bets, ladies and gentlemen.'

	act 'Place a bet':
		if money < 1:
			'You don''t have any money!'
			act 'Leave the table' :gt 'kazvar'
		end

		bet_amount = input 'Enter the amount to bet'

		if money < bet_amount:
			msg 'You don''t have enough money to bet that much'
		elseif bet_amount < 1:
			msg 'You must place a minimum bet of 1 <b>₽</b>.'
		elseif bet_amount > 1000:
			msg 'The maximum bet allowed is 1000 <b>₽</b>.'
		else
			money -= bet_amount
			turn1 = 1
		end

		gt 'igrkart2'
	end

	act 'Leave the table' :gt 'kazvar'
end

if turn1 = 1:
	cla
	bet_draw = 0
	'<right><img <<$set_imgh>> src="images/locations/city/industrial/casino/stavkacw.jpg"></right>'
	'Continue with regular bet (payout 2 to 1), or bet on a draw (payout 11 to 1)?'
	if money < bet_amount:
		turn1 = 2
		gt 'igrkart2'
	else
		act 'Continue with regular bet':
			turn1 = 2
			gt 'igrkart2'
		end

		act 'Bet on draw (doubles bet)':
			turn1 = 2
			bet_draw = 1
			money -= bet_amount
			gt 'igrkart2'
		end
	end
end

if turn1 = 2:
	cla
	'<right><img <<$set_imgh>> src="images/locations/city/industrial/casino/cartcw.jpg"></right>'
	' The dealer deals the cards:'
	'...'
	suit = rand(1, 4)
	number = rand(1, 13)
	$d_card[1] = $number[number] + 'of ' + $suit[suit]
	d_points = number
	suit = rand(1, 4)
	!! Player draws from cards 2-14 so that they win if both they and the dealer draw an ace
	number = rand(2, 14)
	$p_card[1] = $number[number] + 'of ' + $suit[suit]
	p_points = number
	wait 1000
	'Dealer''s Card:'
	'  <<$d_card[1]>>'

	'__________________________'
	'Your Card:'
	'  <<$p_card[1]>>'

	if d_points > p_points:
		' '
		'Casino won'

		act 'You lost':
			turn1 = 0
			gt 'igrkart2'
		end
	elseif d_points < p_points:
		' '
		'You won'
		act 'Take money (<<2 * bet_amount>> <b>₽</b>)':
			money += 2 * bet_amount
			turn1 = 0
			gt 'igrkart2'
		end
	else
		if bet_draw = 1:
			' '
			'You won'

			act 'Take money (<<11 * bet_amount>> <b>₽</b>)':
				money += 11 * bet_amount
				turn1 = 0
				gt 'igrkart2'
			end
		else
			turn1 = 3
			gt 'igrkart2'
		end
	end
end

if turn1 = 3:
	'<right><img <<$set_imgh>> src="images/locations/city/industrial/casino/cartcw.jpg"></right>'
	' '
	'Draw'

	if money >= bet_amount:
		act 'Continue (bet another <<bet_amount>> <b>₽</b>)':
			cla

			money -= bet_amount

			' The dealer deals the cards:'
			'...'
			suit = rand(1, 4)
			number = rand(1, 13)
			$d_card[2] = $number[number] + 'of ' + $suit[suit]
			d_points = number
			suit = rand(1, 4)
			number = rand(2, 14)
			$p_card[2] = $number[number] + 'of ' + $suit[suit]
			p_points = number
			'Dealer''s Cards:'
			'  <<$d_card[1]>>'
			'  <<$d_card[2]>>'
			'__________________________'
			'Your Cards:'
			'  <<$p_card[1]>>'
			'  <<$p_card[2]>>'

			if d_points > p_points:
				' '
				'Casino won'

				act 'You lost':
					turn1 = 0
					gt 'igrkart2'
				end
			elseif d_points < p_points:
				' '
				'You won'

				act 'Take money (<<4 * bet_amount>> <b>₽</b>)':
					money += 4 * bet_amount
					turn1 = 0
					gt 'igrkart2'
				end
			elseif d_points = p_points:
				' '
				'Draw'

				act 'Take money (<<3 * bet_amount>> <b>₽</b>)':
					money += 3 * bet_amount
					turn1 = 0
					gt 'igrkart2'
				end
			end
		end
	else
		' '
		'You don''t have enough money to continue'
	end

	act 'Take original bet (<<bet_amount>> <b>₽</b>)':
		money += bet_amount
		turn1 = 0
		gt 'igrkart2'
	end
end

--- igrkart2 ---------------------------------

