Minor compiler-compatibility fixes.
5 // Created by Jens Alfke on 7/3/08.
6 // Copyright 2008 Jens Alfke. All rights reserved.
15 @implementation Player
18 - (id) initWithGame: (Game*)game
28 - (id) initWithName: (NSString*)name
38 - (id) initWithCoder: (NSCoder*)decoder
42 _game = [decoder decodeObjectForKey: @"game"];
43 _name = [[decoder decodeObjectForKey: @"name"] copy];
44 _local= [decoder decodeBoolForKey: @"local"];
45 _extraValues = [[decoder decodeObjectForKey: @"extraValues"] mutableCopy];
50 - (void) encodeWithCoder: (NSCoder*)coder
52 [coder encodeObject: _game forKey: @"game"];
53 [coder encodeObject: _name forKey: @"name"];
54 [coder encodeBool: _local forKey: @"local"];
55 [coder encodeObject: _extraValues forKey: @"extraValues"];
61 [_extraValues release];
66 - (id)valueForUndefinedKey:(NSString *)key
68 return [_extraValues objectForKey: key];
71 - (void)setValue:(id)value forUndefinedKey:(NSString *)key
74 _extraValues = [[NSMutableDictionary alloc] init];
76 [_extraValues setObject: value forKey: key];
78 [_extraValues removeObjectForKey: key];
82 - (void) copyFrom: (Player*)player
84 self.local = player.local;
85 self.name = player.name;
86 setObj(&_extraValues, [[player->_extraValues mutableCopy] autorelease]);
90 @synthesize game=_game, name=_name, local=_local;
92 - (BOOL) isCurrent {return self == _game.currentPlayer;}
93 - (BOOL) isFriendly {return self == _game.currentPlayer;} // could be overridden for games with partners
94 - (BOOL) isUnfriendly {return ! self.friendly;}
96 + (NSArray*) keyPathsForValuesAffectingCurrent {return [NSArray arrayWithObject: @"game.currentPlayer"];}
101 return [_game.players indexOfObjectIdenticalTo: self];
104 - (Player*) nextPlayer
106 return [_game.players objectAtIndex: (self.index+1) % _game.players.count];
109 - (Player*) previousPlayer
111 return [_game.players objectAtIndex: (self.index-1) % _game.players.count];
116 return [_game iconForPlayer: self.index];
119 - (NSString*) description
121 return [NSString stringWithFormat: @"%@[%@]", self.class,self.name];