-- Set the minimum and maximum bet limits
local minBetMain = 50
local maxBetMain = 1500
local minBetPP = 5
local maxBetPP = 400
local minBet213 = 5
local maxBet213 = 400

local betAmountMain = {}
local betAmountPP = {}
local betAmount213 = {}

for i = 1, 5 do
    betAmountMain[i] = 0
    betAmountPP[i] = 0
    betAmount213[i] = 0
end

local Player1Active = false
local Player2Active = false
local Player3Active = false
local Player4Active = false
local Player5Active = false

local result1Flagged = false
local result2Flagged = false
local double1Flag = false

local countdownTimer1
local countdownTimer2
local countdownTimer3
local countdownTimer4
local countdownTimer5
local countdownDuration = 30
local countdownDurationResult = 5

-- Initialize the turn counter at 0
local turn = 0

local unitName1 = GetRaidRosterInfo(2) or "Seat Empty";
local unitName2 = GetRaidRosterInfo(3) or "Seat Empty";
local unitName3 = GetRaidRosterInfo(4) or "Seat Empty";
local unitName4 = GetRaidRosterInfo(5) or "Seat Empty";
local unitName5 = GetRaidRosterInfo(6) or "Seat Empty";

local playerName = UnitName("player");  -- Get your own player name

local soundFiles = {
    "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
    "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21",
    "1 or 11", -- 22
    "2 or 12", -- 23
    "3 or 13", -- 24
    "4 or 14", -- 25
    "5 or 15", -- 26
    "6 or 16", -- 27
    "7 or 17", -- 28
    "8 or 18", -- 29
    "9 or 19", -- 30
    "10 or 20", -- 31
    "PlayerBlackjack", "PlayerWin", "PlayerLoss", "PlayerBust", -- 32, 33, 34, 35
    "DealerBlackjack", "DealerBust", -- 36, 37
    "Push", -- 38
    "Hit", "Stand", "Double", -- 39, 40, 41
    "DealingCard", "ConfirmBet", -- 42, 43
    "Player1Win", -- 44
    "Player2Win", -- 45
    "Player1Loss", -- 46
    "Player2Loss", -- 47
    "Player1Bust", -- 48
    "Player2Bust", -- 49
    "Player12Win", -- 50
    "Player12Loss", -- 51
    "Player1BJ", -- 52
    "Player2BJ", -- 53
    "Player12Push", -- 54
    "Player1Push", -- 55
    "Player2Push" -- 56
}

local soundFilePaths = {}

for i, fileName in ipairs(soundFiles) do
    soundFilePaths[i] = "Interface\\AddOns\\BJPlayer_v1.1\\Sounds\\" .. fileName .. ".mp3"
end


local cardNames = {
    ["AD.tga"] = "Ace of Diamonds",
    ["2D.tga"] = "2 of Diamonds",
    ["3D.tga"] = "3 of Diamonds",
    ["4D.tga"] = "4 of Diamonds",
    ["5D.tga"] = "5 of Diamonds",
    ["6D.tga"] = "6 of Diamonds",
    ["7D.tga"] = "7 of Diamonds",
    ["8D.tga"] = "8 of Diamonds",
    ["9D.tga"] = "9 of Diamonds",
    ["10D.tga"] = "10 of Diamonds",
    ["JD.tga"] = "Jack of Diamonds",
    ["QD.tga"] = "Queen of Diamonds",
    ["KD.tga"] = "King of Diamonds",
    ["AH.tga"] = "Ace of Hearts",
    ["2H.tga"] = "2 of Hearts",
    ["3H.tga"] = "3 of Hearts",
    ["4H.tga"] = "4 of Hearts",
    ["5H.tga"] = "5 of Hearts",
    ["6H.tga"] = "6 of Hearts",
    ["7H.tga"] = "7 of Hearts",
    ["8H.tga"] = "8 of Hearts",
    ["9H.tga"] = "9 of Hearts",
    ["10H.tga"] = "10 of Hearts",
    ["JH.tga"] = "Jack of Hearts",
    ["QH.tga"] = "Queen of Hearts",
    ["KH.tga"] = "King of Hearts",
    ["AC.tga"] = "Ace of Clubs",
    ["2C.tga"] = "2 of Clubs",
    ["3C.tga"] = "3 of Clubs",
    ["4C.tga"] = "4 of Clubs",
    ["5C.tga"] = "5 of Clubs",
    ["6C.tga"] = "6 of Clubs",
    ["7C.tga"] = "7 of Clubs",
    ["8C.tga"] = "8 of Clubs",
    ["9C.tga"] = "9 of Clubs",
    ["10C.tga"] = "10 of Clubs",
    ["JC.tga"] = "Jack of Clubs",
    ["QC.tga"] = "Queen of Clubs",
    ["KC.tga"] = "King of Clubs",
    ["AS.tga"] = "Ace of Spades",
    ["2S.tga"] = "2 of Spades",
    ["3S.tga"] = "3 of Spades",
    ["4S.tga"] = "4 of Spades",
    ["5S.tga"] = "5 of Spades",
    ["6S.tga"] = "6 of Spades",
    ["7S.tga"] = "7 of Spades",
    ["8S.tga"] = "8 of Spades",
    ["9S.tga"] = "9 of Spades",
    ["10S.tga"] = "10 of Spades",
    ["JS.tga"] = "Jack of Spades",
    ["QS.tga"] = "Queen of Spades",
    ["KS.tga"] = "King of Spades",
    -- Add more card entries as needed
}

local cardValues = {
    ["AD.tga"] = {1, 11},
    ["2D.tga"] = {2},
    ["3D.tga"] = {3},
    ["4D.tga"] = {4},
    ["5D.tga"] = {5},
    ["6D.tga"] = {6},
    ["7D.tga"] = {7},
    ["8D.tga"] = {8},
    ["9D.tga"] = {9},
    ["10D.tga"] = {10},
    ["JD.tga"] = {10},
    ["QD.tga"] = {10},
    ["KD.tga"] = {10},
    ["AH.tga"] = {1, 11},
    ["2H.tga"] = {2},
    ["3H.tga"] = {3},
    ["4H.tga"] = {4},
    ["5H.tga"] = {5},
    ["6H.tga"] = {6},
    ["7H.tga"] = {7},
    ["8H.tga"] = {8},
    ["9H.tga"] = {9},
    ["10H.tga"] = {10},
    ["JH.tga"] = {10},
    ["QH.tga"] = {10},
    ["KH.tga"] = {10},
    ["AC.tga"] = {1, 11},
    ["2C.tga"] = {2},
    ["3C.tga"] = {3},
    ["4C.tga"] = {4},
    ["5C.tga"] = {5},
    ["6C.tga"] = {6},
    ["7C.tga"] = {7},
    ["8C.tga"] = {8},
    ["9C.tga"] = {9},
    ["10C.tga"] = {10},
    ["JC.tga"] = {10},
    ["QC.tga"] = {10},
    ["KC.tga"] = {10},
    ["AS.tga"] = {1, 11},
    ["2S.tga"] = {2},
    ["3S.tga"] = {3},
    ["4S.tga"] = {4},
    ["5S.tga"] = {5},
    ["6S.tga"] = {6},
    ["7S.tga"] = {7},
    ["8S.tga"] = {8},
    ["9S.tga"] = {9},
    ["10S.tga"] = {10},
    ["JS.tga"] = {10},
    ["QS.tga"] = {10},
    ["KS.tga"] = {10},
}

-- Table to store the drawn cards in order
local drawnCards = {}
























-- Create a frame for the initial screen
local initialFrame = CreateFrame("Frame", "BlackjackInitialFrame", UIParent, "BasicFrameTemplateWithInset")
initialFrame:SetSize(400, 200)
initialFrame:SetPoint("CENTER")
initialFrame:Hide()

-- Add a title to the initial frame
initialFrame.title = initialFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
initialFrame.title:SetPoint("TOP", initialFrame, 0, -6)
initialFrame.title:SetText("Welcome to Blackjack!")

-- Create a "Join Table" button to start the game
initialFrame.reloadButton = CreateFrame("Button", nil, initialFrame, "GameMenuButtonTemplate")
initialFrame.reloadButton:SetPoint("CENTER", initialFrame, 0, -12)
initialFrame.reloadButton:SetSize(120, 30)
initialFrame.reloadButton:SetText("Reload")

-- Create a "Join Table" button to start the game
initialFrame.joinButton = CreateFrame("Button", nil, initialFrame, "GameMenuButtonTemplate")
initialFrame.joinButton:SetPoint("CENTER", initialFrame, 0, -42)
initialFrame.joinButton:SetSize(120, 30)
initialFrame.joinButton:SetText("Join Table")
initialFrame.joinButton:Disable()

-- Create a font string to display the join instructions
initialFrame.join1Text = initialFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
initialFrame.join1Text:SetPoint("TOP", initialFrame, 0, -40)
initialFrame.join1Text:SetText("You will be able to play\nonce the dealer has opened up a table\n\nPlease hit the 'Reload' button before joining")
initialFrame.join1Text:SetJustifyH("CENTER")
initialFrame.join1Text:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")

-- Create a font string to display the developer
initialFrame.join3Text = initialFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
initialFrame.join3Text:SetPoint("BOTTOM", initialFrame, 0, 15)
initialFrame.join3Text:SetText("BJ Player v1.1  |  Developed by Hyrav")
initialFrame.join3Text:SetJustifyH("CENTER")
initialFrame.join3Text:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
initialFrame.join3Text:SetTextColor(1, 0.5, 0)


-- Enable click-and-drag functionality
initialFrame:SetMovable(true)
initialFrame:EnableMouse(true)
initialFrame:RegisterForDrag("LeftButton")

-- Set the frame's script for handling the drag
initialFrame:SetScript("OnDragStart", function(self)
    self:StartMoving()
end)

initialFrame:SetScript("OnDragStop", function(self)
    self:StopMovingOrSizing()
end)

-- Function to enable the "Join Table" button
local function EnableJoinButton()
    initialFrame.joinButton:Enable()
end








-- Creating the core playerFrame
-- Setting its size & loading point (center)
-- Setting its frame strata (to appear above UI elements) and frame level (to sit in the foreground)
local playerFrame = CreateFrame("Frame", "BlackjackPlayerFrame", UIParent, "BasicFrameTemplateWithInset")
playerFrame:SetSize(1280, 720)
playerFrame:SetPoint("CENTER")
playerFrame:SetFrameStrata("HIGH")
playerFrame:SetFrameLevel(1)
playerFrame:Hide()

-- Setting a title
playerFrame.title = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.title:SetPoint("TOP", playerFrame, 0, -6)
playerFrame.title:SetText("Blackjack Player")

-- Enabling click-and-drag functionality
playerFrame:SetMovable(true)
playerFrame:EnableMouse(true)
playerFrame:RegisterForDrag("LeftButton")

-- Script for handling the drag of playerFrame
playerFrame:SetScript("OnDragStart", function(self)
    self:StartMoving()
end)

playerFrame:SetScript("OnDragStop", function(self)
    self:StopMovingOrSizing()
end)

-- Setting background texture (Blackjack Table)
local backgroundImage = playerFrame:CreateTexture(nil, "BACKGROUND")
backgroundImage:SetSize(2048, 1024)
backgroundImage:SetPoint("TOP", playerFrame, "TOP", 17, 187)
backgroundImage:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\blackjackplayer.tga")
backgroundImage:SetBlendMode("BLEND")
backgroundImage:SetDrawLayer("ARTWORK")

--
--
--

-- playerFrame extras
-- Creating the History button
playerFrame.historyButton = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.historyButton:SetPoint("TOPRIGHT", playerFrame, -23, -70)
playerFrame.historyButton:SetSize(80, 30)
playerFrame.historyButton:SetText("History")
playerFrame.historyButton:Disable()

-- Add a leave table button
playerFrame.leaveTableButton = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.leaveTableButton:SetPoint("BOTTOMRIGHT", playerFrame, -20, 50)
playerFrame.leaveTableButton:SetSize(100, 30)
playerFrame.leaveTableButton:SetText("Leave Table")
-- Disclaimer text below leave table button
playerFrame.DisclaimerText = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.DisclaimerText:SetPoint("BOTTOMRIGHT", playerFrame, -20, 20)
playerFrame.DisclaimerText:SetJustifyH("RIGHT")
playerFrame.DisclaimerText:SetText("Please play responsibly. Only stake what you can\nafford to lose. When the fun stops - stop immediately.") -- Get the character's name
playerFrame.DisclaimerText:SetTextColor(1 , 0, 0)
playerFrame.DisclaimerText:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE") -- Adjust the font and size as needed
-- Table limit text in corner
local tableLimitText = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
tableLimitText:SetPoint("BOTTOMLEFT", playerFrame, 17, 17)
tableLimitText:SetFont("Fonts\\FRIZQT__.TTF", 14, "OUTLINE")
tableLimitText:SetText("Table Limits:    50 G - 1500 G\n  Side Bets:         5 G -    400 G")

-- Timer Limit 1
playerFrame.timerText1 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
playerFrame.timerText1:SetFont("Fonts\\FRIZQT__.TTF", 18, "OUTLINE")

-- Timer Limit 2
playerFrame.timerText2 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
playerFrame.timerText2:SetFont("Fonts\\FRIZQT__.TTF", 18, "OUTLINE")

-- Timer Limit 3
playerFrame.timerText3 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
playerFrame.timerText3:SetFont("Fonts\\FRIZQT__.TTF", 18, "OUTLINE")

-- Timer Limit 4
playerFrame.timerText4 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
playerFrame.timerText4:SetFont("Fonts\\FRIZQT__.TTF", 18, "OUTLINE")

-- Timer Limit 5
playerFrame.timerText5 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
playerFrame.timerText5:SetFont("Fonts\\FRIZQT__.TTF", 18, "OUTLINE")

-- Timer Limit Bets
playerFrame.timerTextBets = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
playerFrame.timerTextBets:SetPoint("LEFT", playerFrame, 227, 200)
playerFrame.timerTextBets:SetFont("Fonts\\FRIZQT__.TTF", 40, "OUTLINE")
playerFrame.timerTextBets:SetJustifyH("CENTER")


-- Function to disable the "Join Table" button and hide the Blackjack Player frame
local function PlayerFrameHide()
    playerFrame:Hide()
    initialFrame.joinButton:Disable()
    initialFrame:Show()
end



-- Add a click event handler to the "Join Table" button
initialFrame.reloadButton:SetScript("OnClick", function(self, button, down)
    local chatFrame = SELECTED_DOCK_FRAME
    ChatFrame_OpenChat("/reload", chatFrame)
    local editBox = _G[chatFrame:GetName().."EditBox"]
    editBox:Insert("/reload")
    ChatEdit_SendText(editBox)
    SendChatMessage("Initiating..", "RAID")
end)





-- Payouts window
-- Creating the payoutsFrame
local payoutsFrame = CreateFrame("Frame", "BlackjackPayoutsFrame", UIParent, "BasicFrameTemplateWithInset")
payoutsFrame:SetSize(275, 720)
payoutsFrame:SetPoint("LEFT", playerFrame, "TOPRIGHT", -3, -360)
payoutsFrame:SetFrameStrata("HIGH")
payoutsFrame:SetFrameLevel(1)
payoutsFrame:Hide()

-- Setting a title
payoutsFrame.title = payoutsFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.title:SetPoint("TOP", payoutsFrame, 0, -6)
payoutsFrame.title:SetText("Payouts")

-- Creating the Payouts button
playerFrame.payoutsButton = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.payoutsButton:SetPoint("TOPRIGHT", playerFrame, -23, -40)
playerFrame.payoutsButton:SetSize(80, 30)
playerFrame.payoutsButton:SetText("Payouts")



-- Headings
-- Main Bets
payoutsFrame.mainBetsTitle = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.mainBetsTitle:SetPoint("TOPLEFT", payoutsFrame, 15, -36)
payoutsFrame.mainBetsTitle:SetJustifyH("LEFT")
payoutsFrame.mainBetsTitle:SetText("Main Bets")
payoutsFrame.mainBetsTitle:SetFont("Fonts\\FRIZQT__.TTF", 16, "OUTLINE")
payoutsFrame.mainBetsTitle:SetTextColor(1, 0, 0)
payoutsFrame.mainBetsTitle:Hide()
-- Side Bets
payoutsFrame.sideBetsTitle = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.sideBetsTitle:SetPoint("TOPLEFT", payoutsFrame, 15, -135)
payoutsFrame.sideBetsTitle:SetJustifyH("LEFT")
payoutsFrame.sideBetsTitle:SetText("Side Bets")
payoutsFrame.sideBetsTitle:SetFont("Fonts\\FRIZQT__.TTF", 16, "OUTLINE")
payoutsFrame.sideBetsTitle:SetTextColor(1, 0, 0)
payoutsFrame.sideBetsTitle:Hide()
-- Perfect Pairs
payoutsFrame.perfectPairsTitle = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.perfectPairsTitle:SetPoint("TOPLEFT", payoutsFrame, 15, -155)
payoutsFrame.perfectPairsTitle:SetJustifyH("LEFT")
payoutsFrame.perfectPairsTitle:SetText("Perfect Pairs (PP)")
payoutsFrame.perfectPairsTitle:SetTextColor(1, 0.298, 0.298)
payoutsFrame.perfectPairsTitle:SetFont("Fonts\\FRIZQT__.TTF", 14, "OUTLINE")
payoutsFrame.perfectPairsTitle:Hide()
-- Perfect Pairs (explain)
payoutsFrame.perfectPairsExplain = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.perfectPairsExplain:SetPoint("TOPLEFT", payoutsFrame, 147, -156)
payoutsFrame.perfectPairsExplain:SetJustifyH("LEFT")
payoutsFrame.perfectPairsExplain:SetText("(Player's 2 Cards)")
payoutsFrame.perfectPairsExplain:SetTextColor(1, 0.298, 0.298)
payoutsFrame.perfectPairsExplain:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
payoutsFrame.perfectPairsExplain:Hide()
-- 21+3
payoutsFrame.t213Title = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.t213Title:SetPoint("TOPLEFT", payoutsFrame, 15, -325)
payoutsFrame.t213Title:SetJustifyH("LEFT")
payoutsFrame.t213Title:SetText("21+3")
payoutsFrame.t213Title:SetTextColor(1, 0.298, 0.298)
payoutsFrame.t213Title:SetFont("Fonts\\FRIZQT__.TTF", 14, "OUTLINE")
payoutsFrame.t213Title:Hide()
-- 21+3 (explain)
payoutsFrame.t213Explain = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.t213Explain:SetPoint("TOPLEFT", payoutsFrame, 62, -327)
payoutsFrame.t213Explain:SetJustifyH("LEFT")
payoutsFrame.t213Explain:SetText("(Player's 2 Cards + Dealer's Upcard)")
payoutsFrame.t213Explain:SetTextColor(1, 0.298, 0.298)
payoutsFrame.t213Explain:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
payoutsFrame.t213Explain:Hide()
-- 21+3 (explain) 2
payoutsFrame.t213Explain2 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.t213Explain2:SetPoint("TOPLEFT", payoutsFrame, 198, -370)
payoutsFrame.t213Explain2:SetJustifyH("RIGHT")
payoutsFrame.t213Explain2:SetText("Any Card\n\nSame Suit")
payoutsFrame.t213Explain2:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
payoutsFrame.t213Explain2:Hide()
-- 21+3 (explain) 3
payoutsFrame.t213Explain3 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.t213Explain3:SetPoint("TOPLEFT", payoutsFrame, 176, -444)
payoutsFrame.t213Explain3:SetJustifyH("RIGHT")
payoutsFrame.t213Explain3:SetText("Numeric Order\n\nAny Suit")
payoutsFrame.t213Explain3:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
payoutsFrame.t213Explain3:Hide()
-- 21+3 (explain) 4
payoutsFrame.t213Explain4 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.t213Explain4:SetPoint("TOPLEFT", payoutsFrame, 198, -519)
payoutsFrame.t213Explain4:SetJustifyH("RIGHT")
payoutsFrame.t213Explain4:SetText("Same Card\n\nAny Suit")
payoutsFrame.t213Explain4:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
payoutsFrame.t213Explain4:Hide()
-- 21+3 (explain) 5
payoutsFrame.t213Explain5 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.t213Explain5:SetPoint("TOPLEFT", payoutsFrame, 176, -589)
payoutsFrame.t213Explain5:SetJustifyH("RIGHT")
payoutsFrame.t213Explain5:SetText("Numeric Order\n\nSame Suit")
payoutsFrame.t213Explain5:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
payoutsFrame.t213Explain5:Hide()
-- 21+3 (explain) 6
payoutsFrame.t213Explain6 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.t213Explain6:SetPoint("TOPLEFT", payoutsFrame, 198, -663)
payoutsFrame.t213Explain6:SetJustifyH("RIGHT")
payoutsFrame.t213Explain6:SetText("Same Card\n\nSame Suit")
payoutsFrame.t213Explain6:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
payoutsFrame.t213Explain6:Hide()




-- Subheadings and Payouts
-- Standard
payoutsFrame.mainBetStandard = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.mainBetStandard:SetPoint("TOPLEFT", payoutsFrame, 15, -60)
payoutsFrame.mainBetStandard:SetJustifyH("LEFT")
payoutsFrame.mainBetStandard:SetText("Standard")
payoutsFrame.mainBetStandard:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
payoutsFrame.mainBetStandard:Hide()
-- Standard 1:1
payoutsFrame.standardPayout = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.standardPayout:SetPoint("TOPLEFT", payoutsFrame, 87, -93)
payoutsFrame.standardPayout:SetJustifyH("LEFT")
payoutsFrame.standardPayout:SetText("1:1")
payoutsFrame.standardPayout:SetTextColor(1, 0.973, 0.4)
payoutsFrame.standardPayout:SetFont("Fonts\\FRIZQT__.TTF", 16, "OUTLINE")
payoutsFrame.standardPayout:Hide()
-- Blackjack
payoutsFrame.mainBetBlackjack = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.mainBetBlackjack:SetPoint("TOPLEFT", payoutsFrame, 137, -60)
payoutsFrame.mainBetBlackjack:SetJustifyH("LEFT")
payoutsFrame.mainBetBlackjack:SetText("Blackjack")
payoutsFrame.mainBetBlackjack:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
payoutsFrame.mainBetBlackjack:Hide()
-- Blackjack 3:2
payoutsFrame.blackjackPayout = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.blackjackPayout:SetPoint("TOPLEFT", payoutsFrame, 214, -93)
payoutsFrame.blackjackPayout:SetJustifyH("LEFT")
payoutsFrame.blackjackPayout:SetText("3:2")
payoutsFrame.blackjackPayout:SetTextColor(1, 0.973, 0.4)
payoutsFrame.blackjackPayout:SetFont("Fonts\\FRIZQT__.TTF", 16, "OUTLINE")
payoutsFrame.blackjackPayout:Hide()
-- (PP) Mixed Pair
payoutsFrame.mixedPairPP = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.mixedPairPP:SetPoint("TOPLEFT", payoutsFrame, 15, -175)
payoutsFrame.mixedPairPP:SetJustifyH("LEFT")
payoutsFrame.mixedPairPP:SetText("Mixed Pair")
payoutsFrame.mixedPairPP:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
payoutsFrame.mixedPairPP:Hide()
-- (PP) Mixed Pair 5:1
payoutsFrame.mixedPairPayout = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.mixedPairPayout:SetPoint("TOPLEFT", payoutsFrame, 89, -208)
payoutsFrame.mixedPairPayout:SetJustifyH("LEFT")
payoutsFrame.mixedPairPayout:SetText("5:1")
payoutsFrame.mixedPairPayout:SetTextColor(1, 0.973, 0.4)
payoutsFrame.mixedPairPayout:SetFont("Fonts\\FRIZQT__.TTF", 16, "OUTLINE")
payoutsFrame.mixedPairPayout:Hide()
-- (PP) Coloured Pair
payoutsFrame.colouredPairPP = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.colouredPairPP:SetPoint("TOPLEFT", payoutsFrame, 138, -175)
payoutsFrame.colouredPairPP:SetJustifyH("LEFT")
payoutsFrame.colouredPairPP:SetText("Coloured Pair")
payoutsFrame.colouredPairPP:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
payoutsFrame.colouredPairPP:Hide()
-- (PP) Coloured Pair 10:1
payoutsFrame.colouredPairPayout = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.colouredPairPayout:SetPoint("TOPLEFT", payoutsFrame, 212, -208)
payoutsFrame.colouredPairPayout:SetJustifyH("LEFT")
payoutsFrame.colouredPairPayout:SetText("10:1")
payoutsFrame.colouredPairPayout:SetTextColor(1, 0.973, 0.4)
payoutsFrame.colouredPairPayout:SetFont("Fonts\\FRIZQT__.TTF", 16, "OUTLINE")
payoutsFrame.colouredPairPayout:Hide()
-- (PP) Perfect Pair
payoutsFrame.perfectPairPP = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.perfectPairPP:SetPoint("TOPLEFT", payoutsFrame, 15, -248)
payoutsFrame.perfectPairPP:SetJustifyH("LEFT")
payoutsFrame.perfectPairPP:SetText("Perfect Pair")
payoutsFrame.perfectPairPP:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
payoutsFrame.perfectPairPP:Hide()
-- (PP) Perfect Pair 30:1
payoutsFrame.perfectPairPayout = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.perfectPairPayout:SetPoint("TOPLEFT", payoutsFrame, 89, -280)
payoutsFrame.perfectPairPayout:SetJustifyH("LEFT")
payoutsFrame.perfectPairPayout:SetText("30:1")
payoutsFrame.perfectPairPayout:SetTextColor(1, 0.973, 0.4)
payoutsFrame.perfectPairPayout:SetFont("Fonts\\FRIZQT__.TTF", 16, "OUTLINE")
payoutsFrame.perfectPairPayout:Hide()
-- Flush
payoutsFrame.flush213 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.flush213:SetPoint("TOPLEFT", payoutsFrame, 15, -345)
payoutsFrame.flush213:SetJustifyH("LEFT")
payoutsFrame.flush213:SetText("Flush")
payoutsFrame.flush213:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
payoutsFrame.flush213:Hide()
-- Flush 5:1
payoutsFrame.flushPayout = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.flushPayout:SetPoint("TOPLEFT", payoutsFrame, 124, -377)
payoutsFrame.flushPayout:SetJustifyH("LEFT")
payoutsFrame.flushPayout:SetText("5:1")
payoutsFrame.flushPayout:SetTextColor(1, 0.973, 0.4)
payoutsFrame.flushPayout:SetFont("Fonts\\FRIZQT__.TTF", 16, "OUTLINE")
payoutsFrame.flushPayout:Hide()
-- Straight
payoutsFrame.straight213 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.straight213:SetPoint("TOPLEFT", payoutsFrame, 15, -417)
payoutsFrame.straight213:SetJustifyH("LEFT")
payoutsFrame.straight213:SetText("Straight")
payoutsFrame.straight213:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
payoutsFrame.straight213:Hide()
-- Straight 10:1
payoutsFrame.straightPayout = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.straightPayout:SetPoint("TOPLEFT", payoutsFrame, 123, -450)
payoutsFrame.straightPayout:SetJustifyH("LEFT")
payoutsFrame.straightPayout:SetText("10:1")
payoutsFrame.straightPayout:SetTextColor(1, 0.973, 0.4)
payoutsFrame.straightPayout:SetFont("Fonts\\FRIZQT__.TTF", 16, "OUTLINE")
payoutsFrame.straightPayout:Hide()
-- Three of a Kind
payoutsFrame.threeOfAKind213 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.threeOfAKind213:SetPoint("TOPLEFT", payoutsFrame, 15, -491)
payoutsFrame.threeOfAKind213:SetJustifyH("LEFT")
payoutsFrame.threeOfAKind213:SetText("Three of a Kind")
payoutsFrame.threeOfAKind213:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
payoutsFrame.threeOfAKind213:Hide()
-- Three of a Kind 30:1
payoutsFrame.threeOfAKindPayout = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.threeOfAKindPayout:SetPoint("TOPLEFT", payoutsFrame, 125, -525)
payoutsFrame.threeOfAKindPayout:SetJustifyH("LEFT")
payoutsFrame.threeOfAKindPayout:SetText("30:1")
payoutsFrame.threeOfAKindPayout:SetTextColor(1, 0.973, 0.4)
payoutsFrame.threeOfAKindPayout:SetFont("Fonts\\FRIZQT__.TTF", 16, "OUTLINE")
payoutsFrame.threeOfAKindPayout:Hide()
-- Straight Flush
payoutsFrame.straightFlush213 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.straightFlush213:SetPoint("TOPLEFT", payoutsFrame, 15, -563)
payoutsFrame.straightFlush213:SetJustifyH("LEFT")
payoutsFrame.straightFlush213:SetText("Straight Flush")
payoutsFrame.straightFlush213:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
payoutsFrame.straightFlush213:Hide()
-- Straight Flush 40:1
payoutsFrame.straightFlushPayout = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.straightFlushPayout:SetPoint("TOPLEFT", payoutsFrame, 124, -595)
payoutsFrame.straightFlushPayout:SetJustifyH("LEFT")
payoutsFrame.straightFlushPayout:SetText("40:1")
payoutsFrame.straightFlushPayout:SetTextColor(1, 0.973, 0.4)
payoutsFrame.straightFlushPayout:SetFont("Fonts\\FRIZQT__.TTF", 16, "OUTLINE")
payoutsFrame.straightFlushPayout:Hide()
-- Suited Three of a Kind
payoutsFrame.suitedThreeOfAKind213 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.suitedThreeOfAKind213:SetPoint("TOPLEFT", payoutsFrame, 15, -637)
payoutsFrame.suitedThreeOfAKind213:SetJustifyH("LEFT")
payoutsFrame.suitedThreeOfAKind213:SetText("Suited Three of a Kind")
payoutsFrame.suitedThreeOfAKind213:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
payoutsFrame.suitedThreeOfAKind213:Hide()
-- Suited Three of a Kind 100:1
payoutsFrame.suitedThreeOfAKindPayout = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
payoutsFrame.suitedThreeOfAKindPayout:SetPoint("TOPLEFT", payoutsFrame, 123, -669)
payoutsFrame.suitedThreeOfAKindPayout:SetJustifyH("LEFT")
payoutsFrame.suitedThreeOfAKindPayout:SetText("100:1")
payoutsFrame.suitedThreeOfAKindPayout:SetTextColor(1, 0.973, 0.4)
payoutsFrame.suitedThreeOfAKindPayout:SetFont("Fonts\\FRIZQT__.TTF", 16, "OUTLINE")
payoutsFrame.suitedThreeOfAKindPayout:Hide()



