Source/Player.h
author snej@snej.local
Sun Jan 11 00:02:27 2009 -0800 (2009-01-11)
changeset 26 e7a464fb6d39
parent 13 db7bb080c3d5
permissions -rw-r--r--
Added ball graphics to Xcode project, which fixes the Go game. Fixed Tic-Tac-Toe. Fixed an exception in the demo app when changing games.
     1 //
     2 //  Player.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;
    11 
    12 
    13 /** A mostly-passive object used to represent a player. */
    14 @interface Player : NSObject <NSCoding>
    15 {
    16     Game *_game;
    17     NSString *_name;
    18     BOOL _local;
    19     NSMutableDictionary *_extraValues;
    20 }
    21 
    22 - (id) initWithGame: (Game*)game;
    23 - (id) initWithName: (NSString*)name;
    24 
    25 - (id) initWithCoder: (NSCoder*)decoder;
    26 - (void) encodeWithCoder: (NSCoder*)coder;
    27 
    28 @property (copy) NSString *name;                            // Display name
    29 @property (readonly) CGImageRef icon;                       // An icon to display (calls game.iconForPlayer:)
    30 
    31 @property (readonly) Game *game;
    32 @property (readonly) int index;                             // Player's index in the Game's -players array
    33 @property (readwrite,getter=isLocal) BOOL local;            // Is player a human at this computer? (Defaults to YES)
    34 @property (readonly, getter=isCurrent) BOOL current;        // Is it this player's turn?
    35 @property (readonly, getter=isFriendly) BOOL friendly;      // Is this player the current player or an ally?
    36 @property (readonly, getter=isUnfriendly) BOOL unfriendly;  // Is this player an opponent of the current player?
    37 @property (readonly) Player *nextPlayer, *previousPlayer;   // The next/previous player in sequence
    38 
    39 /** Copy all of the player's attributes (name, local...) into myself. */
    40 - (void) copyFrom: (Player*)player;
    41 @end
    42 
    43 
    44 
    45 @interface CALayer (Game)
    46 
    47 /** Called on any CALayer in the game's layer tree, will return the current Game object. */
    48 @property (readonly) Game *game;
    49 
    50 @end