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

Diff of /hegemonie/GameEngine/HgTeam.m

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

revision 1.11 by dam, Mon Aug 18 01:42:25 2003 UTC revision 1.12 by nicov, Mon Aug 18 10:39:02 2003 UTC
# Line 88  Line 88 
88   * Add a player to the team.   * Add a player to the team.
89   * The player must exist and mustn't be already in the team   * The player must exist and mustn't be already in the team
90   * already contains the player.   * already contains the player.
91   * Post an notification named "updateTeam" containing the current object.   * Post an notification named "updateTeam" containing the current game and
92     * the current object.
93   */   */
94  - (void) addPlayer: (HgPlayer *)player  - (void) addPlayer: (HgPlayer *)player
95  {  {
# Line 98  Line 99 
99        
100    [_players addObject: player];    [_players addObject: player];
101    
102    [[NSNotificationCenter defaultCenter]    [[NSNotificationCenter defaultCenter] postNotificationName: @"updateTeam"
103      postNotificationName:@"updateTeam" object:self];                                                        object: _game
104                    userInfo: [NSDictionary dictionaryWithObject: self
105                                                          forKey: @"HgTeam"]];
106  }  }
107    
108  /**  /**
109   * Remove a player to the team.   * Remove a player to the team.
110   * The player must be in the team.   * The player must be in the team.
111   * Post an notification named "updateTeam" containing the current object.   * Post an notification named "updateTeam" containing the current game and
112     * the current object.
113   */   */
114  - (void) removePlayer: (HgPlayer *)player  - (void) removePlayer: (HgPlayer *)player
115  {  {
# Line 114  Line 118 
118    
119    [_players removeObject: player];    [_players removeObject: player];
120    
121    [[NSNotificationCenter defaultCenter]    [[NSNotificationCenter defaultCenter] postNotificationName: @"updateTeam"
122      postNotificationName:@"updateTeam" object:self];                                                        object: _game
123                    userInfo: [NSDictionary dictionaryWithObject: self
124                                                          forKey: @"HgTeam"]];
125  }  }
126    
127  /**  /**
# Line 127  Line 133 
133  }  }
134    
135    
136    @end
137    
138    @implementation HgTeam (NSCoding)
139    
140  /**  /**
141   * encode the HgTeam object to send it across the network   * NSCoding method to encode and decode objects
142   */   */
143  - (void)encodeWithCoder: (NSCoder *)encoder  - (void)encodeWithCoder: (NSCoder *)encoder
144  {  {
# Line 138  Line 148 
148    [encoder encodeObject: _players];    [encoder encodeObject: _players];
149  }  }
150    
 /**  
  * decode the HgTeam object to read it  
  */  
151  - (id)initWithCoder: (NSCoder *)decoder  - (id)initWithCoder: (NSCoder *)decoder
152  {  {
153    [decoder decodeValueOfObjCType: "I" at: &_identifier];    [decoder decodeValueOfObjCType: "I" at: &_identifier];
154    NSNumber *numIdent = [NSNumber numberWithInt: _identifier];    NSNumber *numIdent = [NSNumber numberWithInt: _identifier];
155    
156    HgTeam *teamObject = [[_game teams] objectForKey: numIdent];    HgGame *currentGame = [HgGame currentGame];
157      HgTeam *teamObject = [[currentGame teams] objectForKey: numIdent];
158    
159    if (teamObject != nil)    if (teamObject != nil)
160      {      {

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

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