-- Creating card textures
-- Standard 1
payoutsFrame.card1image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card1image:SetSize(32, 64)
payoutsFrame.card1image:SetPoint("TOPLEFT", payoutsFrame, 17, -70)
payoutsFrame.card1image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\JH.tga")
payoutsFrame.card1image:SetBlendMode("BLEND")
payoutsFrame.card1image:SetDrawLayer("ARTWORK")
payoutsFrame.card1image:Hide()
-- Standard 2
payoutsFrame.card2image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card2image:SetSize(32, 64)
payoutsFrame.card2image:SetPoint("TOPLEFT", payoutsFrame, 52, -70)
payoutsFrame.card2image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\8S.tga")
payoutsFrame.card2image:SetBlendMode("BLEND")
payoutsFrame.card2image:SetDrawLayer("ARTWORK")
payoutsFrame.card2image:Hide()
-- Blackjack 1
payoutsFrame.card3image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card3image:SetSize(32, 64)
payoutsFrame.card3image:SetPoint("TOPLEFT", payoutsFrame, 140, -70)
payoutsFrame.card3image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\AS.tga")
payoutsFrame.card3image:SetBlendMode("BLEND")
payoutsFrame.card3image:SetDrawLayer("ARTWORK")
payoutsFrame.card3image:Hide()
-- Blackjack 2
payoutsFrame.card4image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card4image:SetSize(32, 64)
payoutsFrame.card4image:SetPoint("TOPLEFT", payoutsFrame, 176, -70)
payoutsFrame.card4image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\QD.tga")
payoutsFrame.card4image:SetBlendMode("BLEND")
payoutsFrame.card4image:SetDrawLayer("ARTWORK")
payoutsFrame.card4image:Hide()
-- (PP) Mixed Pair 1
payoutsFrame.card5image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card5image:SetSize(32, 64)
payoutsFrame.card5image:SetPoint("TOPLEFT", payoutsFrame, 17, -185)
payoutsFrame.card5image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\2C.tga")
payoutsFrame.card5image:SetBlendMode("BLEND")
payoutsFrame.card5image:SetDrawLayer("ARTWORK")
payoutsFrame.card5image:Hide()
-- (PP) Mixed Pair 2
payoutsFrame.card6image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card6image:SetSize(32, 64)
payoutsFrame.card6image:SetPoint("TOPLEFT", payoutsFrame, 52, -185)
payoutsFrame.card6image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\2D.tga")
payoutsFrame.card6image:SetBlendMode("BLEND")
payoutsFrame.card6image:SetDrawLayer("ARTWORK")
payoutsFrame.card6image:Hide()
-- (PP) Coloured Pair 1
payoutsFrame.card7image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card7image:SetSize(32, 64)
payoutsFrame.card7image:SetPoint("TOPLEFT", payoutsFrame, 140, -185)
payoutsFrame.card7image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\6S.tga")
payoutsFrame.card7image:SetBlendMode("BLEND")
payoutsFrame.card7image:SetDrawLayer("ARTWORK")
payoutsFrame.card7image:Hide()
-- (PP) Coloured Pair 2
payoutsFrame.card8image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card8image:SetSize(32, 64)
payoutsFrame.card8image:SetPoint("TOPLEFT", payoutsFrame, 176, -185)
payoutsFrame.card8image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\6C.tga")
payoutsFrame.card8image:SetBlendMode("BLEND")
payoutsFrame.card8image:SetDrawLayer("ARTWORK")
payoutsFrame.card8image:Hide()
-- (PP) Perfect Pair 1
payoutsFrame.card9image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card9image:SetSize(32, 64)
payoutsFrame.card9image:SetPoint("TOPLEFT", payoutsFrame, 17, -257)
payoutsFrame.card9image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\5D.tga")
payoutsFrame.card9image:SetBlendMode("BLEND")
payoutsFrame.card9image:SetDrawLayer("ARTWORK")
payoutsFrame.card9image:Hide()
-- (PP) Perfect Pair 2
payoutsFrame.card10image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card10image:SetSize(32, 64)
payoutsFrame.card10image:SetPoint("TOPLEFT", payoutsFrame, 52, -257)
payoutsFrame.card10image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\5D.tga")
payoutsFrame.card10image:SetBlendMode("BLEND")
payoutsFrame.card10image:SetDrawLayer("ARTWORK")
payoutsFrame.card10image:Hide()
-- (21+3) Flush 1
payoutsFrame.card11image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card11image:SetSize(32, 64)
payoutsFrame.card11image:SetPoint("TOPLEFT", payoutsFrame, 17, -354)
payoutsFrame.card11image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\3S.tga")
payoutsFrame.card11image:SetBlendMode("BLEND")
payoutsFrame.card11image:SetDrawLayer("ARTWORK")
payoutsFrame.card11image:Hide()
-- (21+3) Flush 2
payoutsFrame.card12image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card12image:SetSize(32, 64)
payoutsFrame.card12image:SetPoint("TOPLEFT", payoutsFrame, 52, -354)
payoutsFrame.card12image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\7S.tga")
payoutsFrame.card12image:SetBlendMode("BLEND")
payoutsFrame.card12image:SetDrawLayer("ARTWORK")
payoutsFrame.card12image:Hide()
-- (21+3) Flush 3
payoutsFrame.card13image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card13image:SetSize(32, 64)
payoutsFrame.card13image:SetPoint("TOPLEFT", payoutsFrame, 88, -354)
payoutsFrame.card13image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\QS.tga")
payoutsFrame.card13image:SetBlendMode("BLEND")
payoutsFrame.card13image:SetDrawLayer("ARTWORK")
payoutsFrame.card13image:Hide()
-- (21+3) Straight 1
payoutsFrame.card14image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card14image:SetSize(32, 64)
payoutsFrame.card14image:SetPoint("TOPLEFT", payoutsFrame, 17, -426)
payoutsFrame.card14image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\2H.tga")
payoutsFrame.card14image:SetBlendMode("BLEND")
payoutsFrame.card14image:SetDrawLayer("ARTWORK")
payoutsFrame.card14image:Hide()
-- (21+3) Straight 2
payoutsFrame.card15image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card15image:SetSize(32, 64)
payoutsFrame.card15image:SetPoint("TOPLEFT", payoutsFrame, 52, -426)
payoutsFrame.card15image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\3C.tga")
payoutsFrame.card15image:SetBlendMode("BLEND")
payoutsFrame.card15image:SetDrawLayer("ARTWORK")
payoutsFrame.card15image:Hide()
-- (21+3) Straight 3
payoutsFrame.card16image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card16image:SetSize(32, 64)
payoutsFrame.card16image:SetPoint("TOPLEFT", payoutsFrame, 88, -426)
payoutsFrame.card16image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\4D.tga")
payoutsFrame.card16image:SetBlendMode("BLEND")
payoutsFrame.card16image:SetDrawLayer("ARTWORK")
payoutsFrame.card16image:Hide()
-- (21+3) Three of a Kind 1
payoutsFrame.card17image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card17image:SetSize(32, 64)
payoutsFrame.card17image:SetPoint("TOPLEFT", payoutsFrame, 17, -500)
payoutsFrame.card17image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\AC.tga")
payoutsFrame.card17image:SetBlendMode("BLEND")
payoutsFrame.card17image:SetDrawLayer("ARTWORK")
payoutsFrame.card17image:Hide()
-- (21+3) Three of a Kind 2
payoutsFrame.card18image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card18image:SetSize(32, 64)
payoutsFrame.card18image:SetPoint("TOPLEFT", payoutsFrame, 52, -500)
payoutsFrame.card18image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\AD.tga")
payoutsFrame.card18image:SetBlendMode("BLEND")
payoutsFrame.card18image:SetDrawLayer("ARTWORK")
payoutsFrame.card18image:Hide()
-- (21+3) Three of a Kind 3
payoutsFrame.card19image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card19image:SetSize(32, 64)
payoutsFrame.card19image:SetPoint("TOPLEFT", payoutsFrame, 88, -500)
payoutsFrame.card19image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\AH.tga")
payoutsFrame.card19image:SetBlendMode("BLEND")
payoutsFrame.card19image:SetDrawLayer("ARTWORK")
payoutsFrame.card19image:Hide()
-- (21+3) Straight Flush 1
payoutsFrame.card20image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card20image:SetSize(32, 64)
payoutsFrame.card20image:SetPoint("TOPLEFT", payoutsFrame, 17, -572)
payoutsFrame.card20image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\2D.tga")
payoutsFrame.card20image:SetBlendMode("BLEND")
payoutsFrame.card20image:SetDrawLayer("ARTWORK")
payoutsFrame.card20image:Hide()
-- (21+3) Straight Flush 2
payoutsFrame.card21image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card21image:SetSize(32, 64)
payoutsFrame.card21image:SetPoint("TOPLEFT", payoutsFrame, 52, -572)
payoutsFrame.card21image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\3D.tga")
payoutsFrame.card21image:SetBlendMode("BLEND")
payoutsFrame.card21image:SetDrawLayer("ARTWORK")
payoutsFrame.card21image:Hide()
-- (21+3) Straight Flush 3
payoutsFrame.card22image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card22image:SetSize(32, 64)
payoutsFrame.card22image:SetPoint("TOPLEFT", payoutsFrame, 88, -572)
payoutsFrame.card22image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\4D.tga")
payoutsFrame.card22image:SetBlendMode("BLEND")
payoutsFrame.card22image:SetDrawLayer("ARTWORK")
payoutsFrame.card22image:Hide()
-- (21+3) Suited Three of a Kind 1
payoutsFrame.card23image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card23image:SetSize(32, 64)
payoutsFrame.card23image:SetPoint("TOPLEFT", payoutsFrame, 17, -646)
payoutsFrame.card23image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\AS.tga")
payoutsFrame.card23image:SetBlendMode("BLEND")
payoutsFrame.card23image:SetDrawLayer("ARTWORK")
payoutsFrame.card23image:Hide()
-- (21+3) Suited Three of a Kind 2
payoutsFrame.card24image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card24image:SetSize(32, 64)
payoutsFrame.card24image:SetPoint("TOPLEFT", payoutsFrame, 52, -646)
payoutsFrame.card24image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\AS.tga")
payoutsFrame.card24image:SetBlendMode("BLEND")
payoutsFrame.card24image:SetDrawLayer("ARTWORK")
payoutsFrame.card24image:Hide()
-- (21+3) Suited Three of a Kind 3
payoutsFrame.card25image = payoutsFrame:CreateTexture(nil, "OVERLAY")
payoutsFrame.card25image:SetSize(32, 64)
payoutsFrame.card25image:SetPoint("TOPLEFT", payoutsFrame, 88, -646)
payoutsFrame.card25image:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\AS.tga")
payoutsFrame.card25image:SetBlendMode("BLEND")
payoutsFrame.card25image:SetDrawLayer("ARTWORK")
payoutsFrame.card25image:Hide()



-- Payouts button click function
playerFrame.payoutsButton:SetScript("OnClick", function()
    if payoutsFrame:IsShown() then
        payoutsFrame:Hide()
        payoutsFrame.mainBetsTitle:Hide()
        payoutsFrame.sideBetsTitle:Hide()
        payoutsFrame.perfectPairsTitle:Hide()
        payoutsFrame.perfectPairsExplain:Hide()
        payoutsFrame.t213Title:Hide()
        payoutsFrame.t213Explain:Hide()
        payoutsFrame.t213Explain2:Hide()
        payoutsFrame.t213Explain3:Hide()
        payoutsFrame.t213Explain4:Hide()
        payoutsFrame.t213Explain5:Hide()
        payoutsFrame.t213Explain6:Hide()
        payoutsFrame.mainBetStandard:Hide()
        payoutsFrame.standardPayout:Hide()
        payoutsFrame.mainBetBlackjack:Hide()
        payoutsFrame.blackjackPayout:Hide()
        payoutsFrame.mixedPairPP:Hide()
        payoutsFrame.mixedPairPayout:Hide()
        payoutsFrame.colouredPairPP:Hide()
        payoutsFrame.colouredPairPayout:Hide()
        payoutsFrame.perfectPairPP:Hide()
        payoutsFrame.perfectPairPayout:Hide()
        payoutsFrame.flush213:Hide()
        payoutsFrame.flushPayout:Hide()
        payoutsFrame.straight213:Hide()
        payoutsFrame.straightPayout:Hide()
        payoutsFrame.threeOfAKind213:Hide()
        payoutsFrame.threeOfAKindPayout:Hide()
        payoutsFrame.straightFlush213:Hide()
        payoutsFrame.straightFlushPayout:Hide()
        payoutsFrame.suitedThreeOfAKind213:Hide()
        payoutsFrame.suitedThreeOfAKindPayout:Hide()
        payoutsFrame.card1image:Hide()
        payoutsFrame.card2image:Hide()
        payoutsFrame.card3image:Hide()
        payoutsFrame.card4image:Hide()
        payoutsFrame.card5image:Hide()
        payoutsFrame.card6image:Hide()
        payoutsFrame.card7image:Hide()
        payoutsFrame.card8image:Hide()
        payoutsFrame.card9image:Hide()
        payoutsFrame.card10image:Hide()
        payoutsFrame.card11image:Hide()
        payoutsFrame.card12image:Hide()
        payoutsFrame.card13image:Hide()
        payoutsFrame.card14image:Hide()
        payoutsFrame.card15image:Hide()
        payoutsFrame.card16image:Hide()
        payoutsFrame.card17image:Hide()
        payoutsFrame.card18image:Hide()
        payoutsFrame.card19image:Hide()
        payoutsFrame.card20image:Hide()
        payoutsFrame.card21image:Hide()
        payoutsFrame.card22image:Hide()
        payoutsFrame.card23image:Hide()
        payoutsFrame.card24image:Hide()
        payoutsFrame.card25image:Hide()
    else
        payoutsFrame:Show()
        payoutsFrame.mainBetsTitle:Show()
        payoutsFrame.sideBetsTitle:Show()
        payoutsFrame.perfectPairsTitle:Show()
        payoutsFrame.perfectPairsExplain:Show()
        payoutsFrame.t213Title:Show()
        payoutsFrame.t213Explain:Show()
        payoutsFrame.t213Explain2:Show()
        payoutsFrame.t213Explain3:Show()
        payoutsFrame.t213Explain4:Show()
        payoutsFrame.t213Explain5:Show()
        payoutsFrame.t213Explain6:Show()
        payoutsFrame.mainBetStandard:Show()
        payoutsFrame.standardPayout:Show()
        payoutsFrame.mainBetBlackjack:Show()
        payoutsFrame.blackjackPayout:Show()
        payoutsFrame.mixedPairPP:Show()
        payoutsFrame.mixedPairPayout:Show()
        payoutsFrame.colouredPairPP:Show()
        payoutsFrame.colouredPairPayout:Show()
        payoutsFrame.perfectPairPP:Show()
        payoutsFrame.perfectPairPayout:Show()
        payoutsFrame.flush213:Show()
        payoutsFrame.flushPayout:Show()
        payoutsFrame.straight213:Show()
        payoutsFrame.straightPayout:Show()
        payoutsFrame.threeOfAKind213:Show()
        payoutsFrame.threeOfAKindPayout:Show()
        payoutsFrame.straightFlush213:Show()
        payoutsFrame.straightFlushPayout:Show()
        payoutsFrame.suitedThreeOfAKind213:Show()
        payoutsFrame.suitedThreeOfAKindPayout:Show()
        payoutsFrame.card1image:Show()
        payoutsFrame.card2image:Show()
        payoutsFrame.card3image:Show()
        payoutsFrame.card4image:Show()
        payoutsFrame.card5image:Show()
        payoutsFrame.card6image:Show()
        payoutsFrame.card7image:Show()
        payoutsFrame.card8image:Show()
        payoutsFrame.card9image:Show()
        payoutsFrame.card10image:Show()
        payoutsFrame.card11image:Show()
        payoutsFrame.card12image:Show()
        payoutsFrame.card13image:Show()
        payoutsFrame.card14image:Show()
        payoutsFrame.card15image:Show()
        payoutsFrame.card16image:Show()
        payoutsFrame.card17image:Show()
        payoutsFrame.card18image:Show()
        payoutsFrame.card19image:Show()
        payoutsFrame.card20image:Show()
        payoutsFrame.card21image:Show()
        payoutsFrame.card22image:Show()
        payoutsFrame.card23image:Show()
        payoutsFrame.card24image:Show()
        payoutsFrame.card25image:Show()
    end
end)





-- Insurance YES for Player 1
insuranceYesIcon1 = playerFrame:CreateTexture(nil, "OVERLAY")
insuranceYesIcon1:SetSize(32, 32)
insuranceYesIcon1:SetPoint("CENTER", playerFrame, 539, -9)
insuranceYesIcon1:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\insuranceYes.tga")
insuranceYesIcon1:SetDrawLayer("ARTWORK")
insuranceYesIcon1:Hide()

-- Insurance NO for Player 1
insuranceNoIcon1 = playerFrame:CreateTexture(nil, "OVERLAY")
insuranceNoIcon1:SetSize(32, 32)
insuranceNoIcon1:SetPoint("CENTER", playerFrame, 539, -9)
insuranceNoIcon1:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\insuranceNo.tga")
insuranceNoIcon1:SetDrawLayer("ARTWORK")
insuranceNoIcon1:Hide()



-- Buttons for Player 1
-- Hit
playerFrame.hitButton1 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.hitButton1:SetPoint("BOTTOM", playerFrame, 419, 275)
playerFrame.hitButton1:SetSize(65, 30)
playerFrame.hitButton1:SetText("Hit")
playerFrame.hitButton1:Disable()
-- Stand
playerFrame.standButton1 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.standButton1:SetPoint("BOTTOM", playerFrame, 485, 275)
playerFrame.standButton1:SetSize(65, 30)
playerFrame.standButton1:SetText("Stand")
playerFrame.standButton1:Disable()
-- Double
playerFrame.doubleButton1 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.doubleButton1:SetPoint("BOTTOM", playerFrame, 419, 245)
playerFrame.doubleButton1:SetSize(65, 30)
playerFrame.doubleButton1:SetText("Double")
playerFrame.doubleButton1:Disable()
-- Split
playerFrame.splitButton1 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.splitButton1:SetPoint("BOTTOM", playerFrame, 485, 245)
playerFrame.splitButton1:SetSize(65, 30)
playerFrame.splitButton1:SetText("Split")
playerFrame.splitButton1:Disable()
-- Insurance Yes
playerFrame.insuranceYesButton1 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.insuranceYesButton1:SetPoint("BOTTOM", playerFrame, 387, 215)
playerFrame.insuranceYesButton1:SetSize(55, 30)
playerFrame.insuranceYesButton1:SetText("Yes")
playerFrame.insuranceYesButton1:Disable()
-- Insurance No
playerFrame.insuranceNoButton1 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.insuranceNoButton1:SetPoint("BOTTOM", playerFrame, 515, 215)
playerFrame.insuranceNoButton1:SetSize(55, 30)
playerFrame.insuranceNoButton1:SetText("No")
playerFrame.insuranceNoButton1:Disable()
-- Main Bet Confirm
local confirmBetButtonMain1 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
confirmBetButtonMain1:SetPoint("BOTTOM", playerFrame, 485, 335)
confirmBetButtonMain1:SetSize(65, 30)
confirmBetButtonMain1:SetText("Bet")
-- Perfect Pairs Confirm
local confirmBetButtonPP1 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
confirmBetButtonPP1:SetPoint("BOTTOM", playerFrame, 309, 335)
confirmBetButtonPP1:SetSize(43, 25)
confirmBetButtonPP1:SetText("Bet")
-- 21+3 Confirm
local confirmBetButton2131 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
confirmBetButton2131:SetPoint("BOTTOM", playerFrame, 385, 470)
confirmBetButton2131:SetSize(43, 25)
confirmBetButton2131:SetText("Bet")



-- Wagers for Player 1
-- Main Bet
local betEditBoxMain1 = CreateFrame("EditBox", nil, playerFrame, "InputBoxTemplate")
betEditBoxMain1:SetSize(55, 30)
betEditBoxMain1:SetPoint("BOTTOM", playerFrame, 422, 335)
betEditBoxMain1:SetAutoFocus(false)
betEditBoxMain1:SetNumeric(true)
-- Perfect Pairs
local betEditBoxPP1 = CreateFrame("EditBox", nil, playerFrame, "InputBoxTemplate")
betEditBoxPP1:SetSize(35, 30)
betEditBoxPP1:SetPoint("BOTTOM", playerFrame, 312, 355)
betEditBoxPP1:SetAutoFocus(false)
betEditBoxPP1:SetNumeric(true)
-- 21+3
local betEditBox2131 = CreateFrame("EditBox", nil, playerFrame, "InputBoxTemplate")
betEditBox2131:SetSize(35, 30)
betEditBox2131:SetPoint("BOTTOM", playerFrame, 388, 490)
betEditBox2131:SetAutoFocus(false)
betEditBox2131:SetNumeric(true)



-- Labels for Player 1
-- Main Bet
playerFrame.mainBet1 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.mainBet1:SetPoint("BOTTOM", playerFrame, 421, 362)
playerFrame.mainBet1:SetJustifyH("CENTER")
playerFrame.mainBet1:SetText("Main Bet")
playerFrame.mainBet1:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- Main Bet Amount
mainBetAmount1 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
mainBetAmount1:SetPoint("CENTER", playerFrame, 338, 100)
mainBetAmount1:SetJustifyH("CENTER")
mainBetAmount1:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- Perfect Pairs
playerFrame.ppBet1 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.ppBet1:SetPoint("BOTTOM", playerFrame, 276, 353)
playerFrame.ppBet1:SetJustifyH("CENTER")
playerFrame.ppBet1:SetText("PP")
playerFrame.ppBet1:SetFont("Fonts\\FRIZQT__.TTF", 15, "OUTLINE")
-- Perfect Pairs Amount
ppBetAmount1 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
ppBetAmount1:SetPoint("CENTER", playerFrame, 275, 60)
ppBetAmount1:SetJustifyH("CENTER")
ppBetAmount1:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- 21+3
playerFrame.t213Bet1 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.t213Bet1:SetPoint("BOTTOM", playerFrame, 430, 488)
playerFrame.t213Bet1:SetJustifyH("CENTER")
playerFrame.t213Bet1:SetText("21+3")
playerFrame.t213Bet1:SetFont("Fonts\\FRIZQT__.TTF", 15, "OUTLINE")
-- 21+3 Amount
t213BetAmount1 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
t213BetAmount1:SetPoint("CENTER", playerFrame, 345, 156)
t213BetAmount1:SetJustifyH("CENTER")
t213BetAmount1:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- Insurance Amount
playerFrame.insuranceBetAmount1 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.insuranceBetAmount1:SetPoint("BOTTOM", playerFrame, 541, 372)
playerFrame.insuranceBetAmount1:SetJustifyH("CENTER")
playerFrame.insuranceBetAmount1:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
-- Player Name
playerFrame.player1Name = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.player1Name:SetPoint("BOTTOM", playerFrame, 452, 311)
playerFrame.player1Name:SetText(UnitName("player"))
playerFrame.player1Name:SetFont("Fonts\\FRIZQT__.TTF", 22, "OUTLINE")
-- Insurance
playerFrame.insuranceBet1 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.insuranceBet1:SetPoint("BOTTOM", playerFrame, 452, 229) 
playerFrame.insuranceBet1:SetText("Insurance")
playerFrame.insuranceBet1:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
-- Insurance (if available)
playerFrame.insuranceIfAvailable1 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.insuranceIfAvailable1:SetPoint("BOTTOM", playerFrame, 452, 219)
playerFrame.insuranceIfAvailable1:SetText("(if available)")
playerFrame.insuranceIfAvailable1:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")



-- Images for Player 1
-- Main Bet
playerFrame.coinsMainBet1 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coinsMainBet1:SetSize(128, 128)
playerFrame.coinsMainBet1:SetPoint("CENTER", playerFrame, 355, 70)
playerFrame.coinsMainBet1:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsBet.tga")
playerFrame.coinsMainBet1:SetBlendMode("BLEND")
playerFrame.coinsMainBet1:SetDrawLayer("OVERLAY")
playerFrame.coinsMainBet1:Hide()
-- Blackjack Win
playerFrame.coinsBJWin1 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coinsBJWin1:SetSize(128, 128)
playerFrame.coinsBJWin1:SetPoint("CENTER", playerFrame, 355, 70)
playerFrame.coinsBJWin1:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsBJWin.tga")
playerFrame.coinsBJWin1:SetBlendMode("BLEND")
playerFrame.coinsBJWin1:SetDrawLayer("OVERLAY")
playerFrame.coinsBJWin1:Hide()
-- Double Bet
playerFrame.coinsDoubleBet1 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coinsDoubleBet1:SetSize(128, 128)
playerFrame.coinsDoubleBet1:SetPoint("CENTER", playerFrame, 355, 70)
playerFrame.coinsDoubleBet1:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsWin.tga")
playerFrame.coinsDoubleBet1:SetBlendMode("BLEND")
playerFrame.coinsDoubleBet1:SetDrawLayer("OVERLAY")
playerFrame.coinsDoubleBet1:Hide()
-- PP Bet
playerFrame.coinsPPBet1 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coinsPPBet1:SetSize(128, 128)
playerFrame.coinsPPBet1:SetPoint("CENTER", playerFrame, 280, 40)
playerFrame.coinsPPBet1:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsHalfBet.tga")
playerFrame.coinsPPBet1:SetBlendMode("BLEND")
playerFrame.coinsPPBet1:SetDrawLayer("OVERLAY")
playerFrame.coinsPPBet1:Hide()
-- 21+3 Bet
playerFrame.coins213Bet1 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coins213Bet1:SetSize(128, 128)
playerFrame.coins213Bet1:SetPoint("CENTER", playerFrame, 350, 136)
playerFrame.coins213Bet1:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsHalfBet.tga")
playerFrame.coins213Bet1:SetBlendMode("BLEND")
playerFrame.coins213Bet1:SetDrawLayer("OVERLAY")
playerFrame.coins213Bet1:Hide()
-- PP Win
playerFrame.coinsPPWin1 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coinsPPWin1:SetSize(128, 128)
playerFrame.coinsPPWin1:SetPoint("CENTER", playerFrame, 292, 44)
playerFrame.coinsPPWin1:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsBet.tga")
playerFrame.coinsPPWin1:SetBlendMode("BLEND")
playerFrame.coinsPPWin1:SetDrawLayer("OVERLAY")
playerFrame.coinsPPWin1:Hide()
-- 21+3 Win
playerFrame.coins213Win1 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coins213Win1:SetSize(128, 128)
playerFrame.coins213Win1:SetPoint("CENTER", playerFrame, 361, 141)
playerFrame.coins213Win1:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsBet.tga")
playerFrame.coins213Win1:SetBlendMode("BLEND")
playerFrame.coins213Win1:SetDrawLayer("OVERLAY")
playerFrame.coins213Win1:Hide()



-- Function to handle Player 1 Double Bet Image
local function PlaceBJWin1(message)
    playerFrame.coinsMainBet1:Hide()
    playerFrame.coinsBJWin1:Show()
end

-- Function to handle Player 1 Double Bet Image
local function PlaceWin1(message)
    playerFrame.coinsMainBet1:Hide()
    playerFrame.coinsDoubleBet1:Show()
end

-- Function to handle Player 1 Double Bet Image
local function PlaceBetsMain1Double(message)
    playerFrame.coinsMainBet1:Hide()
    playerFrame.coinsDoubleBet1:Show()
end

-- Function to handle Player 1 Main Bet Image
local function PlaceBetsMain1(message)
    playerFrame.coinsMainBet1:Show()
end

-- Function to handle Player 1 Main Bet Text
local function PlaceBetsTextMain1(Amount)
    mainBetAmount1:SetText(Amount .. " G")
    mainBetAmount1:Show()
end

-- Function to handle Player 1 PP Bet Image
local function PlaceBetsPP1(message)
    playerFrame.coinsPPBet1:Show()
end

-- Function to handle Player 1 PP Bet Text
local function PlaceBetsTextPP1(Amount)
    ppBetAmount1:SetText(Amount .. " G")
    ppBetAmount1:Show()
end

-- Function to handle Player 1 21+3 Bet Image
local function PlaceBets2131(message)
    playerFrame.coins213Bet1:Show()
end

-- Function to handle Player 1 21+3 Bet Text
local function PlaceBetsText2131(Amount)
    t213BetAmount1:SetText(Amount .. " G")
    t213BetAmount1:Show()
end



-- Function to handle the Player 1 Main "Bet" button click
local function ConfirmBetClickMain1()
    betAmountMain1 = tonumber(betEditBoxMain1:GetText()) -- Get the entered bet amount
    if betAmountMain1 and betAmountMain1 >= minBetMain and betAmountMain1 <= maxBetMain then
        -- Valid bet amount, send the message with the bet
        SendChatMessage("[P1] Placing a " ..betAmountMain1.. "G main bet.", "RAID")
        -- Disable the edit box and button
        betEditBoxMain1:SetFocus(false)
        betEditBoxMain1:ClearFocus()
        betEditBoxMain1:Disable()
        confirmBetButtonMain1:Disable()
        PlaySoundFile(soundFilePaths[43])
        
    else
        print("Invalid bet amount. Please enter a value between " .. minBetMain .. "G and " .. maxBetMain .. "G.")
    end
    local chatFrame = SELECTED_DOCK_FRAME
    ChatFrame_OpenChat("/trade", chatFrame)
    local editBox = _G[chatFrame:GetName().."EditBox"]
    editBox:Insert("/trade")
    ChatEdit_SendText(editBox)
end



-- Function to handle the Player 1 PP "Bet" button click
local function ConfirmBetClickPP1()
    betAmountPP1 = tonumber(betEditBoxPP1:GetText()) -- Get the entered bet amount
    if betAmountPP1 and betAmountPP1 >= minBetPP and betAmountPP1 <= maxBetPP then
        -- Valid bet amount, send the message with the bet
        SendChatMessage("[P1] Placing a " ..betAmountPP1.. "G side bet on Perfect Pairs.", "RAID")
        -- Disable the edit box and button
        betEditBoxPP1:SetFocus(false)
        betEditBoxPP1:ClearFocus()
        betEditBoxPP1:Disable()
        confirmBetButtonPP1:Disable()
        PlaySoundFile(soundFilePaths[43])
    else
        print("Invalid bet amount. Please enter a value between " .. minBetPP .. "G and " .. maxBetPP .. "G.")
    end
    local chatFrame = SELECTED_DOCK_FRAME
    ChatFrame_OpenChat("/trade", chatFrame)
    local editBox = _G[chatFrame:GetName().."EditBox"]
    editBox:Insert("/trade")
    ChatEdit_SendText(editBox)
end



-- Function to handle the Player 1 21+3 "Bet" button click
local function ConfirmBetClick2131()
    betAmount2131 = tonumber(betEditBox2131:GetText()) -- Get the entered bet amount
    if betAmount2131 and betAmount2131 >= minBet213 and betAmount2131 <= maxBet213 then
        -- Valid bet amount, send the message with the bet
        SendChatMessage("[P1] Placing a " ..betAmount2131.. "G side bet on 21+3.", "RAID")
        -- Disable the edit box and button
        betEditBox2131:SetFocus(false)
        betEditBox2131:ClearFocus()
        betEditBox2131:Disable()
        confirmBetButton2131:Disable()
        PlaySoundFile(soundFilePaths[43])
    else
        print("Invalid bet amount. Please enter a value between " .. minBet213 .. "G and " .. maxBet213 .. "G.")
    end
    local chatFrame = SELECTED_DOCK_FRAME
    ChatFrame_OpenChat("/trade", chatFrame)
    local editBox = _G[chatFrame:GetName().."EditBox"]
    editBox:Insert("/trade")
    ChatEdit_SendText(editBox)
end



-- Player 1 Main "Bet" button
confirmBetButtonMain1:SetScript("OnClick", ConfirmBetClickMain1)

-- Player 1 PP "Bet" button
confirmBetButtonPP1:SetScript("OnClick", ConfirmBetClickPP1)

-- Player 1 21+3 "Bet" button
confirmBetButton2131:SetScript("OnClick", ConfirmBetClick2131)










-- Insurance YES for Player 2
insuranceYesIcon2 = playerFrame:CreateTexture(nil, "OVERLAY")
insuranceYesIcon2:SetSize(32, 32)
insuranceYesIcon2:SetPoint("CENTER", playerFrame, 342, -158)
insuranceYesIcon2:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\insuranceYes.tga")
insuranceYesIcon2:SetDrawLayer("ARTWORK")
insuranceYesIcon2:Hide()


-- Insurance NO for Player 2
insuranceNoIcon2 = playerFrame:CreateTexture(nil, "OVERLAY")
insuranceNoIcon2:SetSize(32, 32)
insuranceNoIcon2:SetPoint("CENTER", playerFrame, 342, -158)
insuranceNoIcon2:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\insuranceNo.tga")
insuranceNoIcon2:SetDrawLayer("ARTWORK")
insuranceNoIcon2:Hide()




-- Buttons for Player 2
-- Hit
playerFrame.hitButton2 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.hitButton2:SetPoint("BOTTOM", playerFrame, 222, 127)
playerFrame.hitButton2:SetSize(65, 30)
playerFrame.hitButton2:SetText("Hit")
playerFrame.hitButton2:Disable()
-- Stand
playerFrame.standButton2 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.standButton2:SetPoint("BOTTOM", playerFrame, 288, 127)
playerFrame.standButton2:SetSize(65, 30)
playerFrame.standButton2:SetText("Stand")
playerFrame.standButton2:Disable()
-- Double
playerFrame.doubleButton2 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.doubleButton2:SetPoint("BOTTOM", playerFrame, 222, 97)
playerFrame.doubleButton2:SetSize(65, 30)
playerFrame.doubleButton2:SetText("Double")
playerFrame.doubleButton2:Disable()
-- Split
playerFrame.splitButton2 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.splitButton2:SetPoint("BOTTOM", playerFrame, 288, 97)
playerFrame.splitButton2:SetSize(65, 30)
playerFrame.splitButton2:SetText("Split")
playerFrame.splitButton2:Disable()
-- Insurance Yes
playerFrame.insuranceYesButton2 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.insuranceYesButton2:SetPoint("BOTTOM", playerFrame, 190, 67)
playerFrame.insuranceYesButton2:SetSize(55, 30)
playerFrame.insuranceYesButton2:SetText("Yes")
playerFrame.insuranceYesButton2:Disable()
-- Insurance No
playerFrame.insuranceNoButton2 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.insuranceNoButton2:SetPoint("BOTTOM", playerFrame, 318, 67)
playerFrame.insuranceNoButton2:SetSize(55, 30)
playerFrame.insuranceNoButton2:SetText("No")
playerFrame.insuranceNoButton2:Disable()
-- Main Bet Confirm
local confirmBetButtonMain2 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
confirmBetButtonMain2:SetPoint("BOTTOM", playerFrame, 288, 187)
confirmBetButtonMain2:SetSize(65, 30)
confirmBetButtonMain2:SetText("Bet")
-- Perfect Pairs Confirm
local confirmBetButtonPP2 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
confirmBetButtonPP2:SetPoint("BOTTOM", playerFrame, 129, 244)
confirmBetButtonPP2:SetSize(43, 25)
confirmBetButtonPP2:SetText("Bet")
-- 21+3 Confirm
local confirmBetButton2132 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
confirmBetButton2132:SetPoint("BOTTOM", playerFrame, 245, 295)
confirmBetButton2132:SetSize(43, 25)
confirmBetButton2132:SetText("Bet")



-- Wagers for Player 2
-- Main Bet
local betEditBoxMain2 = CreateFrame("EditBox", nil, playerFrame, "InputBoxTemplate")
betEditBoxMain2:SetSize(55, 30)
betEditBoxMain2:SetPoint("BOTTOM", playerFrame, 225, 187)
betEditBoxMain2:SetAutoFocus(false)
betEditBoxMain2:SetNumeric(true)
-- Perfect Pairs
local betEditBoxPP2 = CreateFrame("EditBox", nil, playerFrame, "InputBoxTemplate")
betEditBoxPP2:SetSize(35, 30)
betEditBoxPP2:SetPoint("BOTTOM", playerFrame, 132, 264)
betEditBoxPP2:SetAutoFocus(false)
betEditBoxPP2:SetNumeric(true)
-- 21+3
local betEditBox2132 = CreateFrame("EditBox", nil, playerFrame, "InputBoxTemplate")
betEditBox2132:SetSize(35, 30)
betEditBox2132:SetPoint("BOTTOM", playerFrame, 247, 315)
betEditBox2132:SetAutoFocus(false)
betEditBox2132:SetNumeric(true)



-- Labels for Player 2
-- Main Bet
playerFrame.mainBet2 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.mainBet2:SetPoint("BOTTOM", playerFrame, 224, 214)
playerFrame.mainBet2:SetJustifyH("CENTER")
playerFrame.mainBet2:SetText("Main Bet")
playerFrame.mainBet2:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- Main Bet Amount
mainBetAmount2 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
mainBetAmount2:SetPoint("CENTER", playerFrame, 189, -16)
mainBetAmount2:SetJustifyH("CENTER")
mainBetAmount2:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- Perfect Pairs
playerFrame.ppBet2 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.ppBet2:SetPoint("BOTTOM", playerFrame, 96, 262)
playerFrame.ppBet2:SetJustifyH("CENTER")
playerFrame.ppBet2:SetText("PP")
playerFrame.ppBet2:SetFont("Fonts\\FRIZQT__.TTF", 15, "OUTLINE")
-- Perfect Pairs Amount
ppBetAmount2 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
ppBetAmount2:SetPoint("CENTER", playerFrame, 123, -23)
ppBetAmount2:SetJustifyH("CENTER")
ppBetAmount2:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- 21+3
playerFrame.t213Bet2 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.t213Bet2:SetPoint("BOTTOM", playerFrame, 290, 312)
playerFrame.t213Bet2:SetJustifyH("CENTER")
playerFrame.t213Bet2:SetText("21+3")
playerFrame.t213Bet2:SetFont("Fonts\\FRIZQT__.TTF", 15, "OUTLINE")
-- 21+3 Amount
t213BetAmount2 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
t213BetAmount2:SetPoint("CENTER", playerFrame, 231, 29)
t213BetAmount2:SetJustifyH("CENTER")
t213BetAmount2:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- Insurance Amount
playerFrame.insuranceBetAmount2 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.insuranceBetAmount2:SetPoint("CENTER", playerFrame, 346, -131)
playerFrame.insuranceBetAmount2:SetJustifyH("CENTER")
playerFrame.insuranceBetAmount2:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
-- Player Name
playerFrame.player2Name = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.player2Name:SetPoint("BOTTOM", playerFrame, 255, 163)
playerFrame.player2Name:SetText(UnitName("player"))
playerFrame.player2Name:SetFont("Fonts\\FRIZQT__.TTF", 22, "OUTLINE")
-- Insurance Bet
playerFrame.insuranceBet2 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.insuranceBet2:SetPoint("BOTTOM", playerFrame, 255, 81)
playerFrame.insuranceBet2:SetText("Insurance")
playerFrame.insuranceBet2:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
-- Insurance (if available)
playerFrame.insuranceIfAvailable2 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.insuranceIfAvailable2:SetPoint("BOTTOM", playerFrame, 255, 71)
playerFrame.insuranceIfAvailable2:SetText("(if available)")
playerFrame.insuranceIfAvailable2:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")




