Update Critical Turn

This commit is contained in:
ckcz123 2018-04-17 17:50:18 +08:00
parent 8936185276
commit ece78a0c9f
5 changed files with 82 additions and 29 deletions

View File

@ -1054,10 +1054,7 @@ control.prototype.snipe = function (snipes) {
else if (damage < hero_hp) color = '#FF7F00';
else color = '#FF0000';
if (damage>=1e17) damage = (damage / 1e16).toFixed(1) + "j";
else if (damage>=1e13) damage = (damage / 1e12).toFixed(1) + "z";
else if (damage>=1e9) damage = (damage / 1e8).toFixed(1) + "e";
else if (damage>=1e5) damage = (damage / 1e4).toFixed(1) + "w";
damage = core.formatBigNumber(damage);
}
snipe.damage = damage;
@ -1288,10 +1285,7 @@ control.prototype.updateFg = function () {
else if (damage < hero_hp) color = '#FF7F00';
else color = '#FF0000';
if (damage>=1e17) damage = (damage / 1e16).toFixed(1) + "j";
else if (damage>=1e13) damage = (damage / 1e12).toFixed(1) + "z";
else if (damage>=1e9) damage = (damage / 1e8).toFixed(1) + "e";
else if (damage>=1e5) damage = (damage / 1e4).toFixed(1) + "w";
damage = core.formatBigNumber(damage);
}
core.setFillStyle('fg', '#000000');

View File

