Source/Game.h
changeset 9 a59acc683080
parent 7 428a194e3e59
child 10 6c78cc6bd7a6
     1.1 --- a/Source/Game.h	Sun Mar 16 15:06:47 2008 -0700
     1.2 +++ b/Source/Game.h	Thu May 29 15:04:06 2008 -0700
     1.3 @@ -27,6 +27,7 @@
     1.4  /** Abstract superclass. Keeps track of the rules and turns of a game. */
     1.5  @interface Game : NSObject
     1.6  {
     1.7 +    NSString *_uniqueID;
     1.8      GGBLayer *_board;
     1.9      NSArray *_players;
    1.10      Player *_currentPlayer, *_winner;
    1.11 @@ -35,6 +36,10 @@
    1.12      unsigned _currentTurn;
    1.13  }
    1.14  
    1.15 +/** Returns the name used to identify this game in URLs.
    1.16 +     (By default it just returns the class name with the "Game" suffix removed.) */
    1.17 ++ (NSString*) identifier;
    1.18 +
    1.19  /** Returns the human-readable name of this game.
    1.20      (By default it just returns the class name with the "Game" suffix removed.) */
    1.21  + (NSString*) displayName;
    1.22 @@ -49,9 +54,17 @@
    1.23  @property unsigned currentTurn;
    1.24  @property (readonly) BOOL isLatestTurn;
    1.25  
    1.26 +
    1.27 +/** A globally-unique string assigned to this game instance, to help networked players identify it. */
    1.28 +@property (readonly) NSString* uniqueID;
    1.29 +
    1.30  - (BOOL) animateMoveFrom: (BitHolder*)src to: (BitHolder*)dst;
    1.31  
    1.32  
    1.33 +- (id) initWithUniqueID: (NSString*)uniqueID;
    1.34 +- (id) init;
    1.35 +
    1.36 +
    1.37  // Methods for subclasses to implement:
    1.38  
    1.39  /** Designated initializer. After calling the superclass implementation,
    1.40 @@ -87,8 +100,11 @@
    1.41      Default implementation returns nil. */
    1.42  - (Player*) checkForWinner;
    1.43  
    1.44 +/** A string describing the current state of the game (the positions of all pieces,
    1.45 +    orderings of cards, player scores, ... */
    1.46 +@property (copy) NSString* stateString;
    1.47  
    1.48 -@property (copy) NSString* stateString;
    1.49 +/** Add a move to the game based on the contents of the string. */
    1.50  - (BOOL) applyMoveString: (NSString*)move;
    1.51  
    1.52  
    1.53 @@ -111,7 +127,7 @@
    1.54  
    1.55  
    1.56  /** A mostly-passive object used to represent a player. */
    1.57 -@interface Player : NSObject
    1.58 +@interface Player : NSObject <NSCoding>
    1.59  {
    1.60      Game *_game;
    1.61      NSString *_name;