From 4a801cbc859fc62a4b39ed9ee039cde321c6c4fe Mon Sep 17 00:00:00 2001 From: unamed <1319491857@qq.com> Date: Tue, 1 Feb 2022 22:22:52 +0800 Subject: [PATCH] polyfill & kill bug --- index.html | 1 + libs/events.js | 278 +++++++++++----------- libs/maps.js | 291 ++++++++++++------------ libs/thirdparty/browser-polyfill.min.js | 2 + libs/utils.js | 122 +++++----- 5 files changed, 354 insertions(+), 340 deletions(-) create mode 100644 libs/thirdparty/browser-polyfill.min.js diff --git a/index.html b/index.html index d7d64c54..e6f6a77b 100644 --- a/index.html +++ b/index.html @@ -189,6 +189,7 @@ + diff --git a/libs/events.js b/libs/events.js index 155476e9..0ac09e82 100644 --- a/libs/events.js +++ b/libs/events.js @@ -2,7 +2,7 @@ "use strict"; -function events() { +function events () { this._init(); } @@ -61,7 +61,7 @@ events.prototype._startGame_start = function (hard, seed, route, callback) { core.dom.enlargeBtn.style.display = 'block'; core.push(todo, core.firstData.startCanvas); } - core.push(todo, {"type": "function", "function": "function() { core.events._startGame_setHard(); }"}) + core.push(todo, { "type": "function", "function": "function() { core.events._startGame_setHard(); }" }) core.push(todo, core.firstData.startText); this.insertAction(todo, null, null, function () { core.events._startGame_afterStart(callback); @@ -78,7 +78,7 @@ events.prototype._startGame_setHard = function () { main.levelChoose.forEach(function (one) { if (one.name == core.status.hard) { hardValue = one.hard; - hardColor = core.arrayToRGBA(one.color || [255,0,0,1]); + hardColor = core.arrayToRGBA(one.color || [255, 0, 0, 1]); core.insertAction(one.action); } }); @@ -162,8 +162,8 @@ events.prototype._gameOver_confirmUpload = function (ending, norank) { else { var id = core.getCookie('id') || ""; var hint = "请输入你的ID:\n(登录状态下输入数字用户编号可成为蓝名成绩并计入用户通关数)"; - if (id) hint = "请输入你的ID:\n(输入数字用户编号"+id+ "可成为蓝名成绩并计入用户通关数)"; - core.myprompt(hint, id, function (username) { + if (id) hint = "请输入你的ID:\n(输入数字用户编号" + id + "可成为蓝名成绩并计入用户通关数)"; + core.myprompt(hint, id, function (username) { core.events._gameOver_doUpload(username, ending, norank); }); } @@ -220,7 +220,7 @@ events.prototype._gameOver_confirmDownload = function (ending) { 'seed': core.getFlag('__seed__'), 'route': core.encodeRoute(core.status.route) } - core.download(core.firstData.name + "_" + core.formatDate2(new Date()) + ".h5route", + core.download(core.firstData.name + "_" + core.formatDate2(new Date()) + ".h5route", LZString.compressToBase64(JSON.stringify(obj))); core.events._gameOver_askRate(ending); }, function () { @@ -272,7 +272,7 @@ events.prototype._gameOver_askRate = function (ending) { } ////// 重新开始游戏;此函数将回到标题页面 ////// -events.prototype.restart = function() { +events.prototype.restart = function () { core.showStartAnimate(); core.playBgm(main.startBgm); } @@ -313,7 +313,7 @@ events.prototype.doSystemEvent = function (type, data, callback) { } catch (e) { main.log(e); - main.log("ERROR in systemEvents["+type+"]"); + main.log("ERROR in systemEvents[" + type + "]"); } } if (this["_sys_" + type]) return this["_sys_" + type](data, callback); @@ -333,7 +333,7 @@ events.prototype.trigger = function (x, y, callback) { } if (core.status.gameOver) return _executeCallback(); if (core.status.event.id == 'action') { - core.insertAction({"type": "function", "function": "function () { core.events._trigger_inAction("+x+","+y+"); }", "async": true}, + core.insertAction({ "type": "function", "function": "function () { core.events._trigger_inAction(" + x + "," + y + "); }", "async": true }, null, null, null, true); return _executeCallback(); } @@ -373,7 +373,7 @@ events.prototype.trigger = function (x, y, callback) { events.prototype._trigger_inAction = function (x, y) { if (core.status.gameOver || core.status.event.id != 'action') return; - + var block = core.getBlock(x, y); if (block == null) return core.doAction(); @@ -439,9 +439,9 @@ events.prototype._sys_battle = function (data, callback) { // 检查战前事件 var beforeBattle = []; core.push(beforeBattle, core.floors[core.status.floorId].beforeBattle[data.x + "," + data.y]); - core.push(beforeBattle, (core.material.enemys[data.event.id]||{}).beforeBattle); + core.push(beforeBattle, (core.material.enemys[data.event.id] || {}).beforeBattle); if (beforeBattle.length > 0) { - core.push(beforeBattle, [{"type": "battle", "x": data.x, "y": data.y}]); + core.push(beforeBattle, [{ "type": "battle", "x": data.x, "y": data.y }]); core.clearContinueAutomaticRoute(); // 自动存档 @@ -545,7 +545,7 @@ events.prototype._openDoor_check = function (block, x, y, needKey) { if (needKey) { for (var keyName in keyInfo) { var keyValue = keyInfo[keyName]; - if (keyName.endsWith(':o')) keyName = keyName.substring(0, keyName.length - 2); + if (keyName.endsWith(':o')) keyName = keyName.substring(0, keyName.length - 2); // --- 如果是一个不存在的道具,则直接认为无法开启 if (!core.material.items[keyName]) { @@ -562,7 +562,7 @@ events.prototype._openDoor_check = function (block, x, y, needKey) { } } if (!core.status.event.id) core.autosave(true); - for (var keyName in keyInfo) { + for (var keyName in keyInfo) { if (!keyName.endsWith(':o')) core.removeItem(keyName, keyInfo[keyName]); } } @@ -593,7 +593,7 @@ events.prototype._openDoor_animate = function (block, x, y, callback) { if (callback) callback(); } - var animate = window.setInterval(function() { + var animate = window.setInterval(function () { blockInfo.posX++; if (blockInfo.posX == 4) { clearInterval(animate); @@ -601,9 +601,9 @@ events.prototype._openDoor_animate = function (block, x, y, callback) { cb(); return; } - core.maps._drawBlockInfo(blockInfo, x, y); + core.maps._drawBlockInfo(blockInfo, x, y); }, core.status.replay.speed == 24 ? 1 : speed / Math.max(core.status.replay.speed, 1)); - + core.animateFrame.lastAsyncId = animate; core.animateFrame.asyncId[animate] = cb; } @@ -635,13 +635,13 @@ events.prototype.getItem = function (id, num, x, y, isGentleClick, callback) { var hint = core.material.items[id].text || "该道具暂无描述"; try { hint = core.replaceText(hint); - } catch (e) {} - if (!core.status.event.id || core.status.event.id=='action') { - core.insertAction("\t["+core.material.items[id].name+","+id+"]" + hint + "\n" + } catch (e) { } + if (!core.status.event.id || core.status.event.id == 'action') { + core.insertAction("\t[" + core.material.items[id].name + "," + id + "]" + hint + "\n" + (id.endsWith('Key') ? "(钥匙类道具,遇到对应的门时自动打开)" : itemCls == 'tools' ? "(消耗类道具,请按T在道具栏使用)" - : itemCls == 'constants' ? "(永久类道具,请按T在道具栏使用)" - : itemCls == 'equips' ? "(装备类道具,请按Q在装备栏进行装备)" : "")); + : itemCls == 'constants' ? "(永久类道具,请按T在道具栏使用)" + : itemCls == 'equips' ? "(装备类道具,请按Q在装备栏进行装备)" : "")); } itemHint.push(id); } @@ -686,7 +686,7 @@ events.prototype._getNextItem = function (direction, noRoute) { events.prototype._sys_changeFloor = function (data, callback) { data = data.event.data; var heroLoc = {}; - if (data.loc) heroLoc = {'x': data.loc[0], 'y': data.loc[1]}; + if (data.loc) heroLoc = { 'x': data.loc[0], 'y': data.loc[1] }; if (data.direction) heroLoc.direction = data.direction; if (core.status.event.id != 'action') core.status.event.id = null; core.changeFloor(data.floorId, data.stair, heroLoc, data.time, function () { @@ -799,13 +799,13 @@ events.prototype._changeFloor_beforeChange = function (info, callback) { } events.prototype._changeFloor_playSound = function () { - // 播放换层音效 - if (core.hasFlag('__fromLoad__')) // 是否是读档造成的切换 - core.playSound('读档'); - else if (core.hasFlag('__isFlying__')) // 是否是楼传造成的切换 - core.playSound('飞行器'); - else - core.playSound('上下楼'); + // 播放换层音效 + if (core.hasFlag('__fromLoad__')) // 是否是读档造成的切换 + core.playSound('读档'); + else if (core.hasFlag('__isFlying__')) // 是否是楼传造成的切换 + core.playSound('飞行器'); + else + core.playSound('上下楼'); } events.prototype._changeFloor_changing = function (info, callback) { @@ -814,7 +814,7 @@ events.prototype._changeFloor_changing = function (info, callback) { var __lockViewport__ = flags.__lockViewport__; core.setFlag('__lockViewport__', null); core.drawHero(); - core.setFlag('__lockViewport__', __lockViewport__); + core.setFlag('__lockViewport__', __lockViewport__); if (info.time == 0) this._changeFloor_afterChange(info, callback); @@ -888,8 +888,8 @@ events.prototype.pushBox = function (data) { core.setBlock('flower', data.x, data.y); // 勇士前进一格,然后触发推箱子后事件 core.insertAction([ - {"type": "moveAction"}, - {"type": "function", "function": "function() { core.afterPushBox(); }"} + { "type": "moveAction" }, + { "type": "function", "function": "function() { core.afterPushBox(); }" } ]); } @@ -953,7 +953,7 @@ events.prototype.doEvent = function (data, x, y, prefix) { } catch (e) { main.log(e); - main.log("ERROR in actions["+type+"]"); + main.log("ERROR in actions[" + type + "]"); } } if (this["_action_" + type]) return this["_action_" + type](data, x, y, prefix); @@ -966,8 +966,8 @@ events.prototype.setEvents = function (list, x, y, callback) { if (list) { var l = core.clone(list); if (!(l instanceof Array)) l = [l]; - l.push({"type": "_label"}); - data.list = [{todo: l, total: core.clone(l), condition: "false"}]; + l.push({ "type": "_label" }); + data.list = [{ todo: l, total: core.clone(l), condition: "false" }]; // 结束所有正在执行的自动事件 if (list.length == 0) { core.status.autoEvents.forEach(function (autoEvent) { @@ -1020,7 +1020,7 @@ events.prototype.doAction = function () { var data = current.todo.shift(); core.status.event.data.current = data; if (typeof data == "string") - data = {"type": "text", "text": data}; + data = { "type": "text", "text": data }; // 该事件块已经被禁用 if (data._disabled) return core.doAction(); data.floorId = data.floorId || floorId; @@ -1082,7 +1082,7 @@ events.prototype.insertAction = function (action, x, y, callback, addToLast) { list.splice(index, 0, action); break; } - } + } } else core.unshift(core.status.event.data.list[0].todo, action); this.setEvents(null, x, y, callback); @@ -1103,12 +1103,12 @@ events.prototype.insertCommonEvent = function (name, args, x, y, callback, addTo for (var i = 0; i < args.length; ++i) { try { if (args[i] != null) - core.setFlag('arg'+(i+1), args[i]); + core.setFlag('arg' + (i + 1), args[i]); } catch (e) { main.log(e); } } } - this.insertAction({"type": "dowhile", "condition": "false", "data": commonEvent}, x, y, callback, addToLast); + this.insertAction({ "type": "dowhile", "condition": "false", "data": commonEvent }, x, y, callback, addToLast); } ////// 获得一个公共事件 ////// @@ -1143,7 +1143,7 @@ events.prototype.checkAutoEvents = function () { // 不在当前楼层 or 已经执行过 or 已被分区 or 正在执行中 if (autoEvent.currentFloor && floorId != core.status.floorId) return; if (!autoEvent.multiExecute && core.autoEventExecuted(symbol)) return; - if ((flags.__removed__||[]).indexOf(floorId) >= 0) return; + if ((flags.__removed__ || []).indexOf(floorId) >= 0) return; if (core.autoEventExecuting(symbol)) return; var prefix = floorId + "@" + x + "@" + y; try { @@ -1154,23 +1154,29 @@ events.prototype.checkAutoEvents = function () { core.autoEventExecuting(symbol, true); core.autoEventExecuted(symbol, true); - + var event; if (x == null && y == null) { event = [ // 用do-while(0)包一层防止break影响事件流 - {"type": "dowhile", "condition": "false", "data": autoEvent.data}, - {"type": "function", "function": - "function() { core.autoEventExecuting('" + symbol + "', false); }"} + { "type": "dowhile", "condition": "false", "data": autoEvent.data }, + { + "type": "function", "function": + "function() { core.autoEventExecuting('" + symbol + "', false); }" + } ]; } else { event = [ - {"type": "function", "function": - "function() { core.pushEventLoc(" + x + ", " + y + ", '" + floorId + "' ); }"}, + { + "type": "function", "function": + "function() { core.pushEventLoc(" + x + ", " + y + ", '" + floorId + "' ); }" + }, // 用do-while(0)包一层防止break影响事件流 - {"type": "dowhile", "condition": "false", "data": autoEvent.data}, - {"type": "function", "function": - "function() { core.popEventLoc(); core.autoEventExecuting('" + symbol + "', false); }"} + { "type": "dowhile", "condition": "false", "data": autoEvent.data }, + { + "type": "function", "function": + "function() { core.popEventLoc(); core.autoEventExecuting('" + symbol + "', false); }" + } ]; } @@ -1397,7 +1403,7 @@ events.prototype._action_text = function (data, x, y, prefix) { events.prototype._action_moveTextBox = function (data, x, y, prefix) { if (this.__action_checkReplaying()) return; - this.__action_doAsyncFunc(data.async, core.moveTextBox, + this.__action_doAsyncFunc(data.async, core.moveTextBox, data.code, this.__action_getLoc(data.loc, x, y, prefix), data.relative, data.moveMode, data.time); } @@ -1439,7 +1445,7 @@ events.prototype._action_tip = function (data, x, y, prefix) { events.prototype._action_show = function (data, x, y, prefix) { data.loc = this.__action_getLoc2D(data.loc, x, y, prefix); - if (data.time > 0 && data.floorId == core.status.floorId) { + if (data.time > 0 && data.floorId == core.status.floorId) { this.__action_doAsyncFunc(data.async, core.animateBlock, data.loc, 'show', data.time); } else { @@ -1583,14 +1589,14 @@ events.prototype._action_moveAction = function (data, x, y, prefix) { // 检查noPass决定是撞击还是移动 if (core.noPass(nx, ny)) { core.insertAction([ - {"type": "trigger", "loc": [nx, ny]} + { "type": "trigger", "loc": [nx, ny] } ]); } else { // 先移动一格,然后尝试触发事件 core.insertAction([ - {"type": "moveHero", "steps": ["forward"]}, - {"type": "function", "function": "function() { core.moveOneStep(core.doAction); }", "async": true}, - {"type": "_label"}, + { "type": "moveHero", "steps": ["forward"] }, + { "type": "function", "function": "function() { core.moveOneStep(core.doAction); }", "async": true }, + { "type": "_label" }, ]); } } @@ -1630,7 +1636,7 @@ events.prototype._action_jumpHero = function (data, x, y, prefix) { events.prototype._action_changeFloor = function (data, x, y, prefix) { var loc = this.__action_getHeroLoc(data.loc, prefix); - var heroLoc = {x: loc[0], y: loc[1], direction: data.direction}; + var heroLoc = { x: loc[0], y: loc[1], direction: data.direction }; core.changeFloor(data.floorId, data.stair, heroLoc, data.time, core.doAction); } @@ -1666,7 +1672,7 @@ events.prototype._action_showTextImage = function (data, x, y, prefix) { var loc = this.__action_getLoc(data.loc, 0, 0, prefix); if (core.isReplaying()) data.time = 0; data.text = core.replaceText(data.text, prefix); - var __tmpName = (Math.random()+"_"+Math.random()).replace(/\./g, "") + ".png"; + var __tmpName = (Math.random() + "_" + Math.random()).replace(/\./g, "") + ".png"; core.material.images.images[__tmpName] = core.ui.textImage(data.text); this.__action_doAsyncFunc(data.async || data.time == 0, core.showImage, data.code, __tmpName + (data.reverse || ""), null, loc, data.opacity, data.time); @@ -1816,18 +1822,18 @@ events.prototype._action_insert = function (data, x, y, prefix) { else { // 设置参数 if (data.args instanceof Array) { - for (var i = 0; i < data.args.length; ++i) { - try { - if (data.args[i] != null) - core.setFlag('arg'+(i+1), data.args[i]); - } catch (e) { main.log(e); } - } + for (var i = 0; i < data.args.length; ++i) { + try { + if (data.args[i] != null) + core.setFlag('arg' + (i + 1), data.args[i]); + } catch (e) { main.log(e); } + } } var loc = this.__action_getLoc(data.loc, x, y, prefix); core.setFlag('arg0', loc); var floorId = data.floorId; var which = data.which || "events"; - var event = (core.floors[floorId][which]||[])[loc[0] + "," + loc[1]]; + var event = (core.floors[floorId][which] || [])[loc[0] + "," + loc[1]]; if (event) this.insertAction(event.data || event); } core.doAction(); @@ -2099,13 +2105,13 @@ events.prototype._action_choices = function (data, x, y, prefix) { core.status.route.push("choices:none"); core.setFlag('timeout', 0); core.doAction(); - }, data.timeout); + }, data.timeout); } core.status.event.timeout = new Date().getTime() + (data.timeout || 0); } for (var i = 0; i < data.choices.length; i++) { if (typeof data.choices[i] === 'string') - data.choices[i] = {"text": data.choices[i]}; + data.choices[i] = { "text": data.choices[i] }; data.choices[i].text = core.replaceText(data.choices[i].text, prefix); } core.ui.drawChoices(core.replaceText(data.text, prefix), data.choices, data.width); @@ -2126,13 +2132,13 @@ events.prototype.__action_choices_replaying = function (data, index) { } else core.setFlag('timeout', 0); core.status.event.selection = selection; setTimeout(function () { - core.status.route.push("choices:"+index); + core.status.route.push("choices:" + index); if (selection != 'none') { // 检查 var choice = data.choices[selection]; if (choice.need != null && choice.need != '' && !core.calValue(choice.need)) { // 无法选择此项 - core.control._replay_error("无法选择项:"+index); + core.control._replay_error("无法选择项:" + index); return; } else { core.insertAction(choice.action); @@ -2155,7 +2161,7 @@ events.prototype._precompile_choices = function (data) { events.prototype._action_confirm = function (data, x, y, prefix) { data.text = core.replaceText(data.text, prefix); - core.status.event.ui = {"text": data.text, "yes": data.yes, "no": data.no}; + core.status.event.ui = { "text": data.text, "yes": data.yes, "no": data.no }; if (core.isReplaying()) { var action = core.status.replay.toReplay.shift(); if (action.indexOf('choices:') == 0 && !(action == 'choices:none' && !data.timeout)) { @@ -2194,7 +2200,7 @@ events.prototype.__action_confirm_replaying = function (data, index) { } else core.setFlag('timeout', 0); core.status.event.selection = index; setTimeout(function () { - core.status.route.push("choices:"+index); + core.status.route.push("choices:" + index); if (index != 'none') { if (index == 0) core.insertAction(data.yes); else core.insertAction(data.no); @@ -2218,7 +2224,7 @@ events.prototype._action_for = function (data, x, y, prefix) { var from = core.calValue(data.from); var to = core.calValue(data.to); var step = core.calValue(data.step); - if (typeof from != 'number' || typeof to !='number' || typeof step != 'number') { + if (typeof from != 'number' || typeof to != 'number' || typeof step != 'number') { core.insertAction('循环遍历事件要求【起始点】【终止点】【每步】仅能是数字!'); return core.doAction(); } @@ -2234,18 +2240,18 @@ events.prototype._action_for = function (data, x, y, prefix) { var stepName = '@temp@for-step@' + letter; core.setFlag(toName, data.to); core.setFlag(stepName, data.step); - var condition = "(function () {"+ - "var to = core.calValue(core.getFlag('" + toName + "'));"+ - "var step = core.calValue(core.getFlag('" + stepName + "'));"+ - "if (typeof step != 'number' || typeof to != 'number') return false;"+ - "if (step == 0) return true;"+ - "var currentValue = core.getFlag('@temp@" + letter + "');"+ - "currentValue += step;"+ - "core.setFlag('@temp@" + letter + "', currentValue);"+ - "if (step > 0) { return currentValue <= to; }"+ - "else { return currentValue >= to; }"+ + var condition = "(function () {" + + "var to = core.calValue(core.getFlag('" + toName + "'));" + + "var step = core.calValue(core.getFlag('" + stepName + "'));" + + "if (typeof step != 'number' || typeof to != 'number') return false;" + + "if (step == 0) return true;" + + "var currentValue = core.getFlag('@temp@" + letter + "');" + + "currentValue += step;" + + "core.setFlag('@temp@" + letter + "', currentValue);" + + "if (step > 0) { return currentValue <= to; }" + + "else { return currentValue >= to; }" + "})()"; - return this._action_dowhile({"condition": condition, "data": data.data}, x, y, prefix); + return this._action_dowhile({ "condition": condition, "data": data.data }, x, y, prefix); } events.prototype._precompile_for = function (data) { @@ -2265,12 +2271,12 @@ events.prototype._action_forEach = function (data, x, y, prefix) { var listName = '@temp@forEach@' + data.name.substring(5); core.setFlag(listName, core.clone(data.list)); var condition = "(function () {" + - "var list = core.getFlag('"+listName+"', []);"+ - "if (list.length == 0) return false;"+ - "core.setFlag('@temp@'+'" + data.name.substring(5) + "', list.shift());"+ - "return true;"+ + "var list = core.getFlag('" + listName + "', []);" + + "if (list.length == 0) return false;" + + "core.setFlag('@temp@'+'" + data.name.substring(5) + "', list.shift());" + + "return true;" + "})()"; - return this._action_while({"condition": condition, "data": data.data}, x, y, prefix); + return this._action_while({ "condition": condition, "data": data.data }, x, y, prefix); } events.prototype._precompile_forEach = function (data) { @@ -2282,9 +2288,9 @@ events.prototype._action_while = function (data, x, y, prefix) { if (core.calValue(data.condition, prefix)) { var list = core.clone(data.data); if (!(list instanceof Array)) list = [list]; - list.push({"type": "_label"}); + list.push({ "type": "_label" }); core.unshift(core.status.event.data.list, - {"todo": list, "total": core.clone(list), "condition": data.condition} + { "todo": list, "total": core.clone(list), "condition": data.condition } ); } core.doAction(); @@ -2299,9 +2305,9 @@ events.prototype._precompile_while = function (data) { events.prototype._action_dowhile = function (data, x, y, prefix) { var list = core.clone(data.data); if (!(list instanceof Array)) list = [list]; - list.push({"type": "_label"}); + list.push({ "type": "_label" }); core.unshift(core.status.event.data.list, - {"todo": list, "total": core.clone(list), "condition": data.condition} + { "todo": list, "total": core.clone(list), "condition": data.condition } ); core.doAction(); } @@ -2431,7 +2437,7 @@ events.prototype._action_wait = function (data, x, y, prefix) { core.control._replay_error(code); return; } else if (data.timeout) { - core.status.event.interval = setTimeout(function() { + core.status.event.interval = setTimeout(function () { core.status.route.push("input:none"); core.setFlag("type", -1); core.setFlag("timeout", 0); @@ -2498,7 +2504,7 @@ events.prototype.__action_wait_afterGet = function (data) { } if (one["case"] == "condition") { var condition = false; - try { condition = core.calValue(one.condition); } catch (e) {} + try { condition = core.calValue(one.condition); } catch (e) { } if (condition) { found = true; core.push(todo, one.action); @@ -2532,9 +2538,9 @@ events.prototype._precompile_wait = function (data) { events.prototype._action_waitAsync = function (data, x, y, prefix) { var test = window.setInterval(function () { - if (!core.hasAsync() - && (data.excludeAnimates || core.isReplaying() || core.getPlayingAnimates().length == 0) - && (!data.includeSounds || core.isReplaying() || core.getPlayingSounds().length == 0)) { + if (!core.hasAsync() + && (data.excludeAnimates || core.isReplaying() || core.getPlayingAnimates().length == 0) + && (!data.includeSounds || core.isReplaying() || core.getPlayingSounds().length == 0)) { clearInterval(test); core.doAction(); } @@ -2778,7 +2784,7 @@ events.prototype.useFly = function (fromUserAction) { if (!core.hasItem('fly')) { core.playSound('操作失败'); core.drawTip('你没有' + core.material.items['fly'].name, 'fly'); - } else if (!core.canUseItem('fly')) { + } else if (!core.canUseItem('fly') || (core.flags.flyNearStair && !core.nearStair())) { core.playSound('操作失败'); core.drawTip('无法传送到当前层', 'fly'); } else { @@ -2880,32 +2886,32 @@ events.prototype.save = function (fromUserAction) { return; if (!this._checkStatus('save', fromUserAction)) return; var saveIndex = core.saves.saveIndex; - var page=parseInt((saveIndex-1)/5), offset=saveIndex-5*page; + var page = parseInt((saveIndex - 1) / 5), offset = saveIndex - 5 * page; core.playSound('打开界面'); - core.ui._drawSLPanel(10*page+offset); + core.ui._drawSLPanel(10 * page + offset); } ////// 点击读取按钮时的打开操作 ////// events.prototype.load = function (fromUserAction) { if (core.isReplaying()) return; var saveIndex = core.saves.saveIndex; - var page=parseInt((saveIndex-1)/5), offset=saveIndex-5*page; + var page = parseInt((saveIndex - 1) / 5), offset = saveIndex - 5 * page; // 游戏开始前读档 if (!core.isPlaying()) { core.dom.startPanel.style.display = 'none'; core.clearStatus(); core.clearMap('all'); - core.status.event = {'id': 'load', 'data': null}; + core.status.event = { 'id': 'load', 'data': null }; core.status.lockControl = true; core.playSound('打开界面'); - core.ui._drawSLPanel(10*page+offset); + core.ui._drawSLPanel(10 * page + offset); return; } if (core.status.event.id == 'load' && core.events.recoverEvents(core.status.event.interval)) return; if (!this._checkStatus('load', fromUserAction)) return; core.playSound('打开界面'); - core.ui._drawSLPanel(10*page+offset); + core.ui._drawSLPanel(10 * page + offset); } ////// 点击设置按钮时的操作 ////// @@ -2944,7 +2950,7 @@ events.prototype.hasAsyncAnimate = function () { events.prototype.follow = function (name) { name = core.getMappedName(name); if (core.material.images.images[name]) { - core.status.hero.followers.push({"name": name}); + core.status.hero.followers.push({ "name": name }); core.gatherFollowers(); core.clearMap('hero'); core.drawHero(); @@ -3045,9 +3051,9 @@ events.prototype.setEnemy = function (id, name, value, operator, prefix, norefre var enemyInfo = core.getFlag('enemyInfo'); if (!enemyInfo[id]) enemyInfo[id] = {}; if (typeof value === 'string' && name == 'name') value = value.replace(/\r/g, '\\r'); - value = this._updateValueByOperator(core.calValue(value, prefix), (core.material.enemys[id]||{})[name], operator); + value = this._updateValueByOperator(core.calValue(value, prefix), (core.material.enemys[id] || {})[name], operator); enemyInfo[id][name] = value; - (core.material.enemys[id]||{})[name] = core.clone(value); + (core.material.enemys[id] || {})[name] = core.clone(value); if (!norefresh) core.updateStatusBar(); } @@ -3062,24 +3068,24 @@ events.prototype.setEnemyOnPoint = function (x, y, floorId, name, value, operato if (typeof value === 'string' && name == 'name') value = value.replaceAll(/\r/g, '\\r'); value = this._updateValueByOperator(core.calValue(value, prefix), core.getEnemyValue(enemy, name, x, y, floorId), operator); flags.enemyOnPoint = flags.enemyOnPoint || {}; - flags.enemyOnPoint[floorId] = flags.enemyOnPoint[floorId] || {}; - flags.enemyOnPoint[floorId][x+","+y] = flags.enemyOnPoint[floorId][x+","+y] || {}; - flags.enemyOnPoint[floorId][x+","+y][name] = value; + flags.enemyOnPoint[floorId] = flags.enemyOnPoint[floorId] || {}; + flags.enemyOnPoint[floorId][x + "," + y] = flags.enemyOnPoint[floorId][x + "," + y] || {}; + flags.enemyOnPoint[floorId][x + "," + y][name] = value; if (!norefresh) core.updateStatusBar(); } ////// 重置某个点上的怪物属性 ////// events.prototype.resetEnemyOnPoint = function (x, y, floorId, norefresh) { - delete ((flags.enemyOnPoint||{})[floorId||core.status.floorId]||{})[x+","+y]; + delete ((flags.enemyOnPoint || {})[floorId || core.status.floorId] || {})[x + "," + y]; if (!norefresh) core.updateStatusBar(); } ////// 将某个点上已经设置的怪物属性移动到其他点 ////// events.prototype.moveEnemyOnPoint = function (fromX, fromY, toX, toY, floorId, norefresh) { floorId = floorId || core.status.floorId; - if (((flags.enemyOnPoint||{})[floorId]||{})[fromX+","+fromY]) { - flags.enemyOnPoint[floorId][toX+","+toY] = flags.enemyOnPoint[floorId][fromX+","+fromY]; - delete flags.enemyOnPoint[floorId][fromX+","+fromY]; + if (((flags.enemyOnPoint || {})[floorId] || {})[fromX + "," + fromY]) { + flags.enemyOnPoint[floorId][toX + "," + toY] = flags.enemyOnPoint[floorId][fromX + "," + fromY]; + delete flags.enemyOnPoint[floorId][fromX + "," + fromY]; if (!norefresh) core.updateStatusBar(); } } @@ -3115,7 +3121,7 @@ events.prototype.setGlobalFlag = function (name, value) { var flags = core.getFlag("globalFlags", {}); if (name.startsWith('s:')) { name = name.substring(2); - var statusBarItems = core.flags.statusBarItems.filter(function (v) {return v!=name;}); + var statusBarItems = core.flags.statusBarItems.filter(function (v) { return v != name; }); if (value) statusBarItems.push(name); core.flags.statusBarItems = statusBarItems; flags.statusBarItems = core.clone(statusBarItems); @@ -3201,7 +3207,7 @@ events.prototype._moveTextBox_moving = function (ctx, moveInfo, callback) { if (callback) callback(); } }, 10); - + core.animateFrame.lastAsyncId = animate; core.animateFrame.asyncId[animate] = callback; } @@ -3234,7 +3240,7 @@ events.prototype.clearTextBox = function (code, callback) { events.prototype.closeDoor = function (x, y, id, callback) { id = id || ""; if ((core.material.icons.animates[id] == null && core.material.icons.npc48[id] == null) - || core.getBlock(x, y) != null) { + || core.getBlock(x, y) != null) { if (callback) callback(); return; } @@ -3267,7 +3273,7 @@ events.prototype.closeDoor = function (x, y, id, callback) { } core.maps._drawBlockInfo(blockInfo, x, y); }, core.status.replay.speed == 24 ? 1 : speed / Math.max(core.status.replay.speed, 1)); - + core.animateFrame.lastAsyncId = animate; core.animateFrame.asyncId[animate] = cb; } @@ -3378,7 +3384,7 @@ events.prototype._moveImage_moving = function (name, moveInfo, callback) { if (callback) callback(); } }, per_time); - + core.animateFrame.lastAsyncId = animate; core.animateFrame.asyncId[animate] = callback; } @@ -3423,7 +3429,7 @@ events.prototype._rotateImage_rotating = function (name, rotateInfo, callback) { if (callback) callback(); } }, per_time); - + core.animateFrame.lastAsyncId = animate; core.animateFrame.asyncId[animate] = callback; } @@ -3451,7 +3457,7 @@ events.prototype.scaleImage = function (code, center, scale, moveMode, time, cal centerY = currTop + height * currScale / 2; } var scaleInfo = { - x: (currLeft - centerX) / currScale, y: (currTop - centerY) / currScale, centerX: centerX, centerY: centerY, + x: (currLeft - centerX) / currScale, y: (currTop - centerY) / currScale, centerX: centerX, centerY: centerY, width: width, height: height, currScale: currScale, scale: scale, moveMode: moveMode, time: time } this._scaleImage_scale(ctx, scaleInfo, callback); @@ -3484,7 +3490,7 @@ events.prototype._scaleImage_scale = function (ctx, scaleInfo, callback) { if (callback) callback(); } }, per_time); - + core.animateFrame.lastAsyncId = animate; core.animateFrame.asyncId[animate] = callback; } @@ -3533,7 +3539,7 @@ events.prototype.setVolume = function (value, time, callback) { if (callback) callback(); } }, per_time); - + core.animateFrame.lastAsyncId = animate; core.animateFrame.asyncId[animate] = callback; } @@ -3547,7 +3553,7 @@ events.prototype.vibrate = function (direction, time, speed, power, callback) { if (!time) time = 1000; speed = speed || 10; power = power || 10; - var shakeInfo = {duration: parseInt(time / 10), speed: speed, power: power, direction: 1, shake: 0}; + var shakeInfo = { duration: parseInt(time / 10), speed: speed, power: power, direction: 1, shake: 0 }; if (direction == 'random') { direction = ['horizontal', 'vertical', 'diagonal1', 'diagonal2'][Math.floor(Math.random() * 4)]; } @@ -3595,12 +3601,12 @@ events.prototype._vibrate_update = function (shakeInfo) { } /////// 使用事件让勇士移动。这个函数将不会触发任何事件 ////// -events.prototype.eventMoveHero = function(steps, time, callback) { +events.prototype.eventMoveHero = function (steps, time, callback) { time = time || core.values.moveSpeed; - var step = 0, moveSteps = (steps||[]).map(function (t) { - return [t.split(':')[0], parseInt(t.split(':')[1]||"1")]; + var step = 0, moveSteps = (steps || []).map(function (t) { + return [t.split(':')[0], parseInt(t.split(':')[1] || "1")]; }).filter(function (t) { - return ['up','down','left','right','forward','backward','leftup','leftdown','rightup','rightdown','speed'].indexOf(t[0])>=0 + return ['up', 'down', 'left', 'right', 'forward', 'backward', 'leftup', 'leftdown', 'rightup', 'rightdown', 'speed'].indexOf(t[0]) >= 0 && !(t[0] == 'speed' && t[1] < 16); }); core.status.heroMoving = -1; @@ -3611,8 +3617,8 @@ events.prototype.eventMoveHero = function(steps, time, callback) { if (callback) callback(); } - var animate=window.setInterval(function() { - if (moveSteps.length==0) { + var animate = window.setInterval(function () { + if (moveSteps.length == 0) { delete core.animateFrame.asyncId[animate]; clearInterval(animate); cb(); @@ -3629,7 +3635,7 @@ events.prototype.eventMoveHero = function(steps, time, callback) { step = 0; } }, core.status.replay.speed == 24 ? 1 : time / 8 / core.status.replay.speed); - + core.animateFrame.lastAsyncId = animate; core.animateFrame.asyncId[animate] = cb; } @@ -3674,9 +3680,9 @@ events.prototype.jumpHero = function (ex, ey, time, callback) { var sx = core.getHeroLoc('x'), sy = core.getHeroLoc('y'); if (ex == null) ex = sx; if (ey == null) ey = sy; - var sx=core.status.hero.loc.x, sy=core.status.hero.loc.y; - if (!core.isset(ex)) ex=sx; - if (!core.isset(ey)) ey=sy; + var sx = core.status.hero.loc.x, sy = core.status.hero.loc.y; + if (!core.isset(ex)) ex = sx; + if (!core.isset(ey)) ey = sy; var jumpInfo = core.maps.__generateJumpInfo(sx, sy, ex, ey, time || 500); jumpInfo.icon = core.material.icons.hero[core.getHeroLoc('direction')]; jumpInfo.width = core.material.icons.hero.width || 32; @@ -3723,7 +3729,7 @@ events.prototype.setHeroIcon = function (name, noDraw) { name = core.getMappedName(name); var img = core.material.images.images[name]; if (!img) { - console.error("找不到图片: "+img); + console.error("找不到图片: " + img); return; } if (core.material.images.hero == img) return; @@ -3747,7 +3753,7 @@ events.prototype.checkLvUp = function () { } events.prototype._checkLvUp_check = function () { - if (core.flags.statusBarItems.indexOf('enableLevelUp')<0 || !core.firstData.levelUp + if (core.flags.statusBarItems.indexOf('enableLevelUp') < 0 || !core.firstData.levelUp || core.status.hero.lv >= core.firstData.levelUp.length) return null; // 计算下一个所需要的数值 var next = (core.firstData.levelUp[core.status.hero.lv] || {}); diff --git a/libs/maps.js b/libs/maps.js index 01571131..c1c7b5f9 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -2,7 +2,7 @@ "use strict"; -function maps() { +function maps () { this._init(); } @@ -53,7 +53,7 @@ maps.prototype.loadFloor = function (floorId, map) { var floor = core.floors[floorId]; if (!map) map = core.cloneArray(floor.map); if (map instanceof Array) { - map = {"map": map}; + map = { "map": map }; } if (!map.map) map.map = core.cloneArray(floor.map); var content = {}; @@ -76,7 +76,7 @@ maps.prototype.loadFloor = function (floorId, map) { maps.prototype._loadFloor_doNotCopy = function () { return [ "firstArrive", "eachArrive", "blocks", "parallelDo", "map", "bgmap", "fgmap", - "events", "changeFloor", "beforeBattle", "afterBattle", "afterGetItem", "afterOpenDoor", + "events", "changeFloor", "beforeBattle", "afterBattle", "afterGetItem", "afterOpenDoor", "cannotMove", "cannotMoveIn" ]; } @@ -84,7 +84,7 @@ maps.prototype._loadFloor_doNotCopy = function () { /// 根据需求解析出blocks maps.prototype.extractBlocks = function (map) { map = map || core.status.floorId; - if (typeof map == 'string') map = (core.status.maps||{})[map]; + if (typeof map == 'string') map = (core.status.maps || {})[map]; if (!map) return; if (map.blocks) return; if (map.deleted) { @@ -104,7 +104,7 @@ maps.prototype._mapIntoBlocks = function (map, floor, floorId) { var number = (map[i] || [])[j] || 0, block; if (main.mode == 'editor') { if (!number) continue; - block = {x: j, y: i, id: number, event: this.getBlockByNumber(number).event}; + block = { x: j, y: i, id: number, event: this.getBlockByNumber(number).event }; } else { block = this.initBlock(j, i, number, true, floor); } @@ -147,7 +147,7 @@ maps.prototype.extractBlocksForUI = function (map, flags) { var event = (floor.events || {})[j + "," + i]; if (event != null && event.filter != null) filter = core.clone(event.filter); } - map.blocks.push(Object.assign({}, this.getBlockByNumber(number), {x: j, y: i, opacity: opacity, filter: filter})); + map.blocks.push(Object.assign({}, this.getBlockByNumber(number), { x: j, y: i, opacity: opacity, filter: filter })); } } } @@ -202,15 +202,15 @@ maps.prototype.initBlock = function (x, y, id, addInfo, eventFloor) { opacity = this._getBlockOpacityFromFlag(eventFloor.floorId, x, y); filter = this._getBlockFilterFromFlag(eventFloor.floorId, x, y); } - var block = {'x': x, 'y': y, 'id': id}; + var block = { 'x': x, 'y': y, 'id': id }; if (disable != null) block.disable = disable; if (opacity != null) block.opacity = opacity; if (filter != null) block.filter = filter; - if (id == 17) block.event = {"cls": "terrains", "id": "airwall", "cannotIn":["up", "down", "left", "right"]}; + if (id == 17) block.event = { "cls": "terrains", "id": "airwall", "cannotIn": ["up", "down", "left", "right"] }; else if (id in this.blocksInfo) block.event = JSON.parse(JSON.stringify(this.blocksInfo[id])); - else if (core.icons.getTilesetOffset(id)) block.event = {"cls": "tileset", "id": "X" + id}; - else block.event = {'cls': 'terrains', 'id': 'none', 'noPass': false}; + else if (core.icons.getTilesetOffset(id)) block.event = { "cls": "tileset", "id": "X" + id }; + else block.event = { 'cls': 'terrains', 'id': 'none', 'noPass': false }; if (block.event.noPass == null) { if (block.event.canPass == null) { @@ -222,7 +222,7 @@ maps.prototype.initBlock = function (x, y, id, addInfo, eventFloor) { delete block.event.canPass; // 增加怪物的faceIds - if (block.event.cls.indexOf("enemy") ==0 ) { + if (block.event.cls.indexOf("enemy") == 0) { var enemy = core.material.enemys[block.event.id]; if (enemy && enemy.faceIds) { block.event.faceIds = enemy.faceIds; @@ -233,7 +233,7 @@ maps.prototype.initBlock = function (x, y, id, addInfo, eventFloor) { if (eventFloor) { this._addEvent(block, x, y, (eventFloor.events || {})[x + "," + y]); var changeFloor = (eventFloor.changeFloor || {})[x + "," + y]; - if (changeFloor) this._addEvent(block, x, y, {"trigger": "changeFloor", "data": changeFloor}); + if (changeFloor) this._addEvent(block, x, y, { "trigger": "changeFloor", "data": changeFloor }); } if (main.mode == 'editor') delete block.disable; return block; @@ -260,10 +260,10 @@ maps.prototype._addEvent = function (block, x, y, event) { if (!event) return; // event是字符串或数组? if (typeof event == "string") { - event = {"data": [event]}; + event = { "data": [event] }; } else if (event instanceof Array) { - event = {"data": event}; + event = { "data": event }; } event.data = event.data || []; @@ -337,7 +337,7 @@ maps.prototype._processInvalidMap = function (mapArr, width, height) { } for (var j = 0; j < height; ++j) { for (var i = 0; i < width; ++i) { - if (j < mapArr.length && i < mapArr[j].length) + if (j < mapArr.length && i < mapArr[j].length) map[j][i] = mapArr[j][i]; } } @@ -352,7 +352,7 @@ maps.prototype._getBlockOpacityFromFlag = function (floorId, x, y, flags) { if (!floorId) return null; if ((flags.__removed__ || []).indexOf(floorId) >= 0) return null; var index = x + y * core.floors[floorId].width; - return (__opacity__[floorId]||{})[index]; + return (__opacity__[floorId] || {})[index]; } maps.prototype._getBlockFilterFromFlag = function (floorId, x, y, flags) { @@ -363,7 +363,7 @@ maps.prototype._getBlockFilterFromFlag = function (floorId, x, y, flags) { if (!floorId) return null; if ((flags.__removed__ || []).indexOf(floorId) >= 0) return null; var index = x + y * core.floors[floorId].width; - return core.clone((__filter__[floorId]||{})[index]); + return core.clone((__filter__[floorId] || {})[index]); } ////// 设置某个点的不透明度 ////// @@ -447,10 +447,10 @@ maps.prototype.setMapBlockDisabled = function (floorId, x, y, disabled) { if (!window.flags.__disabled__) window.flags.__disabled__ = {}; if ((window.flags.__removed__ || []).indexOf(floorId) >= 0) return; var __disabled__ = window.flags.__disabled__ || {}; - if (!__disabled__[floorId]) __disabled__[floorId] = [[],[]]; + if (!__disabled__[floorId]) __disabled__[floorId] = [[], []]; var index = x + y * core.floors[floorId].width; - __disabled__[floorId][0] = __disabled__[floorId][0].filter(function (x) {return x != index}); - __disabled__[floorId][1] = __disabled__[floorId][1].filter(function (x) {return x != index}); + __disabled__[floorId][0] = __disabled__[floorId][0].filter(function (x) { return x != index }); + __disabled__[floorId][1] = __disabled__[floorId][1].filter(function (x) { return x != index }); if (disabled == null) return; if (disabled) __disabled__[floorId][0].push(index); else __disabled__[floorId][1].push(index); @@ -525,7 +525,7 @@ maps.prototype.loadMap = function (data, floorId, flags) { if (!floorId) { var map = {}; core.floorIds.forEach(function (id) { - if (core.inArray((flags||{}).__removed__, id)) { + if (core.inArray((flags || {}).__removed__, id)) { data[id] = { deleted: true, canFlyTo: false, canFlyFrom: false, cannotViewMap: true }; } map[id] = core.maps.loadFloor(id, data[id]); @@ -601,7 +601,7 @@ maps.prototype._getMapArrayFromBlocks = function (blockArray, width, height, sho ////// 以x,y的形式返回每个点的事件 ////// maps.prototype.getMapBlocksObj = function (floorId, noCache) { floorId = floorId || core.status.floorId; - if (core.status.mapBlockObjs[floorId] && !noCache) + if (core.status.mapBlockObjs[floorId] && !noCache) return core.status.mapBlockObjs[floorId]; var obj = {}; @@ -630,10 +630,10 @@ maps.prototype._getBgFgMapArray = function (name, floorId, noCache) { for (var y = 0; y < height; ++y) { if (arr[y] == null) arr[y] = Array(width).fill(0); } - (core.getFlag('__'+name+'v__', {})[floorId] || []).forEach(function (one) { + (core.getFlag('__' + name + 'v__', {})[floorId] || []).forEach(function (one) { arr[one[1]][one[0]] = one[2] || 0; }); - (core.getFlag('__'+name+'d__', {})[floorId] || []).forEach(function (one) { + (core.getFlag('__' + name + 'd__', {})[floorId] || []).forEach(function (one) { arr[one[1]][one[0]] = 0; }); if (main.mode == 'editor') { @@ -701,7 +701,7 @@ maps.prototype.generateMovableArray = function (floorId) { maps.prototype._generateMovableArray_arrays = function (floorId) { return { - bgArray: this.getBgMapArray(floorId), + bgArray: this.getBgMapArray(floorId), fgArray: this.getFgMapArray(floorId), eventArray: this.getMapArray(floorId) }; @@ -740,7 +740,7 @@ maps.prototype._canMoveHero_checkPoint = function (x, y, direction, floorId, arr // 4. 检查是否能进将死的领域 if (floorId == core.status.floorId && !core.flags.canGoDeadZone && !core.status.lockControl && - Math.max(core.status.hero.hp, 1) <= ((core.status.checkBlock.damage||{})[nx + "," + ny]||0) && arrays.eventArray[ny][nx] == 0) + Math.max(core.status.hero.hp, 1) <= ((core.status.checkBlock.damage || {})[nx + "," + ny] || 0) && arrays.eventArray[ny][nx] == 0) return false; return true; @@ -760,7 +760,7 @@ maps.prototype._canMoveHero_checkCannotInOut = function (number, name, direction ////// 能否瞬间移动 ////// maps.prototype.canMoveDirectly = function (destX, destY) { - return this.canMoveDirectlyArray([[destX,destY]])[0]; + return this.canMoveDirectlyArray([[destX, destY]])[0]; } maps.prototype.canMoveDirectlyArray = function (locs, canMoveArray) { @@ -888,12 +888,12 @@ maps.prototype.automaticRoute = function (destX, destY) { if (destX == startX && destY == startY) return []; // BFS找寻最短路径 var route = this._automaticRoute_bfs(startX, startY, destX, destY); - if (route[destX+","+destY] == null) return []; + if (route[destX + "," + destY] == null) return []; // 路径数组转换 var ans = [], nowX = destX, nowY = destY; while (nowX != startX || nowY != startY) { var dir = route[nowX + "," + nowY]; - ans.push({'direction': dir, 'x': nowX, 'y': nowY}); + ans.push({ 'direction': dir, 'x': nowX, 'y': nowY }); nowX -= core.utils.scan[dir].x; nowY -= core.utils.scan[dir].y; } @@ -904,28 +904,28 @@ maps.prototype.automaticRoute = function (destX, destY) { maps.prototype._automaticRoute_bfs = function (startX, startY, destX, destY) { var route = {}, canMoveArray = this.generateMovableArray(); // 使用优先队列 - var queue = new PriorityQueue({comparator: function (a,b) { return a.depth - b.depth; }}); + var queue = new PriorityQueue({ comparator: function (a, b) { return a.depth - b.depth; } }); route[startX + "," + startY] = ''; - queue.queue({depth: 0, x: startX, y: startY}); + queue.queue({ depth: 0, x: startX, y: startY }); var blocks = core.getMapBlocksObj(); - while (queue.length!=0) { + while (queue.length != 0) { var curr = queue.dequeue(), deep = curr.depth, nowX = curr.x, nowY = curr.y; for (var direction in core.utils.scan) { if (!core.inArray(canMoveArray[nowX][nowY], direction)) continue; var nx = nowX + core.utils.scan[direction].x; var ny = nowY + core.utils.scan[direction].y; - if (nx<0 || nx>=core.bigmap.width || ny<0 || ny>=core.bigmap.height || route[nx+","+ny] != null) continue; + if (nx < 0 || nx >= core.bigmap.width || ny < 0 || ny >= core.bigmap.height || route[nx + "," + ny] != null) continue; // 重点 if (nx == destX && ny == destY) { - route[nx+","+ny] = direction; + route[nx + "," + ny] = direction; break; } // 不可通行 if (core.noPass(nx, ny)) continue; - route[nx+","+ny] = direction; - queue.queue({depth: deep + this._automaticRoute_deepAdd(nx, ny, blocks), x: nx, y: ny}); + route[nx + "," + ny] = direction; + queue.queue({ depth: deep + this._automaticRoute_deepAdd(nx, ny, blocks), x: nx, y: ny }); } - if (route[destX+","+destY] != null) break; + if (route[destX + "," + destY] != null) break; } return route; } @@ -933,7 +933,7 @@ maps.prototype._automaticRoute_bfs = function (startX, startY, destX, destY) { maps.prototype._automaticRoute_deepAdd = function (x, y, blocks) { // 判定每个可通行点的损耗值,越高越应该绕路 var deepAdd = 1; - var block = blocks[x+","+y]; + var block = blocks[x + "," + y]; if (block && !block.disable) { var id = block.event.id; // 绕过亮灯 @@ -946,9 +946,9 @@ maps.prototype._automaticRoute_deepAdd = function (x, y, blocks) { // if (block.event.trigger == 'changeFloor') deepAdd+=10; } // 绕过存在伤害的地方 - deepAdd += (core.status.checkBlock.damage[x+","+y]||0) * 100; + deepAdd += (core.status.checkBlock.damage[x + "," + y] || 0) * 100; // 绕过捕捉 - if (core.status.checkBlock.ambush[x+","+y]) deepAdd += 1000; + if (core.status.checkBlock.ambush[x + "," + y]) deepAdd += 1000; return deepAdd; } @@ -973,7 +973,7 @@ maps.prototype._getBigImageInfo = function (bigImage, face, animate) { // case "right": dx = 32 - per_width; dy = 32 - per_height; break; } - return {sx: sx, sy: sy, per_width: per_width, per_height: per_height, face: face, dx: dx, dy: dy}; + return { sx: sx, sy: sy, per_width: per_width, per_height: per_height, face: face, dx: dx, dy: dy }; } ////// 绘制一个图块 ////// @@ -1025,7 +1025,7 @@ maps.prototype._drawBlockInfo_bigImage = function (blockInfo, x, y, ctx) { var px = 32 * x - core.bigmap.offsetX; var py = 32 * y - core.bigmap.offsetY; - + // 上半部分 - 会遮挡勇士;z值高于event2,为51 var header = "_bigImage_header_" + x + "_" + y; // 下半部分 - 会被勇士遮挡;z值高于event,为31 @@ -1172,7 +1172,7 @@ maps.prototype.redrawMap = function () { core.bigmap.canvas.forEach(function (one) { core.clearMap(one); }); - this._drawMap_drawAll(null, {redraw: true}); + this._drawMap_drawAll(null, { redraw: true }); core.drawDamage(); } @@ -1211,7 +1211,7 @@ maps.prototype._drawMap_drawBlockInfo = function (ctx, block, blockInfo, arr, co var bigImageInfo = core.maps._getBigImageInfo(blockInfo.bigImage, blockInfo.face, 0); var per_width = bigImageInfo.per_width, per_height = bigImageInfo.per_height; core.maps._drawBlockInfo_drawWithFilter(block, ctx, function () { - core.drawImage(ctx, blockInfo.bigImage, bigImageInfo.sx, bigImageInfo.sy, per_width, per_height, + core.drawImage(ctx, blockInfo.bigImage, bigImageInfo.sx, bigImageInfo.sy, per_width, per_height, 32 * block.x + bigImageInfo.dx, 32 * block.y + bigImageInfo.dy, per_width, per_height); }); }); @@ -1232,7 +1232,7 @@ maps.prototype._drawMap_drawBlockInfo = function (ctx, block, blockInfo, arr, co maps.prototype.drawBg = function (floorId, config) { floorId = floorId || core.status.floorId; if (config == null) config = {}; - if (typeof config == 'string' || config.canvas) config = {ctx: config}; + if (typeof config == 'string' || config.canvas) config = { ctx: config }; config = Object.assign({}, config); if (config.ctx == null) { config.onMap = true; @@ -1286,7 +1286,7 @@ maps.prototype._drawBg_drawBackground = function (floorId, config) { maps.prototype.drawEvents = function (floorId, blocks, config) { floorId = floorId || core.status.floorId; if (config == null) config = {}; - if (typeof config == 'string' || config.canvas) config = {ctx: config}; + if (typeof config == 'string' || config.canvas) config = { ctx: config }; config = Object.assign({}, config); if (config.ctx == null) { config.onMap = true; @@ -1342,7 +1342,7 @@ maps.prototype.drawEvents = function (floorId, blocks, config) { maps.prototype.drawFg = function (floorId, config) { floorId = floorId || core.status.floorId; if (config == null) config = {}; - if (typeof config == 'string' || config.canvas) config = {ctx: config}; + if (typeof config == 'string' || config.canvas) config = { ctx: config }; config = Object.assign({}, config); if (config.ctx == null) { config.onMap = true; @@ -1444,14 +1444,14 @@ maps.prototype._drawFloorImages_gif = function (image, dx, dy) { maps.prototype._drawFloorImage = function (ctx, name, one, image, currStatus, onMap) { var height = image.height; - var imageName = one.name + (one.reverse||''); + var imageName = one.name + (one.reverse || ''); var width = parseInt((one.w == null ? image.width : one.w) / (one.frame || 1)); var height = one.h == null ? image.height : one.h; var sx = (one.sx || 0) + (currStatus || 0) % (one.frame || 1) * width; var sy = one.sy || 0; var x = one.x || 0, y = one.y || 0; if (onMap && core.bigmap.v2) { - if (x > 32 * core.bigmap.posX + core.__PIXELS__ + 32 || x + width < 32 * core.bigmap.posX - 32 + if (x > 32 * core.bigmap.posX + core.__PIXELS__ + 32 || x + width < 32 * core.bigmap.posX - 32 || y > 32 * core.bigmap.posX + core.__PIXELS__ + 32 || y + height < 32 * core.bigmap.posY - 32) { return; } @@ -1483,111 +1483,112 @@ maps.prototype._drawAutotile = function (ctx, mapArr, block, size, left, top, st status = status || 0; status %= parseInt(autotile.width / 96); var done = {}; - var isGrass = function(x,y){ - if(core.maps._drawAutotile_getAutotileAroundId(mapArr[yy][xx],x,y,mapArr)){ + var isGrass = function (x, y) { + if (core.maps._drawAutotile_getAutotileAroundId(mapArr[yy][xx], x, y, mapArr)) { return 1; - }else{ + } else { return 0; } } var iG = []; - [-1,0,1].forEach(function(_x){ - iG[_x] = []; - [-1,0,1].forEach(function(_y){ + [-1, 0, 1].forEach(function (_x) { + iG[_x] = []; + [-1, 0, 1].forEach(function (_y) { iG[_x][_y] = isGrass(xx + _x, yy + _y); - })}); - if(iG[-1][-1] + iG[0][-1] + iG[0][0] + iG[-1][0] == 3 && !iG[-1][-1]){ + }) + }); + if (iG[-1][-1] + iG[0][-1] + iG[0][0] + iG[-1][0] == 3 && !iG[-1][-1]) { this._drawAutotile_render(ctx, xx * size + left, yy * size + top, size, autotile, status, 16, null, onMap); done[0] = true; } - if(iG[0][-1] + iG[1][-1] + iG[1][0] + iG[0][0] == 3 && !iG[1][-1]){ - this._drawAutotile_render(ctx, xx * size + left + size/2, yy * size + top, size, autotile, status, 17, null, onMap); + if (iG[0][-1] + iG[1][-1] + iG[1][0] + iG[0][0] == 3 && !iG[1][-1]) { + this._drawAutotile_render(ctx, xx * size + left + size / 2, yy * size + top, size, autotile, status, 17, null, onMap); done[1] = true; } - if(iG[0][0] + iG[1][0] + iG[1][1] + iG[0][1] == 3 && !iG[1][1]){ - this._drawAutotile_render(ctx, xx * size + left+size/2, yy * size + top + size/2, size, autotile, status, 18, null, onMap); + if (iG[0][0] + iG[1][0] + iG[1][1] + iG[0][1] == 3 && !iG[1][1]) { + this._drawAutotile_render(ctx, xx * size + left + size / 2, yy * size + top + size / 2, size, autotile, status, 18, null, onMap); done[3] = true; } - if(iG[0-1][0] + iG[0][0] + iG[0][1] + iG[-1][1] == 3 && !iG[-1][1]){ - this._drawAutotile_render(ctx, xx * size + left, yy * size + top + size/2, size, autotile, status, 19, null, onMap); + if (iG[0 - 1][0] + iG[0][0] + iG[0][1] + iG[-1][1] == 3 && !iG[-1][1]) { + this._drawAutotile_render(ctx, xx * size + left, yy * size + top + size / 2, size, autotile, status, 19, null, onMap); done[2] = true; } var _id = iG[0][-1] + 2 * iG[-1][0] + 4 * iG[0][1] + 8 * iG[1][0]; - this._drawAutotile_render(ctx, xx * size, yy * size, size, autotile, status, _id, done, onMap); + this._drawAutotile_render(ctx, xx * size, yy * size, size, autotile, status, _id, done, onMap); } -maps.prototype._drawAutotile_render = function(canvas, x, y, size, autotile, status, index, done, onMap) { +maps.prototype._drawAutotile_render = function (canvas, x, y, size, autotile, status, index, done, onMap) { if (onMap) { x -= 32 * core.bigmap.posX; y -= 32 * core.bigmap.posY; } var indexData = [[[96 * status, 0, 32, 32, x, y, size, size],], - [[96 * status, 3 * 32, 16, 32, x, y, size / 2, size],[96 * status + 2 * 32 + 16, 3 * 32, 16, 32, x + size / 2, y, size / 2, size],], - [[96 * status + 2 * 32, 32, 32, 16, x, y, size, size / 2],[96 * status + 2 * 32, 3 * 32 + 16, 32, 16, x, y + size / 2, size, size / 2],], - [[96 * status + 2 * 32, 3 * 32, 32, 32, x, y, size, size],], - [[96 * status, 32, 16, 32, x, y, size / 2, size],[96 * status + 2 * 32 + 16, 32, 16, 32, x + size / 2, y, size / 2, size],], - [[96 * status, 2 * 32, 16, 32, x, y, size / 2, size],[96 * status + 2 * 32 + 16, 2 * 32, 16, 32, x + size / 2, y, size / 2, size],], - [[96 * status + 2 * 32, 32, 32, 32, x, y, size, size],], - [[96 * status + 2 * 32, 2 * 32, 32, 32, x, y, size, size],], - [[96 * status, 32, 32, 16, x, y, size, size / 2],[96 * status, 3 * 32 + 16, 32, 16, x, y + size / 2, size, size / 2],], - [[96 * status, 3 * 32, 32, 32, x, y, size, size],], - [[96 * status + 32, 32, 32, 16, x, y, size, size / 2],[96 * status + 32, 3 * 32 + 16, 32, 16, x, y + size / 2, size, size / 2],], - [[96 * status + 32, 3 * 32, 32, 32, x, y, size, size],], - [[96 * status, 32, 32, 32, x, y, size, size],], - [[96 * status, 2 * 32, 32, 32, x, y, size, size],], - [[96 * status + 32, 32, 32, 32, x, y, size, size],], - [[96 * status + 32, 2 * 32, 32, 32, x, y, size, size],], - [[96 * status + 2 * 32, 0, 16, 16, x, y, size / 2, size / 2],], - [[96 * status + 2 * 32 + 16, 0, 16, 16, x, y, size / 2, size / 2],], - [[96 * status + 2 * 32 + 16, 16, 16, 16, x, y, size / 2, size / 2],], - [[96 * status + 2 * 32, 16, 16, 16, x, y, size / 2, size / 2],], + [[96 * status, 3 * 32, 16, 32, x, y, size / 2, size], [96 * status + 2 * 32 + 16, 3 * 32, 16, 32, x + size / 2, y, size / 2, size],], + [[96 * status + 2 * 32, 32, 32, 16, x, y, size, size / 2], [96 * status + 2 * 32, 3 * 32 + 16, 32, 16, x, y + size / 2, size, size / 2],], + [[96 * status + 2 * 32, 3 * 32, 32, 32, x, y, size, size],], + [[96 * status, 32, 16, 32, x, y, size / 2, size], [96 * status + 2 * 32 + 16, 32, 16, 32, x + size / 2, y, size / 2, size],], + [[96 * status, 2 * 32, 16, 32, x, y, size / 2, size], [96 * status + 2 * 32 + 16, 2 * 32, 16, 32, x + size / 2, y, size / 2, size],], + [[96 * status + 2 * 32, 32, 32, 32, x, y, size, size],], + [[96 * status + 2 * 32, 2 * 32, 32, 32, x, y, size, size],], + [[96 * status, 32, 32, 16, x, y, size, size / 2], [96 * status, 3 * 32 + 16, 32, 16, x, y + size / 2, size, size / 2],], + [[96 * status, 3 * 32, 32, 32, x, y, size, size],], + [[96 * status + 32, 32, 32, 16, x, y, size, size / 2], [96 * status + 32, 3 * 32 + 16, 32, 16, x, y + size / 2, size, size / 2],], + [[96 * status + 32, 3 * 32, 32, 32, x, y, size, size],], + [[96 * status, 32, 32, 32, x, y, size, size],], + [[96 * status, 2 * 32, 32, 32, x, y, size, size],], + [[96 * status + 32, 32, 32, 32, x, y, size, size],], + [[96 * status + 32, 2 * 32, 32, 32, x, y, size, size],], + [[96 * status + 2 * 32, 0, 16, 16, x, y, size / 2, size / 2],], + [[96 * status + 2 * 32 + 16, 0, 16, 16, x, y, size / 2, size / 2],], + [[96 * status + 2 * 32 + 16, 16, 16, 16, x, y, size / 2, size / 2],], + [[96 * status + 2 * 32, 16, 16, 16, x, y, size / 2, size / 2],], ]; var data = indexData[index]; - if(index>=16){ // 拐角直接绘制 - core.drawImage(canvas, autotile, data[0][0], data[0][1], data[0][2], data[0][3], data[0][4], data[0][5], size/2, size/2); - }else{ // 非拐角要根据是否已经绘制进行切分后绘制 + if (index >= 16) { // 拐角直接绘制 + core.drawImage(canvas, autotile, data[0][0], data[0][1], data[0][2], data[0][3], data[0][4], data[0][5], size / 2, size / 2); + } else { // 非拐角要根据是否已经绘制进行切分后绘制 this._drawAutotile_renderCut(canvas, autotile, x, y, size, data, done); } } -maps.prototype._drawAutotile_renderCut = function(canvas, autotile, x, y, size, data, done){ +maps.prototype._drawAutotile_renderCut = function (canvas, autotile, x, y, size, data, done) { var drawData = []; done = done || {}; - if(data.length == 2){ + if (data.length == 2) { var idx = 0; var cut = 0; - for(var i in data){ - if(data[i][2] % 32){ // 是否纵切 + for (var i in data) { + if (data[i][2] % 32) { // 是否纵切 cut = 0; } - else if(data[i][3] % 32){ // 是否横切 + else if (data[i][3] % 32) { // 是否横切 cut = 1; } - if(data[i][0] % 32 || data[i][1] % 32){ // right down + if (data[i][0] % 32 || data[i][1] % 32) { // right down idx = 1; - }else{ // left top + } else { // left top idx = 0; } - if(cut){ + if (cut) { idx *= 2; - if(!done[idx])drawData[idx] = [data[i][0], data[i][1]]; - if(!done[idx + 1])drawData[idx + 1] = [parseInt(data[i][0]) + 16, data[i][1]]; - }else{ - if(!done[idx])drawData[idx] = [data[i][0], data[i][1]]; - if(!done[idx + 2])drawData[idx + 2] = [data[i][0], parseInt(data[i][1]) + 16]; + if (!done[idx]) drawData[idx] = [data[i][0], data[i][1]]; + if (!done[idx + 1]) drawData[idx + 1] = [parseInt(data[i][0]) + 16, data[i][1]]; + } else { + if (!done[idx]) drawData[idx] = [data[i][0], data[i][1]]; + if (!done[idx + 2]) drawData[idx + 2] = [data[i][0], parseInt(data[i][1]) + 16]; } } - }else{ - if(!done[0])drawData[0] = [data[0][0], data[0][1]]; - if(!done[1])drawData[1] = [data[0][0] + 16, data[0][1]]; - if(!done[2])drawData[2] = [data[0][0], data[0][1] + 16]; - if(!done[3])drawData[3] = [data[0][0] + 16, data[0][1] + 16]; + } else { + if (!done[0]) drawData[0] = [data[0][0], data[0][1]]; + if (!done[1]) drawData[1] = [data[0][0] + 16, data[0][1]]; + if (!done[2]) drawData[2] = [data[0][0], data[0][1] + 16]; + if (!done[3]) drawData[3] = [data[0][0] + 16, data[0][1] + 16]; } - for(var i = 0; i<4; i++){ - var dt = drawData[i];if(!dt)continue; - core.drawImage(canvas, autotile, dt[0], dt[1], 16, 16, x + (i % 2) * size / 2, y + parseInt(i / 2) * size / 2, size/2, size/2); + for (var i = 0; i < 4; i++) { + var dt = drawData[i]; if (!dt) continue; + core.drawImage(canvas, autotile, dt[0], dt[1], 16, 16, x + (i % 2) * size / 2, y + parseInt(i / 2) * size / 2, size / 2, size / 2); }; } @@ -1642,12 +1643,12 @@ maps.prototype._drawAutotileAnimate = function (block, animate) { } } else { if (32 * x < core.bigmap.offsetX - 64 || 32 * x > core.bigmap.offsetX + core.__PIXELS__ + 32 - || 32 * y < core.bigmap.offsetY - 64 || 32 * y > core.bigmap.offsetY + core.__PIXELS__ + 32 + 16) { + || 32 * y < core.bigmap.offsetY - 64 || 32 * y > core.bigmap.offsetY + core.__PIXELS__ + 32 + 16) { return; } } - var cv = block.name?core.canvas[block.name]:core.canvas.event; + var cv = block.name ? core.canvas[block.name] : core.canvas.event; cv.clearRect(32 * x - 32 * core.bigmap.posX, 32 * y - 32 * core.bigmap.posY, 32, 32); var alpha = null; if (block.opacity != null) alpha = core.setAlpha(cv, block.opacity); @@ -1710,7 +1711,7 @@ maps.prototype.drawThumbnail = function (floorId, blocks, options) { floorId = floorId || core.status.floorId; if (!floorId) return; options = options || {}; - if (typeof options == 'string' || options.canvas) options = {ctx: options}; + if (typeof options == 'string' || options.canvas) options = { ctx: options }; var ctx = options.ctx; // Step1:绘制到tempCanvas上 this._drawThumbnail_drawTempCanvas(floorId, blocks, options); @@ -1748,7 +1749,7 @@ maps.prototype._drawThumbnail_drawTempCanvas = function (floorId, blocks, option tempCanvas.canvas.height = height * 32; } options.ctx = tempCanvas; - + // 地图过大的缩略图不绘制显伤 if (width * height > core.bigmap.threshold) options.damage = false; @@ -1801,7 +1802,7 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) { var centerX = options.centerX, centerY = options.centerY; if (centerX == null) centerX = Math.floor(width / 2); if (centerY == null) centerY = Math.floor(height / 2); - var tempCanvas = core.bigmap.tempCanvas; + var tempCanvas = core.bigmap.tempCanvas; if (options.all) { var tempWidth = tempCanvas.canvas.width, tempHeight = tempCanvas.canvas.height; @@ -1861,9 +1862,9 @@ maps.prototype.terrainExists = function (x, y, id, floorId) { maps.prototype.stairExists = function (x, y, floorId) { var blockId = this.getBlockId(x, y, floorId); if (blockId == null) return false; - var ids = ['upFloor','downFloor']; - ids = ids.concat(['leftPortal','rightPortal','upPortal','downPortal','portal','starPortal']); - return ids.indexOf(blockId)>=0; + var ids = ['upFloor', 'downFloor']; + ids = ids.concat(['leftPortal', 'rightPortal', 'upPortal', 'downPortal', 'portal', 'starPortal']); + return ids.indexOf(blockId) >= 0; } ////// 当前位置是否在楼梯边 ////// @@ -1920,7 +1921,7 @@ maps.prototype.getBlockOpacity = function (x, y, floorId, showDisable) { maps.prototype.getBlockFilter = function (x, y, floorId, showDisable) { var block = core.getBlock(x, y, floorId, showDisable); if (block == null) return null; - if (block.filter == null) return {blur: 0, hue: 0, grayscale: 0, invert: false, shadow: 0}; + if (block.filter == null) return { blur: 0, hue: 0, grayscale: 0, invert: false, shadow: 0 }; return core.clone(block.filter); } @@ -1975,8 +1976,10 @@ maps.prototype.getBlockInfo = function (block) { if (!doorInfo && bigImage != null) animate = 4; } - return {number: number, id: id, cls: cls, name: name, image: image, posX: posX, doorInfo: doorInfo, - posY: posY, height: height, faceIds: faceIds, animate: animate, face: face, bigImage: bigImage}; + return { + number: number, id: id, cls: cls, name: name, image: image, posX: posX, doorInfo: doorInfo, + posY: posY, height: height, faceIds: faceIds, animate: animate, face: face, bigImage: bigImage + }; } ////// 搜索某个图块出现的所有位置 ////// @@ -1994,7 +1997,7 @@ maps.prototype.searchBlock = function (id, floorId, showDisable) { for (var i = 0; i < core.status.maps[floorId].blocks.length; ++i) { var block = core.status.maps[floorId].blocks[i]; if ((showDisable || !block.disable) && (core.matchWildcard(id, block.event.id) || core.matchRegex(id, block.event.id))) { - result.push({floorId: floorId, x: block.x, y: block.y, block: block}); + result.push({ floorId: floorId, x: block.x, y: block.y, block: block }); } } return result; @@ -2014,7 +2017,7 @@ maps.prototype.searchBlockWithFilter = function (blockFilter, floorId, showDisab for (var i = 0; i < core.status.maps[floorId].blocks.length; ++i) { var block = core.status.maps[floorId].blocks[i]; if ((showDisable || !block.disable) && blockFilter(block)) { - result.push({floorId: floorId, x: block.x, y: block.y, block: block}); + result.push({ floorId: floorId, x: block.x, y: block.y, block: block }); } } return result; @@ -2141,7 +2144,7 @@ maps.prototype.removeBlockByIndex = function (index, floorId) { var blocks = core.status.maps[floorId].blocks, block = blocks[index]; blocks.splice(index, 1); if (core.status.mapBlockObjs[floorId]) - delete core.status.mapBlockObjs[floorId][block.x+","+block.y]; + delete core.status.mapBlockObjs[floorId][block.x + "," + block.y]; core.setMapBlockDisabled(floorId, block.x, block.y, true); this._updateMapArray(floorId, block.x, block.y); } @@ -2175,17 +2178,17 @@ maps.prototype._triggerBgFgMap = function (type, name, loc, floorId, callback) { if (!floorId) return; if (loc.length == 0) return; - var disabled = core.getFlag('__'+name+'d__', {}); + var disabled = core.getFlag('__' + name + 'd__', {}); disabled[floorId] = disabled[floorId] || []; loc.forEach(function (t) { if (type == 'hide') { disabled[floorId].push([t[0], t[1]]); } else { - disabled[floorId] = disabled[floorId].filter(function (one) { return one[0] != t[0] || one[1] != t[1]}); + disabled[floorId] = disabled[floorId].filter(function (one) { return one[0] != t[0] || one[1] != t[1] }); } }) - core.setFlag('__'+name+'d__', disabled); - + core.setFlag('__' + name + 'd__', disabled); + core.status[name + "maps"][floorId] = null; if (floorId == core.status.floorId) { @@ -2247,7 +2250,7 @@ maps.prototype.setBlock = function (number, x, y, floorId) { if (originBlock == null) { core.status.maps[floorId].blocks.push(block); if (core.status.mapBlockObjs[floorId]) - core.status.mapBlockObjs[floorId][block.x+","+block.y] = block; + core.status.mapBlockObjs[floorId][block.x + "," + block.y] = block; core.setMapBlockDisabled(floorId, block.x, block.y, false); delete block.disable; } @@ -2263,7 +2266,7 @@ maps.prototype.setBlock = function (number, x, y, floorId) { core.redrawMap(); } else { if (originEvent != null) { - this._removeBlockFromMap(floorId, {x: x, y: y, event: originEvent}); + this._removeBlockFromMap(floorId, { x: x, y: y, event: originEvent }); } if (!block.disable) { core.drawBlock(block); @@ -2357,7 +2360,7 @@ maps.prototype.animateSetBlocks = function (number, locs, floorId, time, callbac return; } if (typeof locs[0] == 'number' && typeof locs[1] == 'number') - locs = [locs]; + locs = [locs]; var count = locs.length; var _afterSet = function () { @@ -2426,14 +2429,16 @@ maps.prototype.setBgFgBlock = function (name, number, x, y, floorId) { else number = core.getNumberById(number); } - var values = core.getFlag('__'+name+'v__', {}); + var values = core.getFlag('__' + name + 'v__', {}); values[floorId] = (values[floorId] || []).filter(function (one) { return one[0] != x || one[1] != y }); - values[floorId].push([x,y,number]); - core.setFlag('__'+name+'v__', values); + values[floorId].push([x, y, number]); + core.setFlag('__' + name + 'v__', values); core.status[name + "maps"][floorId] = null; - if (floorId == core.status.floorId){ + this._getBgFgMapArray(name, floorId, true); + + if (floorId == core.status.floorId) { core.clearMap(name); if (name.startsWith('bg')) core.drawBg(floorId); else core.drawFg(floorId); @@ -2574,10 +2579,10 @@ maps.prototype.moveBlock = function (x, y, steps, time, keep, callback) { return; } var block = blockArr[0], blockInfo = blockArr[1]; - var moveSteps = (steps||[]).map(function (t) { - return [t.split(':')[0], parseInt(t.split(':')[1]||"1")]; + var moveSteps = (steps || []).map(function (t) { + return [t.split(':')[0], parseInt(t.split(':')[1] || "1")]; }).filter(function (t) { - return ['up','down','left','right','forward','backward','leftup','leftdown','rightup','rightdown','speed'].indexOf(t[0])>=0 + return ['up', 'down', 'left', 'right', 'forward', 'backward', 'leftup', 'leftdown', 'rightup', 'rightdown', 'speed'].indexOf(t[0]) >= 0 && !(t[0] == 'speed' && t[1] < 16) }); var canvases = this._initDetachedBlock(blockInfo, x, y, block.event.animate !== false); @@ -2625,7 +2630,7 @@ maps.prototype._moveBlock_doMove = function (blockInfo, canvases, moveInfo, call else core.maps._moveJumpBlock_finished(blockInfo, canvases, moveInfo, animate, cb); }, moveInfo.per_time); - + core.animateFrame.lastAsyncId = animate; core.animateFrame.asyncId[animate] = cb; } @@ -2706,7 +2711,7 @@ maps.prototype._moveBlock_moving = function (blockInfo, canvases, moveInfo) { if (moveInfo.step == 16) { moveInfo.step = 0; moveInfo.moveSteps[0][1]--; - if (moveInfo.moveSteps[0][1]<=0) { + if (moveInfo.moveSteps[0][1] <= 0) { moveInfo.moveSteps.shift(); } } @@ -2947,7 +2952,7 @@ maps.prototype.drawBoxAnimate = function () { var bigImageInfo = core.maps._getBigImageInfo(obj.bigImage, obj.face, core.status.globalAnimateStatus % 4); var sx = bigImageInfo.sx, sy = bigImageInfo.sy, per_width = bigImageInfo.per_width, per_height = bigImageInfo.per_height; var actual_width = Math.min(per_width, obj.max_width || per_width), actual_height = per_height * actual_width / per_width; - core.drawImage(ctx, obj.bigImage, sx, sy, per_width, per_height, + core.drawImage(ctx, obj.bigImage, sx, sy, per_width, per_height, obj.centerX - actual_width / 2, obj.centerY - actual_height / 2, actual_width, actual_height); } else { var ctx = obj.ctx || 'ui'; @@ -2977,7 +2982,7 @@ maps.prototype.drawAnimate = function (name, x, y, alignWindow, callback) { centerY += core.bigmap.offsetY; } animate.se = animate.se || {}; - if (typeof animate.se == 'string') animate.se = {1: animate.se}; + if (typeof animate.se == 'string') animate.se = { 1: animate.se }; var id = setTimeout(null); core.status.animateObjs.push({ @@ -3006,7 +3011,7 @@ maps.prototype.drawHeroAnimate = function (name, callback) { // 开始绘制 var animate = core.material.animates[name]; animate.se = animate.se || {}; - if (typeof animate.se == 'string') animate.se = {1: animate.se}; + if (typeof animate.se == 'string') animate.se = { 1: animate.se }; var id = setTimeout(null); core.status.animateObjs.push({ @@ -3033,7 +3038,7 @@ maps.prototype._drawAnimateFrame = function (name, animate, centerX, centerY, in var ctx = core.getContextByName(name); if (!ctx) return; var frame = animate.frames[index % animate.frame]; - core.playSound((animate.se||{})[index % animate.frame + 1], (animate.pitch||{})[index % animate.frame + 1]); + core.playSound((animate.se || {})[index % animate.frame + 1], (animate.pitch || {})[index % animate.frame + 1]); var ratio = animate.ratio; frame.forEach(function (t) { var image = animate.images[t.index]; @@ -3051,7 +3056,7 @@ maps.prototype._drawAnimateFrame = function (name, animate, centerX, centerY, in var mirror = t.mirror ? 'x' : null; var angle = t.angle ? -t.angle * Math.PI / 180 : null; core.drawImage(ctx, image, ix, iy, realWidth, realHeight, null, null, null, null, angle, mirror); - + core.setAlpha(ctx, 1); }) } diff --git a/libs/thirdparty/browser-polyfill.min.js b/libs/thirdparty/browser-polyfill.min.js new file mode 100644 index 00000000..79447613 --- /dev/null +++ b/libs/thirdparty/browser-polyfill.min.js @@ -0,0 +1,2 @@ +!function t(e,n,r){function o(s,c){if(!n[s]){if(!e[s]){var u="function"==typeof require&&require;if(!c&&u)return u(s,!0);if(i)return i(s,!0);var a=new Error("Cannot find module '"+s+"'");throw a.code="MODULE_NOT_FOUND",a}var f=n[s]={exports:{}};e[s][0].call(f.exports,function(t){var n=e[s][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s$;$++)if((u||$ in d)&&(f=d[$],l=p(f,$,h),t))if(e)v[$]=l;else if(l)switch(t){case 3:return!0;case 5:return f;case 6:return $;case 2:v.push(f)}else if(s)return!1;return c?-1:i||s?s:v}}},{"./$":16,"./$.ctx":11}],5:[function(t,e){function n(t,e,n){if(!t)throw TypeError(n?e+n:e)}var r=t("./$");n.def=r.assertDefined,n.fn=function(t){if(!r.isFunction(t))throw TypeError(t+" is not a function!");return t},n.obj=function(t){if(!r.isObject(t))throw TypeError(t+" is not an object!");return t},n.inst=function(t,e,n){if(!(t instanceof e))throw TypeError(n+": use the 'new' operator!");return t},e.exports=n},{"./$":16}],6:[function(t,e){var n=t("./$");e.exports=Object.assign||function(t){for(var e=Object(n.assertDefined(t)),r=arguments.length,o=1;r>o;)for(var i,s=n.ES5Object(arguments[o++]),c=n.getKeys(s),u=c.length,a=0;u>a;)e[i=c[a++]]=s[i];return e}},{"./$":16}],7:[function(t,e){function n(t){return i.call(t).slice(8,-1)}var r=t("./$"),o=t("./$.wks")("toStringTag"),i={}.toString;n.classof=function(t){var e,r;return void 0==t?void 0===t?"Undefined":"Null":"string"==typeof(r=(e=Object(t))[o])?r:n(e)},n.set=function(t,e,n){t&&!r.has(t=n?t:t.prototype,o)&&r.hide(t,o,e)},e.exports=n},{"./$":16,"./$.wks":26}],8:[function(t,e){"use strict";function n(t,e){if(!l(t))return("string"==typeof t?"S":"P")+t;if(p(t))return"F";if(!a(t,g)){if(!e)return"E";h(t,g,++w)}return"O"+t[g]}function r(t,e){var r,o=n(e);if("F"!=o)return t[$][o];for(r=t[y];r;r=r.n)if(r.k==e)return r}var o=t("./$"),i=t("./$.ctx"),s=t("./$.uid").safe,c=t("./$.assert"),u=t("./$.iter"),a=o.has,f=o.set,l=o.isObject,h=o.hide,d=u.step,p=Object.isFrozen||o.core.Object.isFrozen,g=s("id"),$=s("O1"),v=s("last"),y=s("first"),m=s("iter"),b=o.DESC?s("size"):"size",w=0;e.exports={getConstructor:function(t,e,n){function s(r){var i=c.inst(this,s,t);f(i,$,o.create(null)),f(i,b,0),f(i,v,void 0),f(i,y,void 0),void 0!=r&&u.forOf(r,e,i[n],i)}return o.mix(s.prototype,{clear:function(){for(var t=this,e=t[$],n=t[y];n;n=n.n)n.r=!0,n.p&&(n.p=n.p.n=void 0),delete e[n.i];t[y]=t[v]=void 0,t[b]=0},"delete":function(t){var e=this,n=r(e,t);if(n){var o=n.n,i=n.p;delete e[$][n.i],n.r=!0,i&&(i.n=o),o&&(o.p=i),e[y]==n&&(e[y]=o),e[v]==n&&(e[v]=i),e[b]--}return!!n},forEach:function(t){for(var e,n=i(t,arguments[1],3);e=e?e.n:this[y];)for(n(e.v,e.k,this);e&&e.r;)e=e.p},has:function(t){return!!r(this,t)}}),o.DESC&&o.setDesc(s.prototype,"size",{get:function(){return c.def(this[b])}}),s},def:function(t,e,o){var i,s,c=r(t,e);return c?c.v=o:(t[v]=c={i:s=n(e,!0),k:e,v:o,p:i=t[v],n:void 0,r:!1},t[y]||(t[y]=c),i&&(i.n=c),t[b]++,"F"!=s&&(t[$][s]=c)),t},getEntry:r,getIterConstructor:function(){return function(t,e){f(this,m,{o:t,k:e})}},next:function(){for(var t=this[m],e=t.k,n=t.l;n&&n.r;)n=n.p;return t.o&&(t.l=n=n?n.n:t.o[y])?"key"==e?d(0,n.k):"value"==e?d(0,n.v):d(0,[n.k,n.v]):(t.o=void 0,d(1))}}},{"./$":16,"./$.assert":5,"./$.ctx":11,"./$.iter":15,"./$.uid":24}],9:[function(t,e){"use strict";function n(t,e){return v.call(t.array,function(t){return t[0]===e})}function r(t){return t[g]||f(t,g,{array:[],get:function(t){var e=n(this,t);return e?e[1]:void 0},has:function(t){return!!n(this,t)},set:function(t,e){var r=n(this,t);r?r[1]=e:this.array.push([t,e])},"delete":function(t){var e=y.call(this.array,function(e){return e[0]===t});return~e&&this.array.splice(e,1),!!~e}})[g]}var o=t("./$"),i=t("./$.uid").safe,s=t("./$.assert"),c=t("./$.iter").forOf,u=o.has,a=o.isObject,f=o.hide,l=Object.isFrozen||o.core.Object.isFrozen,h=0,d=i("id"),p=i("weak"),g=i("leak"),$=t("./$.array-methods"),v=$(5),y=$(6);e.exports={getConstructor:function(t,e,n){function i(r){o.set(s.inst(this,i,t),d,h++),void 0!=r&&c(r,e,this[n],this)}return o.mix(i.prototype,{"delete":function(t){return a(t)?l(t)?r(this)["delete"](t):u(t,p)&&u(t[p],this[d])&&delete t[p][this[d]]:!1},has:function(t){return a(t)?l(t)?r(this).has(t):u(t,p)&&u(t[p],this[d]):!1}}),i},def:function(t,e,n){return l(s.obj(e))?r(t).set(e,n):(u(e,p)||f(e,p,{}),e[p][t[d]]=n),t},leakStore:r,WEAK:p,ID:d}},{"./$":16,"./$.array-methods":4,"./$.assert":5,"./$.iter":15,"./$.uid":24}],10:[function(t,e){"use strict";var n=t("./$"),r=t("./$.def"),o=t("./$.iter"),i=t("./$.assert").inst;e.exports=function(e,s,c,u,a){function f(t,e){var r=p[t];n.FW&&(p[t]=function(t,n){var o=r.call(this,0===t?0:t,n);return e?this:o})}var l=n.g[e],h=l,d=u?"set":"add",p=h&&h.prototype,g={};if(n.isFunction(h)&&(a||!o.BUGGY&&p.forEach&&p.entries)){var $,v=new h,y=v[d](a?{}:-0,1);(o.fail(function(t){new h(t)})||o.DANGER_CLOSING)&&(h=function(t){i(this,h,e);var n=new l;return void 0!=t&&o.forOf(t,u,n[d],n),n},h.prototype=p,n.FW&&(p.constructor=h)),a||v.forEach(function(t,e){$=1/e===-1/0}),$&&(f("delete"),f("has"),u&&f("get")),($||y!==v)&&f(d,!0)}else h=c.getConstructor(e,u,d),n.mix(h.prototype,s);return t("./$.cof").set(h,e),t("./$.species")(h),g[e]=h,r(r.G+r.W+r.F*(h!=l),g),a||o.std(h,e,c.getIterConstructor(),c.next,u?"key+value":"value",!u,!0),h}},{"./$":16,"./$.assert":5,"./$.cof":7,"./$.def":12,"./$.iter":15,"./$.species":21}],11:[function(t,e){var n=t("./$.assert").fn;e.exports=function(t,e,r){if(n(t),~r&&void 0===e)return t;switch(r){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}}},{"./$.assert":5}],12:[function(t,e){function n(t,e){return function(){return t.apply(e,arguments)}}function r(t,e,u){var a,f,l,h,d=t&r.G,p=d?i:t&r.S?i[e]:(i[e]||{}).prototype,g=d?s:s[e]||(s[e]={});d&&(u=e);for(a in u)f=!(t&r.F)&&p&&a in p,l=(f?p:u)[a],h=t&r.B&&f?n(l,i):t&r.P&&c(l)?n(Function.call,l):l,p&&!f&&(d?p[a]=l:delete p[a]&&o.hide(p,a,l)),g[a]!=l&&o.hide(g,a,h)}var o=t("./$"),i=o.g,s=o.core,c=o.isFunction;i.core=s,r.F=1,r.G=2,r.S=4,r.P=8,r.B=16,r.W=32,e.exports=r},{"./$":16}],13:[function(t,e){e.exports=function(t){return t.FW=!0,t.path=t.g,t}},{}],14:[function(t,e){e.exports=function(t,e,n){var r=void 0===n;switch(e.length){case 0:return r?t():t.call(n);case 1:return r?t(e[0]):t.call(n,e[0]);case 2:return r?t(e[0],e[1]):t.call(n,e[0],e[1]);case 3:return r?t(e[0],e[1],e[2]):t.call(n,e[0],e[1],e[2]);case 4:return r?t(e[0],e[1],e[2],e[3]):t.call(n,e[0],e[1],e[2],e[3]);case 5:return r?t(e[0],e[1],e[2],e[3],e[4]):t.call(n,e[0],e[1],e[2],e[3],e[4])}return t.apply(n,e)}},{}],15:[function(t,e){"use strict";function n(t,e){c.hide(t,h,e),d in[]&&c.hide(t,d,e)}function r(t,e,r,o){var i=t.prototype,s=i[h]||i[d]||o&&i[o]||r;if(c.FW&&n(i,s),s!==r){var u=c.getProto(s.call(new t));a.set(u,e+" Iterator",!0),c.FW&&c.has(i,d)&&n(u,c.that)}return p[e]=s,p[e+" Iterator"]=c.that,s}function o(t){var e=c.g.Symbol,n=t[e&&e.iterator||d],r=n||t[h]||p[a.classof(t)];return l(r.call(t))}function i(t){var e=t["return"];void 0!==e&&l(e.call(t))}function s(t,e,n,r){try{return r?e(l(n)[0],n[1]):e(n)}catch(o){throw i(t),o}}var c=t("./$"),u=t("./$.ctx"),a=t("./$.cof"),f=t("./$.def"),l=t("./$.assert").obj,h=t("./$.wks")("iterator"),d="@@iterator",p={},g={},$="keys"in[]&&!("next"in[].keys());n(g,c.that);var v=!0;!function(){try{var t=[1].keys();t["return"]=function(){v=!1},Array.from(t,function(){throw 2})}catch(e){}}();var y=e.exports={BUGGY:$,DANGER_CLOSING:v,fail:function(t){var e=!0;try{var n=[[{},1]],r=n[h](),o=r.next;r.next=function(){return e=!1,o.call(this)},n[h]=function(){return r},t(n)}catch(i){}return e},Iterators:p,prototype:g,step:function(t,e){return{value:e,done:!!t}},stepCall:s,close:i,is:function(t){var e=Object(t),n=c.g.Symbol,r=n&&n.iterator||d;return r in e||h in e||c.has(p,a.classof(e))},get:o,set:n,create:function(t,e,n,r){t.prototype=c.create(r||y.prototype,{next:c.desc(1,n)}),a.set(t,e+" Iterator")},define:r,std:function(t,e,n,o,i,s,u){function a(t){return function(){return new n(this,t)}}y.create(n,e,o);var l,h,d=a("key+value"),p=a("value"),g=t.prototype;if("value"==i?p=r(t,e,p,"values"):d=r(t,e,d,"entries"),i&&(l={entries:d,keys:s?p:a("key"),values:p},f(f.P+f.F*$,e,l),u))for(h in l)h in g||c.hide(g,h,l[h])},forOf:function(t,e,n,r){for(var c,a=o(t),f=u(n,r,e?2:1);!(c=a.next()).done;)if(s(a,f,c.value,e)===!1)return i(a)}}},{"./$":16,"./$.assert":5,"./$.cof":7,"./$.ctx":11,"./$.def":12,"./$.wks":26}],16:[function(t,e){"use strict";function n(t){return isNaN(t=+t)?0:(t>0?p:d)(t)}function r(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}function o(t,e,n){return t[e]=n,t}function i(t){return v?function(e,n,o){return m.setDesc(e,n,r(t,o))}:o}function s(t){return null!==t&&("object"==typeof t||"function"==typeof t)}function c(t){return"function"==typeof t}function u(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}var a="undefined"!=typeof self?self:Function("return this")(),f={},l=Object.defineProperty,h={}.hasOwnProperty,d=Math.ceil,p=Math.floor,g=Math.max,$=Math.min,v=!!function(){try{return 2==l({},"a",{get:function(){return 2}}).a}catch(t){}}(),y=i(1),m=e.exports=t("./$.fw")({g:a,core:f,html:a.document&&document.documentElement,isObject:s,isFunction:c,it:function(t){return t},that:function(){return this},toInteger:n,toLength:function(t){return t>0?$(n(t),9007199254740991):0},toIndex:function(t,e){return t=n(t),0>t?g(t+e,0):$(t,e)},has:function(t,e){return h.call(t,e)},create:Object.create,getProto:Object.getPrototypeOf,DESC:v,desc:r,getDesc:Object.getOwnPropertyDescriptor,setDesc:l,getKeys:Object.keys,getNames:Object.getOwnPropertyNames,getSymbols:Object.getOwnPropertySymbols,assertDefined:u,ES5Object:Object,toObject:function(t){return m.ES5Object(u(t))},hide:y,def:i(0),set:a.Symbol?o:y,mix:function(t,e){for(var n in e)y(t,n,e[n]);return t},each:[].forEach});"undefined"!=typeof __e&&(__e=f),"undefined"!=typeof __g&&(__g=a)},{"./$.fw":13}],17:[function(t,e){var n=t("./$");e.exports=function(t,e){for(var r,o=n.toObject(t),i=n.getKeys(o),s=i.length,c=0;s>c;)if(o[r=i[c++]]===e)return r}},{"./$":16}],18:[function(t,e){var n=t("./$"),r=t("./$.assert").obj;e.exports=function(t){return r(t),n.getSymbols?n.getNames(t).concat(n.getSymbols(t)):n.getNames(t)}},{"./$":16,"./$.assert":5}],19:[function(t,e){"use strict";e.exports=function(t,e,n){var r=e===Object(e)?function(t){return e[t]}:e;return function(e){return String(n?e:this).replace(t,r)}}},{}],20:[function(t,e){var n=t("./$"),r=t("./$.assert");e.exports=Object.setPrototypeOf||("__proto__"in{}?function(e,o){try{o=t("./$.ctx")(Function.call,n.getDesc(Object.prototype,"__proto__").set,2),o({},[])}catch(i){e=!0}return function(t,i){return r.obj(t),r(null===i||n.isObject(i),i,": can't set as prototype!"),e?t.__proto__=i:o(t,i),t}}():void 0)},{"./$":16,"./$.assert":5,"./$.ctx":11}],21:[function(t,e){var n=t("./$");e.exports=function(e){n.DESC&&n.FW&&n.setDesc(e,t("./$.wks")("species"),{configurable:!0,get:n.that})}},{"./$":16,"./$.wks":26}],22:[function(t,e){"use strict";var n=t("./$");e.exports=function(t){return function(e){var r,o,i=String(n.assertDefined(this)),s=n.toInteger(e),c=i.length;return 0>s||s>=c?t?"":void 0:(r=i.charCodeAt(s),55296>r||r>56319||s+1===c||(o=i.charCodeAt(s+1))<56320||o>57343?t?i.charAt(s):r:t?i.slice(s,s+2):(r-55296<<10)+(o-56320)+65536)}}},{"./$":16}],23:[function(t,e){"use strict";function n(){var t=+this;if(c.has(m,t)){var e=m[t];delete m[t],e()}}function r(t){n.call(t.data)}var o,i,s,c=t("./$"),u=t("./$.ctx"),a=t("./$.cof"),f=t("./$.invoke"),l=c.g,h=c.isFunction,d=l.setImmediate,p=l.clearImmediate,g=l.postMessage,$=l.addEventListener,v=l.MessageChannel,y=0,m={},b="onreadystatechange";h(d)&&h(p)||(d=function(t){for(var e=[],n=1;arguments.length>n;)e.push(arguments[n++]);return m[++y]=function(){f(h(t)?t:Function(t),e)},o(y),y},p=function(t){delete m[t]},"process"==a(l.process)?o=function(t){l.process.nextTick(u(n,t,1))}:$&&h(g)&&!c.g.importScripts?(o=function(t){g(t,"*")},$("message",r,!1)):h(v)?(i=new v,s=i.port2,i.port1.onmessage=r,o=u(s.postMessage,s,1)):o=c.g.document&&b in document.createElement("script")?function(t){c.html.appendChild(document.createElement("script"))[b]=function(){c.html.removeChild(this),n.call(t)}}:function(t){setTimeout(u(n,t,1),0)}),e.exports={set:d,clear:p}},{"./$":16,"./$.cof":7,"./$.ctx":11,"./$.invoke":14}],24:[function(t,e){function n(t){return"Symbol("+t+")_"+(++r+Math.random()).toString(36)}var r=0;n.safe=t("./$").g.Symbol||n,e.exports=n},{"./$":16}],25:[function(t,e){var n=t("./$"),r=t("./$.wks")("unscopables");!n.FW||r in[]||n.hide(Array.prototype,r,{}),e.exports=function(t){n.FW&&([][r][t]=!0)}},{"./$":16,"./$.wks":26}],26:[function(t,e){var n=t("./$").g,r={};e.exports=function(e){return r[e]||(r[e]=n.Symbol&&n.Symbol[e]||t("./$.uid").safe("Symbol."+e))}},{"./$":16,"./$.uid":24}],27:[function(t){"use strict";var e=t("./$"),n=t("./$.def"),r=e.toIndex;n(n.P,"Array",{copyWithin:function(t,n){var o=Object(e.assertDefined(this)),i=e.toLength(o.length),s=r(t,i),c=r(n,i),u=arguments[2],a=void 0===u?i:r(u,i),f=Math.min(a-c,i-s),l=1;for(s>c&&c+f>s&&(l=-1,c=c+f-1,s=s+f-1);f-->0;)c in o?o[s]=o[c]:delete o[s],s+=l,c+=l;return o}}),t("./$.unscope")("copyWithin")},{"./$":16,"./$.def":12,"./$.unscope":25}],28:[function(t){"use strict";var e=t("./$"),n=t("./$.def"),r=e.toIndex;n(n.P,"Array",{fill:function(t){for(var n=Object(e.assertDefined(this)),o=e.toLength(n.length),i=r(arguments[1],o),s=arguments[2],c=void 0===s?o:r(s,o);c>i;)n[i++]=t;return n}}),t("./$.unscope")("fill")},{"./$":16,"./$.def":12,"./$.unscope":25}],29:[function(t){var e=t("./$.def");e(e.P,"Array",{findIndex:t("./$.array-methods")(6)}),t("./$.unscope")("findIndex")},{"./$.array-methods":4,"./$.def":12,"./$.unscope":25}],30:[function(t){var e=t("./$.def");e(e.P,"Array",{find:t("./$.array-methods")(5)}),t("./$.unscope")("find")},{"./$.array-methods":4,"./$.def":12,"./$.unscope":25}],31:[function(t){var e=t("./$"),n=t("./$.ctx"),r=t("./$.def"),o=t("./$.iter"),i=o.stepCall;r(r.S+r.F*o.DANGER_CLOSING,"Array",{from:function(t){var r,s,c,u,a=Object(e.assertDefined(t)),f=arguments[1],l=void 0!==f,h=l?n(f,arguments[2],2):void 0,d=0;if(o.is(a))for(u=o.get(a),s=new("function"==typeof this?this:Array);!(c=u.next()).done;d++)s[d]=l?i(u,h,[c.value,d],!0):c.value;else for(s=new("function"==typeof this?this:Array)(r=e.toLength(a.length));r>d;d++)s[d]=l?h(a[d],d):a[d];return s.length=d,s}})},{"./$":16,"./$.ctx":11,"./$.def":12,"./$.iter":15}],32:[function(t){var e=t("./$"),n=t("./$.unscope"),r=t("./$.uid").safe("iter"),o=t("./$.iter"),i=o.step,s=o.Iterators;o.std(Array,"Array",function(t,n){e.set(this,r,{o:e.toObject(t),i:0,k:n})},function(){var t=this[r],e=t.o,n=t.k,o=t.i++;return!e||o>=e.length?(t.o=void 0,i(1)):"key"==n?i(0,o):"value"==n?i(0,e[o]):i(0,[o,e[o]])},"value"),s.Arguments=s.Array,n("keys"),n("values"),n("entries")},{"./$":16,"./$.iter":15,"./$.uid":24,"./$.unscope":25}],33:[function(t){var e=t("./$.def");e(e.S,"Array",{of:function(){for(var t=0,e=arguments.length,n=new("function"==typeof this?this:Array)(e);e>t;)n[t]=arguments[t++];return n.length=e,n}})},{"./$.def":12}],34:[function(t){t("./$.species")(Array)},{"./$.species":21}],35:[function(t){"use strict";var e=t("./$"),n="name",r=e.setDesc,o=Function.prototype;n in o||e.FW&&e.DESC&&r(o,n,{configurable:!0,get:function(){var t=String(this).match(/^\s*function ([^ (]*)/),o=t?t[1]:"";return e.has(this,n)||r(this,n,e.desc(5,o)),o},set:function(t){e.has(this,n)||r(this,n,e.desc(0,t))}})},{"./$":16}],36:[function(t){"use strict";var e=t("./$.collection-strong");t("./$.collection")("Map",{get:function(t){var n=e.getEntry(this,t);return n&&n.v},set:function(t,n){return e.def(this,0===t?0:t,n)}},e,!0)},{"./$.collection":10,"./$.collection-strong":8}],37:[function(t){function e(t){return isFinite(t=+t)&&0!=t?0>t?-e(-t):a(t+f(t*t+1)):t}function n(t){return 0==(t=+t)?t:t>-1e-6&&1e-6>t?t+t*t/2:u(t)-1}var r=1/0,o=t("./$.def"),i=Math.E,s=Math.pow,c=Math.abs,u=Math.exp,a=Math.log,f=Math.sqrt,l=Math.ceil,h=Math.floor,d=Math.sign||function(t){return 0==(t=+t)||t!=t?t:0>t?-1:1};o(o.S,"Math",{acosh:function(t){return(t=+t)<1?0/0:isFinite(t)?a(t/i+f(t+1)*f(t-1)/i)+1:t},asinh:e,atanh:function(t){return 0==(t=+t)?t:a((1+t)/(1-t))/2},cbrt:function(t){return d(t=+t)*s(c(t),1/3)},clz32:function(t){return(t>>>=0)?32-t.toString(2).length:32},cosh:function(t){return(u(t=+t)+u(-t))/2},expm1:n,fround:function(t){return new Float32Array([t])[0]},hypot:function(){for(var t,e=0,n=arguments.length,o=n,i=Array(n),c=-r;n--;){if(t=i[n]=+arguments[n],t==r||t==-r)return r;t>c&&(c=t)}for(c=t||1;o--;)e+=s(i[o]/c,2);return c*f(e)},imul:function(t,e){var n=65535,r=+t,o=+e,i=n&r,s=n&o;return 0|i*s+((n&r>>>16)*s+i*(n&o>>>16)<<16>>>0)},log1p:function(t){return(t=+t)>-1e-8&&1e-8>t?t-t*t/2:a(1+t)},log10:function(t){return a(t)/Math.LN10},log2:function(t){return a(t)/Math.LN2},sign:d,sinh:function(t){return c(t=+t)<1?(n(t)-n(-t))/2:(u(t-1)-u(-t-1))*(i/2)},tanh:function(t){var e=n(t=+t),o=n(-t);return e==r?1:o==r?-1:(e-o)/(u(t)+u(-t))},trunc:function(t){return(t>0?h:l)(t)}})},{"./$.def":12}],38:[function(t){"use strict";function e(t){var e,n;if(i(e=t.valueOf)&&!o(n=e.call(t)))return n;if(i(e=t.toString)&&!o(n=e.call(t)))return n;throw TypeError("Can't convert object to number")}function n(t){if(o(t)&&(t=e(t)),"string"==typeof t&&t.length>2&&48==t.charCodeAt(0)){var n=!1;switch(t.charCodeAt(1)){case 66:case 98:n=!0;case 79:case 111:return parseInt(t.slice(2),n?2:8)}}return+t}var r=t("./$"),o=r.isObject,i=r.isFunction,s="Number",c=r.g[s],u=c,a=c.prototype;!r.FW||c("0o1")&&c("0b1")||(c=function f(t){return this instanceof f?new u(n(t)):n(t)},r.each.call(r.DESC?r.getNames(u):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger".split(","),function(t){r.has(u,t)&&!r.has(c,t)&&r.setDesc(c,t,r.getDesc(u,t))}),c.prototype=a,a.constructor=c,r.hide(r.g,s,c))},{"./$":16}],39:[function(t){function e(t){return!n.isObject(t)&&isFinite(t)&&i(t)===t}var n=t("./$"),r=t("./$.def"),o=Math.abs,i=Math.floor,s=9007199254740991;r(r.S,"Number",{EPSILON:Math.pow(2,-52),isFinite:function(t){return"number"==typeof t&&isFinite(t)},isInteger:e,isNaN:function(t){return t!=t},isSafeInteger:function(t){return e(t)&&o(t)<=s},MAX_SAFE_INTEGER:s,MIN_SAFE_INTEGER:-s,parseFloat:parseFloat,parseInt:parseInt})},{"./$":16,"./$.def":12}],40:[function(t){var e=t("./$.def");e(e.S,"Object",{assign:t("./$.assign")})},{"./$.assign":6,"./$.def":12}],41:[function(t){var e=t("./$.def");e(e.S,"Object",{is:function(t,e){return t===e?0!==t||1/t===1/e:t!=t&&e!=e}})},{"./$.def":12}],42:[function(t){var e=t("./$.def");e(e.S,"Object",{setPrototypeOf:t("./$.set-proto")})},{"./$.def":12,"./$.set-proto":20}],43:[function(t){function e(t,e){var s=(n.core.Object||{})[t]||Object[t],c=0,u={};u[t]=1==e?function(t){return o(t)?s(t):t}:2==e?function(t){return o(t)?s(t):!0}:3==e?function(t){return o(t)?s(t):!1}:4==e?function(t,e){return s(i(t),e)}:5==e?function(t){return s(Object(n.assertDefined(t)))}:function(t){return s(i(t))};try{s("z")}catch(a){c=1}r(r.S+r.F*c,"Object",u)}var n=t("./$"),r=t("./$.def"),o=n.isObject,i=n.toObject;e("freeze",1),e("seal",1),e("preventExtensions",1),e("isFrozen",2),e("isSealed",2),e("isExtensible",3),e("getOwnPropertyDescriptor",4),e("getPrototypeOf",5),e("keys"),e("getOwnPropertyNames")},{"./$":16,"./$.def":12}],44:[function(t){"use strict";var e=t("./$"),n=t("./$.cof"),r={};r[t("./$.wks")("toStringTag")]="z",e.FW&&"z"!=n(r)&&e.hide(Object.prototype,"toString",function(){return"[object "+n.classof(this)+"]"})},{"./$":16,"./$.cof":7,"./$.wks":26}],45:[function(t){"use strict";function e(t){var e=w(t)[a];return void 0!=e?e:t}var n,r=t("./$"),o=t("./$.ctx"),i=t("./$.cof"),s=t("./$.def"),c=t("./$.assert"),u=t("./$.iter"),a=t("./$.wks")("species"),f=t("./$.uid").safe("record"),l=u.forOf,h="Promise",d=r.g,p=d.process,g=p&&p.nextTick||t("./$.task").set,$=d[h],v=$,y=r.isFunction,m=r.isObject,b=c.fn,w=c.obj;y($)&&y($.resolve)&&$.resolve(n=new $(function(){}))==n||function(){function t(t){var e;return m(t)&&(e=t.then),y(e)?e:!1}function e(t){var n,r=t[f],o=r.c,i=0;if(r.h)return!0;for(;o.length>i;)if(n=o[i++],n.fail||e(n.P))return!0}function n(n,r){var o=n.c;(r||o.length)&&g(function(){var s=n.p,c=n.v,u=1==n.s,a=0;if(r&&!e(s))setTimeout(function(){e(s)||("process"==i(p)?p.emit("unhandledRejection",c,s):d.console&&y(console.error)&&console.error("Unhandled promise rejection",c))},1e3);else for(;o.length>a;)!function(e){var r,o,i=u?e.ok:e.fail;try{i?(u||(n.h=!0),r=i===!0?c:i(c),r===e.P?e.rej(TypeError(h+"-chain cycle")):(o=t(r))?o.call(r,e.res,e.rej):e.res(r)):e.rej(c)}catch(s){e.rej(s)}}(o[a++]);o.length=0})}function s(t){var e=this;e.d||(e.d=!0,e=e.r||e,e.v=t,e.s=2,n(e,!0))}function u(e){var r,i,c=this;if(!c.d){c.d=!0,c=c.r||c;try{(r=t(e))?(i={r:c,d:!1},r.call(e,o(u,i,1),o(s,i,1))):(c.v=e,c.s=1,n(c))}catch(a){s.call(i||{r:c,d:!1},a)}}}$=function(t){b(t);var e={p:c.inst(this,$,h),c:[],s:0,d:!1,v:void 0,h:!1};r.hide(this,f,e);try{t(o(u,e,1),o(s,e,1))}catch(n){s.call(e,n)}},r.mix($.prototype,{then:function(t,e){var r=w(w(this).constructor)[a],o={ok:y(t)?t:!0,fail:y(e)?e:!1},i=o.P=new(void 0!=r?r:$)(function(t,e){o.res=b(t),o.rej=b(e)}),s=this[f];return s.c.push(o),s.s&&n(s),i},"catch":function(t){return this.then(void 0,t)}})}(),s(s.G+s.W+s.F*($!=v),{Promise:$}),s(s.S,h,{reject:function(t){return new(e(this))(function(e,n){n(t)})},resolve:function(t){return m(t)&&f in t&&r.getProto(t)===this.prototype?t:new(e(this))(function(e){e(t)})}}),s(s.S+s.F*(u.fail(function(t){$.all(t)["catch"](function(){})})||u.DANGER_CLOSING),h,{all:function(t){var n=e(this),o=[];return new n(function(e,i){l(t,!1,o.push,o);var s=o.length,c=Array(s);s?r.each.call(o,function(t,r){n.resolve(t).then(function(t){c[r]=t,--s||e(c)},i)}):e(c)})},race:function(t){var n=e(this);return new n(function(e,r){l(t,!1,function(t){n.resolve(t).then(e,r)})})}}),i.set($,h),t("./$.species")($)},{"./$":16,"./$.assert":5,"./$.cof":7,"./$.ctx":11,"./$.def":12,"./$.iter":15,"./$.species":21,"./$.task":23,"./$.uid":24,"./$.wks":26}],46:[function(t){function e(t){var e,n=[];for(e in t)n.push(e);i.set(this,a,{o:t,a:n,i:0})}function n(t){return function(e){v(e);try{return t.apply(void 0,arguments),!0}catch(n){return!1}}}function r(t,e){var n,o=arguments.length<3?t:arguments[2],s=d(v(t),e);return s?i.has(s,"value")?s.value:void 0===s.get?void 0:s.get.call(o):h(n=g(t))?r(n,e,o):void 0}function o(t,e,n){var r,s,c=arguments.length<4?t:arguments[3],u=d(v(t),e);if(!u){if(h(s=g(t)))return o(s,e,n,c);u=i.desc(0)}return i.has(u,"value")?u.writable!==!1&&h(c)?(r=d(c,e)||i.desc(0),r.value=n,p(c,e,r),!0):!1:void 0===u.set?!1:(u.set.call(c,n),!0)}var i=t("./$"),s=t("./$.def"),c=t("./$.set-proto"),u=t("./$.iter"),a=t("./$.uid").safe("iter"),f=u.step,l=t("./$.assert"),h=i.isObject,d=i.getDesc,p=i.setDesc,g=i.getProto,$=Function.apply,v=l.obj,y=Object.isExtensible||i.it;u.create(e,"Object",function(){var t,e=this[a],n=e.a;do if(e.i>=n.length)return f(1);while(!((t=n[e.i++])in e.o));return f(0,t)});var m={apply:t("./$.ctx")(Function.call,$,3),construct:function(t,e){var n=l.fn(arguments.length<3?t:arguments[2]).prototype,r=i.create(h(n)?n:Object.prototype),o=$.call(t,r,e);return h(o)?o:r},defineProperty:n(p),deleteProperty:function(t,e){var n=d(v(t),e);return n&&!n.configurable?!1:delete t[e]},enumerate:function(t){return new e(v(t))},get:r,getOwnPropertyDescriptor:function(t,e){return d(v(t),e)},getPrototypeOf:function(t){return g(v(t))},has:function(t,e){return e in t},isExtensible:function(t){return!!y(v(t))},ownKeys:t("./$.own-keys"),preventExtensions:n(Object.preventExtensions||i.it),set:o};c&&(m.setPrototypeOf=function(t,e){return c(v(t),e),!0}),s(s.G,{Reflect:{}}),s(s.S,"Reflect",m)},{"./$":16,"./$.assert":5,"./$.ctx":11,"./$.def":12,"./$.iter":15,"./$.own-keys":18,"./$.set-proto":20,"./$.uid":24}],47:[function(t){var e=t("./$"),n=t("./$.cof"),r=e.g.RegExp,o=r,i=r.prototype;e.FW&&e.DESC&&(function(){try{return"/a/i"==r(/a/g,"i")}catch(t){}}()||(r=function(t,e){return new o("RegExp"==n(t)&&void 0!==e?t.source:t,e)},e.each.call(e.getNames(o),function(t){t in r||e.setDesc(r,t,{configurable:!0,get:function(){return o[t]},set:function(e){o[t]=e}})}),i.constructor=r,r.prototype=i,e.hide(e.g,"RegExp",r)),"g"!=/./g.flags&&e.setDesc(i,"flags",{configurable:!0,get:t("./$.replacer")(/^.*\/(\w*)$/,"$1")})),t("./$.species")(r)},{"./$":16,"./$.cof":7,"./$.replacer":19,"./$.species":21}],48:[function(t){"use strict";var e=t("./$.collection-strong");t("./$.collection")("Set",{add:function(t){return e.def(this,t=0===t?0:t,t)}},e)},{"./$.collection":10,"./$.collection-strong":8}],49:[function(t){var e=t("./$.def");e(e.P,"String",{codePointAt:t("./$.string-at")(!1)})},{"./$.def":12,"./$.string-at":22}],50:[function(t){"use strict";var e=t("./$"),n=t("./$.cof"),r=t("./$.def"),o=e.toLength;r(r.P,"String",{endsWith:function(t){if("RegExp"==n(t))throw TypeError();var r=String(e.assertDefined(this)),i=arguments[1],s=o(r.length),c=void 0===i?s:Math.min(o(i),s);return t+="",r.slice(c-t.length,c)===t}})},{"./$":16,"./$.cof":7,"./$.def":12}],51:[function(t){var e=t("./$.def"),n=t("./$").toIndex,r=String.fromCharCode;e(e.S,"String",{fromCodePoint:function(){for(var t,e=[],o=arguments.length,i=0;o>i;){if(t=+arguments[i++],n(t,1114111)!==t)throw RangeError(t+" is not a valid code point");e.push(65536>t?r(t):r(((t-=65536)>>10)+55296,t%1024+56320))}return e.join("")}})},{"./$":16,"./$.def":12}],52:[function(t){"use strict";var e=t("./$"),n=t("./$.cof"),r=t("./$.def");r(r.P,"String",{includes:function(t){if("RegExp"==n(t))throw TypeError();return!!~String(e.assertDefined(this)).indexOf(t,arguments[1])}})},{"./$":16,"./$.cof":7,"./$.def":12}],53:[function(t){var e=t("./$").set,n=t("./$.string-at")(!0),r=t("./$.uid").safe("iter"),o=t("./$.iter"),i=o.step;o.std(String,"String",function(t){e(this,r,{o:String(t),i:0})},function(){var t,e=this[r],o=e.o,s=e.i;return s>=o.length?i(1):(t=n.call(o,s),e.i+=t.length,i(0,t))})},{"./$":16,"./$.iter":15,"./$.string-at":22,"./$.uid":24}],54:[function(t){var e=t("./$"),n=t("./$.def");n(n.S,"String",{raw:function(t){for(var n=e.toObject(t.raw),r=e.toLength(n.length),o=arguments.length,i=[],s=0;r>s;)i.push(String(n[s++])),o>s&&i.push(String(arguments[s]));return i.join("")}})},{"./$":16,"./$.def":12}],55:[function(t){"use strict";var e=t("./$"),n=t("./$.def");n(n.P,"String",{repeat:function(t){var n=String(e.assertDefined(this)),r="",o=e.toInteger(t);if(0>o||1/0==o)throw RangeError("Count can't be negative");for(;o>0;(o>>>=1)&&(n+=n))1&o&&(r+=n);return r}})},{"./$":16,"./$.def":12}],56:[function(t){"use strict";var e=t("./$"),n=t("./$.cof"),r=t("./$.def");r(r.P,"String",{startsWith:function(t){if("RegExp"==n(t))throw TypeError();var r=String(e.assertDefined(this)),o=e.toLength(Math.min(arguments[1],r.length));return t+="",r.slice(o,o+t.length)===t}})},{"./$":16,"./$.cof":7,"./$.def":12}],57:[function(t){"use strict";function e(t){var e=$[t]=n.set(n.create(l.prototype),p,t);return n.DESC&&d&&n.setDesc(Object.prototype,t,{configurable:!0,set:function(e){u(this,t,e)}}),e}var n=t("./$"),r=t("./$.cof").set,o=t("./$.uid"),i=t("./$.def"),s=t("./$.keyof"),c=n.has,u=n.hide,a=n.getNames,f=n.toObject,l=n.g.Symbol,h=l,d=!1,p=o.safe("tag"),g={},$={};n.isFunction(l)||(l=function(t){if(this instanceof l)throw TypeError("Symbol is not a constructor");return e(o(t))},u(l.prototype,"toString",function(){return this[p]})),i(i.G+i.W,{Symbol:l});var v={"for":function(t){return c(g,t+="")?g[t]:g[t]=l(t)},keyFor:function(t){return s(g,t)},pure:o.safe,set:n.set,useSetter:function(){d=!0},useSimple:function(){d=!1}};n.each.call("hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),function(n){var r=t("./$.wks")(n);v[n]=l===h?r:e(r)}),d=!0,i(i.S,"Symbol",v),i(i.S+i.F*(l!=h),"Object",{getOwnPropertyNames:function(t){for(var e,n=a(f(t)),r=[],o=0;n.length>o;)c($,e=n[o++])||r.push(e);return r},getOwnPropertySymbols:function(t){for(var e,n=a(f(t)),r=[],o=0;n.length>o;)c($,e=n[o++])&&r.push($[e]);return r}}),r(l,"Symbol"),r(Math,"Math",!0),r(n.g.JSON,"JSON",!0)},{"./$":16,"./$.cof":7,"./$.def":12,"./$.keyof":17,"./$.uid":24,"./$.wks":26}],58:[function(t){"use strict";var e=t("./$"),n=t("./$.collection-weak"),r=n.leakStore,o=n.ID,i=n.WEAK,s=e.has,c=e.isObject,u=Object.isFrozen||e.core.Object.isFrozen,a={},f=t("./$.collection")("WeakMap",{get:function(t){if(c(t)){if(u(t))return r(this).get(t);if(s(t,i))return t[i][this[o]]}},set:function(t,e){return n.def(this,t,e)}},n,!0,!0);e.FW&&7!=(new f).set((Object.freeze||Object)(a),7).get(a)&&e.each.call(["delete","has","get","set"],function(t){var e=f.prototype[t]; +f.prototype[t]=function(n,o){if(c(n)&&u(n)){var i=r(this)[t](n,o);return"set"==t?this:i}return e.call(this,n,o)}})},{"./$":16,"./$.collection":10,"./$.collection-weak":9}],59:[function(t){"use strict";var e=t("./$.collection-weak");t("./$.collection")("WeakSet",{add:function(t){return e.def(this,t,!0)}},e,!1,!0)},{"./$.collection":10,"./$.collection-weak":9}],60:[function(t,e){(function(t){!function(t){"use strict";function n(t,e,n,r){return new s(t,e,n||null,r||[])}function r(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(r){return{type:"throw",arg:r}}}function o(){}function i(){}function s(t,e,n,o){function i(e,o){if(u===m)throw new Error("Generator is already running");if(u===b)return l();for(;;){var i=c.delegate;if(i){var s=r(i.iterator[e],i.iterator,o);if("throw"===s.type){c.delegate=null,e="throw",o=s.arg;continue}e="next",o=h;var a=s.arg;if(!a.done)return u=y,a;c[i.resultName]=a.value,c.next=i.nextLoc,c.delegate=null}if("next"===e){if(u===v&&"undefined"!=typeof o)throw new TypeError("attempt to send "+JSON.stringify(o)+" to newborn generator");u===y?c.sent=o:delete c.sent}else if("throw"===e){if(u===v)throw u=b,o;c.dispatchException(o)&&(e="next",o=h)}else"return"===e&&c.abrupt("return",o);u=m;var s=r(t,n,c);if("normal"===s.type){u=c.done?b:y;var a={value:s.arg,done:c.done};if(s.arg!==w)return a;c.delegate&&"next"===e&&(o=h)}else"throw"===s.type&&(u=b,"next"===e?c.dispatchException(s.arg):o=s.arg)}}var s=e?Object.create(e.prototype):this,c=new a(o),u=v;return s.next=i.bind(s,"next"),s["throw"]=i.bind(s,"throw"),s["return"]=i.bind(s,"return"),s}function c(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function u(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function a(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(c,this),this.reset()}function f(t){if(t){var e=t[p];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,r=function o(){for(;++ne;++e)this[t]=null},stop:function(){this.done=!0;var t=this.tryEntries[0],e=t.completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){function e(e,r){return i.type="throw",i.arg=t,n.next=e,!!r}if(this.done)throw t;for(var n=this,r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],i=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var s=d.call(o,"catchLoc"),c=d.call(o,"finallyLoc");if(s&&c){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&d.call(r,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc)}},"catch":function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;u(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:f(t),resultName:e,nextLoc:n},w}}}("object"==typeof t?t:"object"==typeof window?window:this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1]); \ No newline at end of file diff --git a/libs/utils.js b/libs/utils.js index dc6e41b3..988b1fe8 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -7,23 +7,23 @@ utils.js 工具类 "use strict"; -function utils() { +function utils () { this._init(); this.scan = { - 'up': {'x': 0, 'y': -1}, - 'left': {'x': -1, 'y': 0}, - 'down': {'x': 0, 'y': 1}, - 'right': {'x': 1, 'y': 0} + 'up': { 'x': 0, 'y': -1 }, + 'left': { 'x': -1, 'y': 0 }, + 'down': { 'x': 0, 'y': 1 }, + 'right': { 'x': 1, 'y': 0 } }; this.scan2 = { - 'up': {'x': 0, 'y': -1}, - 'left': {'x': -1, 'y': 0}, - 'down': {'x': 0, 'y': 1}, - 'right': {'x': 1, 'y': 0}, - 'leftup': {'x': -1, 'y': -1}, - 'leftdown': {'x': -1, 'y': 1}, - 'rightup': {'x': 1, 'y': -1}, - 'rightdown': {'x': 1, 'y': 1} + 'up': { 'x': 0, 'y': -1 }, + 'left': { 'x': -1, 'y': 0 }, + 'down': { 'x': 0, 'y': 1 }, + 'right': { 'x': 1, 'y': 0 }, + 'leftup': { 'x': -1, 'y': -1 }, + 'leftdown': { 'x': -1, 'y': 1 }, + 'rightup': { 'x': 1, 'y': -1 }, + 'rightdown': { 'x': 1, 'y': 1 } }; } @@ -105,7 +105,7 @@ utils.prototype.replaceText = function (text, prefix) { if (cnt == 0) break; } if (cnt != 0) return text; - var value = core.calValue(text.substring(index+2, curr), prefix); + 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); } @@ -124,17 +124,17 @@ utils.prototype.replaceValue = function (value) { // value = value.replace(/switch:([a-zA-Z0-9_]+)/g, "core.getFlag('" + (prefix || ":f@x@y") + "@$1', 0)"); if (value.indexOf('global:') >= 0 || value.indexOf('global:') >= 0) value = value.replace(/global[::]([a-zA-Z0-9_\u4E00-\u9FCC\u3040-\u30FF\u2160-\u216B\u0391-\u03C9]+)/g, "core.getGlobal('$1', 0)"); - if (value.indexOf('enemy:')>=0) + if (value.indexOf('enemy:') >= 0) value = value.replace(/enemy:([a-zA-Z0-9_]+)[\.:]([a-zA-Z0-9_]+)/g, "core.material.enemys['$1'].$2"); - if (value.indexOf('blockId:')>=0) + if (value.indexOf('blockId:') >= 0) value = value.replace(/blockId:(\d+),(\d+)/g, "core.getBlockId($1, $2)"); - if (value.indexOf('blockNumber:')>=0) + if (value.indexOf('blockNumber:') >= 0) value = value.replace(/blockNumber:(\d+),(\d+)/g, "core.getBlockNumber($1, $2)"); - if (value.indexOf('blockCls:')>=0) + if (value.indexOf('blockCls:') >= 0) value = value.replace(/blockCls:(\d+),(\d+)/g, "core.getBlockCls($1, $2)"); - if (value.indexOf('equip:')>=0) + if (value.indexOf('equip:') >= 0) value = value.replace(/equip:(\d)/g, "core.getEquip($1)"); - if (value.indexOf('temp:')>=0) + if (value.indexOf('temp:') >= 0) value = value.replace(/temp:([a-zA-Z0-9_]+)/g, "core.getFlag('@temp@$1', 0)"); } return value; @@ -145,7 +145,7 @@ utils.prototype.calValue = function (value, prefix) { if (!core.isset(value)) return null; if (typeof value === 'string') { if (value.indexOf(':') >= 0 || value.indexOf("flag:") >= 0 || value.indexOf('global:') >= 0) { - if (value.indexOf('switch:' >= 0)) + if (value.indexOf('switch:') >= 0) value = value.replace(/switch:([a-zA-Z0-9_]+)/g, "core.getFlag('" + (prefix || ":f@x@y") + "@$1', 0)"); value = this.replaceValue(value); } @@ -426,7 +426,7 @@ utils.prototype.clone = function (data, filter, recursion) { var copy = []; for (var i in data) { if (!filter || filter(i, data[i])) - copy[i] = core.clone(data[i], recursion?filter:null, recursion); + copy[i] = core.clone(data[i], recursion ? filter : null, recursion); } return copy; } @@ -439,7 +439,7 @@ utils.prototype.clone = function (data, filter, recursion) { var copy = {}; for (var i in data) { if (data.hasOwnProperty(i) && (!filter || filter(i, data[i]))) - copy[i] = core.clone(data[i], recursion?filter:null, recursion); + copy[i] = core.clone(data[i], recursion ? filter : null, recursion); } return copy; } @@ -496,9 +496,9 @@ utils.prototype.formatDate2 = function (date) { } utils.prototype.formatTime = function (time) { - return core.setTwoDigits(parseInt(time/3600000)) - +":"+core.setTwoDigits(parseInt(time/60000)%60) - +":"+core.setTwoDigits(parseInt(time/1000)%60); + return core.setTwoDigits(parseInt(time / 3600000)) + + ":" + core.setTwoDigits(parseInt(time / 60000) % 60) + + ":" + core.setTwoDigits(parseInt(time / 1000) % 60); } ////// 两位数显示 ////// @@ -508,27 +508,27 @@ utils.prototype.setTwoDigits = function (x) { utils.prototype.formatSize = function (size) { if (size < 1024) return size + 'B'; - else if (size < 1024 * 1024) return (size/1024).toFixed(2) + "KB"; - else return (size/1024/1024).toFixed(2) + "MB"; + else if (size < 1024 * 1024) return (size / 1024).toFixed(2) + "KB"; + else return (size / 1024 / 1024).toFixed(2) + "MB"; } utils.prototype.formatBigNumber = function (x, digits) { - if (digits === true) digits = 5; // 兼容旧版onMap参数 - if (!digits || digits < 5) digits = 6; // 连同负号、小数点和后缀字母在内的总位数,至少需为5,默认为6 - x = Math.trunc(parseFloat(x)); // 尝试识别为小数,然后向0取整 - if (x == null || !Number.isFinite(x)) return '???'; // 无法识别的数或正负无穷大,显示'???' - var units = [ // 单位及其后缀字母,可自定义,如改成千进制下的K、M、G、T、P - { "val": 1e4, "suffix": "w" }, - { "val": 1e8, "suffix": "e" }, - { "val": 1e12, "suffix": "z" }, - { "val": 1e16, "suffix": "j" }, - { "val": 1e20, "suffix": "g" }, - ]; - if (Math.abs(x) > 1e20 * Math.pow(10, digits - 2)) - return x.toExponential(0); // 绝对值过大以致于失去精度的数,直接使用科学记数法,系数只保留整数 - var sign = x < 0 ? '-' : ''; - if (sign) --digits; // 符号位单独处理,负号要占一位 - x = Math.abs(x); + if (digits === true) digits = 5; // 兼容旧版onMap参数 + if (!digits || digits < 5) digits = 6; // 连同负号、小数点和后缀字母在内的总位数,至少需为5,默认为6 + x = Math.trunc(parseFloat(x)); // 尝试识别为小数,然后向0取整 + if (x == null || !Number.isFinite(x)) return '???'; // 无法识别的数或正负无穷大,显示'???' + var units = [ // 单位及其后缀字母,可自定义,如改成千进制下的K、M、G、T、P + { "val": 1e4, "suffix": "w" }, + { "val": 1e8, "suffix": "e" }, + { "val": 1e12, "suffix": "z" }, + { "val": 1e16, "suffix": "j" }, + { "val": 1e20, "suffix": "g" }, + ]; + if (Math.abs(x) > 1e20 * Math.pow(10, digits - 2)) + return x.toExponential(0); // 绝对值过大以致于失去精度的数,直接使用科学记数法,系数只保留整数 + var sign = x < 0 ? '-' : ''; + if (sign) --digits; // 符号位单独处理,负号要占一位 + x = Math.abs(x); if (x < Math.pow(10, digits)) return sign + x; @@ -539,24 +539,24 @@ utils.prototype.formatBigNumber = function (x, digits) { u = u.substring(0, u[u.length - 2] == '.' ? u.length - 2 : u.length - 1); return sign + u + each.suffix; } - return sign + x.toExponential(0); + return sign + x.toExponential(0); } ////// 变速移动 ////// -utils.prototype.applyEasing = function(name) { +utils.prototype.applyEasing = function (name) { var list = { - "easeIn": function(t) { + "easeIn": function (t) { return Math.pow(t, 3); }, - "easeOut": function(t) { + "easeOut": function (t) { return 1 - Math.pow(1 - t, 3); }, - "easeInOut": function(t) { + "easeInOut": function (t) { // easeInOut试了一下感觉二次方效果明显点 if (t < 0.5) return Math.pow(t, 2) * 2; else return 1 - Math.pow(1 - t, 2) * 2; }, - "linear": function(t) { + "linear": function (t) { return t } } @@ -659,7 +659,7 @@ utils.prototype._encodeRoute_encodeOne = function (t) { return 'k' + t.substring(6); else if (t.indexOf('random:') == 0) return 'X' + t.substring(7); - return '('+t+')'; + return '(' + t + ')'; } ////// 解密路线 ////// @@ -676,7 +676,7 @@ utils.prototype.decodeRoute = function (route) { } catch (e) { } - var decodeObj = {route: route, index: 0, ans: []}; + var decodeObj = { route: route, index: 0, ans: [] }; while (decodeObj.index < decodeObj.route.length) { this._decodeRoute_decodeOne(decodeObj, decodeObj.route.charAt(decodeObj.index++)); } @@ -728,7 +728,7 @@ utils.prototype._decodeRoute_decodeOne = function (decodeObj, c) { var nxt = (c == 'I' || c == 'e' || c == 'F' || c == 'S' || c == 'Q' || c == 't') ? this._decodeRoute_getString(decodeObj) : this._decodeRoute_getNumber(decodeObj); - var mp = {"U": "up", "D": "down", "L": "left", "R": "right"}; + var mp = { "U": "up", "D": "down", "L": "left", "R": "right" }; switch (c) { case "U": @@ -797,7 +797,7 @@ utils.prototype._decodeRoute_decodeOne = function (decodeObj, c) { var px = this._decodeRoute_getNumber(decodeObj); ++decodeObj.index; var py = this._decodeRoute_getNumber(decodeObj); - decodeObj.ans.push("click:"+nxt+":"+px+":"+py); + decodeObj.ans.push("click:" + nxt + ":" + px + ":" + py); break; case "X": decodeObj.ans.push("random:" + nxt); @@ -870,7 +870,7 @@ utils.prototype.turnDirection = function (turn, direction) { direction = direction || core.getHeroLoc('direction'); var directionList = ["left", "leftup", "up", "rightup", "right", "rightdown", "down", "leftdown"]; if (directionList.indexOf(turn) >= 0) return turn; - if (turn == ':hero') return core.getHeroLoc('direction'); + if (turn == ':hero') return core.getHeroLoc('direction'); if (turn == ':backhero') return this.turnDirection(':back', core.getHeroLoc('direction')); if (typeof turn === 'number' && turn % 45 == 0) turn /= 45; else { @@ -1030,7 +1030,7 @@ utils.prototype.readFileContent = function (content) { // 检查base64 try { obj = JSON.parse(LZString.decompressFromBase64(content)); - } catch (e) {} + } catch (e) { } if (!obj) { try { obj = JSON.parse(content); @@ -1090,7 +1090,7 @@ utils.prototype.download = function (filename, content) { // Step 3: 如果是Safari浏览器,则提示并打开新窗口 if (core.platform.isSafari) { alert("你当前使用的是Safari浏览器,不支持直接下载文件。\n即将打开一个新窗口为应下载内容,请自行全选复制然后创建空白文件并粘贴。"); - var blob = new Blob([content], {type: 'text/plain;charset=utf-8'}); + var blob = new Blob([content], { type: 'text/plain;charset=utf-8' }); var href = window.URL.createObjectURL(blob); var opened = window.open(href, "_blank"); window.URL.revokeObjectURL(href); @@ -1098,7 +1098,7 @@ utils.prototype.download = function (filename, content) { } // Step 4: 下载 - var blob = new Blob([content], {type: 'text/plain;charset=utf-8'}); + var blob = new Blob([content], { type: 'text/plain;charset=utf-8' }); if (window.navigator.msSaveOrOpenBlob) { window.navigator.msSaveBlob(blob, filename); } @@ -1168,7 +1168,7 @@ utils.prototype.myprompt = function (hint, value, callback) { main.dom.inputDiv.style.display = 'block'; main.dom.inputMessage.innerHTML = hint.replace(/\n/g, '
'); main.dom.inputBox.style.display = 'block'; - main.dom.inputBox.value = value==null?"":value; + main.dom.inputBox.value = value == null ? "" : value; main.dom.inputYes.blur(); main.dom.inputNo.blur(); setTimeout(function () { @@ -1350,7 +1350,7 @@ utils.prototype.http = function (type, url, formData, success, error, mimeType, // LZW-compress // https://gist.github.com/revolunet/843889 -function lzw_encode(s) { +function lzw_encode (s) { var dict = {}; var data = (s + "").split(""); var out = []; @@ -1377,7 +1377,7 @@ function lzw_encode(s) { } // Decompress an LZW-encoded string -function lzw_decode(s) { +function lzw_decode (s) { var dict = {}; var data = (s + "").split(""); var currChar = data[0];