Skip to content

Commit 190dbe7

Browse files
committed
Begin moving colour management to JavaScript
1 parent b953584 commit 190dbe7

12 files changed

Lines changed: 558 additions & 8 deletions

javascript/features/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ other foundational features, without circular dependencies.
3333

3434
Feature | Code Health | Description
3535
-------------------------------------|-------------|------------------------------------------------------------------
36-
[AccountProvider](account_provider/) | ✔ 2020 | Provides the `Player.account` supplement, loads and saves account data.
36+
[AccountProvider](account_provider/) | ✔ 2020 | Provides the `Player.prototype.account` supplement, loads and saves account data.
3737
[Communication](communication/) | ✔ 2020 | Provides communication abilities, chat, spam and message filters.
3838
[Finance](finance/) | ✔ 2020 | Manages player's cash, bank account balances, tax and loans.
3939
[Limits](limits/) | ✔ 2020 | Centrally decides on limitations for various features, e.g. teleportation.
4040
[Nuwani](nuwani/) | ✔ 2020 | Provides our ability to interact with IRC and Discord.
41-
[PlayerStats](player_stats/) | ✔ 2020 | Provides the `Player.stats` supplement, tracks player metrics.
41+
[PlayerColors](player_colors/) | ✔ 2020 | Provides the `Player.prototype.colors` supplement and color management.
42+
[PlayerStats](player_stats/) | ✔ 2020 | Provides the `Player.prototype.stats` supplement, tracks player metrics.
4243
[SAMPCAC](sampcac/) | ✔ 2020 | Integration with the SAMPCAC anti cheat system, optional for players.
4344
[Settings](settings/) | ✔ 2020 | Manages persistent settings on the server.
4445

@@ -79,7 +80,7 @@ Feature | Code Health | Description
7980
[Leaderboard](leaderboard/) | ❓ 2020 | The `/leaderboard` command, and database routines to calculate it.
8081
[Location](location/) | ❓ 2020 | -
8182
[NuwaniCommands](nuwani_commands/) | ❓ 2020 | The `/nuwani` command, enabling Management to control the bot system.
82-
[PlayerCommands](player_commands/) | ❓ 2020 | Provides commands for the player also useable for admins. E.g. to buy weapons.
83+
[PlayerCommands](player_commands/) | ❓ 2020 | Provides commands for the player also useable for admins. E.g. to buy weapons.
8384
[PlayerFavours](player_favours/) | ❓ 2020 | -
8485
[PlayerSettings](player_settings/) | ❓ 2020 | -
8586
[Playground](playground/) | ❓ 2020 | -

