ftp.nice.ch/pub/next/games/card/NEXTVegas3.0.src.tar.gz#/NEXTVegas/Documentation/CardSet/Card.rtf

This is Card.rtf in view mode; [Download] [Up]

CardSet Release 2.1






Card 






Inherits From:	Object

Declared In:	Card.h





Class Description

Instances of this class provide low-level functionality for card games.  Cards can have a suit, a value, and an orientation.  These values can be initialized, modified and determined by clients of the class.  Cards also know how to render themselves on screen.

The card images can either be drawn by compositing the partial card images contained in the TIFF files in the CardSet, or the 52 cards in a deck can be pre-drawn and stored in shared NXImage caches (which are private class variables) for reuse. The shared NXImage caches increase performance, but with the penalty of increased memory usage.





Instance Variables

CardSuit suit;
CardValue value;
BOOL faceUp;



suit 	The card's suit.

value 	The card's value.

faceUp 	TRUE if the card is face-up.





Method Types

Initializing the class object	+ initialize
+ drawCardImages
+ freeCardImages
+ setCardBackImage:
+ setCardBack:

Creating and freeing	± init
± initSuit:value:
- initSuit:value:faceUp:
- copyFromZone:


Setting Card object state	- setSuit:
- setValue:
- setUserValue:
- flip
- setFaceUp:

Determining Card object state	- suit
- value
- isFaceUp
- cardColor

Drawing the card	- preDrawCard:
	± drawCardAt:
- drawContentsAt:
- drawOutlineAt:

Archiving	- read: 
- write:





Class Methods

initialize
+ initialize

Initializes the class object.  The partial card images from the CardSet TIFFs are loaded here.  Returns self.

See also:  + initialize (Object)




drawCardImages
+ drawCardImages

Creates shared NXImage caches of all 52 cards in the deck. Uses the instance method preDrawCards: to do the actual drawing. Returns self.

See also:  ± preDrawCards:




freeCardImages
+ freeCardImages

Frees the shared NXImage caches of all 52 cards in the deck.  Returns self.




setCardBackImage:
+ setCardBackImage:theNXImage

Sets a custom image used to draw the back of the card.  Returns self.




setCardBack:
+ setCardBack:(CardBack)aBack

Sets the id number of the image used to draw the back of the card.  Returns self.

Constant	Image
CS_DEFAULT	Original image from version 1.0.
CS_TRAD	Traditional pattern.
CS_SHIP	Ship at sea.
CS_CUSTOM	Custom image.





Instance Methods

cardColor
- (CardColor)cardColor

Returns the receiver's color.  The returned value is equal to one of these constants:

Constant	Color
CS_BLACK	Card's suit is either spades or clubs.
CS_RED	Card's suit is either hearts or diamonds.

See also:  - setSuit:




copyFromZone:
- copyFromZone:(NXZone *)zone

Returns a new Card object, allocated from the specified zone, which is an exact duplicate of the sender.

See also:  ± drawOutlineAt:, ± drawContentsAt:




drawCardAt:
- drawCardAt:(NXPoint *)thePoint

Draws the card, both outline and contents, at thePoint, by calling drawOutlineAt: and drawContentsAt:.  If the 52 cards of the deck have been pre-drawn, the shared NXImage cache is used. Otherwise, the card is drawn by compositing the partial images. Returns self.

See also:  ± drawOutlineAt:, ± drawContentsAt:, + drawCardImages




drawContentsAt:
- drawContentsAt:(NXPoint *)thePoint

Draws the contents of the card (but not the border) at thePoint.  Returns self.

See also:  ± drawCardAt:, ± drawOutlineAt:




drawOutlineAt:
- drawOutlineAt:(NXPoint *)thePoint

Draws the card's border at thePoint.

See also: ± drawCardAt:, ± drawContentsAt:




flip
- flip

Turns the card over.  Returns self.

See also:  ± isFaceUp, ± setFaceUp:




init
- init

Initialize a new Card object.  This method invokes the initSuit:value:faceUp: method.  The suit is set to CS_CLUBS, the value is set to CS_ACE, and the card is face down.  Returns self.

