Im designing a game engine for use with card games. (Ill post the source-code when I get back home) I have an NSObject Subclass called Card, which has the variables
and the method
Anyway, I have a subclass of NSMutableArray called Deck with the methods (void)prepare; (Adds 54 cards to the deck) and (Card *)drawRandomCard; (Avoids the need for a rather complicated shuffle method, and deletes the card from the array)
I didn't quite think through the how I was going to implement the prepare method.
I thought of using some loops, [variable copy], a temp card object; and some preprocessor macros... But doesn't copy only copy the pointer and arrays only hold pointers? (Making the temporary object style useless)
Am I approaching this the wrong way?
Code:
//(S)pades, (C)lubs, (H)earts, (D)iamonds, (J)oker
char type;
//(1)Ace ... (11)Joker, (12)Queen, (13)King (0)Joker
int number;
//2 of Clubs, King of Spades etc
NSString *cardName;
and the method
Code:
-(void)setVariablesWithType:(char)t number:(int)n name:(NSString *)name {
type = t;
number = n;
switch (name) {
switch code to set full name of cards
}
Anyway, I have a subclass of NSMutableArray called Deck with the methods (void)prepare; (Adds 54 cards to the deck) and (Card *)drawRandomCard; (Avoids the need for a rather complicated shuffle method, and deletes the card from the array)
I didn't quite think through the how I was going to implement the prepare method.
I thought of using some loops, [variable copy], a temp card object; and some preprocessor macros... But doesn't copy only copy the pointer and arrays only hold pointers? (Making the temporary object style useless)
Am I approaching this the wrong way?