javascript/features/communication/communication.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ export default class Communication extends Feature {
3232
// features, as communication is a cricial part of the server.
3333
this.markFoundational();
3434

35+
// Depend on the PlayerColors feature, which provides a supplement we style text with.
36+
this.defineDependency('player_colors');
37+
3538
// Depend on Nuwani for being able to distribute communication to non-game destinations.
3639
const nuwani = this.defineDependency('nuwani');
3740

javascript/features/communication/communication_manager.test.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import { AdministratorChannel } from 'features/communication/channels/administrator_channel.js';
66

7+
import { format } from 'base/format.js';
8+
79
describe('CommunicationManager', (it, beforeEach, afterEach) => {
810
let gunther = null;
911
let manager = null;
@@ -70,6 +72,11 @@ describe('CommunicationManager', (it, beforeEach, afterEach) => {
7072
});
7173

7274
it('should allow players to mention other players in public chat', async (assert) => {
75+
function colorForPlayer(player) {
76+
return format(
77+
'{%06X}@%s{FFFFFF}', player.colors.currentColor.toNumberRGB(), player.name);
78+
}
79+
7380
// (1) Verify that all nicknames can be matched
7481
const nicknameTestCasePlayerId = 42;
7582
const nicknameTestCases = [
@@ -88,7 +95,7 @@ describe('CommunicationManager', (it, beforeEach, afterEach) => {
8895

8996
await gunther.issueMessage(`Hey @${testCase}, how are you?`);
9097
assert.equal(gunther.messages.length, 1);
91-
assert.includes(gunther.messages.pop(), `{FFFFFF}@${testCase}{FFFFFF}`);
98+
assert.includes(gunther.messages.pop(), colorForPlayer(testPlayer));
9299

93100
assert.equal(testPlayer.soundIdForTesting, 1058);
94101

@@ -107,27 +114,27 @@ describe('CommunicationManager', (it, beforeEach, afterEach) => {
107114

108115
await gunther.issueMessage(testCase);
109116
assert.equal(gunther.messages.length, 1);
110-
assert.includes(gunther.messages.pop(), `{FFFFFF}@Russell{FFFFFF}`);
117+
assert.includes(gunther.messages.pop(), colorForPlayer(russell));
111118

112119
await server.clock.advance(10 * 1000); // get past the spam filter
113120
}
114121

115122
// (3) Verify that players cannot mention themselves, or invalid players.
116123
await gunther.issueMessage('Hey @Gunther, how are you?');
117124
assert.equal(gunther.messages.length, 1);
118-
assert.doesNotInclude(gunther.messages.pop(), `{FFFFFF}@Gunther{FFFFFF}`);
125+
assert.doesNotInclude(gunther.messages.pop(), `@Gunther{FFFFFF}`);
119126

120127
// (4) Verify that it doesn't catch cases that aren't mentions.
121128
await gunther.issueMessage('info@domain.com');
122129
assert.equal(gunther.messages.length, 1);
123130
assert.doesNotInclude(gunther.messages.pop(), `{FFFFFF}info@domain.com{FFFFFF}`);
124131

125132
// (5) Verify that it's got the ability to use the mentioned player's colour.
126-
russell.color = Color.fromRGB(50, 150, 250);
133+
russell.colors.customColor = Color.fromRGB(50, 150, 250);
127134

128135
await gunther.issueMessage('Heya @Russell, how are you?');
129136
assert.equal(gunther.messages.length, 1);
130-
assert.includes(gunther.messages.pop(), `{3296FA}@Russell{FFFFFF}`);
137+
assert.includes(gunther.messages.pop(), colorForPlayer(russell));
131138
});
132139

133140
it('should allow delegates to intercept received messages', async (assert) => {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Player Colors
2+
Determining which colour will be assigned to a player is not an entirely straightforward task. It's
3+
decided based on a hierarchy of needs:
4+
5+
1. Base colour assigned based on their ID,
6+
1. Base colour assigned based on their level, when applicable,
7+
1. Custom colour that the player is able to pick themselves,
8+
1. Custom colour based on the gang that the player is part of, if they choose to use this,
9+
1. Custom colour applied based on their activity, e.g. while playing a minigame.
10+
11+
Some of these have additional complexities, for example because players can decide that they don't
12+
want to use their gang's colour at all.
13+
14+
## Updating a player's color
15+
Features are free to update colours through the `Player.prototype.colors` supplement, which has been
16+
implemented by the [PlayerColorsSupplement](player_colors_supplement.js) class. Examples include:
17+
18+
### Usage for Games
19+
```javascript
20+
class MyGame extends Game {
21+
async onPlayerAdded(player) {
22+
player.colors.gameColor = Color.fromRGBA(255, 0, 0, 170);
23+
}
24+
25+
async onPlayerRemoved(player) {
26+
player.colors.gameColor = null;
27+
}
28+
}
29+
```
30+
31+
### Usage from Pawn
32+
```
33+
stock StartGame() {
34+
SetPlayerGameColor(playerId, COLOR_RED);
35+
}
36+
37+
stock StopGame() {
38+
ReleasePlayerGameColor(playerId);
39+
}
40+
```
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
// Copyright 2020 Las Venturas Playground. All rights reserved.
2+
// Use of this source code is governed by the MIT license, a copy of which can
3+
// be found in the LICENSE file.
4+
5+
import { Color } from 'base/color.js';
6+
7+
// Default alpha channel for player colors.
8+
export const kDefaultAlpha = 170;
9+
10+
// Array of the default colors that will be assigned to players based on their ID. When Player IDs
11+
// are seen that exceed the number of colours in this array, it will loop around instead.
12+
const kDefaultColors = [
13+
/* 0 */ Color.fromRGBA(47, 200, 39, kDefaultAlpha),
14+
/* 1 */ Color.fromRGBA(15, 217, 250, kDefaultAlpha),
15+
/* 2 */ Color.fromRGBA(220, 20, 60, kDefaultAlpha),
16+
/* 3 */ Color.fromRGBA(227, 172, 18, kDefaultAlpha),
17+
/* 4 */ Color.fromRGBA(119, 136, 153, kDefaultAlpha),
18+
/* 5 */ Color.fromRGBA(0, 248, 83, kDefaultAlpha),
19+
/* 6 */ Color.fromRGBA(101, 173, 235, kDefaultAlpha),
20+
/* 7 */ Color.fromRGBA(255, 20, 147, kDefaultAlpha),
21+
/* 8 */ Color.fromRGBA(244, 164, 96, kDefaultAlpha),
22+
/* 9 */ Color.fromRGBA(238, 130, 238, kDefaultAlpha),
23+
/* 10 */ Color.fromRGBA(220, 222, 61, kDefaultAlpha),
24+
/* 11 */ Color.fromRGBA(165, 94, 44, kDefaultAlpha),
25+
/* 12 */ Color.fromRGBA(130, 157, 199, kDefaultAlpha),
26+
/* 13 */ Color.fromRGBA(4, 149, 205, kDefaultAlpha),
27+
/* 14 */ Color.fromRGBA(20, 255, 127, kDefaultAlpha),
28+
/* 15 */ Color.fromRGBA(203, 126, 211, kDefaultAlpha),
29+
/* 16 */ Color.fromRGBA(201, 80, 84, kDefaultAlpha),
30+
/* 17 */ Color.fromRGBA(250, 251, 113, kDefaultAlpha),
31+
/* 18 */ Color.fromRGBA(36, 124, 27, kDefaultAlpha),
32+
/* 19 */ Color.fromRGBA(241, 50, 50, kDefaultAlpha),
33+
/* 20 */ Color.fromRGBA(250, 36, 204, kDefaultAlpha),
34+
/* 21 */ Color.fromRGBA(179, 107, 114, kDefaultAlpha),
35+
/* 22 */ Color.fromRGBA(67, 128, 216, kDefaultAlpha),
36+
/* 23 */ Color.fromRGBA(255, 146, 73, kDefaultAlpha),
37+
/* 24 */ Color.fromRGBA(255, 153, 194, kDefaultAlpha),
38+
/* 25 */ Color.fromRGBA(255, 39, 39, kDefaultAlpha),
39+
/* 26 */ Color.fromRGBA(137, 82, 235, kDefaultAlpha),
40+
/* 27 */ Color.fromRGBA(70, 126, 64, kDefaultAlpha),
41+
/* 28 */ Color.fromRGBA(175, 175, 175, kDefaultAlpha),
42+
/* 29 */ Color.fromRGBA(255, 68, 169, kDefaultAlpha),
43+
/* 30 */ Color.fromRGBA(193, 247, 236, kDefaultAlpha),
44+
/* 31 */ Color.fromRGBA(78, 255, 0, kDefaultAlpha),
45+
/* 32 */ Color.fromRGBA(0, 219, 255, kDefaultAlpha),
46+
/* 33 */ Color.fromRGBA(219, 54, 250, kDefaultAlpha),
47+
/* 34 */ Color.fromRGBA(218, 120, 37, kDefaultAlpha),
48+
/* 35 */ Color.fromRGBA(214, 66, 96, kDefaultAlpha),
49+
/* 36 */ Color.fromRGBA(56, 75, 202, kDefaultAlpha),
50+
/* 37 */ Color.fromRGBA(210, 235, 27, kDefaultAlpha),
51+
/* 38 */ Color.fromRGBA(172, 55, 110, kDefaultAlpha),
52+
/* 39 */ Color.fromRGBA(184, 166, 107, kDefaultAlpha),
53+
/* 40 */ Color.fromRGBA(47, 200, 39, kDefaultAlpha),
54+
/* 41 */ Color.fromRGBA(15, 217, 250, kDefaultAlpha),
55+
/* 42 */ Color.fromRGBA(220, 20, 60, kDefaultAlpha),
56+
/* 43 */ Color.fromRGBA(227, 172, 18, kDefaultAlpha),
57+
/* 44 */ Color.fromRGBA(119, 136, 153, kDefaultAlpha),
58+
/* 45 */ Color.fromRGBA(0, 248, 83, kDefaultAlpha),
59+
/* 46 */ Color.fromRGBA(101, 173, 235, kDefaultAlpha),
60+
/* 47 */ Color.fromRGBA(255, 20, 147, kDefaultAlpha),
61+
/* 48 */ Color.fromRGBA(244, 164, 96, kDefaultAlpha),
62+
/* 49 */ Color.fromRGBA(238, 130, 238, kDefaultAlpha),
63+
/* 50 */ Color.fromRGBA(220, 222, 61, kDefaultAlpha),
64+
/* 51 */ Color.fromRGBA(165, 94, 44, kDefaultAlpha),
65+
/* 52 */ Color.fromRGBA(130, 157, 199, kDefaultAlpha),
66+
/* 53 */ Color.fromRGBA(4, 149, 205, kDefaultAlpha),
67+
/* 54 */ Color.fromRGBA(20, 255, 127, kDefaultAlpha),
68+
/* 55 */ Color.fromRGBA(203, 126, 211, kDefaultAlpha),
69+
/* 56 */ Color.fromRGBA(201, 80, 84, kDefaultAlpha),
70+
/* 57 */ Color.fromRGBA(250, 251, 113, kDefaultAlpha),
71+
/* 58 */ Color.fromRGBA(36, 124, 27, kDefaultAlpha),
72+
/* 59 */ Color.fromRGBA(241, 50, 50, kDefaultAlpha),
73+
/* 60 */ Color.fromRGBA(250, 36, 204, kDefaultAlpha),
74+
/* 61 */ Color.fromRGBA(179, 107, 114, kDefaultAlpha),
75+
/* 62 */ Color.fromRGBA(67, 128, 216, kDefaultAlpha),
76+
/* 63 */ Color.fromRGBA(255, 146, 73, kDefaultAlpha),
77+
/* 64 */ Color.fromRGBA(255, 153, 194, kDefaultAlpha),
78+
/* 65 */ Color.fromRGBA(255, 39, 39, kDefaultAlpha),
79+
/* 66 */ Color.fromRGBA(137, 82, 235, kDefaultAlpha),
80+
/* 67 */ Color.fromRGBA(70, 126, 64, kDefaultAlpha),
81+
/* 68 */ Color.fromRGBA(175, 175, 175, kDefaultAlpha),
82+
/* 69 */ Color.fromRGBA(255, 68, 169, kDefaultAlpha),
83+
/* 70 */ Color.fromRGBA(193, 247, 236, kDefaultAlpha),
84+
/* 71 */ Color.fromRGBA(78, 255, 0, kDefaultAlpha),
85+
/* 72 */ Color.fromRGBA(0, 219, 255, kDefaultAlpha),
86+
/* 73 */ Color.fromRGBA(219, 54, 250, kDefaultAlpha),
87+
/* 74 */ Color.fromRGBA(218, 120, 37, kDefaultAlpha),
88+
/* 75 */ Color.fromRGBA(214, 66, 96, kDefaultAlpha),
89+
/* 76 */ Color.fromRGBA(56, 75, 202, kDefaultAlpha),
90+
/* 77 */ Color.fromRGBA(210, 235, 27, kDefaultAlpha),
91+
/* 78 */ Color.fromRGBA(172, 55, 110, kDefaultAlpha),
92+
/* 79 */ Color.fromRGBA(184, 166, 107, kDefaultAlpha),
93+
/* 80 */ Color.fromRGBA(47, 200, 39, kDefaultAlpha),
94+
/* 81 */ Color.fromRGBA(15, 217, 250, kDefaultAlpha),
95+
/* 82 */ Color.fromRGBA(220, 20, 60, kDefaultAlpha),
96+
/* 83 */ Color.fromRGBA(227, 172, 18, kDefaultAlpha),
97+
/* 84 */ Color.fromRGBA(119, 136, 153, kDefaultAlpha),
98+
/* 85 */ Color.fromRGBA(0, 248, 83, kDefaultAlpha),
99+
/* 86 */ Color.fromRGBA(101, 173, 235, kDefaultAlpha),
100+
/* 87 */ Color.fromRGBA(255, 20, 147, kDefaultAlpha),
101+
/* 88 */ Color.fromRGBA(244, 164, 96, kDefaultAlpha),
102+
/* 89 */ Color.fromRGBA(238, 130, 238, kDefaultAlpha),
103+
/* 90 */ Color.fromRGBA(220, 222, 61, kDefaultAlpha),
104+
/* 91 */ Color.fromRGBA(165, 94, 44, kDefaultAlpha),
105+
/* 92 */ Color.fromRGBA(130, 157, 199, kDefaultAlpha),
106+
/* 93 */ Color.fromRGBA(4, 149, 205, kDefaultAlpha),
107+
/* 94 */ Color.fromRGBA(20, 255, 127, kDefaultAlpha),
108+
/* 95 */ Color.fromRGBA(203, 126, 211, kDefaultAlpha),
109+
/* 96 */ Color.fromRGBA(201, 80, 84, kDefaultAlpha),
110+
/* 97 */ Color.fromRGBA(250, 251, 113, kDefaultAlpha),
111+
/* 98 */ Color.fromRGBA(36, 124, 27, kDefaultAlpha),
112+
/* 99 */ Color.fromRGBA(241, 50, 50, kDefaultAlpha),
113+
/* 100 */ Color.fromRGBA(250, 36, 204, kDefaultAlpha),
114+
/* 101 */ Color.fromRGBA(179, 107, 114, kDefaultAlpha),
115+
/* 102 */ Color.fromRGBA(67, 128, 216, kDefaultAlpha),
116+
/* 103 */ Color.fromRGBA(255, 146, 73, kDefaultAlpha),
117+
/* 104 */ Color.fromRGBA(255, 153, 194, kDefaultAlpha),
118+
/* 105 */ Color.fromRGBA(255, 39, 39, kDefaultAlpha),
119+
/* 106 */ Color.fromRGBA(137, 82, 235, kDefaultAlpha),
120+
/* 107 */ Color.fromRGBA(70, 126, 64, kDefaultAlpha),
121+
/* 108 */ Color.fromRGBA(175, 175, 175, kDefaultAlpha),
122+
/* 109 */ Color.fromRGBA(255, 68, 169, kDefaultAlpha),
123+
/* 110 */ Color.fromRGBA(193, 247, 236, kDefaultAlpha),
124+
/* 111 */ Color.fromRGBA(78, 255, 0, kDefaultAlpha),
125+
/* 112 */ Color.fromRGBA(0, 219, 255, kDefaultAlpha),
126+
/* 113 */ Color.fromRGBA(219, 54, 250, kDefaultAlpha),
127+
/* 114 */ Color.fromRGBA(218, 120, 37, kDefaultAlpha),
128+
/* 115 */ Color.fromRGBA(214, 66, 96, kDefaultAlpha),
129+
/* 116 */ Color.fromRGBA(56, 75, 202, kDefaultAlpha),
130+
/* 117 */ Color.fromRGBA(210, 235, 27, kDefaultAlpha),
131+
/* 118 */ Color.fromRGBA(172, 55, 110, kDefaultAlpha),
132+
/* 119 */ Color.fromRGBA(184, 166, 107, kDefaultAlpha),
133+
/* 120 */ Color.fromRGBA(47, 200, 39, kDefaultAlpha),
134+
/* 121 */ Color.fromRGBA(15, 217, 250, kDefaultAlpha),
135+
/* 122 */ Color.fromRGBA(220, 20, 60, kDefaultAlpha),
136+
/* 123 */ Color.fromRGBA(227, 172, 18, kDefaultAlpha),
137+
/* 124 */ Color.fromRGBA(119, 136, 153, kDefaultAlpha),
138+
/* 125 */ Color.fromRGBA(0, 248, 83, kDefaultAlpha),
139+
/* 126 */ Color.fromRGBA(101, 173, 235, kDefaultAlpha),
140+
/* 127 */ Color.fromRGBA(255, 20, 147, kDefaultAlpha),
141+
/* 128 */ Color.fromRGBA(244, 164, 96, kDefaultAlpha),
142+
/* 129 */ Color.fromRGBA(238, 130, 238, kDefaultAlpha),
143+
/* 130 */ Color.fromRGBA(220, 222, 61, kDefaultAlpha),
144+
/* 131 */ Color.fromRGBA(165, 94, 44, kDefaultAlpha),
145+
/* 132 */ Color.fromRGBA(130, 157, 199, kDefaultAlpha),
146+
/* 133 */ Color.fromRGBA(4, 149, 205, kDefaultAlpha),
147+
/* 134 */ Color.fromRGBA(20, 255, 127, kDefaultAlpha),
148+
/* 135 */ Color.fromRGBA(203, 126, 211, kDefaultAlpha),
149+
/* 136 */ Color.fromRGBA(201, 80, 84, kDefaultAlpha),
150+
/* 137 */ Color.fromRGBA(250, 251, 113, kDefaultAlpha),
151+
/* 138 */ Color.fromRGBA(36, 124, 27, kDefaultAlpha),
152+
/* 139 */ Color.fromRGBA(241, 50, 50, kDefaultAlpha),
153+
/* 140 */ Color.fromRGBA(250, 36, 204, kDefaultAlpha),
154+
/* 141 */ Color.fromRGBA(179, 107, 114, kDefaultAlpha),
155+
/* 142 */ Color.fromRGBA(67, 128, 216, kDefaultAlpha),
156+
/* 143 */ Color.fromRGBA(255, 146, 73, kDefaultAlpha),
157+
/* 144 */ Color.fromRGBA(255, 153, 194, kDefaultAlpha),
158+
/* 145 */ Color.fromRGBA(255, 39, 39, kDefaultAlpha),
159+
/* 146 */ Color.fromRGBA(137, 82, 235, kDefaultAlpha),
160+
/* 147 */ Color.fromRGBA(70, 126, 64, kDefaultAlpha),
161+
/* 148 */ Color.fromRGBA(175, 175, 175, kDefaultAlpha),
162+
/* 149 */ Color.fromRGBA(255, 68, 169, kDefaultAlpha),
163+
/* 150 */ Color.fromRGBA(193, 247, 236, kDefaultAlpha),
164+
/* 151 */ Color.fromRGBA(78, 255, 0, kDefaultAlpha),
165+
/* 152 */ Color.fromRGBA(0, 219, 255, kDefaultAlpha),
166+
/* 153 */ Color.fromRGBA(219, 54, 250, kDefaultAlpha),
167+
/* 154 */ Color.fromRGBA(218, 120, 37, kDefaultAlpha),
168+
/* 155 */ Color.fromRGBA(214, 66, 96, kDefaultAlpha),
169+
/* 156 */ Color.fromRGBA(56, 75, 202, kDefaultAlpha),
170+
/* 157 */ Color.fromRGBA(210, 235, 27, kDefaultAlpha),
171+
/* 158 */ Color.fromRGBA(172, 55, 110, kDefaultAlpha),
172+
/* 159 */ Color.fromRGBA(184, 166, 107, kDefaultAlpha),
173+
/* 160 */ Color.fromRGBA(47, 200, 39, kDefaultAlpha),
174+
/* 161 */ Color.fromRGBA(15, 217, 250, kDefaultAlpha),
175+
/* 162 */ Color.fromRGBA(220, 20, 60, kDefaultAlpha),
176+
/* 163 */ Color.fromRGBA(227, 172, 18, kDefaultAlpha),
177+
/* 164 */ Color.fromRGBA(119, 136, 153, kDefaultAlpha),
178+
/* 165 */ Color.fromRGBA(0, 248, 83, kDefaultAlpha),
179+
/* 166 */ Color.fromRGBA(101, 173, 235, kDefaultAlpha),
180+
/* 167 */ Color.fromRGBA(255, 20, 147, kDefaultAlpha),
181+
/* 168 */ Color.fromRGBA(244, 164, 96, kDefaultAlpha),
182+
/* 169 */ Color.fromRGBA(238, 130, 238, kDefaultAlpha),
183+
/* 170 */ Color.fromRGBA(220, 222, 61, kDefaultAlpha),
184+
/* 171 */ Color.fromRGBA(165, 94, 44, kDefaultAlpha),
185+
/* 172 */ Color.fromRGBA(130, 157, 199, kDefaultAlpha),
186+
/* 173 */ Color.fromRGBA(4, 149, 205, kDefaultAlpha),
187+
/* 174 */ Color.fromRGBA(20, 255, 127, kDefaultAlpha),
188+
/* 175 */ Color.fromRGBA(203, 126, 211, kDefaultAlpha),
189+
/* 176 */ Color.fromRGBA(201, 80, 84, kDefaultAlpha),
190+
/* 177 */ Color.fromRGBA(250, 251, 113, kDefaultAlpha),
191+
/* 178 */ Color.fromRGBA(36, 124, 27, kDefaultAlpha),
192+
/* 179 */ Color.fromRGBA(241, 50, 50, kDefaultAlpha),
193+
/* 180 */ Color.fromRGBA(250, 36, 204, kDefaultAlpha),
194+
/* 181 */ Color.fromRGBA(179, 107, 114, kDefaultAlpha),
195+
/* 182 */ Color.fromRGBA(67, 128, 216, kDefaultAlpha),
196+
/* 183 */ Color.fromRGBA(255, 146, 73, kDefaultAlpha),
197+
/* 184 */ Color.fromRGBA(255, 153, 194, kDefaultAlpha),
198+
/* 185 */ Color.fromRGBA(255, 39, 39, kDefaultAlpha),
199+
/* 186 */ Color.fromRGBA(137, 82, 235, kDefaultAlpha),
200+
/* 187 */ Color.fromRGBA(70, 126, 64, kDefaultAlpha),
201+
/* 188 */ Color.fromRGBA(175, 175, 175, kDefaultAlpha),
202+
/* 189 */ Color.fromRGBA(255, 68, 169, kDefaultAlpha),
203+
/* 190 */ Color.fromRGBA(193, 247, 236, kDefaultAlpha),
204+
/* 191 */ Color.fromRGBA(78, 255, 0, kDefaultAlpha),
205+
/* 192 */ Color.fromRGBA(0, 219, 255, kDefaultAlpha),
206+
/* 193 */ Color.fromRGBA(219, 54, 250, kDefaultAlpha),
207+
/* 194 */ Color.fromRGBA(218, 120, 37, kDefaultAlpha),
208+
/* 195 */ Color.fromRGBA(214, 66, 96, kDefaultAlpha),
209+
/* 196 */ Color.fromRGBA(56, 75, 202, kDefaultAlpha),
210+
/* 197 */ Color.fromRGBA(210, 235, 27, kDefaultAlpha),
211+
/* 198 */ Color.fromRGBA(172, 55, 110, kDefaultAlpha),
212+
/* 199 */ Color.fromRGBA(184, 166, 107, kDefaultAlpha)
213+
];
214+
215+
// Returns the default color for the given |player|.
216+
export function getDefaultColorForPlayer(player) {
217+
return kDefaultColors[player.id % kDefaultColors.length];
218+
}

0 commit comments

Comments
 (0)