Appendix A. Video Poker
Shuffling a deck -
0: i => 0
1: a => deck.numberOfCards();
2: for i => a
2.0: swap deck.card(i) with deck.card(Math.Random(a-i)+i);
3: next i;
Probably need to repeat this process several times, cause nobody shuffles just once.
Card -
Card {
value :>
suit :>
}
Name of card image is: card.value()."_".card.suit().".gif";
Checking for point values - (Reorder the cards in value order)
To Calculate a flush ()
if (card1.suit == card2.suit &&
card2.suit == card3.suit &&
card3.suit == card4.suit &&
card4.suit == card5.suit);
To Calculate a straight ()
// This is the only time that it matters if an ace is high or low. Every
// other time it is high.
if (card1.value + 1 == card2.value &&
card2.value + 1 == card3.value &&
card3.value + 1 == card4.value &&
card4.value + 1 == card5.value)
if (card1.value + 1 == card2.value &&
card2.value + 1 == card3.value &&
card3.value + 1 == card4.value &&
card1.value == 2 && card5.value == 13);
// Straight with ace - 5
to Calculate a striaghtFlush()
if straight() && flush()
to Calculate fourOfAKind ()
if ((card1.value == card2.value &&
card2.value == card3.value &&
card3.value == card4.value) ||
(card2.value == card3.value &&
card3.value == card4.value &&
card4.value == card5.value));
to Calculate threeOfAKind()
// Returns the position of the three of a kind
if (card1.value = card2.value &&
card2.value = card3.value) return 0;
if (card2.value = card3.value &&
card3.value = card4.value) return 1;
if (card3.value = card4.value &&
card4.value = card5.value) return 2;
to Calculate pair(StartSearchPos)
// Returns the position of the first pair
if (card1.value = card2.value) return 0;
if (card2.value = card3.value) return 1;
if (card3.value = card4.value) return 2;
if (card4.value = card5.value) return 3;
to Calculate fullHouse()
if (threeOfAKind() == 0 && pair() == 3);
if (threeOfAKind() == 2 && pair() == 0);
-----------------------
Just another pretty face....
Verastinian Republic - Almighty Dictator
"If in physics there's something you don't understand, you can always hide behind the uncharted depths of nature. You can always blame God. You didn't make it so complex yourself. But if your program doesn't work, there is no one to hide behind. You cannot hide behind an obstinate nature. If it doesn't work, you've messed up." -- Dijkstra
[This message has been edited by
Kiption
(edited July 10, 2005
4:57:55 PM)]