Source/Player.h
author Jens Alfke <jens@mooseyard.com>
Fri Jul 18 13:26:59 2008 -0700 (2008-07-18)
changeset 20 7c9ecb09a612
parent 13 db7bb080c3d5
permissions -rw-r--r--
Checkers and Hexchequer now detect victory when the other player can't move.
jens@10
     1
//
jens@10
     2
//  Player.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;
jens@10
    11
jens@10
    12
jens@10
    13
/** A mostly-passive object used to represent a player. */
jens@10
    14
@interface Player : NSObject <NSCoding>
jens@10
    15
{
jens@10
    16
    Game *_game;
jens@13
    17
    NSString *_name;
jens@10
    18
    BOOL _local;
jens@13
    19
    NSMutableDictionary *_extraValues;
jens@10
    20
}
jens@10
    21
jens@10
    22
- (id) initWithGame: (Game*)game;
jens@10
    23
- (id) initWithName: (NSString*)name;
jens@10
    24
jens@10
    25
- (id) initWithCoder: (NSCoder*)decoder;
jens@10
    26
- (void) encodeWithCoder: (NSCoder*)coder;
jens@10
    27
jens@13
    28
@property (copy) NSString *name;                            // Display name
jens@13
    29
@property (readonly) CGImageRef icon;                       // An icon to display (calls game.iconForPlayer:)
jens@13
    30
jens@10
    31
@property (readonly) Game *game;
jens@10
    32
@property (readonly) int index;                             // Player's index in the Game's -players array
jens@13
    33
@property (readwrite,getter=isLocal) BOOL local;            // Is player a human at this computer? (Defaults to YES)
jens@10
    34
@property (readonly, getter=isCurrent) BOOL current;        // Is it this player's turn?
jens@10
    35
@property (readonly, getter=isFriendly) BOOL friendly;      // Is this player the current player or an ally?
jens@10
    36
@property (readonly, getter=isUnfriendly) BOOL unfriendly;  // Is this player an opponent of the current player?
jens@10
    37
@property (readonly) Player *nextPlayer, *previousPlayer;   // The next/previous player in sequence
jens@14
    38
jens@14
    39
/** Copy all of the player's attributes (name, local...) into myself. */
jens@14
    40
- (void) copyFrom: (Player*)player;
jens@10
    41
@end
jens@10
    42
jens@10
    43
jens@10
    44
jens@10
    45
@interface CALayer (Game)
jens@10
    46
jens@10
    47
/** Called on any CALayer in the game's layer tree, will return the current Game object. */
jens@10
    48
@property (readonly) Game *game;
jens@10
    49
jens@10
    50
@end