-- Set the minimum and maximum bet limits
minBetMain = 50
maxBetMain = 2000
minBetPP = 5
maxBetPP = 500
minBet213 = 5
maxBet213 = 500

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

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

player1totalBetAmount = 0
player2totalBetAmount = 0
player1totalWin = 0
player2totalWin = 0
player1totalLoss = 0
player2totalLoss = 0
player1totalProfit = 0
player2totalProfit = 0

player1PPSideBetWin = false
player1213SideBetWin = false
player2PPSideBetWin = false
player2213SideBetWin = false

Player1Active = false
Player2Active = false
Player3Active = false
Player4Active = false
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\\BlackjackPlayer\\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 = {}

local dealtCards = {}






















-- 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("Blackjack Player v2.1.4  |  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\\BlackjackPlayer\\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, -123)
playerFrame.historyButton:SetSize(80, 30)
playerFrame.historyButton:SetText("History")

-- Creating the History button
playerFrame.rebetButton = CreateFrame("Button", nil, playerFrame, "GameMenuButtonTemplate")
playerFrame.rebetButton:SetPoint("TOPRIGHT", playerFrame, -23, -155)
playerFrame.rebetButton:SetSize(80, 30)
playerFrame.rebetButton:SetText("Rebet")

-- 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 - 2000 G\n     Side Bets:      5 G -   500 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")


-- 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)











-- Rebet window
-- Creating the rulesFrame
local rebetFrame = CreateFrame("Frame", "BlackjackPayoutsFrame", UIParent, "BasicFrameTemplateWithInset")
rebetFrame:SetSize(170, 140)
rebetFrame:SetPoint("RIGHT", playerFrame, 170, 0)
rebetFrame:SetFrameStrata("HIGH")
rebetFrame:SetFrameLevel(8)
rebetFrame:Hide()

-- Setting a title
rebetFrame.title = rebetFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rebetFrame.title:SetPoint("TOP", rebetFrame, -12, -5)
rebetFrame.title:SetText("Preload Bets")


-- Main Bet Text
rebetFrame.preloadMainBetText = rebetFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rebetFrame.preloadMainBetText:SetPoint("LEFT", rebetFrame, 13, 30)
rebetFrame.preloadMainBetText:SetJustifyH("LEFT")
rebetFrame.preloadMainBetText:SetText("Main Bet:")
rebetFrame.preloadMainBetText:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
rebetFrame.preloadMainBetText:Hide()

-- PP Side Bet Text
rebetFrame.preloadPPBetText = rebetFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rebetFrame.preloadPPBetText:SetPoint("LEFT", rebetFrame, 13, 8)
rebetFrame.preloadPPBetText:SetJustifyH("LEFT")
rebetFrame.preloadPPBetText:SetText("PP Side Bet:")
rebetFrame.preloadPPBetText:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
rebetFrame.preloadPPBetText:Hide()

-- PP Side Bet Text
rebetFrame.preload213BetText = rebetFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rebetFrame.preload213BetText:SetPoint("LEFT", rebetFrame, 13, -14)
rebetFrame.preload213BetText:SetJustifyH("LEFT")
rebetFrame.preload213BetText:SetText("21+3 Side Bet:")
rebetFrame.preload213BetText:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
rebetFrame.preload213BetText:Hide()


-- Wagers for Player 1
-- Main Bet
local player1PreloadEditBoxMainBet = CreateFrame("EditBox", nil, rebetFrame, "InputBoxTemplate")
player1PreloadEditBoxMainBet:SetSize(55, 30)
player1PreloadEditBoxMainBet:SetPoint("LEFT", rebetFrame, 100, 30)
player1PreloadEditBoxMainBet:SetAutoFocus(false)
player1PreloadEditBoxMainBet:SetNumeric(true)
player1PreloadEditBoxMainBet:Hide()
-- Perfect Pairs
local player1PreloadEditBoxPPBet = CreateFrame("EditBox", nil, rebetFrame, "InputBoxTemplate")
player1PreloadEditBoxPPBet:SetSize(35, 30)
player1PreloadEditBoxPPBet:SetPoint("LEFT", rebetFrame, 119, 8)
player1PreloadEditBoxPPBet:SetAutoFocus(false)
player1PreloadEditBoxPPBet:SetNumeric(true)
player1PreloadEditBoxPPBet:Hide()
-- 21+3
local player1PreloadEditBox213Bet = CreateFrame("EditBox", nil, rebetFrame, "InputBoxTemplate")
player1PreloadEditBox213Bet:SetSize(35, 30)
player1PreloadEditBox213Bet:SetPoint("LEFT", rebetFrame, 119, -14)
player1PreloadEditBox213Bet:SetAutoFocus(false)
player1PreloadEditBox213Bet:SetNumeric(true)
player1PreloadEditBox213Bet:Hide()

-- Player 1 Preload Bet button
local player1PreloadBetButton = CreateFrame("Button", nil, rebetFrame, "GameMenuButtonTemplate")
player1PreloadBetButton:SetPoint("BOTTOM", rebetFrame, 0, 14)
player1PreloadBetButton:SetSize(85, 25)
player1PreloadBetButton:SetText("Bet All")
player1PreloadBetButton:Hide()


-- Wagers for Player 2
-- Main Bet
local player2PreloadEditBoxMainBet = CreateFrame("EditBox", nil, rebetFrame, "InputBoxTemplate")
player2PreloadEditBoxMainBet:SetSize(55, 30)
player2PreloadEditBoxMainBet:SetPoint("LEFT", rebetFrame, 100, 30)
player2PreloadEditBoxMainBet:SetAutoFocus(false)
player2PreloadEditBoxMainBet:SetNumeric(true)
player2PreloadEditBoxMainBet:Hide()
-- Perfect Pairs
local player2PreloadEditBoxPPBet = CreateFrame("EditBox", nil, rebetFrame, "InputBoxTemplate")
player2PreloadEditBoxPPBet:SetSize(35, 30)
player2PreloadEditBoxPPBet:SetPoint("LEFT", rebetFrame, 119, 8)
player2PreloadEditBoxPPBet:SetAutoFocus(false)
player2PreloadEditBoxPPBet:SetNumeric(true)
player2PreloadEditBoxPPBet:Hide()
-- 21+3
local player2PreloadEditBox213Bet = CreateFrame("EditBox", nil, rebetFrame, "InputBoxTemplate")
player2PreloadEditBox213Bet:SetSize(35, 30)
player2PreloadEditBox213Bet:SetPoint("LEFT", rebetFrame, 119, -14)
player2PreloadEditBox213Bet:SetAutoFocus(false)
player2PreloadEditBox213Bet:SetNumeric(true)
player2PreloadEditBox213Bet:Hide()

-- Player 2 Preload Bet button
local player2PreloadBetButton = CreateFrame("Button", nil, rebetFrame, "GameMenuButtonTemplate")
player2PreloadBetButton:SetPoint("BOTTOM", rebetFrame, 0, 14)
player2PreloadBetButton:SetSize(85, 25)
player2PreloadBetButton:SetText("Bet All")
player2PreloadBetButton:Hide()










-- History window
-- Creating the rulesFrame
local historyFrame = CreateFrame("Frame", "BlackjackPayoutsFrame", UIParent, "BasicFrameTemplateWithInset")
historyFrame:SetSize(246, 105)
historyFrame:SetPoint("TOP", playerFrame, 2, -26)
historyFrame:SetFrameStrata("HIGH")
historyFrame:SetFrameLevel(8)
historyFrame:Hide()

-- Setting a title
historyFrame.title = historyFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
historyFrame.title:SetPoint("TOP", historyFrame, 0, -5)
historyFrame.title:SetText("Profit/Loss")

-- Total Wagered Text
historyFrame.totalWageredText = historyFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
historyFrame.totalWageredText:SetPoint("CENTER", historyFrame, -42, 12)
historyFrame.totalWageredText:SetJustifyH("RIGHT")
historyFrame.totalWageredText:SetText("Total Wagered:")
historyFrame.totalWageredText:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
historyFrame.totalWageredText:Hide()

-- Total Wagered Amount
historyFrame.player1totalWageredAmount = historyFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
historyFrame.player1totalWageredAmount:SetPoint("CENTER", historyFrame, 40, 12)
historyFrame.player1totalWageredAmount:SetJustifyH("LEFT")
historyFrame.player1totalWageredAmount:SetText("0 G")
historyFrame.player1totalWageredAmount:SetTextColor(1, 0.98, 0.557)
historyFrame.player1totalWageredAmount:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
historyFrame.player1totalWageredAmount:Hide()

historyFrame.player2totalWageredAmount = historyFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
historyFrame.player2totalWageredAmount:SetPoint("CENTER", historyFrame, 40, 12)
historyFrame.player2totalWageredAmount:SetJustifyH("LEFT")
historyFrame.player2totalWageredAmount:SetText("0 G")
historyFrame.player2totalWageredAmount:SetTextColor(1, 0.98, 0.557)
historyFrame.player2totalWageredAmount:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
historyFrame.player2totalWageredAmount:Hide()

-- Total Won Text
historyFrame.totalWonText = historyFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
historyFrame.totalWonText:SetPoint("CENTER", historyFrame, -30, -3)
historyFrame.totalWonText:SetJustifyH("RIGHT")
historyFrame.totalWonText:SetText("Total Won:")
historyFrame.totalWonText:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
historyFrame.totalWonText:Hide()

-- Total Won Amount
historyFrame.player1totalWonAmount = historyFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
historyFrame.player1totalWonAmount:SetPoint("CENTER", historyFrame, 40, -3)
historyFrame.player1totalWonAmount:SetJustifyH("LEFT")
historyFrame.player1totalWonAmount:SetText("0 G")
historyFrame.player1totalWonAmount:SetTextColor(1, 0.98, 0.557)
historyFrame.player1totalWonAmount:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
historyFrame.player1totalWonAmount:Hide()

historyFrame.player2totalWonAmount = historyFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
historyFrame.player2totalWonAmount:SetPoint("CENTER", historyFrame, 40, -3)
historyFrame.player2totalWonAmount:SetJustifyH("LEFT")
historyFrame.player2totalWonAmount:SetText("0 G")
historyFrame.player2totalWonAmount:SetTextColor(1, 0.98, 0.557)
historyFrame.player2totalWonAmount:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
historyFrame.player2totalWonAmount:Hide()

-- Total Lost Text
historyFrame.totalLostText = historyFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
historyFrame.totalLostText:SetPoint("CENTER", historyFrame, -28, -18)
historyFrame.totalLostText:SetJustifyH("RIGHT")
historyFrame.totalLostText:SetText("Total Lost:")
historyFrame.totalLostText:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
historyFrame.totalLostText:Hide()

-- Total Lost Amount
historyFrame.player1totalLostAmount = historyFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
historyFrame.player1totalLostAmount:SetPoint("CENTER", historyFrame, 40, -18)
historyFrame.player1totalLostAmount:SetJustifyH("LEFT")
historyFrame.player1totalLostAmount:SetText("0 G")
historyFrame.player1totalLostAmount:SetTextColor(1, 0.98, 0.557)
historyFrame.player1totalLostAmount:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
historyFrame.player1totalLostAmount:Hide()

historyFrame.player2totalLostAmount = historyFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
historyFrame.player2totalLostAmount:SetPoint("CENTER", historyFrame, 40, -18)
historyFrame.player2totalLostAmount:SetJustifyH("LEFT")
historyFrame.player2totalLostAmount:SetText("0 G")
historyFrame.player2totalLostAmount:SetTextColor(1, 0.98, 0.557)
historyFrame.player2totalLostAmount:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
historyFrame.player2totalLostAmount:Hide()

-- Profit Text
historyFrame.ProfitText = historyFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
historyFrame.ProfitText:SetPoint("CENTER", historyFrame, -16, -33)
historyFrame.ProfitText:SetJustifyH("RIGHT")
historyFrame.ProfitText:SetText("Profit:")
historyFrame.ProfitText:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
historyFrame.ProfitText:Hide()

-- Total Profit Amount
historyFrame.player1ProfitAmount = historyFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
historyFrame.player1ProfitAmount:SetPoint("CENTER", historyFrame, 40, -33)
historyFrame.player1ProfitAmount:SetJustifyH("LEFT")
historyFrame.player1ProfitAmount:SetText("0 G")
historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
historyFrame.player1ProfitAmount:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
historyFrame.player1ProfitAmount:Hide()

historyFrame.player2ProfitAmount = historyFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
historyFrame.player2ProfitAmount:SetPoint("CENTER", historyFrame, 40, -33)
historyFrame.player2ProfitAmount:SetJustifyH("LEFT")
historyFrame.player2ProfitAmount:SetText("0 G")
historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
historyFrame.player2ProfitAmount:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
historyFrame.player2ProfitAmount:Hide()















-- Rules window
-- Creating the rulesFrame
local rulesFrame = CreateFrame("Frame", "BlackjackPayoutsFrame", UIParent, "BasicFrameTemplateWithInset")
rulesFrame:SetSize(900, 546)
rulesFrame:SetPoint("CENTER", playerFrame, 0, 0)
rulesFrame:SetFrameStrata("HIGH")
rulesFrame:SetFrameLevel(5)
rulesFrame:Hide()

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

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


-- Text1
rulesFrame.rulesText1 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.rulesText1:SetPoint("TOP", rulesFrame, 20, -50)
rulesFrame.rulesText1:SetJustifyH("CENTER")
rulesFrame.rulesText1:SetText("Blackjack (otherwise known as '21') is a popular card game. The goal is to beat the dealer by having\n a hand value closer to 21 than the dealer's hand, without going over 21. Here are the basic rules:")
rulesFrame.rulesText1:SetFont("Fonts\\FRIZQT__.TTF", 14, "OUTLINE")
rulesFrame.rulesText1:Hide()

-- "Card Values" Heading
rulesFrame.HeadingText1 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.HeadingText1:SetPoint("CENTER", rulesFrame, -340, 150)
rulesFrame.HeadingText1:SetJustifyH("CENTER")
rulesFrame.HeadingText1:SetText("1. Card Values")
rulesFrame.HeadingText1:SetTextColor(1, 0.298, 0.298)
rulesFrame.HeadingText1:SetFont("Fonts\\FRIZQT__.TTF", 18, "OUTLINE")
rulesFrame.HeadingText1:Hide()


-- Text2
rulesFrame.rulesText2 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.rulesText2:SetPoint("CENTER", rulesFrame, -231, 100)
rulesFrame.rulesText2:SetJustifyH("LEFT")
rulesFrame.rulesText2:SetText("• Number cards (2-10) are worth their face value\n• Face cards (Jack, Queen, King) are each worth 10 points\n• Aces can be worth 1 or 11 points\n\nThe dealer uses the '/roll 1-13' in-game command\nto decide the card, which ensures a 100% random result")
rulesFrame.rulesText2:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
rulesFrame.rulesText2:Hide()

-- Text3
rulesFrame.rulesText3 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.rulesText3:SetPoint("CENTER", rulesFrame, -353, 10)
rulesFrame.rulesText3:SetJustifyH("LEFT")
rulesFrame.rulesText3:SetTextColor(0.969, 0.961, 0.42)
rulesFrame.rulesText3:SetText("1 = 1 or 11 (Ace)\n2 = 2\n3 = 3\n4 = 4\n5 = 5\n6 = 6\n7 = 7")
rulesFrame.rulesText3:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
rulesFrame.rulesText3:Hide()

-- Text4
rulesFrame.rulesText4 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.rulesText4:SetPoint("CENTER", rulesFrame, -210, 15)
rulesFrame.rulesText4:SetJustifyH("LEFT")
rulesFrame.rulesText4:SetTextColor(0.969, 0.961, 0.42)
rulesFrame.rulesText4:SetText("8 = 8\n9 = 9\n10 = 10\n11 = 10 (Jack)\n12 = 10 (Queen)\n13 = 10 (King)")
rulesFrame.rulesText4:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
rulesFrame.rulesText4:Hide()