-- Images for Player 2
-- Main Bet
playerFrame.coinsMainBet2 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coinsMainBet2:SetSize(128, 128)
playerFrame.coinsMainBet2:SetPoint("CENTER", playerFrame, 206, -47)
playerFrame.coinsMainBet2:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsBet.tga")
playerFrame.coinsMainBet2:SetBlendMode("BLEND")
playerFrame.coinsMainBet2:SetDrawLayer("OVERLAY")
playerFrame.coinsMainBet2:Hide()
-- Blackjack Win
playerFrame.coinsBJWin2 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coinsBJWin2:SetSize(128, 128)
playerFrame.coinsBJWin2:SetPoint("CENTER", playerFrame, 206, -47)
playerFrame.coinsBJWin2:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsBJWin.tga")
playerFrame.coinsBJWin2:SetBlendMode("BLEND")
playerFrame.coinsBJWin2:SetDrawLayer("OVERLAY")
playerFrame.coinsBJWin2:Hide()
-- Double Bet
playerFrame.coinsDoubleBet2 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coinsDoubleBet2:SetSize(128, 128)
playerFrame.coinsDoubleBet2:SetPoint("CENTER", playerFrame, 206, -47)
playerFrame.coinsDoubleBet2:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsWin.tga")
playerFrame.coinsDoubleBet2:SetBlendMode("BLEND")
playerFrame.coinsDoubleBet2:SetDrawLayer("OVERLAY")
playerFrame.coinsDoubleBet2:Hide()
-- PP Bet
playerFrame.coinsPPBet2 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coinsPPBet2:SetSize(128, 128)
playerFrame.coinsPPBet2:SetPoint("CENTER", playerFrame, 127, -42)
playerFrame.coinsPPBet2:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsHalfBet.tga")
playerFrame.coinsPPBet2:SetBlendMode("BLEND")
playerFrame.coinsPPBet2:SetDrawLayer("OVERLAY")
playerFrame.coinsPPBet2:Hide()
-- 21+3 Bet
playerFrame.coins213Bet2 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coins213Bet2:SetSize(128, 128)
playerFrame.coins213Bet2:SetPoint("CENTER", playerFrame, 235, 8)
playerFrame.coins213Bet2:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsHalfBet.tga")
playerFrame.coins213Bet2:SetBlendMode("BLEND")
playerFrame.coins213Bet2:SetDrawLayer("OVERLAY")
playerFrame.coins213Bet2:Hide()
-- PP Win
playerFrame.coinsPPWin2 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coinsPPWin2:SetSize(128, 128)
playerFrame.coinsPPWin2:SetPoint("CENTER", playerFrame, 138, -36)
playerFrame.coinsPPWin2:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsBet.tga")
playerFrame.coinsPPWin2:SetBlendMode("BLEND")
playerFrame.coinsPPWin2:SetDrawLayer("OVERLAY")
playerFrame.coinsPPWin2:Hide()
-- 21+3 Win
playerFrame.coins213Win2 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coins213Win2:SetSize(128, 128)
playerFrame.coins213Win2:SetPoint("CENTER", playerFrame, 246, 16)
playerFrame.coins213Win2:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsBet.tga")
playerFrame.coins213Win2:SetBlendMode("BLEND")
playerFrame.coins213Win2:SetDrawLayer("OVERLAY")
playerFrame.coins213Win2:Hide()


-- Function to handle Player 2 Double Bet Image
local function PlaceBJWin2(message)
    playerFrame.coinsMainBet2:Hide()
    playerFrame.coinsBJWin2:Show()
end

-- Function to handle Player 2 Double Bet Image
local function PlaceWin2(message)
    playerFrame.coinsMainBet2:Hide()
    playerFrame.coinsDoubleBet2:Show()
end

-- Function to handle Player 2 Double Bet Image
local function PlaceBetsMain2Double(message)
    playerFrame.coinsMainBet2:Hide()
    playerFrame.coinsDoubleBet2:Show()
end

-- Function to handle Player 2 Main Bet Image
local function PlaceBetsMain2(message)
    playerFrame.coinsMainBet2:Show()
end

-- Function to handle Player 2 Main Bet Text
local function PlaceBetsTextMain2(Amount)
    mainBetAmount2:SetText(Amount .. " G")
    mainBetAmount2:Show()
end

-- Function to handle Player 2 PP Bet Image
local function PlaceBetsPP2(message)
    playerFrame.coinsPPBet2:Show()
end

-- Function to handle Player 2 PP Bet Text
local function PlaceBetsTextPP2(Amount)
    ppBetAmount2:SetText(Amount .. " G")
    ppBetAmount2:Show()
end

-- Function to handle Player 2 21+3 Bet Image
local function PlaceBets2132(message)
    playerFrame.coins213Bet2:Show()
end

-- Function to handle Player 2 21+3 Bet Text
local function PlaceBetsText2132(Amount)
    t213BetAmount2:SetText(Amount .. " G")
    t213BetAmount2:Show()
end



-- Function to handle the Player 2 Main "Bet" button click
local function ConfirmBetClickMain2()
    betAmountMain2 = tonumber(betEditBoxMain2:GetText()) -- Get the entered bet amount
    if betAmountMain2 and betAmountMain2 >= minBetMain and betAmountMain2 <= maxBetMain then
        -- Valid bet amount, send the message with the bet
        SendChatMessage("[P2] Placing a " ..betAmountMain2.. "G main bet.", "RAID")
        -- Disable the edit box and button
        betEditBoxMain2:SetFocus(false)
        betEditBoxMain2:ClearFocus()
        betEditBoxMain2:Disable()
        confirmBetButtonMain2:Disable()
        PlaySoundFile(soundFilePaths[43])
    else
        print("Invalid bet amount. Please enter a value between " .. minBetMain .. "G and " .. maxBetMain .. "G.")
    end
end



-- Function to handle the Player 2 PP "Bet" button click
local function ConfirmBetClickPP2()
    betAmountPP2 = tonumber(betEditBoxPP2:GetText()) -- Get the entered bet amount
    if betAmountPP2 and betAmountPP2 >= minBetPP and betAmountPP2 <= maxBetPP then
        -- Valid bet amount, send the message with the bet
        SendChatMessage("[P2] Placing a " ..betAmountPP2.. "G side bet on Perfect Pairs.", "RAID")
        -- Disable the edit box and button
        betEditBoxPP2:SetFocus(false)
        betEditBoxPP2:ClearFocus()
        betEditBoxPP2:Disable()
        confirmBetButtonPP2:Disable()
        PlaySoundFile(soundFilePaths[43])
    else
        print("Invalid bet amount. Please enter a value between " .. minBetPP .. "G and " .. maxBetPP .. "G.")
    end
end



-- Function to handle the Player 2 21+3 "Bet" button click
local function ConfirmBetClick2132()
    betAmount2132 = tonumber(betEditBox2132:GetText()) -- Get the entered bet amount
    if betAmount2132 and betAmount2132 >= minBet213 and betAmount2132 <= maxBet213 then
        -- Valid bet amount, send the message with the bet
        SendChatMessage("[P2] Placing a " ..betAmount2132.. "G side bet on 21+3.", "RAID")
        -- Disable the edit box and button
        betEditBox2132:SetFocus(false)
        betEditBox2132:ClearFocus()
        betEditBox2132:Disable()
        confirmBetButton2132:Disable()
        PlaySoundFile(soundFilePaths[43])
    else
        print("Invalid bet amount. Please enter a value between " .. minBet213 .. "G and " .. maxBet213 .. "G.")
    end
end



-- Player 2 Main "Bet" button
confirmBetButtonMain2:SetScript("OnClick", ConfirmBetClickMain2)

-- Player 2 PP "Bet" button
confirmBetButtonPP2:SetScript("OnClick", ConfirmBetClickPP2)

-- Player 2 21+3 "Bet" button
confirmBetButton2132:SetScript("OnClick", ConfirmBetClick2132)







-- Insurance YES for Player 3
insuranceYesIcon3 = playerFrame:CreateTexture(nil, "OVERLAY")
insuranceYesIcon3:SetSize(32, 32)
insuranceYesIcon3:SetPoint("CENTER", playerFrame, 87, -205)
insuranceYesIcon3:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\insuranceYes.tga")
insuranceYesIcon3:SetDrawLayer("ARTWORK")
insuranceYesIcon3:Hide()

-- Insurance NO for Player 3
insuranceNoIcon3 = playerFrame:CreateTexture(nil, "OVERLAY")
insuranceNoIcon3:SetSize(32, 32)
insuranceNoIcon3:SetPoint("CENTER", playerFrame, 87, -205)
insuranceNoIcon3:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\insuranceNo.tga")
insuranceNoIcon3:SetDrawLayer("ARTWORK")
insuranceNoIcon3:Hide()



-- Buttons for Player 3
-- Hit
playerFrame.hitButton3 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.hitButton3:SetPoint("BOTTOM", playerFrame, -33, 80)
playerFrame.hitButton3:SetSize(65, 30)
playerFrame.hitButton3:SetText("Hit")
playerFrame.hitButton3:Disable()
-- Stand
playerFrame.standButton3 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.standButton3:SetPoint("BOTTOM", playerFrame, 33, 80)
playerFrame.standButton3:SetSize(65, 30)
playerFrame.standButton3:SetText("Stand")
playerFrame.standButton3:Disable()
-- Double
playerFrame.doubleButton3 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.doubleButton3:SetPoint("BOTTOM", playerFrame, -33, 50)
playerFrame.doubleButton3:SetSize(65, 30)
playerFrame.doubleButton3:SetText("Double")
playerFrame.doubleButton3:Disable()
-- Split
playerFrame.splitButton3 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.splitButton3:SetPoint("BOTTOM", playerFrame, 33, 50)
playerFrame.splitButton3:SetSize(65, 30)
playerFrame.splitButton3:SetText("Split")
playerFrame.splitButton3:Disable()
-- Insurance Yes
playerFrame.insuranceYesButton3 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.insuranceYesButton3:SetPoint("BOTTOM", playerFrame, -65, 20)
playerFrame.insuranceYesButton3:SetSize(55, 30)
playerFrame.insuranceYesButton3:SetText("Yes")
playerFrame.insuranceYesButton3:Disable()
-- Insurance No
playerFrame.insuranceNoButton3 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.insuranceNoButton3:SetPoint("BOTTOM", playerFrame, 63, 20)
playerFrame.insuranceNoButton3:SetSize(55, 30)
playerFrame.insuranceNoButton3:SetText("No")
playerFrame.insuranceNoButton3:Disable()
-- Main Bet Confirm
local confirmBetButtonMain3 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
confirmBetButtonMain3:SetPoint("BOTTOM", playerFrame, 33, 140)
confirmBetButtonMain3:SetSize(65, 30)
confirmBetButtonMain3:SetText("Bet")
-- Perfect Pairs Confirm
local confirmBetButtonPP3 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
confirmBetButtonPP3:SetPoint("BOTTOM", playerFrame, -56, 232)
confirmBetButtonPP3:SetSize(43, 25)
confirmBetButtonPP3:SetText("Bet")
-- 21+3 Confirm
local confirmBetButton2133 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
confirmBetButton2133:SetPoint("BOTTOM", playerFrame, 64, 232)
confirmBetButton2133:SetSize(43, 25)
confirmBetButton2133:SetText("Bet")



-- Wagers for Player 3
-- Main Bet
local betEditBoxMain3 = CreateFrame("EditBox", nil, playerFrame, "InputBoxTemplate")
betEditBoxMain3:SetSize(55, 30)
betEditBoxMain3:SetPoint("BOTTOM", playerFrame, -30, 140)
betEditBoxMain3:SetAutoFocus(false)
betEditBoxMain3:SetNumeric(true)
-- Perfect Pairs
local betEditBoxPP3 = CreateFrame("EditBox", nil, playerFrame, "InputBoxTemplate")
betEditBoxPP3:SetSize(35, 30)
betEditBoxPP3:SetPoint("BOTTOM", playerFrame, -54, 252)
betEditBoxPP3:SetAutoFocus(false)
betEditBoxPP3:SetNumeric(true)
-- 21+3
local betEditBox2133 = CreateFrame("EditBox", nil, playerFrame, "InputBoxTemplate")
betEditBox2133:SetSize(35, 30)
betEditBox2133:SetPoint("BOTTOM", playerFrame, 66, 252)
betEditBox2133:SetAutoFocus(false)
betEditBox2133:SetNumeric(true)



-- Labels for Player 3
-- Main Bet
playerFrame.mainBet3 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.mainBet3:SetPoint("BOTTOM", playerFrame, -31, 167)
playerFrame.mainBet3:SetJustifyH("CENTER")
playerFrame.mainBet3:SetText("Main Bet")
playerFrame.mainBet3:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- Main Bet Amount
mainBetAmount3 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
mainBetAmount3:SetPoint("CENTER", playerFrame, 6, -59)
mainBetAmount3:SetJustifyH("CENTER")
mainBetAmount3:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- Perfect Pairs
playerFrame.ppBet3 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.ppBet3:SetPoint("BOTTOM", playerFrame, -90, 250)
playerFrame.ppBet3:SetJustifyH("CENTER")
playerFrame.ppBet3:SetText("PP")
playerFrame.ppBet3:SetFont("Fonts\\FRIZQT__.TTF", 15, "OUTLINE")
-- Perfect Pairs Amount
ppBetAmount3 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
ppBetAmount3:SetPoint("CENTER", playerFrame, -51, -35)
ppBetAmount3:SetJustifyH("CENTER")
ppBetAmount3:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- 21+3
playerFrame.t213Bet3 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.t213Bet3:SetPoint("BOTTOM", playerFrame, 109, 250)
playerFrame.t213Bet3:SetJustifyH("CENTER")
playerFrame.t213Bet3:SetText("21+3")
playerFrame.t213Bet3:SetFont("Fonts\\FRIZQT__.TTF", 15, "OUTLINE")
-- 21+3 Amount
t213BetAmount3 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
t213BetAmount3:SetPoint("CENTER", playerFrame, 67, -36)
t213BetAmount3:SetJustifyH("CENTER")
t213BetAmount3:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- Player Name
playerFrame.player3Name = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.player3Name:SetPoint("BOTTOM", playerFrame, 0, 116)
playerFrame.player3Name:SetText(UnitName("player"))
playerFrame.player3Name:SetFont("Fonts\\FRIZQT__.TTF", 22, "OUTLINE")
-- Insurance
playerFrame.insuranceBet3 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.insuranceBet3:SetPoint("BOTTOM", playerFrame, 0, 34)
playerFrame.insuranceBet3:SetText("Insurance")
playerFrame.insuranceBet3:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
-- Insurance (if available)
playerFrame.insuranceIfAvailable3 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.insuranceIfAvailable3:SetPoint("BOTTOM", playerFrame, 0, 24)
playerFrame.insuranceIfAvailable3:SetText("(if available)")
playerFrame.insuranceIfAvailable3:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")



-- Images for Player 3
-- Main Bet
playerFrame.coinsMainBet3 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coinsMainBet3:SetSize(128, 128)
playerFrame.coinsMainBet3:SetPoint("CENTER", playerFrame, 23, -90)
playerFrame.coinsMainBet3:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsBet.tga")
playerFrame.coinsMainBet3:SetBlendMode("BLEND")
playerFrame.coinsMainBet3:SetDrawLayer("OVERLAY")
playerFrame.coinsMainBet3:Hide()
-- PP Bet
playerFrame.coinsPPBet3 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coinsPPBet3:SetSize(128, 128)
playerFrame.coinsPPBet3:SetPoint("CENTER", playerFrame, -47, -55)
playerFrame.coinsPPBet3:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsHalfBet.tga")
playerFrame.coinsPPBet3:SetBlendMode("BLEND")
playerFrame.coinsPPBet3:SetDrawLayer("OVERLAY")
playerFrame.coinsPPBet3:Hide()
-- 21+3 Bet
playerFrame.coins213Bet3 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coins213Bet3:SetSize(128, 128)
playerFrame.coins213Bet3:SetPoint("CENTER", playerFrame, 72, -56)
playerFrame.coins213Bet3:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsHalfBet.tga")
playerFrame.coins213Bet3:SetBlendMode("BLEND")
playerFrame.coins213Bet3:SetDrawLayer("OVERLAY")
playerFrame.coins213Bet3:Hide()



-- Function to handle Player 3 Main Bet Image
local function PlaceBetsMain3(message)
    playerFrame.coinsMainBet3:Show()
end

-- Function to handle Player 3 Main Bet Text
local function PlaceBetsTextMain3(Amount)
    mainBetAmount3:SetText(Amount .. " G")
    mainBetAmount3:Show()
end

-- Function to handle Player 3 PP Bet Image
local function PlaceBetsPP3(message)
    playerFrame.coinsPPBet3:Show()
end

-- Function to handle Player 3 PP Bet Text
local function PlaceBetsTextPP3(Amount)
    ppBetAmount3:SetText(Amount .. " G")
    ppBetAmount3:Show()
end

-- Function to handle Player 3 21+3 Bet Image
local function PlaceBets2133(message)
    playerFrame.coins213Bet3:Show()
end

-- Function to handle Player 3 21+3 Bet Text
local function PlaceBetsText2133(Amount)
    t213BetAmount3:SetText(Amount .. " G")
    t213BetAmount3:Show()
end



-- Function to handle the Player 3 Main "Bet" button click
local function ConfirmBetClickMain3()
    betAmountMain3 = tonumber(betEditBoxMain3:GetText()) -- Get the entered bet amount
    if betAmountMain3 and betAmountMain3 >= minBetMain and betAmountMain3 <= maxBetMain then
        -- Valid bet amount, send the message with the bet
        SendChatMessage("[P3] Placing a " ..betAmountMain3.. "G main bet.", "RAID")
        -- Disable the edit box and button
        betEditBoxMain3:SetFocus(false)
        betEditBoxMain3:ClearFocus()
        betEditBoxMain3:Disable()
        confirmBetButtonMain3:Disable()
        PlaySoundFile(soundFilePaths[43])
    else
        print("Invalid bet amount. Please enter a value between " .. minBetMain .. "G and " .. maxBetMain .. "G.")
    end
end



-- Function to handle the Player 3 PP "Bet" button click
local function ConfirmBetClickPP3()
    betAmountPP3 = tonumber(betEditBoxPP3:GetText()) -- Get the entered bet amount
    if betAmountPP3 and betAmountPP3 >= minBetPP and betAmountPP3 <= maxBetPP then
        -- Valid bet amount, send the message with the bet
        SendChatMessage("[P3] Placing a " ..betAmountPP3.. "G side bet on Perfect Pairs.", "RAID")
        -- Disable the edit box and button
        betEditBoxPP3:SetFocus(false)
        betEditBoxPP3:ClearFocus()
        betEditBoxPP3:Disable()
        confirmBetButtonPP3:Disable()
        PlaySoundFile(soundFilePaths[43])
    else
        print("Invalid bet amount. Please enter a value between " .. minBetPP .. "G and " .. maxBetPP .. "G.")
    end
end



-- Function to handle the Player 3 21+3 "Bet" button click
local function ConfirmBetClick2133()
    betAmount2133 = tonumber(betEditBox2133:GetText()) -- Get the entered bet amount
    if betAmount2133 and betAmount2133 >= minBet213 and betAmount2133 <= maxBet213 then
        -- Valid bet amount, send the message with the bet
        SendChatMessage("[P3] Placing a " ..betAmount2133.. "G side bet on 21+3.", "RAID")
        -- Disable the edit box and button
        betEditBox2133:SetFocus(false)
        betEditBox2133:ClearFocus()
        betEditBox2133:Disable()
        confirmBetButton2133:Disable()
        PlaySoundFile(soundFilePaths[43])
    else
        print("Invalid bet amount. Please enter a value between " .. minBet213 .. "G and " .. maxBet213 .. "G.")
    end
end



-- Player 3 Main "Bet" button
confirmBetButtonMain3:SetScript("OnClick", ConfirmBetClickMain3)

-- Player 3 PP "Bet" button
confirmBetButtonPP3:SetScript("OnClick", ConfirmBetClickPP3)

-- Player 3 21+3 "Bet" button
confirmBetButton2133:SetScript("OnClick", ConfirmBetClick2133)









-- Insurance YES for Player 4
insuranceYesIcon4 = playerFrame:CreateTexture(nil, "OVERLAY")
insuranceYesIcon4:SetSize(32, 32)
insuranceYesIcon4:SetPoint("CENTER", playerFrame, -340, -158)
insuranceYesIcon4:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\insuranceYes.tga")
insuranceYesIcon4:SetDrawLayer("ARTWORK")
insuranceYesIcon4:Hide()

-- Insurance NO for Player 4
insuranceYesIcon4 = playerFrame:CreateTexture(nil, "OVERLAY")
insuranceYesIcon4:SetSize(32, 32)
insuranceYesIcon4:SetPoint("CENTER", playerFrame, -340, -152)
insuranceYesIcon4:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\insuranceNo.tga")
insuranceYesIcon4:SetDrawLayer("ARTWORK")
insuranceYesIcon4:Hide()




-- Buttons for Player 4
-- Hit
playerFrame.hitButton4 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.hitButton4:SetPoint("BOTTOM", playerFrame, -288, 135)
playerFrame.hitButton4:SetSize(65, 30)
playerFrame.hitButton4:SetText("Hit")
playerFrame.hitButton4:Disable()
-- Stand
playerFrame.standButton4 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.standButton4:SetPoint("BOTTOM", playerFrame, -222, 135)
playerFrame.standButton4:SetSize(65, 30)
playerFrame.standButton4:SetText("Stand")
playerFrame.standButton4:Disable()
-- Double
playerFrame.doubleButton4 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.doubleButton4:SetPoint("BOTTOM", playerFrame, -288, 105)
playerFrame.doubleButton4:SetSize(65, 30)
playerFrame.doubleButton4:SetText("Double")
playerFrame.doubleButton4:Disable()
-- Split
playerFrame.splitButton4 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.splitButton4:SetPoint("BOTTOM", playerFrame, -222, 105)
playerFrame.splitButton4:SetSize(65, 30)
playerFrame.splitButton4:SetText("Split")
playerFrame.splitButton4:Disable()
-- Insurance Yes
playerFrame.insuranceYesButton4 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.insuranceYesButton4:SetPoint("BOTTOM", playerFrame, -320, 75)
playerFrame.insuranceYesButton4:SetSize(55, 30)
playerFrame.insuranceYesButton4:SetText("Yes")
playerFrame.insuranceYesButton4:Disable()
-- Insurance No
playerFrame.insuranceNoButton4 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.insuranceNoButton4:SetPoint("BOTTOM", playerFrame, -195, 75)
playerFrame.insuranceNoButton4:SetSize(55, 30)
playerFrame.insuranceNoButton4:SetText("No")
playerFrame.insuranceNoButton4:Disable()
-- Main Bet Confirm
local confirmBetButtonMain4 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
confirmBetButtonMain4:SetPoint("BOTTOM", playerFrame, -222, 195)
confirmBetButtonMain4:SetSize(65, 30)
confirmBetButtonMain4:SetText("Bet")
-- Perfect Pairs Confirm
local confirmBetButtonPP4 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
confirmBetButtonPP4:SetPoint("BOTTOM", playerFrame, -237, 295)
confirmBetButtonPP4:SetSize(43, 25)
confirmBetButtonPP4:SetText("Bet")
-- 21+3 Confirm
local confirmBetButton2134 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
confirmBetButton2134:SetPoint("BOTTOM", playerFrame, -121, 244)
confirmBetButton2134:SetSize(43, 25)
confirmBetButton2134:SetText("Bet")



-- Wagers for Player 4
-- Main Bet
local betEditBoxMain4 = CreateFrame("EditBox", nil, playerFrame, "InputBoxTemplate")
betEditBoxMain4:SetSize(55, 30)
betEditBoxMain4:SetPoint("BOTTOM", playerFrame, -284, 195)
betEditBoxMain4:SetAutoFocus(false)
betEditBoxMain4:SetNumeric(true)
-- Perfect Pairs
local betEditBoxPP4 = CreateFrame("EditBox", nil, playerFrame, "InputBoxTemplate")
betEditBoxPP4:SetSize(35, 30)
betEditBoxPP4:SetPoint("BOTTOM", playerFrame, -235, 315)
betEditBoxPP4:SetAutoFocus(false)
betEditBoxPP4:SetNumeric(true)
-- 21+3
local betEditBox2134 = CreateFrame("EditBox", nil, playerFrame, "InputBoxTemplate")
betEditBox2134:SetSize(35, 30)
betEditBox2134:SetPoint("BOTTOM", playerFrame, -119, 264)
betEditBox2134:SetAutoFocus(false)
betEditBox2134:SetNumeric(true)



-- Labels for Player 4
-- Main Bet
playerFrame.mainBet4 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.mainBet4:SetPoint("BOTTOM", playerFrame, -284, 222)
playerFrame.mainBet4:SetJustifyH("CENTER")
playerFrame.mainBet4:SetText("Main Bet")
playerFrame.mainBet4:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- Main Bet Amount
mainBetAmount4 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
mainBetAmount4:SetPoint("CENTER", playerFrame, -179, -18)
mainBetAmount4:SetJustifyH("CENTER")
mainBetAmount4:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- Perfect Pairs
playerFrame.ppBet4 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.ppBet4:SetPoint("BOTTOM", playerFrame, -270, 312)
playerFrame.ppBet4:SetJustifyH("CENTER")
playerFrame.ppBet4:SetText("PP")
playerFrame.ppBet4:SetFont("Fonts\\FRIZQT__.TTF", 15, "OUTLINE")
-- Perfect Pairs Amount
ppBetAmount4 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
ppBetAmount4:SetPoint("CENTER", playerFrame, -219, 26)
ppBetAmount4:SetJustifyH("CENTER")
ppBetAmount4:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- 21+3
playerFrame.t213Bet4 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.t213Bet4:SetPoint("BOTTOM", playerFrame, -75, 259)
playerFrame.t213Bet4:SetJustifyH("CENTER")
playerFrame.t213Bet4:SetText("21+3")
playerFrame.t213Bet4:SetFont("Fonts\\FRIZQT__.TTF", 15, "OUTLINE")
-- 21+3 Amount
t213BetAmount4 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
t213BetAmount4:SetPoint("CENTER", playerFrame, -107, -25)
t213BetAmount4:SetJustifyH("CENTER")
t213BetAmount4:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- Player Name
playerFrame.player4Name = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.player4Name:SetPoint("BOTTOM", playerFrame, -255, 171)
playerFrame.player4Name:SetText(UnitName("player"))
playerFrame.player4Name:SetFont("Fonts\\FRIZQT__.TTF", 22, "OUTLINE")
-- Insurance
playerFrame.insuranceBet4 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.insuranceBet4:SetPoint("BOTTOM", playerFrame, -255, 89)
playerFrame.insuranceBet4:SetText("Insurance")
playerFrame.insuranceBet4:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
-- Insurance (if available)
playerFrame.insuranceIfAvailable4 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.insuranceIfAvailable4:SetPoint("BOTTOM", playerFrame, -255, 79)
playerFrame.insuranceIfAvailable4:SetText("(if available)")
playerFrame.insuranceIfAvailable4:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")



-- Images for Player 4
-- Main Bet
playerFrame.coinsMainBet4 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coinsMainBet4:SetSize(128, 128)
playerFrame.coinsMainBet4:SetPoint("CENTER", playerFrame, -163, -48)
playerFrame.coinsMainBet4:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsBet.tga")
playerFrame.coinsMainBet4:SetBlendMode("BLEND")
playerFrame.coinsMainBet4:SetDrawLayer("OVERLAY")
playerFrame.coinsMainBet4:Hide()
-- PP Bet
playerFrame.coinsPPBet4 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coinsPPBet4:SetSize(128, 128)
playerFrame.coinsPPBet4:SetPoint("CENTER", playerFrame, -215, 8)
playerFrame.coinsPPBet4:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsHalfBet.tga")
playerFrame.coinsPPBet4:SetBlendMode("BLEND")
playerFrame.coinsPPBet4:SetDrawLayer("OVERLAY")
playerFrame.coinsPPBet4:Hide()
-- 21+3 Bet
playerFrame.coins213Bet4 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coins213Bet4:SetSize(128, 128)
playerFrame.coins213Bet4:SetPoint("CENTER", playerFrame, -102, -44)
playerFrame.coins213Bet4:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsHalfBet.tga")
playerFrame.coins213Bet4:SetBlendMode("BLEND")
playerFrame.coins213Bet4:SetDrawLayer("OVERLAY")
playerFrame.coins213Bet4:Hide()



-- Function to handle Player 4 Main Bet Image
local function PlaceBetsMain4(message)
    playerFrame.coinsMainBet4:Show()
end

-- Function to handle Player 4 Main Bet Text
local function PlaceBetsTextMain4(Amount)
    mainBetAmount4:SetText(Amount .. " G")
    mainBetAmount4:Show()
end

-- Function to handle Player 4 PP Bet Image
local function PlaceBetsPP4(message)
    playerFrame.coinsPPBet4:Show()
end

-- Function to handle Player 4 PP Bet Text
local function PlaceBetsTextPP4(Amount)
    ppBetAmount4:SetText(Amount .. " G")
    ppBetAmount4:Show()
end

-- Function to handle Player 4 21+3 Bet Image
local function PlaceBets2134(message)
    playerFrame.coins213Bet4:Show()
end

-- Function to handle Player 4 21+3 Bet Text
local function PlaceBetsText2134(Amount)
    t213BetAmount4:SetText(Amount .. " G")
    t213BetAmount4:Show()
end


-- Function to handle the Player 4 Main "Bet" button click
local function ConfirmBetClickMain4()
    betAmountMain4 = tonumber(betEditBoxMain4:GetText()) -- Get the entered bet amount
    if betAmountMain4 and betAmountMain4 >= minBetMain and betAmountMain4 <= maxBetMain then
        -- Valid bet amount, send the message with the bet
        SendChatMessage("[P4] Placing a " ..betAmountMain4.. "G main bet.", "RAID")
        -- Disable the edit box and button
        betEditBoxMain4:SetFocus(false)
        betEditBoxMain4:ClearFocus()
        betEditBoxMain4:Disable()
        confirmBetButtonMain4:Disable()
        PlaySoundFile(soundFilePaths[43])
    else
        print("Invalid bet amount. Please enter a value between " .. minBetMain .. "G and " .. maxBetMain .. "G.")
    end
end



-- Function to handle the Player 4 PP "Bet" button click
local function ConfirmBetClickPP4()
    betAmountPP4 = tonumber(betEditBoxPP4:GetText()) -- Get the entered bet amount
    if betAmountPP4 and betAmountPP4 >= minBetPP and betAmountPP4 <= maxBetPP then
        -- Valid bet amount, send the message with the bet
        SendChatMessage("[P4] Placing a " ..betAmountPP4.. "G side bet on Perfect Pairs.", "RAID")
        -- Disable the edit box and button
        betEditBoxPP4:SetFocus(false)
        betEditBoxPP4:ClearFocus()
        betEditBoxPP4:Disable()
        confirmBetButtonPP4:Disable()
        PlaySoundFile(soundFilePaths[43])
    else
        print("Invalid bet amount. Please enter a value between " .. minBetPP .. "G and " .. maxBetPP .. "G.")
    end
end



-- Function to handle the Player 4 21+3 "Bet" button click
local function ConfirmBetClick2134()
    betAmount2134 = tonumber(betEditBox2134:GetText()) -- Get the entered bet amount
    if betAmount2134 and betAmount2134 >= minBet213 and betAmount2134 <= maxBet213 then
        -- Valid bet amount, send the message with the bet
        SendChatMessage("[P4] Placing a " ..betAmount2134.. "G side bet on 21+3.", "RAID")
        -- Disable the edit box and button
        betEditBox2134:SetFocus(false)
        betEditBox2134:ClearFocus()
        betEditBox2134:Disable()
        confirmBetButton2134:Disable()
        PlaySoundFile(soundFilePaths[43])
    else
        print("Invalid bet amount. Please enter a value between " .. minBet213 .. "G and " .. maxBet213 .. "G.")
    end
end



-- Player 4 Main "Bet" button
confirmBetButtonMain4:SetScript("OnClick", ConfirmBetClickMain4)

-- Player 4 PP "Bet" button
confirmBetButtonPP4:SetScript("OnClick", ConfirmBetClickPP4)

-- Player 4 21+3 "Bet" button
confirmBetButton2134:SetScript("OnClick", ConfirmBetClick2134)






-- Insurance YES for Player 5
insuranceYesIcon5 = playerFrame:CreateTexture(nil, "OVERLAY")
insuranceYesIcon5:SetSize(32, 32)
insuranceYesIcon5:SetPoint("CENTER", playerFrame, -523, -12)
insuranceYesIcon5:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\insuranceYes.tga")
insuranceYesIcon5:SetDrawLayer("ARTWORK")
insuranceYesIcon5:Hide()

-- Insurance NO for Player 5
insuranceNoIcon5 = playerFrame:CreateTexture(nil, "OVERLAY")
insuranceNoIcon5:SetSize(32, 32)
insuranceNoIcon5:SetPoint("CENTER", playerFrame, -523, -12)
insuranceNoIcon5:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\insuranceNo.tga")
insuranceNoIcon5:SetDrawLayer("ARTWORK")
insuranceNoIcon5:Hide()




-- Buttons for Player 5
-- Hit
playerFrame.hitButton5 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.hitButton5:SetPoint("BOTTOM", playerFrame, -472, 275)
playerFrame.hitButton5:SetSize(65, 30)
playerFrame.hitButton5:SetText("Hit")
playerFrame.hitButton5:Disable()
-- Stand
playerFrame.standButton5 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.standButton5:SetPoint("BOTTOM", playerFrame, -406, 275)
playerFrame.standButton5:SetSize(65, 30)
playerFrame.standButton5:SetText("Stand")
playerFrame.standButton5:Disable()
-- Double
playerFrame.doubleButton5 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.doubleButton5:SetPoint("BOTTOM", playerFrame, -472, 245)
playerFrame.doubleButton5:SetSize(65, 30)
playerFrame.doubleButton5:SetText("Double")
playerFrame.doubleButton5:Disable()
-- Split
playerFrame.splitButton5 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.splitButton5:SetPoint("BOTTOM", playerFrame, -406, 245)
playerFrame.splitButton5:SetSize(65, 30)
playerFrame.splitButton5:SetText("Split")
playerFrame.splitButton5:Disable()
-- Insurance Yes
playerFrame.insuranceYesButton5 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.insuranceYesButton5:SetPoint("BOTTOM", playerFrame, -505, 215)
playerFrame.insuranceYesButton5:SetSize(55, 30)
playerFrame.insuranceYesButton5:SetText("Yes")
playerFrame.insuranceYesButton5:Disable()
-- Insurance No
playerFrame.insuranceNoButton5 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.insuranceNoButton5:SetPoint("BOTTOM", playerFrame, -378, 215)
playerFrame.insuranceNoButton5:SetSize(55, 30)
playerFrame.insuranceNoButton5:SetText("No")
playerFrame.insuranceNoButton5:Disable()
-- Main Bet Confirm
local confirmBetButtonMain5 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
confirmBetButtonMain5:SetPoint("BOTTOM", playerFrame, -406, 334)
confirmBetButtonMain5:SetSize(65, 30)
confirmBetButtonMain5:SetText("Bet")
-- Perfect Pairs Confirm
local confirmBetButtonPP5 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
confirmBetButtonPP5:SetPoint("BOTTOM", playerFrame, -375, 468)
confirmBetButtonPP5:SetSize(43, 25)
confirmBetButtonPP5:SetText("Bet")
-- 21+3 Confirm
local confirmBetButton2135 = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
confirmBetButton2135:SetPoint("BOTTOM", playerFrame, -305, 335)
confirmBetButton2135:SetSize(43, 25)
confirmBetButton2135:SetText("Bet")



