Code edit (4 edits merged)
Please save this source code
User prompt
Make the console logs and gui displays conditioned to debug === true
Code edit (12 edits merged)
Please save this source code
User prompt
When last candy is taken set the gameState to 2; display a winBackground or a loseBackground depending on the playerTurn
User prompt
disable up and down events when gameState != 1
Code edit (1 edits merged)
Please save this source code
User prompt
if gameState == 2 then on 'down' reset the game
User prompt
Fix game not ending when computer takes last stick
User prompt
fix game change turn instead of ending immediately when player takes last candy.
User prompt
Bug : game changes turn instead of ending when player takes last candy.
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: playerTrun is not defined' in this line: 'if (playerTrun && playerSelecting && !self.selectedCandiesCount) {' Line Number: 229
Code edit (2 edits merged)
Please save this source code
User prompt
speed up computer selection movement when screen size is small
User prompt
speed up computer selection movement when candiesToPick is 2
User prompt
Add an explosion background and an animation when anyone takes the last candy and before the win/lose backgrounr display
Code edit (2 edits merged)
Please save this source code
User prompt
place the explostion at x =2048 / 2 + 30; y=250 + 12 * 190 + 20;
Code edit (11 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught TypeError: Math.Random is not a function' in this line: 'candiesNumber = Math.Random() > 0.5 ? 12 : 11;' Line Number: 207
Code edit (1 edits merged)
Please save this source code
User prompt
show the explosion animation also when computer lose
Code edit (7 edits merged)
Please save this source code
User prompt
factorize the 3 blocks if (candyCanes.length === 0) {...} in a global function with all required parameters
===================================================================
--- original.js
+++ change.js
@@ -225,14 +225,23 @@
if (gameState === 1) {
if (debug) {
console.log('Mouse up event:', obj);
}
+ if (playerTrun && playerSelecting && !self.selectedCandiesCount) {
+ if (debug) {
+ console.log('Nothing selected');
+ }
+ return;
+ }
playerSelecting = false;
stage.off('move', handleSelection);
removeCandies(candyCanes, self.selectedCandiesCount);
if (candyCanes.length === 0) {
+ if (debug) {
+ console.log('Game end 1');
+ }
gameState = 2;
- var endBackground = playerTurn ? 'winBackground' : 'loseBackground';
+ var endBackground = playerTurn ? 'loseBackground' : 'winBackground';
var backgroundAsset = self.createAsset(endBackground, 'End Game Background', 0.5, 0.5);
backgroundAsset.x = 2048 / 2;
backgroundAsset.y = 2732 / 2;
self.addChild(backgroundAsset);
@@ -245,8 +254,11 @@
setSelectionPositions(self, candyCanes.length > 0 ? candyCanes[0].y : 0);
if (playerTurn) {
removeCandies(candyCanes, self.selectedCandiesCount);
if (candyCanes.length === 0) {
+ if (debug) {
+ console.log('Game end 2');
+ }
gameState = 2;
var endBackground = 'winBackground';
var backgroundAsset = self.createAsset(endBackground, 'End Game Background', 0.5, 0.5);
backgroundAsset.x = 2048 / 2;
@@ -272,8 +284,11 @@
if (debug) {
console.log("Human Player's turn");
}
if (candyCanes.length === 0) {
+ if (debug) {
+ console.log('Game end 3');
+ }
gameState = 2;
var endBackground = playerTurn ? 'winBackground' : 'loseBackground';
var backgroundAsset = self.createAsset(endBackground, 'End Game Background', 0.5, 0.5);
backgroundAsset.x = 2048 / 2;
a christmas wooden board Background image. High contrast. No shadows.
a vertical christmas wooden board with snow, and decorations on its sides Background image. High contrast. No shadows.
a photo-realistic white and red vertical candy stick slice Single Game Texture. No background. High contrast. No shadows.
a horizontal santa's arm with a white glove and the index pointing to the right Single Game Texture. No background. High contrast. No shadows.
an green hairy grinch's arm, pointing in the horizontal direction, the index finger pointing to the left Single Game Texture. No background. High contrast. No shadows.
a photo-realistic white and red twisted candy stick slice in vertical position and with an extinguished wick. At its center, a simple white rectangular "TNT" sticker in the same direction as the stick Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a top view of a TNT explosion fire Background image. High contrast. No shadows.
A funny Santa Claus disheveled and covered by black soot after an explosion. stary night. High contrast.
a futuristic white robot arm. horizontal direction. the index finger pointing to the left. Single Game Texture. No background. High contrast. No shadows.
A old super hero Santa Claus holding a candy cane in his hand High contrast.
frame of an empty christmas themed popup with a decorated border User interface
a single mat rounded empty button User interface