|
@@ -73,11 +73,24 @@ class Game {
|
73
|
73
|
|
74
|
74
|
let pouringColor = sourceTube.peekTopColor();
|
75
|
75
|
|
76
|
|
- while (sourceTube.peekTopColor() == pouringColor && !targetTube.isFull())
|
|
76
|
+ while (sourceTube.peekTopColor() == pouringColor && !targetTube.isFull() && !targetTube.isComplete())
|
77
|
77
|
{
|
78
|
78
|
targetTube.addColor(sourceTube.removeColorLayer());
|
79
|
79
|
}
|
|
80
|
+
|
|
81
|
+ this.checkTubeCompletion(sourceTube);
|
|
82
|
+ this.checkTubeCompletion(targetTube);
|
80
|
83
|
}
|
81
|
84
|
|
82
|
|
-
|
|
85
|
+ checkTubeCompletion(tube)
|
|
86
|
+ {
|
|
87
|
+ if (tube.isComplete())
|
|
88
|
+ {
|
|
89
|
+ let tubeIndex = this.tubes.indexOf(tube);
|
|
90
|
+
|
|
91
|
+ this.tubes.splice(tubeIndex, 1);
|
|
92
|
+
|
|
93
|
+ if (this.selectedTube == tube) this.selectedTube = null;
|
|
94
|
+ }
|
|
95
|
+ }
|
83
|
96
|
}
|