/[hegemonie]/hegemonie/GameEngine/HgPlayer.m
ViewVC logotype

Diff of /hegemonie/GameEngine/HgPlayer.m

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16 by dam, Mon Aug 18 01:41:58 2003 UTC revision 1.17 by nicov, Mon Aug 18 10:33:34 2003 UTC
# Line 140  Line 140 
140  /**  /**
141   * Change the player's ship.   * Change the player's ship.
142   * The ship must exist.   * The ship must exist.
143   * Post an notification named "updatePlayer" containing the current object.   * Post an notification named "updatePlayer" containing the current game and
144     * the current object.
145   */   */
146  -(void) setShip: (HgShip *)ship  -(void) setShip: (HgShip *)ship
147  {  {
# Line 148  Line 149 
149        
150    ASSIGN(_ship, ship);    ASSIGN(_ship, ship);
151    
152    [[NSNotificationCenter defaultCenter]    [[NSNotificationCenter defaultCenter] postNotificationName: @"updatePlayer"
153      postNotificationName:@"updatePlayer" object:self];                                                        object: _game
154                    userInfo: [NSDictionary dictionaryWithObject: self
155                                                          forKey: @"HgPlayer"]];
156  }  }
157    
158  /**  /**
159   * Change the player's team.   * Change the player's team.
160   * The team must exist.   * The team must exist.
161   * Post an notification named "updatePlayer" containing the current object.   * Post an notification named "updatePlayer" containing the current game and
162     * the current object.
163   */   */
164  -(void) setTeam: (HgTeam *)team  -(void) setTeam: (HgTeam *)team
165  {  {
# Line 163  Line 167 
167    
168    ASSIGN(_team, team);    ASSIGN(_team, team);
169    
170    [[NSNotificationCenter defaultCenter]    [[NSNotificationCenter defaultCenter] postNotificationName: @"updatePlayer"
171      postNotificationName:@"updatePlayer" object:self];                                                        object: _game
172                    userInfo: [NSDictionary dictionaryWithObject: self
173                                                          forKey: @"HgPlayer"]];
174  }  }
175    
176  /**  /**
177   * Add any point to the player's score.   * Add any point to the player's score.
178   * Post an notification named "updatePlayer" containing the current object.   * Post an notification named "updatePlayer" containing the current game and
179     * the current object.
180   */   */
181  -(void) addPoint: (int)point  -(void) addPoint: (int)point
182  {  {
183    _score += point;    _score += point;
184    
185    [[NSNotificationCenter defaultCenter]    [[NSNotificationCenter defaultCenter] postNotificationName: @"updatePlayer"
186      postNotificationName:@"updatePlayer" object:self];                                                        object: _game
187                    userInfo: [NSDictionary dictionaryWithObject: self
188                                                          forKey: @"HgPlayer"]];
189  }  }
190    
191  /**  /**
# Line 194  Line 203 
203  @implementation HgPlayer (NSCoding)  @implementation HgPlayer (NSCoding)
204    
205  /**  /**
206   * NSCoding method   * NSCoding method to encode and decode objects
  * to encode and decode objects  
207   */   */
208  - (void)encodeWithCoder: (NSCoder *)encoder  - (void)encodeWithCoder: (NSCoder *)encoder
209  {  {
# Line 212  Line 220 
220    [decoder decodeValueOfObjCType: "I" at:  &_identifier];    [decoder decodeValueOfObjCType: "I" at:  &_identifier];
221    NSNumber *numIdent = [NSNumber numberWithInt: _identifier];    NSNumber *numIdent = [NSNumber numberWithInt: _identifier];
222    
223    HgPlayer *playerObject = [[_game players] objectForKey: numIdent];      HgGame *currentGame = [HgGame currentGame];
224      HgPlayer *playerObject = [[currentGame players] objectForKey: numIdent];  
225    
226    if (playerObject != nil)    if (playerObject != nil)
227      {      {
228        DESTROY(self);        DESTROY(self);

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26