Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save slashramin/f68cdb740131ee24bce582b384b2a662 to your computer and use it in GitHub Desktop.

Select an option

Save slashramin/f68cdb740131ee24bce582b384b2a662 to your computer and use it in GitHub Desktop.
Tarjomyar.ir
/**
* This script is written to automate Pac-Man game play hosted on Tarjomyar.ir and is available to play at:
* http://tarjomyar.ir/games/Pac-Man/play.html
* How to use:
* 1) Let the game load completely,
* 2) Copy and paste the following scripts into `Console` of `DevTools` of your browser and,
* 3) Call `walkOnMap();` on each map.
* NOTE: Do NOT cheat on games please ... ツ
*/
// Prevent dying facing ghosts. It's not really needed! Avoid using this since it'll cause source change and stop recording score.
// NOTE: in case of webpack rebuild, the following will not work. If so, search for `checkItemCollision` in source and comment out specified block.
/*
application.game.level.entities.pacman.checkItemCollision = function(_0x1b6d0d) {
var _0x59ef78 = this['level']();
var _0x5a2a43 = _0x1b6d0d[_0x4770('0x8f5')]['x'];
var _0x4c542a = _0x1b6d0d[_0x4770('0x8f5')]['y'];
if (_0x1b6d0d[_0x4770('0x32')] == TileTypes['DOT']) {
var _0x2ca376 = _0x59ef78[_0x4770('0x88a')][_0x4770('0x89a')] % 0x2;
SoundManager[_0x4770('0x947')](_0x4770('0x962') + _0x2ca376, 0.5);
_0x1b6d0d[_0x4770('0x8b9')](TileTypes['EMPTY'], _0x59ef78[_0x4770('0x87c')]);
this['addScore'](0x1);
this['eatDot']();
} else {
var _0x40c59f = _0x59ef78[_0x4770('0x87a')][_0x4770('0x963')](_0x5a2a43, _0x4c542a);
if (_0x40c59f) {
if (instanceOf(_0x40c59f, PowerPill)) {
_0x59ef78[_0x4770('0x88a')][_0x4770('0x964')] = 0x0;
this[_0x4770('0x965')]();
} else if (instanceOf(_0x40c59f, Bonus)) {
this[_0x4770('0x966')](_0x40c59f[_0x4770('0x87f')], !![], _0x40c59f['x'], _0x40c59f['y'], 0x7d0);
}
_0x40c59f['onCollect']();
}
}
var _0x50446c = _0x59ef78[_0x4770('0x87a')][_0x4770('0x967')](this['x'], this['y']);
if (_0x50446c != null) {
var _0x224956 = _0x50446c[_0x4770('0x895')]['name'];
if (_0x224956 == GhostState[_0x4770('0x893')]) {
SoundManager[_0x4770('0x947')](_0x4770('0x823'));
var _0x8a5047 = _0x59ef78['levelData'][_0x4770('0x964')] = Math[_0x4770('0x251')](0x14, _0x59ef78[_0x4770('0x88a')][_0x4770('0x964')] * 0x2);
this[_0x4770('0x966')](_0x8a5047, !![], this['x'], this['y']);
this[_0x4770('0x7ec')](![]);
_0x50446c['changeBehavior'](GhostState[_0x4770('0x822')]);
_0x50446c[_0x4770('0x7ec')](![]);
_0x59ef78[_0x4770('0x87a')]['pause'](0x2bc);
_0x59ef78['levelData'][_0x4770('0x899')]['ghostsEaten']++;
setTimeout(this[_0x4770('0x968')][_0x4770('0x152')](this, _0x50446c), 0x2bc);
} else if (_0x224956 != GhostState[_0x4770('0x822')]) {
/* SoundManager[_0x4770('0x969')]();
_0x59ef78[_0x4770('0x87a')][_0x4770('0x330')]();
_0x59ef78[_0x4770('0x88a')][_0x4770('0x899')][_0x4770('0x8bd')]++;
this[_0x4770('0x90d')](0x0, 0x0);
setTimeout(this[_0x4770('0x96a')][_0x4770('0x152')](this), 0x3e8); */
}
}
}
*/
// Helper func
function timer(v) {
return new Promise(function(r) {
return setTimeout(r, v);
});
}
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
// Do the trick
async function walkOnMap() {
let walkable = application.game.level.tiles.walkable;
// application.game.level.entities.pacman.speed = 4
console.log('walking on map ... ');
for (var i = 0; i < walkable.length; i++) {
let col = walkable[i];
if (col.type === TileTypes.DOT || col.type === TileTypes.PILL) {
application.game.level.entities.pacman.setState(col)
} else {
console.log(col)
}
await timer(getRandomInt(25, 35));
}
application.game.level.entities.pacman.setState(application.game.level.levelData.start)
application.game.level.entities.pacman.setState(application.game.level.levelData.start)
console.log('Done! Now go to one of the exit points and run `walkOnMap()` again!');
}
// 😈 Call the main script on each level
walkOnMap();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment