看:
如何复制我的*问题:
如果您将所有奖励积分放入除 1 之外的统计数据中,然后在另一个统计数据中按 CTRL-CLICK,则奖励值将变为负数,此时*它应该停止在 0 处。
控制:
- 左键单击 = 分配 1 个点
- CTRL 左键单击 = 分配 5 个点
- 右键单击 = 收回 1 分
- CTRL 右键单击 = 收回 5 点
JavaScript:
var Alexander =
{
Magic: "MagicVal",
Attack: "AttackVal",
Bonus: "BonusVal",
Limits: {
Magic: {
max: 100,
min: 80
},
Attack: {
max: 100,
min: 80
}
}
};
function table(e)
{
e.preventDefault();
}
function add(character, stat) //Allocates "1" with left-click//
{
var txtNumber = document.getElementById(character[stat]);
var newNumber = parseInt(txtNumber.value) + 1;
if(newNumber > character.Limits[stat].max) return;
var BonusVal = document.getElementById(character.Bonus);
if(BonusVal.value <= 0) return;
var newBonus = parseInt(BonusVal.value) - 1;
BonusVal.value = newBonus;
txtNumber.value = newNumber;
}
function subtract(character, stat) //Takes back "1" with right-click//
{
var txtNumber = document.getElementById(character[stat]);
var newNumber = parseInt(txtNumber.value) - 1;
if(newNumber < character.Limits[stat].min) return;
var BonusVal = document.getElementById(character.Bonus);
var newBonus = parseInt(BonusVal.value) + 1;
BonusVal.value = newBonus;
txtNumber.value = newNumber;
}
function dump(e, character, stat) //Allocates "5" with CTRL+left-click//
{
if (e.ctrlKey == 1 && e.which == 1) {
console.log('met');
var txtNumber = document.getElementById(character[stat]);
var newNumber = parseInt(txtNumber.value) + 4;
if(newNumber > character.Limits[stat].max) return;
var BonusVal = document.getElementById(character.Bonus);
if(BonusVal.value <= 0) return;
var newBonus = parseInt(BonusVal.value) - 4;
BonusVal.value = newBonus;
txtNumber.value = newNumber;
}
}
function reclaim(e, character, stat) //Takes back "5" with CTRL+right-click//
{
if (e.ctrlKey == 1 && e.which == 3) {
console.log('met');
var txtNumber = document.getElementById(character[stat]);
var newNumber = parseInt(txtNumber.value) - 4;
if(newNumber < character.Limits[stat].min) return;
var BonusVal = document.getElementById(character.Bonus);
var newBonus = parseInt(BonusVal.value) + 4;
BonusVal.value = newBonus;
txtNumber.value = newNumber;
}
}