jens@10: // jens@10: // Turn.h jens@10: // YourMove jens@10: // jens@10: // Created by Jens Alfke on 7/3/08. jens@10: // Copyright 2008 Jens Alfke. All rights reserved. jens@10: // jens@10: jens@10: #import jens@10: @class Game, Player; jens@10: jens@10: jens@10: typedef enum { jens@10: kTurnEmpty, // No action yet jens@10: kTurnPartial, // Action taken, but more needs to be done jens@10: kTurnComplete, // Action complete, but player needs to confirm jens@10: kTurnFinished // Turn is confirmed and finished jens@10: } TurnStatus; jens@10: jens@10: jens@10: extern NSString* const kTurnCompleteNotification; jens@10: jens@10: jens@10: /** A record of a particular turn in a Game, including the player's move and the resulting state. */ jens@10: @interface Turn : NSObject jens@10: { jens@10: Game *_game; jens@10: Player *_player; jens@10: TurnStatus _status; jens@10: NSString *_move; jens@10: NSString *_boardState; jens@10: NSDate *_date; jens@10: NSString *_comment; jens@10: BOOL _replaying; jens@10: } jens@10: jens@10: - (id) initWithPlayer: (Player*)player; jens@10: - (id) initStartOfGame: (Game*)game; jens@10: jens@10: @property (readonly) Game *game; jens@10: @property (readonly) Player *player, *nextPlayer; jens@15: @property (readonly) Turn *previousTurn, *nextTurn; jens@10: @property (readonly) unsigned turnNumber; jens@10: @property (readonly) BOOL isLatestTurn; jens@10: jens@10: @property TurnStatus status; jens@10: jens@15: @property (readonly,copy) NSString *move; // The player's move (nil for turn 0) jens@15: @property (readonly,copy) NSString *boardState; // State of the game AFTER the move jens@10: @property (readonly,retain)NSDate *date; jens@10: @property (copy) NSString *comment; jens@10: jens@10: /** Appends to the move string. Only allowed if the status is Empty or Partial. */ jens@10: - (void) addToMove: (NSString*)move; jens@10: jens@10: /** Copies the current state of the Game's board to my boardState */ jens@10: - (void) captureBoardState; jens@10: jens@10: @property BOOL replaying; jens@10: jens@10: @end