54 lines
1.6 KiB
Lua
54 lines
1.6 KiB
Lua
local love = require "love"
|
|
require "karten"
|
|
|
|
spielerHand = {}
|
|
DealerHand = {}
|
|
Deck = {}
|
|
|
|
function LoadBlackjack()
|
|
Deck = Karten:createDeck()
|
|
Karten:shuffleDeck(Deck)
|
|
DealInitialCards()
|
|
Cards = love.graphics.newImage("/cards_asset_pack/CuteCards.png")
|
|
end
|
|
|
|
function UpdateBlackjack(dt)
|
|
-- Hier können zukünftige Updates für Blackjack hinzugefügt werden
|
|
end
|
|
|
|
function DrawBlackjack()
|
|
print(love.graphics:getWidth())
|
|
love.graphics.draw(Cards, love.graphics.getWidth() / 2 - 90 , 50, 0, 0.2)
|
|
-- love.graphics.print("Spieler Hand: " .. Karten:handValue(spielerHand), 50, 50)
|
|
-- love.graphics.print("Dealer Hand: " .. Karten: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
|
|
Karten:hit(spielerHand)
|
|
if Karten:handValue(spielerHand) > 21 then
|
|
love.graphics.print("Spieler hat verloren!", 50, 200)
|
|
end
|
|
elseif key == 's' then
|
|
while Karten:handValue(DealerHand) < 17 do
|
|
Karten:hit(DealerHand)
|
|
end
|
|
if Karten:handValue(DealerHand) > 21 then
|
|
love.graphics.print("Dealer hat verloren!", 50, 200)
|
|
elseif Karten:handValue(spielerHand) > Karten: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
|
|
Karten:hit(spielerHand)
|
|
Karten:hit(DealerHand)
|
|
end
|
|
end
|
|
|