Skip to content

Commit 9f4a27a

Browse files
committed
Implement support for disabling team damage
1 parent ed7643d commit 9f4a27a

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

javascript/entities/test/mock_player.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class MockPlayer extends Player {
4444
#fightingStyle_ = Player.kFightingStyleNormal;
4545
#gravity_ = 0.008;
4646
#score_ = 0;
47-
#team_ = 255; // NO_TEAM
47+
#team_ = Player.kNoTeam;
4848
#time_ = [0, 0];
4949
#wantedLevel_ = 0;
5050

javascript/features/games_deathmatch/deathmatch_game.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,17 @@ export class DeathmatchGame extends Game {
132132
// and will ensure that all settings for the |player| are synchronized to others.
133133
enableTeamStateForPlayer(player) {
134134
// TODO: Map marker visibility
135-
// TODO: Player team settings
135+
136+
if (this.#teams_.has(player) && !this.#teamDamage_)
137+
player.team = this.#teams_.get(player);
136138
}
137139

138140
// Disables the team-specific state for the given |player|. This will reset the team that they
139141
// are part of when damage has been disabled, clean up marker state, etecetera.
140142
clearTeamStateForPlayer(player) {
141143
// TODO: Map marker visibility
142-
// TODO: Player team settings
144+
145+
if (this.#teams_.has(player) && !this.#teamDamage_)
146+
player.team = Player.kNoTeam;
143147
}
144148
}

javascript/features/games_deathmatch/games_deathmatch.test.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ describe('GamesDeathmatch', (it, beforeEach) => {
134134
maximumPlayers: 4,
135135
});
136136

137+
assert.equal(gunther.team, Player.kNoTeam);
138+
assert.equal(russell.team, Player.kNoTeam);
139+
assert.equal(lucy.team, Player.kNoTeam);
140+
137141
assert.isTrue(await gunther.issueCommand('/bubble'));
138142
assert.isTrue(await russell.issueCommand('/bubble'));
139143
assert.isTrue(await lucy.issueCommand('/bubble'));
@@ -148,7 +152,12 @@ describe('GamesDeathmatch', (it, beforeEach) => {
148152
assert.equal(game.getTeamForPlayer(lucy), DeathmatchGame.kTeamBravo);
149153

150154
// TODO: Verify the expected map marker visibility.
151-
// TODO: Verify the expected player team values.
155+
156+
assert.equal(gunther.team, game.getTeamForPlayer(gunther));
157+
assert.equal(russell.team, game.getTeamForPlayer(russell));
158+
assert.equal(lucy.team, game.getTeamForPlayer(lucy));
159+
160+
assert.equal(gunther.team, russell.team);
152161

153162
assert.isTrue(await gunther.issueCommand('/leave'));
154163
assert.isTrue(await russell.issueCommand('/leave'));
@@ -158,6 +167,11 @@ describe('GamesDeathmatch', (it, beforeEach) => {
158167

159168
// Verify that the Game instance has been destroyed, together with all supporting infra.
160169
assert.throws(() => getGameInstance());
170+
171+
assert.equal(gunther.team, Player.kNoTeam);
172+
assert.equal(russell.team, Player.kNoTeam);
173+
assert.equal(lucy.team, Player.kNoTeam);
174+
161175
});
162176

163177
it('should maintain statistics of all participants in the game', async (assert) => {

0 commit comments

Comments
 (0)