-- Wagers for Player 5
-- Main Bet
local betEditBoxMain5 = CreateFrame("EditBox", nil, playerFrame, "InputBoxTemplate")
betEditBoxMain5:SetSize(55, 30)
betEditBoxMain5:SetPoint("BOTTOM", playerFrame, -468, 334)
betEditBoxMain5:SetAutoFocus(false)
betEditBoxMain5:SetNumeric(true)
-- Perfect Pairs
local betEditBoxPP5 = CreateFrame("EditBox", nil, playerFrame, "InputBoxTemplate")
betEditBoxPP5:SetSize(35, 30)
betEditBoxPP5:SetPoint("BOTTOM", playerFrame, -373, 488)
betEditBoxPP5:SetAutoFocus(false)
betEditBoxPP5:SetNumeric(true)
-- 21+3
local betEditBox2135 = CreateFrame("EditBox", nil, playerFrame, "InputBoxTemplate")
betEditBox2135:SetSize(35, 30)
betEditBox2135:SetPoint("BOTTOM", playerFrame, -303, 355)
betEditBox2135:SetAutoFocus(false)
betEditBox2135:SetNumeric(true)



-- Labels for Player 5
-- Main Bet
playerFrame.mainBet5 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.mainBet5:SetPoint("BOTTOM", playerFrame, -468, 362)
playerFrame.mainBet5:SetJustifyH("CENTER")
playerFrame.mainBet5:SetText("Main Bet")
playerFrame.mainBet5:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- Main Bet Amount
mainBetAmount5 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
mainBetAmount5:SetPoint("CENTER", playerFrame, -330, 97)
mainBetAmount5:SetJustifyH("CENTER")
mainBetAmount5:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- Perfect Pairs
playerFrame.ppBet5 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.ppBet5:SetPoint("BOTTOM", playerFrame, -408, 483)
playerFrame.ppBet5:SetJustifyH("CENTER")
playerFrame.ppBet5:SetText("PP")
playerFrame.ppBet5:SetFont("Fonts\\FRIZQT__.TTF", 15, "OUTLINE")
-- Perfect Pairs Amount
ppBetAmount5 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
ppBetAmount5:SetPoint("CENTER", playerFrame, -328, 154)
ppBetAmount5:SetJustifyH("CENTER")
ppBetAmount5:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- 21+3
playerFrame.t213Bet5 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.t213Bet5:SetPoint("BOTTOM", playerFrame, -261, 351)
playerFrame.t213Bet5:SetJustifyH("CENTER")
playerFrame.t213Bet5:SetText("21+3")
playerFrame.t213Bet5:SetFont("Fonts\\FRIZQT__.TTF", 15, "OUTLINE")
-- 21+3 Amount
t213BetAmount5 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
t213BetAmount5:SetPoint("CENTER", playerFrame, -263, 56)
t213BetAmount5:SetJustifyH("CENTER")
t213BetAmount5:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")
-- Player Name
playerFrame.player5Name = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.player5Name:SetPoint("BOTTOM", playerFrame, -439, 310)
playerFrame.player5Name:SetText(UnitName("player"))
playerFrame.player5Name:SetFont("Fonts\\FRIZQT__.TTF", 22, "OUTLINE")
-- Insurance
playerFrame.insuranceBet5 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.insuranceBet5:SetPoint("BOTTOM", playerFrame, -439, 228)
playerFrame.insuranceBet5:SetText("Insurance")
playerFrame.insuranceBet5:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
-- Insurance (if available)
playerFrame.insuranceIfAvailable5 = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.insuranceIfAvailable5:SetPoint("BOTTOM", playerFrame, -439, 218)
playerFrame.insuranceIfAvailable5:SetText("(if available)")
playerFrame.insuranceIfAvailable5:SetFont("Fonts\\FRIZQT__.TTF", 8, "OUTLINE")




-- Images for Player 5
-- Main Bet
playerFrame.coinsMainBet5 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coinsMainBet5:SetSize(128, 128)
playerFrame.coinsMainBet5:SetPoint("CENTER", playerFrame, -308, 68)
playerFrame.coinsMainBet5:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsBet.tga")
playerFrame.coinsMainBet5:SetBlendMode("BLEND")
playerFrame.coinsMainBet5:SetDrawLayer("OVERLAY")
playerFrame.coinsMainBet5:Hide()
-- PP Bet
playerFrame.coinsPPBet5 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coinsPPBet5:SetSize(128, 128)
playerFrame.coinsPPBet5:SetPoint("CENTER", playerFrame, -323, 136)
playerFrame.coinsPPBet5:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsHalfBet.tga")
playerFrame.coinsPPBet5:SetBlendMode("BLEND")
playerFrame.coinsPPBet5:SetDrawLayer("OVERLAY")
playerFrame.coinsPPBet5:Hide()
-- 21+3 Bet
playerFrame.coins213Bet5 = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.coins213Bet5:SetSize(128, 128)
playerFrame.coins213Bet5:SetPoint("CENTER", playerFrame, -258, 36)
playerFrame.coins213Bet5:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\CoinsHalfBet.tga")
playerFrame.coins213Bet5:SetBlendMode("BLEND")
playerFrame.coins213Bet5:SetDrawLayer("OVERLAY")
playerFrame.coins213Bet5:Hide()



-- Function to handle Player 5 Main Bet Image
local function PlaceBetsMain5(message)
    playerFrame.coinsMainBet5:Show()
end

-- Function to handle Player 5 Main Bet Text
local function PlaceBetsTextMain5(Amount)
    mainBetAmount5:SetText(Amount .. " G")
    mainBetAmount5:Show()
end

-- Function to handle Player 5 PP Bet Image
local function PlaceBetsPP5(message)
    playerFrame.coinsPPBet5:Show()
end

-- Function to handle Player 5 PP Bet Text
local function PlaceBetsTextPP5(Amount)
    ppBetAmount5:SetText(Amount .. " G")
    ppBetAmount5:Show()
end

-- Function to handle Player 5 21+3 Bet Image
local function PlaceBets2135(message)
    playerFrame.coins213Bet5:Show()
end

-- Function to handle Player 5 21+3 Bet Text
local function PlaceBetsText2135(Amount)
    t213BetAmount5:SetText(Amount .. " G")
    t213BetAmount5:Show()
end



-- Function to handle the Player 5 Main "Bet" button click
local function ConfirmBetClickMain5()
    betAmountMain5 = tonumber(betEditBoxMain5:GetText()) -- Get the entered bet amount
    if betAmountMain5 and betAmountMain5 >= minBetMain and betAmountMain5 <= maxBetMain then
        -- Valid bet amount, send the message with the bet
        SendChatMessage("[P5] Placing a " ..betAmountMain5.. "G main bet.", "RAID")
        -- Disable the edit box and button
        betEditBoxMain5:SetFocus(false)
        betEditBoxMain5:ClearFocus()
        betEditBoxMain5:Disable()
        confirmBetButtonMain5:Disable()
        PlaySoundFile(soundFilePaths[43])
    else
        print("Invalid bet amount. Please enter a value between " .. minBetMain .. "G and " .. maxBetMain .. "G.")
    end
end



-- Function to handle the Player 5 PP "Bet" button click
local function ConfirmBetClickPP5()
    betAmountPP5 = tonumber(betEditBoxPP5:GetText()) -- Get the entered bet amount
    if betAmountPP5 and betAmountPP5 >= minBetPP and betAmountPP5 <= maxBetPP then
        -- Valid bet amount, send the message with the bet
        SendChatMessage("[P5] Placing a " ..betAmountPP5.. "G side bet on Perfect Pairs.", "RAID")
        -- Disable the edit box and button
        betEditBoxPP5:SetFocus(false)
        betEditBoxPP5:ClearFocus()
        betEditBoxPP5:Disable()
        confirmBetButtonPP5:Disable()
        PlaySoundFile(soundFilePaths[43])
    else
        print("Invalid bet amount. Please enter a value between " .. minBetPP .. "G and " .. maxBetPP .. "G.")
    end
end



-- Function to handle the Player 5 21+3 "Bet" button click
local function ConfirmBetClick2135()
    betAmount2135 = tonumber(betEditBox2135:GetText()) -- Get the entered bet amount
    if betAmount2135 and betAmount2135 >= minBet213 and betAmount2135 <= maxBet213 then
        -- Valid bet amount, send the message with the bet
        SendChatMessage("[P5] Placing a " ..betAmount2135.. "G side bet on 21+3.", "RAID")
        -- Disable the edit box and button
        betEditBox2135:SetFocus(false)
        betEditBox2135:ClearFocus()
        betEditBox2135:Disable()
        confirmBetButton2135:Disable()
        PlaySoundFile(soundFilePaths[43])
    else
        print("Invalid bet amount. Please enter a value between " .. minBet213 .. "G and " .. maxBet213 .. "G.")
    end
end



-- Player 5 Main "Bet" button
confirmBetButtonMain5:SetScript("OnClick", ConfirmBetClickMain5)

-- Player 5 PP "Bet" button
confirmBetButtonPP5:SetScript("OnClick", ConfirmBetClickPP5)

-- Player 5 21+3 "Bet" button
confirmBetButton2135:SetScript("OnClick", ConfirmBetClick2135)

playerFrame.numberPlayer1Text = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.numberPlayer1Text:SetPoint("BOTTOM", playerFrame, "BOTTOM", 385, 368)
playerFrame.numberPlayer1Text:SetFont("Fonts\\FRIZQT__.TTF", 28, "OUTLINE")
playerFrame.numberPlayer1Text:SetText("")

playerFrame.numberPlayer2Text = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.numberPlayer2Text:SetPoint("BOTTOM", playerFrame, "BOTTOM", 210, 230)
playerFrame.numberPlayer2Text:SetFont("Fonts\\FRIZQT__.TTF", 28, "OUTLINE") -- Adjust the font and size as needed
playerFrame.numberPlayer2Text:SetText("")

playerFrame.numberPlayer3Text = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.numberPlayer3Text:SetPoint("BOTTOM", playerFrame, "BOTTOM", 4, 180)
playerFrame.numberPlayer3Text:SetFont("Fonts\\FRIZQT__.TTF", 28, "OUTLINE") -- Adjust the font and size as needed
playerFrame.numberPlayer3Text:SetText("")

playerFrame.numberPlayer4Text = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.numberPlayer4Text:SetPoint("BOTTOM", playerFrame, "BOTTOM", -210, 230)
playerFrame.numberPlayer4Text:SetFont("Fonts\\FRIZQT__.TTF", 28, "OUTLINE") -- Adjust the font and size as needed
playerFrame.numberPlayer4Text:SetText("")

playerFrame.numberPlayer5Text = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.numberPlayer5Text:SetPoint("BOTTOM", playerFrame, "BOTTOM", -385, 368)
playerFrame.numberPlayer5Text:SetFont("Fonts\\FRIZQT__.TTF", 28, "OUTLINE") -- Adjust the font and size as needed
playerFrame.numberPlayer5Text:SetText("")

playerFrame.numberDealerText = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
playerFrame.numberDealerText:SetPoint("TOP", playerFrame, "TOP", -65, -148)
playerFrame.numberDealerText:SetFont("Fonts\\FRIZQT__.TTF", 28, "OUTLINE") -- Adjust the font and size as needed
playerFrame.numberDealerText:SetText("")








-- Check if the player is in the raid party
local function isPlayerInRaidParty(playerName, raidPartyMembers)
    for _, memberName in ipairs(raidPartyMembers) do
        if playerName == memberName then
            return true
        end
    end
    return false
end



-- Set visibility for seat 1 (raidpartymember 2)
local function isPlayer1()
    playerFrame.hitButton1:Show()
    playerFrame.standButton1:Show()
    playerFrame.doubleButton1:Show()
    playerFrame.splitButton1:Show()
    playerFrame.insuranceYesButton1:Show()
    playerFrame.insuranceNoButton1:Show()
    confirmBetButtonMain1:Show()
    confirmBetButtonPP1:Show()
    confirmBetButton2131:Show()
    betEditBoxMain1:Show()
    betEditBox2131:Show()
    betEditBoxPP1:Show()
    playerFrame.mainBet1:Show()
    playerFrame.ppBet1:Show()
    playerFrame.t213Bet1:Show()
    playerFrame.insuranceBet1:Show()
    playerFrame.insuranceIfAvailable1:Show()
    playerFrame.hitButton2:Hide()
    playerFrame.standButton2:Hide()
    playerFrame.doubleButton2:Hide()
    playerFrame.splitButton2:Hide()
    playerFrame.insuranceYesButton2:Hide()
    playerFrame.insuranceNoButton2:Hide()
    confirmBetButtonMain2:Hide()
    confirmBetButtonPP2:Hide()
    confirmBetButton2132:Hide()
    betEditBoxMain2:Hide()
    betEditBox2132:Hide()
    betEditBoxPP2:Hide()
    playerFrame.mainBet2:Hide()
    playerFrame.ppBet2:Hide()
    playerFrame.t213Bet2:Hide()
    playerFrame.insuranceBet2:Hide()
    playerFrame.insuranceIfAvailable2:Hide()
    playerFrame.hitButton3:Hide()
    playerFrame.standButton3:Hide()
    playerFrame.doubleButton3:Hide()
    playerFrame.splitButton3:Hide()
    playerFrame.insuranceYesButton3:Hide()
    playerFrame.insuranceNoButton3:Hide()
    confirmBetButtonMain3:Hide()
    confirmBetButtonPP3:Hide()
    confirmBetButton2133:Hide()
    betEditBoxMain3:Hide()
    betEditBox2133:Hide()
    betEditBoxPP3:Hide()
    playerFrame.mainBet3:Hide()
    playerFrame.ppBet3:Hide()
    playerFrame.t213Bet3:Hide()
    playerFrame.insuranceBet3:Hide()
    playerFrame.insuranceIfAvailable3:Hide()
    playerFrame.hitButton4:Hide()
    playerFrame.standButton4:Hide()
    playerFrame.doubleButton4:Hide()
    playerFrame.splitButton4:Hide()
    playerFrame.insuranceYesButton4:Hide()
    playerFrame.insuranceNoButton4:Hide()
    confirmBetButtonMain4:Hide()
    confirmBetButtonPP4:Hide()
    confirmBetButton2134:Hide()
    betEditBoxMain4:Hide()
    betEditBox2134:Hide()
    betEditBoxPP4:Hide()
    playerFrame.mainBet4:Hide()
    playerFrame.ppBet4:Hide()
    playerFrame.t213Bet4:Hide()
    playerFrame.insuranceBet4:Hide()
    playerFrame.insuranceIfAvailable4:Hide()
    playerFrame.hitButton5:Hide()
    playerFrame.standButton5:Hide()
    playerFrame.doubleButton5:Hide()
    playerFrame.splitButton5:Hide()
    playerFrame.insuranceYesButton5:Hide()
    playerFrame.insuranceNoButton5:Hide()
    confirmBetButtonMain5:Hide()
    confirmBetButtonPP5:Hide()
    confirmBetButton2135:Hide()
    betEditBoxMain5:Hide()
    betEditBox2135:Hide()
    betEditBoxPP5:Hide()
    playerFrame.mainBet5:Hide()
    playerFrame.ppBet5:Hide()
    playerFrame.t213Bet5:Hide()
    playerFrame.insuranceBet5:Hide()
    playerFrame.insuranceIfAvailable5:Hide()
    print("You're in Seat 1!")
end

-- Set visibility for seat 2 (raidpartymember 3)
local function isPlayer2()
    playerFrame.hitButton2:Show()
    playerFrame.standButton2:Show()
    playerFrame.doubleButton2:Show()
    playerFrame.splitButton2:Show()
    playerFrame.insuranceYesButton2:Show()
    playerFrame.insuranceNoButton2:Show()
    confirmBetButtonMain2:Show()
    confirmBetButtonPP2:Show()
    confirmBetButton2132:Show()
    betEditBoxMain2:Show()
    betEditBox2132:Show()
    betEditBoxPP2:Show()
    playerFrame.mainBet2:Show()
    playerFrame.ppBet2:Show()
    playerFrame.t213Bet2:Show()
    playerFrame.insuranceBet2:Show()
    playerFrame.insuranceIfAvailable2:Show()
    playerFrame.hitButton1:Hide()
    playerFrame.standButton1:Hide()
    playerFrame.doubleButton1:Hide()
    playerFrame.splitButton1:Hide()
    playerFrame.insuranceYesButton1:Hide()
    playerFrame.insuranceNoButton1:Hide()
    confirmBetButtonMain1:Hide()
    confirmBetButtonPP1:Hide()
    confirmBetButton2131:Hide()
    betEditBoxMain1:Hide()
    betEditBox2131:Hide()
    betEditBoxPP1:Hide()
    playerFrame.mainBet1:Hide()
    playerFrame.ppBet1:Hide()
    playerFrame.t213Bet1:Hide()
    playerFrame.insuranceBet1:Hide()
    playerFrame.insuranceIfAvailable1:Hide()
    playerFrame.hitButton3:Hide()
    playerFrame.standButton3:Hide()
    playerFrame.doubleButton3:Hide()
    playerFrame.splitButton3:Hide()
    playerFrame.insuranceYesButton3:Hide()
    playerFrame.insuranceNoButton3:Hide()
    confirmBetButtonMain3:Hide()
    confirmBetButtonPP3:Hide()
    confirmBetButton2133:Hide()
    betEditBoxMain3:Hide()
    betEditBox2133:Hide()
    betEditBoxPP3:Hide()
    playerFrame.mainBet3:Hide()
    playerFrame.ppBet3:Hide()
    playerFrame.t213Bet3:Hide()
    playerFrame.insuranceBet3:Hide()
    playerFrame.insuranceIfAvailable3:Hide()
    playerFrame.hitButton4:Hide()
    playerFrame.standButton4:Hide()
    playerFrame.doubleButton4:Hide()
    playerFrame.splitButton4:Hide()
    playerFrame.insuranceYesButton4:Hide()
    playerFrame.insuranceNoButton4:Hide()
    confirmBetButtonMain4:Hide()
    confirmBetButtonPP4:Hide()
    confirmBetButton2134:Hide()
    betEditBoxMain4:Hide()
    betEditBox2134:Hide()
    betEditBoxPP4:Hide()
    playerFrame.mainBet4:Hide()
    playerFrame.ppBet4:Hide()
    playerFrame.t213Bet4:Hide()
    playerFrame.insuranceBet4:Hide()
    playerFrame.insuranceIfAvailable4:Hide()
    playerFrame.hitButton5:Hide()
    playerFrame.standButton5:Hide()
    playerFrame.doubleButton5:Hide()
    playerFrame.splitButton5:Hide()
    playerFrame.insuranceYesButton5:Hide()
    playerFrame.insuranceNoButton5:Hide()
    confirmBetButtonMain5:Hide()
    confirmBetButtonPP5:Hide()
    confirmBetButton2135:Hide()
    betEditBoxMain5:Hide()
    betEditBox2135:Hide()
    betEditBoxPP5:Hide()
    playerFrame.mainBet5:Hide()
    playerFrame.ppBet5:Hide()
    playerFrame.t213Bet5:Hide()
    playerFrame.insuranceBet5:Hide()
    playerFrame.insuranceIfAvailable5:Hide()
    print("You're in Seat 2!")
end

-- Set visibility for seat 3 (raidpartymember 4)
local function isPlayer3()
    playerFrame.hitButton3:Show()
    playerFrame.standButton3:Show()
    playerFrame.doubleButton3:Show()
    playerFrame.splitButton3:Show()
    playerFrame.insuranceYesButton3:Show()
    playerFrame.insuranceNoButton3:Show()
    confirmBetButtonMain3:Show()
    confirmBetButtonPP3:Show()
    confirmBetButton2133:Show()
    betEditBoxMain3:Show()
    betEditBox2133:Show()
    betEditBoxPP3:Show()
    playerFrame.mainBet3:Show()
    playerFrame.ppBet3:Show()
    playerFrame.t213Bet3:Show()
    playerFrame.insuranceBet3:Show()
    playerFrame.insuranceIfAvailable3:Show()
    playerFrame.hitButton1:Hide()
    playerFrame.standButton1:Hide()
    playerFrame.doubleButton1:Hide()
    playerFrame.splitButton1:Hide()
    playerFrame.insuranceYesButton1:Hide()
    playerFrame.insuranceNoButton1:Hide()
    confirmBetButtonMain1:Hide()
    confirmBetButtonPP1:Hide()
    confirmBetButton2131:Hide()
    betEditBoxMain1:Hide()
    betEditBox2131:Hide()
    betEditBoxPP1:Hide()
    playerFrame.mainBet1:Hide()
    playerFrame.ppBet1:Hide()
    playerFrame.t213Bet1:Hide()
    playerFrame.insuranceBet1:Hide()
    playerFrame.insuranceIfAvailable1:Hide()
    playerFrame.hitButton2:Hide()
    playerFrame.standButton2:Hide()
    playerFrame.doubleButton2:Hide()
    playerFrame.splitButton2:Hide()
    playerFrame.insuranceYesButton2:Hide()
    playerFrame.insuranceNoButton2:Hide()
    confirmBetButtonMain2:Hide()
    confirmBetButtonPP2:Hide()
    confirmBetButton2132:Hide()
    betEditBoxMain2:Hide()
    betEditBox2132:Hide()
    betEditBoxPP2:Hide()
    playerFrame.mainBet2:Hide()
    playerFrame.ppBet2:Hide()
    playerFrame.t213Bet2:Hide()
    playerFrame.insuranceBet2:Hide()
    playerFrame.insuranceIfAvailable2:Hide()
    playerFrame.hitButton4:Hide()
    playerFrame.standButton4:Hide()
    playerFrame.doubleButton4:Hide()
    playerFrame.splitButton4:Hide()
    playerFrame.insuranceYesButton4:Hide()
    playerFrame.insuranceNoButton4:Hide()
    confirmBetButtonMain4:Hide()
    confirmBetButtonPP4:Hide()
    confirmBetButton2134:Hide()
    betEditBoxMain4:Hide()
    betEditBox2134:Hide()
    betEditBoxPP4:Hide()
    playerFrame.mainBet4:Hide()
    playerFrame.ppBet4:Hide()
    playerFrame.t213Bet4:Hide()
    playerFrame.insuranceBet4:Hide()
    playerFrame.insuranceIfAvailable4:Hide()
    playerFrame.hitButton5:Hide()
    playerFrame.standButton5:Hide()
    playerFrame.doubleButton5:Hide()
    playerFrame.splitButton5:Hide()
    playerFrame.insuranceYesButton5:Hide()
    playerFrame.insuranceNoButton5:Hide()
    confirmBetButtonMain5:Hide()
    confirmBetButtonPP5:Hide()
    confirmBetButton2135:Hide()
    betEditBoxMain5:Hide()
    betEditBox2135:Hide()
    betEditBoxPP5:Hide()
    playerFrame.mainBet5:Hide()
    playerFrame.ppBet5:Hide()
    playerFrame.t213Bet5:Hide()
    playerFrame.insuranceBet5:Hide()
    playerFrame.insuranceIfAvailable5:Hide()
    print("You're in Seat 3!")
end

-- Set visibility for seat 4 (raidpartymember 5)
local function isPlayer4()
    playerFrame.hitButton4:Show()
    playerFrame.standButton4:Show()
    playerFrame.doubleButton4:Show()
    playerFrame.splitButton4:Show()
    playerFrame.insuranceYesButton4:Show()
    playerFrame.insuranceNoButton4:Show()
    confirmBetButtonMain4:Show()
    confirmBetButtonPP4:Show()
    confirmBetButton2134:Show()
    betEditBoxMain4:Show()
    betEditBox2134:Show()
    betEditBoxPP4:Show()
    playerFrame.mainBet4:Show()
    playerFrame.ppBet4:Show()
    playerFrame.t213Bet4:Show()
    playerFrame.insuranceBet4:Show()
    playerFrame.insuranceIfAvailable4:Show()
    playerFrame.hitButton1:Hide()
    playerFrame.standButton1:Hide()
    playerFrame.doubleButton1:Hide()
    playerFrame.splitButton1:Hide()
    playerFrame.insuranceYesButton1:Hide()
    playerFrame.insuranceNoButton1:Hide()
    confirmBetButtonMain1:Hide()
    confirmBetButtonPP1:Hide()
    confirmBetButton2131:Hide()
    betEditBoxMain1:Hide()
    betEditBox2131:Hide()
    betEditBoxPP1:Hide()
    playerFrame.mainBet1:Hide()
    playerFrame.ppBet1:Hide()
    playerFrame.t213Bet1:Hide()
    playerFrame.insuranceBet1:Hide()
    playerFrame.insuranceIfAvailable1:Hide()
    playerFrame.hitButton2:Hide()
    playerFrame.standButton2:Hide()
    playerFrame.doubleButton2:Hide()
    playerFrame.splitButton2:Hide()
    playerFrame.insuranceYesButton2:Hide()
    playerFrame.insuranceNoButton2:Hide()
    confirmBetButtonMain2:Hide()
    confirmBetButtonPP2:Hide()
    confirmBetButton2132:Hide()
    betEditBoxMain2:Hide()
    betEditBox2132:Hide()
    betEditBoxPP2:Hide()
    playerFrame.mainBet2:Hide()
    playerFrame.ppBet2:Hide()
    playerFrame.t213Bet2:Hide()
    playerFrame.insuranceBet2:Hide()
    playerFrame.insuranceIfAvailable2:Hide()
    playerFrame.hitButton3:Hide()
    playerFrame.standButton3:Hide()
    playerFrame.doubleButton3:Hide()
    playerFrame.splitButton3:Hide()
    playerFrame.insuranceYesButton3:Hide()
    playerFrame.insuranceNoButton3:Hide()
    confirmBetButtonMain3:Hide()
    confirmBetButtonPP3:Hide()
    confirmBetButton2133:Hide()
    betEditBoxMain3:Hide()
    betEditBox2133:Hide()
    betEditBoxPP3:Hide()
    playerFrame.mainBet3:Hide()
    playerFrame.ppBet3:Hide()
    playerFrame.t213Bet3:Hide()
    playerFrame.insuranceBet3:Hide()
    playerFrame.insuranceIfAvailable3:Hide()
    playerFrame.hitButton5:Hide()
    playerFrame.standButton5:Hide()
    playerFrame.doubleButton5:Hide()
    playerFrame.splitButton5:Hide()
    playerFrame.insuranceYesButton5:Hide()
    playerFrame.insuranceNoButton5:Hide()
    confirmBetButtonMain5:Hide()
    confirmBetButtonPP5:Hide()
    confirmBetButton2135:Hide()
    betEditBoxMain5:Hide()
    betEditBox2135:Hide()
    betEditBoxPP5:Hide()
    playerFrame.mainBet5:Hide()
    playerFrame.ppBet5:Hide()
    playerFrame.t213Bet5:Hide()
    playerFrame.insuranceBet5:Hide()
    playerFrame.insuranceIfAvailable5:Hide()
    print("You're in Seat 4!")
end

-- Set visibility for seat 5 (raidpartymember 6)
local function isPlayer5()
    playerFrame.hitButton5:Show()
    playerFrame.standButton5:Show()
    playerFrame.doubleButton5:Show()
    playerFrame.splitButton5:Show()
    playerFrame.insuranceYesButton5:Show()
    playerFrame.insuranceNoButton5:Show()
    confirmBetButtonMain5:Show()
    confirmBetButtonPP5:Show()
    confirmBetButton2135:Show()
    betEditBoxMain5:Show()
    betEditBox2135:Show()
    betEditBoxPP5:Show()
    playerFrame.mainBet5:Show()
    playerFrame.ppBet5:Show()
    playerFrame.t213Bet5:Show()
    playerFrame.insuranceBet5:Show()
    playerFrame.insuranceIfAvailable5:Show()
    playerFrame.hitButton1:Hide()
    playerFrame.standButton1:Hide()
    playerFrame.doubleButton1:Hide()
    playerFrame.splitButton1:Hide()
    playerFrame.insuranceYesButton1:Hide()
    playerFrame.insuranceNoButton1:Hide()
    confirmBetButtonMain1:Hide()
    confirmBetButtonPP1:Hide()
    confirmBetButton2131:Hide()
    betEditBoxMain1:Hide()
    betEditBox2131:Hide()
    betEditBoxPP1:Hide()
    playerFrame.mainBet1:Hide()
    playerFrame.ppBet1:Hide()
    playerFrame.t213Bet1:Hide()
    playerFrame.insuranceBet1:Hide()
    playerFrame.insuranceIfAvailable1:Hide()
    playerFrame.hitButton2:Hide()
    playerFrame.standButton2:Hide()
    playerFrame.doubleButton2:Hide()
    playerFrame.splitButton2:Hide()
    playerFrame.insuranceYesButton2:Hide()
    playerFrame.insuranceNoButton2:Hide()
    confirmBetButtonMain2:Hide()
    confirmBetButtonPP2:Hide()
    confirmBetButton2132:Hide()
    betEditBoxMain2:Hide()
    betEditBox2132:Hide()
    betEditBoxPP2:Hide()
    playerFrame.mainBet2:Hide()
    playerFrame.ppBet2:Hide()
    playerFrame.t213Bet2:Hide()
    playerFrame.insuranceBet2:Hide()
    playerFrame.insuranceIfAvailable2:Hide()
    playerFrame.hitButton3:Hide()
    playerFrame.standButton3:Hide()
    playerFrame.doubleButton3:Hide()
    playerFrame.splitButton3:Hide()
    playerFrame.insuranceYesButton3:Hide()
    playerFrame.insuranceNoButton3:Hide()
    confirmBetButtonMain3:Hide()
    confirmBetButtonPP3:Hide()
    confirmBetButton2133:Hide()
    betEditBoxMain3:Hide()
    betEditBox2133:Hide()
    betEditBoxPP3:Hide()
    playerFrame.mainBet3:Hide()
    playerFrame.ppBet3:Hide()
    playerFrame.t213Bet3:Hide()
    playerFrame.insuranceBet3:Hide()
    playerFrame.insuranceIfAvailable3:Hide()
    playerFrame.hitButton4:Hide()
    playerFrame.standButton4:Hide()
    playerFrame.doubleButton4:Hide()
    playerFrame.splitButton4:Hide()
    playerFrame.insuranceYesButton4:Hide()
    playerFrame.insuranceNoButton4:Hide()
    confirmBetButtonMain4:Hide()
    confirmBetButtonPP4:Hide()
    confirmBetButton2134:Hide()
    betEditBoxMain4:Hide()
    betEditBox2134:Hide()
    betEditBoxPP4:Hide()
    playerFrame.mainBet4:Hide()
    playerFrame.ppBet4:Hide()
    playerFrame.t213Bet4:Hide()
    playerFrame.insuranceBet4:Hide()
    playerFrame.insuranceIfAvailable4:Hide()
    print("You're in Seat 5!")
end

-- Update player names in the playerFrame
playerFrame.player1Name:SetText(unitName1);
playerFrame.player2Name:SetText(unitName2);
playerFrame.player3Name:SetText(unitName3);
playerFrame.player4Name:SetText(unitName4);
playerFrame.player5Name:SetText(unitName5);


local function UpdateTimerDisplay1(secondsRemaining)
    playerFrame.timerText1:SetText("Timer: " .. secondsRemaining .. " s remaining")
end

local function OnTimerUpdate1()
    countdownDuration = countdownDuration - 1

    if countdownDuration <= 0 then
        playerFrame.hitButton1:Disable()
        playerFrame.standButton1:Disable()
        playerFrame.doubleButton1:Disable()
        if Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == false and Player5Active == false then       -- Players: 1
            turn = 9
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == false then    -- Players: 1 2
            turn = 11
        elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 1 3
            turn = 11
        elseif Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 1 4
            turn = 11
        elseif Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 1 5
            turn = 11
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 1 2 3
            turn = 13
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 1 2 4
            turn = 13
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 1 2 5
            turn = 13
        elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 1 3 4
            turn = 13
        elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 1 3 5
            turn = 13
        elseif Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 1 4 5
            turn = 13
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 1 2 3 4
            turn = 15
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 1 2 3 5
            turn = 15
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 1 2 4 5
            turn = 15
        elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 3 4 5
            turn = 15
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 2 3 4 5
            turn = 17
        end
        countdownTimer1:Cancel()
        playerFrame.timerText1:SetPoint("TOPRIGHT", playerFrame, "TOPRIGHT", -280, -150)
        playerFrame.timerText1:SetText("Time is up!")
        playerFrame.timerText1:SetJustifyH("CENTER")
        playerFrame.timerText1:SetTextColor(1, 0, 0)
    else
        UpdateTimerDisplay1(countdownDuration)
    end
end

local function StartCountdownTimer1()
    if countdownTimer1 then
        countdownTimer1:Cancel()
    end
    countdownTimer1 = C_Timer.NewTicker(1, OnTimerUpdate1, countdownDuration)
    playerFrame.timerText1:SetPoint("TOPRIGHT", playerFrame, "TOPRIGHT", -230, -150)
    playerFrame.timerText1:Show()
    playerFrame.timerText1:SetTextColor(1, 1, 1)
end



local function UpdateTimerDisplay2(secondsRemaining)
    playerFrame.timerText2:SetText("Timer: " .. secondsRemaining .. " s remaining")
end

local function OnTimerUpdate2()
    countdownDuration = countdownDuration - 1

    if countdownDuration <= 0 then
        playerFrame.hitButton2:Disable()
        playerFrame.standButton2:Disable()
        playerFrame.doubleButton2:Disable()
        if Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == false then       -- Players: 2
            turn = 9
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == false then    -- Players: 1 2
            turn = 17
        elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 2 3
            turn = 11
        elseif Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 2 4
            turn = 11
        elseif Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 2 5
            turn = 11
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 1 2 3
            turn = 19
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 1 2 4
            turn = 19
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 1 2 5
            turn = 19
        elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 2 3 4
            turn = 13
        elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 2 3 5
            turn = 13
        elseif Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 2 4 5
            turn = 13
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 1 2 3 4
            turn = 21
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 1 2 3 5
            turn = 21
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 1 2 4 5
            turn = 15
        elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 2 3 4 5
            turn = 15
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 2 3 4 5
            turn = 23
        end
        countdownTimer2:Cancel()
        playerFrame.timerText2:SetPoint("TOPRIGHT", playerFrame, "TOPRIGHT", -280, -150)
        playerFrame.timerText2:SetText("Time is up!")
        playerFrame.timerText2:SetJustifyH("CENTER")
        playerFrame.timerText2:SetTextColor(1, 0, 0)
    else
        UpdateTimerDisplay2(countdownDuration)
    end
end

local function StartCountdownTimer2()
    if countdownTimer2 then
        countdownTimer2:Cancel()
    end
    countdownTimer2 = C_Timer.NewTicker(1, OnTimerUpdate2, countdownDuration)
    playerFrame.timerText2:SetPoint("TOPRIGHT", playerFrame, "TOPRIGHT", -230, -150)
    playerFrame.timerText2:Show()
    playerFrame.timerText2:SetTextColor(1, 1, 1)
end



local function UpdateTimerDisplayBets(secondsRemaining)
    playerFrame.timerTextBets:SetText("Place your bets!\nTimer: " .. secondsRemaining .. " s remaining")
end

local function OnTimerUpdateBets()
    countdownDuration = countdownDuration - 1

    if countdownDuration <= 0 then
        confirmBetButtonMain1:Disable()
        confirmBetButtonPP1:Disable()
        confirmBetButton2131:Disable()
        confirmBetButtonMain2:Disable()
        confirmBetButtonPP2:Disable()
        confirmBetButton2132:Disable()
        confirmBetButtonMain3:Disable()
        confirmBetButtonPP3:Disable()
        confirmBetButton2133:Disable()
        confirmBetButtonMain4:Disable()
        confirmBetButtonPP4:Disable()
        confirmBetButton2134:Disable()
        confirmBetButtonMain5:Disable()
        confirmBetButtonPP5:Disable()
        confirmBetButton2135:Disable()
        countdownTimerBets:Cancel()
        playerFrame.timerTextBets:SetText("No more bets!")
        playerFrame.timerTextBets:SetJustifyH("CENTER")
        playerFrame.timerTextBets:SetTextColor(1, 1, 0)
    else
        UpdateTimerDisplayBets(countdownDuration)
    end
end

local function StartCountdownTimerBets()
    if countdownTimerBets then
        countdownTimerBets:Cancel()
    end
    countdownTimerBets = C_Timer.NewTicker(1, OnTimerUpdateBets, countdownDuration)
    playerFrame.timerTextBets:SetPoint("TOPRIGHT", playerFrame, "TOPRIGHT", -230, -150)
    playerFrame.timerTextBets:Show()
    playerFrame.timerTextBets:SetTextColor(1, 1, 1)
end





local function playerTurn1()
    playerFrame.hitButton1:Enable()
    playerFrame.standButton1:Enable()
    if double1Flag == false then
        playerFrame.doubleButton1:Enable()
    else
        playerFrame.doubleButton1:Disable()
    end
end

local function playerTurn2()
    playerFrame.hitButton2:Enable()
    playerFrame.standButton2:Enable()
    if double2Flag == false then
        playerFrame.doubleButton2:Enable()
    else
        playerFrame.doubleButton2:Disable()
    end
end

local function playerTurn3()
    playerFrame.hitButton3:Enable()
    playerFrame.standButton3:Enable()
    playerFrame.doubleButton3:Enable()
end

local function playerTurn4()
    playerFrame.hitButton4:Enable()
    playerFrame.standButton4:Enable()
    playerFrame.doubleButton4:Enable()
end

local function playerTurn5()
    playerFrame.hitButton5:Enable()
    playerFrame.standButton5:Enable()
    playerFrame.doubleButton5:Enable()
end











-- Function to add a drawn card to the player's cards and display it
local function P12345(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 296, 428)       -- Player 1: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 165, 337)       -- Player 2: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 300)         -- Player 3: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -160, 337)      -- Player 4: 1
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -285, 429)      -- Player 5: 1
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 286, 438)       -- Player 1: 2
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 155, 347)       -- Player 2: 2
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 315)         -- Player 3: 2
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -150, 347)      -- Player 4: 2
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -275, 439)      -- Player 5: 2
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: 3
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 266, 458)       -- Player 1: 4
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 256, 468)       -- Player 1: 5
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 246, 478)       -- Player 1: 6
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 236, 488)       -- Player 1: 7
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: Double
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: 3
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 135, 367)       -- Player 2: 4
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 125, 377)       -- Player 2: 5
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 115, 387)       -- Player 2: 6
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 105, 397)       -- Player 2: 7
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: Double
        elseif turn == 23 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: 3
        elseif turn == 24 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 345)         -- Player 3: 4
        elseif turn == 25 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 360)         -- Player 3: 5
        elseif turn == 26 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 375)         -- Player 3: 6
        elseif turn == 27 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 390)         -- Player 3: 7
        elseif turn == 28 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: Double
        elseif turn == 29 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: 3
        elseif turn == 30 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -130, 367)      -- Player 4: 4
        elseif turn == 31 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -120, 377)      -- Player 4: 5
        elseif turn == 32 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -110, 387)      -- Player 4: 6
        elseif turn == 33 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -100, 397)      -- Player 4: 7
        elseif turn == 34 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: Double
        elseif turn == 35 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: 3
        elseif turn == 36 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -255, 459)      -- Player 5: 4
        elseif turn == 37 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -245, 469)      -- Player 5: 5
        elseif turn == 38 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -235, 479)      -- Player 5: 6
        elseif turn == 39 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -225, 489)      -- Player 5: 7
        elseif turn == 40 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: Double
        elseif turn == 41 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 42 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 43 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 44 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 45 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 46 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end


        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P2345(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 165, 337)       -- Player 2: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 300)         -- Player 3: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -160, 337)      -- Player 4: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -285, 429)      -- Player 5: 1
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 155, 347)       -- Player 2: 2
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 315)         -- Player 3: 2
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -150, 347)      -- Player 4: 2
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -275, 439)      -- Player 5: 2
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: 3
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 135, 367)       -- Player 2: 4
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 125, 377)       -- Player 2: 5
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 115, 387)       -- Player 2: 6
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 105, 397)       -- Player 2: 7
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: Double
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: 3
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 345)         -- Player 3: 4
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 360)         -- Player 3: 5
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 375)         -- Player 3: 6
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 390)         -- Player 3: 7
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: Double
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: 3
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -130, 367)      -- Player 4: 4
        elseif turn == 23 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -120, 377)      -- Player 4: 5
        elseif turn == 24 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -110, 387)      -- Player 4: 6
        elseif turn == 25 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -100, 397)      -- Player 4: 7
        elseif turn == 26 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: Double
        elseif turn == 27 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: 3
        elseif turn == 28 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -255, 459)      -- Player 5: 4
        elseif turn == 29 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -245, 469)      -- Player 5: 5
        elseif turn == 30 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -235, 479)      -- Player 5: 6
        elseif turn == 31 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -225, 489)      -- Player 5: 7
        elseif turn == 32 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: Double
        elseif turn == 33 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 34 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 35 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 36 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 37 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 38 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end


        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P1345(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 296, 428)       -- Player 1: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 300)         -- Player 3: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -160, 337)      -- Player 4: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -285, 429)      -- Player 5: 1
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 286, 438)       -- Player 1: 2
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 315)         -- Player 3: 2
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -150, 347)      -- Player 4: 2
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -275, 439)      -- Player 5: 2
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: 3
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 266, 458)       -- Player 1: 4
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 256, 468)       -- Player 1: 5
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 246, 478)       -- Player 1: 6
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 236, 488)       -- Player 1: 7
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: Double
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: 3
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 345)         -- Player 3: 4
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 360)         -- Player 3: 5
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 375)         -- Player 3: 6
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 390)         -- Player 3: 7
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: Double
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: 3
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -130, 367)      -- Player 4: 4
        elseif turn == 23 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -120, 377)      -- Player 4: 5
        elseif turn == 24 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -110, 387)      -- Player 4: 6
        elseif turn == 25 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -100, 397)      -- Player 4: 7
        elseif turn == 26 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: Double
        elseif turn == 27 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: 3
        elseif turn == 28 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -255, 459)      -- Player 5: 4
        elseif turn == 29 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -245, 469)      -- Player 5: 5
        elseif turn == 30 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -235, 479)      -- Player 5: 6
        elseif turn == 31 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -225, 489)      -- Player 5: 7
        elseif turn == 32 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: Double
        elseif turn == 33 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 34 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 35 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 36 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 37 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 38 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end


        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P1245(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 296, 428)       -- Player 1: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 165, 337)       -- Player 2: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -160, 337)      -- Player 4: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -285, 429)      -- Player 5: 1
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 286, 438)       -- Player 1: 2
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 155, 347)       -- Player 2: 2
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -150, 347)      -- Player 4: 2
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -275, 439)      -- Player 5: 2
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: 3
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 266, 458)       -- Player 1: 4
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 256, 468)       -- Player 1: 5
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 246, 478)       -- Player 1: 6
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 236, 488)       -- Player 1: 7
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: Double
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: 3
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 135, 367)       -- Player 2: 4
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 125, 377)       -- Player 2: 5
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 115, 387)       -- Player 2: 6
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 105, 397)       -- Player 2: 7
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: Double
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: 3
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -130, 367)      -- Player 4: 4
        elseif turn == 23 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -120, 377)      -- Player 4: 5
        elseif turn == 24 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -110, 387)      -- Player 4: 6
        elseif turn == 25 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -100, 397)      -- Player 4: 7
        elseif turn == 26 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: Double
        elseif turn == 27 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: 3
        elseif turn == 28 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -255, 459)      -- Player 5: 4
        elseif turn == 29 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -245, 469)      -- Player 5: 5
        elseif turn == 30 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -235, 479)      -- Player 5: 6
        elseif turn == 31 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -225, 489)      -- Player 5: 7
        elseif turn == 32 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: Double
        elseif turn == 33 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 34 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 35 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 36 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 37 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 38 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end


        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P1235(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 296, 428)       -- Player 1: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 165, 337)       -- Player 2: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 300)         -- Player 3: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -285, 429)      -- Player 5: 1
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 286, 438)       -- Player 1: 2
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 155, 347)       -- Player 2: 2
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 315)         -- Player 3: 2
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -275, 439)      -- Player 5: 2
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: 3
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 266, 458)       -- Player 1: 4
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 256, 468)       -- Player 1: 5
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 246, 478)       -- Player 1: 6
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 236, 488)       -- Player 1: 7
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: Double
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: 3
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 135, 367)       -- Player 2: 4
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 125, 377)       -- Player 2: 5
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 115, 387)       -- Player 2: 6
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 105, 397)       -- Player 2: 7
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: Double
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: 3
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 345)         -- Player 3: 4
        elseif turn == 23 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 360)         -- Player 3: 5
        elseif turn == 24 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 375)         -- Player 3: 6
        elseif turn == 25 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 390)         -- Player 3: 7
        elseif turn == 26 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: Double
        elseif turn == 27 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: 3
        elseif turn == 28 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -255, 459)      -- Player 5: 4
        elseif turn == 29 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -245, 469)      -- Player 5: 5
        elseif turn == 30 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -235, 479)      -- Player 5: 6
        elseif turn == 31 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -225, 489)      -- Player 5: 7
        elseif turn == 32 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: Double
        elseif turn == 33 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 34 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 35 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 36 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 37 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 38 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end


        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P1234(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 296, 428)       -- Player 1: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 165, 337)       -- Player 2: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 300)         -- Player 3: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -160, 337)      -- Player 4: 1
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 286, 438)       -- Player 1: 2
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 155, 347)       -- Player 2: 2
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 315)         -- Player 3: 2
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -150, 347)      -- Player 4: 2
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: 3
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 266, 458)       -- Player 1: 4
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 256, 468)       -- Player 1: 5
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 246, 478)       -- Player 1: 6
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 236, 488)       -- Player 1: 7
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: Double
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: 3
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 135, 367)       -- Player 2: 4
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 125, 377)       -- Player 2: 5
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 115, 387)       -- Player 2: 6
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 105, 397)       -- Player 2: 7
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: Double
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: 3
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 345)         -- Player 3: 4
        elseif turn == 23 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 360)         -- Player 3: 5
        elseif turn == 24 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 375)         -- Player 3: 6
        elseif turn == 25 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 390)         -- Player 3: 7
        elseif turn == 26 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: Double
        elseif turn == 27 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: 3
        elseif turn == 28 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -130, 367)      -- Player 4: 4
        elseif turn == 29 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -120, 377)      -- Player 4: 5
        elseif turn == 30 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -110, 387)      -- Player 4: 6
        elseif turn == 31 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -100, 397)      -- Player 4: 7
        elseif turn == 32 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: Double
        elseif turn == 33 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 34 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 35 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 36 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 37 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 38 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end


        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P345(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 300)         -- Player 3: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -160, 337)      -- Player 4: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -285, 429)      -- Player 5: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 315)         -- Player 3: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -150, 347)      -- Player 4: 2
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -275, 439)      -- Player 5: 2
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: 3
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 345)         -- Player 3: 4
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 360)         -- Player 3: 5
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 375)         -- Player 3: 6
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 390)         -- Player 3: 7
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: Double
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: 3
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -130, 367)      -- Player 4: 4
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -120, 377)      -- Player 4: 5
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -110, 387)      -- Player 4: 6
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -100, 397)      -- Player 4: 7
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: Double
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: 3
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -255, 459)      -- Player 5: 4
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -245, 469)      -- Player 5: 5
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -235, 479)      -- Player 5: 6
        elseif turn == 23 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -225, 489)      -- Player 5: 7
        elseif turn == 24 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: Double
        elseif turn == 25 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 26 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 27 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 28 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 29 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 30 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P245(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 165, 337)       -- Player 2: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -160, 337)      -- Player 4: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -285, 429)      -- Player 5: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 155, 347)       -- Player 2: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -150, 347)      -- Player 4: 2
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -275, 439)      -- Player 5: 2
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: 3
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 135, 367)       -- Player 2: 4
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 125, 377)       -- Player 2: 5
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 115, 387)       -- Player 2: 6
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 105, 397)       -- Player 2: 7
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: Double
        elseif turn == 29 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: 3
        elseif turn == 30 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -130, 367)      -- Player 4: 4
        elseif turn == 31 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -120, 377)      -- Player 4: 5
        elseif turn == 32 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -110, 387)      -- Player 4: 6
        elseif turn == 33 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -100, 397)      -- Player 4: 7
        elseif turn == 34 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: Double
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: 3
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -255, 459)      -- Player 5: 4
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -245, 469)      -- Player 5: 5
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -235, 479)      -- Player 5: 6
        elseif turn == 23 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -225, 489)      -- Player 5: 7
        elseif turn == 24 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: Double
        elseif turn == 25 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 26 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 27 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 28 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 29 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 30 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P235(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 165, 337)       -- Player 2: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 300)         -- Player 3: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -285, 429)      -- Player 5: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 155, 347)       -- Player 2: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 315)         -- Player 3: 2
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -275, 439)      -- Player 5: 2
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: 3
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 135, 367)       -- Player 2: 4
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 125, 377)       -- Player 2: 5
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 115, 387)       -- Player 2: 6
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 105, 397)       -- Player 2: 7
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: Double
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: 3
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 345)         -- Player 3: 4
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 360)         -- Player 3: 5
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 375)         -- Player 3: 6
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 390)         -- Player 3: 7
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: Double
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: 3
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -255, 459)      -- Player 5: 4
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -245, 469)      -- Player 5: 5
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -235, 479)      -- Player 5: 6
        elseif turn == 23 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -225, 489)      -- Player 5: 7
        elseif turn == 24 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: Double
        elseif turn == 25 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 26 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 27 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 28 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 29 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 30 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P234(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 165, 337)       -- Player 2: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 300)         -- Player 3: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -160, 337)      -- Player 4: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 155, 347)       -- Player 2: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 315)         -- Player 3: 2
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -150, 347)      -- Player 4: 2
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: 3
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 135, 367)       -- Player 2: 4
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 125, 377)       -- Player 2: 5
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 115, 387)       -- Player 2: 6
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 105, 397)       -- Player 2: 7
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: Double
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: 3
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 345)         -- Player 3: 4
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 360)         -- Player 3: 5
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 375)         -- Player 3: 6
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 390)         -- Player 3: 7
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: Double
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: 3
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -130, 367)      -- Player 4: 4
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -120, 377)      -- Player 4: 5
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -110, 387)      -- Player 4: 6
        elseif turn == 23 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -100, 397)      -- Player 4: 7
        elseif turn == 24 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: Double
        elseif turn == 25 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 26 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 27 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 28 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 29 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 30 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P145(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 296, 428)       -- Player 1: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -160, 337)      -- Player 4: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -285, 429)      -- Player 5: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 286, 438)       -- Player 1: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -150, 347)      -- Player 4: 2
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -275, 439)      -- Player 5: 2
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: 3
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 266, 458)       -- Player 1: 4
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 256, 468)       -- Player 1: 5
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 246, 478)       -- Player 1: 6
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 236, 488)       -- Player 1: 7
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: Double
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: 3
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -130, 367)      -- Player 4: 4
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -120, 377)      -- Player 4: 5
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -110, 387)      -- Player 4: 6
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -100, 397)      -- Player 4: 7
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: Double
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: 3
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -255, 459)      -- Player 5: 4
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -245, 469)      -- Player 5: 5
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -235, 479)      -- Player 5: 6
        elseif turn == 23 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -225, 489)      -- Player 5: 7
        elseif turn == 24 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: Double
        elseif turn == 25 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 26 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 27 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 28 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 29 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 30 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P135(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 296, 428)       -- Player 1: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 300)         -- Player 3: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -285, 429)      -- Player 5: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 286, 438)       -- Player 1: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 315)         -- Player 3: 2
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -275, 439)      -- Player 5: 2
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: 3
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 266, 458)       -- Player 1: 4
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 256, 468)       -- Player 1: 5
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 246, 478)       -- Player 1: 6
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 236, 488)       -- Player 1: 7
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: Double
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: 3
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 345)         -- Player 3: 4
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 360)         -- Player 3: 5
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 375)         -- Player 3: 6
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 390)         -- Player 3: 7
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: Double
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: 3
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -255, 459)      -- Player 5: 4
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -245, 469)      -- Player 5: 5
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -235, 479)      -- Player 5: 6
        elseif turn == 23 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -225, 489)      -- Player 5: 7
        elseif turn == 24 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: Double
        elseif turn == 25 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 26 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 27 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 28 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 29 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 30 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P134(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 296, 428)       -- Player 1: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 300)         -- Player 3: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -160, 337)      -- Player 4: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 286, 438)       -- Player 1: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 315)         -- Player 3: 2
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -150, 347)      -- Player 4: 2
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: 3
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 266, 458)       -- Player 1: 4
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 256, 468)       -- Player 1: 5
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 246, 478)       -- Player 1: 6
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 236, 488)       -- Player 1: 7
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: Double
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: 3
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 345)         -- Player 3: 4
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 360)         -- Player 3: 5
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 375)         -- Player 3: 6
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 390)         -- Player 3: 7
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: Double
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: 3
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -130, 367)      -- Player 4: 4
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -120, 377)      -- Player 4: 5
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -110, 387)      -- Player 4: 6
        elseif turn == 23 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -100, 397)      -- Player 4: 7
        elseif turn == 24 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: Double
        elseif turn == 25 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 26 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 27 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 28 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 29 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 30 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P125(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 296, 428)       -- Player 1: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 165, 337)       -- Player 2: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -285, 429)      -- Player 5: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 286, 438)       -- Player 1: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 155, 347)       -- Player 2: 2
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -275, 439)      -- Player 5: 2
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: 3
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 266, 458)       -- Player 1: 4
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 256, 468)       -- Player 1: 5
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 246, 478)       -- Player 1: 6
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 236, 488)       -- Player 1: 7
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: Double
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: 3
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 135, 367)       -- Player 2: 4
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 125, 377)       -- Player 2: 5
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 115, 387)       -- Player 2: 6
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 105, 397)       -- Player 2: 7
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: Double
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: 3
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -255, 459)      -- Player 5: 4
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -245, 469)      -- Player 5: 5
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -235, 479)      -- Player 5: 6
        elseif turn == 23 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -225, 489)      -- Player 5: 7
        elseif turn == 24 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: Double
        elseif turn == 25 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 26 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 27 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 28 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 29 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 30 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P124(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 296, 428)       -- Player 1: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 165, 337)       -- Player 2: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -160, 337)      -- Player 4: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 286, 438)       -- Player 1: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 155, 347)       -- Player 2: 2
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -150, 347)      -- Player 4: 2
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: 3
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 266, 458)       -- Player 1: 4
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 256, 468)       -- Player 1: 5
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 246, 478)       -- Player 1: 6
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 236, 488)       -- Player 1: 7
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: Double
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: 3
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 135, 367)       -- Player 2: 4
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 125, 377)       -- Player 2: 5
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 115, 387)       -- Player 2: 6
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 105, 397)       -- Player 2: 7
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: Double
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: 3
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -130, 367)      -- Player 4: 4
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -120, 377)      -- Player 4: 5
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -110, 387)      -- Player 4: 6
        elseif turn == 23 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -100, 397)      -- Player 4: 7
        elseif turn == 24 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: Double
        elseif turn == 25 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 26 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 27 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 28 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 29 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 30 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P123(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 296, 428)       -- Player 1: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 165, 337)       -- Player 2: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 300)         -- Player 3: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 286, 438)       -- Player 1: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 155, 347)       -- Player 2: 2
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 315)         -- Player 3: 2
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: 3
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 266, 458)       -- Player 1: 4
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 256, 468)       -- Player 1: 5
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 246, 478)       -- Player 1: 6
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 236, 488)       -- Player 1: 7
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: Double
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: 3
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 135, 367)       -- Player 2: 4
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 125, 377)       -- Player 2: 5
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 115, 387)       -- Player 2: 6
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 105, 397)       -- Player 2: 7
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: Double
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: 3
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 345)         -- Player 3: 4
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 360)         -- Player 3: 5
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 375)         -- Player 3: 6
        elseif turn == 23 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 390)         -- Player 3: 7
        elseif turn == 24 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: Double
        elseif turn == 25 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 26 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 27 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 28 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 29 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 30 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P45(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, -160, 337)      -- Player 4: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -285, 429)      -- Player 5: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -150, 347)      -- Player 4: 2
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -275, 439)      -- Player 5: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: 3
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -130, 367)      -- Player 4: 4
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -120, 377)      -- Player 4: 5
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -110, 387)      -- Player 4: 6
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -100, 397)      -- Player 4: 7
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: Double
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: 3
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -255, 459)      -- Player 5: 4
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -245, 469)      -- Player 5: 5
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -235, 479)      -- Player 5: 6
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -225, 489)      -- Player 5: 7
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: Double
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P35(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 300)         -- Player 3: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -285, 429)      -- Player 5: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 315)         -- Player 3: 2
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -275, 439)      -- Player 5: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: 3
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 345)         -- Player 3: 4
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 360)         -- Player 3: 5
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 375)         -- Player 3: 6
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 390)         -- Player 3: 7
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: Double
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: 3
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -255, 459)      -- Player 5: 4
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -245, 469)      -- Player 5: 5
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -235, 479)      -- Player 5: 6
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -225, 489)      -- Player 5: 7
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: Double
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P34(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 300)         -- Player 3: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -160, 337)      -- Player 4: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 315)         -- Player 3: 2
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -150, 347)      -- Player 4: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: 3
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 345)         -- Player 3: 4
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 360)         -- Player 3: 5
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 375)         -- Player 3: 6
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 390)         -- Player 3: 7
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: Double
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: 3
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -130, 367)      -- Player 4: 4
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -120, 377)      -- Player 4: 5
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -110, 387)      -- Player 4: 6
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -100, 397)      -- Player 4: 7
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: Double
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P25(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 165, 337)       -- Player 2: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -285, 429)      -- Player 5: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 155, 347)       -- Player 2: 2
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -275, 439)      -- Player 5: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: 3
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 135, 367)       -- Player 2: 4
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 125, 377)       -- Player 2: 5
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 115, 387)       -- Player 2: 6
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 105, 397)       -- Player 2: 7
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: Double
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: 3
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -255, 459)      -- Player 5: 4
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -245, 469)      -- Player 5: 5
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -235, 479)      -- Player 5: 6
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -225, 489)      -- Player 5: 7
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: Double
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P24(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 165, 337)       -- Player 2: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -160, 337)      -- Player 4: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 155, 347)       -- Player 2: 2
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -150, 347)      -- Player 4: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: 3
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 135, 367)       -- Player 2: 4
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 125, 377)       -- Player 2: 5
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 115, 387)       -- Player 2: 6
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 105, 397)       -- Player 2: 7
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: Double
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: 3
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -130, 367)      -- Player 4: 4
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -120, 377)      -- Player 4: 5
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -110, 387)      -- Player 4: 6
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -100, 397)      -- Player 4: 7
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: Double
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P23(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 165, 337)       -- Player 2: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 300)         -- Player 3: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 155, 347)       -- Player 2: 2
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 315)         -- Player 3: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: 3
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 135, 367)       -- Player 2: 4
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 125, 377)       -- Player 2: 5
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 115, 387)       -- Player 2: 6
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 105, 397)       -- Player 2: 7
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: Double
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: 3
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 345)         -- Player 3: 4
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 360)         -- Player 3: 5
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 375)         -- Player 3: 6
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 390)         -- Player 3: 7
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: Double
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P15(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 296, 428)       -- Player 1: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -285, 429)      -- Player 5: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 286, 438)       -- Player 1: 2
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -275, 439)      -- Player 5: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: 3
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 266, 458)       -- Player 1: 4
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 256, 468)       -- Player 1: 5
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 246, 478)       -- Player 1: 6
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 236, 488)       -- Player 1: 7
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: Double
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: 3
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -255, 459)      -- Player 5: 4
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -245, 469)      -- Player 5: 5
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -235, 479)      -- Player 5: 6
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -225, 489)      -- Player 5: 7
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: Double
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P14(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 296, 428)       -- Player 1: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -160, 337)      -- Player 4: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 286, 438)       -- Player 1: 2
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -150, 347)      -- Player 4: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: 3
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 266, 458)       -- Player 1: 4
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 256, 468)       -- Player 1: 5
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 246, 478)       -- Player 1: 6
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 236, 488)       -- Player 1: 7
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: Double
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: 3
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -130, 367)      -- Player 4: 4
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -120, 377)      -- Player 4: 5
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -110, 387)      -- Player 4: 6
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -100, 397)      -- Player 4: 7
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: Double
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P13(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 296, 428)       -- Player 1: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 300)         -- Player 3: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 286, 438)       -- Player 1: 2
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 315)         -- Player 3: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: 3
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 266, 458)       -- Player 1: 4
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 256, 468)       -- Player 1: 5
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 246, 478)       -- Player 1: 6
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 236, 488)       -- Player 1: 7
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: Double
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: 3
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 345)         -- Player 3: 4
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 360)         -- Player 3: 5
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 375)         -- Player 3: 6
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 390)         -- Player 3: 7
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: Double
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P12(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 296, 428)       -- Player 1: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 165, 337)       -- Player 2: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 286, 438)       -- Player 1: 2
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 155, 347)       -- Player 2: 2
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: 3
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 266, 458)       -- Player 1: 4
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 256, 468)       -- Player 1: 5
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 246, 478)       -- Player 1: 6
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 236, 488)       -- Player 1: 7
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: Double
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: 3
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 135, 367)       -- Player 2: 4
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 125, 377)       -- Player 2: 5
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 115, 387)       -- Player 2: 6
        elseif turn == 15 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 105, 397)       -- Player 2: 7
        elseif turn == 16 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: Double
        elseif turn == 17 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 18 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 19 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 20 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 21 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 22 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P5(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, -285, 429)      -- Player 5: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -275, 439)      -- Player 5: 2
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: 3
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -255, 459)      -- Player 5: 4
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -245, 469)      -- Player 5: 5
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -235, 479)      -- Player 5: 6
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -225, 489)      -- Player 5: 7
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -265, 449)      -- Player 5: Double
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P4(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, -160, 337)      -- Player 4: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -150, 347)      -- Player 4: 2
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: 3
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -130, 367)      -- Player 4: 4
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -120, 377)      -- Player 4: 5
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -110, 387)      -- Player 4: 6
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -100, 397)      -- Player 4: 7
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, -140, 357)      -- Player 4: Double
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P3(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 300)         -- Player 3: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 315)         -- Player 3: 2
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: 3
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 345)         -- Player 3: 4
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 360)         -- Player 3: 5
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 375)         -- Player 3: 6
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 390)         -- Player 3: 7
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 3, 330)         -- Player 3: Double
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P2(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 165, 337)       -- Player 2: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 155, 347)       -- Player 2: 2
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: 3
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 135, 367)       -- Player 2: 4
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 125, 377)       -- Player 2: 5
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 115, 387)       -- Player 2: 6
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 105, 397)       -- Player 2: 7
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 145, 357)       -- Player 2: Double
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end

-- Function to add a drawn card to the player's cards and display it
local function P1(cardName)
    if cardName and cardNames[cardName] then
        local cardTexture = playerFrame:CreateTexture(nil, "OVERLAY")
        cardTexture:SetSize(32, 64)
        table.insert(drawnCards, cardTexture)  -- Store the texture in the table

        -- Position the card based on the turn count
        if turn == 0 then 
            cardTexture:SetPoint("BOTTOM", playerFrame, 296, 428)       -- Player 1: 1
        elseif turn == 1 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 0, 525)         -- Dealer: 1
        elseif turn == 2 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 286, 438)       -- Player 1: 2
        elseif turn == 3 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: 3
        elseif turn == 4 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 266, 458)       -- Player 1: 4
        elseif turn == 5 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 256, 468)       -- Player 1: 5
        elseif turn == 6 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 246, 478)       -- Player 1: 6
        elseif turn == 7 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 236, 488)       -- Player 1: 7
        elseif turn == 8 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 276, 448)       -- Player 1: Double
        elseif turn == 9 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 12, 525)        -- Dealer: 2
        elseif turn == 10 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 24, 525)        -- Dealer: 3
        elseif turn == 11 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 36, 525)        -- Dealer: 4
        elseif turn == 12 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 48, 525)        -- Dealer: 5
        elseif turn == 13 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 60, 525)        -- Dealer: 6
        elseif turn == 14 then
            cardTexture:SetPoint("BOTTOM", playerFrame, 72, 525)        -- Dealer: 7
        end

        cardTexture:SetTexture("Interface\\AddOns\\BJPlayer_v1.1\\Images\\" .. cardName)
        cardTexture:SetDrawLayer("OVERLAY")

        -- Increment the turn counter
        turn = turn + 1
    end
end


local function Player1Card1(message)
    number = string.find(message, "(%d+)")
    if string.find(message, "1 or 11") then
        playerFrame.numberPlayer1Text:SetText("1 or 11")
        PlaySoundFile(soundFilePaths[22])
    elseif number >= 2 and number <= 10 then
        playerFrame.numberPlayer1Text:SetText(number)
        PlaySoundFile(soundFilePaths[number])
    end
end


local function Player1Card2to8(message)
    local soundIndex = Player1Total + number
    if soundIndex >= 2 and soundIndex <= 21 then
        PlaySoundFile(soundFilePaths[soundIndex])
    elseif soundIndex >= 22 then
        PlaySoundFile(soundFilePaths[35])
        playerFrame.numberPlayer1Text:SetText(soundIndex)
        playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0)
    end
end


local function Player2Card1(message)
    if string.find(message, "1 or 11") then
        playerFrame.numberPlayer2Text:SetText("1 or 11")
        PlaySoundFile(soundFilePaths[22])
    elseif number >= 2 and number <= 10 then
        playerFrame.numberPlayer2Text:SetText(number)
        PlaySoundFile(soundFilePaths[number])
    end
end

local function Player2Card2to8(message)
    local soundIndex = Player2Total + number
    if string.find(message, unitName2) and string.find(message, "has Blackjack") then
        PlaySoundFile(soundFilePaths[53])
        playerFrame.numberPlayer2Text:SetText("Blackjack")
        playerFrame.numberPlayer2Text:SetTextColor(1, 1, 0)
    elseif soundIndex >= 2 and soundIndex <= 21 then
        PlaySoundFile(soundFilePaths[soundIndex])
    elseif soundIndex >= 22 then
        PlaySoundFile(soundFilePaths[35])
        playerFrame.numberPlayer2Text:SetText(soundIndex)
        playerFrame.numberPlayer2Text:SetTextColor(1, 0, 0)
    end
end

local Player1Total = 0
local Player2Total = 0
local DealerTotal = 0

local function PlayTurnSound(total, isPlayer, soundFilePaths)
    local soundIndex

    if total >= 2 and total <= 20 then
        soundIndex = total + 1
    elseif total >= 21 then
        soundIndex = 20
    else
        return
    end

    local soundFile = isPlayer and soundFilePaths[soundIndex] or soundFilePaths[20 - soundIndex]
    PlaySoundFile(soundFile)
end

local function SetPlayerTextAndHandleSpecialCases(total, isPlayer, playerFrame, soundFilePaths)
    local unitName = isPlayer and unitName1 or "Dealer"

    if total >= 22 then
        playerFrame.numberPlayer1Text:SetText(tostring(total))
        playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0) -- RGB values for red
        PlaySoundFile(soundFilePaths[35])
    end
end

local function SetPlayer2TextAndHandleSpecialCases(total, isPlayer, playerFrame, soundFilePaths)
    local unitName = isPlayer and unitName1 or "Dealer"

    if total >= 22 then
        playerFrame.numberPlayer2Text:SetText(tostring(total))
        playerFrame.numberPlayer2Text:SetTextColor(1, 0, 0) -- RGB values for red
        PlaySoundFile(soundFilePaths[35])
    end
end