-- "Starting the Game" Heading
rulesFrame.HeadingText2 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.HeadingText2:SetPoint("CENTER", rulesFrame, -308, -65)
rulesFrame.HeadingText2:SetJustifyH("CENTER")
rulesFrame.HeadingText2:SetText("2. Starting the Game")
rulesFrame.HeadingText2:SetTextColor(1, 0.298, 0.298)
rulesFrame.HeadingText2:SetFont("Fonts\\FRIZQT__.TTF", 18, "OUTLINE")
rulesFrame.HeadingText2:Hide()

-- Text5
rulesFrame.rulesText5 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.rulesText5:SetPoint("CENTER", rulesFrame, -229, -105)
rulesFrame.rulesText5:SetJustifyH("LEFT")
rulesFrame.rulesText5:SetText("• Players place their bets (within the table limits) and trade\n the dealer the total amount of gold\n• Each player receives two cards - the dealer only receives\n one card (known as the 'upcard')")
rulesFrame.rulesText5:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
rulesFrame.rulesText5:Hide()

-- "Player's Turn" Heading
rulesFrame.HeadingText3 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.HeadingText3:SetPoint("CENTER", rulesFrame, -333, -160)
rulesFrame.HeadingText3:SetJustifyH("CENTER")
rulesFrame.HeadingText3:SetText("3. Player's Turn")
rulesFrame.HeadingText3:SetTextColor(1, 0.298, 0.298)
rulesFrame.HeadingText3:SetFont("Fonts\\FRIZQT__.TTF", 18, "OUTLINE")
rulesFrame.HeadingText3:Hide()

-- Text6
rulesFrame.rulesText6 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.rulesText6:SetPoint("CENTER", rulesFrame, -233, -206)
rulesFrame.rulesText6:SetJustifyH("LEFT")
rulesFrame.rulesText6:SetText("• Players decide to 'Hit' (take another card), 'Stand'\n (keep their current total) or 'Double' (double their bet for\n one extra card only)\n• Players can continue to hit as many times as they like\n but if they exceed 21, they bust and lose the round")
rulesFrame.rulesText6:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
rulesFrame.rulesText6:Hide()

-- "Dealer's Turn" Heading
rulesFrame.HeadingText4 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.HeadingText4:SetPoint("CENTER", rulesFrame, 124, 150)
rulesFrame.HeadingText4:SetJustifyH("CENTER")
rulesFrame.HeadingText4:SetText("4. Dealer's Turn")
rulesFrame.HeadingText4:SetTextColor(1, 0.298, 0.298)
rulesFrame.HeadingText4:SetFont("Fonts\\FRIZQT__.TTF", 18, "OUTLINE")
rulesFrame.HeadingText4:Hide()

-- Text7
rulesFrame.rulesText7 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.rulesText7:SetPoint("CENTER", rulesFrame, 217, 117)
rulesFrame.rulesText7:SetJustifyH("LEFT")
rulesFrame.rulesText7:SetText("• Once all players have finished their turns, the dealer\n will begin their turn\n• The dealer must hit until their hand totals 17 or higher")
rulesFrame.rulesText7:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
rulesFrame.rulesText7:Hide()

-- "Win / Push / Loss" Heading
rulesFrame.HeadingText5 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.HeadingText5:SetPoint("CENTER", rulesFrame, 145, 64)
rulesFrame.HeadingText5:SetJustifyH("CENTER")
rulesFrame.HeadingText5:SetText("5. Win / Push / Loss")
rulesFrame.HeadingText5:SetTextColor(1, 0.298, 0.298)
rulesFrame.HeadingText5:SetFont("Fonts\\FRIZQT__.TTF", 18, "OUTLINE")
rulesFrame.HeadingText5:Hide()

-- "WIN" Heading
rulesFrame.HeadingText6 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.HeadingText6:SetPoint("CENTER", rulesFrame, 70, 42)
rulesFrame.HeadingText6:SetJustifyH("CENTER")
rulesFrame.HeadingText6:SetText("WIN:")
rulesFrame.HeadingText6:SetTextColor(0.325, 0.98, 0.365)
rulesFrame.HeadingText6:SetFont("Fonts\\FRIZQT__.TTF", 14, "OUTLINE")
rulesFrame.HeadingText6:Hide()

-- Text8
rulesFrame.rulesText8 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.rulesText8:SetPoint("CENTER", rulesFrame, 221, 1)
rulesFrame.rulesText8:SetJustifyH("LEFT")
rulesFrame.rulesText8:SetText("• If the players hand is closer to 21 (without going over)\n than the dealer\n• If the dealer busts (goes over 21)\n• If the player has Blackjack (see below) and the dealer's\n upcard is not an Ace or 10")
rulesFrame.rulesText8:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
rulesFrame.rulesText8:Hide()

-- "PUSH" Heading
rulesFrame.HeadingText7 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.HeadingText7:SetPoint("CENTER", rulesFrame, 75, -48)
rulesFrame.HeadingText7:SetJustifyH("CENTER")
rulesFrame.HeadingText7:SetText("PUSH:")
rulesFrame.HeadingText7:SetTextColor(0.275, 0.635, 1)
rulesFrame.HeadingText7:SetFont("Fonts\\FRIZQT__.TTF", 14, "OUTLINE")
rulesFrame.HeadingText7:Hide()

-- Text9
rulesFrame.rulesText9 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.rulesText9:SetPoint("CENTER", rulesFrame, 217, -72)
rulesFrame.rulesText9:SetJustifyH("LEFT")
rulesFrame.rulesText9:SetText("• If the player and dealer have the same hand value, it's\n a push (a tie), and the players bet is returned")
rulesFrame.rulesText9:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
rulesFrame.rulesText9:Hide()

-- "LOSS" Heading
rulesFrame.HeadingText8 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.HeadingText8:SetPoint("CENTER", rulesFrame, 74, -105)
rulesFrame.HeadingText8:SetJustifyH("CENTER")
rulesFrame.HeadingText8:SetText("LOSS:")
rulesFrame.HeadingText8:SetTextColor(1, 0.212, 0.212)
rulesFrame.HeadingText8:SetFont("Fonts\\FRIZQT__.TTF", 14, "OUTLINE")
rulesFrame.HeadingText8:Hide()

-- Text10
rulesFrame.rulesText10 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.rulesText10:SetPoint("CENTER", rulesFrame, 204, -134)
rulesFrame.rulesText10:SetJustifyH("LEFT")
rulesFrame.rulesText10:SetText("• If the players hand is less than the dealer (without\n going over 21)\n• If the player busts (goes over 21)")
rulesFrame.rulesText10:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
rulesFrame.rulesText10:Hide()

-- "Blackjack" Heading
rulesFrame.HeadingText9 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.HeadingText9:SetPoint("CENTER", rulesFrame, 107, -182)
rulesFrame.HeadingText9:SetJustifyH("CENTER")
rulesFrame.HeadingText9:SetText("6. Blackjack")
rulesFrame.HeadingText9:SetTextColor(1, 0.298, 0.298)
rulesFrame.HeadingText9:SetFont("Fonts\\FRIZQT__.TTF", 18, "OUTLINE")
rulesFrame.HeadingText9:Hide()

-- Text11
rulesFrame.rulesText11 = rulesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
rulesFrame.rulesText11:SetPoint("CENTER", rulesFrame, 209, -217)
rulesFrame.rulesText11:SetJustifyH("LEFT")
rulesFrame.rulesText11:SetText("• A 'Blackjack' is a special hand consisting of an Ace\n and a 10-point card. It pays out at 3:2 instead of a\n regular 1:1 win")
rulesFrame.rulesText11:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
rulesFrame.rulesText11:Hide()








-- 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, -90)
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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\Images\\AS.tga")
payoutsFrame.card25image:SetBlendMode("BLEND")
payoutsFrame.card25image:SetDrawLayer("ARTWORK")
payoutsFrame.card25image:Hide()






-- Rebet button click
playerFrame.rebetButton:SetScript("OnClick", function()

    if rebetFrame:IsShown() then
        rebetFrame:Hide()
        rebetFrame.preloadMainBetText:Hide()
        rebetFrame.preloadPPBetText:Hide()
        rebetFrame.preload213BetText:Hide()

        if playerName == unitName1 then
            player1PreloadEditBoxMainBet:Hide()
            player1PreloadEditBoxPPBet:Hide()
            player1PreloadEditBox213Bet:Hide()
            player1PreloadBetButton:Hide()
        elseif playerName == unitName2 then
            player2PreloadEditBoxMainBet:Hide()
            player2PreloadEditBoxPPBet:Hide()
            player2PreloadEditBox213Bet:Hide()
            player2PreloadBetButton:Hide()
        end

    else
        rebetFrame:Show()
        rebetFrame.preloadMainBetText:Show()
        rebetFrame.preloadPPBetText:Show()
        rebetFrame.preload213BetText:Show()

        if playerName == unitName1 then
            player1PreloadEditBoxMainBet:Show()
            player1PreloadEditBoxPPBet:Show()
            player1PreloadEditBox213Bet:Show()
            player1PreloadBetButton:Show()
        elseif playerName == unitName2 then
            player2PreloadEditBoxMainBet:Show()
            player2PreloadEditBoxPPBet:Show()
            player2PreloadEditBox213Bet:Show()
            player2PreloadBetButton:Show()
        end

    end
end)














-- History button click
playerFrame.historyButton:SetScript("OnClick", function()

    if historyFrame:IsShown() then
        historyFrame:Hide()
        historyFrame.totalWageredText:Hide()
        historyFrame.totalWonText:Hide()
        historyFrame.totalLostText:Hide()
        historyFrame.ProfitText:Hide()

        if playerName == unitName1 then
            historyFrame.player1totalWageredAmount:Hide()
            historyFrame.player1totalWonAmount:Hide()
            historyFrame.player1totalLostAmount:Hide()
            historyFrame.player1ProfitAmount:Hide()
        elseif playerName == unitName2 then
            historyFrame.player2totalWageredAmount:Hide()
            historyFrame.player2totalWonAmount:Hide()
            historyFrame.player2totalLostAmount:Hide()
            historyFrame.player2ProfitAmount:Hide()
        end

    else
        historyFrame:Show()
        historyFrame.totalWageredText:Show()
        historyFrame.totalWonText:Show()
        historyFrame.totalLostText:Show()
        historyFrame.ProfitText:Show()

        if playerName == unitName1 then
            historyFrame.player1totalWageredAmount:Show()
            historyFrame.player1totalWonAmount:Show()
            historyFrame.player1totalLostAmount:Show()
            historyFrame.player1ProfitAmount:Show()
        elseif playerName == unitName2 then
            historyFrame.player2totalWageredAmount:Show()
            historyFrame.player2totalWonAmount:Show()
            historyFrame.player2totalLostAmount:Show()
            historyFrame.player2ProfitAmount:Show()
        end

    end
end)


function resetHistory()
    player1totalBetAmount = 0
    player2totalBetAmount = 0
    player1totalWin = 0
    player2totalWin = 0
    player1totalLoss = 0
    player2totalLoss = 0
    player1totalProfit = 0
    player2totalProfit = 0
    historyFrame.player1totalWageredAmount:SetText("0 G")
    historyFrame.player2totalWageredAmount:SetText("0 G")
    historyFrame.player1totalWonAmount:SetText("0 G")
    historyFrame.player2totalWonAmount:SetText("0 G")
    historyFrame.player1totalLostAmount:SetText("0 G")
    historyFrame.player2totalLostAmount:SetText("0 G")
    historyFrame.player1ProfitAmount:SetText("0 G")
    historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
    historyFrame.player2ProfitAmount:SetText("0 G")
    historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
end










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



-- Rules button click function
playerFrame.RulesButton:SetScript("OnClick", function()
    if rulesFrame:IsShown() then
        rulesFrame:Hide()
        rulesFrame.rulesText1:Hide()
        rulesFrame.rulesText2:Hide()
        rulesFrame.rulesText3:Hide()
        rulesFrame.rulesText4:Hide()
        rulesFrame.rulesText5:Hide()
        rulesFrame.rulesText6:Hide()
        rulesFrame.rulesText7:Hide()
        rulesFrame.rulesText8:Hide()
        rulesFrame.rulesText9:Hide()
        rulesFrame.rulesText10:Hide()
        rulesFrame.rulesText11:Hide()
        rulesFrame.HeadingText1:Hide()
        rulesFrame.HeadingText2:Hide()
        rulesFrame.HeadingText3:Hide()
        rulesFrame.HeadingText4:Hide()
        rulesFrame.HeadingText5:Hide()
        rulesFrame.HeadingText6:Hide()
        rulesFrame.HeadingText7:Hide()
        rulesFrame.HeadingText8:Hide()
        rulesFrame.HeadingText9:Hide()
    else
        rulesFrame:Show()
        rulesFrame.rulesText1:Show()
        rulesFrame.rulesText2:Show()
        rulesFrame.rulesText3:Show()
        rulesFrame.rulesText4:Show()
        rulesFrame.rulesText5:Show()
        rulesFrame.rulesText6:Show()
        rulesFrame.rulesText7:Show()
        rulesFrame.rulesText8:Show()
        rulesFrame.rulesText9:Show()
        rulesFrame.rulesText10:Show()
        rulesFrame.rulesText11:Show()
        rulesFrame.HeadingText1:Show()
        rulesFrame.HeadingText2:Show()
        rulesFrame.HeadingText3:Show()
        rulesFrame.HeadingText4:Show()
        rulesFrame.HeadingText5:Show()
        rulesFrame.HeadingText6:Show()
        rulesFrame.HeadingText7:Show()
        rulesFrame.HeadingText8:Show()
        rulesFrame.HeadingText9:Show()
    end
end)






-- 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)












-- sideBet Notification window
-- Creating the sideBetWinFrame
local sideBetWinFrame = CreateFrame("Frame", "BlackjackPayoutsFrame", UIParent, "BasicFrameTemplateWithInset")
sideBetWinFrame:SetSize(325, 180)
sideBetWinFrame:SetPoint("TOPLEFT", playerFrame, 0, 0)
sideBetWinFrame:SetFrameStrata("HIGH")
sideBetWinFrame:SetFrameLevel(2)
sideBetWinFrame:Hide()

-- Setting a title
sideBetWinFrame.title = sideBetWinFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
sideBetWinFrame.title:SetPoint("TOP", sideBetWinFrame, 0, -6)
sideBetWinFrame.title:SetText("Side Bet Notification")
sideBetWinFrame.title:Hide()

sideBetWinFrame.PPtext = sideBetWinFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
sideBetWinFrame.PPtext:SetPoint("TOPLEFT", sideBetWinFrame, 5, -5)
sideBetWinFrame.PPtext:SetJustifyH("CENTER")
sideBetWinFrame.PPtext:SetText("PP")
sideBetWinFrame.PPtext:SetTextColor(1, 0.298, 0.298)
sideBetWinFrame.PPtext:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
sideBetWinFrame.PPtext:Hide()

sideBetWinFrame.t213text = sideBetWinFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
sideBetWinFrame.t213text:SetPoint("TOPLEFT", sideBetWinFrame, 5, -5)
sideBetWinFrame.t213text:SetJustifyH("CENTER")
sideBetWinFrame.t213text:SetText("21+3")
sideBetWinFrame.t213text:SetTextColor(1, 0.298, 0.298)
sideBetWinFrame.t213text:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
sideBetWinFrame.t213text:Hide()

sideBetWinFrame.MixedPairText = sideBetWinFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
sideBetWinFrame.MixedPairText:SetPoint("TOP", sideBetWinFrame, 0, -31)
sideBetWinFrame.MixedPairText:SetJustifyH("CENTER")
sideBetWinFrame.MixedPairText:SetText("You hit a Mixed Pair!\nPayout is 5:1")
sideBetWinFrame.MixedPairText:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
sideBetWinFrame.MixedPairText:Hide()

sideBetWinFrame.ColouredPairText = sideBetWinFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
sideBetWinFrame.ColouredPairText:SetPoint("TOP", sideBetWinFrame, 0, -31)
sideBetWinFrame.ColouredPairText:SetJustifyH("CENTER")
sideBetWinFrame.ColouredPairText:SetText("You hit a Coloured Pair!\nPayout is 10:1")
sideBetWinFrame.ColouredPairText:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
sideBetWinFrame.ColouredPairText:Hide()

sideBetWinFrame.PerfectPairText = sideBetWinFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
sideBetWinFrame.PerfectPairText:SetPoint("TOP", sideBetWinFrame, 0, -31)
sideBetWinFrame.PerfectPairText:SetJustifyH("CENTER")
sideBetWinFrame.PerfectPairText:SetText("You hit a Perfect Pair!\nPayout is 30:1")
sideBetWinFrame.PerfectPairText:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
sideBetWinFrame.PerfectPairText:Hide()

sideBetWinFrame.FlushText = sideBetWinFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
sideBetWinFrame.FlushText:SetPoint("TOP", sideBetWinFrame, 0, -31)
sideBetWinFrame.FlushText:SetJustifyH("CENTER")
sideBetWinFrame.FlushText:SetText("You hit a Flush!\nPayout is 5:1")
sideBetWinFrame.FlushText:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
sideBetWinFrame.FlushText:Hide()

sideBetWinFrame.StraightText = sideBetWinFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
sideBetWinFrame.StraightText:SetPoint("TOP", sideBetWinFrame, 0, -31)
sideBetWinFrame.StraightText:SetJustifyH("CENTER")
sideBetWinFrame.StraightText:SetText("You hit a Straight!\nPayout is 10:1")
sideBetWinFrame.StraightText:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
sideBetWinFrame.StraightText:Hide()

sideBetWinFrame.ThreeOfAKindText = sideBetWinFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
sideBetWinFrame.ThreeOfAKindText:SetPoint("TOP", sideBetWinFrame, 0, -31)
sideBetWinFrame.ThreeOfAKindText:SetJustifyH("CENTER")
sideBetWinFrame.ThreeOfAKindText:SetText("You hit a Three of a Kind!\nPayout is 30:1")
sideBetWinFrame.ThreeOfAKindText:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
sideBetWinFrame.ThreeOfAKindText:Hide()

sideBetWinFrame.StraightFlushText = sideBetWinFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
sideBetWinFrame.StraightFlushText:SetPoint("TOP", sideBetWinFrame, 0, -31)
sideBetWinFrame.StraightFlushText:SetJustifyH("CENTER")
sideBetWinFrame.StraightFlushText:SetText("You hit a Straight Flush!\nPayout is 40:1")
sideBetWinFrame.StraightFlushText:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
sideBetWinFrame.StraightFlushText:Hide()

sideBetWinFrame.SuitedThreeOfAKindText = sideBetWinFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
sideBetWinFrame.SuitedThreeOfAKindText:SetPoint("TOP", sideBetWinFrame, 0, -31)
sideBetWinFrame.SuitedThreeOfAKindText:SetJustifyH("CENTER")
sideBetWinFrame.SuitedThreeOfAKindText:SetText("You hit a Suited Three of a Kind!\nPayout is 100:1")
sideBetWinFrame.SuitedThreeOfAKindText:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
sideBetWinFrame.SuitedThreeOfAKindText:Hide()






sideBetWinFrame.player1PPCardImage1 = sideBetWinFrame:CreateTexture(nil, "OVERLAY")
sideBetWinFrame.player1PPCardImage1:SetSize(72, 144)
sideBetWinFrame.player1PPCardImage1:SetPoint("CENTER", sideBetWinFrame, -40, -23)
sideBetWinFrame.player1PPCardImage1:SetBlendMode("BLEND")
sideBetWinFrame.player1PPCardImage1:SetDrawLayer("ARTWORK")
sideBetWinFrame.player1PPCardImage1:Hide()

sideBetWinFrame.player1PPCardImage2 = sideBetWinFrame:CreateTexture(nil, "OVERLAY")
sideBetWinFrame.player1PPCardImage2:SetSize(72, 144)
sideBetWinFrame.player1PPCardImage2:SetPoint("CENTER", sideBetWinFrame, 40, -23)
sideBetWinFrame.player1PPCardImage2:SetBlendMode("BLEND")
sideBetWinFrame.player1PPCardImage2:SetDrawLayer("ARTWORK")
sideBetWinFrame.player1PPCardImage2:Hide()

sideBetWinFrame.player1213CardImage1 = sideBetWinFrame:CreateTexture(nil, "OVERLAY")
sideBetWinFrame.player1213CardImage1:SetSize(72, 144)
sideBetWinFrame.player1213CardImage1:SetPoint("CENTER", sideBetWinFrame, -100, -23)
sideBetWinFrame.player1213CardImage1:SetBlendMode("BLEND")
sideBetWinFrame.player1213CardImage1:SetDrawLayer("ARTWORK")
sideBetWinFrame.player1213CardImage1:Hide()

sideBetWinFrame.player1213CardImage2 = sideBetWinFrame:CreateTexture(nil, "OVERLAY")
sideBetWinFrame.player1213CardImage2:SetSize(72, 144)
sideBetWinFrame.player1213CardImage2:SetPoint("CENTER", sideBetWinFrame, -20, -23)
sideBetWinFrame.player1213CardImage2:SetBlendMode("BLEND")
sideBetWinFrame.player1213CardImage2:SetDrawLayer("ARTWORK")
sideBetWinFrame.player1213CardImage2:Hide()

sideBetWinFrame.dealer213CardImage1 = sideBetWinFrame:CreateTexture(nil, "OVERLAY")
sideBetWinFrame.dealer213CardImage1:SetSize(72, 144)
sideBetWinFrame.dealer213CardImage1:SetPoint("CENTER", sideBetWinFrame, 100, -23)
sideBetWinFrame.dealer213CardImage1:SetBlendMode("BLEND")
sideBetWinFrame.dealer213CardImage1:SetDrawLayer("ARTWORK")
sideBetWinFrame.dealer213CardImage1:Hide()





sideBetWinFrame.player2PPCardImage1 = sideBetWinFrame:CreateTexture(nil, "OVERLAY")
sideBetWinFrame.player2PPCardImage1:SetSize(72, 144)
sideBetWinFrame.player2PPCardImage1:SetPoint("CENTER", sideBetWinFrame, -40, -23)
sideBetWinFrame.player2PPCardImage1:SetBlendMode("BLEND")
sideBetWinFrame.player2PPCardImage1:SetDrawLayer("ARTWORK")
sideBetWinFrame.player2PPCardImage1:Hide()

sideBetWinFrame.player2PPCardImage2 = sideBetWinFrame:CreateTexture(nil, "OVERLAY")
sideBetWinFrame.player2PPCardImage2:SetSize(72, 144)
sideBetWinFrame.player2PPCardImage2:SetPoint("CENTER", sideBetWinFrame, 40, -23)
sideBetWinFrame.player2PPCardImage2:SetBlendMode("BLEND")
sideBetWinFrame.player2PPCardImage2:SetDrawLayer("ARTWORK")
sideBetWinFrame.player2PPCardImage2:Hide()

sideBetWinFrame.player2213CardImage1 = sideBetWinFrame:CreateTexture(nil, "OVERLAY")
sideBetWinFrame.player2213CardImage1:SetSize(72, 144)
sideBetWinFrame.player2213CardImage1:SetPoint("CENTER", sideBetWinFrame, -100, -23)
sideBetWinFrame.player2213CardImage1:SetBlendMode("BLEND")
sideBetWinFrame.player2213CardImage1:SetDrawLayer("ARTWORK")
sideBetWinFrame.player2213CardImage1:Hide()

sideBetWinFrame.player2213CardImage2 = sideBetWinFrame:CreateTexture(nil, "OVERLAY")
sideBetWinFrame.player2213CardImage2:SetSize(72, 144)
sideBetWinFrame.player2213CardImage2:SetPoint("CENTER", sideBetWinFrame, -20, -23)
sideBetWinFrame.player2213CardImage2:SetBlendMode("BLEND")
sideBetWinFrame.player2213CardImage2:SetDrawLayer("ARTWORK")
sideBetWinFrame.player2213CardImage2:Hide()

sideBetWinFrame.player2213CardImage3 = sideBetWinFrame:CreateTexture(nil, "OVERLAY")
sideBetWinFrame.player2213CardImage3:SetSize(72, 144)
sideBetWinFrame.player2213CardImage3:SetPoint("CENTER", sideBetWinFrame, 100, -23)
sideBetWinFrame.player2213CardImage3:SetBlendMode("BLEND")
sideBetWinFrame.player2213CardImage3:SetDrawLayer("ARTWORK")
sideBetWinFrame.player2213CardImage3:Hide()




sideBetWinFrame.PlusSymbol = sideBetWinFrame:CreateTexture(nil, "OVERLAY")
sideBetWinFrame.PlusSymbol:SetSize(32, 32)
sideBetWinFrame.PlusSymbol:SetPoint("CENTER", sideBetWinFrame, 40, -23)
sideBetWinFrame.PlusSymbol:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\PlusSymbol.tga")
sideBetWinFrame.PlusSymbol:SetBlendMode("BLEND")
sideBetWinFrame.PlusSymbol:SetDrawLayer("ARTWORK")
sideBetWinFrame.PlusSymbol:Hide()



function player1MixedPairNotification()
    sideBetWinFrame:Show()
    sideBetWinFrame.title:Show()
    sideBetWinFrame.PPtext:Show()
    sideBetWinFrame.MixedPairText:Show()
    sideBetWinFrame.player1PPCardImage1:Show()
    sideBetWinFrame.player1PPCardImage2:Show()
end

function player1ColouredPairNotification()
    sideBetWinFrame:Show()
    sideBetWinFrame.title:Show()
    sideBetWinFrame.PPtext:Show()
    sideBetWinFrame.ColouredPairText:Show()
    sideBetWinFrame.player1PPCardImage1:Show()
    sideBetWinFrame.player1PPCardImage2:Show()
end

function player1PerfectPairNotification()
    sideBetWinFrame:Show()
    sideBetWinFrame.title:Show()
    sideBetWinFrame.PPtext:Show()
    sideBetWinFrame.PerfectPairText:Show()
    sideBetWinFrame.player1PPCardImage1:Show()
    sideBetWinFrame.player1PPCardImage2:Show()
end

function player1SuitedThreeOfAKindNotification()
    sideBetWinFrame:Show()
    sideBetWinFrame.title:Show()
    sideBetWinFrame.t213text:Show()
    sideBetWinFrame.SuitedThreeOfAKindText:Show()
    sideBetWinFrame.player1213CardImage1:Show()
    sideBetWinFrame.player1213CardImage2:Show()
    sideBetWinFrame.dealer213CardImage1:Show()
    sideBetWinFrame.PlusSymbol:Show()
end

function player1StraightFlushNotification()
    sideBetWinFrame:Show()
    sideBetWinFrame.title:Show()
    sideBetWinFrame.t213text:Show()
    sideBetWinFrame.StraightFlushText:Show()
    sideBetWinFrame.player1213CardImage1:Show()
    sideBetWinFrame.player1213CardImage2:Show()
    sideBetWinFrame.dealer213CardImage1:Show()
    sideBetWinFrame.PlusSymbol:Show()
end

function player1ThreeOfAKindNotification()
    sideBetWinFrame:Show()
    sideBetWinFrame.title:Show()
    sideBetWinFrame.t213text:Show()
    sideBetWinFrame.ThreeOfAKindText:Show()
    sideBetWinFrame.player1213CardImage1:Show()
    sideBetWinFrame.player1213CardImage2:Show()
    sideBetWinFrame.dealer213CardImage1:Show()
    sideBetWinFrame.PlusSymbol:Show()
end

function player1StraightNotification()
    sideBetWinFrame:Show()
    sideBetWinFrame.title:Show()
    sideBetWinFrame.t213text:Show()
    sideBetWinFrame.StraightText:Show()
    sideBetWinFrame.player1213CardImage1:Show()
    sideBetWinFrame.player1213CardImage2:Show()
    sideBetWinFrame.dealer213CardImage1:Show()
    sideBetWinFrame.PlusSymbol:Show()
end

function player1FlushNotification()
    sideBetWinFrame:Show()
    sideBetWinFrame.title:Show()
    sideBetWinFrame.t213text:Show()
    sideBetWinFrame.FlushText:Show()
    sideBetWinFrame.player1213CardImage1:Show()
    sideBetWinFrame.player1213CardImage2:Show()
    sideBetWinFrame.dealer213CardImage1:Show()
    sideBetWinFrame.PlusSymbol:Show()
end
















function player2MixedPairNotification()
    sideBetWinFrame:Show()
    sideBetWinFrame.title:Show()
    sideBetWinFrame.PPtext:Show()
    sideBetWinFrame.MixedPairText:Show()
    sideBetWinFrame.player2PPCardImage1:Show()
    sideBetWinFrame.player2PPCardImage2:Show()
end

function player2ColouredPairNotification()
    sideBetWinFrame:Show()
    sideBetWinFrame.title:Show()
    sideBetWinFrame.PPtext:Show()
    sideBetWinFrame.ColouredPairText:Show()
    sideBetWinFrame.player2PPCardImage1:Show()
    sideBetWinFrame.player2PPCardImage2:Show()
end

function player2PerfectPairNotification()
    sideBetWinFrame:Show()
    sideBetWinFrame.title:Show()
    sideBetWinFrame.PPtext:Show()
    sideBetWinFrame.PerfectPairText:Show()
    sideBetWinFrame.player2PPCardImage1:Show()
    sideBetWinFrame.player2PPCardImage2:Show()
end

function player2SuitedThreeOfAKindNotification()
    sideBetWinFrame:Show()
    sideBetWinFrame.title:Show()
    sideBetWinFrame.t213text:Show()
    sideBetWinFrame.SuitedThreeOfAKindText:Show()
    sideBetWinFrame.player2213CardImage1:Show()
    sideBetWinFrame.player2213CardImage2:Show()
    sideBetWinFrame.dealer213CardImage1:Show()
    sideBetWinFrame.PlusSymbol:Show()
end

function player2StraightFlushNotification()
    sideBetWinFrame:Show()
    sideBetWinFrame.title:Show()
    sideBetWinFrame.t213text:Show()
    sideBetWinFrame.StraightFlushText:Show()
    sideBetWinFrame.player2213CardImage1:Show()
    sideBetWinFrame.player2213CardImage2:Show()
    sideBetWinFrame.dealer213CardImage1:Show()
    sideBetWinFrame.PlusSymbol:Show()
end

function player2ThreeOfAKindNotification()
    sideBetWinFrame:Show()
    sideBetWinFrame.title:Show()
    sideBetWinFrame.t213text:Show()
    sideBetWinFrame.ThreeOfAKindText:Show()
    sideBetWinFrame.player2213CardImage1:Show()
    sideBetWinFrame.player2213CardImage2:Show()
    sideBetWinFrame.dealer213CardImage1:Show()
    sideBetWinFrame.PlusSymbol:Show()
end

function player2StraightNotification()
    sideBetWinFrame:Show()
    sideBetWinFrame.title:Show()
    sideBetWinFrame.t213text:Show()
    sideBetWinFrame.StraightText:Show()
    sideBetWinFrame.player2213CardImage1:Show()
    sideBetWinFrame.player2213CardImage2:Show()
    sideBetWinFrame.dealer213CardImage1:Show()
    sideBetWinFrame.PlusSymbol:Show()
end

function player2FlushNotification()
    sideBetWinFrame:Show()
    sideBetWinFrame.title:Show()
    sideBetWinFrame.t213text:Show()
    sideBetWinFrame.FlushText:Show()
    sideBetWinFrame.player2213CardImage1:Show()
    sideBetWinFrame.player2213CardImage2:Show()
    sideBetWinFrame.dealer213CardImage1:Show()
    sideBetWinFrame.PlusSymbol:Show()
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\\BlackjackPlayer\\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\\BlackjackPlayer\\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
player1MainBetAmount = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
player1MainBetAmount:SetPoint("CENTER", playerFrame, 338, 100)
player1MainBetAmount:SetJustifyH("CENTER")
player1MainBetAmount: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
player1PPBetAmount = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
player1PPBetAmount:SetPoint("CENTER", playerFrame, 275, 60)
player1PPBetAmount:SetJustifyH("CENTER")
player1PPBetAmount: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
player1213BetAmount = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
player1213BetAmount:SetPoint("CENTER", playerFrame, 345, 156)
player1213BetAmount:SetJustifyH("CENTER")
player1213BetAmount: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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\Images\\CoinsWin.tga")
playerFrame.coinsDoubleBet1:SetBlendMode("BLEND")
playerFrame.coinsDoubleBet1:SetDrawLayer("OVERLAY")
playerFrame.coinsDoubleBet1:Hide()
-- PP Bet
playerFrame.player1CoinsPPBet = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.player1CoinsPPBet:SetSize(128, 128)
playerFrame.player1CoinsPPBet:SetPoint("CENTER", playerFrame, 280, 40)
playerFrame.player1CoinsPPBet:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\CoinsHalfBet.tga")
playerFrame.player1CoinsPPBet:SetBlendMode("BLEND")
playerFrame.player1CoinsPPBet:SetDrawLayer("OVERLAY")
playerFrame.player1CoinsPPBet:Hide()
-- 21+3 Bet
playerFrame.player1Coins213Bet = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.player1Coins213Bet:SetSize(128, 128)
playerFrame.player1Coins213Bet:SetPoint("CENTER", playerFrame, 350, 136)
playerFrame.player1Coins213Bet:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\CoinsHalfBet.tga")
playerFrame.player1Coins213Bet:SetBlendMode("BLEND")
playerFrame.player1Coins213Bet:SetDrawLayer("OVERLAY")
playerFrame.player1Coins213Bet:Hide()
-- PP Win
playerFrame.player1CoinsPPWin = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.player1CoinsPPWin:SetSize(128, 128)
playerFrame.player1CoinsPPWin:SetPoint("CENTER", playerFrame, 292, 44)
playerFrame.player1CoinsPPWin:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\CoinsBet.tga")
playerFrame.player1CoinsPPWin:SetBlendMode("BLEND")
playerFrame.player1CoinsPPWin:SetDrawLayer("OVERLAY")
playerFrame.player1CoinsPPWin:Hide()
-- 21+3 Win
playerFrame.player1Coins213Win = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.player1Coins213Win:SetSize(128, 128)
playerFrame.player1Coins213Win:SetPoint("CENTER", playerFrame, 361, 141)
playerFrame.player1Coins213Win:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\CoinsBet.tga")
playerFrame.player1Coins213Win:SetBlendMode("BLEND")
playerFrame.player1Coins213Win:SetDrawLayer("OVERLAY")
playerFrame.player1Coins213Win:Hide()



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

-- Function to handle Player 1 Double Bet Image
local function player1PlaceBetsRegularWin(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 player1PlaceMainBetText(message)
    local player1HistoryMainBet = string.match(message, "(%d+)G")

        if player1HistoryMainBet then
            player1MainBetAmount:SetText(player1HistoryMainBet .. " G")
            player1MainBetAmount:Show()

            player1totalBetAmount = player1totalBetAmount + tonumber(player1HistoryMainBet)
            historyFrame.player1totalWageredAmount:SetText(player1totalBetAmount .. " G")
        else
    end
end

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

-- Function to handle Player 1 PP Bet Text
local function player1PlacePPBetText(message)
    local player1HistoryPPBet = string.match(message, "(%d+)G")

        if player1HistoryPPBet then
            player1PPBetAmount:SetText(player1HistoryPPBet .. " G")
            player1PPBetAmount:Show()

            player1totalBetAmount = player1totalBetAmount + tonumber(player1HistoryPPBet)
            historyFrame.player1totalWageredAmount:SetText(player1totalBetAmount .. " G")
        else
    end
end

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

-- Function to handle Player 1 21+3 Bet Text
local function player1Place213BetText(message)
    local player1History213Bet = string.match(message, "(%d+)G")

        if player1History213Bet then
            player1213BetAmount:SetText(player1History213Bet .. " G")
            player1213BetAmount:Show()

            player1totalBetAmount = player1totalBetAmount + tonumber(player1History213Bet)
            historyFrame.player1totalWageredAmount:SetText(player1totalBetAmount .. " G")
        else
    end
end






local function player1PreloadBet()
    PlaySoundFile(soundFilePaths[43])
    betAmountMain1 = tonumber(player1PreloadEditBoxMainBet: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
        player1PreloadEditBoxMainBet:SetFocus(false)
        player1PreloadEditBoxMainBet:ClearFocus()

        betEditBoxMain1:SetText(betAmountMain1)
        betEditBoxMain1:SetFocus(false)
        betEditBoxMain1:ClearFocus()
        betEditBoxMain1:Disable()
        confirmBetButtonMain1:Disable()
    end
    betAmountPP1 = tonumber(player1PreloadEditBoxPPBet: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
        player1PreloadEditBoxPPBet:SetFocus(false)
        player1PreloadEditBoxPPBet:ClearFocus()

        betEditBoxPP1:SetText(betAmountPP1)
        betEditBoxPP1:SetFocus(false)
        betEditBoxPP1:ClearFocus()
        betEditBoxPP1:Disable()
        confirmBetButtonPP1:Disable()
    end
    betAmount2131 = tonumber(player1PreloadEditBox213Bet: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
        player1PreloadEditBox213Bet:SetFocus(false)
        player1PreloadEditBox213Bet:ClearFocus()

        betEditBox2131:SetText(betAmount2131)
        betEditBox2131:SetFocus(false)
        betEditBox2131:ClearFocus()
        betEditBox2131:Disable()
        confirmBetButton2131:Disable()
    end
    player1PreloadBetButton:Disable()
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)

-- Player 1 "Bet All" Preload button
player1PreloadBetButton:SetScript("OnClick", player1PreloadBet)











-- Insurance YES for Player 2
insuranceYesIcon2 = playerFrame:CreateTexture(nil, "OVERLAY")
insuranceYesIcon2:SetSize(32, 32)
insuranceYesIcon2:SetPoint("CENTER", playerFrame, 342, -158)
insuranceYesIcon2:SetTexture("Interface\\AddOns\\BlackjackPlayer\\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\\BlackjackPlayer\\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
player2MainBetAmount = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
player2MainBetAmount:SetPoint("CENTER", playerFrame, 189, -16)
player2MainBetAmount:SetJustifyH("CENTER")
player2MainBetAmount: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
player2PPBetAmount = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
player2PPBetAmount:SetPoint("CENTER", playerFrame, 123, -23)
player2PPBetAmount:SetJustifyH("CENTER")
player2PPBetAmount: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
player2213BetAmount = playerFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
player2213BetAmount:SetPoint("CENTER", playerFrame, 231, 29)
player2213BetAmount:SetJustifyH("CENTER")
player2213BetAmount: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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\Images\\CoinsWin.tga")
playerFrame.coinsDoubleBet2:SetBlendMode("BLEND")
playerFrame.coinsDoubleBet2:SetDrawLayer("OVERLAY")
playerFrame.coinsDoubleBet2:Hide()
-- PP Bet
playerFrame.player2CoinsPPBet = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.player2CoinsPPBet:SetSize(128, 128)
playerFrame.player2CoinsPPBet:SetPoint("CENTER", playerFrame, 127, -42)
playerFrame.player2CoinsPPBet:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\CoinsHalfBet.tga")
playerFrame.player2CoinsPPBet:SetBlendMode("BLEND")
playerFrame.player2CoinsPPBet:SetDrawLayer("OVERLAY")
playerFrame.player2CoinsPPBet:Hide()
-- 21+3 Bet
playerFrame.player2Coins213Bet = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.player2Coins213Bet:SetSize(128, 128)
playerFrame.player2Coins213Bet:SetPoint("CENTER", playerFrame, 235, 8)
playerFrame.player2Coins213Bet:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\CoinsHalfBet.tga")
playerFrame.player2Coins213Bet:SetBlendMode("BLEND")
playerFrame.player2Coins213Bet:SetDrawLayer("OVERLAY")
playerFrame.player2Coins213Bet:Hide()
-- PP Win
playerFrame.player2CoinsPPWin = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.player2CoinsPPWin:SetSize(128, 128)
playerFrame.player2CoinsPPWin:SetPoint("CENTER", playerFrame, 138, -36)
playerFrame.player2CoinsPPWin:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\CoinsBet.tga")
playerFrame.player2CoinsPPWin:SetBlendMode("BLEND")
playerFrame.player2CoinsPPWin:SetDrawLayer("OVERLAY")
playerFrame.player2CoinsPPWin:Hide()
-- 21+3 Win
playerFrame.player2Coins213Win = playerFrame:CreateTexture(nil, "OVERLAY")
playerFrame.player2Coins213Win:SetSize(128, 128)
playerFrame.player2Coins213Win:SetPoint("CENTER", playerFrame, 246, 16)
playerFrame.player2Coins213Win:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\CoinsBet.tga")
playerFrame.player2Coins213Win:SetBlendMode("BLEND")
playerFrame.player2Coins213Win:SetDrawLayer("OVERLAY")
playerFrame.player2Coins213Win:Hide()


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

-- Function to handle Player 2 Double Bet Image
local function player2PlaceBetsRegularWin(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 player2PlaceMainBetText(message)
    local player2HistoryMainBet = string.match(message, "(%d+)G")

        if player2HistoryMainBet then
            player2MainBetAmount:SetText(player2HistoryMainBet .. " G")
            player2MainBetAmount:Show()

            player2totalBetAmount = player2totalBetAmount + tonumber(player2HistoryMainBet)
            historyFrame.player2totalWageredAmount:SetText(player2totalBetAmount .. " G")
        else
    end
end


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

-- Function to handle Player 2 PP Bet Text
local function player2PlacePPBetText(message)
    local player2HistoryPPBet = string.match(message, "(%d+)G")

        if player2HistoryPPBet then
            player2PPBetAmount:SetText(player2HistoryPPBet .. " G")
            player2PPBetAmount:Show()

            player2totalBetAmount = player2totalBetAmount + tonumber(player2HistoryPPBet)
            historyFrame.player2totalWageredAmount:SetText(player2totalBetAmount .. " G")
        else
    end   
end

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

-- Function to handle Player 2 21+3 Bet Text
local function player2Place213BetText(message)
    local player2History213Bet = string.match(message, "(%d+)G")

        if player2History213Bet then
            player2213BetAmount:SetText(player2History213Bet .. " G")
            player2213BetAmount:Show()

            player2totalBetAmount = player2totalBetAmount + tonumber(player2History213Bet)
            historyFrame.player2totalWageredAmount:SetText(player2totalBetAmount .. " G")
        else
    end
end



local function player2PreloadBet()
    PlaySoundFile(soundFilePaths[43])
    betAmountMain2 = tonumber(player2PreloadEditBoxMainBet: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
        player2PreloadEditBoxMainBet:SetFocus(false)
        player2PreloadEditBoxMainBet:ClearFocus()

        betEditBoxMain2:SetText(betAmountMain2)
        betEditBoxMain2:SetFocus(false)
        betEditBoxMain2:ClearFocus()
        betEditBoxMain2:Disable()
        confirmBetButtonMain2:Disable()
    end
    betAmountPP2 = tonumber(player2PreloadEditBoxPPBet: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
        player2PreloadEditBoxPPBet:SetFocus(false)
        player2PreloadEditBoxPPBet:ClearFocus()

        betEditBoxPP2:SetText(betAmountPP2)
        betEditBoxPP2:SetFocus(false)
        betEditBoxPP2:ClearFocus()
        betEditBoxPP2:Disable()
        confirmBetButtonPP2:Disable()
    end
    betAmount2132 = tonumber(player2PreloadEditBox213Bet: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
        player2PreloadEditBox213Bet:SetFocus(false)
        player2PreloadEditBox213Bet:ClearFocus()

        betEditBox2132:SetText(betAmount2132)
        betEditBox2132:SetFocus(false)
        betEditBox2132:ClearFocus()
        betEditBox2132:Disable()
        confirmBetButton2132:Disable()
    end
    player2PreloadBetButton:Disable()
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)

-- Player 2 "Bet All" Preload button
player2PreloadBetButton:SetScript("OnClick", player2PreloadBet)





-- Insurance YES for Player 3
insuranceYesIcon3 = playerFrame:CreateTexture(nil, "OVERLAY")
insuranceYesIcon3:SetSize(32, 32)
insuranceYesIcon3:SetPoint("CENTER", playerFrame, 87, -205)
insuranceYesIcon3:SetTexture("Interface\\AddOns\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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\\BlackjackPlayer\\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)

        if playerName == unitName1 then
            SendChatMessage("[P1] Stand", "RAID")
        end
    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
        table.insert(dealtCards, cardNames[cardName])

        -- 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\\BlackjackPlayer\\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
        table.insert(dealtCards, cardNames[cardName])

        -- 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\\BlackjackPlayer\\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[48])
        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[49])
        playerFrame.numberPlayer2Text:SetText(soundIndex)
        playerFrame.numberPlayer2Text:SetTextColor(1, 0, 0)
    end
end

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


-- 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: 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])
        turn = 9

    -- 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 == 3 or string.find(message, unitName1) and string.find(message, "has") and turn >= 4 and turn <= 9 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()



    -- Dealer: Ace Combos
    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])

    -- Dealer: 2-21
    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 21") then
            PlaySoundFile(soundFilePaths[21])
        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")

    -- Dealer: 22
    elseif string.find(message, "22") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("22")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)
    -- Dealer: 23
    elseif string.find(message, "23") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("23")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)
    -- Dealer: 24
    elseif string.find(message, "24") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("24")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)
    -- Dealer: 25
    elseif string.find(message, "25") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("25")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)
    -- Dealer: 26
    elseif string.find(message, "26") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("26")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)
    -- Dealer: 27
    elseif string.find(message, "27") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("27")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)
    -- Dealer: 28
    elseif string.find(message, "28") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("28")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)
    -- Dealer: 29
    elseif string.find(message, "29") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("29")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)
    -- Dealer: 30
    elseif string.find(message, "30") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("30")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)

    -- Dealer: Blackjack
    elseif string.find(message, "Dealer") and string.find(message, "Blackjack") then
        playerFrame.numberDealerText:SetText("Blackjack")
        playerFrame.numberDealerText:SetTextColor(1, 1, 0) -- RGB values for yellow
        PlaySoundFile(soundFilePaths[36])
    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+)")


    -- 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 21") then
            PlaySoundFile(soundFilePaths[21])  
        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")

    -- Dealer: 22
    elseif string.find(message, "22") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("22")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)
    -- Dealer: 23
    elseif string.find(message, "23") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("23")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)
    -- Dealer: 24
    elseif string.find(message, "24") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("24")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)
    -- Dealer: 25
    elseif string.find(message, "25") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("25")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)
    -- Dealer: 26
    elseif string.find(message, "26") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("26")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)
    -- Dealer: 27
    elseif string.find(message, "27") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("27")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)
    -- Dealer: 28
    elseif string.find(message, "28") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("28")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)
    -- Dealer: 29
    elseif string.find(message, "29") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("29")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)
    -- Dealer: 30
    elseif string.find(message, "30") and string.find(message, "Dealer") then
        playerFrame.numberDealerText:SetText("30")
        playerFrame.numberDealerText:SetTextColor(1, 0, 0)


    -- Dealer: Blackjack
    elseif string.find(message, "Dealer") and string.find(message, "Blackjack") then
        playerFrame.numberDealerText:SetText("Blackjack")
        playerFrame.numberDealerText:SetTextColor(1, 1, 0) -- RGB values for yellow
        PlaySoundFile(soundFilePaths[36])
    
        
    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
            player1PlaceMainBetText(message)
        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
            player1PlacePPBetText(message)
        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
            player1Place213BetText(message)
        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 and Player2Active and not Player3Active and not Player4Active and not Player5Active then    -- Players: 1 2
            if playerFrame.numberPlayer2Text:GetText() == "Blackjack" then
                turn = 17
            else
                turn = 11
            end
        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()
    elseif string.find(message, "%[P1%] Double") then
        local betDoubleAmount1 = string.match(message, "Double my bet to (%d+)G")
        if betDoubleAmount1 then
            PlaceBetsMain1Double()
            player1MainBetAmount: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
            player2PlaceMainBetText(message)
        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
            player2PlacePPBetText(message)
        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
            player2Place213BetText(message)
        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()
            player2MainBetAmount: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.player1CoinsPPBet:Hide()
    playerFrame.player1Coins213Bet:Hide()
    player1MainBetAmount:Hide()
    player1PPBetAmount:Hide()
    player1213BetAmount:Hide()
    insuranceYesIcon1:Hide()
    insuranceNoIcon1:Hide()
    playerFrame.insuranceYesButton1:Disable()
    playerFrame.insuranceNoButton1:Disable()
    playerFrame.insuranceBetAmount1:SetText("")
    playerFrame.player1CoinsPPWin:Hide()
    playerFrame.player1Coins213Win: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.player2CoinsPPBet:Hide()
    playerFrame.player2Coins213Bet:Hide()
    player2MainBetAmount:Hide()
    player2PPBetAmount:Hide()
    player2213BetAmount:Hide()
    insuranceYesIcon2:Hide()
    insuranceNoIcon2:Hide()
    playerFrame.insuranceYesButton2:Disable()
    playerFrame.insuranceNoButton2:Disable()
    playerFrame.insuranceBetAmount2:SetText("")
    playerFrame.player2CoinsPPWin:Hide()
    playerFrame.player2Coins213Win: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

    player1PPSideBetWin = false
    player1213SideBetWin = false
    player2PPSideBetWin = false
    player2213SideBetWin = false

    sideBetWinFrame:Hide()
    sideBetWinFrame.title:Hide()
    sideBetWinFrame.PPtext:Hide()
    sideBetWinFrame.t213text:Hide()
    sideBetWinFrame.MixedPairText:Hide()
    sideBetWinFrame.ColouredPairText:Hide()
    sideBetWinFrame.PerfectPairText:Hide()
    sideBetWinFrame.FlushText:Hide()
    sideBetWinFrame.StraightText:Hide()
    sideBetWinFrame.ThreeOfAKindText:Hide()
    sideBetWinFrame.StraightFlushText:Hide()
    sideBetWinFrame.SuitedThreeOfAKindText:Hide()
    sideBetWinFrame.player1PPCardImage1:Hide()
    sideBetWinFrame.player1PPCardImage2:Hide()
    sideBetWinFrame.player1213CardImage1:Hide()
    sideBetWinFrame.player1213CardImage2:Hide()
    sideBetWinFrame.dealer213CardImage1:Hide()
    sideBetWinFrame.PlusSymbol:Hide()

    player1PreloadBetButton:Enable()
    player2PreloadBetButton:Enable()
end









-- Function to handle Player 1 PP Win Image
function player1PlaceBetsPPWin(message)
    playerFrame.player1CoinsPPBet:Hide()
    playerFrame.player1CoinsPPWin:Show()
    player1PPBetAmount:SetPoint("CENTER", playerFrame, 274, 77)
end

-- Function to handle Player 1 21+3 Win Image
function player1PlaceBets213Win(message)
    playerFrame.player1Coins213Bet:Hide()
    playerFrame.player1Coins213Win:Show()
    player1213BetAmount:SetPoint("CENTER", playerFrame, 345, 174)
end

function player1MixedPairWin(message)
    player1PPBetAmountValue = tonumber(string.match(player1PPBetAmount:GetText(), "%d+"))
    if player1PPBetAmountValue then
        player1NewPPAmount = player1PPBetAmountValue * 5
        player1PPBetAmount:SetText(player1NewPPAmount .. " G")

        player1PPProfitvalue = player1NewPPAmount - player1PPBetAmountValue

        player1totalWin = player1totalWin + tonumber(player1PPProfitvalue)
        historyFrame.player1totalWonAmount:SetText(player1totalWin .. " G")

        player1totalProfit = player1totalProfit + tonumber(player1PPProfitvalue)
        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

        if player1totalProfit >= 0 then
            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

    end
    player1PlaceBetsPPWin()
    player1PPSideBetWin = true
end

function player1ColouredPairWin(message)
    player1PPBetAmountValue = tonumber(string.match(player1PPBetAmount:GetText(), "%d+"))
    if player1PPBetAmountValue then
        player1NewPPAmount = player1PPBetAmountValue * 10
        player1PPBetAmount:SetText(player1NewPPAmount .. " G")

        player1PPProfitvalue = player1NewPPAmount - player1PPBetAmountValue

        player1totalWin = player1totalWin + tonumber(player1PPProfitvalue)
        historyFrame.player1totalWonAmount:SetText(player1totalWin .. " G")

        player1totalProfit = player1totalProfit + tonumber(player1PPProfitvalue)
        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

        if player1totalProfit >= 0 then
            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

    end
    player1PlaceBetsPPWin()
    player1PPSideBetWin = true
end

function player1PerfectPairWin(message)
    player1PPBetAmountValue = tonumber(string.match(player1PPBetAmount:GetText(), "%d+"))
    if player1PPBetAmountValue then
        player1NewPPAmount = player1PPBetAmountValue * 30
        player1PPBetAmount:SetText(player1NewPPAmount .. " G")

        player1PPProfitvalue = player1NewPPAmount - player1PPBetAmountValue

        player1totalWin = player1totalWin + tonumber(player1PPProfitvalue)
        historyFrame.player1totalWonAmount:SetText(player1totalWin .. " G")

        player1totalProfit = player1totalProfit + tonumber(player1PPProfitvalue)
        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

        if player1totalProfit >= 0 then
            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

    end
    player1PlaceBetsPPWin()
    player1PPSideBetWin = true
end

function player1SuitedThreeOfAKindWin(message)
    player1213BetAmountValue = tonumber(string.match(player1213BetAmount:GetText(), "%d+"))
    if player1213BetAmountValue then
        player1New213Amount = player1213BetAmountValue * 100
        player1213BetAmount:SetText(player1New213Amount .. " G")

        player1213Profitvalue = player1New213Amount - player1213BetAmountValue

        player1totalWin = player1totalWin + tonumber(player1213Profitvalue)
        historyFrame.player1totalWonAmount:SetText(player1totalWin .. " G")

        player1totalProfit = player1totalProfit + tonumber(player1213Profitvalue)
        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

        if player1totalProfit >= 0 then
            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

    end
    player1PlaceBets213Win()
    player1213SideBetWin = true
end

function player1StraightFlushWin(message)
    player1213BetAmountValue = tonumber(string.match(player1213BetAmount:GetText(), "%d+"))
    if player1213BetAmountValue then
        player1New213Amount = player1213BetAmountValue * 40
        player1213BetAmount:SetText(player1New213Amount .. " G")

        player1213Profitvalue = player1New213Amount - player1213BetAmountValue

        player1totalWin = player1totalWin + tonumber(player1213Profitvalue)
        historyFrame.player1totalWonAmount:SetText(player1totalWin .. " G")

        player1totalProfit = player1totalProfit + tonumber(player1213Profitvalue)
        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

        if player1totalProfit >= 0 then
            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

    end
    player1PlaceBets213Win()
    player1213SideBetWin = true
end

function player1ThreeOfAKindWin(message)
    player1213BetAmountValue = tonumber(string.match(player1213BetAmount:GetText(), "%d+"))
    if player1213BetAmountValue then
        player1New213Amount = player1213BetAmountValue * 30
        player1213BetAmount:SetText(player1New213Amount .. " G")

        player1213Profitvalue = player1New213Amount - player1213BetAmountValue

        player1totalWin = player1totalWin + tonumber(player1213Profitvalue)
        historyFrame.player1totalWonAmount:SetText(player1totalWin .. " G")

        player1totalProfit = player1totalProfit + tonumber(player1213Profitvalue)
        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

        if player1totalProfit >= 0 then
            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

    end
    player1PlaceBets213Win()
    player1213SideBetWin = true
end

function player1StraightWin(message)
    player1213BetAmountValue = tonumber(string.match(player1213BetAmount:GetText(), "%d+"))
    if player1213BetAmountValue then
        player1New213Amount = player1213BetAmountValue * 10
        player1213BetAmount:SetText(player1New213Amount .. " G")

        player1213Profitvalue = player1New213Amount - player1213BetAmountValue

        player1totalWin = player1totalWin + tonumber(player1213Profitvalue)
        historyFrame.player1totalWonAmount:SetText(player1totalWin .. " G")

        player1totalProfit = player1totalProfit + tonumber(player1213Profitvalue)
        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

        if player1totalProfit >= 0 then
            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

    end
    player1PlaceBets213Win()
    player1213SideBetWin = true
end

function player1FlushWin(message)
    player1213BetAmountValue = tonumber(string.match(player1213BetAmount:GetText(), "%d+"))
    if player1213BetAmountValue then
        player1New213Amount = player1213BetAmountValue * 5
        player1213BetAmount:SetText(player1New213Amount .. " G")
    
        player1213Profitvalue = player1New213Amount - player1213BetAmountValue

        player1totalWin = player1totalWin + tonumber(player1213Profitvalue)
        historyFrame.player1totalWonAmount:SetText(player1totalWin .. " G")

        player1totalProfit = player1totalProfit + tonumber(player1213Profitvalue)
        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

        if player1totalProfit >= 0 then
            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

    end
    player1PlaceBets213Win()
    player1213SideBetWin = true
end


function player1BlackjackWin(message)
    player1MainBetValue = tonumber(string.match(player1MainBetAmount:GetText(), "%d+"))
    if player1MainBetValue then
        player1NewMainBetAmount = player1MainBetValue * 2.5
        player1MainBetAmount:SetText(player1NewMainBetAmount .. " G")

        player1BJProfitvalue = player1NewMainBetAmount - player1MainBetValue

        player1totalWin = player1totalWin + tonumber(player1BJProfitvalue)
        historyFrame.player1totalWonAmount:SetText(player1totalWin .. " G")

        player1totalProfit = player1totalProfit + tonumber(player1BJProfitvalue)
        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

        if player1totalProfit >= 0 then
            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

        player1PPBetAmountValue = tonumber(string.match(player1PPBetAmount:GetText(), "%d+"))
        if player1PPBetAmountValue then
            if player1PPSideBetWin == false then

                player1totalLoss = player1totalLoss + tonumber(player1PPBetAmountValue)
                historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")

                player1totalProfit = player1totalProfit - tonumber(player1PPBetAmountValue)
                historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

                if player1totalProfit >= 0 then
                    historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                else
                    historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                end

            end
        end

        player1213BetAmountValue = tonumber(string.match(player1213BetAmount:GetText(), "%d+"))
        if player1213BetAmountValue then
            if player1213SideBetWin == false then

                player1totalLoss = player1totalLoss + tonumber(player1213BetAmountValue)
                historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")

                player1totalProfit = player1totalProfit - tonumber(player1213BetAmountValue)
                historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

                if player1totalProfit >= 0 then
                    historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                else
                    historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                end

            end
        end

    end
    player1PlaceBetsBJWin()
end

function player1RegularWin(message)
    player1MainBetValue = tonumber(string.match(player1MainBetAmount:GetText(), "%d+"))
    if player1MainBetValue then
        player1NewMainBetAmount = player1MainBetValue * 2
        player1MainBetAmount:SetText(player1NewMainBetAmount .. " G")

        player1totalWin = player1totalWin + tonumber(player1MainBetValue)
        historyFrame.player1totalWonAmount:SetText(player1totalWin .. " G")

        player1totalProfit = player1totalProfit + tonumber(player1MainBetValue)
        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

        if player1totalProfit >= 0 then
            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

        player1PPBetAmountValue = tonumber(string.match(player1PPBetAmount:GetText(), "%d+"))
        if player1PPBetAmountValue then
            if player1PPSideBetWin == false then

                player1totalLoss = player1totalLoss + tonumber(player1PPBetAmountValue)
                historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")

                player1totalProfit = player1totalProfit - tonumber(player1PPBetAmountValue)
                historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

                if player1totalProfit >= 0 then
                    historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                else
                    historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                end

            end
        end

        player1213BetAmountValue = tonumber(string.match(player1213BetAmount:GetText(), "%d+"))
        if player1213BetAmountValue then
            if player1213SideBetWin == false then

                player1totalLoss = player1totalLoss + tonumber(player1213BetAmountValue)
                historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")

                player1totalProfit = player1totalProfit - tonumber(player1213BetAmountValue)
                historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

                if player1totalProfit >= 0 then
                    historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                else
                    historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                end

            end
        end

    end
    player1PlaceBetsRegularWin()
end







-- Function to handle Player 2 PP Win Image
function player2PlaceBetsPPWin(message)
    playerFrame.player2CoinsPPBet:Hide()
    playerFrame.player2CoinsPPWin:Show()
    player2PPBetAmount:SetPoint("CENTER", playerFrame, 121, -2)
end

-- Function to handle Player 2 21+3 Win Image
function player2PlaceBets213Win(message)
    playerFrame.player2Coins213Bet:Hide()
    playerFrame.player2Coins213Win:Show()
    player2213BetAmount:SetPoint("CENTER", playerFrame, 230, 49)
end

function player2MixedPairWin(message)
    player2PPBetAmountValue = tonumber(string.match(player2PPBetAmount:GetText(), "%d+"))
    if player2PPBetAmountValue then
        player2NewPPAmount = player2PPBetAmountValue * 5
        player2PPBetAmount:SetText(player2NewPPAmount .. " G")

        player2PPProfitvalue = player2NewPPAmount - player2PPBetAmountValue

        player2totalWin = player2totalWin + tonumber(player2PPProfitvalue)
        historyFrame.player2totalWonAmount:SetText(player2totalWin .. " G")

        player2totalProfit = player2totalProfit + tonumber(player2PPProfitvalue)
        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

        if player2totalProfit >= 0 then
            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

    end
    player2PlaceBetsPPWin()
    player2PPSideBetWin = true
end

function player2ColouredPairWin(message)
    player2PPBetAmountValue = tonumber(string.match(player2PPBetAmount:GetText(), "%d+"))
    if player2PPBetAmountValue then
        player2NewPPAmount = player2PPBetAmountValue * 10
        player2PPBetAmount:SetText(player2NewPPAmount .. " G")

        player2PPProfitvalue = player2NewPPAmount - player2PPBetAmountValue

        player2totalWin = player2totalWin + tonumber(player2PPProfitvalue)
        historyFrame.player2totalWonAmount:SetText(player2totalWin .. " G")

        player2totalProfit = player2totalProfit + tonumber(player2PPProfitvalue)
        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

        if player2totalProfit >= 0 then
            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

    end
    player2PlaceBetsPPWin()
    player2PPSideBetWin = true
end

function player2PerfectPairWin(message)
    player2PPBetAmountValue = tonumber(string.match(player2PPBetAmount:GetText(), "%d+"))
    if player2PPBetAmountValue then
        player2NewPPAmount = player2PPBetAmountValue * 30
        player2PPBetAmount:SetText(player2NewPPAmount .. " G")

        player2PPProfitvalue = player2NewPPAmount - player2PPBetAmountValue

        player2totalWin = player2totalWin + tonumber(player2PPProfitvalue)
        historyFrame.player2totalWonAmount:SetText(player2totalWin .. " G")

        player2totalProfit = player2totalProfit + tonumber(player2PPProfitvalue)
        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

        if player2totalProfit >= 0 then
            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

    end
    player2PlaceBetsPPWin()
    player2PPSideBetWin = true
end

function player2SuitedThreeOfAKindWin(message)
    player2213BetAmountValue = tonumber(string.match(player2213BetAmount:GetText(), "%d+"))
    if player2213BetAmountValue then
        player2New213Amount = player2213BetAmountValue * 100
        player2213BetAmount:SetText(player2New213Amount .. " G")

        player2213Profitvalue = player2New213Amount - player2213BetAmountValue

        player2totalWin = player2totalWin + tonumber(player2213Profitvalue)
        historyFrame.player2totalWonAmount:SetText(player2totalWin .. " G")

        player2totalProfit = player2totalProfit + tonumber(player2213Profitvalue)
        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

        if player2totalProfit >= 0 then
            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

    end
    player2PlaceBets213Win()
    player2213SideBetWin = true
end

function player2StraightFlushWin(message)
    player2213BetAmountValue = tonumber(string.match(player2213BetAmount:GetText(), "%d+"))
    if player2213BetAmountValue then
        player2New213Amount = player2213BetAmountValue * 40
        player2213BetAmount:SetText(player2New213Amount .. " G")

        player2213Profitvalue = player2New213Amount - player2213BetAmountValue

        player2totalWin = player2totalWin + tonumber(player2213Profitvalue)
        historyFrame.player2totalWonAmount:SetText(player2totalWin .. " G")

        player2totalProfit = player2totalProfit + tonumber(player2213Profitvalue)
        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

        if player2totalProfit >= 0 then
            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

    end
    player2PlaceBets213Win()
    player2213SideBetWin = true
end

function player2ThreeOfAKindWin(message)
    player2213BetAmountValue = tonumber(string.match(player2213BetAmount:GetText(), "%d+"))
    if player2213BetAmountValue then
        player2New213Amount = player2213BetAmountValue * 30
        player2213BetAmount:SetText(player2New213Amount .. " G")

        player2213Profitvalue = player2New213Amount - player2213BetAmountValue

        player2totalWin = player2totalWin + tonumber(player2213Profitvalue)
        historyFrame.player2totalWonAmount:SetText(player2totalWin .. " G")

        player2totalProfit = player2totalProfit + tonumber(player2213Profitvalue)
        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

        if player2totalProfit >= 0 then
            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end


    end
    player2PlaceBets213Win()
    player2213SideBetWin = true
end

function player2StraightWin(message)
    player2213BetAmountValue = tonumber(string.match(player2213BetAmount:GetText(), "%d+"))
    if player2213BetAmountValue then
        player2New213Amount = player2213BetAmountValue * 10
        player2213BetAmount:SetText(player2New213Amount .. " G")
        
        player2213Profitvalue = player2New213Amount - player2213BetAmountValue

        player2totalWin = player2totalWin + tonumber(player2213Profitvalue)
        historyFrame.player2totalWonAmount:SetText(player2totalWin .. " G")

        player2totalProfit = player2totalProfit + tonumber(player2213Profitvalue)
        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

        if player2totalProfit >= 0 then
            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

    end
    player2PlaceBets213Win()
    player2213SideBetWin = true
end

function player2FlushWin(message)
    player2213BetAmountValue = tonumber(string.match(player2213BetAmount:GetText(), "%d+"))
    if player2213BetAmountValue then
        player2New213Amount = player2213BetAmountValue * 5
        player2213BetAmount:SetText(player2New213Amount .. " G")
        
        player2213Profitvalue = player2New213Amount - player2213BetAmountValue

        player2totalWin = player2totalWin + tonumber(player2213Profitvalue)
        historyFrame.player2totalWonAmount:SetText(player2totalWin .. " G")

        player2totalProfit = player2totalProfit + tonumber(player2213Profitvalue)
        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

        if player2totalProfit >= 0 then
            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

    end
    player2PlaceBets213Win()
    player2213SideBetWin = true
end


function player2BlackjackWin(message)
    player2MainBetValue = tonumber(string.match(player2MainBetAmount:GetText(), "%d+"))
    if player2MainBetValue then
        player2NewMainBetAmount = player2MainBetValue * 2.5
        player2MainBetAmount:SetText(player2NewMainBetAmount .. " G")

        player2BJProfitvalue = player2NewMainBetAmount - player2MainBetValue

        player2totalWin = player2totalWin + tonumber(player2BJProfitvalue)
        historyFrame.player2totalWonAmount:SetText(player2totalWin .. " G")

        player2totalProfit = player2totalProfit + tonumber(player2BJProfitvalue)
        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

        if player2totalProfit >= 0 then
            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

        player2PPBetAmountValue = tonumber(string.match(player2PPBetAmount:GetText(), "%d+"))
        if player2PPBetAmountValue then
            if player2PPSideBetWin == false then

                player2totalLoss = player2totalLoss + tonumber(player2PPBetAmountValue)
                historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")

                player2totalProfit = player2totalProfit - tonumber(player2PPBetAmountValue)
                historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

                if player2totalProfit >= 0 then
                    historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                else
                    historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                end

            end
        end

        player2213BetAmountValue = tonumber(string.match(player2213BetAmount:GetText(), "%d+"))
        if player2213BetAmountValue then
            if player2213SideBetWin == false then

                player2totalLoss = player2totalLoss + tonumber(player2213BetAmountValue)
                historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")

                player2totalProfit = player2totalProfit - tonumber(player2213BetAmountValue)
                historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

                if player2totalProfit >= 0 then
                    historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                else
                    historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                end

            end
        end

    end
    player2PlaceBetsBJWin()
end

function player2RegularWin(message)
    player2MainBetValue = tonumber(string.match(player2MainBetAmount:GetText(), "%d+"))
    if player2MainBetValue then
        player2NewMainBetAmount = player2MainBetValue * 2
        player2MainBetAmount:SetText(player2NewMainBetAmount .. " G")

        player2totalWin = player2totalWin + tonumber(player2MainBetValue)
        historyFrame.player2totalWonAmount:SetText(player2totalWin .. " G")

        player2totalProfit = player2totalProfit + tonumber(player2MainBetValue)
        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

        if player2totalProfit >= 0 then
            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
        else
            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
        end

        player2PPBetAmountValue = tonumber(string.match(player2PPBetAmount:GetText(), "%d+"))
        if player2PPBetAmountValue then
            if player2PPSideBetWin == false then

                player2totalLoss = player2totalLoss + tonumber(player2PPBetAmountValue)
                historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")

                player2totalProfit = player2totalProfit - tonumber(player2PPBetAmountValue)
                historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

                if player2totalProfit >= 0 then
                    historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                else
                    historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                end

            end
        end

        player2213BetAmountValue = tonumber(string.match(player2213BetAmount:GetText(), "%d+"))
        if player2213BetAmountValue then
            if player2213SideBetWin == false then

                player2totalLoss = player2totalLoss + tonumber(player2213BetAmountValue)
                historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")

                player2totalProfit = player2totalProfit - tonumber(player2213BetAmountValue)
                historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

                if player2totalProfit >= 0 then
                    historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                else
                    historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                end

            end
        end

    end
    player2PlaceBetsRegularWin()
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
    dealtCards = {}
    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



-- Function to get the card image file name from the card name
local function GetCardFileName(cardName)
    for fileName, name in pairs(cardNames) do
        if name == cardName then
            return fileName
        end
    end
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()
            resetHistory()
        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()
            print(turn)
        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, unitName1) and string.find(message, "has gone bust") and not string.find(message, "wins this") then
            PlaySoundFile(soundFilePaths[48]) -- "Player 1 bust"
            playerFrame.numberPlayer1Text:SetTextColor(1, 0, 0)

            betInsuranceLossAmount1 = tonumber(playerFrame.insuranceBetAmount1:GetText())
            if betInsuranceLossAmount1 then
                player1totalLoss = player1totalLoss + tonumber(betInsuranceLossAmount1)
                historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")
            end

            player1MainBetValue = tonumber(string.match(player1MainBetAmount:GetText(), "%d+"))
            if player1MainBetValue then

                player1totalLoss = player1totalLoss + tonumber(player1MainBetValue)
                historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")
        
                player1totalProfit = player1totalProfit - tonumber(player1MainBetValue)
                historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")
                if player1totalProfit >= 0 then
                    historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                else
                    historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                end

                player1PPBetAmountValue = tonumber(string.match(player1PPBetAmount:GetText(), "%d+"))
                if player1PPBetAmountValue then
                    if player1PPSideBetWin == false then

                        player1totalLoss = player1totalLoss + tonumber(player1PPBetAmountValue)
                        historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")

                        player1totalProfit = player1totalProfit - tonumber(player1PPBetAmountValue)
                        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

                        if player1totalProfit >= 0 then
                            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                        else
                            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                        end

                    end
                end

                player1213BetAmountValue = tonumber(string.match(player1213BetAmount:GetText(), "%d+"))
                if player1213BetAmountValue then
                    if player1213SideBetWin == false then

                        player1totalLoss = player1totalLoss + tonumber(player1213BetAmountValue)
                        historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")

                        player1totalProfit = player1totalProfit - tonumber(player1213BetAmountValue)
                        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

                        if player1totalProfit >= 0 then
                            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                        else
                            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                        end

                    end
                end

            else
            end
        
            if Player1Active and not Player2Active and not Player3Active and not Player4Active and not Player5Active then
                print("Doing nothing")
            elseif Player1Active and Player2Active and not Player3Active and not Player4Active and not Player5Active then
                turn = 11
                print("Turn going to 11")
            end

            if string.find(message, "22") then
                playerFrame.numberPlayer1Text:SetText("22")
            elseif string.find(message, "23") then
                playerFrame.numberPlayer1Text:SetText("23")
            elseif string.find(message, "24") then
                playerFrame.numberPlayer1Text:SetText("24")
            elseif string.find(message, "25") then
                playerFrame.numberPlayer1Text:SetText("25")
            elseif string.find(message, "26") then
                playerFrame.numberPlayer1Text:SetText("26")
            elseif string.find(message, "27") then
                playerFrame.numberPlayer1Text:SetText("27")
            elseif string.find(message, "28") then
                playerFrame.numberPlayer1Text:SetText("28")
            elseif string.find(message, "29") then
                playerFrame.numberPlayer1Text:SetText("29")
            elseif string.find(message, "30") then
                playerFrame.numberPlayer1Text:SetText("30")
            end


        elseif string.find(message, unitName2) and string.find(message, "has gone bust") and not string.find(message, "wins this") then
            PlaySoundFile(soundFilePaths[49]) -- "Player 2 bust"
            playerFrame.numberPlayer2Text:SetTextColor(1, 0, 0)

            betInsuranceLossAmount2 = tonumber(playerFrame.insuranceBetAmount2:GetText())
            if betInsuranceLossAmount2 then
                player2totalLoss = player2totalLoss + tonumber(betInsuranceLossAmount2)
                historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")
            end

            player2MainBetValue = tonumber(string.match(player2MainBetAmount:GetText(), "%d+"))
            if player2MainBetValue then

                player2totalLoss = player2totalLoss + tonumber(player2MainBetValue)
                historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")
        
                player2totalProfit = player2totalProfit - tonumber(player2MainBetValue)
                historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")
                if player2totalProfit >= 0 then
                    historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                else
                    historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                end

                player2PPBetAmountValue = tonumber(string.match(player2PPBetAmount:GetText(), "%d+"))
                if player2PPBetAmountValue then
                    if player2PPSideBetWin == false then

                        player2totalLoss = player2totalLoss + tonumber(player2PPBetAmountValue)
                        historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")

                        player2totalProfit = player2totalProfit - tonumber(player2PPBetAmountValue)
                        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

                        if player2totalProfit >= 0 then
                            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                        else
                            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                        end

                    end
                end

                player2213BetAmountValue = tonumber(string.match(player2213BetAmount:GetText(), "%d+"))
                if player2213BetAmountValue then
                    if player2213SideBetWin == false then

                        player2totalLoss = player2totalLoss + tonumber(player2213BetAmountValue)
                        historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")

                        player2totalProfit = player2totalProfit - tonumber(player2213BetAmountValue)
                        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

                        if player2totalProfit >= 0 then
                            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                        else
                            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                        end

                    end
                end

            else
            end

            turn = 17
            if string.find(message, "22") then
                playerFrame.numberPlayer2Text:SetText("22")
            elseif string.find(message, "23") then
                playerFrame.numberPlayer2Text:SetText("23")
            elseif string.find(message, "24") then
                playerFrame.numberPlayer2Text:SetText("24")
            elseif string.find(message, "25") then
                playerFrame.numberPlayer2Text:SetText("25")
            elseif string.find(message, "26") then
                playerFrame.numberPlayer2Text:SetText("26")
            elseif string.find(message, "27") then
                playerFrame.numberPlayer2Text:SetText("27")
            elseif string.find(message, "28") then
                playerFrame.numberPlayer2Text:SetText("28")
            elseif string.find(message, "29") then
                playerFrame.numberPlayer2Text:SetText("29")
            elseif string.find(message, "30") then
                playerFrame.numberPlayer2Text:SetText("30")
            end

        elseif string.find(message, "Dealer has gone bust") then
            playerFrame.numberDealerText:SetTextColor(1, 0, 0)

            betInsuranceLossAmount1 = tonumber(playerFrame.insuranceBetAmount1:GetText())
            if betInsuranceLossAmount1 then
                player1totalLoss = player1totalLoss + tonumber(betInsuranceLossAmount1)
                historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")
            end

            betInsuranceLossAmount2 = tonumber(playerFrame.insuranceBetAmount2:GetText())
            if betInsuranceLossAmount2 then
                player2totalLoss = player2totalLoss + tonumber(betInsuranceLossAmount2)
                historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")
            end

            if string.find(message, unitName1) and string.find(message, "wins this") then 
                PlaySoundFile(soundFilePaths[44]) -- "Player 1 win"
                player1RegularWin()
            elseif string.find(message, unitName2) and string.find(message, "wins this") then 
                PlaySoundFile(soundFilePaths[45]) -- "Player 2 win"
                player2RegularWin()
            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)

                player1PPBetAmountValue = tonumber(string.match(player1PPBetAmount:GetText(), "%d+"))
                if player1PPBetAmountValue then
                    if player1PPSideBetWin == false then

                        player1totalLoss = player1totalLoss + tonumber(player1PPBetAmountValue)
                        historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")

                        player1totalProfit = player1totalProfit - tonumber(player1PPBetAmountValue)
                        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

                        if player1totalProfit >= 0 then
                            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                        else
                            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                        end

                    end
                end

                player1213BetAmountValue = tonumber(string.match(player1213BetAmount:GetText(), "%d+"))
                if player1213BetAmountValue then
                    if player1213SideBetWin == false then

                        player1totalLoss = player1totalLoss + tonumber(player1213BetAmountValue)
                        historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")

                        player1totalProfit = player1totalProfit - tonumber(player1213BetAmountValue)
                        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

                        if player1totalProfit >= 0 then
                            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                        else
                            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                        end

                    end
                end

                player2PPBetAmountValue = tonumber(string.match(player2PPBetAmount:GetText(), "%d+"))
                if player2PPBetAmountValue then
                    if player2PPSideBetWin == false then

                        player2totalLoss = player2totalLoss + tonumber(player2PPBetAmountValue)
                        historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")

                        player2totalProfit = player2totalProfit - tonumber(player2PPBetAmountValue)
                        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

                        if player2totalProfit >= 0 then
                            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                        else
                            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                        end

                    end
                end

                player2213BetAmountValue = tonumber(string.match(player2213BetAmount:GetText(), "%d+"))
                if player2213BetAmountValue then
                    if player2213SideBetWin == false then

                        player2totalLoss = player2totalLoss + tonumber(player2213BetAmountValue)
                        historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")

                        player2totalProfit = player2totalProfit - tonumber(player2213BetAmountValue)
                        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

                        if player2totalProfit >= 0 then
                            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                        else
                            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                        end

                    end
                end

            elseif string.find(message, unitName1) then
                PlaySoundFile(soundFilePaths[55]) -- "Player 1 push"
                playerFrame.numberPlayer1Text:SetTextColor(0.2, 0.7, 1)

                player1PPBetAmountValue = tonumber(string.match(player1PPBetAmount:GetText(), "%d+"))
                if player1PPBetAmountValue then
                    if player1PPSideBetWin == false then

                        player1totalLoss = player1totalLoss + tonumber(player1PPBetAmountValue)
                        historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")

                        player1totalProfit = player1totalProfit - tonumber(player1PPBetAmountValue)
                        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

                        if player1totalProfit >= 0 then
                            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                        else
                            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                        end

                    end
                end

                player1213BetAmountValue = tonumber(string.match(player1213BetAmount:GetText(), "%d+"))
                if player1213BetAmountValue then
                    if player1213SideBetWin == false then

                        player1totalLoss = player1totalLoss + tonumber(player1213BetAmountValue)
                        historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")

                        player1totalProfit = player1totalProfit - tonumber(player1213BetAmountValue)
                        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

                        if player1totalProfit >= 0 then
                            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                        else
                            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                        end

                    end
                end

            elseif string.find(message, unitName2) then
                PlaySoundFile(soundFilePaths[56]) -- "Player 2 push"
                playerFrame.numberPlayer2Text:SetTextColor(0.2, 0.7, 1)

                player2PPBetAmountValue = tonumber(string.match(player2PPBetAmount:GetText(), "%d+"))
                if player2PPBetAmountValue then
                    if player2PPSideBetWin == false then

                        player2totalLoss = player2totalLoss + tonumber(player2PPBetAmountValue)
                        historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")

                        player2totalProfit = player2totalProfit - tonumber(player2PPBetAmountValue)
                        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

                        if player2totalProfit >= 0 then
                            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                        else
                            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                        end

                    end
                end

                player2213BetAmountValue = tonumber(string.match(player2213BetAmount:GetText(), "%d+"))
                if player2213BetAmountValue then
                    if player2213SideBetWin == false then

                        player2totalLoss = player2totalLoss + tonumber(player2213BetAmountValue)
                        historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")

                        player2totalProfit = player2totalProfit - tonumber(player2213BetAmountValue)
                        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

                        if player2totalProfit >= 0 then
                            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                        else
                            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                        end

                    end
                end

            end
        elseif string.find(message, "has less than") and string.find(message, unitName1) then
            PlaySoundFile(soundFilePaths[46])
            player1MainBetValue = tonumber(string.match(player1MainBetAmount:GetText(), "%d+"))
            if player1MainBetValue then

                player1totalLoss = player1totalLoss + tonumber(player1MainBetValue)
                historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")
        
                player1totalProfit = player1totalProfit - tonumber(player1MainBetValue)
                historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")
                if player1totalProfit >= 0 then
                    historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                else
                    historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                end

                player1PPBetAmountValue = tonumber(string.match(player1PPBetAmount:GetText(), "%d+"))
                if player1PPBetAmountValue then
                    if player1PPSideBetWin == false then

                        player1totalLoss = player1totalLoss + tonumber(player1PPBetAmountValue)
                        historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")

                        player1totalProfit = player1totalProfit - tonumber(player1PPBetAmountValue)
                        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

                        if player1totalProfit >= 0 then
                            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                        else
                            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                        end

                    end
                end

                player1213BetAmountValue = tonumber(string.match(player1213BetAmount:GetText(), "%d+"))
                if player1213BetAmountValue then
                    if player1213SideBetWin == false then

                        player1totalLoss = player1totalLoss + tonumber(player1213BetAmountValue)
                        historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")

                        player1totalProfit = player1totalProfit - tonumber(player1213BetAmountValue)
                        historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

                        if player1totalProfit >= 0 then
                            historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                        else
                            historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                        end

                    end
                end

            else
            end
        elseif string.find(message, "has less than") and string.find(message, unitName2) then
            PlaySoundFile(soundFilePaths[47])
            player2MainBetValue = tonumber(string.match(player2MainBetAmount:GetText(), "%d+"))
            if player2MainBetValue then

                player2totalLoss = player2totalLoss + tonumber(player2MainBetValue)
                historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")
        
                player2totalProfit = player2totalProfit - tonumber(player2MainBetValue)
                historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")
                if player2totalProfit >= 0 then
                    historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                else
                    historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                end

                player2PPBetAmountValue = tonumber(string.match(player2PPBetAmount:GetText(), "%d+"))
                if player2PPBetAmountValue then
                    if player2PPSideBetWin == false then

                        player2totalLoss = player2totalLoss + tonumber(player2PPBetAmountValue)
                        historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")

                        player2totalProfit = player2totalProfit - tonumber(player2PPBetAmountValue)
                        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

                        if player2totalProfit >= 0 then
                            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                        else
                            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                        end

                    end
                end

                player2213BetAmountValue = tonumber(string.match(player2213BetAmount:GetText(), "%d+"))
                if player2213BetAmountValue then
                    if player2213SideBetWin == false then

                        player2totalLoss = player2totalLoss + tonumber(player2213BetAmountValue)
                        historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")

                        player2totalProfit = player2totalProfit - tonumber(player2213BetAmountValue)
                        historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

                        if player2totalProfit >= 0 then
                            historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                        else
                            historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                        end

                    end
                end

            else
            end
        elseif string.find(message, "has more than") and string.find(message, unitName1) then
            player1RegularWin()
            PlaySoundFile(soundFilePaths[44])
        elseif string.find(message, "has more than") and string.find(message, unitName2) then
            player2RegularWin()
            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 string.find(message, "has won this") then
                player1BlackjackWin()
                PlaySoundFile(soundFilePaths[44])
            else
                PlaySoundFile(soundFilePaths[52])
            end

            if Player1Active and not Player2Active and not Player3Active and not Player4Active and not Player5Active then 
                turn = 10
            else
                print("")
            end

        elseif string.find(message, "has Blackjack") and string.find(message, unitName2) then
            playerFrame.numberPlayer2Text:SetText("Blackjack")
            playerFrame.numberPlayer2Text:SetTextColor(1, 1, 0)

            if string.find(message, "has won this") then
                player2BlackjackWin()
                PlaySoundFile(soundFilePaths[45])
            else
                PlaySoundFile(soundFilePaths[53])
            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])

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

                player1MainBetValue = tonumber(string.match(player1MainBetAmount:GetText(), "%d+"))
                if player1MainBetValue then

                    player1totalLoss = player1totalLoss + tonumber(player1MainBetValue)
                    historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")
            
                    player1totalProfit = player1totalProfit - tonumber(player1MainBetValue)
                    historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")
                    if player1totalProfit >= 0 then
                        historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                    else
                        historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                    end

                    player1PPBetAmountValue = tonumber(string.match(player1PPBetAmount:GetText(), "%d+"))
                    if player1PPBetAmountValue then
                        if player1PPSideBetWin == false then

                            player1totalLoss = player1totalLoss + tonumber(player1PPBetAmountValue)
                            historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")

                            player1totalProfit = player1totalProfit - tonumber(player1PPBetAmountValue)
                            historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

                            if player1totalProfit >= 0 then
                                historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                            else
                                historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                            end

                        end
                    end

                    player1213BetAmountValue = tonumber(string.match(player1213BetAmount:GetText(), "%d+"))
                    if player1213BetAmountValue then
                        if player1213SideBetWin == false then

                            player1totalLoss = player1totalLoss + tonumber(player1213BetAmountValue)
                            historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")

                            player1totalProfit = player1totalProfit - tonumber(player1213BetAmountValue)
                            historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

                            if player1totalProfit >= 0 then
                                historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                            else
                                historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                            end

                        end
                    end

                else
                end

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

                player1MainBetValue = tonumber(string.match(player1MainBetAmount:GetText(), "%d+"))
                if player1MainBetValue then

                    player1totalLoss = player1totalLoss + tonumber(player1MainBetValue)
                    historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")
            
                    player1totalProfit = player1totalProfit - tonumber(player1MainBetValue)
                    historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")
                    if player1totalProfit >= 0 then
                        historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                    else
                        historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                    end

                    player1PPBetAmountValue = tonumber(string.match(player1PPBetAmount:GetText(), "%d+"))
                    if player1PPBetAmountValue then
                        if player1PPSideBetWin == false then

                            player1totalLoss = player1totalLoss + tonumber(player1PPBetAmountValue)
                            historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")

                            player1totalProfit = player1totalProfit - tonumber(player1PPBetAmountValue)
                            historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

                            if player1totalProfit >= 0 then
                                historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                            else
                                historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                            end

                        end
                    end

                    player1213BetAmountValue = tonumber(string.match(player1213BetAmount:GetText(), "%d+"))
                    if player1213BetAmountValue then
                        if player1213SideBetWin == false then

                            player1totalLoss = player1totalLoss + tonumber(player1213BetAmountValue)
                            historyFrame.player1totalLostAmount:SetText(player1totalLoss .. " G")

                            player1totalProfit = player1totalProfit - tonumber(player1213BetAmountValue)
                            historyFrame.player1ProfitAmount:SetText(player1totalProfit .. " G")

                            if player1totalProfit >= 0 then
                                historyFrame.player1ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                            else
                                historyFrame.player1ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                            end

                        end
                    end

                else
                end

                player2MainBetValue = tonumber(string.match(player2MainBetAmount:GetText(), "%d+"))
                if player2MainBetValue then

                    player2totalLoss = player2totalLoss + tonumber(player2MainBetValue)
                    historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")
            
                    player2totalProfit = player2totalProfit - tonumber(player2MainBetValue)
                    historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")
                    if player2totalProfit >= 0 then
                        historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                    else
                        historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                    end

                    player2PPBetAmountValue = tonumber(string.match(player2PPBetAmount:GetText(), "%d+"))
                    if player2PPBetAmountValue then
                        if player2PPSideBetWin == false then

                            player2totalLoss = player2totalLoss + tonumber(player2PPBetAmountValue)
                            historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")

                            player2totalProfit = player2totalProfit - tonumber(player2PPBetAmountValue)
                            historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

                            if player2totalProfit >= 0 then
                                historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                            else
                                historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                            end

                        end
                    end

                    player2213BetAmountValue = tonumber(string.match(player2213BetAmount:GetText(), "%d+"))
                    if player2213BetAmountValue then
                        if player2213SideBetWin == false then

                            player2totalLoss = player2totalLoss + tonumber(player2213BetAmountValue)
                            historyFrame.player2totalLostAmount:SetText(player2totalLoss .. " G")

                            player2totalProfit = player2totalProfit - tonumber(player2213BetAmountValue)
                            historyFrame.player2ProfitAmount:SetText(player2totalProfit .. " G")

                            if player2totalProfit >= 0 then
                                historyFrame.player2ProfitAmount:SetTextColor(0.098, 0.878, 0.098)
                            else
                                historyFrame.player2ProfitAmount:SetTextColor(0.961, 0.306, 0.306)
                            end

                        end
                    end

                else
                end

            end

        elseif string.find(message, "hit a Suited Three of a Kind") then
            if string.find(message, "Player 1") and playerName == unitName1 then 

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

                    player1213CardName1 = dealtCards[1]
                    dealer213CardName1 = dealtCards[2]
                    player1213CardName2 = dealtCards[3]

                    player1213CardFileName1 = GetCardFileName(player1213CardName1)
                    dealer213CardFileName1 = GetCardFileName(dealer213CardName1)
                    player1213CardFileName2 = GetCardFileName(player1213CardName2)

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

                    player1213CardName1 = dealtCards[1]
                    dealer213CardName1 = dealtCards[3]
                    player1213CardName2 = dealtCards[4]

                    player1213CardFileName1 = GetCardFileName(player1213CardName1)
                    dealer213CardFileName1 = GetCardFileName(dealer213CardName1)
                    player1213CardFileName2 = GetCardFileName(player1213CardName2)

                end

                if player1213CardFileName1 then
                    sideBetWinFrame.player1213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player1213CardFileName1)
                else
                    print("Card image filename not found for " .. player1213CardName1)
                end
                if dealer213CardFileName1 then
                    sideBetWinFrame.dealer213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. dealer213CardFileName1)
                else
                    print("Card image filename not found for " .. dealer213CardName1)
                end
                if player1213CardFileName2 then
                    sideBetWinFrame.player1213CardImage2:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player1213CardFileName2)
                else
                    print("Card image filename not found for " .. player1213CardName2)
                end

                player1SuitedThreeOfAKindNotification()

                if string.find(message, "congratulations") then
                    player1SuitedThreeOfAKindWin()
                else
                    print("")
                end
            elseif string.find(message, "Player 2") and playerName == unitName2 then

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

                    player2213CardName1 = dealtCards[2]
                    dealer213CardName1 = dealtCards[3]
                    player2213CardName2 = dealtCards[5]

                    player2213CardFileName1 = GetCardFileName(player2213CardName1)
                    dealer213CardFileName1 = GetCardFileName(dealer213CardName1)
                    player2213CardFileName2 = GetCardFileName(player2213CardName2)

                end

                if player2213CardFileName1 then
                    sideBetWinFrame.player2213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player2213CardFileName1)
                else
                    print("Card image filename not found for " .. player2213CardName1)
                end
                if dealer213CardFileName1 then
                    sideBetWinFrame.dealer213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. dealer213CardFileName1)
                else
                    print("Card image filename not found for " .. dealer213CardName1)
                end
                if player2213CardFileName2 then
                    sideBetWinFrame.player2213CardImage2:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player2213CardFileName2)
                else
                    print("Card image filename not found for " .. player2213CardName2)
                end

                player2SuitedThreeOfAKindNotification()

                if string.find(message, "congratulations") then
                    player2SuitedThreeOfAKindWin()
                else
                    print("")
                end  
            end
        elseif string.find(message, "hit a Straight Flush") then
            if string.find(message, "Player 1") and playerName == unitName1 then 

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

                    player1213CardName1 = dealtCards[1]
                    dealer213CardName1 = dealtCards[2]
                    player1213CardName2 = dealtCards[3]

                    player1213CardFileName1 = GetCardFileName(player1213CardName1)
                    dealer213CardFileName1 = GetCardFileName(dealer213CardName1)
                    player1213CardFileName2 = GetCardFileName(player1213CardName2)

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

                    player1213CardName1 = dealtCards[1]
                    dealer213CardName1 = dealtCards[3]
                    player1213CardName2 = dealtCards[4]

                    player1213CardFileName1 = GetCardFileName(player1213CardName1)
                    dealer213CardFileName1 = GetCardFileName(dealer213CardName1)
                    player1213CardFileName2 = GetCardFileName(player1213CardName2)

                end

                if player1213CardFileName1 then
                    sideBetWinFrame.player1213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player1213CardFileName1)
                else
                    print("Card image filename not found for " .. player1213CardName1)
                end
                if dealer213CardFileName1 then
                    sideBetWinFrame.dealer213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. dealer213CardFileName1)
                else
                    print("Card image filename not found for " .. dealer213CardName1)
                end
                if player1213CardFileName2 then
                    sideBetWinFrame.player1213CardImage2:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player1213CardFileName2)
                else
                    print("Card image filename not found for " .. player1213CardName2)
                end

                player1StraightFlushNotification()

                if string.find(message, "congratulations") then
                    player1StraightFlushWin()
                else
                    print("")
                end
            elseif string.find(message, "Player 2") and playerName == unitName2 then

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

                    player2213CardName1 = dealtCards[2]
                    dealer213CardName1 = dealtCards[3]
                    player2213CardName2 = dealtCards[5]

                    player2213CardFileName1 = GetCardFileName(player2213CardName1)
                    dealer213CardFileName1 = GetCardFileName(dealer213CardName1)
                    player2213CardFileName2 = GetCardFileName(player2213CardName2)

                end

                if player2213CardFileName1 then
                    sideBetWinFrame.player2213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player2213CardFileName1)
                else
                    print("Card image filename not found for " .. player2213CardName1)
                end
                if dealer213CardFileName1 then
                    sideBetWinFrame.dealer213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. dealer213CardFileName1)
                else
                    print("Card image filename not found for " .. dealer213CardName1)
                end
                if player2213CardFileName2 then
                    sideBetWinFrame.player2213CardImage2:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player2213CardFileName2)
                else
                    print("Card image filename not found for " .. player2213CardName2)
                end

                player2StraightFlushNotification()

                if string.find(message, "congratulations") then
                    player2StraightFlushWin()
                else
                    print("")
                end  
            end
        elseif string.find(message, "hit a Flush") then
            if string.find(message, "Player 1") and playerName == unitName1 then 

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

                    player1213CardName1 = dealtCards[1]
                    dealer213CardName1 = dealtCards[2]
                    player1213CardName2 = dealtCards[3]

                    player1213CardFileName1 = GetCardFileName(player1213CardName1)
                    dealer213CardFileName1 = GetCardFileName(dealer213CardName1)
                    player1213CardFileName2 = GetCardFileName(player1213CardName2)

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

                    player1213CardName1 = dealtCards[1]
                    dealer213CardName1 = dealtCards[3]
                    player1213CardName2 = dealtCards[4]

                    player1213CardFileName1 = GetCardFileName(player1213CardName1)
                    dealer213CardFileName1 = GetCardFileName(dealer213CardName1)
                    player1213CardFileName2 = GetCardFileName(player1213CardName2)

                end

                if player1213CardFileName1 then
                    sideBetWinFrame.player1213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player1213CardFileName1)
                else
                    print("Card image filename not found for " .. player1213CardName1)
                end
                if dealer213CardFileName1 then
                    sideBetWinFrame.dealer213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. dealer213CardFileName1)
                else
                    print("Card image filename not found for " .. dealer213CardName1)
                end
                if player1213CardFileName2 then
                    sideBetWinFrame.player1213CardImage2:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player1213CardFileName2)
                else
                    print("Card image filename not found for " .. player1213CardName2)
                end

                player1FlushNotification()

                if string.find(message, "congratulations") then
                    player1FlushWin()
                else
                    print("")
                end
            elseif string.find(message, "Player 2") and playerName == unitName2 then

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

                    player2213CardName1 = dealtCards[2]
                    dealer213CardName1 = dealtCards[3]
                    player2213CardName2 = dealtCards[5]

                    player2213CardFileName1 = GetCardFileName(player2213CardName1)
                    dealer213CardFileName1 = GetCardFileName(dealer213CardName1)
                    player2213CardFileName2 = GetCardFileName(player2213CardName2)

                end

                if player2213CardFileName1 then
                    sideBetWinFrame.player2213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player2213CardFileName1)
                else
                    print("Card image filename not found for " .. player2213CardName1)
                end
                if dealer213CardFileName1 then
                    sideBetWinFrame.dealer213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. dealer213CardFileName1)
                else
                    print("Card image filename not found for " .. dealer213CardName1)
                end
                if player2213CardFileName2 then
                    sideBetWinFrame.player2213CardImage2:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player2213CardFileName2)
                else
                    print("Card image filename not found for " .. player2213CardName2)
                end

                player2FlushNotification()

                if string.find(message, "congratulations") then
                    player2FlushWin()
                else
                    print("")
                end  
            end
        elseif string.find(message, "hit a Three of a Kind") then
            if string.find(message, "Player 1") and playerName == unitName1 then 

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

                    player1213CardName1 = dealtCards[1]
                    dealer213CardName1 = dealtCards[2]
                    player1213CardName2 = dealtCards[3]

                    player1213CardFileName1 = GetCardFileName(player1213CardName1)
                    dealer213CardFileName1 = GetCardFileName(dealer213CardName1)
                    player1213CardFileName2 = GetCardFileName(player1213CardName2)

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

                    player1213CardName1 = dealtCards[1]
                    dealer213CardName1 = dealtCards[3]
                    player1213CardName2 = dealtCards[4]

                    player1213CardFileName1 = GetCardFileName(player1213CardName1)
                    dealer213CardFileName1 = GetCardFileName(dealer213CardName1)
                    player1213CardFileName2 = GetCardFileName(player1213CardName2)

                end

                if player1213CardFileName1 then
                    sideBetWinFrame.player1213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player1213CardFileName1)
                else
                    print("Card image filename not found for " .. player1213CardName1)
                end
                if dealer213CardFileName1 then
                    sideBetWinFrame.dealer213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. dealer213CardFileName1)
                else
                    print("Card image filename not found for " .. dealer213CardName1)
                end
                if player1213CardFileName2 then
                    sideBetWinFrame.player1213CardImage2:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player1213CardFileName2)
                else
                    print("Card image filename not found for " .. player1213CardName2)
                end

                player1ThreeOfAKindNotification()

                if string.find(message, "congratulations") then
                    player1ThreeOfAKindWin()
                else
                    print("")
                end
            elseif string.find(message, "Player 2") and playerName == unitName2 then

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

                    player2213CardName1 = dealtCards[2]
                    dealer213CardName1 = dealtCards[3]
                    player2213CardName2 = dealtCards[5]

                    player2213CardFileName1 = GetCardFileName(player2213CardName1)
                    dealer213CardFileName1 = GetCardFileName(dealer213CardName1)
                    player2213CardFileName2 = GetCardFileName(player2213CardName2)

                end

                if player2213CardFileName1 then
                    sideBetWinFrame.player2213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player2213CardFileName1)
                else
                    print("Card image filename not found for " .. player2213CardName1)
                end
                if dealer213CardFileName1 then
                    sideBetWinFrame.dealer213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. dealer213CardFileName1)
                else
                    print("Card image filename not found for " .. dealer213CardName1)
                end
                if player2213CardFileName2 then
                    sideBetWinFrame.player2213CardImage2:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player2213CardFileName2)
                else
                    print("Card image filename not found for " .. player2213CardName2)
                end

                player2ThreeOfAKindNotification()

                if string.find(message, "congratulations") then
                    player2ThreeOfAKindWin()
                else
                    print("")
                end  
            end
        elseif string.find(message, "hit a Straight") then
            if string.find(message, "Player 1") and playerName == unitName1 then 

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

                    player1213CardName1 = dealtCards[1]
                    dealer213CardName1 = dealtCards[2]
                    player1213CardName2 = dealtCards[3]

                    player1213CardFileName1 = GetCardFileName(player1213CardName1)
                    dealer213CardFileName1 = GetCardFileName(dealer213CardName1)
                    player1213CardFileName2 = GetCardFileName(player1213CardName2)

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

                    player1213CardName1 = dealtCards[1]
                    dealer213CardName1 = dealtCards[3]
                    player1213CardName2 = dealtCards[4]

                    player1213CardFileName1 = GetCardFileName(player1213CardName1)
                    dealer213CardFileName1 = GetCardFileName(dealer213CardName1)
                    player1213CardFileName2 = GetCardFileName(player1213CardName2)

                end

                if player1213CardFileName1 then
                    sideBetWinFrame.player1213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player1213CardFileName1)
                else
                    print("Card image filename not found for " .. player1213CardName1)
                end
                if dealer213CardFileName1 then
                    sideBetWinFrame.dealer213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. dealer213CardFileName1)
                else
                    print("Card image filename not found for " .. dealer213CardName1)
                end
                if player1213CardFileName2 then
                    sideBetWinFrame.player1213CardImage2:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player1213CardFileName2)
                else
                    print("Card image filename not found for " .. player1213CardName2)
                end

                player1StraightNotification()

                if string.find(message, "congratulations") then
                    player1StraightWin()
                else
                    print("")
                end
            elseif string.find(message, "Player 2") and playerName == unitName2 then

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

                    player2213CardName1 = dealtCards[2]
                    dealer213CardName1 = dealtCards[3]
                    player2213CardName2 = dealtCards[5]

                    player2213CardFileName1 = GetCardFileName(player2213CardName1)
                    dealer213CardFileName1 = GetCardFileName(dealer213CardName1)
                    player2213CardFileName2 = GetCardFileName(player2213CardName2)

                end

                if player2213CardFileName1 then
                    sideBetWinFrame.player2213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player2213CardFileName1)
                else
                    print("Card image filename not found for " .. player2213CardName1)
                end
                if dealer213CardFileName1 then
                    sideBetWinFrame.dealer213CardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. dealer213CardFileName1)
                else
                    print("Card image filename not found for " .. dealer213CardName1)
                end
                if player2213CardFileName2 then
                    sideBetWinFrame.player2213CardImage2:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player2213CardFileName2)
                else
                    print("Card image filename not found for " .. player2213CardName2)
                end

                player2StraightNotification()

                if string.find(message, "congratulations") then
                    player2StraightWin()
                else
                    print("")
                end  
            end
        elseif string.find(message, "hit a Perfect Pair") then
            if string.find(message, "Player 1") and playerName == unitName1 then 

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

                    player1PPCardName1 = dealtCards[1]
                    player1PPCardName2 = dealtCards[3]

                    player1PPCardFileName1 = GetCardFileName(player1PPCardName1)
                    player1PPCardFileName2 = GetCardFileName(player1PPCardName2)

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

                    player1PPCardName1 = dealtCards[1]
                    player1PPCardName2 = dealtCards[4]

                    player1PPCardFileName1 = GetCardFileName(player1PPCardName1)
                    player1PPCardFileName2 = GetCardFileName(player1PPCardName2)

                end

                if player1PPCardFileName1 then
                    sideBetWinFrame.player1PPCardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player1PPCardFileName1)
                else
                    print("Card image filename not found for " .. player1PPCardName1)
                end
                if player1PPCardFileName2 then
                    sideBetWinFrame.player1PPCardImage2:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player1PPCardFileName2)
                else
                    print("Card image filename not found for " .. player1PPCardName2)
                end

                player1PerfectPairNotification()

                if string.find(message, "congratulations") then
                    player1PerfectPairWin()
                else
                    print("")
                end
            elseif string.find(message, "Player 2") and playerName == unitName2 then

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

                    player2PPCardName1 = dealtCards[2]
                    player2PPCardName2 = dealtCards[5]

                    player2PPCardFileName1 = GetCardFileName(player2PPCardName1)
                    player2PPCardFileName2 = GetCardFileName(player2PPCardName2)

                end

                if player2PPCardFileName1 then
                    sideBetWinFrame.player2PPCardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player2PPCardFileName1)
                else
                    print("Card image filename not found for " .. player2PPCardName1)
                end
                if player2PPCardFileName2 then
                    sideBetWinFrame.player2PPCardImage2:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player2PPCardFileName2)
                else
                    print("Card image filename not found for " .. player2PPCardName2)
                end

                player2PerfectPairNotification()

                if string.find(message, "congratulations") then
                    player2PerfectPairWin()
                else
                    print("")
                end  
            end
        elseif string.find(message, "hit a Coloured Pair") then
            if string.find(message, "Player 1") and playerName == unitName1 then 

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

                    player1PPCardName1 = dealtCards[1]
                    player1PPCardName2 = dealtCards[3]

                    player1PPCardFileName1 = GetCardFileName(player1PPCardName1)
                    player1PPCardFileName2 = GetCardFileName(player1PPCardName2)

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

                    player1PPCardName1 = dealtCards[1]
                    player1PPCardName2 = dealtCards[4]

                    player1PPCardFileName1 = GetCardFileName(player1PPCardName1)
                    player1PPCardFileName2 = GetCardFileName(player1PPCardName2)

                end

                if player1PPCardFileName1 then
                    sideBetWinFrame.player1PPCardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player1PPCardFileName1)
                else
                    print("Card image filename not found for " .. player1PPCardName1)
                end
                if player1PPCardFileName2 then
                    sideBetWinFrame.player1PPCardImage2:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player1PPCardFileName2)
                else
                    print("Card image filename not found for " .. player1PPCardName2)
                end

                player1ColouredPairNotification()

                if string.find(message, "congratulations") then
                    player1ColouredPairWin()
                else
                    print("")
                end
            elseif string.find(message, "Player 2") and playerName == unitName2 then

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

                    player2PPCardName1 = dealtCards[2]
                    player2PPCardName2 = dealtCards[5]

                    player2PPCardFileName1 = GetCardFileName(player2PPCardName1)
                    player2PPCardFileName2 = GetCardFileName(player2PPCardName2)

                end

                if player2PPCardFileName1 then
                    sideBetWinFrame.player2PPCardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player2PPCardFileName1)
                else
                    print("Card image filename not found for " .. player2PPCardName1)
                end
                if player2PPCardFileName2 then
                    sideBetWinFrame.player2PPCardImage2:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player2PPCardFileName2)
                else
                    print("Card image filename not found for " .. player2PPCardName2)
                end

                player2ColouredPairNotification()

                if string.find(message, "congratulations") then
                    player2ColouredPairWin()
                else
                    print("")
                end  
            end
        elseif string.find(message, "hit a Mixed Pair") then
            if string.find(message, "Player 1") and playerName == unitName1 then 

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

                    player1PPCardName1 = dealtCards[1]
                    player1PPCardName2 = dealtCards[3]

                    player1PPCardFileName1 = GetCardFileName(player1PPCardName1)
                    player1PPCardFileName2 = GetCardFileName(player1PPCardName2)

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

                    player1PPCardName1 = dealtCards[1]
                    player1PPCardName2 = dealtCards[4]

                    player1PPCardFileName1 = GetCardFileName(player1PPCardName1)
                    player1PPCardFileName2 = GetCardFileName(player1PPCardName2)

                end

                if player1PPCardFileName1 then
                    sideBetWinFrame.player1PPCardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player1PPCardFileName1)
                else
                    print("Card image filename not found for " .. player1PPCardName1)
                end
                if player1PPCardFileName2 then
                    sideBetWinFrame.player1PPCardImage2:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player1PPCardFileName2)
                else
                    print("Card image filename not found for " .. player1PPCardName2)
                end

                player1MixedPairNotification()

                if string.find(message, "congratulations") then
                    player1MixedPairWin()
                else
                    print("")
                end
            elseif string.find(message, "Player 2") and playerName == unitName2 then

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

                    player2PPCardName1 = dealtCards[2]
                    player2PPCardName2 = dealtCards[5]

                    player2PPCardFileName1 = GetCardFileName(player2PPCardName1)
                    player2PPCardFileName2 = GetCardFileName(player2PPCardName2)

                end

                if player2PPCardFileName1 then
                    sideBetWinFrame.player2PPCardImage1:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player2PPCardFileName1)
                else
                    print("Card image filename not found for " .. player2PPCardName1)
                end
                if player2PPCardFileName2 then
                    sideBetWinFrame.player2PPCardImage2:SetTexture("Interface\\AddOns\\BlackjackPlayer\\Images\\" .. player2PPCardFileName2)
                else
                    print("Card image filename not found for " .. player2PPCardName2)
                end

                player2MixedPairNotification()

                if string.find(message, "congratulations") then
                    player2MixedPairWin()
                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

    player1totalBetAmount = player1totalBetAmount + tonumber(betInsuranceAmount1)
    historyFrame.player1totalWageredAmount:SetText(player1totalBetAmount .. " G")

    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

        player1totalBetAmount = player1totalBetAmount + tonumber(betAmount1)
        historyFrame.player1totalWageredAmount:SetText(player1totalBetAmount .. " G")

    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

    player1totalBetAmount = player1totalBetAmount + tonumber(betInsuranceAmount2)
    historyFrame.player1totalWageredAmount:SetText(player1totalBetAmount .. " G")

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

        player2totalBetAmount = player2totalBetAmount + tonumber(betAmount2)
        historyFrame.player2totalWageredAmount:SetText(player2totalBetAmount .. " G")

    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()
    historyFrame:Hide()
    rulesFrame:Hide()
    payoutsFrame: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"