Torrwin
asked on
Card Game Ideas - How to handle deck and players hand?
Hello,
I am making a card game, and I was looking for thoughts/ideas on how to proceed.
Currently I have two arrays: one contains the cards in the players hand, and one contains the cards in the deck. Each array is two dimensional with one column for card number(2, 3, 4, ... Q, K, A) and one column for card suit (C, D, H, S).
The problem I am running into is how to remove the cards in the players hand array from the deck array so that the deck actually has one less row and not just an empty row.
Does anyone have any idea how to do this, or have a better idea on how to accomplish this?
Thanks in advance,
-Torrwin
I am making a card game, and I was looking for thoughts/ideas on how to proceed.
Currently I have two arrays: one contains the cards in the players hand, and one contains the cards in the deck. Each array is two dimensional with one column for card number(2, 3, 4, ... Q, K, A) and one column for card suit (C, D, H, S).
The problem I am running into is how to remove the cards in the players hand array from the deck array so that the deck actually has one less row and not just an empty row.
Does anyone have any idea how to do this, or have a better idea on how to accomplish this?
Thanks in advance,
-Torrwin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
1) Have an Hashtable for the deck: 2C, ... AC, 2D, ... AD, 2H, ... AH,
2) Have a hashtable for each hand
3) When you deal, calculate a random number 1..52, determine the key, remove from the deck table by key, and add to the hand by the key
Bob