-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgroups.js
96 lines (94 loc) · 1.89 KB
/
groups.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const pots = {
"POT 1": [
"Man City",
"Sevilla",
"Barcelona",
"Napoli",
"Bayern",
"Paris",
"Benfica",
"Feyenoord",
"Liverpool",
],
"POT 2": [
"Real Madrid",
"Man United",
"Internazionale",
"Dortmund",
"Atletico",
"Leipzig",
"Porto",
"Arsenal",
"Atalanta",
],
"POT 3": [
"Shakhtar",
"Salzburg",
"Milan",
"Braga",
"PSV",
"Lazio",
"Crvena zvezda",
"Copenhagen",
"Marseille",
],
"POT 4": [
"Young Boys",
"Real Sociedad",
"Galatasaray",
"Celtic",
"Newcastle",
"Union Berlin",
"Antwerp",
"Lens",
"Molde",
],
};
const groups = [[], [], [], []];
const selections = [
[
{ pot: "POT 1", count: 3 },
{ pot: "POT 2", count: 2 },
{ pot: "POT 3", count: 2 },
{ pot: "POT 4", count: 2 },
],
[
{ pot: "POT 1", count: 2 },
{ pot: "POT 2", count: 3 },
{ pot: "POT 3", count: 2 },
{ pot: "POT 4", count: 2 },
],
[
{ pot: "POT 1", count: 2 },
{ pot: "POT 2", count: 2 },
{ pot: "POT 3", count: 3 },
{ pot: "POT 4", count: 2 },
],
[
{ pot: "POT 1", count: 2 },
{ pot: "POT 2", count: 2 },
{ pot: "POT 3", count: 2 },
{ pot: "POT 4", count: 3 },
],
];
for (let i = 0; i < selections.length; i++) {
selectTeams(groups[i], selections[i]);
}
function selectTeams(group, selections) {
for (const selection of selections) {
selectUniqueTeamsFromPot(pots[selection.pot], selection.count, group);
}
}
function selectUniqueTeamsFromPot(pot, count, selectedTeams) {
for (let i = 0; i < count; i++) {
if (pot.length === 0) {
console.error("Hata: Pot boş.");
return;
}
const teamIndex = Math.floor(Math.random() * pot.length);
selectedTeams.push(pot[teamIndex]);
pot.splice(teamIndex, 1);
}
}
export default groups;
export { pots, selections, selectTeams, selectUniqueTeamsFromPot };