From 511cce3e4f3a2ca87fda1208ab79b0778d3b1db0 Mon Sep 17 00:00:00 2001 From: Manmadedrummer <140130825+Manmadedrummer@users.noreply.github.com> Date: Tue, 27 Aug 2024 17:00:21 -0400 Subject: [PATCH] Update BlackjackServer.lua --- Blackjack/BlackjackServer.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Blackjack/BlackjackServer.lua b/Blackjack/BlackjackServer.lua index 738593a..ff800f7 100644 --- a/Blackjack/BlackjackServer.lua +++ b/Blackjack/BlackjackServer.lua @@ -2,9 +2,9 @@ local AIO = AIO or require("AIO") --- Register the NPC with ID 1000000 -local NPC_ID = 1000000 +-- Register the NPC with ID 1000000 (1000000 is the original) +local NPC_ID = 1000000 local BlackjackGame = {} -- Define the game cost in copper (500 gold) @@ -72,12 +72,20 @@ function BlackjackGame.HandleDrawCard(player) end -- Handle the player winning -function BlackjackGame.HandlePlayerWin(player, betAmount) - local rewardAmount = betAmount + GAME_COST -- Add the bet amount and 500 gold +function BlackjackGame.HandlePlayerWin(player, betAmount, mult) + local rewardAmount = (betAmount + GAME_COST) * mult -- Add the bet amount and 500 gold player:ModifyMoney(rewardAmount) SendWorldMessage("|cff00ff00" .. player:GetName() .. " wins " .. (rewardAmount / 10000) .. " gold in Blackjack!|r") end +-- Function to check if the player has enough money to play again +function BlackjackGame.CheckPlayerMoney(player) + local canPlay = player:GetCoinage() >= GAME_COST + + -- Send the result back to the client + AIO.Handle(player, "Blackjack", "ReceiveCanPlayResponse", canPlay) +end + -- Register the gossip events for the NPC RegisterCreatureGossipEvent(NPC_ID, 1, BlackjackGame.OnGossipHello) RegisterCreatureGossipEvent(NPC_ID, 2, BlackjackGame.OnGossipSelect)