-- Function to handle incoming chat messages
local function HandleCardsP1(message)
    -- Check if the message contains card names
    for cardName, cardFullName in pairs(cardNames) do
        playerFrame.numberPlayer1Text:Show()
        playerFrame.numberDealerText:Show()
        if string.find(message, cardFullName) then
            P1(cardName)
        end
    end

    local _, _, number = string.find(message, "(%d+)")

        -- Players: 1
        if Player1Active and not Player2Active and not Player3Active and not Player4Active and not Player5Active then
            if string.find(message, unitName1) and string.find(message, "1 or 11") and turn == 1 then -- Player: Ace
                playerFrame.numberPlayer1Text:SetText("1 or 11")
                PlaySoundFile(soundFilePaths[22])
            elseif string.find(message, unitName1) and string.find(message, "2 or 12") then -- Player: Ace + Ace
                playerFrame.numberPlayer1Text:SetText("2 or 12")
                PlaySoundFile(soundFilePaths[23])
            elseif string.find(message, unitName1) and string.find(message, "3 or 13") then -- Player: Ace + 2   or   2 + Ace
                playerFrame.numberPlayer1Text:SetText("3 or 13")
                PlaySoundFile(soundFilePaths[24])
            elseif string.find(message, unitName1) and string.find(message, "4 or 14") then -- Player: Ace + 3   or   3 + Ace
                playerFrame.numberPlayer1Text:SetText("4 or 14")
                PlaySoundFile(soundFilePaths[25])
            elseif string.find(message, unitName1) and string.find(message, "5 or 15") then -- Player: Ace + 4   or   4 + Ace
                playerFrame.numberPlayer1Text:SetText("5 or 15")
                PlaySoundFile(soundFilePaths[26])
            elseif string.find(message, unitName1) and string.find(message, "6 or 16") then -- Player: Ace + 5   or   5 + Ace
                playerFrame.numberPlayer1Text:SetText("6 or 16")
                PlaySoundFile(soundFilePaths[27])
            elseif string.find(message, unitName1) and string.find(message, "7 or 17") then -- Player: Ace + 6   or   6 + Ace
                playerFrame.numberPlayer1Text:SetText("7 or 17")
                PlaySoundFile(soundFilePaths[28])
            elseif string.find(message, unitName1) and string.find(message, "8 or 18") then -- Player: Ace + 7   or   7 + Ace
                playerFrame.numberPlayer1Text:SetText("8 or 18")
                PlaySoundFile(soundFilePaths[29])
            elseif string.find(message, unitName1) and string.find(message, "9 or 19") then -- Player: Ace + 8   or   8 + Ace
                playerFrame.numberPlayer1Text:SetText("9 or 19")
                PlaySoundFile(soundFilePaths[30])
            elseif string.find(message, unitName1) and string.find(message, "10 or 20") then -- Player: Ace + 9   or   9 + Ace
                playerFrame.numberPlayer1Text:SetText("10 or 20")
                PlaySoundFile(soundFilePaths[31])
            elseif string.find(message, unitName1) and string.find(message, "21") then -- Player: 21
                playerFrame.numberPlayer1Text:SetText("21")
                PlaySoundFile(soundFilePaths[21])
            elseif number and tonumber(number) >= 2 and tonumber(number) <= 20 and string.find(message, unitName1) then -- Player Total: 2 to 21
                playerFrame.numberPlayer1Text:SetText(Player1Total + number)
                if string.find(message,"received the") and turn == 1 then
                    if Player1Total + number == 2 then
                        PlaySoundFile(soundFilePaths[2])
                    elseif Player1Total + number == 3 then
                        PlaySoundFile(soundFilePaths[3])
                    elseif Player1Total + number == 4 then
                        PlaySoundFile(soundFilePaths[4])
                    elseif Player1Total + number == 5 then
                        PlaySoundFile(soundFilePaths[5])
                    elseif Player1Total + number == 6 then
                        PlaySoundFile(soundFilePaths[6])
                    elseif Player1Total + number == 7 then
                        PlaySoundFile(soundFilePaths[7])
                    elseif Player1Total + number == 8 then
                        PlaySoundFile(soundFilePaths[8])
                    elseif Player1Total + number == 9 then
                        PlaySoundFile(soundFilePaths[9])
                    elseif Player1Total + number == 10 then
                        PlaySoundFile(soundFilePaths[10])
                    else
                    end
                elseif string.find(message, unitName1) and string.find(message, "has") and turn == 3 then
                    if Player1Total + number == 2 then
                        PlaySoundFile(soundFilePaths[2])
                    elseif Player1Total + number == 3 then
                        PlaySoundFile(soundFilePaths[3])
                    elseif Player1Total + number == 4 then
                        PlaySoundFile(soundFilePaths[4])
                    elseif Player1Total + number == 5 then
                        PlaySoundFile(soundFilePaths[5])
                    elseif Player1Total + number == 6 then
                        PlaySoundFile(soundFilePaths[6])
                    elseif Player1Total + number == 7 then
                        PlaySoundFile(soundFilePaths[7])
                    elseif Player1Total + number == 8 then
                        PlaySoundFile(soundFilePaths[8])
                    elseif Player1Total + number == 9 then
                        PlaySoundFile(soundFilePaths[9])
                    elseif Player1Total + number == 10 then
                        PlaySoundFile(soundFilePaths[10])
                    elseif Player1Total + number == 11 then
                        PlaySoundFile(soundFilePaths[11])
                    elseif Player1Total + number == 12 then
                        PlaySoundFile(soundFilePaths[12])
                    elseif Player1Total + number == 13 then
                        PlaySoundFile(soundFilePaths[13])
                    elseif Player1Total + number == 14 then
                        PlaySoundFile(soundFilePaths[14])
                    elseif Player1Total + number == 15 then
                        PlaySoundFile(soundFilePaths[15])
                    elseif Player1Total + number == 16 then
                        PlaySoundFile(soundFilePaths[16])
                    elseif Player1Total + number == 17 then
                        PlaySoundFile(soundFilePaths[17])
                    elseif Player1Total + number == 18 then
                        PlaySoundFile(soundFilePaths[18])
                    elseif Player1Total + number == 19 then
                        PlaySoundFile(soundFilePaths[19])
                    elseif Player1Total + number == 20 then
                        PlaySoundFile(soundFilePaths[20])
                    else
                    end
                elseif string.find(message, unitName1) and string.find(message, "has") and turn == 4 then
                    if Player1Total + number == 2 then
                        PlaySoundFile(soundFilePaths[2])
                    elseif Player1Total + number == 3 then
                        PlaySoundFile(soundFilePaths[3])
                    elseif Player1Total + number == 4 then
                        PlaySoundFile(soundFilePaths[4])
                    elseif Player1Total + number == 5 then
                        PlaySoundFile(soundFilePaths[5])
                    elseif Player1Total + number == 6 then
                        PlaySoundFile(soundFilePaths[6])
                    elseif Player1Total + number == 7 then
                        PlaySoundFile(soundFilePaths[7])
                    elseif Player1Total + number == 8 then
                        PlaySoundFile(soundFilePaths[8])
                    elseif Player1Total + number == 9 then
                        PlaySoundFile(soundFilePaths[9])
                    elseif Player1Total + number == 10 then
                        PlaySoundFile(soundFilePaths[10])
                    elseif Player1Total + number == 11 then
                        PlaySoundFile(soundFilePaths[11])
                    elseif Player1Total + number == 12 then
                        PlaySoundFile(soundFilePaths[12])
                    elseif Player1Total + number == 13 then
                        PlaySoundFile(soundFilePaths[13])
                    elseif Player1Total + number == 14 then
                        PlaySoundFile(soundFilePaths[14])
                    elseif Player1Total + number == 15 then
                        PlaySoundFile(soundFilePaths[15])
                    elseif Player1Total + number == 16 then
                        PlaySoundFile(soundFilePaths[16])
                    elseif Player1Total + number == 17 then
                        PlaySoundFile(soundFilePaths[17])
                    elseif Player1Total + number == 18 then
                        PlaySoundFile(soundFilePaths[18])
                    elseif Player1Total + number == 19 then
                        PlaySoundFile(soundFilePaths[19])
                    elseif Player1Total + number == 20 then
                        PlaySoundFile(soundFilePaths[20])
                    else
                    end
                elseif string.find(message, unitName1) and string.find(message, "has") and turn == 5 then
                    if Player1Total + number == 2 then
                        PlaySoundFile(soundFilePaths[2])
                    elseif Player1Total + number == 3 then
                        PlaySoundFile(soundFilePaths[3])
                    elseif Player1Total + number == 4 then
                        PlaySoundFile(soundFilePaths[4])
                    elseif Player1Total + number == 5 then
                        PlaySoundFile(soundFilePaths[5])
                    elseif Player1Total + number == 6 then
                        PlaySoundFile(soundFilePaths[6])
                    elseif Player1Total + number == 7 then
                        PlaySoundFile(soundFilePaths[7])
                    elseif Player1Total + number == 8 then
                        PlaySoundFile(soundFilePaths[8])
                    elseif Player1Total + number == 9 then
                        PlaySoundFile(soundFilePaths[9])
                    elseif Player1Total + number == 10 then
                        PlaySoundFile(soundFilePaths[10])
                    elseif Player1Total + number == 11 then
                        PlaySoundFile(soundFilePaths[11])
                    elseif Player1Total + number == 12 then
                        PlaySoundFile(soundFilePaths[12])
                    elseif Player1Total + number == 13 then
                        PlaySoundFile(soundFilePaths[13])
                    elseif Player1Total + number == 14 then
                        PlaySoundFile(soundFilePaths[14])
                    elseif Player1Total + number == 15 then
                        PlaySoundFile(soundFilePaths[15])
                    elseif Player1Total + number == 16 then
                        PlaySoundFile(soundFilePaths[16])
                    elseif Player1Total + number == 17 then
                        PlaySoundFile(soundFilePaths[17])
                    elseif Player1Total + number == 18 then
                        PlaySoundFile(soundFilePaths[18])
                    elseif Player1Total + number == 19 then
                        PlaySoundFile(soundFilePaths[19])
                    elseif Player1Total + number == 20 then
                        PlaySoundFile(soundFilePaths[20])
                    else
                    end
                elseif string.find(message, unitName1) and string.find(message, "has") and turn == 6 then
                    if Player1Total + number == 2 then
                        PlaySoundFile(soundFilePaths[2])
                    elseif Player1Total + number == 3 then
                        PlaySoundFile(soundFilePaths[3])
                    elseif Player1Total + number == 4 then
                        PlaySoundFile(soundFilePaths[4])
                    elseif Player1Total + number == 5 then
                        PlaySoundFile(soundFilePaths[5])
                    elseif Player1Total + number == 6 then
                        PlaySoundFile(soundFilePaths[6])
                    elseif Player1Total + number == 7 then
                        PlaySoundFile(soundFilePaths[7])
                    elseif Player1Total + number == 8 then
                        PlaySoundFile(soundFilePaths[8])
                    elseif Player1Total + number == 9 then
                        PlaySoundFile(soundFilePaths[9])
                    elseif Player1Total + number == 10 then
                        PlaySoundFile(soundFilePaths[10])
                    elseif Player1Total + number == 11 then
                        PlaySoundFile(soundFilePaths[11])
                    elseif Player1Total + number == 12 then
                        PlaySoundFile(soundFilePaths[12])
                    elseif Player1Total + number == 13 then
                        PlaySoundFile(soundFilePaths[13])
                    elseif Player1Total + number == 14 then
                        PlaySoundFile(soundFilePaths[14])
                    elseif Player1Total + number == 15 then
                        PlaySoundFile(soundFilePaths[15])
                    elseif Player1Total + number == 16 then
                        PlaySoundFile(soundFilePaths[16])
                    elseif Player1Total + number == 17 then
                        PlaySoundFile(soundFilePaths[17])
                    elseif Player1Total + number == 18 then
                        PlaySoundFile(soundFilePaths[18])
                    elseif Player1Total + number == 19 then
                        PlaySoundFile(soundFilePaths[19])
                    elseif Player1Total + number == 20 then
                        PlaySoundFile(soundFilePaths[20])
                    else
                    end
                elseif string.find(message, unitName1) and string.find(message, "has") and turn == 7 then
                    if Player1Total + number == 2 then
                        PlaySoundFile(soundFilePaths[2])
                    elseif Player1Total + number == 3 then
                        PlaySoundFile(soundFilePaths[3])
                    elseif Player1Total + number == 4 then
                        PlaySoundFile(soundFilePaths[4])
                    elseif Player1Total + number == 5 then
                        PlaySoundFile(soundFilePaths[5])
                    elseif Player1Total + number == 6 then
                        PlaySoundFile(soundFilePaths[6])
                    elseif Player1Total + number == 7 then
                        PlaySoundFile(soundFilePaths[7])
                    elseif Player1Total + number == 8 then
                        PlaySoundFile(soundFilePaths[8])
                    elseif Player1Total + number == 9 then
                        PlaySoundFile(soundFilePaths[9])
                    elseif Player1Total + number == 10 then
                        PlaySoundFile(soundFilePaths[10])
                    elseif Player1Total + number == 11 then
                        PlaySoundFile(soundFilePaths[11])
                    elseif Player1Total + number == 12 then
                        PlaySoundFile(soundFilePaths[12])
                    elseif Player1Total + number == 13 then
                        PlaySoundFile(soundFilePaths[13])
                    elseif Player1Total + number == 14 then
                        PlaySoundFile(soundFilePaths[14])
                    elseif Player1Total + number == 15 then
                        PlaySoundFile(soundFilePaths[15])
                    elseif Player1Total + number == 16 then
                        PlaySoundFile(soundFilePaths[16])
                    elseif Player1Total + number == 17 then
                        PlaySoundFile(soundFilePaths[17])
                    elseif Player1Total + number == 18 then
                        PlaySoundFile(soundFilePaths[18])
                    elseif Player1Total + number == 19 then
                        PlaySoundFile(soundFilePaths[19])
                    elseif Player1Total + number == 20 then
                        PlaySoundFile(soundFilePaths[20])
                    else
                    end
                elseif string.find(message, unitName1) and string.find(message, "has") and turn == 8 then
                    if Player1Total + number == 2 then
                        PlaySoundFile(soundFilePaths[2])
                    elseif Player1Total + number == 3 then
                        PlaySoundFile(soundFilePaths[3])
                    elseif Player1Total + number == 4 then
                        PlaySoundFile(soundFilePaths[4])
                    elseif Player1Total + number == 5 then
                        PlaySoundFile(soundFilePaths[5])
                    elseif Player1Total + number == 6 then
                        PlaySoundFile(soundFilePaths[6])
                    elseif Player1Total + number == 7 then
                        PlaySoundFile(soundFilePaths[7])
                    elseif Player1Total + number == 8 then
                        PlaySoundFile(soundFilePaths[8])
                    elseif Player1Total + number == 9 then
                        PlaySoundFile(soundFilePaths[9])
                    elseif Player1Total + number == 10 then
                        PlaySoundFile(soundFilePaths[10])
                    elseif Player1Total + number == 11 then
                        PlaySoundFile(soundFilePaths[11])
                    elseif Player1Total + number == 12 then
                        PlaySoundFile(soundFilePaths[12])
                    elseif Player1Total + number == 13 then
                        PlaySoundFile(soundFilePaths[13])
                    elseif Player1Total + number == 14 then
                        PlaySoundFile(soundFilePaths[14])
                    elseif Player1Total + number == 15 then
                        PlaySoundFile(soundFilePaths[15])
                    elseif Player1Total + number == 16 then
                        PlaySoundFile(soundFilePaths[16])
                    elseif Player1Total + number == 17 then
                        PlaySoundFile(soundFilePaths[17])
                    elseif Player1Total + number == 18 then
                        PlaySoundFile(soundFilePaths[18])
                    elseif Player1Total + number == 19 then
                        PlaySoundFile(soundFilePaths[19])
                    elseif Player1Total + number == 20 then
                        PlaySoundFile(soundFilePaths[20])
                    else
                    end
                elseif string.find(message, unitName1) and string.find(message, "has") and turn == 9 then
                    if Player1Total + number == 2 then
                        PlaySoundFile(soundFilePaths[2])
                    elseif Player1Total + number == 3 then
                        PlaySoundFile(soundFilePaths[3])
                    elseif Player1Total + number == 4 then
                        PlaySoundFile(soundFilePaths[4])
                    elseif Player1Total + number == 5 then
                        PlaySoundFile(soundFilePaths[5])
                    elseif Player1Total + number == 6 then
                        PlaySoundFile(soundFilePaths[6])
                    elseif Player1Total + number == 7 then
                        PlaySoundFile(soundFilePaths[7])
                    elseif Player1Total + number == 8 then
                        PlaySoundFile(soundFilePaths[8])
                    elseif Player1Total + number == 9 then
                        PlaySoundFile(soundFilePaths[9])
                    elseif Player1Total + number == 10 then
                        PlaySoundFile(soundFilePaths[10])
                    elseif Player1Total + number == 11 then
                        PlaySoundFile(soundFilePaths[11])
                    elseif Player1Total + number == 12 then
                        PlaySoundFile(soundFilePaths[12])
                    elseif Player1Total + number == 13 then
                        PlaySoundFile(soundFilePaths[13])
                    elseif Player1Total + number == 14 then
                        PlaySoundFile(soundFilePaths[14])
                    elseif Player1Total + number == 15 then
                        PlaySoundFile(soundFilePaths[15])
                    elseif Player1Total + number == 16 then
                        PlaySoundFile(soundFilePaths[16])
                    elseif Player1Total + number == 17 then
                        PlaySoundFile(soundFilePaths[17])
                    elseif Player1Total + number == 18 then
                        PlaySoundFile(soundFilePaths[18])
                    elseif Player1Total + number == 19 then
                        PlaySoundFile(soundFilePaths[19])
                    elseif Player1Total + number == 20 then
                        PlaySoundFile(soundFilePaths[20])
                    else
                    end
                end
            elseif string.find(message, unitName1) and string.find(message, "has 21") then
                playerFrame.numberPlayer1Text:SetText("21")
                PlaySoundFile(soundFilePaths[21])

            elseif string.find(message, unitName1) and string.find(message, "Blackjack") then
                playerFrame.numberPlayer1Text:SetText(BlackjackText)
                playerFrame.numberPlayer1Text:SetTextColor(1, 1, 0) -- RGB values for yellow
                PlaySoundFile(soundFilePaths[32])
                playerFrame.hitButton1:Disable()
                playerFrame.standButton1:Disable()
                playerFrame.doubleButton1:Disable()
                countdownDuration = 30
                playerFrame.timerText1:SetText("")
                playerFrame.timerText1:Hide()
            elseif string.find(message, "22") and string.find(message, unitName1) then -- Player (BUST) Total: 22
                playerFrame.numberPlayer1Text:SetText("22")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[35])
            elseif string.find(message, "23") and string.find(message, unitName1) then -- Player (BUST) Total: 23
                playerFrame.numberPlayer1Text:SetText("23")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[35])
            elseif string.find(message, "24") and string.find(message, unitName1) then -- Player (BUST) Total: 24
                playerFrame.numberPlayer1Text:SetText("24")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[35])
            elseif string.find(message, "25") and string.find(message, unitName1) then -- Player (BUST) Total: 25
                playerFrame.numberPlayer1Text:SetText("25")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[35])
            elseif string.find(message, "26") and string.find(message, unitName1) then -- Player (BUST) Total: 26
                playerFrame.numberPlayer1Text:SetText("26")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[35])
            elseif string.find(message, "27") and string.find(message, unitName1) then -- Player (BUST) Total: 27
                playerFrame.numberPlayer1Text:SetText("27")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[35])
            elseif string.find(message, "28") and string.find(message, unitName1) then -- Player (BUST) Total: 28
                playerFrame.numberPlayer1Text:SetText("28")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[35])
            elseif string.find(message, "29") and string.find(message, unitName1) then -- Player (BUST) Total: 29
                playerFrame.numberPlayer1Text:SetText("29")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[35])
            elseif string.find(message, "30") and string.find(message, unitName1) then -- Player (BUST) Total: 30
                playerFrame.numberPlayer1Text:SetText("30")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[35])
            elseif string.find(message, "Dealer") and string.find(message, "1 or 11") and turn == 2 then -- Dealer: Ace
                playerFrame.numberDealerText:SetText("1 or 11")
                PlaySoundFile(soundFilePaths[22])
            elseif string.find(message, "Dealer") and string.find(message, "2 or 12") then -- Dealer: Ace + Ace
                playerFrame.numberDealerText:SetText("2 or 12")
                PlaySoundFile(soundFilePaths[23])
            elseif string.find(message, "Dealer") and string.find(message, "3 or 13") then -- Dealer: Ace + 2   or   2 + Ace
                playerFrame.numberDealerText:SetText("3 or 13")
                PlaySoundFile(soundFilePaths[24])
            elseif string.find(message, "Dealer") and string.find(message, "4 or 14") then -- Dealer: Ace + 3   or   3 + Ace
                playerFrame.numberDealerText:SetText("4 or 14")
                PlaySoundFile(soundFilePaths[25])
            elseif string.find(message, "Dealer") and string.find(message, "5 or 15") then -- Dealer: Ace + 4   or   4 + Ace
                playerFrame.numberDealerText:SetText("5 or 15")
                PlaySoundFile(soundFilePaths[26])
            elseif string.find(message, "Dealer") and string.find(message, "6 or 16") then -- Dealer: Ace + 5   or   5 + Ace
                playerFrame.numberDealerText:SetText("6 or 16")
                PlaySoundFile(soundFilePaths[27])
            elseif number and tonumber(number) >=2 and tonumber(number) <= 21 and string.find(message, "Dealer") then -- Dealer Total: 2 to 21
                playerFrame.numberDealerText:SetText(DealerTotal + number)
                if string.find(message, "Dealer has 20") then
                    PlaySoundFile(soundFilePaths[20])
                elseif string.find(message, "Dealer has 2") then
                    PlaySoundFile(soundFilePaths[2])
                elseif string.find(message, "Dealer has 3") then
                    PlaySoundFile(soundFilePaths[3])
                elseif string.find(message, "Dealer has 4") then
                    PlaySoundFile(soundFilePaths[4])
                elseif string.find(message, "Dealer has 5") then
                    PlaySoundFile(soundFilePaths[5])
                elseif string.find(message, "Dealer has 6") then
                    PlaySoundFile(soundFilePaths[6])
                elseif string.find(message, "Dealer has 7") then
                    PlaySoundFile(soundFilePaths[7])
                elseif string.find(message, "Dealer has 8") then
                    PlaySoundFile(soundFilePaths[8])
                elseif string.find(message, "Dealer has 9") then
                    PlaySoundFile(soundFilePaths[9])
                elseif string.find(message, "Dealer has 10") then
                    PlaySoundFile(soundFilePaths[10])
                elseif string.find(message, "Dealer has 11") then
                    PlaySoundFile(soundFilePaths[11])
                elseif string.find(message, "Dealer has 12") then
                    PlaySoundFile(soundFilePaths[12])
                elseif string.find(message, "Dealer has 13") then
                    PlaySoundFile(soundFilePaths[13])
                elseif string.find(message, "Dealer has 14") then
                    PlaySoundFile(soundFilePaths[14])
                elseif string.find(message, "Dealer has 15") then
                    PlaySoundFile(soundFilePaths[15])
                elseif string.find(message, "Dealer has 16") then
                    PlaySoundFile(soundFilePaths[16])
                elseif string.find(message, "Dealer has 17") then
                    PlaySoundFile(soundFilePaths[17])
                elseif string.find(message, "Dealer has 18") then
                    PlaySoundFile(soundFilePaths[18])
                elseif string.find(message, "Dealer has 19") then
                    PlaySoundFile(soundFilePaths[19])
                else
                end
            elseif string.find(message, "21") and string.find(message, "Dealer") then
                playerFrame.numberDealerText:SetText("21")
                PlaySoundFile(soundFilePaths[21])
            elseif string.find(message, "Dealer") and string.find(message, "Blackjack") then
                playerFrame.numberDealerText:SetText(BlackjackText)
                playerFrame.numberDealerText:SetTextColor(1, 1, 0) -- RGB values for yellow
                PlaySoundFile(soundFilePaths[36])
            elseif string.find(message, "22") and string.find(message, "Dealer") then -- Dealer (BUST) Total: 22
                playerFrame.numberDealerText:SetText("22")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[37])
            elseif string.find(message, "23") and string.find(message, "Dealer") then -- Dealer (BUST) Total: 23
                playerFrame.numberDealerText:SetText("23")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[37])
            elseif string.find(message, "24") and string.find(message, "Dealer") then -- Dealer (BUST) Total: 24
                playerFrame.numberDealerText:SetText("24")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[37])
            elseif string.find(message, "25") and string.find(message, "Dealer") then -- Dealer (BUST) Total: 25
                playerFrame.numberDealerText:SetText("25")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[37])
            elseif string.find(message, "26") and string.find(message, "Dealer") then -- Dealer (BUST) Total: 26
                playerFrame.numberDealerText:SetText("26")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[37])
            elseif string.find(message, "27") and string.find(message, "Dealer") then -- Dealer (BUST) Total: 27
                playerFrame.numberDealerText:SetText("27")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[37])
            elseif string.find(message, "28") and string.find(message, "Dealer") then -- Dealer (BUST) Total: 28
                playerFrame.numberDealerText:SetText("28")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[37])
            elseif string.find(message, "29") and string.find(message, "Dealer") then -- Dealer (BUST) Total: 29
                playerFrame.numberDealerText:SetText("29")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[37])
            elseif string.find(message, "30") and string.find(message, "Dealer") then -- Dealer (BUST) Total: 30
                playerFrame.numberDealerText:SetText("30")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0) -- RGB values for red
                PlaySoundFile(soundFilePaths[37])
            end
        end
    
end

-- Function to handle incoming chat messages
local function HandleCardsP12(message)

    -- Check if the message contains card names
    for cardName, cardFullName in pairs(cardNames) do
        playerFrame.numberPlayer1Text:Show()
        playerFrame.numberPlayer2Text:Show()
        playerFrame.numberDealerText:Show()
        if string.find(message, cardFullName) then
            P12(cardName)
        end
    end


    local _, _, number = string.find(message, "(%d+)")

        -- Players: 1, 2
        if Player1Active and Player2Active and not Player3Active and not Player4Active and not Player5Active then
    




            -- Player 1: Ace Combos
            if string.find(message, unitName1) and string.find(message, "1 or 11") and turn == 1 then -- Player: Ace
                playerFrame.numberPlayer1Text:SetText("1 or 11")
                PlaySoundFile(soundFilePaths[22])
            elseif string.find(message, unitName1) and string.find(message, "2 or 12") then -- Player: Ace + Ace
                playerFrame.numberPlayer1Text:SetText("2 or 12")
                PlaySoundFile(soundFilePaths[23])
            elseif string.find(message, unitName1) and string.find(message, "3 or 13") then -- Player: Ace + 2   or   2 + Ace
                playerFrame.numberPlayer1Text:SetText("3 or 13")
                PlaySoundFile(soundFilePaths[24])
            elseif string.find(message, unitName1) and string.find(message, "4 or 14") then -- Player: Ace + 3   or   3 + Ace
                playerFrame.numberPlayer1Text:SetText("4 or 14")
                PlaySoundFile(soundFilePaths[25])
            elseif string.find(message, unitName1) and string.find(message, "5 or 15") then -- Player: Ace + 4   or   4 + Ace
                playerFrame.numberPlayer1Text:SetText("5 or 15")
                PlaySoundFile(soundFilePaths[26])
            elseif string.find(message, unitName1) and string.find(message, "6 or 16") then -- Player: Ace + 5   or   5 + Ace
                playerFrame.numberPlayer1Text:SetText("6 or 16")
                PlaySoundFile(soundFilePaths[27])
            elseif string.find(message, unitName1) and string.find(message, "7 or 17") then -- Player: Ace + 6   or   6 + Ace
                playerFrame.numberPlayer1Text:SetText("7 or 17")
                PlaySoundFile(soundFilePaths[28])
            elseif string.find(message, unitName1) and string.find(message, "8 or 18") then -- Player: Ace + 7   or   7 + Ace
                playerFrame.numberPlayer1Text:SetText("8 or 18")
                PlaySoundFile(soundFilePaths[29])
            elseif string.find(message, unitName1) and string.find(message, "9 or 19") then -- Player: Ace + 8   or   8 + Ace
                playerFrame.numberPlayer1Text:SetText("9 or 19")
                PlaySoundFile(soundFilePaths[30])
            elseif string.find(message, unitName1) and string.find(message, "10 or 20") then -- Player: Ace + 9   or   9 + Ace
                playerFrame.numberPlayer1Text:SetText("10 or 20")
                PlaySoundFile(soundFilePaths[31])
            elseif string.find(message, unitName1) and string.find(message, "21") then -- Player: 21
                playerFrame.numberPlayer1Text:SetText("21")
                PlaySoundFile(soundFilePaths[21])

            -- Player 1: 2-21
            elseif number and tonumber(number) >= 2 and tonumber(number) <= 21 and string.find(message, unitName1) then
                playerFrame.numberPlayer1Text:SetText(Player1Total + number)
                if string.find(message,"received the") and turn == 1 then
                    if Player1Total + number >= 2 and Player1Total + number <= 10 then
                        PlaySoundFile(soundFilePaths[Player1Total + number])
                    end
                elseif string.find(message, unitName1) and string.find(message, "has") and turn == 4 or string.find(message, unitName1) and string.find(message, "has") and turn >= 6 and turn <= 10 then
                    if Player1Total + number >= 2 and Player1Total + number <= 21 then
                        PlaySoundFile(soundFilePaths[Player1Total + number])
                    end
                end

            -- Player 1: Blackjack
            elseif string.find(message, unitName1) and string.find(message, "Blackjack") then
                playerFrame.numberPlayer1Text:SetText("Blackjack")
                playerFrame.numberPlayer1Text:SetTextColor(1, 1, 0) -- RGB values for yellow
                PlaySoundFile(soundFilePaths[32])
                playerFrame.hitButton1:Disable()
                playerFrame.standButton1:Disable()
                playerFrame.doubleButton1:Disable()
                countdownDuration = 30
                playerFrame.timerText1:SetText("")
                playerFrame.timerText1:Hide()





            -- Player 2: Ace Combos
            elseif string.find(message, unitName2) and string.find(message, "1 or 11") and turn == 2 then -- Player: Ace
                playerFrame.numberPlayer2Text:SetText("1 or 11")
                PlaySoundFile(soundFilePaths[22])
            elseif string.find(message, unitName2) and string.find(message, "2 or 12") then -- Player: Ace + Ace
                playerFrame.numberPlayer2Text:SetText("2 or 12")
                PlaySoundFile(soundFilePaths[23])
            elseif string.find(message, unitName2) and string.find(message, "3 or 13") then -- Player: Ace + 2   or   2 + Ace
                playerFrame.numberPlayer2Text:SetText("3 or 13")
                PlaySoundFile(soundFilePaths[24])
            elseif string.find(message, unitName2) and string.find(message, "4 or 14") then -- Player: Ace + 3   or   3 + Ace
                playerFrame.numberPlayer2Text:SetText("4 or 14")
                PlaySoundFile(soundFilePaths[25])
            elseif string.find(message, unitName2) and string.find(message, "5 or 15") then -- Player: Ace + 4   or   4 + Ace
                playerFrame.numberPlayer2Text:SetText("5 or 15")
                PlaySoundFile(soundFilePaths[26])
            elseif string.find(message, unitName2) and string.find(message, "6 or 16") then -- Player: Ace + 5   or   5 + Ace
                playerFrame.numberPlayer2Text:SetText("6 or 16")
                PlaySoundFile(soundFilePaths[27])
            elseif string.find(message, unitName2) and string.find(message, "7 or 17") then -- Player: Ace + 6   or   6 + Ace
                playerFrame.numberPlayer2Text:SetText("7 or 17")
                PlaySoundFile(soundFilePaths[28])
            elseif string.find(message, unitName2) and string.find(message, "8 or 18") then -- Player: Ace + 7   or   7 + Ace
                playerFrame.numberPlayer2Text:SetText("8 or 18")
                PlaySoundFile(soundFilePaths[29])
            elseif string.find(message, unitName2) and string.find(message, "9 or 19") then -- Player: Ace + 8   or   8 + Ace
                playerFrame.numberPlayer2Text:SetText("9 or 19")
                PlaySoundFile(soundFilePaths[30])
            elseif string.find(message, unitName2) and string.find(message, "10 or 20") then -- Player: Ace + 9   or   9 + Ace
                playerFrame.numberPlayer2Text:SetText("10 or 20")
                PlaySoundFile(soundFilePaths[31])
            elseif string.find(message, unitName2) and string.find(message, "21") then -- Player: 21
                playerFrame.numberPlayer2Text:SetText("21")
                PlaySoundFile(soundFilePaths[21])

            -- Player 2: 2-21
            elseif number and tonumber(number) >= 2 and tonumber(number) <= 21 and string.find(message, unitName2) then
                playerFrame.numberPlayer2Text:SetText(Player2Total + number)
                if string.find(message,"received the") and turn == 2 then
                    if Player2Total + number == 2 then
                        PlaySoundFile(soundFilePaths[2])
                    elseif Player2Total + number == 3 then
                        PlaySoundFile(soundFilePaths[3])
                    elseif Player2Total + number == 4 then
                        PlaySoundFile(soundFilePaths[4])
                    elseif Player2Total + number == 5 then
                        PlaySoundFile(soundFilePaths[5])
                    elseif Player2Total + number == 6 then
                        PlaySoundFile(soundFilePaths[6])
                    elseif Player2Total + number == 7 then
                        PlaySoundFile(soundFilePaths[7])
                    elseif Player2Total + number == 8 then
                        PlaySoundFile(soundFilePaths[8])
                    elseif Player2Total + number == 9 then
                        PlaySoundFile(soundFilePaths[9])
                    elseif Player2Total + number == 10 then
                        PlaySoundFile(soundFilePaths[10])
                    end
                elseif string.find(message, unitName2) and string.find(message, "has") and turn == 5 or string.find(message, unitName2) and string.find(message, "has") and turn >= 11 and turn <= 15 then
                    if Player2Total + number >= 2 and Player2Total + number <= 21 then
                        PlaySoundFile(soundFilePaths[Player2Total + number])
                    end
                end

            -- Player 2: Blackjack
            elseif string.find(message, unitName2) and string.find(message, "Blackjack") then
                playerFrame.numberPlayer2Text:SetText("Blackjack")
                playerFrame.numberPlayer2Text:SetTextColor(1, 1, 0) -- RGB values for yellow
                PlaySoundFile(soundFilePaths[32])
                playerFrame.hitButton2:Disable()
                playerFrame.standButton2:Disable()
                playerFrame.doubleButton2:Disable()
                countdownDuration = 30
                playerFrame.timerText2:SetText("")
                playerFrame.timerText2:Hide()

           
            -- Dealer: Ace Combos
            elseif string.find(message, "Dealer") and string.find(message, "1 or 11") and turn == 3 then -- Dealer: Ace
                playerFrame.numberDealerText:SetText("1 or 11")
                PlaySoundFile(soundFilePaths[22])
            elseif string.find(message, "Dealer") and string.find(message, "2 or 12") then -- Dealer: Ace + Ace
                playerFrame.numberDealerText:SetText("2 or 12")
                PlaySoundFile(soundFilePaths[23])
            elseif string.find(message, "Dealer") and string.find(message, "3 or 13") then -- Dealer: Ace + 2   or   2 + Ace
                playerFrame.numberDealerText:SetText("3 or 13")
                PlaySoundFile(soundFilePaths[24])
            elseif string.find(message, "Dealer") and string.find(message, "4 or 14") then -- Dealer: Ace + 3   or   3 + Ace
                playerFrame.numberDealerText:SetText("4 or 14")
                PlaySoundFile(soundFilePaths[25])
            elseif string.find(message, "Dealer") and string.find(message, "5 or 15") then -- Dealer: Ace + 4   or   4 + Ace
                playerFrame.numberDealerText:SetText("5 or 15")
                PlaySoundFile(soundFilePaths[26])
            elseif string.find(message, "Dealer") and string.find(message, "6 or 16") then -- Dealer: Ace + 5   or   5 + Ace
                playerFrame.numberDealerText:SetText("6 or 16")
                PlaySoundFile(soundFilePaths[27])

            -- Dealer: 2-21
            elseif number and tonumber(number) >=2 and tonumber(number) <= 20 and string.find(message, "Dealer") then -- Dealer Total: 2 to 21
                playerFrame.numberDealerText:SetText(DealerTotal + number)
                if string.find(message, "Dealer has 20") then
                    PlaySoundFile(soundFilePaths[20])
                elseif string.find(message, "Dealer has 2") then
                    PlaySoundFile(soundFilePaths[2])
                elseif string.find(message, "Dealer has 3") then
                    PlaySoundFile(soundFilePaths[3])
                elseif string.find(message, "Dealer has 4") then
                    PlaySoundFile(soundFilePaths[4])
                elseif string.find(message, "Dealer has 5") then
                    PlaySoundFile(soundFilePaths[5])
                elseif string.find(message, "Dealer has 6") then
                    PlaySoundFile(soundFilePaths[6])
                elseif string.find(message, "Dealer has 7") then
                    PlaySoundFile(soundFilePaths[7])
                elseif string.find(message, "Dealer has 8") then
                    PlaySoundFile(soundFilePaths[8])
                elseif string.find(message, "Dealer has 9") then
                    PlaySoundFile(soundFilePaths[9])
                elseif string.find(message, "Dealer has 10") then
                    PlaySoundFile(soundFilePaths[10])
                elseif string.find(message, "Dealer has 11") then
                    PlaySoundFile(soundFilePaths[11])
                elseif string.find(message, "Dealer has 12") then
                    PlaySoundFile(soundFilePaths[12])
                elseif string.find(message, "Dealer has 13") then
                    PlaySoundFile(soundFilePaths[13])
                elseif string.find(message, "Dealer has 14") then
                    PlaySoundFile(soundFilePaths[14])
                elseif string.find(message, "Dealer has 15") then
                    PlaySoundFile(soundFilePaths[15])
                elseif string.find(message, "Dealer has 16") then
                    PlaySoundFile(soundFilePaths[16])
                elseif string.find(message, "Dealer has 17") then
                    PlaySoundFile(soundFilePaths[17])
                elseif string.find(message, "Dealer has 18") then
                    PlaySoundFile(soundFilePaths[18])
                elseif string.find(message, "Dealer has 19") then
                    PlaySoundFile(soundFilePaths[19])
                else
                end

            -- Dealer: 21
            elseif string.find(message, "21") and string.find(message, "Dealer") then
                playerFrame.numberDealerText:SetText("21")
                PlaySoundFile(soundFilePaths[21])

            -- Dealer: Blackjack
            elseif string.find(message, "Dealer") and string.find(message, "Blackjack") then
                playerFrame.numberDealerText:SetText(BlackjackText)
                playerFrame.numberDealerText:SetTextColor(1, 1, 0) -- RGB values for yellow
                PlaySoundFile(soundFilePaths[36])
            end
            
        end
    
