1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/Source/Turn.h Tue Jul 08 13:12:01 2008 -0700
1.3 @@ -0,0 +1,61 @@
1.4 +//
1.5 +// Turn.h
1.6 +// YourMove
1.7 +//
1.8 +// Created by Jens Alfke on 7/3/08.
1.9 +// Copyright 2008 Jens Alfke. All rights reserved.
1.10 +//
1.11 +
1.12 +#import <Foundation/Foundation.h>
1.13 +@class Game, Player;
1.14 +
1.15 +
1.16 +typedef enum {
1.17 + kTurnEmpty, // No action yet
1.18 + kTurnPartial, // Action taken, but more needs to be done
1.19 + kTurnComplete, // Action complete, but player needs to confirm
1.20 + kTurnFinished // Turn is confirmed and finished
1.21 +} TurnStatus;
1.22 +
1.23 +
1.24 +extern NSString* const kTurnCompleteNotification;
1.25 +
1.26 +
1.27 +/** A record of a particular turn in a Game, including the player's move and the resulting state. */
1.28 +@interface Turn : NSObject <NSCoding>
1.29 +{
1.30 + Game *_game;
1.31 + Player *_player;
1.32 + TurnStatus _status;
1.33 + NSString *_move;
1.34 + NSString *_boardState;
1.35 + NSDate *_date;
1.36 + NSString *_comment;
1.37 + BOOL _replaying;
1.38 +}
1.39 +
1.40 +- (id) initWithPlayer: (Player*)player;
1.41 +- (id) initStartOfGame: (Game*)game;
1.42 +
1.43 +@property (readonly) Game *game;
1.44 +@property (readonly) Player *player, *nextPlayer;
1.45 +@property (readonly) Turn *previousTurn;
1.46 +@property (readonly) unsigned turnNumber;
1.47 +@property (readonly) BOOL isLatestTurn;
1.48 +
1.49 +@property TurnStatus status;
1.50 +
1.51 +@property (readonly,copy) NSString *move;
1.52 +@property (readonly,copy) NSString *boardState;
1.53 +@property (readonly,retain)NSDate *date;
1.54 +@property (copy) NSString *comment;
1.55 +
1.56 +/** Appends to the move string. Only allowed if the status is Empty or Partial. */
1.57 +- (void) addToMove: (NSString*)move;
1.58 +
1.59 +/** Copies the current state of the Game's board to my boardState */
1.60 +- (void) captureBoardState;
1.61 +
1.62 +@property BOOL replaying;
1.63 +
1.64 +@end