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