end



















-- Function to handle incoming chat messages
local function HandleChatMessage(message)
    -- Check if the message contains card names
    for cardName, cardFullName in pairs(cardNames) do
        if string.find(message, cardFullName) and Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then
            P12345(cardName)
        elseif string.find(message, cardFullName) and Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then
            P2345(cardName)
        elseif string.find(message, cardFullName) and Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == true then
            P1345(cardName)  
        elseif string.find(message, cardFullName) and Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then
            P1245(cardName) 
        elseif string.find(message, cardFullName) and Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then
            P1235(cardName)
        elseif string.find(message, cardFullName) and Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then
            P1234(cardName)
        elseif string.find(message, cardFullName) and Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == true then
            P345(cardName)
        elseif string.find(message, cardFullName) and Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then
            P245(cardName)
        elseif string.find(message, cardFullName) and Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then
            P235(cardName)
        elseif string.find(message, cardFullName) and Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then
            P234(cardName)
        elseif string.find(message, cardFullName) and Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == true then
            P145(cardName)
        elseif string.find(message, cardFullName) and Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == true then
            P135(cardName)
        elseif string.find(message, cardFullName) and Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == false then
            P134(cardName)
        elseif string.find(message, cardFullName) and Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == true then
            P125(cardName)
        elseif string.find(message, cardFullName) and Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == false then
            P124(cardName)
        elseif string.find(message, cardFullName) and Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == false then
            P123(cardName)
        elseif string.find(message, cardFullName) and Player1Active == false and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == true then
            P45(cardName)
        elseif string.find(message, cardFullName) and Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == true then
            P35(cardName)
        elseif string.find(message, cardFullName) and Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == false then
            P34(cardName)
        elseif string.find(message, cardFullName) and Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == true then
            P25(cardName)
        elseif string.find(message, cardFullName) and Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == false then
            P24(cardName)
        elseif string.find(message, cardFullName) and Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == false then
            P23(cardName)
        elseif string.find(message, cardFullName) and Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == false and Player5Active == true then
            P15(cardName)
        elseif string.find(message, cardFullName) and Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == false then
            P14(cardName)
        elseif string.find(message, cardFullName) and Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == false then
            P13(cardName)
        elseif string.find(message, cardFullName) and Player1Active == false and Player2Active == false and Player3Active == false and Player4Active == false and Player5Active == true then
            P5(cardName)
        elseif string.find(message, cardFullName) and Player1Active == false and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == false then
            P4(cardName)
        elseif string.find(message, cardFullName) and Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == false then
            P3(cardName)
        elseif string.find(message, cardFullName) and Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == false then
            P2(cardName)
        end
        playerFrame.numberPlayer1Text:Show()
        playerFrame.numberPlayer2Text:Show()
        playerFrame.numberPlayer3Text:Show()
        playerFrame.numberPlayer4Text:Show()
        playerFrame.numberPlayer5Text:Show()
        playerFrame.numberDealerText:Show()
    end

    -- Players: 1
    if Player1Active and not Player2Active and not Player3Active and not Player4Active and not Player5Active then
        HandleCardsP1(message)
    -- Players: 1, 2
    elseif Player1Active and Player2Active and not Player3Active and not Player4Active and not Player5Active then
        HandleCardsP12(message)
    end

end







-- Update player names with the names of raid party members 2 - 6
local function updatePlayerNames()
    local playerName = UnitName("player");  -- Get your own player name

    -- Check if the player is in the raid party
    local isInRaidParty = isPlayerInRaidParty(playerName, {unitName1, unitName2, unitName3, unitName4, unitName5})

    -- Sets the POV using visibility functions above
    if isInRaidParty then
        if playerName == unitName1 then
            isPlayer1()
        elseif playerName == unitName2 then
            isPlayer2()
        elseif playerName == unitName3 then
            isPlayer3()
        elseif playerName == unitName4 then
            isPlayer4()
        elseif playerName == unitName5 then
            isPlayer5()
        end
    else
        print("You must reload to claim a seat.")
    end
end

updatePlayerNames();

-- Updates player names when raid roster changes (requires /reload)
local eventFrame = CreateFrame("Frame")
eventFrame:RegisterEvent("RAID_ROSTER_UPDATE")
eventFrame:SetScript("OnEvent", updatePlayerNames)

-- Event register for raid chat messages
local eventFrame = CreateFrame("Frame")
eventFrame:RegisterEvent("CHAT_MSG_RAID")

-- Event handler if it detects raid chat messages
eventFrame:SetScript("OnEvent", function(self, event, message, sender)
    if string.find(message, "%[P1%] Placing") and string.find(message, "main") then
        PlaceBetsMain1()
        Player1Active = true
        local betAmountMain1 = string.match(message, "(%d+)G")
        if betAmountMain1 then
            PlaceBetsTextMain1(betAmountMain1)
        else
        end
    elseif string.find(message, "%[P1%] Placing") and string.find(message, "Perfect") then
        PlaceBetsPP1()
        local betAmountPP1 = string.match(message, "(%d+)G")
        if betAmountPP1 then
            PlaceBetsTextPP1(betAmountPP1)
        else
        end
    elseif string.find(message, "%[P1%] Placing") and string.find(message, "21") then
        PlaceBets2131()
        local betAmount2131 = string.match(message, "(%d+)G")
        if betAmount2131 then
            PlaceBetsText2131(betAmount2131)
        else
        end
    elseif string.find(message, "%[P1%] Hit") then
        playerFrame.timerText1:SetText("")
        playerFrame.timerText1:Hide()
        countdownDuration = 30
        playerFrame.hitButton1:Disable()
        playerFrame.standButton1:Disable()
        playerFrame.doubleButton1:Disable()
        playerFrame.splitButton1:Disable()
    elseif string.find(message, "%[P1%] Stand") then
        playerFrame.timerText1:SetText("")
        playerFrame.timerText1:Hide()
        countdownDuration = 30
        if Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == false and Player5Active == false then       -- Players: 1
            turn = 9
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == false then    -- Players: 1 2
            turn = 11
        elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 1 3
            turn = 11
        elseif Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 1 4
            turn = 11
        elseif Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 1 5
            turn = 11
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 1 2 3
            turn = 13
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 1 2 4
            turn = 13
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 1 2 5
            turn = 13
        elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 1 3 4
            turn = 13
        elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 1 3 5
            turn = 13
        elseif Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 1 4 5
            turn = 13
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 1 2 3 4
            turn = 15
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 1 2 3 5
            turn = 15
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 1 2 4 5
            turn = 15
        elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 3 4 5
            turn = 15
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 2 3 4 5
            turn = 17
        end
        if playerFrame.numberPlayer1Text:GetText() == "1 or 11" then
            playerFrame.numberPlayer1Text:SetText("11")
        elseif playerFrame.numberPlayer1Text:GetText() == "2 or 12" then
            playerFrame.numberPlayer1Text:SetText("12")
        elseif playerFrame.numberPlayer1Text:GetText() == "3 or 13" then
            playerFrame.numberPlayer1Text:SetText("13")
        elseif playerFrame.numberPlayer1Text:GetText() == "4 or 14" then
            playerFrame.numberPlayer1Text:SetText("14")
        elseif playerFrame.numberPlayer1Text:GetText() == "5 or 15" then
            playerFrame.numberPlayer1Text:SetText("15")
        elseif playerFrame.numberPlayer1Text:GetText() == "6 or 16" then
            playerFrame.numberPlayer1Text:SetText("16")
        elseif playerFrame.numberPlayer1Text:GetText() == "7 or 17" then
            playerFrame.numberPlayer1Text:SetText("17")
        elseif playerFrame.numberPlayer1Text:GetText() == "8 or 18" then
            playerFrame.numberPlayer1Text:SetText("18")
        elseif playerFrame.numberPlayer1Text:GetText() == "9 or 19" then
            playerFrame.numberPlayer1Text:SetText("19")
        elseif playerFrame.numberPlayer1Text:GetText() == "10 or 20" then
            playerFrame.numberPlayer1Text:SetText("20")
        end
        playerFrame.hitButton1:Disable()
        playerFrame.standButton1:Disable()
        playerFrame.doubleButton1:Disable()
        playerFrame.splitButton1:Disable()
        if playerFrame.numberPlayer2Text:GetText() == "Blackjack" then
            turn = 17
        else
            turn = 11
        end
    elseif string.find(message, "%[P1%] Double") then
        local betDoubleAmount1 = string.match(message, "Double my bet to (%d+)G")
        if betDoubleAmount1 then
            PlaceBetsMain1Double()
            mainBetAmount1:SetText(betDoubleAmount1 .. " G")
            PlaySoundFile(soundFilePaths[43])
            playerFrame.timerText1:SetText("")
            playerFrame.timerText1:Hide()
            countdownDuration = 30
            if Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == false and Player5Active == false then       -- Players: 1
                turn = 8
            elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == false then    -- Players: 1 2
                turn = 10
            elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 1 3
                turn = 10
            elseif Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 1 4
                turn = 10
            elseif Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 1 5
                turn = 10
            elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 1 2 3
                turn = 12
            elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 1 2 4
                turn = 12
            elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 1 2 5
                turn = 12
            elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 1 3 4
                turn = 12
            elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 1 3 5
                turn = 12
            elseif Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 1 4 5
                turn = 12
            elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 1 2 3 4
                turn = 14
            elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 1 2 3 5
                turn = 14
            elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 1 2 4 5
                turn = 14
            elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 3 4 5
                turn = 14
            elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 2 3 4 5
                turn = 16
            end
            if playerFrame.numberPlayer1Text:GetText() == "1 or 11" then
                playerFrame.numberPlayer1Text:SetText("11")
            elseif playerFrame.numberPlayer1Text:GetText() == "2 or 12" then
                playerFrame.numberPlayer1Text:SetText("12")
            elseif playerFrame.numberPlayer1Text:GetText() == "3 or 13" then
                playerFrame.numberPlayer1Text:SetText("13")
            elseif playerFrame.numberPlayer1Text:GetText() == "4 or 14" then
                playerFrame.numberPlayer1Text:SetText("14")
            elseif playerFrame.numberPlayer1Text:GetText() == "5 or 15" then
                playerFrame.numberPlayer1Text:SetText("15")
            elseif playerFrame.numberPlayer1Text:GetText() == "6 or 16" then
                playerFrame.numberPlayer1Text:SetText("16")
            elseif playerFrame.numberPlayer1Text:GetText() == "7 or 17" then
                playerFrame.numberPlayer1Text:SetText("17")
            elseif playerFrame.numberPlayer1Text:GetText() == "8 or 18" then
                playerFrame.numberPlayer1Text:SetText("18")
            elseif playerFrame.numberPlayer1Text:GetText() == "9 or 19" then
                playerFrame.numberPlayer1Text:SetText("19")
            elseif playerFrame.numberPlayer1Text:GetText() == "10 or 20" then
                playerFrame.numberPlayer1Text:SetText("20")
            end
            playerFrame.hitButton1:Disable()
            playerFrame.standButton1:Disable()
            playerFrame.doubleButton1:Disable()
            playerFrame.splitButton1:Disable()
        end
    elseif string.find(message, "%[P2%] Placing") and string.find(message, "main") then
        PlaceBetsMain2() 
        Player2Active = true
        local betAmountMain2 = string.match(message, "(%d+)G")
        if betAmountMain2 then
            PlaceBetsTextMain2(betAmountMain2)
        else
        end
    elseif string.find(message, "%[P2%] Placing") and string.find(message, "Perfect") then
        PlaceBetsPP2()
        local betAmountPP2 = string.match(message, "(%d+)G")
        if betAmountPP2 then
            PlaceBetsTextPP2(betAmountPP2)
        else
        end
    elseif string.find(message, "%[P2%] Placing") and string.find(message, "21") then
        PlaceBets2132()
        local betAmount2132 = string.match(message, "(%d+)G")
        if betAmount2132 then
            PlaceBetsText2132(betAmount2132)
        else
        end
    elseif string.find(message, "%[P2%] Hit") then
        playerFrame.timerText2:SetText("")
        playerFrame.timerText2:Hide()
        countdownDuration = 30
        playerFrame.hitButton2:Disable()
        playerFrame.standButton2:Disable()
        playerFrame.doubleButton2:Disable()
        playerFrame.splitButton2:Disable()
    elseif string.find(message, "%[P2%] Stand") then
        playerFrame.timerText2:SetText("")
        playerFrame.timerText2:Hide()
        countdownDuration = 30
        if Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == false then       -- Players: 2
            turn = 9
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == false then    -- Players: 1 2
            turn = 17
        elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 2 3
            turn = 11
        elseif Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 2 4
            turn = 11
        elseif Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 2 5
            turn = 11
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 1 2 3
            turn = 19
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 1 2 4
            turn = 19
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 1 2 5
            turn = 19
        elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 2 3 4
            turn = 13
        elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 2 3 5
            turn = 13
        elseif Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 2 4 5
            turn = 13
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 1 2 3 4
            turn = 21
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 1 2 3 5
            turn = 21
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 1 2 4 5
            turn = 15
        elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 2 3 4 5
            turn = 15
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 2 3 4 5
            turn = 23
        end
        if playerFrame.numberPlayer2Text:GetText() == "1 or 11" then
            playerFrame.numberPlayer2Text:SetText("11")
        elseif playerFrame.numberPlayer2Text:GetText() == "2 or 12" then
            playerFrame.numberPlayer2Text:SetText("12")
        elseif playerFrame.numberPlayer2Text:GetText() == "3 or 13" then
            playerFrame.numberPlayer2Text:SetText("13")
        elseif playerFrame.numberPlayer2Text:GetText() == "4 or 14" then
            playerFrame.numberPlayer2Text:SetText("14")
        elseif playerFrame.numberPlayer2Text:GetText() == "5 or 15" then
            playerFrame.numberPlayer2Text:SetText("15")
        elseif playerFrame.numberPlayer2Text:GetText() == "6 or 16" then
            playerFrame.numberPlayer2Text:SetText("16")
        elseif playerFrame.numberPlayer2Text:GetText() == "7 or 17" then
            playerFrame.numberPlayer2Text:SetText("17")
        elseif playerFrame.numberPlayer2Text:GetText() == "8 or 18" then
            playerFrame.numberPlayer2Text:SetText("18")
        elseif playerFrame.numberPlayer2Text:GetText() == "9 or 19" then
            playerFrame.numberPlayer2Text:SetText("19")
        elseif playerFrame.numberPlayer2Text:GetText() == "10 or 20" then
            playerFrame.numberPlayer2Text:SetText("20")
        end
        playerFrame.hitButton2:Disable()
        playerFrame.standButton2:Disable()
        playerFrame.doubleButton2:Disable()
        playerFrame.splitButton2:Disable()
    elseif string.find(message, "%[P2%] Double") then
        local betDoubleAmount2 = string.match(message, "Double my bet to (%d+)G")
        if betDoubleAmount2 then
            PlaceBetsMain2Double()
            mainBetAmount2:SetText(betDoubleAmount2 .. " G")
            PlaySoundFile(soundFilePaths[43])
            playerFrame.timerText2:SetText("")
            playerFrame.timerText2:Hide()
            countdownDuration = 30
            if Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == false then       -- Players: 2
                turn = 8
            elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == false then    -- Players: 1 2
                turn = 16
            elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 2 3
                turn = 10
            elseif Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 2 4
                turn = 10
            elseif Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 2 5
                turn = 10
            elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 1 2 3
                turn = 18
            elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 1 2 4
                turn = 18
            elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 1 2 5
                turn = 18
            elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 2 3 4
                turn = 12
            elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 2 3 5
                turn = 12
            elseif Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 2 4 5
                turn = 12
            elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 1 2 3 4
                turn = 20
            elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 1 2 3 5
                turn = 20
            elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 1 2 4 5
                turn = 14
            elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 2 3 4 5
                turn = 14
            elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 2 3 4 5
                turn = 22
            end
            if playerFrame.numberPlayer2Text:GetText() == "1 or 11" then
                playerFrame.numberPlayer2Text:SetText("11")
            elseif playerFrame.numberPlayer2Text:GetText() == "2 or 12" then
                playerFrame.numberPlayer2Text:SetText("12")
            elseif playerFrame.numberPlayer2Text:GetText() == "3 or 13" then
                playerFrame.numberPlayer2Text:SetText("13")
            elseif playerFrame.numberPlayer2Text:GetText() == "4 or 14" then
                playerFrame.numberPlayer2Text:SetText("14")
            elseif playerFrame.numberPlayer2Text:GetText() == "5 or 15" then
                playerFrame.numberPlayer2Text:SetText("15")
            elseif playerFrame.numberPlayer2Text:GetText() == "6 or 16" then
                playerFrame.numberPlayer2Text:SetText("16")
            elseif playerFrame.numberPlayer2Text:GetText() == "7 or 17" then
                playerFrame.numberPlayer2Text:SetText("17")
            elseif playerFrame.numberPlayer2Text:GetText() == "8 or 18" then
                playerFrame.numberPlayer2Text:SetText("18")
            elseif playerFrame.numberPlayer2Text:GetText() == "9 or 19" then
                playerFrame.numberPlayer2Text:SetText("19")
            elseif playerFrame.numberPlayer2Text:GetText() == "10 or 20" then
                playerFrame.numberPlayer2Text:SetText("20")
            end
            playerFrame.hitButton2:Disable()
            playerFrame.standButton2:Disable()
            playerFrame.doubleButton2:Disable()
            playerFrame.splitButton2:Disable()
        end
    elseif string.find(message, "%[P3%] Placing") and string.find(message, "main") then
        PlaceBetsMain3() 
        Player3Active = true
        local betAmountMain3 = string.match(message, "(%d+)G")
        if betAmountMain3 then
            PlaceBetsTextMain3(betAmountMain3)
        else
        end
    elseif string.find(message, "%[P3%] Placing") and string.find(message, "Perfect") then
        PlaceBetsPP3()
        local betAmountPP3 = string.match(message, "(%d+)G")
        if betAmountPP3 then
            PlaceBetsTextPP3(betAmountPP3)
        else
        end
    elseif string.find(message, "%[P3%] Placing") and string.find(message, "21") then
        PlaceBets2133()
        local betAmount2133 = string.match(message, "(%d+)G")
        if betAmount2133 then
            PlaceBetsText2133(betAmount2133)
        else
        end
    elseif string.find(message, "%[P3%] Hit") then
        playerFrame.timerText3:SetText("")
        playerFrame.timerText3:Hide()
        countdownDuration = 30
        playerFrame.hitButton3:Disable()
        playerFrame.standButton3:Disable()
        playerFrame.doubleButton3:Disable()
        playerFrame.splitButton3:Disable()
    elseif string.find(message, "%[P3%] Stand") then
        playerFrame.timerText3:SetText("")
        playerFrame.timerText3:Hide()
        countdownDuration = 30
        if Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == false then       -- Players: 3
            turn = 9
        elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 1 3
            turn = 17
        elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 2 3
            turn = 17
        elseif Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 3 4
            turn = 11
        elseif Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 3 5
            turn = 11
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 1 2 3
            turn = 25
        elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 1 3 4
            turn = 19
        elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 1 3 5
            turn = 19
        elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 2 3 4
            turn = 19
        elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 2 3 5
            turn = 19
        elseif Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 3 4 5
            turn = 13
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 1 2 3 4
            turn = 27
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 1 2 3 5
            turn = 27
        elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 3 4 5
            turn = 21
        elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 2 3 4 5
            turn = 21
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 2 3 4 5
            turn = 29
        end
        playerFrame.hitButton3:Disable()
        playerFrame.standButton3:Disable()
        playerFrame.doubleButton3:Disable()
        playerFrame.splitButton3:Disable()
    elseif string.find(message, "%[P3%] Double") then
        local betDoubleAmount3 = string.match(message, "Double my bet to (%d+)G")
        if betDoubleAmount3 then
            mainBetAmount3:SetText(betDoubleAmount3 .. " G")
            PlaySoundFile(soundFilePaths[43])
            playerFrame.timerText3:SetText("")
            playerFrame.timerText3:Hide()
            countdownDuration = 30
            if Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == false then       -- Players: 3
                turn = 8
            elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 1 3
                turn = 16
            elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 2 3
                turn = 16
            elseif Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 3 4
                turn = 10
            elseif Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 3 5
                turn = 10
            elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == false then    -- Players: 1 2 3
                turn = 24
            elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 1 3 4
                turn = 18
            elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 1 3 5
                turn = 18
            elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 2 3 4
                turn = 18
            elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 2 3 5
                turn = 18
            elseif Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 3 4 5
                turn = 12
            elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 1 2 3 4
                turn = 26
            elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 1 2 3 5
                turn = 26
            elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 3 4 5
                turn = 20
            elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 2 3 4 5
                turn = 20
            elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 2 3 4 5
                turn = 28
            end
            playerFrame.hitButton3:Disable()
            playerFrame.standButton3:Disable()
            playerFrame.doubleButton3:Disable()
            playerFrame.splitButton3:Disable()
        end
    elseif string.find(message, "%[P4%] Placing") and string.find(message, "main") then
        PlaceBetsMain4() 
        Player4Active = true
        local betAmountMain4 = string.match(message, "(%d+)G")
        if betAmountMain4 then
            PlaceBetsTextMain4(betAmountMain4)
        else
        end
    elseif string.find(message, "%[P4%] Placing") and string.find(message, "Perfect") then
        PlaceBetsPP4()
        local betAmountPP4 = string.match(message, "(%d+)G")
        if betAmountPP4 then
            PlaceBetsTextPP4(betAmountPP4)
        else
        end
    elseif string.find(message, "%[P4%] Placing") and string.find(message, "21") then
        PlaceBets2134()
        local betAmount2134 = string.match(message, "(%d+)G")
        if betAmount2134 then
            PlaceBetsText2134(betAmount2134)
        else
        end
    elseif string.find(message, "%[P4%] Hit") then
        playerFrame.timerText4:SetText("")
        playerFrame.timerText4:Hide()
        countdownDuration = 30
        playerFrame.hitButton4:Disable()
        playerFrame.standButton4:Disable()
        playerFrame.doubleButton4:Disable()
        playerFrame.splitButton4:Disable()
    elseif string.find(message, "%[P4%] Stand") then
        playerFrame.timerText4:SetText("")
        playerFrame.timerText4:Hide()
        countdownDuration = 30
        if Player1Active == false and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == false then       -- Players: 4
            turn = 9
        elseif Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 1 4
            turn = 17
        elseif Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 2 4
            turn = 17
        elseif Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 3 4
            turn = 17
        elseif Player1Active == false and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 4 5
            turn = 11
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 1 2 4
            turn = 25
        elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 1 3 4
            turn = 25
        elseif Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 1 4 5
            turn = 19
        elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 2 3 4
            turn = 25
        elseif Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 2 4 5
            turn = 19
        elseif Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 3 4 5
            turn = 19
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 1 2 3 4
            turn = 33
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 1 2 4 5
            turn = 27
        elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 3 4 5
            turn = 27
        elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 2 3 4 5
            turn = 27
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 2 3 4 5
            turn = 35
        end
        playerFrame.hitButton4:Disable()
        playerFrame.standButton4:Disable()
        playerFrame.doubleButton4:Disable()
        playerFrame.splitButton4:Disable()
    elseif string.find(message, "%[P4%] Double") then
        local betDoubleAmount4 = string.match(message, "Double my bet to (%d+)G")
        if betDoubleAmount4 then
            mainBetAmount4:SetText(betDoubleAmount4 .. " G")
            PlaySoundFile(soundFilePaths[43])
            playerFrame.timerText4:SetText("")
            playerFrame.timerText4:Hide()
            countdownDuration = 30
            if Player1Active == false and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == false then       -- Players: 4
                turn = 8
            elseif Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 1 4
                turn = 16
            elseif Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 2 4
                turn = 16
            elseif Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 3 4
                turn = 16
            elseif Player1Active == false and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 4 5
                turn = 10
            elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == false then    -- Players: 1 2 4
                turn = 24
            elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 1 3 4
                turn = 24
            elseif Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 1 4 5
                turn = 18
            elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 2 3 4
                turn = 24
            elseif Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 2 4 5
                turn = 18
            elseif Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 3 4 5
                turn = 18
            elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == false then    -- Players: 1 2 3 4
                turn = 32
            elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 1 2 4 5
                turn = 26
            elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 3 4 5
                turn = 26
            elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 2 3 4 5
                turn = 26
            elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 2 3 4 5
                turn = 34
            end
            playerFrame.hitButton4:Disable()
            playerFrame.standButton4:Disable()
            playerFrame.doubleButton4:Disable()
            playerFrame.splitButton4:Disable()
        end
    elseif string.find(message, "%[P5%] Placing") and string.find(message, "main") then
        PlaceBetsMain5() 
        Player5Active = true
        local betAmountMain5 = string.match(message, "(%d+)G")
        if betAmountMain5 then
            PlaceBetsTextMain5(betAmountMain5)
        else
        end
    elseif string.find(message, "%[P5%] Placing") and string.find(message, "Perfect") then
        PlaceBetsPP5()
        local betAmountPP5 = string.match(message, "(%d+)G")
        if betAmountPP5 then
            PlaceBetsTextPP5(betAmountPP5)
        else
        end
    elseif string.find(message, "%[P5%] Placing") and string.find(message, "21") then
        PlaceBets2135()
        local betAmount2135 = string.match(message, "(%d+)G")
        if betAmount2135 then
            PlaceBetsText2135(betAmount2135)
        else
        end
    elseif string.find(message, "%[P5%] Hit") then
        playerFrame.timerText5:SetText("")
        playerFrame.timerText5:Hide()
        countdownDuration = 30
        playerFrame.hitButton5:Disable()
        playerFrame.standButton5:Disable()
        playerFrame.doubleButton5:Disable()
        playerFrame.splitButton5:Disable()
    elseif string.find(message, "%[P5%] Stand") then
        playerFrame.timerText5:SetText("")
        playerFrame.timerText5:Hide()
        countdownDuration = 30
        if Player1Active == false and Player2Active == false and Player3Active == false and Player4Active == false and Player5Active == true then       -- Players: 5
            turn = 9
        elseif Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 1 5
            turn = 17
        elseif Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 2 5
            turn = 17
        elseif Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 3 5
            turn = 17
        elseif Player1Active == false and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 4 5
            turn = 17
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 1 2 5
            turn = 25
        elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 1 3 5
            turn = 25
        elseif Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 1 4 5
            turn = 25
        elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 2 3 5
            turn = 25
        elseif Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 2 4 5
            turn = 25
        elseif Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 3 4 5
            turn = 25
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 1 2 3 5
            turn = 33
        elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 1 2 4 5
            turn = 33
        elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 3 4 5
            turn = 33
        elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 2 3 4 5
            turn = 33
        elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 2 3 4 5
            turn = 41
        end
        playerFrame.hitButton5:Disable()
        playerFrame.standButton5:Disable()
        playerFrame.doubleButton5:Disable()
        playerFrame.splitButton5:Disable()
    elseif string.find(message, "%[P5%] Double") then
        local betDoubleAmount5 = string.match(message, "Double my bet to (%d+)G")
        if betDoubleAmount5 then
            mainBetAmount5:SetText(betDoubleAmount5 .. " G")
            PlaySoundFile(soundFilePaths[43])
            playerFrame.timerText5:SetText("")
            playerFrame.timerText5:Hide()
            countdownDuration = 30
            if Player1Active == false and Player2Active == false and Player3Active == false and Player4Active == false and Player5Active == true then       -- Players: 5
                turn = 8
            elseif Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 1 5
                turn = 16
            elseif Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 2 5
                turn = 16
            elseif Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 3 5
                turn = 16
            elseif Player1Active == false and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 4 5
                turn = 16
            elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == false and Player5Active == true then    -- Players: 1 2 5
                turn = 24
            elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 1 3 5
                turn = 24
            elseif Player1Active == true and Player2Active == false and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 1 4 5
                turn = 24
            elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 2 3 5
                turn = 24
            elseif Player1Active == false and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 2 4 5
                turn = 24
            elseif Player1Active == false and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 3 4 5
                turn = 24
            elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == false and Player5Active == true then    -- Players: 1 2 3 5
                turn = 32
            elseif Player1Active == true and Player2Active == true and Player3Active == false and Player4Active == true and Player5Active == true then    -- Players: 1 2 4 5
                turn = 32
            elseif Player1Active == true and Player2Active == false and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 3 4 5
                turn = 32
            elseif Player1Active == false and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 2 3 4 5
                turn = 32
            elseif Player1Active == true and Player2Active == true and Player3Active == true and Player4Active == true and Player5Active == true then    -- Players: 1 2 3 4 5
                turn = 40
            end
            playerFrame.hitButton5:Disable()
            playerFrame.standButton5:Disable()
            playerFrame.doubleButton5:Disable()
            playerFrame.splitButton5:Disable()
        end
    else     
    end
end)



local function roundStarted()

    -- "Place your bets" message
    playerFrame.timerTextBets:Hide()
    countdownDuration = 30

    -- Player 1 bet buttons disabled
    confirmBetButtonMain1:Disable()
    confirmBetButtonPP1:Disable()
    confirmBetButton2131:Disable()

    -- Player 2 bet buttons disabled
    confirmBetButtonMain2:Disable()
    confirmBetButtonPP2:Disable()
    confirmBetButton2132:Disable()

end

local function insuranceAvailable()

    -- Player 1
    playerFrame.insuranceYesButton1:Enable()
    playerFrame.insuranceNoButton1:Enable()
    playerFrame.hitButton1:Disable()
    playerFrame.standButton1:Disable()
    playerFrame.doubleButton1:Disable()

    -- Player 2
    playerFrame.insuranceYesButton2:Enable()
    playerFrame.insuranceNoButton2:Enable()
    playerFrame.hitButton2:Disable()
    playerFrame.standButton2:Disable()
    playerFrame.doubleButton2:Disable()

end



-- Reacts to the Dealer "New Game" button - "I have started a new round."
local function betReset()
    confirmBetButtonMain1:Enable()
    confirmBetButtonPP1:Enable()
    confirmBetButton2131:Enable()
    betEditBoxMain1:Enable()
    betEditBoxMain1:SetText("")
    betEditBoxPP1:Enable()
    betEditBoxPP1:SetText("")
    betEditBox2131:Enable()
    betEditBox2131:SetText("")
    playerFrame.hitButton1:Disable()
    playerFrame.standButton1:Disable()
    playerFrame.doubleButton1:Disable()
    playerFrame.coinsMainBet1:Hide()
    playerFrame.coinsDoubleBet1:Hide()
    playerFrame.coinsPPBet1:Hide()
    playerFrame.coins213Bet1:Hide()
    mainBetAmount1:Hide()
    ppBetAmount1:Hide()
    t213BetAmount1:Hide()
    insuranceYesIcon1:Hide()
    insuranceNoIcon1:Hide()
    playerFrame.insuranceYesButton1:Disable()
    playerFrame.insuranceNoButton1:Disable()
    playerFrame.insuranceBetAmount1:SetText("")
    playerFrame.coinsPPWin1:Hide()
    playerFrame.coins213Win1:Hide()
    playerFrame.coinsBJWin1:Hide()


    confirmBetButtonMain2:Enable()
    confirmBetButtonPP2:Enable()
    confirmBetButton2132:Enable()
    betEditBoxMain2:Enable()
    betEditBoxMain2:SetText("")
    betEditBoxPP2:Enable()
    betEditBoxPP2:SetText("")
    betEditBox2132:Enable()
    betEditBox2132:SetText("")
    playerFrame.hitButton2:Disable()
    playerFrame.standButton2:Disable()
    playerFrame.doubleButton2:Disable()
    playerFrame.coinsMainBet2:Hide()
    playerFrame.coinsDoubleBet2:Hide()
    playerFrame.coinsPPBet2:Hide()
    playerFrame.coins213Bet2:Hide()
    mainBetAmount2:Hide()
    ppBetAmount2:Hide()
    t213BetAmount2:Hide()
    insuranceYesIcon2:Hide()
    insuranceNoIcon2:Hide()
    playerFrame.insuranceYesButton2:Disable()
    playerFrame.insuranceNoButton2:Disable()
    playerFrame.insuranceBetAmount2:SetText("")
    playerFrame.coinsPPWin2:Hide()
    playerFrame.coins213Win2:Hide()
    playerFrame.coinsBJWin2:Hide()
    
    playerFrame.timerText1:SetText("")
    playerFrame.timerText1:Hide()
    playerFrame.timerText2:SetText("")
    playerFrame.timerText2:Hide()
    playerFrame.timerText3:SetText("")
    playerFrame.timerText3:Hide()
    playerFrame.timerText4:SetText("")
    playerFrame.timerText4:Hide()
    playerFrame.timerText5:SetText("")
    playerFrame.timerText5:Hide()
    playerFrame.timerTextBets:SetText("")
    playerFrame.timerTextBets:Hide()
    countdownDuration = 30
    turn = 0

    playerFrame.numberPlayer1Text:SetTextColor(1, 1, 1)
    playerFrame.numberPlayer2Text:SetTextColor(1, 1, 1)
    playerFrame.numberDealerText:SetTextColor(1, 1, 1)

    double1Flag = false
    double2Flag = false

