0
我正在開發js遊戲,我覺得我正在重新獲得大量的代碼。無論如何要讓代碼更加優化或使其成爲一個大功能?我希望這是足夠的代碼,如果沒有,我會讓所有的代碼jfiddle。你怎麼能幹這個代碼?
// Shop, Double coffee
$("body").on("click", "#shopUpgradeDoublepoints", function() {
if(storeDoublePoints === false && totalClicks >= storeDoublePointsCost) {
storeDoublePoints = true;
storeReleventCheckMultiplier = true;
storeCurrentActive = "storeDoublePoints";
storeBoughtItems.push("upgradeDoublePoints");
totalClicks -= storeDoublePointsCost;
storeReleventMultiplier();
$("#shopUpgradeDoublepoints").fadeOut();
$(".clicks").html(totalClicks);
console.log("Unlocked doublepoints for " + storeDoublePointsCost + " coffee. Total coffee: " + totalClicks);
}
});
// Shop, Triple coffee
$("body").on("click", "#shopUpgradeTriplepoints", function() {
if(storeTriplePoints === false && totalClicks >= storeTriplePointsCost) {
storeTriplePoints = true;
storeCurrentActive = "storeTriplePoints";
storeBoughtItems.push("upgradeTriplePoints");
totalClicks -= storeTriplePointsCost;
storeReleventMultiplier();
$(".clicks").html(totalClicks);
$("#shopUpgradeTriplepoints").fadeOut();
console.log("Unlocked triplepoints for " + storeTriplePointsCost + " coffee. Total coffee: " + totalClicks);
}
});
// Shop, Quadruple coffee
$("body").on("click", "#shopUpgradeQuadruplepoints", function(){
if(storeQuadruplePoints === false && totalClicks >= storeQuadruplePointsCost) {
storeQuadruplePoints = true;
storeCurrentActive = "storeQuadruplePoints";
storeBoughtItems.push("upgradeQuadruplePoints");
totalClicks -= storeQuadruplePointsCost;
storeReleventMultiplier();
$("#shopUpgradeQuadruplepoints").fadeOut();
$(".clicks").html(totalClicks);
console.log("Unlocked quadruplepoints for " + storeQuadruplePointsCost + " coffee. Total coffee: " + totalClicks);
}
});
如果你希望你的工作代碼審查你應該看看http://codereview.stackexchange.com/ –
只是這段代碼 – Aphryv
這個問題屬於codereview – zurfyx