小编Jj *_*ina的帖子

阻止用户在浏览器控制台中更改游戏值

任何玩家都可以通过浏览器控制台更改纸杯蛋糕的数量轻松欺骗这款游戏.我想知道是否有办法阻止用户这样做.这也发布在github上.

var numberOfCupcakesDisplay = document.getElementById("numberOfCupcakes");
var cupcake = document.getElementById("cupcake");

function updateValues() {
    numberOfCupcakesDisplay.innerHTML = amountOfCupcakes.toString();
    //displays number of cupcakes to screen
    document.getElementById("amountOfToasters").innerHTML = amountOfToasters.toString();
    //displays number of toasters to screen
    document.getElementById("toasterButton").innerHTML = "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp" + Math.round(costOfToasters).toString() + " cc";
    //changes cost of toaster every time it is bought by 110%
}

cupcake.addEventListener('webkitAnimationEnd', function(e){
    e.preventDefault();
    this.style.webkitAnimationName = '';
}, false);

function clickCupcake() {
    ++amountOfCupcakes;
    cupcake.style.animation = "shiftCupcake";
    cupcake.style.webkitAnimationName = "shiftCupcake";
}

updateValues();
Run Code Online (Sandbox Code Playgroud)

html javascript console console.log

3
推荐指数
1
解决办法
5315
查看次数

标签 统计

console ×1

console.log ×1

html ×1

javascript ×1