25 |
#include <Foundation/NSException.h> |
#include <Foundation/NSException.h> |
26 |
#include <Foundation/NSCoder.h> |
#include <Foundation/NSCoder.h> |
27 |
#include <Foundation/NSValue.h> |
#include <Foundation/NSValue.h> |
28 |
|
#include <Foundation/NSNotification.h> |
29 |
|
|
30 |
#include "GameEngine/HgTeam.h" |
#include "GameEngine/HgTeam.h" |
31 |
#include "GameEngine/HgGame.h" |
#include "GameEngine/HgGame.h" |
81 |
} |
} |
82 |
|
|
83 |
/** |
/** |
84 |
* add a player to the team. |
* Add a player to the team. |
85 |
* The player must exist and mustn't be already in the team |
* The player must exist and mustn't be already in the team |
86 |
* already contains the player |
* already contains the player. |
87 |
|
* Post an notification named "updateTeam" containing the current object. |
88 |
*/ |
*/ |
89 |
- (void) addPlayer: (HgPlayer *)player |
- (void) addPlayer: (HgPlayer *)player |
90 |
{ |
{ |
93 |
NSParameterAssert (![_players containsObject: player]); |
NSParameterAssert (![_players containsObject: player]); |
94 |
|
|
95 |
[_players addObject: player]; |
[_players addObject: player]; |
96 |
|
|
97 |
|
[[NSNotificationCenter defaultCenter] |
98 |
|
postNotificationName:@"updateTeam" object:self]; |
99 |
} |
} |
100 |
|
|
101 |
/** |
/** |
102 |
* Remove a player to the team. |
* Remove a player to the team. |
103 |
* the player must be in the team. |
* The player must be in the team. |
104 |
|
* Post an notification named "updateTeam" containing the current object. |
105 |
*/ |
*/ |
106 |
- (void) removePlayer: (HgPlayer *)player |
- (void) removePlayer: (HgPlayer *)player |
107 |
{ |
{ |
109 |
NSParameterAssert ([_players containsObject: player]); |
NSParameterAssert ([_players containsObject: player]); |
110 |
|
|
111 |
[_players removeObject: player]; |
[_players removeObject: player]; |
112 |
|
|
113 |
|
[[NSNotificationCenter defaultCenter] |
114 |
|
postNotificationName:@"updateTeam" object:self]; |
115 |
} |
} |
116 |
|
|
117 |
/** |
/** |
157 |
|
|
158 |
if (self != nil) |
if (self != nil) |
159 |
{ |
{ |
160 |
ASSIGN(_name, [decoder decodeObject]); |
_name = RETAIN([decoder decodeObject]); |
161 |
[decoder decodeValueOfObjCType: "i" at: &_maxPlayers]; |
[decoder decodeValueOfObjCType: "i" at: &_maxPlayers]; |
162 |
ASSIGN(_players, [decoder decodeObject]); |
_players = RETAIN([decoder decodeObject]); |
163 |
} |
} |
164 |
|
|
165 |
return self; |
return self; |