How do I create poker game?

0 favourites
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hi guys,

    I'm trying to make Poker Game in Construct. But I have no idea how to make combinations and compare cards where there are few players.

    Everything i found is scirra[dot]com/forum/viewtopic.php?t=64076&start=0

    But it's not enough. Any ideas?

    You can check what have i done so far: dropbox[dot]com/s/9onfsh1p1o9i1a3/game.capx?dl=0

  • Why not assigning to each card two constants, one for the color (1 to 4) and one for the value (1 to 13 with King = 13) ?

  • And if you use 32 cards, just forget to assign values from 2 to 6.

    Also, you can set the 1 value to 14, as it is the higher value in poker...

  • ok..that's the easy part <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    how to check the hand?

    (one pair.two pair,three of kind.straigh,flush,full house,four of kind,straight flush,royal flush)

    Please check the capx and feel free to modify it <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    capx:

    http://s000.tinyupload.com/index.php?fi ... 9704810401

    Thanks!

  • First, you can, for example, copy the 5 values of the hand in an array of 5x2 values and sort them from the higher to the lower cards value.

    Now, check them in this order :

    Check in the array if the 5 cards have the same color value first.

    • In this case, check the cards value : 14,13,12,11,10 is a Royal Flush.
    • ELSE 13,12,11,10,9 or 12,11,10,9,8 or 11,10,9,8,7 are Straight Flush.
    • ELSE the other case is a Flush.

    ELSE If the 5 cards does not have the same color value, check the number of sames cards value in the array.

    If 4 are the sames, it's Four of a Kind.

    ELSE if 3 are the sames, check if the two others are the sames together, if yes, it's a FullHouse, ELSE it's Three of a Kind.

    ELSE if 2 are the sames, check if the three others are the sames together, if yes, it's a FullHouse, ELSE if there is another pair, it's TWO PAIR, ELSE it's one pair.

    ELSE check for a Straight.

    ELSE if no cards are the same, check for the Higher Card.

    If you have multiple players in your game, don't forget, in some cases, to compare others cards next.

    Example :

    If two players have one pair of 7, check the Higher next card to see who win.

    I don't know what's happens if two players have the exact same hand... lol

    http://en.wikipedia.org/wiki/List_of_poker_hands

  • If you have multiple players, don't forget to also give a constant value to each possibility of winner hand.

    Example :

    • HigherCard = 1
    • OnePair = 2
    • TwoPair = 3

    etc...

    Then, compare first who has the most powerful hand. (TwoPair > OnePair because 3 > 2 ...)

    In case of equality, compare the cards in the array and in the order (one array per player is needed !)

  • Wow,

    Thanks guys Will try to make everything!

  • ok..that's the easy part

    how to check the hand?

    (one pair.two pair,three of kind.straigh,flush,full house,four of kind,straight flush,royal flush)

    Please check the capx and feel free to modify it

    capx:Thanks!

    capx has helped me a lot. But I cant get how for example I should compare values when there will be 2 players?

    Can you help me with that? I very appreciate it!

    Thanks

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • first.

    .Thank you mister Dj ... for tips..

    ..now I see the logic..i need to start from top,not from bottom(one pair,tree of kind,4 of kind...)

    kelney i glad capx help you..

    .but...i still struggle with Video Poker game(for only one player

  • First make constants in this order, from the bottom to the top :

    • HigherCard = 1
    • OnePair = 2
    • TwoPair = 3
    • Three of a kind = 4

    Etc...

    Create an array called, for example, "HandValue" with the players count cases, for example, we will take 4 players, so an array of 4 cases.

    Once you checked the hand of Player1, give him the constant corresponding, set it to his array case.

    Once you checked the hand of Player2, give him the constant corresponding, set it to his array case.

    Etc...

    Then compare in the HandValue array who has the best value.

    In case of equality, as you have an other array (of 5x2) with each hand sorted from the greater card to the lower, do a loop.

    In this loops, compare the first cards of the "winners".

    If one of them has the greater 1st card, he is THE winner.

    Else, if equality, compare the second cards of the "new winners"... If someone has a lower card, he is eliminated.

    If one of them has the greater 2nd card, he is THE winner.

    Etc...

    In case of 5 equals card for two or more players, you have to deal with total equalities.

  • I'm trying to implement what you're telling me to do, but i cant.

    I use capx which korbaach uploaded here.

    I'm adding 2 cards for players, and i have no idea how to compare all that cards. Can you help me with that on this capx example?

    Thank you.

  • Today and tomorrow, i have not the time, but if you can wait theese two days, i'll take a look at the capx file.

  • Sure, thanks.

    I very appreciate this.

  • kelney

    Right, this is done.

    http://www.retro-bruno.com/downloads/Poker.capx

    I've changed a lot of things...

    I'm programming like a cro magnon... lol

    EDIT:

    New version optimized, same link.

    EDIT2:

    Added some functions, you can really play now. <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":-)" title="Smile">

  • Great working example

    Sure, the events could be optimized, but I actually like seeing it this way, for it's easier to read.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)