录像失败 & 未破防临界 & replaceText栈
This commit is contained in:
parent
94939e72a9
commit
3975a0a09d
@ -235,6 +235,14 @@ editor_blockly = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (one.type == 'wait') {
|
||||||
|
var list = one.data;
|
||||||
|
if (list instanceof Array) {
|
||||||
|
for (var j = 0; j < list.length; j++) {
|
||||||
|
if (this.checkAsync(list[j].action)) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (one.type == 'previewUI' && this.checkAsync(one.action)) return true;
|
if (one.type == 'previewUI' && this.checkAsync(one.action)) return true;
|
||||||
if (one.async && one.type != 'animate' && one.type != 'function') hasAsync = true;
|
if (one.async && one.type != 'animate' && one.type != 'function') hasAsync = true;
|
||||||
if (one.type == 'waitAsync') hasAsync = false;
|
if (one.type == 'waitAsync') hasAsync = false;
|
||||||
|
|||||||
@ -1637,7 +1637,7 @@ control.prototype._replay_save = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
control.prototype._replay_error = function (action) {
|
control.prototype._replay_error = function (action, callback) {
|
||||||
core.ui.closePanel();
|
core.ui.closePanel();
|
||||||
core.status.replay.replaying = false;
|
core.status.replay.replaying = false;
|
||||||
var len = core.status.replay.toReplay.length;
|
var len = core.status.replay.toReplay.length;
|
||||||
@ -1655,12 +1655,14 @@ control.prototype._replay_error = function (action) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.playSound('操作失败');
|
core.playSound('操作失败');
|
||||||
core.drawTip("无法回到上一个节点");
|
|
||||||
core.stopReplay(true);
|
core.stopReplay(true);
|
||||||
|
core.drawTip("无法回到上一个节点");
|
||||||
|
if (callback) callback();
|
||||||
}
|
}
|
||||||
}, function () {
|
}, function () {
|
||||||
core.ui.closePanel();
|
core.ui.closePanel();
|
||||||
core.stopReplay(true);
|
core.stopReplay(true);
|
||||||
|
if (callback) callback();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -224,19 +224,22 @@ enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) {
|
|||||||
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
||||||
number = number || 1;
|
number = number || 1;
|
||||||
|
|
||||||
if (this.hasSpecial(enemy.special, 10)) return []; // 模仿怪物临界
|
var specialCriticals = this._nextCriticals_special(enemy, number, x, y, floorId);
|
||||||
|
if (specialCriticals != null) return specialCriticals;
|
||||||
var info = this.getDamageInfo(enemy, null, x, y, floorId);
|
var info = this.getDamageInfo(enemy, null, x, y, floorId);
|
||||||
if (info == null || this.hasSpecial(enemy.special, 3)) { // 未破防,或是坚固怪
|
if (info == null) { // 如果未破防...
|
||||||
info = this.getEnemyInfo(enemy, null, x, y, floorId);
|
var enemyInfo = this.getEnemyInfo(enemy, null, x, y, floorId);
|
||||||
if (core.status.hero.atk <= info.def) {
|
if (enemyInfo.def == null || enemyInfo.def < core.status.hero.atk) return [];
|
||||||
return [[info.def + 1 - core.status.hero.atk, '?']];
|
// 再次尝试获得破防后伤害
|
||||||
}
|
info = this.getDamageInfo(enemy, {atk: enemyInfo.def + 1}, x, y, floorId);
|
||||||
return [];
|
if (info == null || info.mon_def != enemyInfo.def) return [];
|
||||||
|
info.__over__ = true;
|
||||||
|
info.__overAtk__ = info.mon_def + 1 - core.status.hero.atk;
|
||||||
}
|
}
|
||||||
|
|
||||||
// getDamageInfo直接返回数字;0伤且无负伤
|
if (typeof info == 'number') return [[0,0]];
|
||||||
if (typeof info == 'number' || (info.damage <= 0 && !core.flags.enableNegativeDamage)) {
|
if (info.damage <= 0 && !core.flags.enableNegativeDamage) {
|
||||||
return [[0, 0]];
|
return [[info.__overAtk__ || 0, 0]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (core.flags.useLoop) {
|
if (core.flags.useLoop) {
|
||||||
@ -253,10 +256,21 @@ enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enemys.prototype._nextCriticals_special = function (enemy, number, x, y, floorId) {
|
||||||
|
if (this.hasSpecial(enemy.special, 10) || this.hasSpecial(enemy.special, 3))
|
||||||
|
return []; // 模仿or坚固临界
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
enemys.prototype._nextCriticals_useLoop = function (enemy, info, number, x, y, floorId) {
|
enemys.prototype._nextCriticals_useLoop = function (enemy, info, number, x, y, floorId) {
|
||||||
var mon_hp = info.mon_hp, hero_atk = core.status.hero.atk, mon_def = info.mon_def, pre = info.damage;
|
var mon_hp = info.mon_hp, hero_atk = core.status.hero.atk, mon_def = info.mon_def, pre = info.damage;
|
||||||
var list = [];
|
var list = [];
|
||||||
for (var atk = hero_atk + 1; atk <= mon_hp + mon_def; atk++) {
|
var start_atk = hero_atk;
|
||||||
|
if (info.__over__) {
|
||||||
|
start_atk = mon_def + 1;
|
||||||
|
list.push([info.__overAtk__, -info.damage]);
|
||||||
|
}
|
||||||
|
for (var atk = start_atk + 1; atk <= mon_hp + mon_def; atk++) {
|
||||||
var nextInfo = this.getDamageInfo(enemy, {"atk": atk}, x, y, floorId);
|
var nextInfo = this.getDamageInfo(enemy, {"atk": atk}, x, y, floorId);
|
||||||
if (nextInfo == null || (typeof nextInfo == 'number')) break;
|
if (nextInfo == null || (typeof nextInfo == 'number')) break;
|
||||||
if (pre > nextInfo.damage) {
|
if (pre > nextInfo.damage) {
|
||||||
@ -273,6 +287,11 @@ enemys.prototype._nextCriticals_useLoop = function (enemy, info, number, x, y, f
|
|||||||
enemys.prototype._nextCriticals_useBinarySearch = function (enemy, info, number, x, y, floorId) {
|
enemys.prototype._nextCriticals_useBinarySearch = function (enemy, info, number, x, y, floorId) {
|
||||||
var mon_hp = info.mon_hp, hero_atk = core.status.hero.atk, mon_def = info.mon_def, pre = info.damage;
|
var mon_hp = info.mon_hp, hero_atk = core.status.hero.atk, mon_def = info.mon_def, pre = info.damage;
|
||||||
var list = [];
|
var list = [];
|
||||||
|
var start_atk = hero_atk;
|
||||||
|
if (info.__over__) {
|
||||||
|
start_atk = mon_def + 1;
|
||||||
|
list.push([info.__overAtk__, -info.damage]);
|
||||||
|
}
|
||||||
var calNext = function (currAtk, maxAtk) {
|
var calNext = function (currAtk, maxAtk) {
|
||||||
var start = Math.floor(currAtk), end = Math.floor(maxAtk);
|
var start = Math.floor(currAtk), end = Math.floor(maxAtk);
|
||||||
if (start > end) return null;
|
if (start > end) return null;
|
||||||
@ -288,7 +307,7 @@ enemys.prototype._nextCriticals_useBinarySearch = function (enemy, info, number,
|
|||||||
var nextInfo = core.enemys.getDamageInfo(enemy, {"atk": start}, x, y, floorId);
|
var nextInfo = core.enemys.getDamageInfo(enemy, {"atk": start}, x, y, floorId);
|
||||||
return nextInfo == null || (typeof nextInfo == 'number') || nextInfo.damage >= pre ? null : [start, nextInfo.damage];
|
return nextInfo == null || (typeof nextInfo == 'number') || nextInfo.damage >= pre ? null : [start, nextInfo.damage];
|
||||||
}
|
}
|
||||||
var currAtk = hero_atk;
|
var currAtk = start_atk;
|
||||||
while (true) {
|
while (true) {
|
||||||
var next = calNext(currAtk + 1, mon_hp + mon_def, pre);
|
var next = calNext(currAtk + 1, mon_hp + mon_def, pre);
|
||||||
if (next == null) break;
|
if (next == null) break;
|
||||||
@ -310,11 +329,16 @@ enemys.prototype._nextCriticals_useTurn = function (enemy, info, number, x, y, f
|
|||||||
return this._nextCriticals_useBinarySearch(enemy, info, number, x, y, floorId);
|
return this._nextCriticals_useBinarySearch(enemy, info, number, x, y, floorId);
|
||||||
}
|
}
|
||||||
var list = [], pre = null;
|
var list = [], pre = null;
|
||||||
|
var start_atk = hero_atk;
|
||||||
|
if (info.__over__) {
|
||||||
|
start_atk = mon_def + 1;
|
||||||
|
list.push([info.__overAtk__, -info.damage]);
|
||||||
|
}
|
||||||
for (var t = turn - 1; t >= 1; t--) {
|
for (var t = turn - 1; t >= 1; t--) {
|
||||||
var nextAtk = Math.ceil(mon_hp / t) + mon_def;
|
var nextAtk = Math.ceil(mon_hp / t) + mon_def;
|
||||||
// 装备提升比例的计算临界
|
// 装备提升比例的计算临界
|
||||||
nextAtk = Math.ceil(nextAtk / core.getBuff('atk'));
|
nextAtk = Math.ceil(nextAtk / core.getBuff('atk'));
|
||||||
if (nextAtk <= hero_atk) break;
|
if (nextAtk <= start_atk) break;
|
||||||
if (nextAtk != pre) {
|
if (nextAtk != pre) {
|
||||||
var nextInfo = this.getDamageInfo(enemy, {"atk": nextAtk}, x, y, floorId);
|
var nextInfo = this.getDamageInfo(enemy, {"atk": nextAtk}, x, y, floorId);
|
||||||
if (nextInfo == null || (typeof nextInfo == 'number')) break;
|
if (nextInfo == null || (typeof nextInfo == 'number')) break;
|
||||||
|
|||||||
@ -118,6 +118,7 @@ events.prototype.win = function (reason, norank, noexit) {
|
|||||||
|
|
||||||
////// 游戏失败事件 //////
|
////// 游戏失败事件 //////
|
||||||
events.prototype.lose = function (reason) {
|
events.prototype.lose = function (reason) {
|
||||||
|
if (core.isReplaying()) return core.control._replay_error(reason, function () { core.lose(reason); });
|
||||||
core.status.gameOver = true;
|
core.status.gameOver = true;
|
||||||
return this.eventdata.lose(reason);
|
return this.eventdata.lose(reason);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -96,9 +96,18 @@ utils.prototype._init = function () {
|
|||||||
////// 将文字中的${和}(表达式)进行替换 //////
|
////// 将文字中的${和}(表达式)进行替换 //////
|
||||||
utils.prototype.replaceText = function (text, prefix) {
|
utils.prototype.replaceText = function (text, prefix) {
|
||||||
if (typeof text != 'string') return text;
|
if (typeof text != 'string') return text;
|
||||||
return text.replace(/\${(.*?)}/g, function (word, value) {
|
var index = text.indexOf("${");
|
||||||
return core.calValue(value, prefix);
|
if (index < 0) return text;
|
||||||
});
|
var cnt = 0, curr = index;
|
||||||
|
while (++curr < text.length) {
|
||||||
|
if (text.charAt(curr) == '{') cnt++;
|
||||||
|
if (text.charAt(curr) == '}') cnt--;
|
||||||
|
if (cnt == 0) break;
|
||||||
|
}
|
||||||
|
if (cnt != 0) return text;
|
||||||
|
var value = core.calValue(text.substring(index+2, curr), prefix);
|
||||||
|
if (value == null) value = "";
|
||||||
|
return text.substring(0, index) + value + core.replaceText(text.substring(curr + 1), prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.prototype.replaceValue = function (value) {
|
utils.prototype.replaceValue = function (value) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user