Skip to content

Instantly share code, notes, and snippets.

@viko16
Last active May 4, 2018 01:59
Show Gist options
  • Save viko16/427b4754e8282a068187 to your computer and use it in GitHub Desktop.
Save viko16/427b4754e8282a068187 to your computer and use it in GitHub Desktop.
招行信用卡打坦克小游戏刷分 #javascript
// 坤坤写的自动版
if (!Object.prototype.watch) {
Object.defineProperty(Object.prototype, "watch", {
enumerable: false,
configurable: true,
writable: false,
value: function (prop, handler) {
var oldval = this[prop],
newval = oldval,
getter = function () {
return newval;
},
setter = function (val) {
oldval = newval;
return newval = handler.call(this, prop, oldval, val);
};
if (delete this[prop]) {
Object.defineProperty(this, prop, {
get: getter,
set: setter,
enumerable: true,
configurable: true
});
}
}
});
}
TankGame.gameInfo.watch('number', function (id, oldval, newval) {
return Math.floor(Math.random() * 6 + 20);
});
TankGame.Play.prototype.gameOver = function () {
for (var t = Date.now(); Date.now() - t <= 1000 * (Math.random() * 10 + 20););
this.gameStatus = TankGame.STATUS.OVER;
TankGame.gameInfo.gameOver(ig.system.clock.last);
var a = hex_md5(TankGame.gameInfo.number + "cmbchina" + TankGame.gameInfo.serinalNo + "CMBCHINA");
TankGame.ajax({
type: "post",
url: "/IMSPActivities/pointgames/increasePoints",
data: TankGame.params.getUrlParams({
score: TankGame.gameInfo.number,
serinalno: TankGame.gameInfo.serinalNo,
sign: a
}),
success: function (c) {
totalnum = TankGame.gameInfo.number;
if (c.returnCode == "0000") {
console.log('刷了' + totalnum + '分 ' + (new Date().toLocaleString()));
TankGame.gameInfo.setPercent(c.percentage.replace("%", "I"));
TankGame.gameInfo.setTotal(c.totalScore);
TankGame.gameInfo.addScore(TankGame.gameInfo.number);
var b = ig.game.getEntitiesByType(GameTopbar)[0];
b.updateScore();
ig.game.spawnEntity(Resultpanel, (ig.system.width - 537) / 2, (ig.system.height - 338) / 2);
ig.game.sortEntitiesDeferred();
setTimeout(TankGame.payScoreToPlay, 1000 * (Math.random() * 10 + 40));
} else {
if (c.returnCode == "1206") {
TankGame.isGameTime = false;
ig.system.setGame(TankGame.Start)
} else {
if (c.returnCode == "3004") {
TankGame.alert("亲,您的积分未成功获得,请重新游戏哦!")
} else {
TankGame.dealReturnCode(c)
}
}
}
}
})
}
// 别太狠了
var score = 20;
// object.watch polyfill in ES5
if (!Object.prototype.watch) {
Object.defineProperty(Object.prototype, "watch", {
enumerable: false,
configurable: true,
writable: false,
value: function (prop, handler) {
var oldval = this[prop],
newval = oldval,
getter = function () {
return newval;
},
setter = function (val) {
oldval = newval;
return newval = handler.call(this, prop, oldval, val);
};
if (delete this[prop]) {
Object.defineProperty(this, prop, {
get: getter,
set: setter,
enumerable: true,
configurable: true
});
}
}
});
}
// 劫持积分变更
TankGame.gameInfo.watch('number', function (id, oldval, newval) {
console.info('监测到变量更改' + newval);
return score;
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment