/card Poker (deck) support
#1
Title of Suggestion: /card Poker (deck) support

Description
Decks are required for casino games such as poker, which cannot be achieved with the current /card system as cards could be drawn twice causing clashes.



Why?
I've discussed this with Joe Joe and Forgee, and we came upon the reasonable idea with the format as so:

/deck (generates an unlimited deck, essentially the same to /card now)

/card (If no deck is generated, this will notify, but will either pick from unlimited deck or sized deck as set by...)

/deck (1-8) (Only 1 deck needed for poker, but this allows for up to 8 for blackjack, although the house should consider that card counting is made extremely easy by using this)

/pcard <player> (This privately messages from either an unlimited or sized deck. Used predominantly in poker to deal private cards. Possible second argument for how many cards to deal, AKA 2 for a poker hand)

The main reason for this is for poker games which do require a deck for obvious reasons. This should be pretty easy to implement (something similar to my example which follows the above schema) but we agreed that this is the best schema we could think of at the time for simplicity. Could do different features such as /pcard <p1> <p2> etc to send multiple players their cards at once before then printing this to the dealer as a table?
This should simplify poker RPs and keep logs on the server rather than working off of word of mouth from the croupier. 

Hopefully this is of some use, largely untested code but shouldn't be *too* far off a functional system, minus some adjustment and possibly fixing of mistakes.



Spoiler :
Code:
local playerCards = {}

-- Command to create a set of 1-8 decks of playing cards
cityrp.command.add("deck", "b", 0, function(ply, arguments)

    local decksize = tonumber(arguments[1])

    if (decksize < 1 or decksize > 8) then
            
        ply:Notify("Please choose a decksize between 1 and 8 or enter /deck for an infinite deck.", 1)    
        return
            
    end

    if !(decksize) then
        
        local deck = true

    else
    
        local suits = {"Spades", "Clubs", "Hearts", "Diamonds"}
        local values = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"}

        local deck = {}

        for i=1, decksize do
                
            for k, value in pairs(values) do
                        
                for k, suit in pairs(suits) do  
                                            
                    table.insert(deck, value .. " of " .. suit)  
                                            
                end  
                                            
            end  
                            
        end
        
    end

    table.insert(playerCards, {ply, deck})
    ply:Notify("Deck generated!")

end, "Commands", "<1-8>", "Creates a pile of 1-8 card decks for casino games")

-- Command to print a random playing card from a generated deck
cityrp.command.add("card", "b", 0, function(ply)

    local deck = {}
    local index = 0
    for k,v in pairs(playerCards) do
        if (v[1] == ply) then
            deck = v[2]
            index = k
            break
        end
    end

    if (!deck or (table.IsEmpty(deck) and istable(deck)) then

        ply:Notify("You must generate a deck. Use /deck (1-8).", 1)
        return
            
    end



    if (deck = true) then

        local suits = {"Spades", "Clubs", "Hearts", "Diamonds"}
        local values = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"}

        local card = table.Random("values") .. "of " .. table.Random("suits")
        
    else

        local card, index = table.Random(deck)
        table.remove(playerCards,index)
        table.insert(playerCards, index, {ply, deck})

    end

    ply:ConCommand("cityrp me drew " .. card)

end, "Commands", "<none>", "Picks a random card from the deck")

-- Command to PM a random playing card from a generated deck


cityrp.command.add("pcard", "b", 1, function(ply, arguments)

    local target = arguments[1] -- validation here to ensure target is a player on server
    

    local deck = {}
    local index = 0
    for k,v in pairs(playerCards) do
        if (v[1] == ply) then
            deck = v[2]
            index = k
            break
        end
    end

    if (!deck or (table.IsEmpty(deck) and istable(deck)) then

        ply:Notify("You must generate a deck. Use /deck (1-8).", 1)
        return
            
    end



    if (deck = true) then

        local suits = {"Spades", "Clubs", "Hearts", "Diamonds"}
        local values = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"}

        local card = table.Random("values") .. "of " .. table.Random("suits")
        
    else

        local card, index = table.Random(deck)
        table.remove(playerCards,index)
        table.insert(playerCards, index, {ply, deck})

    end

    ply:ConCommand("cityrp pm " .. target .. " Card: " .. card)

end, "Commands", "<player>", "PMs a random card from the deck")




Thanks for reading Smile
Regards,
Connnnnnnn

Consider giving me a rep point here.

#2
Yas queen +support
The following 1 user Likes Forgee's post:
  • Conn
#3
did


Forum Jump:


Users browsing this thread: 1 Guest(s)