pacman-contribution-graph 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pacman-contribution-graph.js +19 -12
- package/dist/pacman-contribution-graph.js.map +1 -1
- package/dist/pacman-contribution-graph.min.js +1 -1
- package/github-action/dist/index.js +2 -2
- package/github-action/package.json +1 -1
- package/github-action/pnpm-lock.yaml +5 -5
- package/index.html +1 -1
- package/package.json +1 -1
- package/pacman.abozanona.me/index.js +47 -0
- package/pacman.abozanona.me/package.json +8 -0
- package/src/movement/ghosts-movement.ts +4 -8
- package/src/movement/pacman-movement.ts +20 -13
- package/src/types.ts +7 -1
- package/embeded/svg.html +0 -18
|
@@ -756,10 +756,6 @@ const moveScaredGhost = (ghost, store) => {
|
|
|
756
756
|
const dy = ghost.target.y - ghost.y;
|
|
757
757
|
// Filter moves that generally go toward the target
|
|
758
758
|
let possibleMoves = validMoves.filter((move) => {
|
|
759
|
-
// If random < 0.3, allow any valid move for more erratic movement
|
|
760
|
-
if (Math.random() < 0.3)
|
|
761
|
-
return true;
|
|
762
|
-
// Otherwise prefer moves that go toward target
|
|
763
759
|
const moveX = move[0];
|
|
764
760
|
const moveY = move[1];
|
|
765
761
|
return (dx > 0 && moveX > 0) || (dx < 0 && moveX < 0) || (dy > 0 && moveY > 0) || (dy < 0 && moveY < 0);
|
|
@@ -967,15 +963,28 @@ const movePacman = (store) => {
|
|
|
967
963
|
}
|
|
968
964
|
const hasPowerup = !!store.pacman.powerupRemainingDuration;
|
|
969
965
|
const scaredGhosts = store.ghosts.filter((ghost) => ghost.scared);
|
|
970
|
-
let targetPosition
|
|
966
|
+
let targetPosition;
|
|
971
967
|
if (hasPowerup && scaredGhosts.length > 0) {
|
|
972
|
-
|
|
968
|
+
const ghostPosition = findClosestScaredGhost(store);
|
|
969
|
+
if (ghostPosition) {
|
|
970
|
+
targetPosition = ghostPosition;
|
|
971
|
+
}
|
|
972
|
+
else {
|
|
973
|
+
targetPosition = findOptimalTarget(store);
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
else if (store.pacman.target) {
|
|
977
|
+
if (store.pacman.target.x == store.pacman.x && store.pacman.target.y == store.pacman.y) {
|
|
978
|
+
targetPosition = findOptimalTarget(store);
|
|
979
|
+
store.pacman.target = { x: targetPosition === null || targetPosition === void 0 ? void 0 : targetPosition.x, y: targetPosition === null || targetPosition === void 0 ? void 0 : targetPosition.y };
|
|
980
|
+
}
|
|
981
|
+
else {
|
|
982
|
+
targetPosition = store.pacman.target;
|
|
983
|
+
}
|
|
973
984
|
}
|
|
974
985
|
else {
|
|
975
986
|
targetPosition = findOptimalTarget(store);
|
|
976
|
-
|
|
977
|
-
if (!targetPosition) {
|
|
978
|
-
return;
|
|
987
|
+
store.pacman.target = { x: targetPosition === null || targetPosition === void 0 ? void 0 : targetPosition.x, y: targetPosition === null || targetPosition === void 0 ? void 0 : targetPosition.y };
|
|
979
988
|
}
|
|
980
989
|
const nextPosition = calculateOptimalPath(store, targetPosition);
|
|
981
990
|
if (nextPosition) {
|
|
@@ -1006,8 +1015,6 @@ const findOptimalTarget = (store) => {
|
|
|
1006
1015
|
}
|
|
1007
1016
|
}
|
|
1008
1017
|
}
|
|
1009
|
-
if (pointCells.length === 0)
|
|
1010
|
-
return null;
|
|
1011
1018
|
pointCells.sort((a, b) => b.value - a.value);
|
|
1012
1019
|
return pointCells[0];
|
|
1013
1020
|
};
|
|
@@ -1127,7 +1134,7 @@ const checkAndEatPoint = (store) => {
|
|
|
1127
1134
|
store.pacman.points++;
|
|
1128
1135
|
store.config.pointsIncreasedCallback(store.pacman.totalPoints);
|
|
1129
1136
|
store.grid[store.pacman.x][store.pacman.y].intensity = 0;
|
|
1130
|
-
if (store.pacman.points >=
|
|
1137
|
+
if (store.pacman.points >= 10)
|
|
1131
1138
|
activatePowerUp(store);
|
|
1132
1139
|
}
|
|
1133
1140
|
};
|