Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in this line: 'var dx = newPos.x - card.x;' Line Number: 398
Code edit (5 edits merged)
Please save this source code
User prompt
update the line `var newPos = positions[index];` to retreive the newPos int the position array using the uid property
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in this line: 'var dx = newPos.x - card.x;' Line Number: 391
Code edit (15 edits merged)
Please save this source code
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'id')' in this line: 'return card.id === index && card !== card1;' Line Number: 479
User prompt
fix reorderedPositions.push(positions[indexes[i]]) because indexes[i] is an id not an index that could be found in positions
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'id')' in this line: 'return card.id === index;' Line Number: 469
User prompt
at line `positions = shuffleWithDifficulty(positions, currentDifficulty);` update the code to reorder the positions array uning the indexes array instead of shuffleWithDifficulty
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
ensureAdjacentIndexes should only treat adjacentIndexes randomly choosen pairs in the array
Code edit (2 edits merged)
Please save this source code
User prompt
fix ensureAdjacentIndexes to realy move elements with same values next to each other using an inner loop
Code edit (1 edits merged)
Please save this source code
User prompt
ensureAdjacentIndexes should randomly create horizontaly and verticaly adjacent pairs
Code edit (2 edits merged)
Please save this source code
User prompt
ensureAdjacentIndexes should only treat adjacentIndexes pairs
Code edit (3 edits merged)
Please save this source code
User prompt
extract the adjacent Indexes part of shuffleWithDifficulty in an independent function
User prompt
the adjacent Indexes part of shuffleWithDifficulty should move the elements of array depending on their value next to each other, not just depending on their index
Code edit (8 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -286,17 +286,17 @@
return array;
}
function ensureAdjacentIndexes(array, difficulty) {
var adjacentIndexes = Math.floor(array.length / 2 / difficulty);
- console.log("Making adjacentIndexes : " + adjacentIndexes, array);
+ console.log("Making adjacentIndexes : " + adjacentIndexes + " / " + array.length, array);
for (var i = 0; i < array.length - 1; i++) {
- for (var j = i + 1; j < array.length; j++) {
- if (array[i] && array[j] && array[i] === array[j]) {
- var temp = array[i + 1];
- array[i + 1] = array[j];
- array[j] = temp;
- break;
+ if (array[i] && array[i + 1] && array[i] === array[i + 1]) {
+ var temp = array[i + adjacentIndexes];
+ if (temp !== undefined) {
+ array[i + adjacentIndexes] = array[i + 1];
+ array[i + 1] = temp;
}
+ break;
}
}
console.log("After adjacent : ", array);
}
a photo realistic top view of empty flat beige plastic square. Single Game Texture. In-Game asset. 2d. No background. High contrast. No shadows.
a christmas tree. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas gift. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas ball. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a golden christmas tree star. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas hat. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas leaf. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas holly leaf. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas snow flake. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas snow man. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas reindeer. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas candy cane. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas green ball . plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas gingerbrean man. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas pine cone. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas present green. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas boe tie. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas socks. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas penguin. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas decorated blue present. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas scarf. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas gloves. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas blue decorated ball. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas candle. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas snow globe. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
an christmas elongated cuboid present. plastic style. No shadow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a round christmas gift.plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a round christmas gift.plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
one cute christmas elf. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
one cute christmas elf. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
one cute christmas reindeer head. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
one cute christmas reindeer head with a red nose. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
one christmas bell. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a couple of christmas bells. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas gifts bag. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas candle. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cute santa clauss. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Santa's sleigh. Side view. Plastic style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Reimagine the cute teddy bear sitting without background. Plastic style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Christmas Rocking Horse. Plastic style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
One Christmas Matryoshka Doll. Plastic style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A christmas Miniature Train. Plastic style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A christmas Toy Soldier. Plastic style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A christmas Music Box . Plastic style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cute polar bear cub. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a sled plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas gingerbread girl. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas gingerbread house. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cute christmas jack in the box. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cute christmas cookie. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas log cacke. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas donut. plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cute christmas owl. Plastic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a feeric christmas landscape at night with decorated trees Background image
a feeric christmas landscape at night with snow men and snow flakes Background image
a feeric christmas landscape at night with a snow man , candy canes ,holly leafs and snow flakes, Background image
a feeric christmas landscape at night with a snow man , candy canes ,holly leafs and snow flakes, Santa's reindeers, green, red and blue presents Background image
a feeric christmas landscape at night with a snow man , candy canes ,holly leafs and snow flakes, cute penguin, Santa's reindeers, green, red and blue presents and a lot of toys, a sled, gingerbread boy and girl, snow globes, a cute polar bear cub. a gingerbread house Background image
A Magical feeric starry christmas landscape at night with a snow man , candy canes ,holly leafs and snow flakes, cute penguin, Santa's reindeers, green, red and blue presents and a lot of toys, a sled, gingerbread boy and girl, snow globes, cute polar bears cub and a gingerbread house. Realistic. Plastic style. Background image