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处理 √