@ -873,6 +873,11 @@ core.prototype.formatDate2 = function (date) {
return core.utils.formatDate2(date);
}
////// 格式化大数 //////
core.prototype.formatBigNumber = function (x) {
return core.utils.formatBigNumber(x);
}
////// 两位数显示 //////
core.prototype.setTwoDigits = function (x) {
return core.utils.setTwoDigits(x);

View File

@ -138,20 +138,44 @@ enemys.prototype.getCritical = function (monsterId) {
// 坚固、模仿怪物没有临界!
if (this.hasSpecial(monster.special, 3) || this.hasSpecial(monster.special, 10)) return "???";
var last = this.calDamage(monster, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef);
if (monster.def + monster.hp/2 <= 10000) {
if (last == null) return '???';
var last = this.calDamage(monster, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef);
if (last <= 0) return 0;
if (last == null) return '???';
if (last <= 0) return 0;
for (var i = core.status.hero.atk + 1; i <= monster.hp + monster.def; i++) {
var damage = this.calDamage(monster, core.status.hero.hp, i, core.status.hero.def, core.status.hero.mdef);
if (damage == null) return '???';
if (damage < last)
return core.formatBigNumber(i - core.status.hero.atk);
last = damage;
}
return 0;
for (var i = core.status.hero.atk + 1; i <= monster.hp + monster.def; i++) {
var damage = this.calDamage(monster, core.status.hero.hp, i, core.status.hero.def, core.status.hero.mdef);
if (damage == null) return '???';
if (damage < last)
return i - core.status.hero.atk;
last = damage;
}
return 0;
else {
var info = this.getDamageInfo(monster, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef);
if (info == null) return '???';
if (info.damage <= 0) return 0;
var mon_hp = info.mon_hp, hero_atk = core.status.hero.atk, mon_def = monster.def, turn = info.turn;
// turn 是怪物攻击次数
if (turn<=0) return '???';
var nextTurn = turn - 1; // 怪物攻击次数少1
// 每回合最小伤害 = ⎡怪物生命/勇士攻击次数⎤
var nextAtk = parseInt((mon_hp - 1)/(nextTurn+1)) + 1 + mon_def;
if (nextAtk <= hero_atk) return '???';
return core.formatBigNumber(nextAtk - hero_atk);
}
}
////// 临界减伤计算 //////
@ -161,9 +185,9 @@ enemys.prototype.getCriticalDamage = function (monsterId) {
if (c <= 0) return 0;
var monster = core.material.enemys[monsterId];
var last = this.calDamage(monster, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef);
if (last == null) return '???';
return last - this.calDamage(monster, core.status.hero.hp, core.status.hero.atk + c, core.status.hero.def, core.status.hero.mdef);
var now = this.calDamage(monster, core.status.hero.hp, core.status.hero.atk+c, core.status.hero.def, core.status.hero.mdef);
if (last == null || now==null) return '???';
return core.formatBigNumber(last - now);
}
////// 1防减伤计算 //////
@ -172,11 +196,11 @@ enemys.prototype.getDefDamage = function (monsterId) {
var nowDamage = this.calDamage(monster, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef);
var nextDamage = this.calDamage(monster, core.status.hero.hp, core.status.hero.atk, core.status.hero.def + 1, core.status.hero.mdef);
if (nowDamage == null || nextDamage ==null) return "???";
return nowDamage - nextDamage;
return core.formatBigNumber(nowDamage - nextDamage);
}
////// 具体的伤害计算公式 //////
enemys.prototype.calDamage = function (monster, hero_hp, hero_atk, hero_def, hero_mdef) {
////// 获得战斗伤害信息 //////
enemys.prototype.getDamageInfo = function(monster, hero_hp, hero_atk, hero_def, hero_mdef) {
var mon_hp = monster.hp, mon_atk = monster.atk, mon_def = monster.def, mon_special = monster.special;
hero_hp=Math.max(0, hero_hp);
@ -245,7 +269,28 @@ enemys.prototype.calDamage = function (monster, hero_hp, hero_atk, hero_def, her
if (!core.flags.enableNegativeDamage)
ans=Math.max(0, ans);
return ans;
return {
"hero_atk": hero_atk,
"hero_def": hero_def,
"hero_mdef": hero_mdef,
"mon_hp": mon_hp,
"mon_atk": mon_atk,
"mod_def": mon_def,
"mon_mdef": mon_mdef,
"per_damage": per_damage,
"initDamage": initDamage,
"turn": turn,
"damage": ans
};
}
////// 具体的伤害计算公式 //////
enemys.prototype.calDamage = function (monster, hero_hp, hero_atk, hero_def, hero_mdef) {
var info = this.getDamageInfo(monster, hero_hp, hero_atk, hero_def, hero_mdef);
if (info == null) return null;
return info.damage;
}
////// 获得当前楼层的怪物列表 //////

View File

@ -1302,10 +1302,7 @@ ui.prototype.drawBook = function (index) {
if (damage >= core.status.hero.hp) color = '#FF0000';
if (damage<=0) color = '#00FF00';
if (damage>=1e17) damage = (damage / 1e16).toFixed(2) + "j";
else if (damage>=1e13) damage = (damage / 1e12).toFixed(2) + "z";
else if (damage>=1e9) damage = (damage / 1e8).toFixed(2) + "e";
else if (damage>=1e5) damage = (damage / 1e4).toFixed(2) + "w";
damage = core.formatBigNumber(damage);
}
core.fillText('ui', damage, damageOffset, 62 * i + 50, color, 'bold 13px Verdana');

View File

@ -145,6 +145,18 @@ utils.prototype.setTwoDigits = function (x) {
return parseInt(x)<10?"0"+x:x;
}
utils.prototype.formatBigNumber = function (x) {
x = parseInt(x);
if (!core.isset(x)) return x;
if (x>=1e17) return (x / 1e16).toFixed(1) + "j";
else if (x>=1e13) return (x / 1e12).toFixed(1) + "z";
else if (x>=1e9) return (x / 1e8).toFixed(1) + "e";
else if (x>=1e5) return (x / 1e4).toFixed(1) + "w";
return x;
}
////// 数组转RGB //////
utils.prototype.arrayToRGB = function (color) {
var nowR = parseInt(color[0])||0, nowG = parseInt(color[1])||0, nowB = parseInt(color[2])||0;