pacman-contribution-graph 1.0.12 → 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.
@@ -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 = null;
966
+ let targetPosition;
971
967
  if (hasPowerup && scaredGhosts.length > 0) {
972
- targetPosition = findClosestScaredGhost(store);
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 >= 30)
1137
+ if (store.pacman.points >= 10)
1131
1138
  activatePowerUp(store);
1132
1139
  }
1133
1140
  };
@@ -1570,7 +1577,7 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
1570
1577
 
1571
1578
  const getGitlabContribution = (store) => __awaiter(void 0, void 0, void 0, function* () {
1572
1579
  // const response = await fetch(`https://gitlab.com/users/${username}/calendar.json`);
1573
- const response = yield fetch(`https://v0-new-project-q1hhrdodoye-abozanona-gmailcoms-projects.vercel.app/api/contributions?username=${store.config.username}`, { cache: 'no-store' });
1580
+ const response = yield fetch(`https://v0-new-project-q1hhrdodoye-abozanona-gmailcoms-projects.vercel.app/api/contributions?username=${store.config.username}`);
1574
1581
  const contributionsList = yield response.json();
1575
1582
  return Object.entries(contributionsList).map(([date, count]) => ({
1576
1583
  date: new Date(date),
@@ -1589,10 +1596,8 @@ const getGithubContribution = (store) => __awaiter(void 0, void 0, void 0, funct
1589
1596
  if ((_a = store.config.githubSettings) === null || _a === void 0 ? void 0 : _a.accessToken) {
1590
1597
  headers['Authorization'] = 'Bearer ' + store.config.githubSettings.accessToken;
1591
1598
  }
1592
- headers['Cache-Control'] = 'no-cache';
1593
1599
  const response = yield fetch(`https://api.github.com/search/commits?q=author:${store.config.username}&sort=author-date&order=desc&page=${page}&per_page=1000`, {
1594
- headers,
1595
- cache: 'no-store'
1600
+ headers
1596
1601
  });
1597
1602
  const contributionsList = yield response.json();
1598
1603
  isComplete = contributionsList.items.length === 0;
@@ -1728,7 +1733,7 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
1728
1733
 
1729
1734
  class PacmanRenderer {
1730
1735
  constructor(conf) {
1731
- this.store = Object.assign({}, _store__WEBPACK_IMPORTED_MODULE_2__.Store);
1736
+ this.store = structuredClone(_store__WEBPACK_IMPORTED_MODULE_2__.Store);
1732
1737
  this.conf = Object.assign({}, conf);
1733
1738
  _grid__WEBPACK_IMPORTED_MODULE_1__.Grid.buildWalls();
1734
1739
  }