Poker Hand Detection
A big part of our game is having the player collect cards as they progress the run in order to buff up their character. And as they collect those cards they will also be able to create a poker hand from the cards they've collected. So, implementing a way for the game to recognize what poker hand the player currently has is necessary. To do this, I needed to create a way for the game to not only keep track of what cards the player has but as well to sort those cards in order to know if the cards produce a hand. Sorting is necessary since the player can have a pair in hand but if the cards aren't gotten one after the other, then it wouldn't have detected a pair since they aren't right next to each other. To fix this, I made a copy list of the cards in hand and then sorted that copy based of the rank and suits of the card.
(Despite it saying High Card x5 it will use the highest poker hand which in this case is Royal Flush)
I needed to create some helper functions that allowed me to get the Rank and Suit of the card using the name of the card in to do so (Some string manipulation) as well as making a custom sort that would organize the hand based of the rank as well as suit using LINQ.
With this done I've made a way for the game to recognize which poker hand the player has as soon as a card is picked up, it does not check constantly only once a card is added. Now, some testing is needed to ensure that any combination of card pickups will correctly be assessed to give the player their buff. To do this, A team member created a specific card pickup that can be used for testing by using a passed in scriptable game object . I then made scriptable game objects for each card and so we have ways for testing a multitude of card pickup combinations as well as having specific card pickups for the future.
Published 4/12/2024
Author: Gustavo Camacho
Get Suits of the Abyss
Suits of the Abyss
Status | In development |
Author | AstralArchitects |
Genre | Action, Platformer |
Tags | Roguelike |
More posts
- Carrying player data between scenes in Unity (Pt.3, The Finale)May 04, 2024
- Player ground detection issueMay 02, 2024
- URP sprite shader issueApr 27, 2024
- Carrying player data between scenes in Unity (Pt.2)Apr 27, 2024
- Weapon Effects and AnimationsApr 27, 2024
- Resolution issuesApr 27, 2024
- Minimap and fog of warApr 20, 2024
- Player WeaponsApr 20, 2024
- Carrying player data between scenes in UnityApr 13, 2024
Leave a comment
Log in with itch.io to leave a comment.