Jump to content

[SOLVED] Casino php scripts


SirChick

Recommended Posts

Was wondering about casino games with php how do you make it so that if a play is dealt a card say 10 of clubs.... the script will know that it is not physically possibly to deal another 10 of clubs? Do you make an array of all the cards and take out that value from it or something ?

Link to comment
Share on other sites

Heres all the card names just to help you out so you dont gotta write em' Im making a blackjack game in Visual Basic so you will need to Translate it itnto PHP but here ya go...

 

Private Enum CardNames
    AceOfSpades
    TwoOfSpades
    ThreeOfSpades
    FourOfSpades
    FiveOfSpades
    SixOfSpades
    SevenOfSpades
    EightOfSpades
    NineOfSpades
    TenOfSpades
    JackOfSpades
    QueenOfSpades
    KingOfSpades
    AceOfDiamonds
    TwoOfDiamonds
    ThreeOfDiamonds
    FourOfDiamonds
    FiveOfDiamonds
    SixOfDiamonds
    SevenOfDiamonds
    EightOfDiamonds
    NineOfDiamonds
    TenOfDiamonds
    JackOfDiamonds
    QueenOfDiamonds
    KingOfDiamonds
    AceOfClubs
    TwoOfClubs
    ThreeOfClubs
    FourOfClubs
    FiveOfClubs
    SixOfClubs
    SevenOfClubs
    EightOfClubs
    NineOfClubs
    TenOfClubs
    JackOfClubs
    QueenOfClubs
    KingOfClubs
    AceOfHearts
    TwoOfHearts
    ThreeOfHearts
    FourOfHearts
    FiveOfHearts
    SixOfHearts
    SevenOfHearts
    EightOfHearts
    NineOfHearts
    TenOfHearts
    JackOfHearts
    QueenOfHearts
    KingOfHearts
End Enum

Link to comment
Share on other sites

Here's my suggestion:

 

Two arrays: one array contains all the cards in the deck (from which you randomly pick a card). one array contains all the cards that are currently in play, or have been played.

 

if(in_array($cards_played,$card_drawn)){//uh-oh, we've already played this card!
//re-draw, w/e
} else {
$cards_played[] = $card_drawn;//auto-add to end
//proceed with script, etc...
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.