end









-- Function to handle Player 1 PP Win Image
function PlaceBetsPPWin1(message)
    playerFrame.coinsPPBet1:Hide()
    playerFrame.coinsPPWin1:Show()
    ppBetAmount1:SetPoint("CENTER", playerFrame, 274, 77)
end

-- Function to handle Player 1 21+3 Win Image
function PlaceBets213Win1(message)
    playerFrame.coins213Bet1:Hide()
    playerFrame.coins213Win1:Show()
    t213BetAmount1:SetPoint("CENTER", playerFrame, 345, 174)
end

function PPWin1MixedPair(message)
    betAmountPP1TextValue = tonumber(string.match(ppBetAmount1:GetText(), "%d+"))
    if betAmountPP1TextValue then
        newPP1Amount = betAmountPP1TextValue * 5
        ppBetAmount1:SetText(newPP1Amount .. " G")
    end
    PlaceBetsPPWin1()
end

function PPWin1ColouredPair(message)
    betAmountPP1TextValue = tonumber(string.match(ppBetAmount1:GetText(), "%d+"))
    if betAmountPP1TextValue then
        newPP1Amount = betAmountPP1TextValue * 10
        ppBetAmount1:SetText(newPP1Amount .. " G")
    end
    PlaceBetsPPWin1()
end

function PPWin1PerfectPair(message)
    betAmountPP1TextValue = tonumber(string.match(ppBetAmount1:GetText(), "%d+"))
    if betAmountPP1TextValue then
        newPP1Amount = betAmountPP1TextValue * 30
        ppBetAmount1:SetText(newPP1Amount .. " G")
    end
    PlaceBetsPPWin1()
end

function t213Win1SuitedThreeOfaKind(message)
    betAmount2131TextValue = tonumber(string.match(t213BetAmount1:GetText(), "%d+"))
    if betAmount2131TextValue then
        new2131Amount = betAmount2131TextValue * 100
        t213BetAmount1:SetText(new2131Amount .. " G")
    end
    PlaceBets213Win1()
end

function t213Win1StraightFlush(message)
    betAmount2131TextValue = tonumber(string.match(t213BetAmount1:GetText(), "%d+"))
    if betAmount2131TextValue then
        new2131Amount = betAmount2131TextValue * 40
        t213BetAmount1:SetText(new2131Amount .. " G")
    end
    PlaceBets213Win1()
end

function t213Win1ThreeOfaKind(message)
    betAmount2131TextValue = tonumber(string.match(t213BetAmount1:GetText(), "%d+"))
    if betAmount2131TextValue then
        new2131Amount = betAmount2131TextValue * 30
        t213BetAmount1:SetText(new2131Amount .. " G")
    end
    PlaceBets213Win1()
end

function t213Win1Straight(message)
    betAmount2131TextValue = tonumber(string.match(t213BetAmount1:GetText(), "%d+"))
    if betAmount2131TextValue then
        new2131Amount = betAmount2131TextValue * 10
        t213BetAmount1:SetText(new2131Amount .. " G")
    end
    PlaceBets213Win1()
end

function t213Win1Flush(message)
    betAmount2131TextValue = tonumber(string.match(t213BetAmount1:GetText(), "%d+"))
    if betAmount2131TextValue then
        new2131Amount = betAmount2131TextValue * 5
        t213BetAmount1:SetText(new2131Amount .. " G")
    end
    PlaceBets213Win1()
end


function updateBlackjackWin1(message)
    print("Executing updateBlackjackWin1")
    betAmountCurrentBetValue = tonumber(string.match(mainBetAmount1:GetText(), "%d+"))
    if betAmountCurrentBetValue then
        newBetAmountValue = betAmountCurrentBetValue * 2.5
        mainBetAmount1:SetText(newBetAmountValue .. " G")
    end
    PlaceBJWin1()
end

function updateRegularWin1(message)
    betAmountCurrentBetValue = tonumber(string.match(mainBetAmount1:GetText(), "%d+"))
    if betAmountCurrentBetValue then
        newBetAmountValue = betAmountCurrentBetValue * 2
        mainBetAmount1:SetText(newBetAmountValue .. " G")
    end
    PlaceWin1()
end







-- Function to handle Player 2 PP Win Image
function PlaceBetsPPWin2(message)
    playerFrame.coinsPPBet2:Hide()
    playerFrame.coinsPPWin2:Show()
    ppBetAmount2:SetPoint("CENTER", playerFrame, 121, -2)
end

-- Function to handle Player 2 21+3 Win Image
function PlaceBets213Win2(message)
    playerFrame.coins213Bet2:Hide()
    playerFrame.coins213Win2:Show()
    t213BetAmount2:SetPoint("CENTER", playerFrame, 230, 49)
end

function PPWin2MixedPair(message)
    betAmountPP2TextValue = tonumber(string.match(ppBetAmount2:GetText(), "%d+"))
    if betAmountPP2TextValue then
        newPP2Amount = betAmountPP2TextValue * 5
        ppBetAmount2:SetText(newPP2Amount .. " G")
    end
    PlaceBetsPPWin2()
end

function PPWin2ColouredPair(message)
    betAmountPP2TextValue = tonumber(string.match(ppBetAmount2:GetText(), "%d+"))
    if betAmountPP2TextValue then
        newPP2Amount = betAmountPP2TextValue * 10
        ppBetAmount2:SetText(newPP2Amount .. " G")
    end
    PlaceBetsPPWin2()
end

function PPWin2PerfectPair(message)
    betAmountPP2TextValue = tonumber(string.match(ppBetAmount2:GetText(), "%d+"))
    if betAmountPP2TextValue then
        newPP2Amount = betAmountPP2TextValue * 30
        ppBetAmount2:SetText(newPP2Amount .. " G")
    end
    PlaceBetsPPWin2()
end

function t213Win2SuitedThreeOfaKind(message)
    betAmount2132TextValue = tonumber(string.match(t213BetAmount2:GetText(), "%d+"))
    if betAmount2132TextValue then
        new2132Amount = betAmount2132TextValue * 100
        t213BetAmount2:SetText(new2132Amount .. " G")
    end
    PlaceBets213Win2()
end

function t213Win2StraightFlush(message)
    betAmount2132TextValue = tonumber(string.match(t213BetAmount2:GetText(), "%d+"))
    if betAmount2132TextValue then
        new2132Amount = betAmount2132TextValue * 40
        t213BetAmount2:SetText(new2132Amount .. " G")
    end
    PlaceBets213Win2()
end

function t213Win2ThreeOfaKind(message)
    betAmount2132TextValue = tonumber(string.match(t213BetAmount2:GetText(), "%d+"))
    if betAmount2132TextValue then
        new2132Amount = betAmount2132TextValue * 30
        t213BetAmount2:SetText(new2132Amount .. " G")
    end
    PlaceBets213Win2()
end

function t213Win2Straight(message)
    betAmount2132TextValue = tonumber(string.match(t213BetAmount2:GetText(), "%d+"))
    if betAmount2132TextValue then
        new2132Amount = betAmount2132TextValue * 10
        t213BetAmount2:SetText(new2132Amount .. " G")
    end
    PlaceBets213Win2()
end

function t213Win2Flush(message)
    betAmount2132TextValue = tonumber(string.match(t213BetAmount2:GetText(), "%d+"))
    if betAmount2132TextValue then
        new2132Amount = betAmount2132TextValue * 5
        t213BetAmount2:SetText(new2132Amount .. " G")
    end
    PlaceBets213Win2()
end


function updateBlackjackWin2(message)
    print("Executing updateBlackjackWin2")
    betAmountCurrentBetValue2 = tonumber(string.match(mainBetAmount2:GetText(), "%d+"))
    if betAmountCurrentBetValue2 then
        newBetAmountValue2 = betAmountCurrentBetValue2 * 2.5
        mainBetAmount2:SetText(newBetAmountValue2 .. " G")
    end
    PlaceBJWin2()
end

function updateRegularWin2(message)
    betAmountCurrentBetValue2 = tonumber(string.match(mainBetAmount2:GetText(), "%d+"))
    if betAmountCurrentBetValue2 then
        newBetAmountValue2 = betAmountCurrentBetValue2 * 2
        mainBetAmount2:SetText(newBetAmountValue2 .. " G")
    end
    PlaceWin2()
end










-- Function to remove card textures
local function RemoveCardTextures()
    for i = 1, #drawnCards do
        drawnCards[i]:Hide() -- Hide the card texture
        drawnCards[i]:SetTexture(nil)  -- Set the texture to nil
    end
    drawnCards = {} -- Reset the table of card textures
    playerFrame.numberPlayer1Text:Hide()
    playerFrame.numberPlayer2Text:Hide()
    playerFrame.numberPlayer3Text:Hide()
    playerFrame.numberPlayer4Text:Hide()
    playerFrame.numberPlayer5Text:Hide()
    playerFrame.numberDealerText:Hide()

    -- Reset Player1Total
    Player1Total = 0
    playerFrame.numberPlayer1Text:SetText("")
    playerFrame.numberPlayer2Text:SetText("")
    playerFrame.numberPlayer3Text:SetText("")
    playerFrame.numberPlayer4Text:SetText("")
    playerFrame.numberPlayer4Text:SetText("")

    -- Reset DealerTotal
    DealerTotal = 0
    playerFrame.numberDealerText:SetText("")
end


-- Chat event to listen for raid leader chat messages
local eventFrame = CreateFrame("Frame")
eventFrame:RegisterEvent("CHAT_MSG_RAID_LEADER")
eventFrame:SetScript("OnEvent", function(self, event, message, sender)

    if sender == "Blackjackk-Earthshaker" or UnitIsGroupLeader(sender,"raid") then
        
        HandleChatMessage(message)
        
        if message == "I have opened the table." then
            EnableJoinButton()
        elseif message == "I have closed the table." then
            PlayerFrameHide()
        elseif message == "I have started a new round." then
            betReset()
            RemoveCardTextures()
        elseif message == "{diamond} Insurance is available." then
            insuranceAvailable()
        elseif message == "{star} Place your bets! You have 30 seconds." then
            StartCountdownTimerBets()
        elseif string.find(message, "received") then
            roundStarted()
        elseif string.find(message, "What is your decision") then
            if string.find(message, unitName1) then
                if playerName == unitName1 then
                    playerTurn1()
                    StartCountdownTimer1()
                else
                end
            elseif string.find(message, unitName2) then
                if playerName == unitName2 then
                    playerTurn2()
                    StartCountdownTimer2()
                else
                end
            end
        elseif string.find(message, "Dealer has gone bust") and string.find(message, unitName1) and string.find(message, "wins") then
            PlaySoundFile(soundFilePaths[44]) -- "Player 1 win"
            updateRegularWin1()
        elseif string.find(message, "Dealer has gone bust") and string.find(message, unitName2) and string.find(message, "wins") then
            PlaySoundFile(soundFilePaths[45]) -- "Player 2 win"
            updateRegularWin2()
        elseif string.find(message, "22") then
            if string.find(message, unitName1) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[48]) -- "Player 1 bust"
                playerFrame.numberPlayer1Text:SetText("22")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0)
                turn = 11
            elseif string.find(message, unitName2) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[49]) -- "Player 2 bust"
                playerFrame.numberPlayer2Text:SetText("22")
                playerFrame.numberPlayer2Text:SetTextColor(1, 0, 0)
                turn = 17
            elseif string.find(message, "Dealer") then
                playerFrame.numberDealerText:SetText("22")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0)
            end
        elseif string.find(message, "23") then
            if string.find(message, unitName1) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[48]) -- "Player 1 bust"
                playerFrame.numberPlayer1Text:SetText("23")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0)
                turn = 11
            elseif string.find(message, unitName2) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[49]) -- "Player 2 bust"
                playerFrame.numberPlayer2Text:SetText("23")
                playerFrame.numberPlayer2Text:SetTextColor(1, 0, 0)
                turn = 17
            elseif string.find(message, "Dealer") then
                playerFrame.numberDealerText:SetText("23")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0)
            end
        elseif string.find(message, "24") then
            if string.find(message, unitName1) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[48]) -- "Player 1 bust"
                playerFrame.numberPlayer1Text:SetText("24")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0)
                turn = 11
            elseif string.find(message, unitName2) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[49]) -- "Player 2 bust"
                playerFrame.numberPlayer2Text:SetText("24")
                playerFrame.numberPlayer2Text:SetTextColor(1, 0, 0)
                turn = 17
            elseif string.find(message, "Dealer") then
                playerFrame.numberDealerText:SetText("24")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0)
            end
        elseif string.find(message, "25") then
            if string.find(message, unitName1) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[48]) -- "Player 1 bust"
                playerFrame.numberPlayer1Text:SetText("25")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0)
                turn = 11
            elseif string.find(message, unitName2) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[49]) -- "Player 2 bust"
                playerFrame.numberPlayer2Text:SetText("25")
                playerFrame.numberPlayer2Text:SetTextColor(1, 0, 0)
                turn = 17
            elseif string.find(message, "Dealer") then
                playerFrame.numberDealerText:SetText("25")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0)
            end
        elseif string.find(message, "26") then
            if string.find(message, unitName1) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[48]) -- "Player 1 bust"
                playerFrame.numberPlayer1Text:SetText("26")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0)
                turn = 11
            elseif string.find(message, unitName2) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[49]) -- "Player 2 bust"
                playerFrame.numberPlayer2Text:SetText("26")
                playerFrame.numberPlayer2Text:SetTextColor(1, 0, 0)
                turn = 17
            elseif string.find(message, "Dealer") then
                playerFrame.numberDealerText:SetText("26")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0)
            end
        elseif string.find(message, "27") then
            if string.find(message, unitName1) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[48]) -- "Player 1 bust"
                playerFrame.numberPlayer1Text:SetText("27")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0)
                turn = 11
            elseif string.find(message, unitName2) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[49]) -- "Player 2 bust"
                playerFrame.numberPlayer2Text:SetText("27")
                playerFrame.numberPlayer2Text:SetTextColor(1, 0, 0)
                turn = 17
            elseif string.find(message, "Dealer") then
                playerFrame.numberDealerText:SetText("27")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0)
            end
        elseif string.find(message, "28") then
            if string.find(message, unitName1) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[48]) -- "Player 1 bust"
                playerFrame.numberPlayer1Text:SetText("28")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0)
                turn = 11
            elseif string.find(message, unitName2) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[49]) -- "Player 2 bust"
                playerFrame.numberPlayer2Text:SetText("28")
                playerFrame.numberPlayer2Text:SetTextColor(1, 0, 0)
                turn = 17
            elseif string.find(message, "Dealer") then
                playerFrame.numberDealerText:SetText("28")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0)
            end
        elseif string.find(message, "29") then
            if string.find(message, unitName1) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[48]) -- "Player 1 bust"
                playerFrame.numberPlayer1Text:SetText("29")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0)
                turn = 11
            elseif string.find(message, unitName2) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[49]) -- "Player 2 bust"
                playerFrame.numberPlayer2Text:SetText("29")
                playerFrame.numberPlayer2Text:SetTextColor(1, 0, 0)
                turn = 17
            elseif string.find(message, "Dealer") then
                playerFrame.numberDealerText:SetText("29")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0)
            end
        elseif string.find(message, "30") then
            if string.find(message, unitName1) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[48]) -- "Player 1 bust"
                playerFrame.numberPlayer1Text:SetText("30")
                playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0)
                turn = 11
            elseif string.find(message, unitName2) and not string.find(message, "wins") then
                PlaySoundFile(soundFilePaths[49]) -- "Player 2 bust"
                playerFrame.numberPlayer2Text:SetText("30")
                playerFrame.numberPlayer2Text:SetTextColor(1, 0, 0)
                turn = 17
            elseif string.find(message, "Dealer") then
                PlaySoundFile(soundFilePaths[37]) -- "Dealer bust"
                playerFrame.numberDealerText:SetText("30")
                playerFrame.numberDealerText:SetTextColor(1, 0, 0)
            end
        elseif string.find(message, "push!") then
            if string.find(message, unitName1) and string.find(message, unitName2) then
                PlaySoundFile(soundFilePaths[54]) -- "Both players push"
                playerFrame.numberPlayer1Text:SetTextColor(0.2, 0.7, 1)
                playerFrame.numberPlayer2Text:SetTextColor(0.2, 0.7, 1)
            elseif string.find(message, unitName1) then
                PlaySoundFile(soundFilePaths[55]) -- "Player 1 push"
                playerFrame.numberPlayer1Text:SetTextColor(0.2, 0.7, 1)
            elseif string.find(message, unitName2) then
                PlaySoundFile(soundFilePaths[56]) -- "Player 2 push"
                playerFrame.numberPlayer2Text:SetTextColor(0.2, 0.7, 1)
            end
        elseif string.find(message, "has less than") and string.find(message, unitName1) then
            PlaySoundFile(soundFilePaths[46])
        elseif string.find(message, "has less than") and string.find(message, unitName2) then
            PlaySoundFile(soundFilePaths[47])
        elseif string.find(message, "has more than") and string.find(message, unitName1) then
            updateRegularWin1()
            PlaySoundFile(soundFilePaths[44])
        elseif string.find(message, "has more than") and string.find(message, unitName2) then
            updateRegularWin2()
            PlaySoundFile(soundFilePaths[45])
        elseif string.find(message, "has Blackjack") and string.find(message, unitName1) then
            playerFrame.numberPlayer1Text:SetText("Blackjack")
            playerFrame.numberPlayer1Text:SetTextColor(1, 1, 0)
            if Player1Active and not Player2Active and not Player3Active and not Player4Active and not Player5Active then
                if string.find(message, "has won this") then
                    PlaySoundFile(soundFilePaths[52])
                    updateBlackjackWin1()
                else
                    PlaySoundFile(soundFilePaths[52])
                    updateBlackjackWin1()
                    turn = 10
                end
            elseif Player1Active and Player2Active and not Player3Active and not Player4Active and not Player5Active then
                playerFrame.numberPlayer1Text:SetText("Blackjack")
                playerFrame.numberPlayer1Text:SetTextColor(1, 1, 0)
                if string.find(message, "has won this") then
                    PlaySoundFile(soundFilePaths[52])
                    updateBlackjackWin1()
                else
                    PlaySoundFile(soundFilePaths[52])
                    updateBlackjackWin1()
                end
            end
        elseif string.find(message, "has Blackjack") and string.find(message, unitName2) then
            if Player1Active and Player2Active and not Player3Active and not Player4Active and not Player5Active then
                if string.find(message, "has won this") then
                    PlaySoundFile(soundFilePaths[53])
                    updateBlackjackWin2()
                else
                    updateBlackjackWin2()
                end
            end
        elseif string.find(message, "has Blackjack") and string.find(message, "Dealer") then
            playerFrame.numberDealerText:SetText("Blackjack")
            playerFrame.numberDealerText:SetTextColor(1, 1, 0)
            PlaySoundFile(soundFilePaths[36])

        elseif string.find(message, "hit a Suited Three of a Kind") then
            if string.find(message, "Player 1") then
                if string.find(message, "congratulations") then
                    t213Win1SuitedThreeOfaKind()
                else
                    print("")
                end
            elseif string.find(message, "Player 2") then
                if string.find(message, "congratulations") then
                    t213Win2SuitedThreeOfaKind()
                else
                    print("")
                end  
            end
        elseif string.find(message, "hit a Straight Flush") then
            if string.find(message, "Player 1") then
                if string.find(message, "congratulations") then
                    t213Win1StraightFlush()
                else
                    print("")
                end
            elseif string.find(message, "Player 2") then
                if string.find(message, "congratulations") then
                    t213Win2StraightFlush()
                else
                    print("")
                end  
            end
        elseif string.find(message, "hit a Flush") then
            if string.find(message, "Player 1") then
                if string.find(message, "congratulations") then
                    t213Win1Flush()
                else
                    print("")
                end
            elseif string.find(message, "Player 2") then
                if string.find(message, "congratulations") then
                    t213Win2Flush()
                else
                    print("")
                end  
            end
        elseif string.find(message, "hit a Three of a Kind") then
            if string.find(message, "Player 1") then
                if string.find(message, "congratulations") then
                    t213Win1ThreeOfaKind()
                else
                    print("")
                end
            elseif string.find(message, "Player 2") then
                if string.find(message, "congratulations") then
                    t213Win2ThreeOfaKind()
                else
                    print("")
                end  
            end
        elseif string.find(message, "hit a Straight") then
            if string.find(message, "Player 1") then
                if string.find(message, "congratulations") then
                    t213Win1Straight()
                else
                    print("")
                end
            elseif string.find(message, "Player 2") then
                if string.find(message, "congratulations") then
                    t213Win2Straight()
                else
                    print("")
                end  
            end
        elseif string.find(message, "hit a Perfect Pair") then
            if string.find(message, "Player 1") then
                if string.find(message, "congratulations") then
                    PPWin1PerfectPair()
                else
                    print("")
                end
            elseif string.find(message, "Player 2") then
                if string.find(message, "congratulations") then
                    PPWin2PerfectPair()
                else
                    print("")
                end  
            end
        elseif string.find(message, "hit a Coloured Pair") then
            if string.find(message, "Player 1") then
                if string.find(message, "congratulations") then
                    PPWin1ColouredPair()
                else
                    print("")
                end
            elseif string.find(message, "Player 2") then
                if string.find(message, "congratulations") then
                    PPWin2ColouredPair()
                else
                    print("")
                end  
            end
        elseif string.find(message, "hit a Mixed Pair") then
            if string.find(message, "Player 1") then
                if string.find(message, "congratulations") then
                    PPWin1MixedPair()
                else
                    print("")
                end
            elseif string.find(message, "Player 2") then
                if string.find(message, "congratulations") then
                    PPWin2MixedPair()
                else
                    print("")
                end  
            end
        end
    end
end)






playerFrame.insuranceYesButton1:SetScript("OnClick", function()
    insuranceYesIcon1:Show()
    playerFrame.insuranceYesButton1:Disable()
    playerFrame.insuranceNoButton1:Disable()
    playerFrame.hitButton1:Enable()
    playerFrame.standButton1:Enable()
    playerFrame.doubleButton1:Enable()
    countdownDuration = 30
    playerFrame.timerText1:SetText("")
    playerFrame.timerText1:Hide()
    betInsuranceAmount1 = 0
    betMainAmount1 = tonumber(betEditBoxMain1:GetText())
    if betMainAmount1 then
        betInsuranceAmount1 = betMainAmount1 / 2
        SendChatMessage("[P1] YES to Insurance - adding " .. betInsuranceAmount1 .. "G", "RAID")
        playerFrame.insuranceBetAmount1:SetText(betInsuranceAmount1 .. " G")
    end
    if Player1Active and not Player2Active and not Player3Active and not Player4Active and not Player5Active then
        local chatFrame = SELECTED_DOCK_FRAME
        ChatFrame_OpenChat("/trade", chatFrame)
        local editBox = _G[chatFrame:GetName().."EditBox"]
        editBox:Insert("/trade")
        ChatEdit_SendText(editBox)
    end
end)

playerFrame.insuranceNoButton1:SetScript("OnClick", function()
    insuranceNoIcon1:Show()
    playerFrame.insuranceYesButton1:Disable()
    playerFrame.insuranceNoButton1:Disable()
    playerFrame.hitButton1:Enable()
    playerFrame.standButton1:Enable()
    playerFrame.doubleButton1:Enable()
    countdownDuration = 30
    playerFrame.timerText1:SetText("")
    playerFrame.timerText1:Hide()
    SendChatMessage("[P1] NO to Insurance", "RAID")
end)



playerFrame.hitButton1:SetScript("OnClick", function()
    -- Handle the "hit" button action
    SendChatMessage("[P1] Hit", "RAID")
    playerFrame.hitButton1:Disable()
    playerFrame.standButton1:Disable()
    playerFrame.doubleButton1:Disable()
    playerFrame.splitButton1:Disable()
    playerFrame.timerText1:SetText("")
    playerFrame.timerText1:Hide()
    if playerFrame.numberDealerText:GetText() == "1 or 11" and playerFrame.insuranceYesButton1:IsEnabled() and playerFrame.insuranceNoButton1:IsEnabled() then
        SendChatMessage("[P1] NO to Insurance", "RAID")
        playerFrame.insuranceYesButton1:Disable()
        playerFrame.insuranceNoButton1:Disable()
        insuranceNoIcon1:Show()
    end
    PlaySoundFile(soundFilePaths[39])
    double1Flag = true
end)

playerFrame.standButton1:SetScript("OnClick", function()
    -- Handle the "stand" button action
    SendChatMessage("[P1] Stand", "RAID")
    playerFrame.hitButton1:Disable()
    playerFrame.standButton1:Disable()
    playerFrame.doubleButton1:Disable()
    playerFrame.splitButton1:Disable()
    playerFrame.timerText1:SetText("")
    playerFrame.timerText1:Hide()
    if playerFrame.numberPlayer1Text:GetText() == "1 or 11" then
        playerFrame.numberPlayer1Text:SetText("11")
    elseif playerFrame.numberPlayer1Text:GetText() == "2 or 12" then
        playerFrame.numberPlayer1Text:SetText("12")
    elseif playerFrame.numberPlayer1Text:GetText() == "3 or 13" then
        playerFrame.numberPlayer1Text:SetText("13")
    elseif playerFrame.numberPlayer1Text:GetText() == "4 or 14" then
        playerFrame.numberPlayer1Text:SetText("14")
    elseif playerFrame.numberPlayer1Text:GetText() == "5 or 15" then
        playerFrame.numberPlayer1Text:SetText("15")
    elseif playerFrame.numberPlayer1Text:GetText() == "6 or 16" then
        playerFrame.numberPlayer1Text:SetText("16")
    elseif playerFrame.numberPlayer1Text:GetText() == "7 or 17" then
        playerFrame.numberPlayer1Text:SetText("17")
    elseif playerFrame.numberPlayer1Text:GetText() == "8 or 18" then
        playerFrame.numberPlayer1Text:SetText("18")
    elseif playerFrame.numberPlayer1Text:GetText() == "9 or 19" then
        playerFrame.numberPlayer1Text:SetText("19")
    elseif playerFrame.numberPlayer1Text:GetText() == "10 or 20" then
        playerFrame.numberPlayer1Text:SetText("20")
    end
    if playerFrame.numberDealerText:GetText() == "1 or 11" and playerFrame.insuranceYesButton1:IsEnabled() and playerFrame.insuranceNoButton1:IsEnabled() then
        SendChatMessage("[P1] NO to Insurance", "RAID")
        playerFrame.insuranceYesButton1:Disable()
        playerFrame.insuranceNoButton1:Disable()
        insuranceNoIcon1:Show()
    end
    if Player1Active and not Player2Active and not Player3Active and not Player4Active and not Player5Active then
        turn = 9
    elseif Player1Active and Player2Active and not Player3Active and not Player4Active and not Player5Active then
        turn = 11
    end
    PlaySoundFile(soundFilePaths[40])
    double1Flag = true
end)

playerFrame.doubleButton1:SetScript("OnClick", function()
    local betDoubleAmount1 = 0
    betAmount1 = tonumber(betEditBoxMain1:GetText()) -- Get the entered bet amount
    if betAmount1 then
        betDoubleAmount1 = betAmount1 * 2
        SendChatMessage("[P1] Double my bet to " ..betDoubleAmount1.. "G", "RAID")
        betEditBoxMain1:SetText(betDoubleAmount1)
        playerFrame.hitButton1:Disable()
        playerFrame.standButton1:Disable()
        playerFrame.doubleButton1:Disable() 
        playerFrame.timerText1:SetText("")
        playerFrame.timerText1:Hide()
        countdownDuration = 30
    end
    if playerFrame.numberDealerText:GetText() == "1 or 11" and playerFrame.insuranceYesButton1:IsEnabled() and playerFrame.insuranceNoButton1:IsEnabled() then
        SendChatMessage("[P1] NO to Insurance", "RAID")
        playerFrame.insuranceYesButton1:Disable()
        playerFrame.insuranceNoButton1:Disable()
        insuranceNoIcon1:Show()
    end
    if Player1Active and not Player2Active and not Player3Active and not Player4Active and not Player5Active then
        local chatFrame = SELECTED_DOCK_FRAME
        ChatFrame_OpenChat("/trade", chatFrame)
        local editBox = _G[chatFrame:GetName().."EditBox"]
        editBox:Insert("/trade")
        ChatEdit_SendText(editBox)
    end
    PlaySoundFile(soundFilePaths[41])
    double1Flag = true
end)




playerFrame.insuranceYesButton2:SetScript("OnClick", function()
    insuranceYesIcon2:Show()
    playerFrame.insuranceYesButton2:Disable()
    playerFrame.insuranceNoButton2:Disable()
    countdownDuration = 30
    playerFrame.timerText2:SetText("")
    playerFrame.timerText2:Hide()
    betInsuranceAmount2 = 0
    betMainAmount2 = tonumber(betEditBoxMain2:GetText())
    if betMainAmount2 then
        betInsuranceAmount2 = betMainAmount2 / 2
        SendChatMessage("[P2] YES to Insurance - adding " .. betInsuranceAmount2 .. "G", "RAID")
        playerFrame.insuranceBetAmount2:SetText(betInsuranceAmount2 .. " G")
    end
end)

playerFrame.insuranceNoButton2:SetScript("OnClick", function()
    insuranceNoIcon2:Show()
    playerFrame.insuranceYesButton2:Disable()
    playerFrame.insuranceNoButton2:Disable()
    countdownDuration = 30
    playerFrame.timerText2:SetText("")
    playerFrame.timerText2:Hide()
    SendChatMessage("[P2] NO to Insurance", "RAID")
end)

playerFrame.hitButton2:SetScript("OnClick", function()
    -- Handle the "hit" button action
    SendChatMessage("[P2] Hit", "RAID")
    playerFrame.hitButton2:Disable()
    playerFrame.standButton2:Disable()
    playerFrame.doubleButton2:Disable()
    playerFrame.splitButton2:Disable()
    playerFrame.timerText2:SetText("")
    playerFrame.timerText2:Hide()
    if playerFrame.numberDealerText:GetText() == "1 or 11" and playerFrame.insuranceYesButton2:IsEnabled() and playerFrame.insuranceNoButton2:IsEnabled() then
        SendChatMessage("[P2] NO to Insurance", "RAID")
        playerFrame.insuranceYesButton2:Disable()
        playerFrame.insuranceNoButton2:Disable()
        insuranceNoIcon2:Show()
    end
    PlaySoundFile(soundFilePaths[39])
    double2Flag = true
end)

playerFrame.standButton2:SetScript("OnClick", function()
    -- Handle the "stand" button action
    SendChatMessage("[P2] Stand", "RAID")
    playerFrame.hitButton2:Disable()
    playerFrame.standButton2:Disable()
    playerFrame.doubleButton2:Disable()
    playerFrame.splitButton2:Disable()
    playerFrame.timerText2:SetText("")
    playerFrame.timerText2:Hide()
    if playerFrame.numberPlayer2Text:GetText() == "1 or 11" then
        playerFrame.numberPlayer2Text:SetText("11")
    elseif playerFrame.numberPlayer2Text:GetText() == "2 or 12" then
        playerFrame.numberPlayer2Text:SetText("12")
    elseif playerFrame.numberPlayer2Text:GetText() == "3 or 13" then
        playerFrame.numberPlayer2Text:SetText("13")
    elseif playerFrame.numberPlayer2Text:GetText() == "4 or 14" then
        playerFrame.numberPlayer2Text:SetText("14")
    elseif playerFrame.numberPlayer2Text:GetText() == "5 or 15" then
        playerFrame.numberPlayer2Text:SetText("15")
    elseif playerFrame.numberPlayer2Text:GetText() == "6 or 16" then
        playerFrame.numberPlayer2Text:SetText("16")
    elseif playerFrame.numberPlayer2Text:GetText() == "7 or 17" then
        playerFrame.numberPlayer2Text:SetText("17")
    elseif playerFrame.numberPlayer2Text:GetText() == "8 or 18" then
        playerFrame.numberPlayer2Text:SetText("18")
    elseif playerFrame.numberPlayer2Text:GetText() == "9 or 19" then
        playerFrame.numberPlayer2Text:SetText("19")
    elseif playerFrame.numberPlayer2Text:GetText() == "10 or 20" then
        playerFrame.numberPlayer2Text:SetText("20")
    end
    if playerFrame.numberDealerText:GetText() == "1 or 11" and playerFrame.insuranceYesButton2:IsEnabled() and playerFrame.insuranceNoButton2:IsEnabled() then
        SendChatMessage("[P2] NO to Insurance", "RAID")
        playerFrame.insuranceYesButton2:Disable()
        playerFrame.insuranceNoButton2:Disable()
        insuranceNoIcon2:Show()
    end
    PlaySoundFile(soundFilePaths[40])
    if Player1Active and Player2Active and not Player3Active and not Player4Active and not Player5Active then
        turn = 17
    end
    double2Flag = true
end)

playerFrame.doubleButton2:SetScript("OnClick", function()
    local betDoubleAmount2 = 0
    betAmount2 = tonumber(betEditBoxMain2:GetText()) -- Get the entered bet amount
    if betAmount2 then
        betDoubleAmount2 = betAmount2 * 2
        SendChatMessage("[P2] Double my bet to " ..betDoubleAmount2.. "G", "RAID")
        betEditBoxMain1:SetText(betDoubleAmount2)
        playerFrame.hitButton2:Disable()
        playerFrame.standButton2:Disable()
        playerFrame.doubleButton2:Disable() 
        playerFrame.timerText2:SetText("")
        playerFrame.timerText2:Hide()
        countdownDuration = 30
    end
    if playerFrame.numberDealerText:GetText() == "1 or 11" and playerFrame.insuranceYesButton2:IsEnabled() and playerFrame.insuranceNoButton2:IsEnabled() then
        SendChatMessage("[P2] NO to Insurance", "RAID")
        playerFrame.insuranceYesButton2:Disable()
        playerFrame.insuranceNoButton2:Disable()
        insuranceNoIcon2:Show()
    end
    PlaySoundFile(soundFilePaths[41])
    double2Flag = true
end)







playerFrame.leaveTableButton:SetScript("OnClick", function()
    -- Handle the "leaving" action, communicate with players, and change game state
    SendChatMessage("{circle} I am leaving the table.", "RAID")
    playerFrame:Hide()
    initialFrame:Show()
end)


-- Add a click event handler to the "Join Table" button
initialFrame.joinButton:SetScript("OnClick", function(self, button, down)
    if button == "LeftButton" then
        -- Hide the initial frame
        initialFrame:Hide()
        -- Show the playerFrame
        playerFrame:Show()
        SendChatMessage("{circle} I have joined the table.", "RAID")
        -- You can add more code here to initialize the playerFrame or start the game.
    end
end)


-- Slash command handler for the player
SlashCmdList["BJ"] = function(msg)
    if msg == "join" then
        initialFrame:Show()
        -- Handle the "/blackjack join" command
    else
        print("Invalid command. Usage: /bj join")
    end
end

-- Register the slash command
SLASH_BJ1 = "/bj"