Source/Player.h
author Jens Alfke <jens@mooseyard.com>
Tue Jul 08 13:12:01 2008 -0700 (2008-07-08)
changeset 13 db7bb080c3d5
parent 10 6c78cc6bd7a6
child 14 4585c74d809c
permissions -rw-r--r--
Fixed some memory leaks, and took the address-related properties out of Player.
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@10
    38
@end
jens@10
    39
jens@10
    40
jens@10
    41
jens@10
    42
@interface CALayer (Game)
jens@10
    43
jens@10
    44
/** Called on any CALayer in the game's layer tree, will return the current Game object. */
jens@10
    45
@property (readonly) Game *game;
jens@10
    46
jens@10
    47
@end