View Single Post
Old 05-17-2011, 02:45 PM   PM User | #2
bullant
Banned

 
Join Date: Feb 2011
Posts: 2,699
Thanks: 13
Thanked 395 Times in 395 Posts
bullant is on a distinguished road
If you want to adopt an object oriented approach you could create a javascript deck of cards object with a property being an array of the cards and then object methods to deal and shuffle the cards. The method to deal the cards would generate a random number from 0 to the number of cards left in the deck -1 and then remove the card at that random number index in the cards array as it is "dealt" to a player.

Using an object oriented approach then allows you to use that deck of cards object in other javascript applications very easily.
bullant is offline   Reply With Quote