// JavaScript Document function checkData(val, name) { if (!val || isNaN(val) || val < 0) { throw new Error(name + "必须为非负数"); } } var aBB = { beginLevel : -1, targetLevel : -1, zz : {gz:0, fz:0, tz:0, faz:0, sz:0, dz:0}, grow : 1, begin_point : { power:0, defend:0, physique:0, magic:0, swift:0, potential:0}, cur_point : {power:0, defend:0, physique:0, magic:0, swift:0, potential:0}, init: function(level, gz, fz, tz, faz, sz, dz, grow, power, defend, physique, magic, swift, potential) { if (isNaN(level) || level < 0 || level > 160) { throw new Error("等级必须在0到160之间"); return; } try { checkData(gz, "攻击资质"); checkData(fz, "防御资质"); checkData(tz, "体力资质"); checkData(faz,"法力资质"); checkData(sz, "速度资质"); checkData(dz, "躲闪资质"); checkData(power, "力量点数"); checkData(defend, "耐力点数"); checkData(physique, "体质点数"); checkData(magic,"法力点数"); checkData(swift, "敏捷点数"); checkData(potential, "潜能点"); checkData(grow, "成长率"); } catch(e) { throw e; return; } var total = parseInt(power) + parseInt(defend) + parseInt(physique) + parseInt(magic) + parseInt(swift) + parseInt(potential); if (total > 120 + level * 10){ throw new Error("请检查总点数是否正确"); return;} if (potential > level * 5){ throw new Error("请检查潜能点数是否正确"); return;} this.beginLevel = this.targetLevel = level; this.zz.gz = parseInt(gz); this.zz.fz = parseInt(fz); this.zz.tz = parseInt(tz); this.zz.faz = parseInt(faz); this.zz.sz = parseInt(sz); this.zz.dz = parseInt(dz); this.grow = parseFloat(grow); this.begin_point.power = parseInt(power); this.cur_point.power = parseInt(power); this.begin_point.defend = parseInt(defend); this.cur_point.defend = parseInt(defend); this.begin_point.physique = parseInt(physique); this.cur_point.physique = parseInt(physique); this.begin_point.magic = parseInt(magic); this.cur_point.magic = parseInt(magic); this.begin_point.swift = parseInt(swift); this.cur_point.swift = parseInt(swift); this.begin_point.potential = parseInt(potential); this.cur_point.potential = parseInt(potential); }, setTargetLevel:function(level) { level = parseInt(level); this.targetLevel = level; var dl = level - this.beginLevel; this.cur_point.power = this.begin_point.power + dl; this.cur_point.defend = this.begin_point.defend + dl; this.cur_point.physique = this.begin_point.physique + dl; this.cur_point.magic = this.begin_point.magic + dl; this.cur_point.swift = this.begin_point.swift + dl; this.cur_point.potential = dl * 5 + this.begin_point.potential; }, gj: function(){ //攻击=等级×攻击资质×(14+10×成长)/7500+成长率×总力量点数。 return Math.floor(this.targetLevel * this.zz.gz * (14 + 10 * this.grow) / 7500 + this.grow * this.cur_point.power); }, fy: function(){ //防御=等级×防御资质×(9.4+19/3×成长)/7500+成长率×总防御点数×4/3。 return Math.floor(this.targetLevel * this.zz.fz * (9.4 + 19 / 3 * this.grow) / 7500 + this.grow * this.cur_point.defend * 4 / 3); }, qx: function(){ //气血=等级×体力资质/1000+成长率×总体质点数×6。 return Math.floor(this.targetLevel * this.zz.tz / 1000 + this.grow * this.cur_point.physique * 6); }, mf: function(){ //法=魔力*成长+法资*等级/500 return Math.floor(this.cur_point.magic * this.grow + this.zz.faz * this.targetLevel / 500); }, sd: function(){ //速度=速度资质×总速度点数/1000。 return Math.floor(this.zz.sz * this.cur_point.swift / 1000); }, ll: function(){ //灵力=(法资/1000+成长)*等级/5+魔力*0.7+力量*0.4+体质*0.3+耐力*0.2 return Math.floor((this.zz.faz / 1000 + this.grow) * this.targetLevel / 5 + this.cur_point.magic * 0.7 + this.cur_point.power * 0.4 + this.cur_point.physique * 0.3 + this.cur_point.defend * 0.2); } }