|
@@ -21,12 +21,13 @@ class Game {
|
21
|
21
|
*/
|
22
|
22
|
initializeColorTubes(tubeLevel)
|
23
|
23
|
{
|
24
|
|
- let nbColors = this.tubes.length - 1;
|
|
24
|
+ let nbTubes = this.tubes.length - 1;
|
25
|
25
|
let allColors = [];
|
26
|
26
|
|
27
|
|
- for (let coloridx = 0; coloridx < nbColors; coloridx++)
|
|
27
|
+ for (let i = 0; i < nbTubes; i++)
|
28
|
28
|
{
|
29
|
|
- for (let times = 0; times < tubeLevel; times++)
|
|
29
|
+ let coloridx = i % this.#colorsBank.length;
|
|
30
|
+ for (let times = 0; times < tubeLevel-1; times++)
|
30
|
31
|
{
|
31
|
32
|
allColors.push(this.#colorsBank[coloridx]);
|
32
|
33
|
}
|
|
@@ -41,7 +42,8 @@ class Game {
|
41
|
42
|
|
42
|
43
|
for (let index = 0; index < allColors.length; index++)
|
43
|
44
|
{
|
44
|
|
- this.tubes[Math.floor(index/tubeLevel)].addColor(allColors[index]);
|
|
45
|
+ let tubeIndex = Math.floor(index/(tubeLevel-1));
|
|
46
|
+ this.tubes[tubeIndex].addColor(allColors[index]);
|
45
|
47
|
}
|
46
|
48
|
}
|
47
|
49
|
|