From 93ee7f04150f1ad4913b342b093be6eaaa94d446 Mon Sep 17 00:00:00 2001 From: oc Date: Fri, 9 Mar 2018 21:11:58 +0800 Subject: [PATCH] Remove Storage --- libs/actions.js | 78 +++++++++++++++++++++++++++++++++++++++++++------ libs/enemys.js | 4 +++ libs/events.js | 2 +- libs/ui.js | 8 +++++ main.js | 6 ++-- 5 files changed, 85 insertions(+), 13 deletions(-) diff --git a/libs/actions.js b/libs/actions.js index 1a815548..aca775d9 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -128,6 +128,10 @@ actions.prototype.keyDown = function(keyCode) { this.keyDownLocalSaveSelect(keyCode); return; } + if (core.status.event.id=='storageRemove') { + this.keyDownStorageRemove(keyCode); + return; + } if (core.status.event.id=='cursor') { this.keyDownCursor(keyCode); return; @@ -255,7 +259,10 @@ actions.prototype.keyUp = function(keyCode) { this.keyUpLocalSaveSelect(keyCode); return; } - + if (core.status.event.id=='storageRemove') { + this.keyUpStorageRemove(keyCode); + return; + } if (core.status.event.id=='cursor') { this.keyUpCursor(keyCode); return; @@ -649,6 +656,10 @@ actions.prototype.onclick = function (x, y, stepPostfix) { this.clickLocalSaveSelect(x,y); return; } + if (core.status.event.id=='storageRemove') { + this.clickStorageRemove(x,y); + return; + } if (core.status.event.id == 'cursor') { this.clickCursor(x,y); @@ -1628,14 +1639,8 @@ actions.prototype.clickSyncSave = function (x,y) { })); break; case 5: - core.status.event.selection=1; - core.ui.drawConfirmBox("你确定要清空所有存档吗?", function() { - localStorage.clear(); - core.drawText("\t[操作成功]你的所有存档已被清空。"); - }, function() { - core.status.event.selection=5; - core.ui.drawSyncSave(); - }) + core.status.event.selection=0; + core.ui.drawStorageRemove(); break; case 6: core.status.event.selection=3; @@ -1793,6 +1798,61 @@ actions.prototype.keyUpLocalSaveSelect = function (keycode) { } } +////// 存档删除界面时的点击操作 ////// +actions.prototype.clickStorageRemove = function (x, y) { + if (x<5 || x>7) return; + var choices = core.status.event.ui.choices; + + var topIndex = 6 - parseInt((choices.length - 1) / 2); + + if (y>=topIndex && y=1 && x<=11) { diff --git a/libs/enemys.js b/libs/enemys.js index cf284486..7a744b53 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -170,6 +170,10 @@ enemys.prototype.getDefDamage = function (monsterId) { enemys.prototype.calDamage = 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); + hero_atk=Math.max(0, hero_atk); + hero_def=Math.max(0, hero_def); + hero_mdef=Math.max(0, hero_mdef); if (this.hasSpecial(mon_special, 20) && !core.hasItem("cross")) // 如果是无敌属性,且勇士未持有十字架 return 999999999; // 返回无限大 diff --git a/libs/events.js b/libs/events.js index 76415798..91a81d5a 100644 --- a/libs/events.js +++ b/libs/events.js @@ -224,9 +224,9 @@ events.prototype.doAction = function() { // 事件处理完毕 if (core.status.event.data.list.length==0) { + core.ui.closePanel(); if (core.isset(core.status.event.data.callback)) core.status.event.data.callback(); - core.ui.closePanel(); core.replay(); return; } diff --git a/libs/ui.js b/libs/ui.js index 47676211..b100b309 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1068,6 +1068,14 @@ ui.prototype.drawLocalSaveSelect = function () { ]); } +////// 绘制存档删除页面 ////// +ui.prototype.drawStorageRemove = function () { + core.status.event.id = 'storageRemove'; + this.drawChoices(null, [ + "清空全部塔的存档", "只清空当前塔的存档", "返回上级菜单" + ]); +} + ////// 绘制分页 ////// ui.prototype.drawPagination = function (page, totalPage) { diff --git a/main.js b/main.js index 693472b1..fee0d1aa 100644 --- a/main.js +++ b/main.js @@ -442,8 +442,9 @@ main.dom.replayGame.onclick = function () { return; } if (core.isset(obj.version) && obj.version!=core.firstData.version) { - alert("游戏版本不一致!"); - return; + // alert("游戏版本不一致!"); + if (!confirm("游戏版本不一致!\n你仍然想播放录像吗?")) + return; } if (!core.isset(obj.route) || !core.isset(obj.hard)) { alert("无效的录像!"); @@ -454,7 +455,6 @@ main.dom.replayGame.onclick = function () { core.resetStatus(core.firstData.hero, obj.hard, core.firstData.floorId, null, core.initStatus.maps); core.events.setInitData(obj.hard); core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() { - //core.setHeroMoveTriggerInterval(); core.startReplay(core.decodeRoute(obj.route)); }, true); }, function () {