-
Notifications
You must be signed in to change notification settings - Fork 0
/
butts2.js
43 lines (42 loc) · 1.21 KB
/
butts2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
export function assignAllUsers(userIds, factions) {
//TODO: IF USER LIST IS LARGER THAN 57, RANDOMLY SELECT 57 OF THEM.
let assignedFactions = factions.map((faction) => {
return { ...faction };
});
switch (factions.length) {
case 2:
userIds.forEach((userId, index) => {
if (index % 2 === 0) {
assignedFactions[1].users.push(userId);
} else {
assignedFactions[0].users.push(userId);
}
});
break;
case 3:
userIds.forEach((userId, index) => {
if (index % 3 === 0) {
assignedFactions[2].users.push(userId);
} else if (index % 3 === 1) {
assignedFactions[1].users.push(userId);
} else {
assignedFactions[0].users.push(userId);
}
});
break;
case 4:
userIds.forEach((userId, index) => {
if (index % 4 === 0) {
assignedFactions[3].users.push(userId);
} else if (index % 4 === 1) {
assignedFactions[2].users.push(userId);
} else if (index % 4 === 2) {
assignedFactions[1].users.push(userId);
} else {
assignedFactions[0].users.push(userId);
}
});
break;
}
return assignedFactions;
}