Thursday, October 16, 2008

Correct Assumptions : More OOP With cards in games

I wrote the last post with out checking out what Micro Soft had to offer. I found that there is a card game starter kit. I downloaded it and began playing with it. I was shocked to see that what I was thinking would actually work for the handling of cards in a game.

The starter kit builds a blackjack game that you should be able to edit and expand. So i began poking around to see what was there that can be used and modded for my needs. I went to the Card Game Framework to see what was there. I found 3 classes (Card,Deck and Hand). These fit my assumptions with minor changes.

Card is built the way I assumed it would be. It encapsulates the values of the suit,faceValue, and isfaceup. This object is just for the play of this card in other collections. The values are set to private readonly fields or public get properties. That's actually good programing as it stops the programmer from attempting to change cards on the fly.

Deck unlike my deck has only one collection. It also has methods for shuffleing that collection.
Also it has a method for drawing a card. I think since black jack doesn't need a discard deck or to shuffle that deck back in those methods are missing. I can use this as an excellent start for my card based game. I can shuffle anything that looks like a deck. These can even be room tiles from games like house on hunted hill or other games with tiles.

Hand is a collection of cards and cantains a number of cards property. It's inherited by blackjack hand and hit has the rules for black jack in that. all this is wrapped by theanother class.

I know I'm on the write path to writing my game. I'm really excited by this and I can add the silverlight bits.

No comments: