init
This commit is contained in:
49
blackjack.lua
Normal file
49
blackjack.lua
Normal file
@@ -0,0 +1,49 @@
|
||||
require "karten"
|
||||
|
||||
spielerHand = {}
|
||||
dealerHand = {}
|
||||
deck = {}
|
||||
|
||||
function loadBlackjack()
|
||||
deck = createDeck()
|
||||
shuffleDeck(deck)
|
||||
dealInitialCards()
|
||||
end
|
||||
|
||||
function updateBlackjack(dt)
|
||||
-- Hier können zukünftige Updates für Blackjack hinzugefügt werden
|
||||
end
|
||||
|
||||
function drawBlackjack()
|
||||
love.graphics.print("Spieler Hand: " .. handValue(spielerHand), 50, 50)
|
||||
love.graphics.print("Dealer Hand: " .. handValue(dealerHand), 50, 100)
|
||||
love.graphics.print("Drücke 'H' für Hit oder 'S' für Stand", 50, 150)
|
||||
end
|
||||
|
||||
function handleBlackjackInput(key)
|
||||
if key == 'h' then
|
||||
hit(spielerHand)
|
||||
if handValue(spielerHand) > 21 then
|
||||
love.graphics.print("Spieler hat verloren!", 50, 200)
|
||||
end
|
||||
elseif key == 's' then
|
||||
while handValue(dealerHand) < 17 do
|
||||
hit(dealerHand)
|
||||
end
|
||||
if handValue(dealerHand) > 21 then
|
||||
love.graphics.print("Dealer hat verloren!", 50, 200)
|
||||
elseif handValue(spielerHand) > handValue(dealerHand) then
|
||||
love.graphics.print("Spieler gewinnt!", 50, 200)
|
||||
else
|
||||
love.graphics.print("Dealer gewinnt!", 50, 200)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function dealInitialCards()
|
||||
for i = 1, 2 do
|
||||
hit(spielerHand)
|
||||
hit(dealerHand)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user