Source/Turn.h
author Jens Alfke <jens@mooseyard.com>
Sun Feb 06 16:31:03 2011 -0800 (2011-02-06)
changeset 29 0b1c315ffc64
parent 15 73f8c889f053
permissions -rw-r--r--
Minor compiler-compatibility fixes.
     1 //
     2 //  Turn.h
     3 //  YourMove
     4 //
     5 //  Created by Jens Alfke on 7/3/08.
     6 //  Copyright 2008 Jens Alfke. All rights reserved.
     7 //
     8 
     9 #import <Foundation/Foundation.h>
    10 @class Game, Player;
    11 
    12 
    13 typedef enum {
    14     kTurnEmpty,             // No action yet
    15     kTurnPartial,           // Action taken, but more needs to be done
    16     kTurnComplete,          // Action complete, but player needs to confirm
    17     kTurnFinished           // Turn is confirmed and finished
    18 } TurnStatus;
    19 
    20 
    21 extern NSString* const kTurnCompleteNotification;
    22 
    23 
    24 /** A record of a particular turn in a Game, including the player's move and the resulting state. */
    25 @interface Turn : NSObject <NSCoding>
    26 {
    27     Game *_game;
    28     Player *_player;
    29     TurnStatus _status;
    30     NSString *_move;
    31     NSString *_boardState;
    32     NSDate *_date;
    33     NSString *_comment;
    34     BOOL _replaying;
    35 }
    36 
    37 - (id) initWithPlayer: (Player*)player;
    38 - (id) initStartOfGame: (Game*)game;
    39 
    40 @property (readonly)      Game      *game;
    41 @property (readonly)      Player    *player, *nextPlayer;
    42 @property (readonly)      Turn      *previousTurn, *nextTurn;
    43 @property (readonly)      unsigned   turnNumber;
    44 @property (readonly)      BOOL       isLatestTurn;
    45 
    46 @property                 TurnStatus status;
    47 
    48 @property (readonly,copy) NSString  *move;              // The player's move (nil for turn  0)
    49 @property (readonly,copy) NSString  *boardState;        // State of the game AFTER the move
    50 @property (readonly,retain)NSDate   *date;
    51 @property (copy)          NSString  *comment;
    52 
    53 /** Appends to the move string. Only allowed if the status is Empty or Partial. */
    54 - (void) addToMove: (NSString*)move;
    55 
    56 /** Copies the current state of the Game's board to my boardState */
    57 - (void) captureBoardState;
    58 
    59 @property BOOL replaying;
    60 
    61 
    62 
    63 /** Changes a Turn's status from finished back to complete. For use only by -[Game unfinishLastTurn] */
    64 - (void) _unfinish;
    65 
    66 @end