From 19387b29d52c58828975cc0edfd0ee917601624a Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Fri, 18 May 2018 15:35:52 +0800 Subject: [PATCH 01/18] Update Docs --- docs/personalization.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/personalization.md b/docs/personalization.md index 3791e943..0b979678 100644 --- a/docs/personalization.md +++ b/docs/personalization.md @@ -676,13 +676,13 @@ if (core.getFlag('skill', 0)==1) { // 开启了技能1 你只需要如下几步来达到多角色的效果。 -1. 每个勇士弄一张行走图。相关信息参见[自定义事件:setHeroIcon](event#setHeroIcon:更改角色行走图)。 +1. 每个角色弄一张行走图。相关信息参见[自定义事件:setHeroIcon](event#setHeroIcon:更改角色行走图)。 2. [覆盖楼传事件](#覆盖楼传事件),这样可以通过点工具栏的楼层传送按钮来切换角色。当然你也完全可以自己写一个道具,或[自定义快捷键](#自定义快捷键)来进行绑定。 3. 在脚本编辑的setInitData中初始化新角色的属性值。 ```js // 所有需要保存的内容;这些保存的内容不会多角色共用,在切换时会进行恢复。 // 你也可以自行新增或删除,比如不共用金币则可以加上"money"的初始化,不共用道具则可以加上"items"的初始化, - // 多勇士共用hp的话则删除hp,等等。 + // 多角色共用hp的话则删除hp,等等。总之,不共用的属性都在这里进行定义就好。 var initData = { "floorId": "MT0", // 该角色楼层ID "icon": "hero2.png", // 角色的行走图名称 From 467c25837ebc06bb59966425ad4429a1a8ff690c Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Fri, 18 May 2018 15:36:25 +0800 Subject: [PATCH 02/18] Update Docs --- docs/personalization.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/personalization.md b/docs/personalization.md index 0b979678..91993245 100644 --- a/docs/personalization.md +++ b/docs/personalization.md @@ -582,7 +582,7 @@ core.statusBar.mana.style.fontStyle = 'normal'; // 这一行会取消斜体。 我们可以在魔力那一行显示当前值和最大值: ``` js -core.setStatus('mana', Math.min(core.getStatus('mana'), core.getStatus('manaMax')); // 如果魔力存在上限,则不能超过其上限值 +core.setStatus('mana', Math.min(core.getStatus('mana'), core.getStatus('manaMax'))); // 如果魔力存在上限,则不能超过其上限值 core.statusBar.mana.innerHTML = core.getStatus('mana') + '/' + core.getStatus('manaMax', 0); // 显示比如 6/30 这样 ``` From 303fb53dbfcd6c17f30f939c2625ac023f1f6ecd Mon Sep 17 00:00:00 2001 From: oc Date: Sat, 19 May 2018 00:36:13 +0800 Subject: [PATCH 03/18] debug mode --- _server/blockly/MotaAction.g4 | 2 +- docs/api.md | 3 ++- docs/start.md | 4 +++- libs/actions.js | 16 ++++++++++++++-- libs/control.js | 23 +++++++++++++++++++---- libs/core.js | 1 + libs/events.js | 5 +++++ libs/ui.js | 4 ++-- project/data.js | 6 +----- 常用工具/便捷PS工具.exe | Bin 24064 -> 24064 bytes 更新说明.txt | 2 +- 11 files changed, 49 insertions(+), 17 deletions(-) diff --git a/_server/blockly/MotaAction.g4 b/_server/blockly/MotaAction.g4 index 4fc0c32f..0ec2654b 100644 --- a/_server/blockly/MotaAction.g4 +++ b/_server/blockly/MotaAction.g4 @@ -1000,7 +1000,7 @@ function_s /* function_s -tooltip : function: 自定义JS脚本\n可以双击进行多行编辑,常见可能会被用到的系统API请参见文档的附录 +tooltip : 可双击多行编辑,请勿使用异步代码。常见API参见文档附录。 helpUrl : https://ckcz123.github.io/mota-js/#/event?id=function%EF%BC%9A%E8%87%AA%E5%AE%9A%E4%B9%89js%E8%84%9A%E6%9C%AC default : ["alert(core.getStatus(\"atk\"));"] colour : this.dataColor diff --git a/docs/api.md b/docs/api.md index fbd09055..179774bf 100644 --- a/docs/api.md +++ b/docs/api.md @@ -43,7 +43,8 @@ core.material.items core.debug() -将攻防设置为10000,近似于无敌模式。 +开启调试模式。此模式下可以按Ctrl键进行穿墙,并忽略一切事件。 +此模式下不可回放录像和上传成绩。 core.updateStatusBar() diff --git a/docs/start.md b/docs/start.md index 4fe8ecc9..180d2002 100644 --- a/docs/start.md +++ b/docs/start.md @@ -30,6 +30,8 @@ * “JS代码压缩工具”能对JS代码进行压缩,从而减少IO请求数和文件大小。 * “伤害和临界值计算器”是一个很便捷的小工具,能对怪物的伤害和临界值进行计算。 +!> **整个造塔过程中,启动服务必须全程处于开启状态!切不可手滑关闭,否则做的都是无用功!** + ## 绘制地图 有两种绘制地图的方式:从头绘制地图;从RMXP中导入已有的地图。 @@ -186,7 +188,7 @@ HTML5的塔都是可以进行控制台调试的。 - `core.status.hero` 获得当前勇士状态信息。例如`core.status.hero.atk`就是当前勇士的攻击力数值。 - `core.material.enemys` 获得所有怪物信息。例如`core.material.enemys.greenSlime`就是获得绿色史莱姆的属性数据。 - `core.material.items` 获得所有道具的信息。例如`core.material.items.pickaxe`就是获得破墙镐的信息。 -- `core.debug()` 无敌模式;使用此命令将会把攻防都置为10000,方便进行乱撞。 +- `core.debug()` 开启调试模式;此模式下可以按住Ctrl键进行穿墙。 - `core.updateStatusBar()` 立刻更新状态栏和地图显伤。 - `core.setStatus('atk', 1000)` 直接设置勇士的某项属性。本句等价于 `core.status.hero.atk = 1000`。 - `core.getStatus('atk')` 返回勇士当前某项属性数值。本句等价于 `core.status.hero.atk`。 diff --git a/libs/actions.js b/libs/actions.js index f9148392..65260f5b 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -25,6 +25,7 @@ actions.prototype.onkeyDown = function (e) { core.status.holdingKeys.push(e.keyCode); this.pressKey(e.keyCode); } else { + if (e.keyCode==17) core.status.ctrlDown = true; this.keyDown(e.keyCode); } } @@ -60,6 +61,7 @@ actions.prototype.onkeyUp = function(e) { } this.keyUp(e.keyCode); } else { + if (e.keyCode==17) core.status.ctrlDown = false; this.keyUp(e.keyCode); } } @@ -337,8 +339,14 @@ actions.prototype.keyUp = function(keyCode, fromReplay) { core.ui.drawHelp(); break; case 82: // R - if (core.status.heroStop) - core.ui.drawReplay(); + if (core.status.heroStop) { + if (core.hasFlag('debug')) { + core.drawText("\t[系统提示]调试模式下无法回放录像"); + } + else { + core.ui.drawReplay(); + } + } break; case 33: case 34: // PAGEUP/PAGEDOWN if (core.status.heroStop) { @@ -1703,6 +1711,10 @@ actions.prototype.clickSyncSave = function (x,y) { }); break; case 4: + if (core.hasFlag('debug')) { + core.drawText("\t[系统提示]调试模式下无法下载录像"); + break; + } core.download(core.firstData.name+"_"+core.formatDate2(new Date())+".h5route", JSON.stringify({ 'name': core.firstData.name, 'hard': core.status.hard, diff --git a/libs/control.js b/libs/control.js index 7c15fb88..48437c91 100644 --- a/libs/control.js +++ b/libs/control.js @@ -621,6 +621,7 @@ control.prototype.moveAction = function (callback) { if (core.status.event.id!='ski') core.status.route.push(direction); core.status.automaticRoute.moveStepBeforeStop = []; + core.status.automaticRoute.lastDirection = core.getHeroLoc('direction'); if (canMove) // 非箭头:触发 core.trigger(x + scan[direction].x, y + scan[direction].y); core.drawHero(direction, x, y); @@ -676,7 +677,7 @@ control.prototype.turnHero = function() { ////// 让勇士开始移动 ////// control.prototype.moveHero = function (direction, callback) { // 如果正在移动,直接return - if (core.status.heroMoving>0) return; + if (core.status.heroMoving!=0) return; if (core.isset(direction)) core.setHeroLoc('direction', direction); if (!core.isset(callback)) { // 如果不存在回调函数,则使用heroMoveTrigger @@ -685,8 +686,18 @@ control.prototype.moveHero = function (direction, callback) { var doAction = function () { if (!core.status.heroStop) { - core.moveAction(); - setTimeout(doAction, 50); + if (core.hasFlag('debug') && core.status.ctrlDown) { + if (core.status.heroMoving!=0) return; + core.status.heroMoving=-1; + core.eventMoveHero([core.getHeroLoc('direction')], 100, function () { + core.status.heroMoving=0; + doAction(); + }); + } + else { + core.moveAction(); + setTimeout(doAction, 50); + } } else { core.stopHero(); @@ -1371,8 +1382,11 @@ control.prototype.doEffect = function (expression) { } } -////// 作弊 ////// +////// 开启debug模式 ////// control.prototype.debug = function() { + core.setFlag('debug', true); + core.insertAction(["\t[调试模式开启]此模式下按住Ctrl键可以穿墙并忽略一切事件。\n同时,录像将失效,也无法上传成绩。"]); + /* core.setStatus('hp', 999999); core.setStatus('atk', 10000); core.setStatus('def', 10000); @@ -1389,6 +1403,7 @@ control.prototype.debug = function() { core.status.hero.flyRange.push(i); core.updateStatusBar(); core.drawTip("作弊成功"); + */ } ////// 开始播放 ////// diff --git a/libs/core.js b/libs/core.js index 888725f0..8eee43fd 100644 --- a/libs/core.js +++ b/libs/core.js @@ -107,6 +107,7 @@ function core() { // 按下键的时间:为了判定双击 'downTime': null, + 'ctrlDown': false, // 路线&回放 'route': [], diff --git a/libs/events.js b/libs/events.js index a0018f7b..09da3f66 100644 --- a/libs/events.js +++ b/libs/events.js @@ -228,6 +228,11 @@ events.prototype.gameOver = function (ending, fromReplay) { core.restart(); }); } + else if (core.hasFlag('debug')) { + core.drawText("\t[系统提示]调试模式下无法上传成绩", function () { + core.restart(); + }) + } else { confirmUpload(); } diff --git a/libs/ui.js b/libs/ui.js index ef9adc03..0d42b692 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -668,8 +668,8 @@ ui.prototype.drawChoices = function(content, choices) { if (choices.length>0) { if (!core.isset(core.status.event.selection)) core.status.event.selection=0; - if (core.status.event.selection<0) core.status.event.selection=0; - if (core.status.event.selection>=choices.length) core.status.event.selection=choices.length-1; + while (core.status.event.selection<0) core.status.event.selection+=choices.length; + while (core.status.event.selection>=choices.length) core.status.event.selection-=choices.length; var len = core.canvas.ui.measureText(core.replaceText(choices[core.status.event.selection].text || choices[core.status.event.selection])).width; core.strokeRect('ui', 208-len/2-5, choice_top + 32 * core.status.event.selection - 20, len+10, 28, "#FFD700", 2); } diff --git a/project/data.js b/project/data.js index 63a4c455..15d26b0a 100644 --- a/project/data.js +++ b/project/data.js @@ -49,11 +49,7 @@ data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = }, "flyRange": [], "loc": {"direction": "up", "x": 6, "y": 10}, - "flags": { - "poison": false, - "weak": false, - "curse": false, - }, + "flags": {}, "steps": 0, }, "startText": [ diff --git a/常用工具/便捷PS工具.exe b/常用工具/便捷PS工具.exe index 78a9c25e870f6c7a44033daf916c754860371042..3f5deca032b4c7119ad12eadef31f613e8f9c436 100644 GIT binary patch delta 102 zcmV-s0Ga=Qya9l`0g#9T@Yw#bi@*c{6q8H^odFcH>IK?I5L>U|VLRxzPn_E#N1CvZ z%(K)@xCI07*#47`QyC!`R1{_gxT;EvXEf^`<~%zm0001GI$UFLa9nnCGB7bRlfqN? Iv%pk92~4CcAOHXW delta 98 zcmV-o0GIK?I5XYd>tX_GiMuMcRug(Et zcC*w?xCH}5uI`hMQyCiR6{+j{>d!`@Z4>7Ot+xOH0001GI$UFLaFfYX_mMCMv%pk9 E368ldng9R* diff --git a/更新说明.txt b/更新说明.txt index 0a123cf2..fb516de6 100644 --- a/更新说明.txt +++ b/更新说明.txt @@ -6,13 +6,13 @@ 衰弱可以减少攻防的比例 √ 地图数据统计 支持 status:x 获得当前坐标 √ +core.debug()改成调试模式,可以Ctrl穿墙 √ 最大存档个数提到main处理 √ 新建地图可以保留楼层属性 √ 地图编辑器可用PageUp和PageDown切换楼层 √ 道具描述过长时可以自动换行 √ 除Autotile外均可自动注册 √ 重写大部分教程,新增大量拓展描述 √ -便捷PS工具偶尔的闪退问题 大量细节进行优化,所有已知的bug进行了修复 √ ----------------------------------------------------------------------- From 1a1a4955cccd5e1158a2bfeff0d0d7b2e76ae698 Mon Sep 17 00:00:00 2001 From: oc Date: Sat, 19 May 2018 22:50:30 +0800 Subject: [PATCH 04/18] modify long click --- libs/actions.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/libs/actions.js b/libs/actions.js index 65260f5b..5e67dae5 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -417,7 +417,7 @@ actions.prototype.ondown = function (x ,y) { core.timeout.onDownTimeout = setTimeout(function () { if (core.interval.onDownInterval == null) { core.interval.onDownInterval = setInterval(function () { - if (!core.actions.longClick()) { + if (!core.actions.longClick(x, y, true)) { clearInterval(core.interval.onDownInterval); core.interval.onDownInterval = null; } @@ -488,10 +488,7 @@ actions.prototype.onup = function () { // 长按 if (!core.status.lockControl && stepPostfix.length==0 && core.status.downTime!=null && new Date()-core.status.downTime>=1000) { - core.waitHeroToStop(function () { - // 绘制快捷键 - core.ui.drawKeyBoard(); - }); + this.longClick(posx, posy); } else { //posx,posy是寻路的目标点,stepPostfix是后续的移动 @@ -717,15 +714,23 @@ actions.prototype.onmousewheel = function (direct) { /////////////////// 在某个界面时的按键点击效果 /////////////////// ////// 长按 ////// -actions.prototype.longClick = function () { +actions.prototype.longClick = function (x, y, fromEvent) { if (!core.isPlaying()) return false; - if (core.status.event.id=='text') { - core.drawText(); - return true; + if (core.status.lockControl) { + if (core.status.event.id=='text') { + core.drawText(); + return true; + } + if (core.status.event.id=='action' && core.status.event.data.type=='text') { + core.doAction(); + return true; + } } - if (core.status.event.id=='action' && core.status.event.data.type=='text') { - core.doAction(); - return true; + else if (!fromEvent) { + core.waitHeroToStop(function () { + // 绘制快捷键 + core.ui.drawKeyBoard(); + }); } return false; } From 609552e0139856560af7fdcf5e2b2d8f5f52e16e Mon Sep 17 00:00:00 2001 From: oc Date: Sun, 20 May 2018 19:19:29 +0800 Subject: [PATCH 05/18] fix bug --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 7cbb42fd..bf79363d 100644 --- a/main.js +++ b/main.js @@ -503,9 +503,9 @@ main.dom.replayGame.onclick = function () { core.dom.startPanel.style.display = 'none'; core.resetStatus(core.firstData.hero, obj.hard, core.firstData.floorId, null, core.initStatus.maps); - core.events.setInitData(obj.hard); core.setFlag('seed', obj.seed); core.setFlag('rand', obj.seed); + core.events.setInitData(obj.hard); core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() { core.startReplay(core.decodeRoute(obj.route)); }, true); From 98137082c445166a9b9195e7172c99004e597a50 Mon Sep 17 00:00:00 2001 From: oc Date: Tue, 22 May 2018 14:27:32 +0800 Subject: [PATCH 06/18] criticals --- docs/api.md | 24 +++++------ libs/control.js | 4 +- libs/enemys.js | 112 ++++++++++++++++++++---------------------------- libs/events.js | 18 +++++--- libs/ui.js | 6 ++- 5 files changed, 77 insertions(+), 87 deletions(-) diff --git a/docs/api.md b/docs/api.md index 179774bf..92bc289b 100644 --- a/docs/api.md +++ b/docs/api.md @@ -313,27 +313,21 @@ core.enemys.getExtraDamage(enemyId) core.enemys.nextCriticals(enemyId, number) -返回接下来number个该怪物的临界。列表每一项类似 "x:y" 表示临界值为x,该临界减伤为y。 +返回一个列表,为接下来number(可忽略,默认为1)个该怪物的临界值和临界减伤。 +列表每一项类似 [x,y] 表示临界值为x,且临界减伤为y。 +如果无临界值,则返回空列表。 -core.enemys.getCritical(enemyId) -返回怪物的下一个临界值。无临界(如坚固、魔防等)返回'???'。 +core.enemys.getDefDamage(enemyId, k) +获得k(可忽略,默认为1)防减伤值。 -core.enemys.getCriticalDamage(enemyId) -获得怪物的下一个临界减伤。 - - -core.enemys.getDefDamage(enemyId) -获得一防减伤值。 - - -core.enemys.getDamageInfo(enemyId, hero_hp, hero_atk, hero_def, hero_mdef) +core.enemys.getDamageInfo(enemy, hero_hp, hero_atk, hero_def, hero_mdef) 获得实际战斗信息,比如伤害,回合数,每回合伤害等等。 此函数是实际战斗过程的计算。 -core.enemys.calDamage(enemyId, hero_hp, hero_atk, hero_def, hero_mdef) +core.enemys.calDamage(enemy, hero_hp, hero_atk, hero_def, hero_mdef) 计算战斗伤害;实际返回的是上面getDamageInfo中伤害的数值。 @@ -372,6 +366,10 @@ core.events.canUseQuickShop(shopId) 当前能否使用某个快捷商店 +core.events.setHeroIcon(name) +设置勇士行走图 + + ========== core.items.XXX 和道具相关的函数 ========== items.js将处理和道具相关的内容,比如道具的使用,获取和删除等等。 diff --git a/libs/control.js b/libs/control.js index 48437c91..429b9af7 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1331,7 +1331,9 @@ control.prototype.updateFg = function () { // 临界显伤 if (core.flags.displayCritical) { - var critical = core.formatBigNumber(core.enemys.getCritical(id)); + var critical = core.enemys.nextCriticals(id); + if (critical.length>0) critical=critical[0]; + critical = core.formatBigNumber(critical[0]); if (critical == '???') critical = '?'; core.setFillStyle('fg', '#000000'); core.canvas.fg.fillText(critical, 32 * x + 2, 32 * (y + 1) - 2 - 10); diff --git a/libs/enemys.js b/libs/enemys.js index 1b4158ff..bdc5e7a0 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -132,92 +132,63 @@ enemys.prototype.getExtraDamage = function (monster) { return extra_damage; } -////// 接下来若干个临界值计算 ///// +////// 接下来N个临界值和临界减伤计算 ////// enemys.prototype.nextCriticals = function (monsterId, number) { - number = number||1; + var useTurn = true; // 是否使用回合法计算临界值;如果要用循环法,则直接改为false。 + number = number||1; var monster = core.material.enemys[monsterId]; // 坚固、模仿怪物没有临界! if (this.hasSpecial(monster.special, 3) || this.hasSpecial(monster.special, 10)) return []; - var info = this.getDamageInfo(monster, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef); if (info == null) { if (core.status.hero.atk<=monster.def) { - return [(monster.def+1-core.status.hero.atk)+":?"]; + return [[monster.def+1-core.status.hero.atk,'?']]; } return []; } - if (info.damage <= 0) return []; - - var mon_hp = info.mon_hp, hero_atk = core.status.hero.atk, mon_def = monster.def, turn = info.turn; - - if (turn<=1) return []; var list = [], pre = null; + var mon_hp = info.mon_hp, hero_atk = core.status.hero.atk, mon_def = monster.def, turn = info.turn; - for (var t = turn-1;t>=1;t--) { - var nextAtk = Math.ceil(mon_hp/t) + mon_def; - if (nextAtk<=hero_atk) break; - if (nextAtk!=pre) { - var nextInfo = this.getDamageInfo(monster, core.status.hero.hp, nextAtk, core.status.hero.def, core.status.hero.mdef); - if (nextInfo==null) break; - list.push((nextAtk-hero_atk)+":"+(info.damage-nextInfo.damage)); - if (nextInfo.damage<=0) break; - pre = nextAtk; + if (useTurn) { // 回合数计算法 + for (var t = turn-1;t>=1;t--) { + var nextAtk = Math.ceil(mon_hp/t) + mon_def; + if (nextAtk<=hero_atk) break; + if (nextAtk!=pre) { + var nextInfo = this.getDamageInfo(monster, core.status.hero.hp, nextAtk, core.status.hero.def, core.status.hero.mdef); + if (nextInfo==null) break; + list.push([nextAtk-hero_atk,info.damage-nextInfo.damage]); + pre = nextAtk; + } + if (list.length>=number) + break; } - if (list.length>=number) - break; } + else { // 暴力for循环法 + pre = info.damage; + for (var atk=hero_atk+1;atk<=mon_hp+mon_def;atk++) { + var nextInfo = this.getDamageInfo(monster, core.status.hero.hp, atk, core.status.hero.def, core.status.hero.mdef); + if (nextInfo==null) break; + if (pre>nextInfo.damage) { + pre = nextInfo.damage; + list.push([atk-hero_atk, info.damage-nextInfo.damage]); + if (list.length>=number) break; + } + } + } + if (list.length==0) list.push([0,0]); return list; } -////// 临界值计算 ////// -enemys.prototype.getCritical = function (monsterId) { - var monster = core.material.enemys[monsterId]; - // 坚固、模仿怪物没有临界! - if (this.hasSpecial(monster.special, 3) || this.hasSpecial(monster.special, 10)) return "???"; - - var info = this.getDamageInfo(monster, core.status.hero.hp, core.status.hero.atk, core.status.hero.def, core.status.hero.mdef); - - if (info == null) { - if (core.status.hero.atk<=monster.def) - return monster.def+1-core.status.hero.atk; - 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<=1) return 0; // 攻杀 - - // 每回合最小伤害 = ⎡怪物生命/勇士攻击次数⎤ - var nextAtk = Math.ceil(mon_hp/(turn-1)) + mon_def; - - if (nextAtk <= hero_atk) return 0; - return nextAtk - hero_atk; - -} - -////// 临界减伤计算 ////// -enemys.prototype.getCriticalDamage = function (monsterId) { - var c = this.getCritical(monsterId); - if (c == '???') return '???'; - 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); - 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 last - now; -} - -////// 1防减伤计算 ////// -enemys.prototype.getDefDamage = function (monsterId) { +////// N防减伤计算 ////// +enemys.prototype.getDefDamage = function (monsterId, k) { + k = k || 1; var monster = core.material.enemys[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); + var nextDamage = this.calDamage(monster, core.status.hero.hp, core.status.hero.atk, core.status.hero.def + k, core.status.hero.mdef); if (nowDamage == null || nextDamage ==null) return "???"; return nowDamage - nextDamage; } @@ -225,6 +196,10 @@ enemys.prototype.getDefDamage = function (monsterId) { ////// 获得战斗伤害信息 ////// enemys.prototype.getDamageInfo = function(monster, hero_hp, hero_atk, hero_def, hero_mdef) { + if (typeof monster == 'string') { + monster = core.material.enemys[monster]; + } + 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); @@ -310,6 +285,10 @@ enemys.prototype.getDamageInfo = function(monster, hero_hp, hero_atk, hero_def, ////// 具体的伤害计算公式 ////// enemys.prototype.calDamage = function (monster, hero_hp, hero_atk, hero_def, hero_mdef) { + if (typeof monster == 'string') { + monster = core.material.enemys[monsterId]; + } + var info = this.getDamageInfo(monster, hero_hp, hero_atk, hero_def, hero_mdef); if (info == null) return null; return info.damage; @@ -341,6 +320,9 @@ enemys.prototype.getCurrentEnemys = function (floorId) { if (specialText.length>=3) specialText = "多属性..."; else specialText = specialText.join(" "); + var critical = this.nextCriticals(monsterId); + if (critical.length>0) critical=critical[0]; + enemys.push({ 'id': monsterId, 'name': monster.name, @@ -352,8 +334,8 @@ enemys.prototype.getCurrentEnemys = function (floorId) { 'point': monster.point||0, // 加点 'special': specialText, 'damage': this.getDamage(monsterId), - 'critical': this.getCritical(monsterId), - 'criticalDamage': this.getCriticalDamage(monsterId), + 'critical': critical[0], + 'criticalDamage': critical[1], 'defDamage': this.getDefDamage(monsterId) }); diff --git a/libs/events.js b/libs/events.js index 09da3f66..b8f2f1b4 100644 --- a/libs/events.js +++ b/libs/events.js @@ -643,13 +643,7 @@ events.prototype.doAction = function() { break; case "setHeroIcon": { - var name = "hero.png"; - if (core.isset(core.material.images.images[data.name]) && core.material.images.images[data.name].width==128) - name = data.name; - core.setFlag("heroIcon", name); - core.material.images.hero.src = core.material.images.images[name].src; - core.material.icons.hero.height = core.material.images.images[name].height/4; - core.drawHero(); + this.setHeroIcon(data.name); this.doAction(); break; } @@ -1256,6 +1250,16 @@ events.prototype.canUseQuickShop = function(shopId) { return null; } +////// 设置角色行走图 ////// +events.prototype.setHeroIcon = function (name) { + if (core.isset(core.material.images.images[name]) && core.material.images.images[name].width==128) { + core.setFlag("heroIcon", name); + core.material.images.hero.src = core.material.images.images[name].src; + core.material.icons.hero.height = core.material.images.images[name].height/4; + core.drawHero(); + } +} + ////// 检查升级事件 ////// events.prototype.checkLvUp = function () { if (!core.flags.enableLevelUp || core.status.hero.lv>=core.firstData.levelUp.length) return; diff --git a/libs/ui.js b/libs/ui.js index 0d42b692..1520a02c 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1341,7 +1341,11 @@ ui.prototype.drawBookDetail = function (index) { hints.push("该怪物无特殊属性。"); hints.push(""); - hints.push("临界表:"+JSON.stringify(core.enemys.nextCriticals(enemyId,10))) + var criticals = core.enemys.nextCriticals(enemyId, 10).map(function (v) { + return v[0]+":"+v[1]; + }); + while (criticals[0]=='0:0') criticals.shift(); + hints.push("临界表:"+JSON.stringify(criticals)) var content=hints.join("\n"); From ba0f1af203650767614cf551fe95d97cc33aea76 Mon Sep 17 00:00:00 2001 From: oc Date: Tue, 22 May 2018 14:35:45 +0800 Subject: [PATCH 07/18] Fix Bug --- libs/events.js | 2 +- project/functions.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/events.js b/libs/events.js index b8f2f1b4..0835161a 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1351,7 +1351,7 @@ events.prototype.passNet = function (data) { if (data.event.id=='weakNet') { // 衰网 if (core.hasFlag('weak')) return; core.setFlag('weak', true); - var weakValue = core.status.weakValue; + var weakValue = core.values.weakValue; var weakAtk = weakValue>=1?weakValue:Math.floor(weakValue*core.status.hero.atk); var weakDef = weakValue>=1?weakValue:Math.floor(weakValue*core.status.hero.def); core.setFlag('weakAtk', weakAtk); diff --git a/project/functions.js b/project/functions.js index 0c7862d1..e6a5a7ba 100644 --- a/project/functions.js +++ b/project/functions.js @@ -155,7 +155,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 衰弱 if (core.enemys.hasSpecial(special, 13) && !core.hasFlag('weak')) { core.setFlag('weak', true); - var weakValue = core.status.weakValue; + var weakValue = core.values.weakValue; var weakAtk = weakValue>=1?weakValue:Math.floor(weakValue*core.status.hero.atk); var weakDef = weakValue>=1?weakValue:Math.floor(weakValue*core.status.hero.def); core.setFlag('weakAtk', weakAtk); From 0c61b1aa45079eeaf0600f614eb7ac099c7e0ec7 Mon Sep 17 00:00:00 2001 From: oc Date: Tue, 22 May 2018 18:48:04 +0800 Subject: [PATCH 08/18] statistics --- _server/data.comment.js | 6 ++ docs/event.md | 2 +- index.html | 2 +- libs/actions.js | 3 + libs/control.js | 47 ++++++++++++- libs/items.js | 2 + libs/maps.js | 16 ++--- libs/ui.js | 144 ++++++++++++++++++++++++++++++++++++++++ main.js | 1 + project/data.js | 1 + project/functions.js | 4 ++ 更新说明.txt | 2 +- 12 files changed, 217 insertions(+), 13 deletions(-) diff --git a/_server/data.comment.js b/_server/data.comment.js index 65db31e4..d431715b 100644 --- a/_server/data.comment.js +++ b/_server/data.comment.js @@ -415,6 +415,12 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_bool": "bool", "_data": "是否允许等级提升(进阶);如果上面enableExperience为false,则此项恒视为false" }, + "enableKeys": { + "_leaf": true, + "_type": "checkbox", + "_bool": "bool", + "_data": "是否在状态栏显示三色钥匙数量" + }, "enableDebuff": { "_leaf": true, "_type": "checkbox", diff --git a/docs/event.md b/docs/event.md index 7fe90b60..ddcff95a 100644 --- a/docs/event.md +++ b/docs/event.md @@ -1576,7 +1576,7 @@ core.insertAction([ // effect也允许写一个function,代表本次升级将会执行的操作,比如可以显示一段提示文字,或者触发一个事件 {"need": 40, "effect": function () { - core.drawText("恭喜升级!"); + core.drawTip("恭喜升级!"); core.status.hero.hp *= 2; core.status.hero.atk += 100; core.status.hero.def += 100; diff --git a/index.html b/index.html index 32cb7037..e03830c3 100644 --- a/index.html +++ b/index.html @@ -82,7 +82,7 @@

-
+
diff --git a/libs/actions.js b/libs/actions.js index 5e67dae5..1fa43e52 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -1562,6 +1562,8 @@ actions.prototype.clickSettings = function (x,y) { }); break; case 5: + core.ui.drawStatistics(); + /* core.ui.drawWaiting("正在拉取统计信息,请稍后..."); var formData = new FormData(); @@ -1609,6 +1611,7 @@ actions.prototype.clickSettings = function (x,y) { core.drawText("出错啦!\n无法拉取统计信息。\n错误原因:XHR Error"); } xhr.send(formData); + */ break; case 6: core.ui.drawHelp(); diff --git a/libs/control.js b/libs/control.js index 429b9af7..444f4fe4 100644 --- a/libs/control.js +++ b/libs/control.js @@ -59,6 +59,13 @@ control.prototype.setRequestAnimationFrame = function () { core.animateFrame.moveTime = core.animateFrame.moveTime||timestamp; core.animateFrame.weather.time = core.animateFrame.weather.time||timestamp; + // move time + if (core.isPlaying() && core.isset(core.status) && core.isset(core.status.hero) + && core.isset(core.status.hero.statistics)) { + core.status.hero.statistics.totalTime += timestamp-(core.status.hero.statistics.start||timestamp); + core.status.hero.statistics.start=timestamp; + } + // Global Animate if (core.animateFrame.globalAnimate && core.isPlaying()) { @@ -237,6 +244,12 @@ control.prototype.clearStatus = function() { ////// 重置游戏状态和初始数据 ////// control.prototype.resetStatus = function(hero, hard, floorId, route, maps) { + var totalTime=0; + if (core.isset(core.status) && core.isset(core.status.hero) + && core.isset(core.status.hero.statistics) && core.isset(route)) { + totalTime=core.status.hero.statistics.totalTime; + } + this.clearStatus(); // 初始化status @@ -249,6 +262,20 @@ control.prototype.resetStatus = function(hero, hard, floorId, route, maps) { core.material.enemys = core.clone(core.enemys.getEnemys()); // 初始化人物属性 core.status.hero = core.clone(hero); + // 统计数据 + if (!core.isset(core.status.hero.statistics)) + core.status.hero.statistics = { + 'totalTime': totalTime, + 'hp': 0, + 'battleDamage': 0, + 'poisonDamage': 0, + 'extraDamage': 0, + 'moveDirectly': 0, + 'ignoreSteps': 0, + } + core.status.hero.statistics.totalTime = Math.max(core.status.hero.statistics.totalTime, totalTime); + core.status.hero.statistics.start = null; + core.status.hard = hard; // 初始化路线 if (core.isset(route)) @@ -349,12 +376,15 @@ control.prototype.setAutomaticRoute = function (destX, destY, stepPostfix) { core.status.automaticRoute.moveDirectly = true; setTimeout(function () { if (core.status.automaticRoute.moveDirectly && core.status.heroMoving==0) { - if (core.canMoveDirectly(destX, destY)) { + var ignoreSteps = core.canMoveDirectly(destX, destY); + if (ignoreSteps>0) { core.clearMap('hero', 0, 0, 416, 416); core.setHeroLoc('x', destX); core.setHeroLoc('y', destY); core.drawHero(); core.status.route.push("move:"+destX+":"+destY); + core.status.hero.statistics.moveDirectly++; + core.status.hero.statistics.ignoreSteps+=ignoreSteps; } } core.status.automaticRoute.moveDirectly = false; @@ -781,6 +811,7 @@ control.prototype.moveOneStep = function() { core.status.hero.steps++; // 中毒状态 if (core.hasFlag('poison')) { + core.status.hero.statistics.poisonDamage += core.values.poisonDamage; core.status.hero.hp -= core.values.poisonDamage; if (core.status.hero.hp<=0) { core.status.hero.hp=0; @@ -1024,6 +1055,7 @@ control.prototype.checkBlock = function () { core.playSound('zone.mp3'); core.drawAnimate("zone", x, y); } + core.status.hero.statistics.extraDamage += damage; if (core.status.hero.hp<=0) { core.status.hero.hp=0; @@ -1680,12 +1712,16 @@ control.prototype.replay = function () { else if (action.indexOf('move:')==0) { var pos=action.substring(5).split(":"); var x=parseInt(pos[0]), y=parseInt(pos[1]); - if (core.canMoveDirectly(x,y)) { + + var ignoreSteps = core.canMoveDirectly(x, y); + if (ignoreSteps>0) { core.clearMap('hero', 0, 0, 416, 416); core.setHeroLoc('x', x); core.setHeroLoc('y', y); core.drawHero(); core.status.route.push("move:"+x+":"+y); + core.status.hero.statistics.moveDirectly++; + core.status.hero.statistics.ignoreSteps+=ignoreSteps; core.replay(); return; } @@ -2382,6 +2418,7 @@ control.prototype.resize = function(clientWidth, clientHeight) { if (!core.flags.enableExperience) count--; if (!core.flags.enableLevelUp) count--; if (!core.flags.enableDebuff) count--; + if (core.isset(core.flags.enableKeys) && !core.flags.enableKeys) count--; var statusLineHeight = BASE_LINEHEIGHT * 9 / count; var statusLineFontSize = DEFAULT_FONT_SIZE; @@ -2666,6 +2703,12 @@ control.prototype.resize = function(clientWidth, clientHeight) { display: core.flags.enableLevelUp ? 'block': 'none' } }, + { + id: 'keyCol', + rules: { + display: !core.isset(core.flags.enableKeys)||core.flags.enableKeys?'block':'none' + } + }, { 'id': 'debuffCol', rules: { diff --git a/libs/items.js b/libs/items.js index 437c7ff4..2b712d38 100644 --- a/libs/items.js +++ b/libs/items.js @@ -23,7 +23,9 @@ items.prototype.getItemEffect = function(itemId, itemNum) { // 消耗品 if (itemCls === 'items') { var ratio = parseInt(core.floors[core.status.floorId].item_ratio) || 1; + var curr_hp = core.status.hero.hp; if (itemId in this.itemEffect)eval(this.itemEffect[itemId]); + core.status.hero.statistics.hp += core.status.hero.hp - curr_hp; } else { core.addItem(itemId, itemNum); diff --git a/libs/maps.js b/libs/maps.js index d631cf43..31e7b6b4 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -255,20 +255,20 @@ maps.prototype.canMoveHero = function(x,y,direction,floorId) { ////// 能否瞬间移动 ////// maps.prototype.canMoveDirectly = function (destX,destY) { - if (!core.flags.enableMoveDirectly) return false; + if (!core.flags.enableMoveDirectly) return -1; // 中毒状态:不能 - if (core.hasFlag('poison')) return false; + if (core.hasFlag('poison')) return -1; var fromX = core.getHeroLoc('x'), fromY = core.getHeroLoc('y'); - if (fromX==destX&&fromY==destY) return false; + if (fromX==destX&&fromY==destY) return -1; if (core.getBlock(fromX,fromY)!=null||core.status.checkBlock.damage[13*fromX+fromY]>0) - return false; + return -1; // BFS var visited=[], queue=[]; - visited[13*fromX+fromY]=true; + visited[13*fromX+fromY]=0; queue.push(13*fromX+fromY); var directions = [[-1,0],[1,0],[0,1],[0,-1]]; @@ -278,12 +278,12 @@ maps.prototype.canMoveDirectly = function (destX,destY) { for (var dir in directions) { var nx=nowX+directions[dir][0], ny=nowY+directions[dir][1]; if (nx<0||nx>=13||ny<0||ny>=13||visited[13*nx+ny]||core.getBlock(nx,ny)!=null||core.status.checkBlock.damage[13*nx+ny]>0) continue; - if (nx==destX&&ny==destY) return true; - visited[13*nx+ny]=true; + visited[13*nx+ny]=visited[13*nowX+nowY]+1; + if (nx==destX&&ny==destY) return visited[13*nx+ny]; queue.push(13*nx+ny); } } - return false; + return -1; } maps.prototype.drawBlock = function (block, animate, dx, dy) { diff --git a/libs/ui.js b/libs/ui.js index 1520a02c..562232ac 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1749,6 +1749,150 @@ ui.prototype.drawKeyBoard = function () { core.fillText("ui", "返回游戏", 416-80, offset-3, '#FFFFFF', 'bold 15px Verdana'); } +////// 绘制“数据统计”界面 ////// +ui.prototype.drawStatistics = function () { + + // 数据统计要统计如下方面: + // 1. 当前全塔剩余下的怪物数量,总金币数,总经验数,总加点数 + // 2. 当前全塔剩余的黄蓝红铁门数量,和对应的钥匙数量 + // 3. 当前全塔剩余的三种宝石数量,血瓶数量,装备数量;总共增加的攻防生命值 + // 4. 当前层的上述信息 + // 5. 当前已走的步数;瞬间移动的步数,瞬间移动的次数(和少走的步数);游戏时长 + // 6. 当前已恢复的生命值;当前总伤害、战斗伤害、阻激夹域血网伤害、中毒伤害。 + + + var total = { + 'monster': { + 'count': 0, 'money': 0, 'experience': 0, 'point': 0, + }, + 'count': { + 'yellowDoor': 0, 'blueDoor': 0, 'redDoor': 0, 'steelDoor': 0, + 'yellowKey': 0, 'blueKey': 0, 'redKey': 0, 'steelKey': 0, + 'redJewel': 0, 'blueJewel': 0, 'greenJewel': 0, 'yellowJewel': 0, + 'redPotion': 0, 'bluePotion': 0, 'greenPotion': 0, 'yellowPotion': 0, 'superPotion': 0, + 'pickaxe': 0, 'bomb': 0, 'centerFly': 0, + 'poisonWine': 0, 'weakWine': 0, 'curseWine': 0, 'superWine': 0, + 'sword1': 0, 'sword2': 0, 'sword3': 0, 'sword4': 0, 'sword5': 0, + 'shield1': 0, 'shield2': 0, 'shield3': 0, 'shield4': 0, 'shield5': 0, + }, + 'add': { + 'hp': 0, 'atk': 0, 'def': 0, 'mdef': 0 + } + }; + var current = core.clone(total); + + core.floorIds.forEach(function (floorId) { + var floor=core.floors[floorId]; + var blocks=core.status.maps[floorId].blocks; + // 隐藏层不给看 + if (floor.cannotViewMap && floorId!=core.status.floorId) return; + + blocks.forEach(function (block) { + if (!core.isset(block.event) || (core.isset(block.enable) && !block.enable)) + return; + var event = block.event; + if (event.cls.indexOf("enemy")==0) { + var enemyId = event.id, enemy = core.material.enemys[enemyId]; + total.monster.money+=enemy.money||0; + total.monster.experience+=enemy.experience||0; + total.monster.point+=enemy.point||0; + total.monster.count++; + if (floorId==core.status.floorId) { + current.monster.money+=enemy.money||0; + current.monster.experience+=enemy.experience||0; + current.monster.point+=enemy.point||0; + current.monster.count++; + } + } + else { + var id = event.id; + + var temp = core.clone(core.status.hero); + + if (core.isset(total.count[id])) { + var hp=0, atk=0, def=0, mdef=0; + + if (core.isset(core.material.items[id]) && core.material.items[id].cls=='items' && id!='superPotion') { + var ratio = floor.item_ratio||1; + if (core.isset(core.items.itemEffect[id])) { + eval(core.items.itemEffect[id]); + } + hp = core.status.hero.hp - temp.hp; + atk = core.status.hero.atk - temp.atk; + def = core.status.hero.def - temp.def; + mdef = core.status.hero.mdef - temp.mdef; + } + else { + if (id.indexOf('sword')==0 && core.isset(core.values[id])) { + var x = core.values[id]; + if (typeof x == 'number') x = {'atk': x}; + atk += x.atk||0; + def += x.def||0; + mdef += x.mdef||0; + } + if (id.indexOf('shield')==0 && core.isset(core.values[id])) { + var x = core.values[id]; + if (typeof x == 'number') x = {'def': x}; + atk += x.atk||0; + def += x.def||0; + mdef += x.mdef||0; + } + } + core.status.hero = core.clone(temp); + total.count[id]++; + total.add.hp+=hp; + total.add.atk+=atk; + total.add.def+=def; + total.add.mdef+=mdef; + if (floorId==core.status.floorId) { + current.count[id]++; + current.add.hp+=hp; + current.add.atk+=atk; + current.add.def+=def; + current.add.mdef+=mdef; + } + } + } + }) + }) + + var getText = function (type, data) { + var text = type+"地图中:\n"; + text += "共有怪物"+data.monster.count+"个"; + if (core.flags.enableMoney) text+=",总金币数"+data.monster.money; + if (core.flags.enableExperience) text+=",总经验数"+data.monster.experience; + if (core.flags.enableAddPoint) text+=",总加点数"+data.monster.point; + text+="。\n"; + Object.keys(data.count).forEach(function (key) { + var value=data.count[key]; + if (value>0) { + var name=""; + if (key=='yellowDoor') name="黄门"; + else if (key=='blueDoor') name="蓝门"; + else if (key=='redDoor') name="红门"; + else if (key=='steelDoor') name="铁门"; + else name=core.material.items[key].name; + if (core.isset(name)) { + text+=name+value+"个;"; + } + } + }) + text+="\n"; + text+="共加生命值"+core.formatBigNumber(data.add.hp)+"点,攻击" + +core.formatBigNumber(data.add.atk)+"点,防御" + +core.formatBigNumber(data.add.def)+"点,魔防" + +core.formatBigNumber(data.add.mdef)+"点。"; + return text; + } + + core.drawText([ + getText("全塔", total), + getText("当前", current), + "当前总步数为"+core.status.hero.steps+"," + ]) + +} + ////// 绘制“关于”界面 ////// ui.prototype.drawAbout = function () { return this.uidata.drawAbout(); diff --git a/main.js b/main.js index bf79363d..1bb53fce 100644 --- a/main.js +++ b/main.js @@ -57,6 +57,7 @@ function main() { 'moneyCol': document.getElementById('moneyCol'), 'expCol': document.getElementById('expCol'), 'upCol': document.getElementById('upCol'), + 'keyCol': document.getElementById('keyCol'), 'debuffCol': document.getElementById('debuffCol'), 'hard': document.getElementById('hard'), }; diff --git a/project/data.js b/project/data.js index 15d26b0a..e03c802b 100644 --- a/project/data.js +++ b/project/data.js @@ -140,6 +140,7 @@ data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "enableMoney": true, "enableExperience": false, "enableLevelUp": false, + "enableKeys": true, "enableDebuff": false, "flyNearStair": true, "pickaxeFourDirections": false, diff --git a/project/functions.js b/project/functions.js index e6a5a7ba..f8004acd 100644 --- a/project/functions.js +++ b/project/functions.js @@ -119,6 +119,10 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 扣减体力值 core.status.hero.hp -= damage; + + // 记录 + core.status.hero.statistics.battleDamage += damage; + if (core.status.hero.hp<=0) { core.status.hero.hp=0; core.updateStatusBar(); diff --git a/更新说明.txt b/更新说明.txt index fb516de6..55da88f0 100644 --- a/更新说明.txt +++ b/更新说明.txt @@ -4,7 +4,7 @@ 事件:while循环处理 √ 事件:等待用户操作并获得按键或点击信息 √ 衰弱可以减少攻防的比例 √ -地图数据统计 +地图数据统计 √ 支持 status:x 获得当前坐标 √ core.debug()改成调试模式,可以Ctrl穿墙 √ 最大存档个数提到main处理 √ From 868e6c8b32e802d40fcb1f6e2a6305605d116fcb Mon Sep 17 00:00:00 2001 From: oc Date: Wed, 23 May 2018 08:33:20 +0800 Subject: [PATCH 09/18] statistics --- libs/control.js | 1 + libs/maps.js | 2 +- libs/ui.js | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/libs/control.js b/libs/control.js index 444f4fe4..e345f6c4 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1386,6 +1386,7 @@ control.prototype.updateFg = function () { for (var y=0;y<13;y++) { var damage = core.status.checkBlock.damage[13*x+y]; if (damage>0) { + damage = core.formatBigNumber(damage); core.setFillStyle('fg', '#000000'); core.canvas.fg.fillText(damage, 32 * x + 17, 32 * (y + 1) - 13); core.canvas.fg.fillText(damage, 32 * x + 15, 32 * (y + 1) - 15); diff --git a/libs/maps.js b/libs/maps.js index 31e7b6b4..2ab284db 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -739,7 +739,7 @@ maps.prototype.removeBlock = function (x, y, floorId) { // 删除Index core.removeBlockById(index, floorId); - core.updateFg(); + core.updateStatusBar(); } ////// 根据block的索引删除该块 ////// diff --git a/libs/ui.js b/libs/ui.js index 562232ac..7089c880 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1885,10 +1885,23 @@ ui.prototype.drawStatistics = function () { return text; } + var formatTime = function (time) { + return core.setTwoDigits(parseInt(time/3600000)) + +":"+core.setTwoDigits(parseInt(time/60000)%60) + +":"+core.setTwoDigits(parseInt(time/1000)%60); + } + + var statistics = core.status.hero.statistics; core.drawText([ getText("全塔", total), getText("当前", current), - "当前总步数为"+core.status.hero.steps+"," + "当前总步数:"+core.status.hero.steps+",游戏时长:"+formatTime(statistics.totalTime) + +"。\n瞬间移动次数:"+statistics.moveDirectly+",共计少走"+statistics.ignoreSteps+"步。" + +"\n\n总计通过血瓶恢复生命值为"+core.formatBigNumber(statistics.hp)+"点。\n\n" + +"总计受到的伤害为"+core.formatBigNumber(statistics.battleDamage+statistics.poisonDamage+statistics.extraDamage) + +",其中战斗伤害"+core.formatBigNumber(statistics.battleDamage)+"点" + +(core.flags.enableDebuff?(",中毒伤害"+core.formatBigNumber(statistics.poisonDamage)+"点"):"") + +",领域/夹击/阻击/血网伤害"+core.formatBigNumber(statistics.extraDamage)+"点。" ]) } From b88071cec878fa5b11132933658d041755111192 Mon Sep 17 00:00:00 2001 From: oc Date: Wed, 23 May 2018 08:43:02 +0800 Subject: [PATCH 10/18] statistics --- libs/ui.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/ui.js b/libs/ui.js index 7089c880..b5fe66fe 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1862,7 +1862,7 @@ ui.prototype.drawStatistics = function () { if (core.flags.enableMoney) text+=",总金币数"+data.monster.money; if (core.flags.enableExperience) text+=",总经验数"+data.monster.experience; if (core.flags.enableAddPoint) text+=",总加点数"+data.monster.point; - text+="。\n"; + text+="。\n\n"; Object.keys(data.count).forEach(function (key) { var value=data.count[key]; if (value>0) { @@ -1877,7 +1877,7 @@ ui.prototype.drawStatistics = function () { } } }) - text+="\n"; + text+="\n\n"; text+="共加生命值"+core.formatBigNumber(data.add.hp)+"点,攻击" +core.formatBigNumber(data.add.atk)+"点,防御" +core.formatBigNumber(data.add.def)+"点,魔防" @@ -1901,7 +1901,11 @@ ui.prototype.drawStatistics = function () { +"总计受到的伤害为"+core.formatBigNumber(statistics.battleDamage+statistics.poisonDamage+statistics.extraDamage) +",其中战斗伤害"+core.formatBigNumber(statistics.battleDamage)+"点" +(core.flags.enableDebuff?(",中毒伤害"+core.formatBigNumber(statistics.poisonDamage)+"点"):"") - +",领域/夹击/阻击/血网伤害"+core.formatBigNumber(statistics.extraDamage)+"点。" + +",领域/夹击/阻击/血网伤害"+core.formatBigNumber(statistics.extraDamage)+"点。", + "\t[说明]1. 地图数据统计的效果仅模拟当前立刻获得该道具的效果。\n2. 无法获得“不可被浏览地图”层的数据统计。\n" + + "3. 不会计算通过任何事件得到或生成的道具(比如利用显示事件或改变图块)个数和效果。\n"+ + "4. 如自定义道具(比如其他宝石)后,需手动在ui.js的drawStatistics中参与统计,不然默认不会进行统计。\n"+ + "5. 以上所有统计信息仅供参考,如有错误,概不负责。" ]) } From 4a35ec6ebfafd5259b9cd0e8e5fc67b25441c951 Mon Sep 17 00:00:00 2001 From: oc Date: Wed, 23 May 2018 08:46:35 +0800 Subject: [PATCH 11/18] statistics --- libs/ui.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/ui.js b/libs/ui.js index b5fe66fe..87118e65 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1902,10 +1902,10 @@ ui.prototype.drawStatistics = function () { +",其中战斗伤害"+core.formatBigNumber(statistics.battleDamage)+"点" +(core.flags.enableDebuff?(",中毒伤害"+core.formatBigNumber(statistics.poisonDamage)+"点"):"") +",领域/夹击/阻击/血网伤害"+core.formatBigNumber(statistics.extraDamage)+"点。", - "\t[说明]1. 地图数据统计的效果仅模拟当前立刻获得该道具的效果。\n2. 无法获得“不可被浏览地图”层的数据统计。\n" + - "3. 不会计算通过任何事件得到或生成的道具(比如利用显示事件或改变图块)个数和效果。\n"+ - "4. 如自定义道具(比如其他宝石)后,需手动在ui.js的drawStatistics中参与统计,不然默认不会进行统计。\n"+ - "5. 以上所有统计信息仅供参考,如有错误,概不负责。" + "\t[说明]1. 地图数据统计的效果仅模拟当前立刻获得该道具的效果。\n2. 不会计算“不可被浏览地图”的隐藏层的数据。\n" + + "3. 不会计算任何通过事件得到的道具(显示事件、改变图块、或直接增加道具等)。\n"+ + "4. 在自定义道具(例如其他宝石)后,需在ui.js的drawStatistics中注册,不然不会进行统计。\n"+ + "5. 所有统计信息仅供参考,如有错误,概不负责。" ]) } From b71806b167267108b60ca14e388e969b5b37a80e Mon Sep 17 00:00:00 2001 From: oc Date: Wed, 23 May 2018 13:37:13 +0800 Subject: [PATCH 12/18] afterloaddata --- docs/event.md | 2 +- libs/core.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/event.md b/docs/event.md index ddcff95a..b1559bcc 100644 --- a/docs/event.md +++ b/docs/event.md @@ -1513,7 +1513,7 @@ core.insertAction([ 而在我们的存档中,是不会对怪物数据进行存储的,只会存各个变量和Flag,因此我们需要在读档后根据变量或Flag来调整怪物数据。 -我们可以在functions.js中的`afterLoadData`进行处理。 +我们可以在脚本编辑中的`afterLoadData`进行处理。 ``` js ////// 读档事件后,载入事件前,可以执行的操作 ////// diff --git a/libs/core.js b/libs/core.js index 8eee43fd..769249b6 100644 --- a/libs/core.js +++ b/libs/core.js @@ -889,6 +889,16 @@ core.prototype.debug = function() { core.control.debug(); } +////// 存档前 ////// +core.prototype.beforeSaveData = function (data) { + return core.events.beforeSaveData(data); +} + +////// 读档后 ////// +core.prototype.afterLoadData = function (data) { + return core.events.afterLoadData(data); +} + ////// 重置当前地图 ////// core.prototype.resetMap = function(floorId) { core.maps.resetMap(floorId); From 7babb707291e079fd438cd641b5b8d0cdd423a47 Mon Sep 17 00:00:00 2001 From: oc Date: Wed, 23 May 2018 20:24:00 +0800 Subject: [PATCH 13/18] autoplay bug --- main.js | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/main.js b/main.js index 1bb53fce..6a89dd6d 100644 --- a/main.js +++ b/main.js @@ -459,8 +459,13 @@ main.dom.playGame.onclick = function () { main.dom.startButtons.style.display='none'; if (main.core.isset(main.core.musicStatus) && main.core.musicStatus.startDirectly - && main.core.musicStatus.bgmStatus && main.core.musicStatus.playingBgm==null) - main.core.playBgm(main.core.bgms[0]); + && main.core.musicStatus.bgmStatus) { + if (main.core.musicStatus.playingBgm==null + || core.material.bgms[main.core.musicStatus.playingBgm].paused) { + main.core.musicStatus.playingBgm=null; + main.core.playBgm(main.core.bgms[0]); + } + } if (main.core.isset(main.core.flags.startDirectly) && main.core.flags.startDirectly) { core.events.startGame(""); @@ -474,8 +479,13 @@ main.dom.playGame.onclick = function () { main.dom.loadGame.onclick = function() { if (main.core.isset(main.core.musicStatus) && main.core.musicStatus.startDirectly - && main.core.musicStatus.bgmStatus && main.core.musicStatus.playingBgm==null) - main.core.playBgm(main.core.bgms[0]); + && main.core.musicStatus.bgmStatus) { + if (main.core.musicStatus.playingBgm==null + || core.material.bgms[main.core.musicStatus.playingBgm].paused) { + main.core.musicStatus.playingBgm=null; + main.core.playBgm(main.core.bgms[0]); + } + } main.core.load(); } @@ -484,8 +494,13 @@ main.dom.loadGame.onclick = function() { main.dom.replayGame.onclick = function () { if (main.core.isset(main.core.musicStatus) && main.core.musicStatus.startDirectly - && main.core.musicStatus.bgmStatus && main.core.musicStatus.playingBgm==null) - main.core.playBgm(main.core.bgms[0]); + && main.core.musicStatus.bgmStatus) { + if (main.core.musicStatus.playingBgm==null + || core.material.bgms[main.core.musicStatus.playingBgm].paused) { + main.core.musicStatus.playingBgm=null; + main.core.playBgm(main.core.bgms[0]); + } + } core.readFile(function (obj) { if (obj.name!=core.firstData.name) { From 10159547ea89eb8489f0e9117df85651037266e4 Mon Sep 17 00:00:00 2001 From: oc Date: Thu, 24 May 2018 01:38:34 +0800 Subject: [PATCH 14/18] Fix Bug --- _server/blockly/MotaAction.g4 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/_server/blockly/MotaAction.g4 b/_server/blockly/MotaAction.g4 index 0ec2654b..48e10939 100644 --- a/_server/blockly/MotaAction.g4 +++ b/_server/blockly/MotaAction.g4 @@ -1385,8 +1385,7 @@ ActionParser.prototype.parseAction = function() { break; case "tip": this.next = MotaActionBlocks['tip_s'].xmlText([ - data.data,this.next]); - this.parseAction(); + data.text,this.next]); break; case "show": // 显示 if (!(data.loc[0] instanceof Array)) From 7301f703ef35d9145fb9e0fac43978416e99e843 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Thu, 24 May 2018 12:00:35 +0800 Subject: [PATCH 15/18] set useCompress false in editor --- editor.html | 1 + 1 file changed, 1 insertion(+) diff --git a/editor.html b/editor.html index f83105d0..010fef99 100644 --- a/editor.html +++ b/editor.html @@ -429,6 +429,7 @@ if (location.protocol.indexOf("http")!=0) {