See also:  ± initSuit:value:, ± initSuit:value:faceUp:




initSuit:value:
- initSuit:(CardSuit)aSuit value:(CardValue)aValue

Initializes a card with suit aSuit and value aValue, face down, by calling initSuit:value:faceUp:.  Returns self.

See also:  ± init, ± initSuit:value:faceUp:




initSuit:value:faceUp:
- initSuit:(CardSuit)aSuit value:(CardValue)aValue faceUp:(BOOL)anOrientation

Initializes a card with suit aSuit, value aValue, and orientation anOrientation.  This is the designated initializer for Card object instances.  Returns self.

See also:  ± init, ± initSuit:value:




isFaceUp
- (BOOL)isFaceUp

Returns YES if receiver is face up, otherwise returns NO.

See also:  ± flip, ± setFaceUp:




preDrawCard:
- preDrawCard:theSharedNXImage

Pre-draws theSharedNXImage, both outline and contents, by calling drawOutlineAt: and drawContentsAt: for point {0.0, 0.0}. Returns self.

See also:  ± drawOutlineAt:, ± drawContentsAt:, + drawCardImages




read:
- read:(NXTypedStream *)stream

Reads the Card object in from the typed stream stream.  A read: message is sent in response to archiving; you never send this message directly.  Returns self.




setFaceUp:
- setFaceUp:(BOOL)anOrientation

Sets the card's orientation to anOrientation.  Returns self.

See also:  ± isFaceUp, ± flip




setSuit:
- setSuit:(CardSuit)aSuit

Sets the card's suit to aSuit.  Returns self.  Valid suit values are:

Constant	Suit
CS_LOWSUIT	Clubs
CS_CLUBS	Clubs
CS_SPADES	Spades
CS_DIAMONDS	Diamonds
CS_HEARTS	Hearts
CS_HIGHSUIT	Hearts

See also:  ± suit




setValue
- setValue:(CardValue)aValue

Sets the card's value to aValue.  Returns self.  Valid card values are:

Constant	Card Value
CS_LOWVALUE	Ace
CS_ACE	Ace
CS_TWO	Two
CS_THREE	Three
CS_FOUR	Four
CS_FIVE	Five
CS_SIX	Six
CS_SEVEN	Seven
CS_EIGHT	Eight
CS_NINE	Nine
CS_TEN	Ten
CS_JACK	Jack
CS_QUEEN	Queen
CS_KING	King
CS_HIGHVALUE	King

See also:  ± value




setUserValue
- setUserValue:(CardValue)aValue

Sets the card's user value to aValue.  Returns self.  Use this method to set the value of the card independent of the card type.  For example, in Blackjack, all face cards can be set to have a user value of 10.  (Trombino 7/3/95).


See also:  ± userValue




suit
- (CardSuit)suit

Returns the receiver's suit.  The returned value will be one of:

Constant	Suit
CS_LOWSUIT	Clubs
CS_CLUBS	Clubs
CS_SPADES	Spades
CS_DIAMONDS	Diamonds
CS_HEARTS	Hearts
CS_HIGHSUIT	Hearts

See also:  ± setSuit:




value
- (CardValue)value

Returns the receiver's value.  The returned value will be one of:

Constant	Card Value
CS_LOWVALUE	Ace
CS_ACE	Ace
CS_TWO	Two
CS_THREE	Three
CS_FOUR	Four
CS_FIVE	Five
CS_SIX	Six
CS_SEVEN	Seven
CS_EIGHT	Eight
CS_NINE	Nine
CS_TEN	Ten
CS_JACK	Jack
CS_QUEEN	Queen
CS_KING	King
CS_HIGHVALUE	King

See also:  ± setValue:




userValue
- (CardValue)userValue

Returns the receiver's user value.  The returned value will be the value set through the setUserValue: method. (Trombino 7/3/95).


See also:  ± setUserValue:




write:
- write:(NXTypedStream *)stream

Writes the Card object to the typed stream stream.  A write: message is sent is response to archiving; you never send this message directly.  Returns self.


These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.