From 00d697af3128da3627576b3eb4c1c58c6e9adc72 Mon Sep 17 00:00:00 2001 From: Zhang Chen Date: Sat, 3 Mar 2018 21:05:29 +0800 Subject: [PATCH 01/23] Fix Bug --- libs/events.js | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/events.js b/libs/events.js index 2136f5fc..6d1b8fae 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1095,6 +1095,7 @@ events.prototype.afterLoadData = function(data) { ////// 长按 ////// events.prototype.longClick = function () { + if (!core.isPlaying()) return false; if (core.status.event.id=='text') { core.drawText(); return true; From 2dd694bcfa4b1b36a019fceadb3fa8af0229f0e2 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Sat, 3 Mar 2018 21:56:12 +0800 Subject: [PATCH 02/23] add weather in comment.js --- libs/events.js | 65 ++++++++++++++++++++++++++------------------ libs/ui.js | 9 +++--- project/comment.js | 1 + project/functions.js | 8 +++--- 4 files changed, 48 insertions(+), 35 deletions(-) diff --git a/libs/events.js b/libs/events.js index a0411cf8..eba4f072 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1,9 +1,10 @@ function events() { this.init(); } -var eventdata = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.events; + ////// 初始化 ////// events.prototype.init = function () { + this.eventdata = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.events; this.events = { 'battle': function (data, core, callback) { //core.autosave(true); @@ -101,16 +102,19 @@ events.prototype.startGame = function (hard) { } ////// 不同难度分别设置初始属性 ////// -events.prototype.setInitData = eventdata.setInitData -// function (hard) +events.prototype.setInitData = function (hard) { + return this.eventdata.setInitData(hard); +} ////// 游戏获胜事件 ////// -events.prototype.win = eventdata.win -// function(reason) +events.prototype.win = function (reason) { + return this.eventdata.win(reason); +} ////// 游戏失败事件 ////// -events.prototype.lose = eventdata.lose -// function(reason) +events.prototype.lose = function (reason) { + return this.eventdata.lose(reason); +} ////// 游戏结束 ////// events.prototype.gameOver = function (ending, fromReplay) { @@ -188,8 +192,9 @@ events.prototype.gameOver = function (ending, fromReplay) { } ////// 转换楼层结束的事件 ////// -events.prototype.afterChangeFloor = eventdata.afterChangeFloor -// function (floorId) +events.prototype.afterChangeFloor = function (floorId) { + return this.eventdata.afterChangeFloor(floorId); +} ////// 开始执行一系列自定义事件 ////// events.prototype.doEvents = function (list, x, y, callback) { @@ -1027,16 +1032,19 @@ events.prototype.useItem = function(itemId) { } ////// 加点事件 ////// -events.prototype.addPoint = eventdata.addPoint -// function (enemy) +events.prototype.addPoint = function (enemy) { + return this.eventdata.addPoint(enemy); +} ////// 战斗结束后触发的事件 ////// -events.prototype.afterBattle = eventdata.afterBattle -// function(enemyId,x,y,callback) +events.prototype.afterBattle = function (enemyId,x,y,callback) { + return this.eventdata.afterBattle(enemyId,x,y,callback); +} ////// 开一个门后触发的事件 ////// -events.prototype.afterOpenDoor = eventdata.afterOpenDoor -// function(doorId,x,y,callback) +events.prototype.afterOpenDoor = function (doorId,x,y,callback) { + return this.eventdata.afterOpenDoor(doorId,x,y,callback); +} ////// 经过一个路障 ////// events.prototype.passNet = function (data) { @@ -1087,8 +1095,9 @@ events.prototype.changeLight = function(x, y) { } ////// 改变亮灯之后,可以触发的事件 ////// -events.prototype.afterChangeLight = eventdata.afterChangeLight -// function(x,y) +events.prototype.afterChangeLight = function (x,y) { + return this.eventdata.afterChangeLight(x,y); +} ////// 滑冰 ////// events.prototype.ski = function (direction) { @@ -1165,21 +1174,23 @@ events.prototype.pushBox = function (data) { } ////// 推箱子后的事件 ////// -events.prototype.afterPushBox = eventdata.afterPushBox -// function () +events.prototype.afterPushBox = function () { + return this.eventdata.afterPushBox(); +} ////// 使用炸弹/圣锤后的事件 ////// -events.prototype.afterUseBomb = eventdata.afterUseBomb -// function () +events.prototype.afterUseBomb = function () { + return this.eventdata.afterUseBomb(); +} ////// 即将存档前可以执行的操作 ////// -events.prototype.beforeSaveData = eventdata.beforeSaveData -// function(data) +events.prototype.beforeSaveData = function (data) { + return this.eventdata.beforeSaveData(data); +} ////// 读档事件后,载入事件前,可以执行的操作 ////// -events.prototype.afterLoadData = eventdata.afterLoadData -// function(data) +events.prototype.afterLoadData = function (data) { + return this.eventdata.afterLoadData(data); +} - -delete(eventdata); \ No newline at end of file diff --git a/libs/ui.js b/libs/ui.js index 638897b3..47676211 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -6,10 +6,10 @@ function ui() { this.init(); } -var uidata = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.ui; + // 初始化UI ui.prototype.init = function () { - + this.uidata = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.ui; } ////////////////// 地图设置 @@ -1626,7 +1626,9 @@ ui.prototype.drawKeyBoard = function () { } ////// 绘制“关于”界面 ////// -ui.prototype.drawAbout = uidata.drawAbout +ui.prototype.drawAbout = function () { + return this.uidata.drawAbout(); +} ////// 绘制帮助页面 ////// ui.prototype.drawHelp = function () { @@ -1657,4 +1659,3 @@ ui.prototype.drawHelp = function () { ]); } -delete(uidata) \ No newline at end of file diff --git a/project/comment.js b/project/comment.js index 23761025..12267989 100644 --- a/project/comment.js +++ b/project/comment.js @@ -40,6 +40,7 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "defaultGround": "默认地面的图块ID(terrains中) ", "png": "背景图;你可以选择一张png图片来作为背景素材。详细用法请参见文档“自定义素材”中的说明。 \n$leaf(true)$end", "color": "该层的默认画面色调。本项可不写(代表无色调),如果写需要是一个RGBA数组。 \n$leaf(true)$end", + "weather": "该层的默认天气。本项可忽略表示晴天,如果写则第一项为\"rain\"或\"snow\"代表雨雪,第二项为1-10之间的数代表强度。 \n$leaf(true)$end", "bgm": "到达该层后默认播放的BGM。本项可忽略。 ", //"map": "地图数据,需要是13x13,建议使用地图生成器来生成 ", "firstArrive": "第一次到该楼层触发的事件 \n$leaf(true)$end", diff --git a/project/functions.js b/project/functions.js index 50c3f9f5..eb97fffe 100644 --- a/project/functions.js +++ b/project/functions.js @@ -19,7 +19,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = if (hard=='Hell') { // 噩梦难度 core.setFlag('hard', 4); // 可以用flag:hard来获得当前难度 } - this.afterLoadData(); + core.events.afterLoadData(); }, ////// 游戏获胜事件 ////// "win" : function(reason) { @@ -54,7 +54,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = if (core.isset(core.status.event.id)) return; // 当前存在事件 if (!core.hasFlag("visited_"+floorId)) { - this.doEvents(core.floors[floorId].firstArrive, null, null, function () { + core.events.doEvents(core.floors[floorId].firstArrive, null, null, function () { //core.autosave(); }); core.setFlag("visited_"+floorId, true); @@ -174,7 +174,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 如果事件不为空,将其插入 if (todo.length>0) { - this.insertAction(todo,x,y); + core.events.insertAction(todo,x,y); } // 如果已有事件正在处理中 @@ -199,7 +199,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } if (todo.length>0) { - this.insertAction(todo,x,y); + core.events.insertAction(todo,x,y); } if (core.status.event.id == null) { From 43681581e09d33543935924b9a771e2542e4ed89 Mon Sep 17 00:00:00 2001 From: oc Date: Sat, 3 Mar 2018 22:47:48 +0800 Subject: [PATCH 03/23] 1 --- .idea/markdown-exported-files.xml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .idea/markdown-exported-files.xml diff --git a/.idea/markdown-exported-files.xml b/.idea/markdown-exported-files.xml new file mode 100644 index 00000000..5d1f1293 --- /dev/null +++ b/.idea/markdown-exported-files.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file From f97495a6b6dd148c99c8325344386b48e3db4a25 Mon Sep 17 00:00:00 2001 From: oc Date: Sat, 3 Mar 2018 23:34:10 +0800 Subject: [PATCH 04/23] Support Reborn --- libs/enemys.js | 4 +++- libs/events.js | 7 +++++++ libs/maps.js | 12 +++++++++--- project/data.js | 2 +- project/enemys.js | 2 +- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/libs/enemys.js b/libs/enemys.js index 1e7629c3..cf284486 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -59,6 +59,7 @@ enemys.prototype.getSpecialText = function (enemyId) { if (this.hasSpecial(special, 20)) text.push("无敌"); if (this.hasSpecial(special, 21)) text.push("退化"); if (this.hasSpecial(special, 22)) text.push("固伤"); + if (this.hasSpecial(special, 23)) text.push("重生"); return text; } @@ -99,9 +100,10 @@ enemys.prototype.getSpecialHint = function (enemy, special) { case 20: return "无敌:勇士无法打败怪物,除非拥有十字架"; case 21: return "退化:战斗后勇士永久下降"+(enemy.atkValue||0)+"点攻击和"+(enemy.defValue||0)+"点防御"; case 22: return "固伤:战斗前,怪物对勇士造成"+(enemy.damage||0)+"点固定伤害,无视勇士魔防。"; + case 23: return "重生:怪物被击败后,角色转换楼层则怪物将再次出现"; default: break; } - return "" + return ""; } ////// 获得某个怪物的伤害 ////// diff --git a/libs/events.js b/libs/events.js index eba4f072..2751ea4f 100644 --- a/libs/events.js +++ b/libs/events.js @@ -879,6 +879,13 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback } else core.setWeather(); + core.status.maps[floorId].blocks.forEach(function(block) { + if (core.isset(block.enable) && !block.enable && core.isset(block.event) && block.event.cls=='enemys' + && core.enemys.hasSpecial(core.material.enemys[block.event.id].special, 23)) { + block.enable = true; + } + }) + core.drawMap(floorId, function () { setTimeout(function() { if (core.isset(heroLoc.direction)) diff --git a/libs/maps.js b/libs/maps.js index 032b59f5..b2e67b1e 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -721,16 +721,22 @@ maps.prototype.removeBlock = function (x, y, floorId) { ////// 根据block的索引删除该块 ////// maps.prototype.removeBlockById = function (index, floorId) { - var blocks = core.status.maps[floorId].blocks; - var x=blocks[index].x, y=blocks[index].y; + var blocks = core.status.maps[floorId].blocks, block = blocks[index]; + var x=blocks.x, y=blocks.y; // 检查该点是否存在事件 var event = core.floors[floorId].events[x+","+y]; if (!core.isset(event)) event = core.floors[floorId].changeFloor[x+","+y]; + // 检查是否存在重生 + var isReborn = false; + if (core.isset(block.event) && block.event.cls=='enemys' + && core.enemys.hasSpecial(core.material.enemys[block.event.id].special, 23)) + isReborn = true; + // 不存在事件,直接删除 - if (!core.isset(event)) { + if (!isReborn && !core.isset(event)) { blocks.splice(index,1); return; } diff --git a/project/data.js b/project/data.js index d8988833..7aefac99 100644 --- a/project/data.js +++ b/project/data.js @@ -218,7 +218,7 @@ data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "showBattleAnimateConfirm": true, // 是否在游戏开始时提供“是否开启战斗动画”的选项 "battleAnimate": true, // 是否默认显示战斗动画;用户可以手动在菜单栏中开关 "displayEnemyDamage": true, // 是否地图怪物显伤;用户可以手动在菜单栏中开关 - "displayExtraDamage": false, // 是否地图高级显伤(领域、夹击等);用户可以手动在菜单栏中开关 + "displayExtraDamage": true, // 是否地图高级显伤(领域、夹击等);用户可以手动在菜单栏中开关 "enableGentleClick": true, // 是否允许轻触(获得面前物品) "potionWhileRouting": false, // 寻路算法是否经过血瓶;如果该项为false,则寻路算法会自动尽量绕过血瓶 "enableViewMaps": true, // 是否支持在菜单栏中查看所有楼层的地图 diff --git a/project/enemys.js b/project/enemys.js index c035efa8..fdc50724 100644 --- a/project/enemys.js +++ b/project/enemys.js @@ -23,7 +23,7 @@ enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 = 'yellowGuard': {'name': '初级卫兵', 'hp': 100, 'atk': 120, 'def': 0, 'money': 10, 'experience': 0, 'special': 0}, 'blueGuard': {'name': '中级卫兵', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0}, 'redGuard': {'name': '高级卫兵', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0}, - 'swordsman': {'name': '双手剑士', 'hp': 100, 'atk': 120, 'def': 0, 'money': 6, 'experience': 0, 'special': 5}, + 'swordsman': {'name': '双手剑士', 'hp': 100, 'atk': 120, 'def': 0, 'money': 6, 'experience': 0, 'special': [5,23]}, 'soldier': {'name': '冥战士', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0}, 'yellowKnight': {'name': '金骑士', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0}, 'redKnight': {'name': '红骑士', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0}, From dcce32f93114f7a8fbfb9a9ac71426ef2fd99412 Mon Sep 17 00:00:00 2001 From: oc Date: Sat, 3 Mar 2018 23:46:21 +0800 Subject: [PATCH 05/23] Support Reborn --- libs/control.js | 2 +- libs/core.js | 4 ++-- libs/events.js | 17 ++++++++++------- libs/maps.js | 4 ++-- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/libs/control.js b/libs/control.js index 7beac62f..4e523a35 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1880,7 +1880,7 @@ control.prototype.loadData = function (data, callback) { core.changeFloor(data.floorId, null, data.hero.loc, 0, function() { if (core.isset(callback)) callback(); - }); + }, true); } ////// 设置勇士属性 ////// diff --git a/libs/core.js b/libs/core.js index ea74aa9e..30de90c1 100644 --- a/libs/core.js +++ b/libs/core.js @@ -536,8 +536,8 @@ core.prototype.trigger = function (x, y) { } ////// 楼层切换 ////// -core.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback) { - core.events.changeFloor(floorId, stair, heroLoc, time, callback); +core.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback, fromLoad) { + core.events.changeFloor(floorId, stair, heroLoc, time, callback, fromLoad); } ////// 清除地图 ////// diff --git a/libs/events.js b/libs/events.js index 2751ea4f..76415798 100644 --- a/libs/events.js +++ b/libs/events.js @@ -801,7 +801,7 @@ events.prototype.trigger = function (x, y) { } ////// 楼层切换 ////// -events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback) { +events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback, fromLoad) { var displayAnimate=!(time==0) && !core.status.replay.replaying; @@ -879,12 +879,15 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback } else core.setWeather(); - core.status.maps[floorId].blocks.forEach(function(block) { - if (core.isset(block.enable) && !block.enable && core.isset(block.event) && block.event.cls=='enemys' - && core.enemys.hasSpecial(core.material.enemys[block.event.id].special, 23)) { - block.enable = true; - } - }) + // 检查重生 + if (!core.isset(fromLoad)) { + core.status.maps[floorId].blocks.forEach(function(block) { + if (core.isset(block.enable) && !block.enable && core.isset(block.event) && block.event.cls=='enemys' + && core.enemys.hasSpecial(core.material.enemys[block.event.id].special, 23)) { + block.enable = true; + } + }) + } core.drawMap(floorId, function () { setTimeout(function() { diff --git a/libs/maps.js b/libs/maps.js index b2e67b1e..90b12abb 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -722,7 +722,7 @@ maps.prototype.removeBlock = function (x, y, floorId) { maps.prototype.removeBlockById = function (index, floorId) { var blocks = core.status.maps[floorId].blocks, block = blocks[index]; - var x=blocks.x, y=blocks.y; + var x=block.x, y=block.y; // 检查该点是否存在事件 var event = core.floors[floorId].events[x+","+y]; @@ -740,7 +740,7 @@ maps.prototype.removeBlockById = function (index, floorId) { blocks.splice(index,1); return; } - blocks[index].enable = false; + block.enable = false; } ////// 一次性删除多个block ////// From 2f5caae07c8e1c8f6812c56306018f0873b52062 Mon Sep 17 00:00:00 2001 From: oc Date: Sat, 3 Mar 2018 23:48:46 +0800 Subject: [PATCH 06/23] Support Reborn --- _server/editor.js | 2 +- libs/actions.js | 2 +- libs/control.js | 4 ++-- main.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/_server/editor.js b/_server/editor.js index 39187c45..bbbcf38d 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -32,7 +32,7 @@ editor.prototype.init = function(callback){ //core.status.maps = core.clone(core.maps.initMaps(floorIds)); core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() { afterCoreReset(); - }); + }, true); core.events.setInitData(hard); } setTimeout(afterMainInit, 500); diff --git a/libs/actions.js b/libs/actions.js index ad767903..7cbebf1d 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -324,7 +324,7 @@ actions.prototype.keyUp = function(keyCode) { core.events.setInitData(hard); core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() { core.startReplay(route); - }); + }, true); }, function () { core.ui.closePanel(); }); diff --git a/libs/control.js b/libs/control.js index 4e523a35..1ca01d62 100644 --- a/libs/control.js +++ b/libs/control.js @@ -280,7 +280,7 @@ control.prototype.startGame = function (hard, callback) { core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() { if (core.isset(callback)) callback(); - }); + }, true); setTimeout(function () { // Upload @@ -1707,7 +1707,7 @@ control.prototype.doSL = function (id, type) { core.events.setInitData(data.hard); core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() { core.startReplay(core.decodeRoute(data.route)); - }); + }, true); } return; } diff --git a/main.js b/main.js index f0117813..314dee38 100644 --- a/main.js +++ b/main.js @@ -458,7 +458,7 @@ main.dom.replayGame.onclick = function () { core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() { //core.setHeroMoveTriggerInterval(); core.startReplay(core.decodeRoute(obj.route)); - }); + }, true); }, function () { }) From df89fd0b7cf995202814b51a98d0abad6e56cb01 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Sun, 4 Mar 2018 11:11:52 +0800 Subject: [PATCH 07/23] =?UTF-8?q?=E8=B0=83=E6=95=B4=20editor.file=20&=20ed?= =?UTF-8?q?itor.mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2.0diff.md | 40 +++++++++++++------------- _server/editor.js | 10 +++++++ _server/editor_file.js | 33 ++++++++++----------- _server/editor_file_test.html | 27 +++++++++--------- _server/editor_mode.js | 54 ++++++++++++++++++----------------- editor.html | 10 +++---- 6 files changed, 94 insertions(+), 80 deletions(-) diff --git a/2.0diff.md b/2.0diff.md index 814b4b04..ebc3c1c3 100644 --- a/2.0diff.md +++ b/2.0diff.md @@ -59,38 +59,38 @@ editor.file.saveFloorFileAs ``` 5个编辑模式有关的查询 ```javascript -editor.file.editItem(editor,'redJewel',[],function(a){console.log(a)}); -editor.file.editEnemy(editor,'redBat',[],function(a){console.log(a)}); -editor.file.editLoc(editor,2,0,[],function(a){console.log(a)}); -editor.file.editFloor(editor,[],function(a){console.log(a)}); -editor.file.editTower(editor,[],function(a){console.log(a)}); +editor.file.editItem('redJewel',[],function(a){console.log(a)}); +editor.file.editEnemy('redBat',[],function(a){console.log(a)}); +editor.file.editLoc(2,0,[],function(a){console.log(a)}); +editor.file.editFloor([],function(a){console.log(a)}); +editor.file.editTower([],function(a){console.log(a)}); ``` 5个编辑模式有关的编辑 ```javascript editor.info={images: "terrains", y: 9}; -editor.file.changeIdAndIdnum(editor,'yellowWall2',16,editor.info,function(a){console.log(a)}); -editor.file.editItem(editor,'book',[["change","['items']['name']","怪物手册的新名字"]],function(a){console.log(a)}); -editor.file.editEnemy(editor,'redBat',[['change',"['atk']",20]],function(a){console.log(a)}); -editor.file.editLoc(editor,2,6,[["change","['afterBattle']",null]],function(a){console.log(a)}); -editor.file.editFloor(editor,[["change","['title']",'样板 33 层']],function(a){console.log(a)}); -editor.file.editTower(editor,[["change","['values']['lavaDamage']",200]],function(a){console.log(a)}); +editor.file.changeIdAndIdnum('yellowWall2',16,editor.info,function(a){console.log(a)}); +editor.file.editItem('book',[["change","['items']['name']","怪物手册的新名字"]],function(a){console.log(a)}); +editor.file.editEnemy('redBat',[['change',"['atk']",20]],function(a){console.log(a)}); +editor.file.editLoc(2,6,[["change","['afterBattle']",null]],function(a){console.log(a)}); +editor.file.editFloor([["change","['title']",'样板 33 层']],function(a){console.log(a)}); +editor.file.editTower([["change","['values']['lavaDamage']",200]],function(a){console.log(a)}); ``` ### editor_mode.js 4个生成表格并绑定事件的函数 ```javascript -editor_mode.loc(); -editor_mode.emenyitem(); -editor_mode.floor(); -editor_mode.tower(); +editor.mode.loc(); +editor.mode.emenyitem(); +editor.mode.floor(); +editor.mode.tower(); ``` 切换模式 ```javascript -editor_mode.onmode(''); -editor_mode.onmode('loc'); -editor_mode.onmode('emenyitem'); -editor_mode.onmode('floor'); -editor_mode.onmode('tower'); +editor.mode.onmode(''); +editor.mode.onmode('loc'); +editor.mode.onmode('emenyitem'); +editor.mode.onmode('floor'); +editor.mode.onmode('tower'); ``` 在切换模式时,改动才会保存到文件,并且需要刷新页面使得`editor`能看到改动 diff --git a/_server/editor.js b/_server/editor.js index bbbcf38d..425de609 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -24,7 +24,10 @@ editor.prototype.init = function(callback){ editor.main=main; editor.core=core; editor.fs=fs; + editor_file = editor_file(editor); editor.file=editor_file; + editor_mode = editor_mode(editor); + editor.mode=editor_mode; editor.material.images=core.material.images; editor.listen(); // 开始监听事件 var hard = 'Hard'; @@ -308,6 +311,13 @@ editor.prototype.changeFloor = function(floorId,callback) { }); } +editor.prototype.guid = function() { + return 'id_'+'xxxxxxxx_xxxx_4xxx_yxxx_xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); + return v.toString(16); + }); +} + editor.prototype.listen = function() { var uc = eui.getContext('2d'); diff --git a/_server/editor_file.js b/_server/editor_file.js index e66c722f..741e5d0f 100644 --- a/_server/editor_file.js +++ b/_server/editor_file.js @@ -1,6 +1,6 @@ -(function(){ +editor_file = function(editor){ - editor_file = {}; + var editor_file = {}; (function(){ var script = document.createElement('script'); @@ -28,7 +28,7 @@ })(); - editor_file.getFloorFileList = function(editor,callback){ + editor_file.getFloorFileList = function(callback){ if (!isset(callback)) {printe('未设置callback');throw('未设置callback')}; /* var fs = editor.fs; fs.readdir('project/floors',function(err, data){ @@ -37,7 +37,7 @@ callback([editor.core.floorIds,null]); } //callback([Array,err:String]) - editor_file.loadFloorFile = function(editor,filename,callback){ + editor_file.loadFloorFile = function(filename,callback){ //filename不含'/'不含'.js' if (!isset(callback)) {printe('未设置callback');throw('未设置callback')}; /* var fs = editor.fs; @@ -63,7 +63,7 @@ editor.currentFloorData = editor.core.floors[editor.currentFloorId]; } //callback(err:String) - editor_file.saveFloorFile = function(editor,callback){ + editor_file.saveFloorFile = function(callback){ if (!isset(callback)) {printe('未设置callback');throw('未设置callback')}; /* if (!isset(editor.currentFloorId) || !isset(editor.currentFloorData)) { callback('未选中文件或无数据'); @@ -85,7 +85,7 @@ }); } //callback(err:String) - editor_file.saveFloorFileAs = function(editor,saveAsFilename,callback){ + editor_file.saveFloorFileAs = function(saveAsFilename,callback){ //saveAsFilename不含'/'不含'.js' if (!isset(callback)) {printe('未设置callback');throw('未设置callback')}; if (!isset(editor.currentFloorData)) { @@ -95,13 +95,13 @@ editor.currentFloorData=JSON.parse(JSON.stringify(editor.currentFloorData)); editor.currentFloorData.floorId=saveAsFilename; editor.currentFloorId=saveAsFilename; - editor_file.saveFloorFile(editor,callback); + editor_file.saveFloorFile(callback); } //callback(err:String) //////////////////////////////////////////////////////////////////// - editor_file.changeIdAndIdnum = function(editor,id,idnum,info,callback){ + editor_file.changeIdAndIdnum = function(id,idnum,info,callback){ if (!isset(callback)) {printe('未设置callback');throw('未设置callback')}; //检查maps中是否有重复的idnum或id var change = -1; @@ -159,7 +159,7 @@ callback(null); } //callback(err:String) - editor_file.editItem = function(editor,id,actionList,callback){ + editor_file.editItem = function(id,actionList,callback){ /*actionList:[ ["change","['items']['name']","红宝石的新名字"], ["add","['items']['新的和name同级的属性']",123], @@ -208,7 +208,7 @@ //只有items.cls是items的才有itemEffect和itemEffectTip,keys和constants和tools只有items } //callback([obj,commentObj,err:String]) - editor_file.editEnemy = function(editor,id,actionList,callback){ + editor_file.editEnemy = function(id,actionList,callback){ /*actionList:[ ["change","['name']","初级巫师的新名字"], ["add","['新的和name同级的属性']",123], @@ -256,7 +256,7 @@ //////////////////////////////////////////////////////////////////// - editor_file.editLoc = function(editor,x,y,actionList,callback){ + editor_file.editLoc = function(x,y,actionList,callback){ /*actionList:[ ["change","['events']",["\t[老人,magician]领域、夹击。\n请注意领域怪需要设置value为伤害数值,可参见样板中初级巫师的写法。"]], ["change","['afterBattle']",null], @@ -304,7 +304,7 @@ //////////////////////////////////////////////////////////////////// - editor_file.editFloor = function(editor,actionList,callback){ + editor_file.editFloor = function(actionList,callback){ /*actionList:[ ["change","['title']",'样板 3 层'], ["change","['color']",null], @@ -348,7 +348,7 @@ //////////////////////////////////////////////////////////////////// - editor_file.editTower = function(editor,actionList,callback){ + editor_file.editTower = function(actionList,callback){ /*actionList:[ ["change","['firstData']['version']",'Ver 1.0.1 (Beta)'], ["change","['values']['lavaDamage']",200], @@ -489,7 +489,7 @@ if (value[0]!='change')return; eval("editor.currentFloorData"+value[1]+'='+JSON.stringify(value[2])); }); - editor_file.saveFloorFile(editor,callback); + editor_file.saveFloorFile(callback); return; } callback('出错了,要设置的文件名不识别'); @@ -523,5 +523,6 @@ // ] */ - -})(); \ No newline at end of file + return editor_file; +} +//editor_file = editor_file(editor); \ No newline at end of file diff --git a/_server/editor_file_test.html b/_server/editor_file_test.html index cd13e6d3..1f4639fd 100644 --- a/_server/editor_file_test.html +++ b/_server/editor_file_test.html @@ -11,31 +11,32 @@ pout.innerHTML='waiting\nwaiting waiting'; var editor={}; editor.fs=fs; + editor_file = editor_file(editor); editor.file=editor_file; //代码复制到 http://127.0.0.1:1055/drawMapGUI.html 的console中进行测试 - /* editor.file.loadFloorFile(editor,'sample0',function(err){console.log(err); - editor.file.saveFloorFileAs(editor,'aaa',function(err){console.log(err)}); + /* editor.file.loadFloorFile('sample0',function(err){console.log(err); + editor.file.saveFloorFileAs('aaa',function(err){console.log(err)}); }); */ //查询 /* - editor_file.editItem(editor,'redJewel',[],function(a){console.log(a)}); - editor_file.editEnemy(editor,'redBat',[],function(a){console.log(a)}); - editor_file.editLoc(editor,2,6,[],function(a){console.log(a)}); - editor_file.editFloor(editor,[],function(a){console.log(a)}); - editor.file.editTower(editor,[],function(a){console.log(a)}); + editor.file.editItem('redJewel',[],function(a){console.log(a)}); + editor.file.editEnemy('redBat',[],function(a){console.log(a)}); + editor.file.editLoc(2,6,[],function(a){console.log(a)}); + editor.file.editFloor([],function(a){console.log(a)}); + editor.file.editTower([],function(a){console.log(a)}); */ //编辑 /* editor.info={images: "terrains", y: 9}; - editor.file.changeIdAndIdnum(editor,'yellowWall2',16,editor.info,function(a){console.log(a)}); - editor_file.editItem(editor,'book',[["change","['items']['name']","怪物手册的新名字"]],function(a){console.log(a)}); - editor_file.editEnemy(editor,'redBat',[['change',"['atk']",20]],function(a){console.log(a)}); - editor_file.editLoc(editor,2,6,[["change","['afterBattle']",null]],function(a){console.log(a)}); - editor_file.editFloor(editor,[["change","['title']",'样板 33 层']],function(a){console.log(a)}); - editor.file.editTower(editor,[["change","['values']['lavaDamage']",200]],function(a){console.log(a)}); + editor.file.changeIdAndIdnum('yellowWall2',16,editor.info,function(a){console.log(a)}); + editor.file.editItem('book',[["change","['items']['name']","怪物手册的新名字"]],function(a){console.log(a)}); + editor.file.editEnemy('redBat',[['change',"['atk']",20]],function(a){console.log(a)}); + editor.file.editLoc(2,6,[["change","['afterBattle']",null]],function(a){console.log(a)}); + editor.file.editFloor([["change","['title']",'样板 33 层']],function(a){console.log(a)}); + editor.file.editTower([["change","['values']['lavaDamage']",200]],function(a){console.log(a)}); */ pout.innerHTML='succeed\nsucceed succeed'; diff --git a/_server/editor_mode.js b/_server/editor_mode.js index 017937b1..5ef6852d 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -1,3 +1,5 @@ +editor_mode = function(editor){ + function editor_mode(){ this.ids={ 'loc':'left2', @@ -12,8 +14,11 @@ function editor_mode(){ this.info={}; this.appendPic={}; } - editor_mode.prototype.init = function(callback){ + if (Boolean(callback))callback(); +} + +editor_mode.prototype.init_dom_ids = function(callback){ Object.keys(editor_mode.ids).forEach(function(v){ editor_mode.dom[v]=document.getElementById(editor_mode.ids[v]); @@ -90,7 +95,7 @@ editor_mode.prototype.checkIsLeaf = function(obj,commentObj,field){ } editor_mode.prototype.objToTr = function(obj,commentObj,field){ - var guid = editor_mode.guid(); + var guid = editor.guid(); var thiseval = eval('obj'+field); var comment = ''; try { @@ -131,13 +136,6 @@ editor_mode.prototype.objToTd = function(thiseval,comment){ } } -editor_mode.prototype.guid = function() { - return 'id_'+'xxxxxxxx_xxxx_4xxx_yxxx_xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); - return v.toString(16); - }); -} - editor_mode.prototype.addAction = function(action){ editor_mode.actionList.push(action); } @@ -147,23 +145,23 @@ editor_mode.prototype.doActionList = function(mode,actionList){ switch (mode) { case 'loc': - editor_file.editLoc(editor,editor_mode.pos.x,editor_mode.pos.y,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')}); + editor.file.editLoc(editor_mode.pos.x,editor_mode.pos.y,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')}); break; case 'emenyitem': if (editor_mode.info.images=='enemys'){ - editor_file.editEnemy(editor,editor_mode.info.id,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')}); + editor.file.editEnemy(editor_mode.info.id,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')}); } else if (editor_mode.info.images=='items'){ - editor_file.editItem(editor,editor_mode.info.id,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')}); + editor.file.editItem(editor_mode.info.id,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')}); } break; case 'floor': - editor_file.editFloor(editor,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')}); + editor.file.editFloor(actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')}); break; case 'tower': - editor.file.editTower(editor,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')}); + editor.file.editTower(actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')}); break; default: break; @@ -186,7 +184,7 @@ editor_mode.prototype.loc = function(callback){ document.getElementById('pos_a6771a78_a099_417c_828f_0a24851ebfce').innerText=editor_mode.pos.x+','+editor_mode.pos.y; var objs=[]; - editor_file.editLoc(editor,editor_mode.pos.x,editor_mode.pos.y,[],function(objs_){objs=objs_;console.log(objs_)}); + editor.file.editLoc(editor_mode.pos.x,editor_mode.pos.y,[],function(objs_){objs=objs_;console.log(objs_)}); //只查询不修改时,内部实现不是异步的,所以可以这么写 var tableinfo=editor_mode.objToTable(objs[0],objs[1]); document.getElementById('table_3d846fc4_7644_44d1_aa04_433d266a73df').innerHTML=tableinfo.HTML; @@ -209,9 +207,9 @@ editor_mode.prototype.emenyitem = function(callback){ var objs=[]; if (editor_mode.info.images=='enemys'){ - editor_file.editEnemy(editor,editor_mode.info.id,[],function(objs_){objs=objs_;console.log(objs_)}); + editor.file.editEnemy(editor_mode.info.id,[],function(objs_){objs=objs_;console.log(objs_)}); } else if (editor_mode.info.images=='items'){ - editor_file.editItem(editor,editor_mode.info.id,[],function(objs_){objs=objs_;console.log(objs_)}); + editor.file.editItem(editor_mode.info.id,[],function(objs_){objs=objs_;console.log(objs_)}); } else { document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML=''; return; @@ -226,7 +224,7 @@ editor_mode.prototype.emenyitem = function(callback){ editor_mode.prototype.floor = function(callback){ var objs=[]; - editor_file.editFloor(editor,[],function(objs_){objs=objs_;console.log(objs_)}); + editor.file.editFloor([],function(objs_){objs=objs_;console.log(objs_)}); //只查询不修改时,内部实现不是异步的,所以可以这么写 var tableinfo=editor_mode.objToTable(objs[0],objs[1]); document.getElementById('table_4a3b1b09_b2fb_4bdf_b9ab_9f4cdac14c74').innerHTML=tableinfo.HTML; @@ -236,7 +234,7 @@ editor_mode.prototype.floor = function(callback){ editor_mode.prototype.tower = function(callback){ var objs=[]; - editor.file.editTower(editor,[],function(objs_){objs=objs_;console.log(objs_)}); + editor.file.editTower([],function(objs_){objs=objs_;console.log(objs_)}); //只查询不修改时,内部实现不是异步的,所以可以这么写 var tableinfo=editor_mode.objToTable(objs[0],objs[1]); document.getElementById('table_b6a03e4c_5968_4633_ac40_0dfdd2c9cde5').innerHTML=tableinfo.HTML; @@ -253,7 +251,7 @@ editor_mode.prototype.listen = function(callback){ if (newIdIdnum.children[0].value && newIdIdnum.children[1].value){ var id = newIdIdnum.children[0].value; var idnum = parseInt(newIdIdnum.children[1].value); - editor_file.changeIdAndIdnum(editor,id,idnum,editor_mode.info,function(err){ + editor.file.changeIdAndIdnum(id,idnum,editor_mode.info,function(err){ if(err){printe(err);throw(err)} printe('添加id的idnum成功,请F5刷新编辑器'); }); @@ -261,7 +259,7 @@ editor_mode.prototype.listen = function(callback){ } var selectFloor = document.getElementById('selectFloor'); - editor_file.getFloorFileList(editor,function(floors){ + editor.file.getFloorFileList(function(floors){ var outstr=[]; floors[0].forEach(function(floor){ outstr.push(["\n'].join('')); @@ -277,7 +275,7 @@ editor_mode.prototype.listen = function(callback){ var saveFloor = document.getElementById('saveFloor'); saveFloor.onclick = function(){ editor_mode.onmode(''); - editor_file.saveFloorFile(editor,function(err){if(err){printe(err);throw(err)}}); + editor.file.saveFloorFile(function(err){if(err){printe(err);throw(err)}}); } var saveFloorAs = document.getElementById('saveFloorAs'); @@ -285,10 +283,10 @@ editor_mode.prototype.listen = function(callback){ saveFloorAs.onclick = function(){ if (!saveAsName.value)return; editor_mode.onmode(''); - editor_file.saveFloorFileAs(editor,saveAsName.value,function(err){ + editor.file.saveFloorFileAs(saveAsName.value,function(err){ if(err){printe(err);throw(err)} core.floorIds.push(saveAsName.value); - editor.file.editTower(editor,[['change',"['main']['floorIds']",core.floorIds]],function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])}}); + editor.file.editTower([['change',"['main']['floorIds']",core.floorIds]],function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])}}); }); } @@ -436,5 +434,9 @@ editor_mode.prototype.listen = function(callback){ if (Boolean(callback))callback(); } -editor_mode = new editor_mode(); -editor_mode.init(); \ No newline at end of file +var editor_mode = new editor_mode(); +editor_mode.init_dom_ids(); + +return editor_mode; +} +//editor_mode = editor_mode(editor); \ No newline at end of file diff --git a/editor.html b/editor.html index ecc3947b..9fabf604 100644 --- a/editor.html +++ b/editor.html @@ -324,12 +324,12 @@ function hasOwnProp (obj, key) { main.init('editor'); editor.init(function(){ editor.pos={x: 0, y: 0}; - editor_mode.loc(); + editor.mode.loc(); editor.info=editor.ids[editor.indexs[201]]; - editor_mode.emenyitem(); - editor_mode.floor(); - editor_mode.tower(); - editor_mode.listen(); + editor.mode.emenyitem(); + editor.mode.floor(); + editor.mode.tower(); + editor.mode.listen(); editor_blockly=editor_blockly(); }); From 3ca7c9523152051f5f36d2de94e7c90fe608b6b3 Mon Sep 17 00:00:00 2001 From: oc Date: Sun, 4 Mar 2018 12:59:33 +0800 Subject: [PATCH 08/23] load mod --- main.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/main.js b/main.js index 314dee38..06887014 100644 --- a/main.js +++ b/main.js @@ -106,7 +106,6 @@ function main() { 'hard': document.getElementById("hard") } this.floors = {} - this.instance = {}; this.canvas = {}; } @@ -213,7 +212,6 @@ main.prototype.loadMod = function (modName, callback) { script.src = 'libs/' + modName + (this.useCompress?".min":"") + '.js?v=' + this.version; main.dom.body.appendChild(script); script.onload = function () { - main[name] = main.instance[name]; callback(name); } } From ddd43a1dbcb7a7340426eaeb1a5d6546ee6ef891 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Mon, 5 Mar 2018 09:50:08 +0800 Subject: [PATCH 09/23] Update blockly --- _server/blockly/Converter.bundle.min.js | 2 +- _server/blockly/MotaAction.g4 | 67 ++++++++----------------- _server/editor_blockly.js | 4 +- 3 files changed, 24 insertions(+), 49 deletions(-) diff --git a/_server/blockly/Converter.bundle.min.js b/_server/blockly/Converter.bundle.min.js index 9f0936df..ddd4e0c7 100644 --- a/_server/blockly/Converter.bundle.min.js +++ b/_server/blockly/Converter.bundle.min.js @@ -1 +1 @@ -!function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=32)}([function(t,e){function n(t){return"["+t.join(", ")+"]"}function r(t,e){return t.equals(e)}function i(t){return t.hashCode()}function o(t,e){return this.data={},this.hashFunction=t||i,this.equalsFunction=e||r,this}function s(){return this.data=[],this}function a(t,e){return this.data={},this.hashFunction=t||i,this.equalsFunction=e||r,this}function l(){return this.data={},this}function u(){return this}function c(){return this.count=0,this.hash=0,this}String.prototype.seed=String.prototype.seed||Math.round(Math.random()*Math.pow(2,32)),String.prototype.hashCode=function(){var t,e,n,r,i,o,s,a,l=this.toString();for(t=3&l.length,e=l.length-t,n=String.prototype.seed,i=3432918353,o=461845907,a=0;a>>16)*i&65535)<<16)&4294967295)<<15|s>>>17))*o+(((s>>>16)*o&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(r>>>16)&65535)<<16);switch(s=0,t){case 3:s^=(255&l.charCodeAt(a+2))<<16;case 2:s^=(255&l.charCodeAt(a+1))<<8;case 1:n^=s=(65535&(s=(s=(65535&(s^=255&l.charCodeAt(a)))*i+(((s>>>16)*i&65535)<<16)&4294967295)<<15|s>>>17))*o+(((s>>>16)*o&65535)<<16)&4294967295}return n^=l.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0},Object.defineProperty(o.prototype,"length",{get:function(){var t=0;for(var e in this.data)0===e.indexOf("hash_")&&(t+=this.data[e].length);return t}}),o.prototype.add=function(t){var e="hash_"+this.hashFunction(t);if(e in this.data){for(var n=this.data[e],r=0;r>>17,n*=461845907,this.count=this.count+1;var r=this.hash^n;r=5*(r=r<<13|r>>>19)+3864292196,this.hash=r}}},c.prototype.finish=function(){var t=this.hash^4*this.count;return t^=t>>>16,t*=2246822507,t^=t>>>13,t*=3266489909,t^=t>>>16},u.prototype.get=function(t,e){var n=this[t]||null;return null===n?null:n[e]||null},u.prototype.set=function(t,e,n){var r=this[t]||null;null===r&&(r={},this[t]=r),r[e]=n},e.Hash=c,e.Set=o,e.Map=a,e.BitSet=s,e.AltDict=l,e.DoubleDict=u,e.hashStuff=function(){var t=new c;return t.update.apply(arguments),t.finish()},e.escapeWhitespace=function(t,e){return t=(t=(t=t.replace("\t","\\t")).replace("\n","\\n")).replace("\r","\\r"),e&&(t=t.replace(" ","·")),t},e.arrayToString=n,e.titleCase=function(t){return t.replace(/\w\S*/g,function(t){return t.charAt(0).toUpperCase()+t.substr(1)})},e.equalArrays=function(t,e){if(!Array.isArray(t)||!Array.isArray(e))return!1;if(t==e)return!0;if(t.length!=e.length)return!1;for(var n=0;n"},set:function(t){this._text=t}}),r.prototype.toString=function(){var t=this.text;return t=null!==t?t.replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"):"","[@"+this.tokenIndex+","+this.start+":"+this.stop+"='"+t+"',<"+this.type+">"+(this.channel>0?",channel="+this.channel:"")+","+this.line+":"+this.column+"]"},e.Token=n,e.CommonToken=r},function(t,e,n){var r=n(1).Token;function i(t,e){return this.start=t,this.stop=e,this}function o(){this.intervals=null,this.readOnly=!1}i.prototype.contains=function(t){return t>=this.start&&t=n.stop?(this.intervals.pop(t+1),this.reduce(t)):e.stop>=n.start&&(this.intervals[t]=new i(e.start,n.stop),this.intervals.pop(t+1))}},o.prototype.complement=function(t,e){var n=new o;n.addInterval(new i(t,e+1));for(var r=0;rr.start&&t.stop=r.stop?(this.intervals.splice(e,1),e-=1):t.start"):t.push("'"+String.fromCharCode(n.start)+"'"):t.push("'"+String.fromCharCode(n.start)+"'..'"+String.fromCharCode(n.stop-1)+"'")}return t.length>1?"{"+t.join(", ")+"}":t[0]},o.prototype.toIndexString=function(){for(var t=[],e=0;e"):t.push(n.start.toString()):t.push(n.start.toString()+".."+(n.stop-1).toString())}return t.length>1?"{"+t.join(", ")+"}":t[0]},o.prototype.toTokenString=function(t,e){for(var n=[],r=0;r1?"{"+n.join(", ")+"}":n[0]},o.prototype.elementName=function(t,e,n){return n===r.EOF?"":n===r.EPSILON?"":t[n]||e[n]},e.Interval=i,e.IntervalSet=o},function(t,e){function n(){return this.atn=null,this.stateNumber=n.INVALID_STATE_NUMBER,this.stateType=null,this.ruleIndex=0,this.epsilonOnlyTransitions=!1,this.transitions=[],this.nextTokenWithinRule=null,this}function r(){return n.call(this),this.stateType=n.BASIC,this}function i(){return n.call(this),this.decision=-1,this.nonGreedy=!1,this}function o(){return i.call(this),this.endState=null,this}function s(){return o.call(this),this.stateType=n.BLOCK_START,this}function a(){return n.call(this),this.stateType=n.BLOCK_END,this.startState=null,this}function l(){return n.call(this),this.stateType=n.RULE_STOP,this}function u(){return n.call(this),this.stateType=n.RULE_START,this.stopState=null,this.isPrecedenceRule=!1,this}function c(){return i.call(this),this.stateType=n.PLUS_LOOP_BACK,this}function h(){return o.call(this),this.stateType=n.PLUS_BLOCK_START,this.loopBackState=null,this}function p(){return o.call(this),this.stateType=n.STAR_BLOCK_START,this}function f(){return n.call(this),this.stateType=n.STAR_LOOP_BACK,this}function d(){return i.call(this),this.stateType=n.STAR_LOOP_ENTRY,this.loopBackState=null,this.isPrecedenceDecision=null,this}function y(){return n.call(this),this.stateType=n.LOOP_END,this.loopBackState=null,this}function g(){return i.call(this),this.stateType=n.TOKEN_START,this}n.INVALID_TYPE=0,n.BASIC=1,n.RULE_START=2,n.BLOCK_START=3,n.PLUS_BLOCK_START=4,n.STAR_BLOCK_START=5,n.TOKEN_START=6,n.RULE_STOP=7,n.BLOCK_END=8,n.STAR_LOOP_BACK=9,n.STAR_LOOP_ENTRY=10,n.PLUS_LOOP_BACK=11,n.LOOP_END=12,n.serializationNames=["INVALID","BASIC","RULE_START","BLOCK_START","PLUS_BLOCK_START","STAR_BLOCK_START","TOKEN_START","RULE_STOP","BLOCK_END","STAR_LOOP_BACK","STAR_LOOP_ENTRY","PLUS_LOOP_BACK","LOOP_END"],n.INVALID_STATE_NUMBER=-1,n.prototype.toString=function(){return this.stateNumber},n.prototype.equals=function(t){return t instanceof n&&this.stateNumber===t.stateNumber},n.prototype.isNonGreedyExitState=function(){return!1},n.prototype.addTransition=function(t,e){void 0===e&&(e=-1),0===this.transitions.length?this.epsilonOnlyTransitions=t.isEpsilon:this.epsilonOnlyTransitions!==t.isEpsilon&&(this.epsilonOnlyTransitions=!1),-1===e?this.transitions.push(t):this.transitions.splice(e,1,t)},r.prototype=Object.create(n.prototype),r.prototype.constructor=r,i.prototype=Object.create(n.prototype),i.prototype.constructor=i,o.prototype=Object.create(i.prototype),o.prototype.constructor=o,s.prototype=Object.create(o.prototype),s.prototype.constructor=s,a.prototype=Object.create(n.prototype),a.prototype.constructor=a,l.prototype=Object.create(n.prototype),l.prototype.constructor=l,u.prototype=Object.create(n.prototype),u.prototype.constructor=u,c.prototype=Object.create(i.prototype),c.prototype.constructor=c,h.prototype=Object.create(o.prototype),h.prototype.constructor=h,p.prototype=Object.create(o.prototype),p.prototype.constructor=p,f.prototype=Object.create(n.prototype),f.prototype.constructor=f,d.prototype=Object.create(i.prototype),d.prototype.constructor=d,y.prototype=Object.create(n.prototype),y.prototype.constructor=y,g.prototype=Object.create(i.prototype),g.prototype.constructor=g,e.ATNState=n,e.BasicState=r,e.DecisionState=i,e.BlockStartState=o,e.BlockEndState=a,e.LoopEndState=y,e.RuleStartState=u,e.RuleStopState=l,e.TokensStartState=g,e.PlusLoopbackState=c,e.StarLoopbackState=f,e.StarLoopEntryState=d,e.PlusBlockStartState=h,e.StarBlockStartState=p,e.BasicBlockStartState=s},function(t,e,n){var r=n(1).Token,i=n(2).Interval,o=new i(-1,-2);n(0);function s(){return this}function a(){return s.call(this),this}function l(){return a.call(this),this}function u(){return l.call(this),this}function c(){return l.call(this),this}function h(){return c.call(this),this}function p(){return this}function f(){return this}function d(t){return c.call(this),this.parentCtx=null,this.symbol=t,this}function y(t){return d.call(this,t),this}function g(){return this}a.prototype=Object.create(s.prototype),a.prototype.constructor=a,l.prototype=Object.create(a.prototype),l.prototype.constructor=l,u.prototype=Object.create(l.prototype),u.prototype.constructor=u,c.prototype=Object.create(l.prototype),c.prototype.constructor=c,h.prototype=Object.create(c.prototype),h.prototype.constructor=h,p.prototype.visit=function(t){return Array.isArray(t)?t.map(function(t){return t.accept(this)},this):t.accept(this)},p.prototype.visitChildren=function(t){return this.visit(t.children)},p.prototype.visitTerminal=function(t){},p.prototype.visitErrorNode=function(t){},f.prototype.visitTerminal=function(t){},f.prototype.visitErrorNode=function(t){},f.prototype.enterEveryRule=function(t){},f.prototype.exitEveryRule=function(t){},d.prototype=Object.create(c.prototype),d.prototype.constructor=d,d.prototype.getChild=function(t){return null},d.prototype.getSymbol=function(){return this.symbol},d.prototype.getParent=function(){return this.parentCtx},d.prototype.getPayload=function(){return this.symbol},d.prototype.getSourceInterval=function(){if(null===this.symbol)return o;var t=this.symbol.tokenIndex;return new i(t,t)},d.prototype.getChildCount=function(){return 0},d.prototype.accept=function(t){return t.visitTerminal(this)},d.prototype.getText=function(){return this.symbol.text},d.prototype.toString=function(){return this.symbol.type===r.EOF?"":this.symbol.text},y.prototype=Object.create(d.prototype),y.prototype.constructor=y,y.prototype.isErrorNode=function(){return!0},y.prototype.accept=function(t){return t.visitErrorNode(this)},g.prototype.walk=function(t,e){if(e instanceof h||void 0!==e.isErrorNode&&e.isErrorNode())t.visitErrorNode(e);else if(e instanceof c)t.visitTerminal(e);else{this.enterRule(t,e);for(var n=0;n=0&&this.startIndexe.returnState&&(f[0]=e.returnState,f[1]=t.returnState);var d=[p,p],y=new u(d,f);return null!==r&&r.set(t,e,y),y}var f=[t.returnState,e.returnState],d=[t.parentCtx,e.parentCtx];t.returnState>e.returnState&&(f[0]=e.returnState,f[1]=t.returnState,d=[e.parentCtx,t.parentCtx]);var g=new u(d,f);return null!==r&&r.set(t,e,g),g}(t,e,n,r);if(n){if(t instanceof l)return t;if(e instanceof l)return e}return t instanceof a&&(t=new u([t.getParent()],[t.returnState])),e instanceof a&&(e=new u([e.getParent()],[e.returnState])),function(t,e,n,r){if(null!==r){var i=r.get(t,e);if(null!==i)return i;if(null!==(i=r.get(e,t)))return i}var s=0,l=0,h=0,p=[],f=[];for(;s0&&(t+=", "),this.returnStates[e]!==o.EMPTY_RETURN_STATE?(t+=this.returnStates[e],null!==this.parents[e]?t=t+" "+this.parents[e]:t+="null"):t+="$";return t+"]"},e.merge=c,e.PredictionContext=o,e.PredictionContextCache=s,e.SingletonPredictionContext=a,e.predictionContextFromRuleContext=function t(e,n){if(void 0!==n&&null!==n||(n=r.EMPTY),null===n.parentCtx||n===r.EMPTY)return o.EMPTY;var i=t(e,n.parentCtx),s=e.states[n.invokingState].transitions[0];return a.create(i,s.followState.stateNumber)},e.getCachedPredictionContext=function t(e,n,r){if(e.isEmpty())return e;var i=r[e]||null;if(null!==i)return i;if(null!==(i=n.get(e)))return r[e]=i,i;for(var s=!1,l=[],c=0;c=this.states.length)throw"Invalid state number.";var n=this.states[t],r=this.nextTokens(n);if(!r.contains(s.EPSILON))return r;var o=new i;for(o.addSet(r),o.removeOne(s.EPSILON);null!==e&&e.invokingState>=0&&r.contains(s.EPSILON);){var a=this.states[e.invokingState].transitions[0];r=this.nextTokens(a.followState),o.addSet(r),o.removeOne(s.EPSILON),e=e.parentCtx}return r.contains(s.EPSILON)&&o.addOne(s.EOF),o},o.INVALID_ALT_NUMBER=0,e.ATN=o},function(t,e,n){var r=n(1).Token,i=(n(2).Interval,n(2).IntervalSet),o=n(10).Predicate,s=n(10).PrecedencePredicate;function a(t){if(void 0===t||null===t)throw"target cannot be null.";return this.target=t,this.isEpsilon=!1,this.label=null,this}function l(t,e){return a.call(this,t),this.label_=e,this.label=this.makeLabel(),this.serializationType=a.ATOM,this}function u(t,e,n,r){return a.call(this,t),this.ruleIndex=e,this.precedence=n,this.followState=r,this.serializationType=a.RULE,this.isEpsilon=!0,this}function c(t,e){return a.call(this,t),this.serializationType=a.EPSILON,this.isEpsilon=!0,this.outermostPrecedenceReturn=e,this}function h(t,e,n){return a.call(this,t),this.serializationType=a.RANGE,this.start=e,this.stop=n,this.label=this.makeLabel(),this}function p(t){return a.call(this,t),this}function f(t,e,n,r){return p.call(this,t),this.serializationType=a.PREDICATE,this.ruleIndex=e,this.predIndex=n,this.isCtxDependent=r,this.isEpsilon=!0,this}function d(t,e,n,r){return a.call(this,t),this.serializationType=a.ACTION,this.ruleIndex=e,this.actionIndex=void 0===n?-1:n,this.isCtxDependent=void 0!==r&&r,this.isEpsilon=!0,this}function y(t,e){return a.call(this,t),this.serializationType=a.SET,void 0!==e&&null!==e?this.label=e:(this.label=new i,this.label.addOne(r.INVALID_TYPE)),this}function g(t,e){return y.call(this,t,e),this.serializationType=a.NOT_SET,this}function v(t){return a.call(this,t),this.serializationType=a.WILDCARD,this}function x(t,e){return p.call(this,t),this.serializationType=a.PRECEDENCE,this.precedence=e,this.isEpsilon=!0,this}a.EPSILON=1,a.RANGE=2,a.RULE=3,a.PREDICATE=4,a.ATOM=5,a.ACTION=6,a.SET=7,a.NOT_SET=8,a.WILDCARD=9,a.PRECEDENCE=10,a.serializationNames=["INVALID","EPSILON","RANGE","RULE","PREDICATE","ATOM","ACTION","SET","NOT_SET","WILDCARD","PRECEDENCE"],a.serializationTypes={EpsilonTransition:a.EPSILON,RangeTransition:a.RANGE,RuleTransition:a.RULE,PredicateTransition:a.PREDICATE,AtomTransition:a.ATOM,ActionTransition:a.ACTION,SetTransition:a.SET,NotSetTransition:a.NOT_SET,WildcardTransition:a.WILDCARD,PrecedencePredicateTransition:a.PRECEDENCE},l.prototype=Object.create(a.prototype),l.prototype.constructor=l,l.prototype.makeLabel=function(){var t=new i;return t.addOne(this.label_),t},l.prototype.matches=function(t,e,n){return this.label_===t},l.prototype.toString=function(){return this.label_},u.prototype=Object.create(a.prototype),u.prototype.constructor=u,u.prototype.matches=function(t,e,n){return!1},c.prototype=Object.create(a.prototype),c.prototype.constructor=c,c.prototype.matches=function(t,e,n){return!1},c.prototype.toString=function(){return"epsilon"},h.prototype=Object.create(a.prototype),h.prototype.constructor=h,h.prototype.makeLabel=function(){var t=new i;return t.addRange(this.start,this.stop),t},h.prototype.matches=function(t,e,n){return t>=this.start&&t<=this.stop},h.prototype.toString=function(){return"'"+String.fromCharCode(this.start)+"'..'"+String.fromCharCode(this.stop)+"'"},p.prototype=Object.create(a.prototype),p.prototype.constructor=p,f.prototype=Object.create(p.prototype),f.prototype.constructor=f,f.prototype.matches=function(t,e,n){return!1},f.prototype.getPredicate=function(){return new o(this.ruleIndex,this.predIndex,this.isCtxDependent)},f.prototype.toString=function(){return"pred_"+this.ruleIndex+":"+this.predIndex},d.prototype=Object.create(a.prototype),d.prototype.constructor=d,d.prototype.matches=function(t,e,n){return!1},d.prototype.toString=function(){return"action_"+this.ruleIndex+":"+this.actionIndex},y.prototype=Object.create(a.prototype),y.prototype.constructor=y,y.prototype.matches=function(t,e,n){return this.label.contains(t)},y.prototype.toString=function(){return this.label.toString()},g.prototype=Object.create(y.prototype),g.prototype.constructor=g,g.prototype.matches=function(t,e,n){return t>=e&&t<=n&&!y.prototype.matches.call(this,t,e,n)},g.prototype.toString=function(){return"~"+y.prototype.toString.call(this)},v.prototype=Object.create(a.prototype),v.prototype.constructor=v,v.prototype.matches=function(t,e,n){return t>=e&&t<=n},v.prototype.toString=function(){return"."},x.prototype=Object.create(p.prototype),x.prototype.constructor=x,x.prototype.matches=function(t,e,n){return!1},x.prototype.getPredicate=function(){return new s(this.precedence)},x.prototype.toString=function(){return this.precedence+" >= _p"},e.Transition=a,e.AtomTransition=l,e.SetTransition=y,e.NotSetTransition=g,e.RuleTransition=u,e.ActionTransition=d,e.EpsilonTransition=c,e.RangeTransition=h,e.WildcardTransition=v,e.PredicateTransition=f,e.PrecedencePredicateTransition=x,e.AbstractPredicateTransition=p},function(t,e,n){var r=n(7).ATN,i=n(0),o=i.Hash,s=i.Set,a=n(10).SemanticContext,l=n(6).merge;function u(t){return t.hashCodeForConfigSet()}function c(t,e){return t===e||null!==t&&null!==e&&t.equalsForConfigSet(e)}function h(t){return this.configLookup=new s(u,c),this.fullCtx=void 0===t||t,this.readOnly=!1,this.configs=[],this.uniqueAlt=0,this.conflictingAlts=null,this.hasSemanticContext=!1,this.dipsIntoOuterContext=!1,this.cachedHashCode=-1,this}function p(){return h.call(this),this.configLookup=new s,this}h.prototype.add=function(t,e){if(void 0===e&&(e=null),this.readOnly)throw"This set is readonly";t.semanticContext!==a.NONE&&(this.hasSemanticContext=!0),t.reachesIntoOuterContext>0&&(this.dipsIntoOuterContext=!0);var n=this.configLookup.add(t);if(n===t)return this.cachedHashCode=-1,this.configs.push(t),!0;var r=!this.fullCtx,i=l(n.context,t.context,r,e);return n.reachesIntoOuterContext=Math.max(n.reachesIntoOuterContext,t.reachesIntoOuterContext),t.precedenceFilterSuppressed&&(n.precedenceFilterSuppressed=!0),n.context=i,!0},h.prototype.getStates=function(){for(var t=new s,e=0;e0){var s=null;i.map(function(t){(null===s||t.precedence0){var s=i.sort(function(t,e){return t.compareTo(e)}),l=s[s.length-1];n.add(l)}return this.opnds=n.values(),this}o.prototype.hashCode=function(){var t=new i;return this.updateHashCode(t),t.finish()},o.prototype.evaluate=function(t,e){},o.prototype.evalPrecedence=function(t,e){return this},o.andContext=function(t,e){if(null===t||t===o.NONE)return e;if(null===e||e===o.NONE)return t;var n=new l(t,e);return 1===n.opnds.length?n.opnds[0]:n},o.orContext=function(t,e){if(null===t)return e;if(null===e)return t;if(t===o.NONE||e===o.NONE)return o.NONE;var n=new u(t,e);return 1===n.opnds.length?n.opnds[0]:n},s.prototype=Object.create(o.prototype),s.prototype.constructor=s,o.NONE=new s,s.prototype.evaluate=function(t,e){var n=this.isCtxDependent?e:null;return t.sempred(n,this.ruleIndex,this.predIndex)},s.prototype.updateHashCode=function(t){t.update(this.ruleIndex,this.predIndex,this.isCtxDependent)},s.prototype.equals=function(t){return this===t||t instanceof s&&(this.ruleIndex===t.ruleIndex&&this.predIndex===t.predIndex&&this.isCtxDependent===t.isCtxDependent)},s.prototype.toString=function(){return"{"+this.ruleIndex+":"+this.predIndex+"}?"},a.prototype=Object.create(o.prototype),a.prototype.constructor=a,a.prototype.evaluate=function(t,e){return t.precpred(e,this.precedence)},a.prototype.evalPrecedence=function(t,e){return t.precpred(e,this.precedence)?o.NONE:null},a.prototype.compareTo=function(t){return this.precedence-t.precedence},a.prototype.updateHashCode=function(t){t.update(31)},a.prototype.equals=function(t){return this===t||t instanceof a&&this.precedence===t.precedence},a.prototype.toString=function(){return"{"+this.precedence+">=prec}?"},a.filterPrecedencePredicates=function(t){var e=[];return t.values().map(function(t){t instanceof a&&e.push(t)}),e},l.prototype=Object.create(o.prototype),l.prototype.constructor=l,l.prototype.equals=function(t){return this===t||t instanceof l&&this.opnds===t.opnds},l.prototype.updateHashCode=function(t){t.update(this.opnds,"AND")},l.prototype.evaluate=function(t,e){for(var n=0;n3?t.slice(3):t},u.prototype=Object.create(o.prototype),u.prototype.constructor=u,u.prototype.constructor=function(t){return this===t||t instanceof u&&this.opnds===t.opnds},u.prototype.updateHashCode=function(t){t.update(this.opnds,"OR")},u.prototype.evaluate=function(t,e){for(var n=0;n3?t.slice(3):t},e.SemanticContext=o,e.PrecedencePredicate=a,e.Predicate=s},function(t,e,n){var r=n(9).ATNConfigSet,i=n(0),o=i.Hash,s=i.Set;function a(t,e){return this.alt=e,this.pred=t,this}function l(t,e){return null===t&&(t=-1),null===e&&(e=new r),this.stateNumber=t,this.configs=e,this.edges=null,this.isAcceptState=!1,this.prediction=0,this.lexerActionExecutor=null,this.requiresFullContext=!1,this.predicates=null,this}a.prototype.toString=function(){return"("+this.pred+", "+this.alt+")"},l.prototype.getAltSet=function(){var t=new s;if(null!==this.configs)for(var e=0;e0?",up="+this.reachesIntoOuterContext:"")+")"},l.prototype=Object.create(a.prototype),l.prototype.constructor=l,l.prototype.updateHashCode=function(t){t.update(this.state.stateNumber,this.alt,this.context,this.semanticContext,this.passedThroughNonGreedyDecision,this.lexerActionExecutor)},l.prototype.equals=function(t){return this===t||t instanceof l&&this.passedThroughNonGreedyDecision==t.passedThroughNonGreedyDecision&&(this.lexerActionExecutor?this.lexerActionExecutor.equals(t.lexerActionExecutor):!t.lexerActionExecutor)&&a.prototype.equals.call(this,t)},l.prototype.hashCodeForConfigSet=l.prototype.hashCode,l.prototype.equalsForConfigSet=l.prototype.equals,l.prototype.checkNonGreedyDecision=function(t,e){return t.passedThroughNonGreedyDecision||e instanceof r&&e.nonGreedy},e.ATNConfig=a,e.LexerATNConfig=l},function(t,e,n){var r=n(4).RuleNode,i=n(4).INVALID_INTERVAL,o=n(7).INVALID_ALT_NUMBER;function s(t,e){return r.call(this),this.parentCtx=t||null,this.invokingState=e||-1,this}s.prototype=Object.create(r.prototype),s.prototype.constructor=s,s.prototype.depth=function(){for(var t=0,e=this;null!==e;)e=e.parentCtx,t+=1;return t},s.prototype.isEmpty=function(){return-1===this.invokingState},s.prototype.getSourceInterval=function(){return i},s.prototype.getRuleContext=function(){return this},s.prototype.getPayload=function(){return this},s.prototype.getText=function(){return 0===this.getChildCount()?"":this.children.map(function(t){return t.getText()}).join("")},s.prototype.getAltNumber=function(){return o},s.prototype.setAltNumber=function(t){},s.prototype.getChild=function(t){return null},s.prototype.getChildCount=function(){return 0},s.prototype.accept=function(t){return t.visitChildren(this)},e.RuleContext=s;var a=n(21).Trees;s.prototype.toStringTree=function(t,e){return a.toStringTree(this,t,e)},s.prototype.toString=function(t,e){t=t||null,e=e||null;for(var n=this,r="[";null!==n&&n!==e;){if(null===t)n.isEmpty()||(r+=n.invokingState);else{var i=n.ruleIndex;r+=i>=0&&i":"\n"===t?"\\n":"\t"===t?"\\t":"\r"===t?"\\r":t},l.prototype.getCharErrorDisplay=function(t){return"'"+this.getErrorDisplayForChar(t)+"'"},l.prototype.recover=function(t){this._input.LA(1)!==r.EOF&&(t instanceof a?this._interp.consume(this._input):this._input.consume())},e.Lexer=l},function(t,e){function n(){return this}function r(){return n.call(this),this}function i(t){if(n.call(this),null===t)throw"delegates";return this.delegates=t,this}n.prototype.syntaxError=function(t,e,n,r,i,o){},n.prototype.reportAmbiguity=function(t,e,n,r,i,o,s){},n.prototype.reportAttemptingFullContext=function(t,e,n,r,i,o){},n.prototype.reportContextSensitivity=function(t,e,n,r,i,o){},r.prototype=Object.create(n.prototype),r.prototype.constructor=r,r.INSTANCE=new r,r.prototype.syntaxError=function(t,e,n,r,i,o){console.error("line "+n+":"+r+" "+i)},i.prototype=Object.create(n.prototype),i.prototype.constructor=i,i.prototype.syntaxError=function(t,e,n,r,i,o){this.delegates.map(function(s){s.syntaxError(t,e,n,r,i,o)})},i.prototype.reportAmbiguity=function(t,e,n,r,i,o,s){this.delegates.map(function(a){a.reportAmbiguity(t,e,n,r,i,o,s)})},i.prototype.reportAttemptingFullContext=function(t,e,n,r,i,o){this.delegates.map(function(s){s.reportAttemptingFullContext(t,e,n,r,i,o)})},i.prototype.reportContextSensitivity=function(t,e,n,r,i,o){this.delegates.map(function(s){s.reportContextSensitivity(t,e,n,r,i,o)})},e.ErrorListener=n,e.ConsoleErrorListener=r,e.ProxyErrorListener=i},function(t,e){function n(t,e,n){return this.dfa=t,this.literalNames=e||[],this.symbolicNames=n||[],this}function r(t){return n.call(this,t,null),this}n.prototype.toString=function(){if(null===this.dfa.s0)return null;for(var t="",e=this.dfa.sortedStates(),n=0;n")).concat(this.getStateString(s))).concat("\n"))}}return 0===t.length?null:t},n.prototype.getEdgeLabel=function(t){return 0===t?"EOF":null!==this.literalNames||null!==this.symbolicNames?this.literalNames[t-1]||this.symbolicNames[t-1]:String.fromCharCode(t-1)},n.prototype.getStateString=function(t){var e=(t.isAcceptState?":":"")+"s"+t.stateNumber+(t.requiresFullContext?"^":"");return t.isAcceptState?null!==t.predicates?e+"=>"+t.predicates.toString():e+"=>"+t.prediction.toString():e},r.prototype=Object.create(n.prototype),r.prototype.constructor=r,r.prototype.getEdgeLabel=function(t){return"'"+String.fromCharCode(t)+"'"},e.DFASerializer=n,e.LexerDFASerializer=r},function(t,e,n){var r=n(14).RuleContext,i=n(4),o=i.INVALID_INTERVAL,s=i.TerminalNode,a=i.TerminalNodeImpl,l=i.ErrorNodeImpl,u=n(2).Interval;function c(t,e){t=t||null,e=e||null,r.call(this,t,e),this.ruleIndex=-1,this.children=null,this.start=null,this.stop=null,this.exception=null}function h(t,e,n){return c.call(t,e),this.ruleIndex=n,this}c.prototype=Object.create(r.prototype),c.prototype.constructor=c,c.prototype.copyFrom=function(t){this.parentCtx=t.parentCtx,this.invokingState=t.invokingState,this.children=null,this.start=t.start,this.stop=t.stop,t.children&&(this.children=[],t.children.map(function(t){t instanceof l&&(this.children.push(t),t.parentCtx=this)},this))},c.prototype.enterRule=function(t){},c.prototype.exitRule=function(t){},c.prototype.addChild=function(t){return null===this.children&&(this.children=[]),this.children.push(t),t},c.prototype.removeLastChild=function(){null!==this.children&&this.children.pop()},c.prototype.addTokenNode=function(t){var e=new a(t);return this.addChild(e),e.parentCtx=this,e},c.prototype.addErrorNode=function(t){var e=new l(t);return this.addChild(e),e.parentCtx=this,e},c.prototype.getChild=function(t,e){if(e=e||null,null===this.children||t<0||t>=this.children.length)return null;if(null===e)return this.children[t];for(var n=0;n=this.children.length)return null;for(var n=0;n=this._size)throw"cannot consume EOF";this._index+=1},i.prototype.LA=function(t){if(0===t)return 0;t<0&&(t+=1);var e=this._index+t-1;return e<0||e>=this._size?r.EOF:this.data[e]},i.prototype.LT=function(t){return this.LA(t)},i.prototype.mark=function(){return-1},i.prototype.release=function(t){},i.prototype.seek=function(t){t<=this._index?this._index=t:this._index=Math.min(t,this._size)},i.prototype.getText=function(t,e){if(e>=this._size&&(e=this._size-1),t>=this._size)return"";if(this.decodeToUnicodeCodePoints){for(var n="",r=t;r<=e;r++)n+=String.fromCodePoint(this.data[r]);return n}return this.strdata.slice(t,e+1)},i.prototype.toString=function(){return this.strdata},e.InputStream=i},function(t,e,n){var r=n(12);function i(){return r.tree.ParseTreeVisitor.call(this),this}i.prototype=Object.create(r.tree.ParseTreeVisitor.prototype),i.prototype.constructor=i,i.prototype.visitGrammarFile=function(t){return this.visitChildren(t)},i.prototype.visitGrammerDecl=function(t){return this.visitChildren(t)},i.prototype.visitStatExprSplit=function(t){return this.visitChildren(t)},i.prototype.visitStatList=function(t){return this.visitChildren(t)},i.prototype.visitStatValue=function(t){return this.visitChildren(t)},i.prototype.visitExprExpression=function(t){return this.visitChildren(t)},i.prototype.visitExprValue=function(t){return this.visitChildren(t)},i.prototype.visitArithmeticRuleCollection=function(t){return this.visitChildren(t)},i.prototype.visitParserAtomExpr=function(t){return this.visitChildren(t)},i.prototype.visitParserAtomParserId=function(t){return this.visitChildren(t)},i.prototype.visitParserAtomLexerId=function(t){return this.visitChildren(t)},i.prototype.visitParserAtomStr=function(t){return this.visitChildren(t)},i.prototype.visitLexerRuleCollection=function(t){return this.visitChildren(t)},i.prototype.visitMeaningfulSplit=function(t){return this.visitChildren(t)},i.prototype.visitLexerRuleStrings=function(t){return this.visitChildren(t)},i.prototype.visitLexerRuleList=function(t){return this.visitChildren(t)},i.prototype.visitLexerRuleComplex=function(t){return this.visitChildren(t)},i.prototype.visitStrings=function(t){return this.visitChildren(t)},i.prototype.visitLexerRuleAtom=function(t){return this.visitChildren(t)},e.BlocklyGrammerVisitor=i},function(t,e,n){var r=n(0),i=n(1).Token,o=(n(4).RuleNode,n(4).ErrorNode),s=n(4).TerminalNode,a=n(18).ParserRuleContext,l=n(14).RuleContext,u=n(7).INVALID_ALT_NUMBER;function c(){}c.toStringTree=function(t,e,n){e=e||null,null!==(n=n||null)&&(e=n.ruleNames);var i=c.getNodeText(t,e);i=r.escapeWhitespace(i,!1);var o=t.getChildCount();if(0===o)return i;var s="("+i+" ";o>0&&(i=c.toStringTree(t.getChild(0),e),s=s.concat(i));for(var a=1;a=n},W.prototype.deserialize=function(t){this.reset(t),this.checkVersion(),this.checkUUID();var e=this.readATN();this.readStates(e),this.readRules(e),this.readModes(e);var n=[];return this.readSets(e,n,this.readInt.bind(this)),this.isFeatureSupported(Y,this.uuid)&&this.readSets(e,n,this.readInt32.bind(this)),this.readEdges(e,n),this.readDecisions(e),this.readLexerActions(e),this.markPrecedenceDecisions(e),this.verifyATN(e),this.deserializationOptions.generateRuleBypassTransitions&&e.grammarType===o.PARSER&&(this.generateRuleBypassTransitions(e),this.verifyATN(e)),e},W.prototype.reset=function(t){var e=t.split("").map(function(t){var e=t.charCodeAt(0);return e>1?e-2:-1});e[0]=t.charCodeAt(0),this.data=e,this.pos=0},W.prototype.checkVersion=function(){var t=this.readInt();if(3!==t)throw"Could not deserialize ATN with version "+t+" (expected 3)."},W.prototype.checkUUID=function(){var t=this.readUUID();if(K.indexOf(t)<0)throw"59627784-3BE5-417A-B9EB-8131A7286089";this.uuid=t},W.prototype.readATN=function(){var t=this.readInt(),e=this.readInt();return new i(t,e)},W.prototype.readStates=function(t){for(var e,n,r,i=[],o=[],s=this.readInt(),l=0;l0;)i.addTransition(p.transitions[f-1]),p.transitions=p.transitions.slice(-1);t.ruleToStartState[e].addTransition(new N(i)),o.addTransition(new N(a));var d=new l;t.addState(d),d.addTransition(new C(o,t.ruleToTokenType[e])),i.addTransition(new N(d))},W.prototype.stateIsEndStateFor=function(t,e){if(t.ruleIndex!==e)return null;if(!(t instanceof x))return null;var n=t.transitions[t.transitions.length-1].target;return n instanceof p&&n.epsilonOnlyTransitions&&n.transitions[0].target instanceof d?t:null},W.prototype.markPrecedenceDecisions=function(t){for(var e=0;e=0):this.checkCondition(n.transitions.length<=1||n instanceof d)}},W.prototype.checkCondition=function(t,e){if(!t)throw void 0!==e&&null!==e||(e="IllegalState"),e},W.prototype.readInt=function(){return this.data[this.pos++]},W.prototype.readInt32=function(){return this.readInt()|this.readInt()<<16},W.prototype.readLong=function(){return 4294967295&this.readInt32()|this.readInt32()<<32};var X=function(){for(var t=[],e=0;e<256;e++)t[e]=(e+256).toString(16).substr(1).toUpperCase();return t}();W.prototype.readUUID=function(){for(var t=[],e=7;e>=0;e--){var n=this.readInt();t[2*e+1]=255&n,t[2*e]=n>>8&255}return X[t[0]]+X[t[1]]+X[t[2]]+X[t[3]]+"-"+X[t[4]]+X[t[5]]+"-"+X[t[6]]+X[t[7]]+"-"+X[t[8]]+X[t[9]]+"-"+X[t[10]]+X[t[11]]+X[t[12]]+X[t[13]]+X[t[14]]+X[t[15]]},W.prototype.edgeFactory=function(t,e,n,i,o,s,a,l){var u=t.states[i];switch(e){case E.EPSILON:return new N(u);case E.RANGE:return new R(u,0!==a?r.EOF:o,s);case E.RULE:return new b(t.states[o],s,a,u);case E.PREDICATE:return new O(u,o,s,0!==a);case E.PRECEDENCE:return new P(u,o);case E.ATOM:return new C(u,0!==a?r.EOF:o);case E.ACTION:return new L(u,o,s,0!==a);case E.SET:return new A(u,l[o]);case E.NOT_SET:return new k(u,l[o]);case E.WILDCARD:return new I(u);default:throw"The specified transition type: "+e+" is not valid."}},W.prototype.stateFactory=function(t,e){if(null===this.stateFactories){var n=[];n[a.INVALID_TYPE]=null,n[a.BASIC]=function(){return new l},n[a.RULE_START]=function(){return new f},n[a.BLOCK_START]=function(){return new _},n[a.PLUS_BLOCK_START]=function(){return new m},n[a.STAR_BLOCK_START]=function(){return new T},n[a.TOKEN_START]=function(){return new y},n[a.RULE_STOP]=function(){return new d},n[a.BLOCK_END]=function(){return new h},n[a.STAR_LOOP_BACK]=function(){return new v},n[a.STAR_LOOP_ENTRY]=function(){return new x},n[a.PLUS_LOOP_BACK]=function(){return new g},n[a.LOOP_END]=function(){return new p},this.stateFactories=n}if(t>this.stateFactories.length||null===this.stateFactories[t])throw"The specified state type "+t+" is not valid.";var r=this.stateFactories[t]();if(null!==r)return r.ruleIndex=e,r},W.prototype.lexerActionFactory=function(t,e,n){if(null===this.actionFactories){var r=[];r[j.CHANNEL]=function(t,e){return new B(t)},r[j.CUSTOM]=function(t,e){return new U(t,e)},r[j.MODE]=function(t,e){return new G(t)},r[j.MORE]=function(t,e){return V.INSTANCE},r[j.POP_MODE]=function(t,e){return q.INSTANCE},r[j.PUSH_MODE]=function(t,e){return new z(t)},r[j.SKIP]=function(t,e){return M.INSTANCE},r[j.TYPE]=function(t,e){return new H(t)},this.actionFactories=r}if(t>this.actionFactories.length||null===this.actionFactories[t])throw"The specified lexer action type "+t+" is not valid.";return this.actionFactories[t](e,n)},e.ATNDeserializer=W},function(t,e){function n(t){return void 0===t&&(t=null),this.readOnly=!1,this.verifyATN=null===t||t.verifyATN,this.generateRuleBypassTransitions=null!==t&&t.generateRuleBypassTransitions,this}n.defaultOptions=new n,n.defaultOptions.readOnly=!0,e.ATNDeserializationOptions=n},function(t,e){function n(){}function r(t){return this.actionType=t,this.isPositionDependent=!1,this}function i(){return r.call(this,n.SKIP),this}function o(t){return r.call(this,n.TYPE),this.type=t,this}function s(t){return r.call(this,n.PUSH_MODE),this.mode=t,this}function a(){return r.call(this,n.POP_MODE),this}function l(){return r.call(this,n.MORE),this}function u(t){return r.call(this,n.MODE),this.mode=t,this}function c(t,e){return r.call(this,n.CUSTOM),this.ruleIndex=t,this.actionIndex=e,this.isPositionDependent=!0,this}function h(t){return r.call(this,n.CHANNEL),this.channel=t,this}function p(t,e){return r.call(this,e.actionType),this.offset=t,this.action=e,this.isPositionDependent=!0,this}n.CHANNEL=0,n.CUSTOM=1,n.MODE=2,n.MORE=3,n.POP_MODE=4,n.PUSH_MODE=5,n.SKIP=6,n.TYPE=7,r.prototype.hashCode=function(){var t=new Hash;return this.updateHashCode(t),t.finish()},r.prototype.updateHashCode=function(t){t.update(this.actionType)},r.prototype.equals=function(t){return this===t},i.prototype=Object.create(r.prototype),i.prototype.constructor=i,i.INSTANCE=new i,i.prototype.execute=function(t){t.skip()},i.prototype.toString=function(){return"skip"},o.prototype=Object.create(r.prototype),o.prototype.constructor=o,o.prototype.execute=function(t){t.type=this.type},o.prototype.updateHashCode=function(t){t.update(this.actionType,this.type)},o.prototype.equals=function(t){return this===t||t instanceof o&&this.type===t.type},o.prototype.toString=function(){return"type("+this.type+")"},s.prototype=Object.create(r.prototype),s.prototype.constructor=s,s.prototype.execute=function(t){t.pushMode(this.mode)},s.prototype.updateHashCode=function(t){t.update(this.actionType,this.mode)},s.prototype.equals=function(t){return this===t||t instanceof s&&this.mode===t.mode},s.prototype.toString=function(){return"pushMode("+this.mode+")"},a.prototype=Object.create(r.prototype),a.prototype.constructor=a,a.INSTANCE=new a,a.prototype.execute=function(t){t.popMode()},a.prototype.toString=function(){return"popMode"},l.prototype=Object.create(r.prototype),l.prototype.constructor=l,l.INSTANCE=new l,l.prototype.execute=function(t){t.more()},l.prototype.toString=function(){return"more"},u.prototype=Object.create(r.prototype),u.prototype.constructor=u,u.prototype.execute=function(t){t.mode(this.mode)},u.prototype.updateHashCode=function(t){t.update(this.actionType,this.mode)},u.prototype.equals=function(t){return this===t||t instanceof u&&this.mode===t.mode},u.prototype.toString=function(){return"mode("+this.mode+")"},c.prototype=Object.create(r.prototype),c.prototype.constructor=c,c.prototype.execute=function(t){t.action(null,this.ruleIndex,this.actionIndex)},c.prototype.updateHashCode=function(t){t.update(this.actionType,this.ruleIndex,this.actionIndex)},c.prototype.equals=function(t){return this===t||t instanceof c&&(this.ruleIndex===t.ruleIndex&&this.actionIndex===t.actionIndex)},h.prototype=Object.create(r.prototype),h.prototype.constructor=h,h.prototype.execute=function(t){t._channel=this.channel},h.prototype.updateHashCode=function(t){t.update(this.actionType,this.channel)},h.prototype.equals=function(t){return this===t||t instanceof h&&this.channel===t.channel},h.prototype.toString=function(){return"channel("+this.channel+")"},p.prototype=Object.create(r.prototype),p.prototype.constructor=p,p.prototype.execute=function(t){this.action.execute(t)},p.prototype.updateHashCode=function(t){t.update(this.actionType,this.offset,this.action)},p.prototype.equals=function(t){return this===t||t instanceof p&&(this.offset===t.offset&&this.action===t.action)},e.LexerActionType=n,e.LexerSkipAction=i,e.LexerChannelAction=h,e.LexerCustomAction=c,e.LexerIndexedCustomAction=p,e.LexerMoreAction=l,e.LexerTypeAction=o,e.LexerPushModeAction=s,e.LexerPopModeAction=a,e.LexerModeAction=u},function(t,e,n){var r=n(1).Token,i=n(16).ConsoleErrorListener,o=n(16).ProxyErrorListener;function s(){return this._listeners=[i.INSTANCE],this._interp=null,this._stateNumber=-1,this}s.tokenTypeMapCache={},s.ruleIndexMapCache={},s.prototype.checkVersion=function(t){"4.7"!==t&&console.log("ANTLR runtime and generated code versions disagree: 4.7!="+t)},s.prototype.addErrorListener=function(t){this._listeners.push(t)},s.prototype.removeErrorListeners=function(){this._listeners=[]},s.prototype.getTokenTypeMap=function(){var t=this.getTokenNames();if(null===t)throw"The current recognizer does not provide a list of token names.";var e=this.tokenTypeMapCache[t];return void 0===e&&((e=t.reduce(function(t,e,n){t[e]=n})).EOF=r.EOF,this.tokenTypeMapCache[t]=e),e},s.prototype.getRuleIndexMap=function(){var t=this.ruleNames;if(null===t)throw"The current recognizer does not provide a list of rule names.";var e=this.ruleIndexMapCache[t];return void 0===e&&(e=t.reduce(function(t,e,n){t[e]=n}),this.ruleIndexMapCache[t]=e),e},s.prototype.getTokenType=function(t){var e=this.getTokenTypeMap()[t];return void 0!==e?e:r.INVALID_TYPE},s.prototype.getErrorHeader=function(t){return"line "+t.getOffendingToken().line+":"+t.getOffendingToken().column},s.prototype.getTokenErrorDisplay=function(t){if(null===t)return"";var e=t.text;return null===e&&(e=t.type===r.EOF?"":"<"+t.type+">"),"'"+(e=e.replace("\n","\\n").replace("\r","\\r").replace("\t","\\t"))+"'"},s.prototype.getErrorListenerDispatch=function(){return new o(this._listeners)},s.prototype.sempred=function(t,e,n){return!0},s.prototype.precpred=function(t,e){return!0},Object.defineProperty(s.prototype,"state",{get:function(){return this._stateNumber},set:function(t){this._stateNumber=t}}),e.Recognizer=s},function(t,e,n){var r=n(11).DFAState,i=n(9).ATNConfigSet,o=n(6).getCachedPredictionContext;function s(t,e){return this.atn=t,this.sharedContextCache=e,this}s.ERROR=new r(2147483647,new i),s.prototype.getCachedContext=function(t){if(null===this.sharedContextCache)return t;return o(t,this.sharedContextCache,{})},e.ATNSimulator=s},function(t,e,n){n(0).Set;var r=n(0).Map,i=n(0).BitSet,o=n(0).AltDict,s=n(7).ATN,a=n(3).RuleStopState,l=n(9).ATNConfigSet,u=n(13).ATNConfig,c=n(10).SemanticContext,h=(n(0).Hash,n(0).hashStuff);n(0).equalArrays;function p(){return this}p.SLL=0,p.LL=1,p.LL_EXACT_AMBIG_DETECTION=2,p.hasSLLConflictTerminatingPrediction=function(t,e){if(p.allConfigsInRuleStopStates(e))return!0;if(t===p.SLL&&e.hasSemanticContext){for(var n=new l,r=0;r1)return!0}return!1},p.allSubsetsEqual=function(t){for(var e=null,n=0;n=n)){var i,o=e.charCodeAt(r);return o>=55296&&o<=56319&&n>r+1&&(i=e.charCodeAt(r+1))>=56320&&i<=57343?1024*(o-55296)+i-56320+65536:o}};t?t(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}()},function(t,e){var n,r,i,o;String.fromCodePoint||(n=function(){try{var t={},e=Object.defineProperty,n=e(t,t,t)&&e}catch(t){}return n}(),r=String.fromCharCode,i=Math.floor,o=function(t){var e,n,o=[],s=-1,a=arguments.length;if(!a)return"";for(var l="";++s1114111||i(u)!=u)throw RangeError("Invalid code point: "+u);u<=65535?o.push(u):(e=55296+((u-=65536)>>10),n=u%1024+56320,o.push(e,n)),(s+1==a||o.length>16384)&&(l+=r.apply(null,o),o.length=0)}return l},n?n(String,"fromCodePoint",{value:o,configurable:!0,writable:!0}):String.fromCodePoint=o)},function(t,e,n){var r=n(1).Token,i=n(5),o=i.NoViableAltException,s=i.InputMismatchException,a=i.FailedPredicateException,l=i.ParseCancellationException,u=n(3).ATNState,c=n(2).Interval,h=n(2).IntervalSet;function p(){}function f(){return p.call(this),this.errorRecoveryMode=!1,this.lastErrorIndex=-1,this.lastErrorStates=null,this}function d(){return f.call(this),this}p.prototype.reset=function(t){},p.prototype.recoverInline=function(t){},p.prototype.recover=function(t,e){},p.prototype.sync=function(t){},p.prototype.inErrorRecoveryMode=function(t){},p.prototype.reportError=function(t){},f.prototype=Object.create(p.prototype),f.prototype.constructor=f,f.prototype.reset=function(t){this.endErrorCondition(t)},f.prototype.beginErrorCondition=function(t){this.errorRecoveryMode=!0},f.prototype.inErrorRecoveryMode=function(t){return this.errorRecoveryMode},f.prototype.endErrorCondition=function(t){this.errorRecoveryMode=!1,this.lastErrorStates=null,this.lastErrorIndex=-1},f.prototype.reportMatch=function(t){this.endErrorCondition(t)},f.prototype.reportError=function(t,e){this.inErrorRecoveryMode(t)||(this.beginErrorCondition(t),e instanceof o?this.reportNoViableAlternative(t,e):e instanceof s?this.reportInputMismatch(t,e):e instanceof a?this.reportFailedPredicate(t,e):(console.log("unknown recognition error type: "+e.constructor.name),console.log(e.stack),t.notifyErrorListeners(e.getOffendingToken(),e.getMessage(),e)))},f.prototype.recover=function(t,e){this.lastErrorIndex===t.getInputStream().index&&null!==this.lastErrorStates&&this.lastErrorStates.indexOf(t.state)>=0&&t.consume(),this.lastErrorIndex=t._input.index,null===this.lastErrorStates&&(this.lastErrorStates=[]),this.lastErrorStates.push(t.state);var n=this.getErrorRecoverySet(t);this.consumeUntil(t,n)},f.prototype.sync=function(t){if(!this.inErrorRecoveryMode(t)){var e=t._interp.atn.states[t.state],n=t.getTokenStream().LA(1),i=t.atn.nextTokens(e);if(!i.contains(r.EPSILON)&&!i.contains(n))switch(e.stateType){case u.BLOCK_START:case u.STAR_BLOCK_START:case u.PLUS_BLOCK_START:case u.STAR_LOOP_ENTRY:if(null!==this.singleTokenDeletion(t))return;throw new s(t);case u.PLUS_LOOP_BACK:case u.STAR_LOOP_BACK:this.reportUnwantedToken(t);var o=new h;o.addSet(t.getExpectedTokens());var a=o.addSet(this.getErrorRecoverySet(t));this.consumeUntil(t,a)}}},f.prototype.reportNoViableAlternative=function(t,e){var n,i=t.getTokenStream();n=null!==i?e.startToken.type===r.EOF?"":i.getText(new c(e.startToken,e.offendingToken)):"";var o="no viable alternative at input "+this.escapeWSAndQuote(n);t.notifyErrorListeners(o,e.offendingToken,e)},f.prototype.reportInputMismatch=function(t,e){var n="mismatched input "+this.getTokenErrorDisplay(e.offendingToken)+" expecting "+e.getExpectedTokens().toString(t.literalNames,t.symbolicNames);t.notifyErrorListeners(n,e.offendingToken,e)},f.prototype.reportFailedPredicate=function(t,e){var n="rule "+t.ruleNames[t._ctx.ruleIndex]+" "+e.message;t.notifyErrorListeners(n,e.offendingToken,e)},f.prototype.reportUnwantedToken=function(t){if(!this.inErrorRecoveryMode(t)){this.beginErrorCondition(t);var e=t.getCurrentToken(),n="extraneous input "+this.getTokenErrorDisplay(e)+" expecting "+this.getExpectedTokens(t).toString(t.literalNames,t.symbolicNames);t.notifyErrorListeners(n,e,null)}},f.prototype.reportMissingToken=function(t){if(!this.inErrorRecoveryMode(t)){this.beginErrorCondition(t);var e=t.getCurrentToken(),n="missing "+this.getExpectedTokens(t).toString(t.literalNames,t.symbolicNames)+" at "+this.getTokenErrorDisplay(e);t.notifyErrorListeners(n,e,null)}},f.prototype.recoverInline=function(t){var e=this.singleTokenDeletion(t);if(null!==e)return t.consume(),e;if(this.singleTokenInsertion(t))return this.getMissingSymbol(t);throw new s(t)},f.prototype.singleTokenInsertion=function(t){var e=t.getTokenStream().LA(1),n=t._interp.atn,r=n.states[t.state].transitions[0].target;return!!n.nextTokens(r,t._ctx).contains(e)&&(this.reportMissingToken(t),!0)},f.prototype.singleTokenDeletion=function(t){var e=t.getTokenStream().LA(2);if(this.getExpectedTokens(t).contains(e)){this.reportUnwantedToken(t),t.consume();var n=t.getCurrentToken();return this.reportMatch(t),n}return null},f.prototype.getMissingSymbol=function(t){var e,n=t.getCurrentToken(),i=this.getExpectedTokens(t).first();e=i===r.EOF?"":"";var o=n,s=t.getTokenStream().LT(-1);return o.type===r.EOF&&null!==s&&(o=s),t.getTokenFactory().create(o.source,i,e,r.DEFAULT_CHANNEL,-1,-1,o.line,o.column)},f.prototype.getExpectedTokens=function(t){return t.getExpectedTokens()},f.prototype.getTokenErrorDisplay=function(t){if(null===t)return"";var e=t.text;return null===e&&(e=t.type===r.EOF?"":"<"+t.type+">"),this.escapeWSAndQuote(e)},f.prototype.escapeWSAndQuote=function(t){return"'"+(t=(t=(t=t.replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t"))+"'"},f.prototype.getErrorRecoverySet=function(t){for(var e=t._interp.atn,n=t._ctx,i=new h;null!==n&&n.invokingState>=0;){var o=e.states[n.invokingState].transitions[0],s=e.nextTokens(o.followState);i.addSet(s),n=n.parentCtx}return i.removeOne(r.EPSILON),i},f.prototype.consumeUntil=function(t,e){for(var n=t.getTokenStream().LA(1);n!==r.EOF&&!e.contains(n);)t.consume(),n=t.getTokenStream().LA(1)},d.prototype=Object.create(f.prototype),d.prototype.constructor=d,d.prototype.recover=function(t,e){for(var n=t._ctx;null!==n;)n.exception=e,n=n.parentCtx;throw new l(e)},d.prototype.recoverInline=function(t){this.recover(t,new s(t))},d.prototype.sync=function(t){},e.BailErrorStrategy=d,e.DefaultErrorStrategy=f},function(t,e){},function(t,e,n){Converter=n(33).Converter},function(module,exports,__webpack_require__){function Converter(){return this}antlr4=__webpack_require__(12),BlocklyGrammerVisitor=__webpack_require__(20).BlocklyGrammerVisitor,BlocklyGrammerLexer=__webpack_require__(51).BlocklyGrammerLexer,BlocklyGrammerParser=__webpack_require__(52).BlocklyGrammerParser,Visitors=__webpack_require__(53),SymbolVisitor=Visitors.SymbolVisitor,EvalVisitor=Visitors.EvalVisitor,tpl=__webpack_require__(54),Converter.prototype.constructor=Converter,Converter.prototype.init=function(){return this.toolboxGap=5,this.toolboxId="toolbox",this.blocklyDivId="blocklyDiv",this.workSpaceName="workspace",this.codeAreaId="codeArea",this},Converter.prototype.main=function(t,e,n){return this.init(),this.generBlocks(t,e),this.renderGrammerName(),this.generToolbox(),this.generMainFile(),this.writeMainFile(n),this},Converter.prototype.generBlocks=function(grammerFile,functions){functions||(functions=[]);var temp_consoleError=console.error;console.error=function(t){throw new Error(t)};var chars=new antlr4.InputStream(grammerFile),lexer=new BlocklyGrammerLexer(chars),tokens=new antlr4.CommonTokenStream(lexer),parser=new BlocklyGrammerParser(tokens);parser.buildParseTrees=!0;var tree=parser.grammarFile();console.error=temp_consoleError;var svisitor=(new SymbolVisitor).init();this.svisitor=svisitor,svisitor.visit(tree),console.log(svisitor),svisitor.checkSymbol();var evisitor=(new EvalVisitor).init(svisitor,grammerFile);return this.evisitor=evisitor,eval(this.evisitor.matchInject("Function_0")),functions[0]&&functions[0](),evisitor.visit(tree),eval(this.evisitor.matchInject("Function_1")),functions[1]&&functions[1](),evisitor.generBlocks(),console.log(evisitor),this.blocks=evisitor.blocks,eval(this.evisitor.matchInject("Function_2")),functions[2]&&functions[2](),this},Converter.prototype.renderGrammerName=function(){this.grammerName=this.svisitor.grammerName,this.generLanguage=this.evisitor.generLanguage,eval(this.grammerName+"Functions={};");var grammerName=this.grammerName,generLanguage=this.generLanguage;this.OmitedError=tpl.OmitedError(),this.Functions_pre=tpl.Functions_pre(grammerName),this.Functions_xmlText=tpl.Functions_xmlText(grammerName),this.Functions_blocksIniter=tpl.Functions_blocksIniter(grammerName,generLanguage),this.mainFileTPL=tpl.mainFileTPL},Converter.prototype.generToolbox=function(){eval(this.Functions_xmlText),eval(this.blocks),eval("var blocksobj = "+this.grammerName+"Blocks;"),console.log(blocksobj);var text=[];for(var key in text.push('"),this.toolbox=this.textToPrettyText(text.join("")),this},Converter.prototype.generMainFile=function(){var t=[],e=this.grammerName;t.push(this.blocks),t.push("\n\n"),t.push(this.OmitedError),t.push("\n\n"),t.push(e+"Functions={}\n\n"),t.push(this.evisitor.matchInject("Functions")),t.push("\n\n"),t.push(this.Functions_pre),t.push("\n\n"),t.push(this.Functions_xmlText),t.push("\n\n"),t.push(this.Functions_blocksIniter),t.push("\n\n"),t.push(e+"Functions.blocksIniter();\n\n"),this.mainFile=this.mainFileTPL(e,this.generLanguage,this.blocklyDivId,this.codeAreaId,this.toolbox,this.workSpaceName,this.toolboxId,t.join(""))},Converter.prototype.writeMainFile=function(t){t||(t=this.grammerName+"index.html"),this.createAndDownloadFile(this.mainFile.join(""),t,"html")},Converter.prototype.editBlock=function(t){var e=this.evisitor.expressionRules[t];return e||(e=this.evisitor.statementRules[t]),e&&1!==e.checklength?e.blockjs:null},Converter.prototype.textToPrettyText=function(t){for(var e=t.split("<"),n="",r=1;r"!=i.slice(-2)&&(n+=" ")}var o=e.join("\n");return(o=o.replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1")).replace(/^\n/,"")},Converter.prototype.createAndDownloadFile=function(t,e,n){var r=new Blob([t],{type:"text/"+n}),i=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1}),o=document.createElement("a");o.href=window.URL.createObjectURL(r),o.download=e,o.textContent="Download file!",o.dispatchEvent(i)},exports.Converter=Converter},function(t,e,n){e.ATN=n(7).ATN,e.ATNDeserializer=n(22).ATNDeserializer,e.LexerATNSimulator=n(37).LexerATNSimulator,e.ParserATNSimulator=n(40).ParserATNSimulator,e.PredictionMode=n(27).PredictionMode},function(t,e,n){var r=n(0).Set,i=n(0).BitSet,o=n(1).Token,s=n(13).ATNConfig,a=(n(2).Interval,n(2).IntervalSet),l=n(3).RuleStopState,u=n(8).RuleTransition,c=n(8).NotSetTransition,h=n(8).WildcardTransition,p=n(8).AbstractPredicateTransition,f=n(6),d=f.predictionContextFromRuleContext,y=f.PredictionContext,g=f.SingletonPredictionContext;function v(t){this.atn=t}v.HIT_PRED=o.INVALID_TYPE,v.prototype.getDecisionLookahead=function(t){if(null===t)return null;for(var e=t.transitions.length,n=[],o=0;ox.MAX_DFA_EDGE)return null;var n=t.edges[e-x.MIN_DFA_EDGE];return void 0===n&&(n=null),x.debug&&null!==n&&console.log("reuse state "+t.stateNumber+" edge to "+n.stateNumber),n},x.prototype.computeTargetState=function(t,e,n){var r=new l;return this.getReachableConfigSet(t,e.configs,r,n),0===r.items.length?(r.hasSemanticContext||this.addDFAEdge(e,n,s.ERROR),s.ERROR):this.addDFAEdge(e,n,null,r)},x.prototype.failOrAccept=function(t,e,n,i){if(null!==this.prevAccept.dfaState){var o=t.dfaState.lexerActionExecutor;return this.accept(e,o,this.startIndex,t.index,t.line,t.column),t.dfaState.prediction}if(i===r.EOF&&e.index===this.startIndex)return r.EOF;throw new y(this.recog,e,this.startIndex,n)},x.prototype.getReachableConfigSet=function(t,e,n,i){for(var s=o.INVALID_ALT_NUMBER,a=0;ax.MAX_DFA_EDGE?n:(x.debug&&console.log("EDGE "+t+" -> "+n+" upon "+e),null===t.edges&&(t.edges=[]),t.edges[e-x.MIN_DFA_EDGE]=n,n)},x.prototype.addDFAState=function(t){for(var e=new a(null,t),n=null,r=0;r0&&(o=this.getAltThatFinishedDecisionEntryRule(i))!==a.INVALID_ALT_NUMBER?o:a.INVALID_ALT_NUMBER},N.prototype.getAltThatFinishedDecisionEntryRule=function(t){for(var e=[],n=0;n0||r.state instanceof x&&r.context.hasEmptyPath())&&e.indexOf(r.alt)<0&&e.push(r.alt)}return 0===e.length?a.INVALID_ALT_NUMBER:Math.min.apply(null,e)},N.prototype.splitAccordingToSemanticValidity=function(t,e){for(var n=new c(t.fullCtx),r=new c(t.fullCtx),i=0;i50))throw"problem";if(t.state instanceof x){if(!t.context.isEmpty()){for(var a=0;a=0&&(p+=1);this.closureCheckingStopState(h,e,n,c,i,p,s)}}},N.prototype.canDropLoopEntryEdgeInLeftRecursiveRule=function(t){var e=t.state;if(e.stateType!=l.STAR_LOOP_ENTRY)return!1;if(e.stateType!=l.STAR_LOOP_ENTRY||!e.isPrecedenceDecision||t.context.isEmpty()||t.context.hasEmptyPath())return!1;for(var n=t.context.length,r=0;r=0?this.parser.ruleNames[t]:""},N.prototype.getEpsilonTarget=function(t,e,n,r,i,o){switch(e.serializationType){case S.RULE:return this.ruleTransition(t,e);case S.PRECEDENCE:return this.precedenceTransition(t,e,n,r,i);case S.PREDICATE:return this.predTransition(t,e,n,r,i);case S.ACTION:return this.actionTransition(t,e);case S.EPSILON:return new u({state:e.target},t);case S.ATOM:case S.RANGE:case S.SET:return o&&e.matches(h.EOF,0,1)?new u({state:e.target},t):null;default:return null}},N.prototype.actionTransition=function(t,e){if(this.debug){var n=-1==e.actionIndex?65535:e.actionIndex;console.log("ACTION edge "+e.ruleIndex+":"+n)}return new u({state:e.target},t)},N.prototype.precedenceTransition=function(t,e,n,i,o){this.debug&&(console.log("PRED (collectPredicates="+n+") "+e.precedence+">=_p, ctx dependent=true"),null!==this.parser&&console.log("context surrounding pred is "+r.arrayToString(this.parser.getRuleInvocationStack())));var s=null;if(n&&i)if(o){var a=this._input.index;this._input.seek(this._startIndex);var l=e.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(a),l&&(s=new u({state:e.target},t))}else{var c=v.andContext(t.semanticContext,e.getPredicate());s=new u({state:e.target,semanticContext:c},t)}else s=new u({state:e.target},t);return this.debug&&console.log("config from pred transition="+s),s},N.prototype.predTransition=function(t,e,n,i,o){this.debug&&(console.log("PRED (collectPredicates="+n+") "+e.ruleIndex+":"+e.predIndex+", ctx dependent="+e.isCtxDependent),null!==this.parser&&console.log("context surrounding pred is "+r.arrayToString(this.parser.getRuleInvocationStack())));var s=null;if(n&&(e.isCtxDependent&&i||!e.isCtxDependent))if(o){var a=this._input.index;this._input.seek(this._startIndex);var l=e.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(a),l&&(s=new u({state:e.target},t))}else{var c=v.andContext(t.semanticContext,e.getPredicate());s=new u({state:e.target,semanticContext:c},t)}else s=new u({state:e.target},t);return this.debug&&console.log("config from pred transition="+s),s},N.prototype.ruleTransition=function(t,e){this.debug&&console.log("CALL rule "+this.getRuleName(e.target.ruleIndex)+", ctx="+t.context);var n=e.followState,r=R.create(t.context,n.stateNumber);return new u({state:e.target,context:r},t)},N.prototype.getConflictingAlts=function(t){var e=y.getConflictingAltSubsets(t);return y.getAlts(e)},N.prototype.getConflictingAltsOrUniqueAlt=function(t){var e=null;return t.uniqueAlt!==a.INVALID_ALT_NUMBER?(e=new o).add(t.uniqueAlt):e=t.conflictingAlts,e},N.prototype.getTokenName=function(t){if(t===h.EOF)return"EOF";if(null!==this.parser&&null!==this.parser.literalNames){if(!(t>=this.parser.literalNames.length&&t>=this.parser.symbolicNames.length))return(this.parser.literalNames[t]||this.parser.symbolicNames[t])+"<"+t+">";console.log(t+" ttype out of range: "+this.parser.literalNames),console.log(""+this.parser.getInputStream().getTokens())}return""+t},N.prototype.getLookaheadName=function(t){return this.getTokenName(t.LA(1))},N.prototype.dumpDeadEndConfigs=function(t){console.log("dead end configs: ");for(var e=t.getDeadEndConfigs(),n=0;n0){var o=r.state.transitions[0];if(o instanceof AtomTransition)i="Atom "+this.getTokenName(o.label);else if(o instanceof E){i=(o instanceof C?"~":"")+"Set "+o.set}}console.error(r.toString(this.parser,!0)+":"+i)}},N.prototype.noViableAlt=function(t,e,n,r){return new b(this.parser,t,t.get(r),t.LT(1),n,e)},N.prototype.getUniqueAlt=function(t){for(var e=a.INVALID_ALT_NUMBER,n=0;n "+r+" upon "+this.getTokenName(n)),null===r)return null;if(r=this.addDFAState(t,r),null===e||n<-1||n>this.atn.maxTokenType)return r;if(null===e.edges&&(e.edges=[]),e.edges[n+1]=r,this.debug){var i=null===this.parser?null:this.parser.literalNames,o=null===this.parser?null:this.parser.symbolicNames;console.log("DFA=\n"+t.toString(i,o))}return r},N.prototype.addDFAState=function(t,e){if(e==d.ERROR)return e;var n=t.states.get(e);return null!==n?n:(e.stateNumber=t.states.length,e.configs.readOnly||(e.configs.optimizeConfigs(this),e.configs.setReadonly(!0)),t.states.add(e),this.debug&&console.log("adding new DFA state: "+e),e)},N.prototype.reportAttemptingFullContext=function(t,e,n,r,i){if(this.debug||this.retry_debug){var o=new T(r,i+1);console.log("reportAttemptingFullContext decision="+t.decision+":"+n+", input="+this.parser.getTokenStream().getText(o))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportAttemptingFullContext(this.parser,t,r,i,e,n)},N.prototype.reportContextSensitivity=function(t,e,n,r,i){if(this.debug||this.retry_debug){var o=new T(r,i+1);console.log("reportContextSensitivity decision="+t.decision+":"+n+", input="+this.parser.getTokenStream().getText(o))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportContextSensitivity(this.parser,t,r,i,e,n)},N.prototype.reportAmbiguity=function(t,e,n,r,i,o,s){if(this.debug||this.retry_debug){var a=new T(n,r+1);console.log("reportAmbiguity "+o+":"+s+", input="+this.parser.getTokenStream().getText(a))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportAmbiguity(this.parser,t,n,r,i,o,s)},e.ParserATNSimulator=N},function(t,e,n){e.DFA=n(42).DFA,e.DFASerializer=n(17).DFASerializer,e.LexerDFASerializer=n(17).LexerDFASerializer,e.PredPrediction=n(11).PredPrediction},function(t,e,n){var r=n(0).Set,i=n(11).DFAState,o=n(3).StarLoopEntryState,s=n(9).ATNConfigSet,a=n(17).DFASerializer,l=n(17).LexerDFASerializer;function u(t,e){if(void 0===e&&(e=0),this.atnStartState=t,this.decision=e,this._states=new r,this.s0=null,this.precedenceDfa=!1,t instanceof o&&t.isPrecedenceDecision){this.precedenceDfa=!0;var n=new i(null,new s);n.edges=[],n.isAcceptState=!1,n.requiresFullContext=!1,this.s0=n}return this}u.prototype.getPrecedenceStartState=function(t){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";return t<0||t>=this.s0.edges.length?null:this.s0.edges[t]||null},u.prototype.setPrecedenceStartState=function(t,e){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";t<0||(this.s0.edges[t]=e)},u.prototype.setPrecedenceDfa=function(t){if(this.precedenceDfa!==t){if(this._states=new DFAStatesSet,t){var e=new i(null,new s);e.edges=[],e.isAcceptState=!1,e.requiresFullContext=!1,this.s0=e}else this.s0=null;this.precedenceDfa=t}},Object.defineProperty(u.prototype,"states",{get:function(){return this._states}}),u.prototype.sortedStates=function(){return this._states.values().sort(function(t,e){return t.stateNumber-e.stateNumber})},u.prototype.toString=function(t,e){return t=t||null,e=e||null,null===this.s0?"":new a(this,t,e).toString()},u.prototype.toLexerString=function(){return null===this.s0?"":new l(this).toString()},e.DFA=u},function(t,e,n){var r=n(4);e.Trees=n(21).Trees,e.RuleNode=r.RuleNode,e.ParseTreeListener=r.ParseTreeListener,e.ParseTreeVisitor=r.ParseTreeVisitor,e.ParseTreeWalker=r.ParseTreeWalker},function(t,e,n){e.RecognitionException=n(5).RecognitionException,e.NoViableAltException=n(5).NoViableAltException,e.LexerNoViableAltException=n(5).LexerNoViableAltException,e.InputMismatchException=n(5).InputMismatchException,e.FailedPredicateException=n(5).FailedPredicateException,e.DiagnosticErrorListener=n(45).DiagnosticErrorListener,e.BailErrorStrategy=n(30).BailErrorStrategy,e.ErrorListener=n(16).ErrorListener},function(t,e,n){var r=n(0).BitSet,i=n(16).ErrorListener,o=n(2).Interval;function s(t){return i.call(this),t=t||!0,this.exactOnly=t,this}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,s.prototype.reportAmbiguity=function(t,e,n,r,i,s,a){if(!this.exactOnly||i){var l="reportAmbiguity d="+this.getDecisionDescription(t,e)+": ambigAlts="+this.getConflictingAlts(s,a)+", input='"+t.getTokenStream().getText(new o(n,r))+"'";t.notifyErrorListeners(l)}},s.prototype.reportAttemptingFullContext=function(t,e,n,r,i,s){var a="reportAttemptingFullContext d="+this.getDecisionDescription(t,e)+", input='"+t.getTokenStream().getText(new o(n,r))+"'";t.notifyErrorListeners(a)},s.prototype.reportContextSensitivity=function(t,e,n,r,i,s){var a="reportContextSensitivity d="+this.getDecisionDescription(t,e)+", input='"+t.getTokenStream().getText(new o(n,r))+"'";t.notifyErrorListeners(a)},s.prototype.getDecisionDescription=function(t,e){var n=e.decision,r=e.atnStartState.ruleIndex,i=t.ruleNames;if(r<0||r>=i.length)return""+n;var o=i[r]||null;return null===o||0===o.length?""+n:n+" ("+o+")"},s.prototype.getConflictingAlts=function(t,e){if(null!==t)return t;for(var n=new r,i=0;i=0&&(this.fetchedEOF?this.index0)||this.fetch(e)>=e},a.prototype.fetch=function(t){if(this.fetchedEOF)return 0;for(var e=0;e=this.tokens.length&&(e=this.tokens.length-1);for(var o=t;o=this.tokens.length?this.tokens[this.tokens.length-1]:this.tokens[e]},a.prototype.adjustSeekIndex=function(t){return t},a.prototype.lazyInit=function(){-1===this.index&&this.setup()},a.prototype.setup=function(){this.sync(0),this.index=this.adjustSeekIndex(0)},a.prototype.setTokenSource=function(t){this.tokenSource=t,this.tokens=[],this.index=-1,this.fetchedEOF=!1},a.prototype.nextTokenOnChannel=function(t,e){if(this.sync(t),t>=this.tokens.length)return-1;for(var n=this.tokens[t];n.channel!==this.channel;){if(n.type===r.EOF)return-1;t+=1,this.sync(t),n=this.tokens[t]}return t},a.prototype.previousTokenOnChannel=function(t,e){for(;t>=0&&this.tokens[t].channel!==e;)t-=1;return t},a.prototype.getHiddenTokensToRight=function(t,e){if(void 0===e&&(e=-1),this.lazyInit(),t<0||t>=this.tokens.length)throw t+" not in 0.."+this.tokens.length-1;var n=this.nextTokenOnChannel(t+1,i.DEFAULT_TOKEN_CHANNEL),r=t+1,o=-1===n?this.tokens.length-1:n;return this.filterForChannel(r,o,e)},a.prototype.getHiddenTokensToLeft=function(t,e){if(void 0===e&&(e=-1),this.lazyInit(),t<0||t>=this.tokens.length)throw t+" not in 0.."+this.tokens.length-1;var n=this.previousTokenOnChannel(t-1,i.DEFAULT_TOKEN_CHANNEL);if(n===t-1)return null;var r=n+1,o=t-1;return this.filterForChannel(r,o,e)},a.prototype.filterForChannel=function(t,e,n){for(var r=[],o=t;o=this.tokens.length&&(n=this.tokens.length-1);for(var i="",s=e;s=0&&this._parseListeners.splice(e,1),0===this._parseListeners.length&&(this._parseListeners=null)}},p.prototype.removeParseListeners=function(){this._parseListeners=null},p.prototype.triggerEnterRuleEvent=function(){if(null!==this._parseListeners){var t=this._ctx;this._parseListeners.map(function(e){e.enterEveryRule(t),t.enterRule(e)})}},p.prototype.triggerExitRuleEvent=function(){if(null!==this._parseListeners){var t=this._ctx;this._parseListeners.slice(0).reverse().map(function(e){t.exitRule(e),e.exitEveryRule(t)})}},p.prototype.getTokenFactory=function(){return this._input.tokenSource._factory},p.prototype.setTokenFactory=function(t){this._input.tokenSource._factory=t},p.prototype.getATNWithBypassAlts=function(){var t=this.getSerializedATN();if(null===t)throw"The current parser does not support an ATN with bypass alternatives.";var e=this.bypassAltsAtnCache[t];if(null===e){var n=new l;n.generateRuleBypassTransitions=!0,e=new a(n).deserialize(t),this.bypassAltsAtnCache[t]=e}return e};var f=n(15).Lexer;p.prototype.compileParseTreePattern=function(t,e,n){if(null===(n=n||null)&&null!==this.getTokenStream()){var r=this.getTokenStream().tokenSource;r instanceof f&&(n=r)}if(null===n)throw"Parser can't discover a lexer to use";return new ParseTreePatternMatcher(n,this).compile(t,e)},p.prototype.getInputStream=function(){return this.getTokenStream()},p.prototype.setInputStream=function(t){this.setTokenStream(t)},p.prototype.getTokenStream=function(){return this._input},p.prototype.setTokenStream=function(t){this._input=null,this.reset(),this._input=t},p.prototype.getCurrentToken=function(){return this._input.LT(1)},p.prototype.notifyErrorListeners=function(t,e,n){e=e||null,n=n||null,null===e&&(e=this.getCurrentToken()),this._syntaxErrors+=1;var r=e.line,i=e.column;this.getErrorListenerDispatch().syntaxError(this,e,r,i,t,n)},p.prototype.consume=function(){var t=this.getCurrentToken();t.type!==r.EOF&&this.getInputStream().consume();var e,n=null!==this._parseListeners&&this._parseListeners.length>0;(this.buildParseTrees||n)&&((e=this._errHandler.inErrorRecoveryMode(this)?this._ctx.addErrorNode(t):this._ctx.addTokenNode(t)).invokingState=this.state,n&&this._parseListeners.map(function(t){e instanceof c||void 0!==e.isErrorNode&&e.isErrorNode()?t.visitErrorNode(e):e instanceof u&&t.visitTerminal(e)}));return t},p.prototype.addContextToParseTree=function(){null!==this._ctx.parentCtx&&this._ctx.parentCtx.addChild(this._ctx)},p.prototype.enterRule=function(t,e,n){this.state=e,this._ctx=t,this._ctx.start=this._input.LT(1),this.buildParseTrees&&this.addContextToParseTree(),null!==this._parseListeners&&this.triggerEnterRuleEvent()},p.prototype.exitRule=function(){this._ctx.stop=this._input.LT(-1),null!==this._parseListeners&&this.triggerExitRuleEvent(),this.state=this._ctx.invokingState,this._ctx=this._ctx.parentCtx},p.prototype.enterOuterAlt=function(t,e){t.setAltNumber(e),this.buildParseTrees&&this._ctx!==t&&null!==this._ctx.parentCtx&&(this._ctx.parentCtx.removeLastChild(),this._ctx.parentCtx.addChild(t)),this._ctx=t},p.prototype.getPrecedence=function(){return 0===this._precedenceStack.length?-1:this._precedenceStack[this._precedenceStack.length-1]},p.prototype.enterRecursionRule=function(t,e,n,r){this.state=e,this._precedenceStack.push(r),this._ctx=t,this._ctx.start=this._input.LT(1),null!==this._parseListeners&&this.triggerEnterRuleEvent()},p.prototype.pushNewRecursionContext=function(t,e,n){var r=this._ctx;r.parentCtx=t,r.invokingState=e,r.stop=this._input.LT(-1),this._ctx=t,this._ctx.start=r.start,this.buildParseTrees&&this._ctx.addChild(r),null!==this._parseListeners&&this.triggerEnterRuleEvent()},p.prototype.unrollRecursionContexts=function(t){this._precedenceStack.pop(),this._ctx.stop=this._input.LT(-1);var e=this._ctx;if(null!==this._parseListeners)for(;this._ctx!==t;)this.triggerExitRuleEvent(),this._ctx=this._ctx.parentCtx;else this._ctx=t;e.parentCtx=t,this.buildParseTrees&&null!==t&&t.addChild(e)},p.prototype.getInvokingContext=function(t){for(var e=this._ctx;null!==e;){if(e.ruleIndex===t)return e;e=e.parentCtx}return null},p.prototype.precpred=function(t,e){return e>=this._precedenceStack[this._precedenceStack.length-1]},p.prototype.inContext=function(t){return!1},p.prototype.isExpectedToken=function(t){var e=this._interp.atn,n=this._ctx,i=e.states[this.state],o=e.nextTokens(i);if(o.contains(t))return!0;if(!o.contains(r.EPSILON))return!1;for(;null!==n&&n.invokingState>=0&&o.contains(r.EPSILON);){var s=e.states[n.invokingState].transitions[0];if((o=e.nextTokens(s.followState)).contains(t))return!0;n=n.parentCtx}return!(!o.contains(r.EPSILON)||t!==r.EOF)},p.prototype.getExpectedTokens=function(){return this._interp.atn.getExpectedTokens(this.state,this._ctx)},p.prototype.getExpectedTokensWithinCurrentRule=function(){var t=this._interp.atn,e=t.states[this.state];return t.nextTokens(e)},p.prototype.getRuleIndex=function(t){var e=this.getRuleIndexMap()[t];return null!==e?e:-1},p.prototype.getRuleInvocationStack=function(t){null===(t=t||null)&&(t=this._ctx);for(var e=[];null!==t;){var n=t.ruleIndex;n<0?e.push("n/a"):e.push(this.ruleNames[n]),t=t.parentCtx}return e},p.prototype.getDFAStrings=function(){return this._interp.decisionToDFA.toString()},p.prototype.dumpDFA=function(){for(var t=!1,e=0;e0&&(t&&console.log(),this.printer.println("Decision "+n.decision+":"),this.printer.print(n.toString(this.literalNames,this.symbolicNames)),t=!0)}},p.prototype.getSourceName=function(){return this._input.sourceName},p.prototype.setTrace=function(t){t?(null!==this._tracer&&this.removeParseListener(this._tracer),this._tracer=new h(this),this.addParseListener(this._tracer)):(this.removeParseListener(this._tracer),this._tracer=null)},e.Parser=p},function(t,e,n){var r=n(12),i=["悋Ꜫ脳맭䅼㯧瞆奤","ŝ\b\t\t","\t\t\t\t","\b\t\b\t\t\t\n\t\n\v\t\v","\f\t\f\r\t\r\t\t","\t\t\t\t","\t\t\t","\t\t\t\t","\t\t\t","\t\t \t ","","","","","","","","","","","","","","\b\b\t\t\n\n","\v\v\v\v\v\v","\v\v\v\v\v\v","\v\v\v\v\v\v","\v\v\v\v\v\v","\v\v\v\v\v\v","\v\v\v\v\v\v","\v\v\v\v\v\v","\v\f\f\r\r","","Ó\n\fÖ","\v","Ü\n\fß\v","ã\n\fæ\v","ê\n","ï\n\fò","\v","ù\n","þ\n\fā\v","Ĉ\n","","","ę\n","Ĝ\n","ġ\n\rĢ","","ī\n\fĮ\v","","","Ŀ\n\fł","\v","Ō\n\f","ŏ\v ","    ŗ\n \f  Ś\v  "," ÔĬŀ!","\t\v\r\b\t\n\v\f\r","!#%","')+-/13579",";=?__C\\","2;C\\aac|c|$$^^\n$$11^^dd","hhppttvv))^^\n))11^^ddhhppttvv2;CHch",'\v\v""\f\f==~~',"ũ","\t","\v\r","","","","","!","#%","35","79;","=?","AI","K\t„","\v†\rˆ","“•","—™","ÄÆ","ÈÊ","Ì!Ù","#à%é'ë",")õ+ú","-Ą/ĉ","1ď3đ","5ě7Ġ","9Ħ;Ĵ=Ň","?ŒABi","BCtCDcDEo","EFoFGcGHtH","IJ=J","KLuLMvMNc","NOvOPGPQzQR","rRStSTUTUr","UVnVWkWXv",'XY"YZ<Z["[\\',")\\]?]^?^_",'?_`"`auabv',"bcccdvdeg","efofggghphi",'vij"jk`kl"',"lm?mn?no?",'op"pqgqrzrs',"rstttuguvu","vwuwxkxyq",'yzpz{"{|x|}','"}~?~?',"€?€)‚",'"‚ƒ=ƒ\b',"„…<…\n","†‡~‡\f","ˆ‰g‰ŠzŠ","‹r‹ŒtŒ","gŽuŽ","uk‘q","‘’p’","“”A”","•–-–","—˜,˜","™šOš›g","›œcœp","žkžŸpŸ ","i ¡h¡¢","w¢£n£¤U","¤¥r¥¦n","¦§k§¨v¨",'©"©ª<ª«','"«¬)¬­',"?­®?®¯?",'¯°"°±o',"±²g²³c³","´p´µkµ¶","p¶·i·¸","h¸¹w¹ºn",'º»"»¼`','¼½"½¾?¾',"¿?¿À?ÀÁ",')ÁÂ"ÂÃ',"=ÃÄÅ","*ÅÆÇ","+ÇÈÉ","€ÉÊË","0ËÌÔ","]ÍÎ^ÎÓ^","ÏÐ^ÐÓ_","ÑÓ\nÒÍ","ÒÏÒÑ","ÓÖÔÕ","ÔÒÕ×","ÖÔר_","Ø ÙÝ\tÚ","Ü\tÛÚÜ","ßÝÛÝ",'ÞÞ"ß',"Ýàä\tá","ã\tâáã","æäâä","åå$æ","äçê+è","ê'éçé","èê&ë","ð$ìï)íï","\nîìîí","ïòðî","ðññó","òðóô","$ô(õø","^öù\t÷ù/","øöø÷","ù*úÿ)","ûþ-üþ\n\býû","ýüþā","ÿýÿĀ","ĀĂāÿ","Ăă)ă,","Ąć^ąĈ\t\t","ĆĈ/ćą","ćĆĈ.","ĉĊwĊċ1","ċČ1Čč1č","Ď1Ď0ďĐ","\t\nĐ2đĒ%","Ēē!ēĔ","Ĕĕ\bĕ4","ĖĘėę\f","ĘėĘę","ęĜĚĜ\f","ěĖěĚ","ĜĝĝĞ\b","Ğ6ğġ\t\vĠ","ğġĢĢ","ĠĢģģ","ĤĤĥ\bĥ","8Ħħ1ħĨ",",ĨĬĩī","\vĪĩīĮ","ĬĭĬĪ","ĭįĮĬ","įİ,İı","1ıIJIJij","\bij:Ĵĵ","hĵĶtĶķc","ķĸiĸĹo","ĹĺgĺĻpĻ","ļvļŀĽ","Ŀ\vľĽĿ","łŀŁŀ","ľŁŃł","ŀŃń=ń","ŅŅņ\bņ","<Ňň1ňʼn","1ʼnōŊŌ","\n\fŋŊŌŏ","ōŋōŎ","ŎŐŏō","Őő\bő>","Œœ/œŔ@","ŔŘŕŗ\n\r","ŖŕŗŚ","ŘŖŘř","řśŚŘ","śŜ\b Ŝ@","ÒÔÝäéîðøýÿćĘ","ěĢĬŀōŘ\b"].join(""),o=(new r.atn.ATNDeserializer).deserialize(i),s=o.decisionToState.map(function(t,e){return new r.dfa.DFA(t,e)});function a(t){return r.Lexer.call(this,t),this._interp=new r.atn.LexerATNSimulator(this,o,s,new r.PredictionContextCache),this}a.prototype=Object.create(r.Lexer.prototype),a.prototype.constructor=a,a.EOF=r.Token.EOF,a.T__0=1,a.T__1=2,a.T__2=3,a.T__3=4,a.T__4=5,a.T__5=6,a.T__6=7,a.T__7=8,a.T__8=9,a.T__9=10,a.T__10=11,a.T__11=12,a.T__12=13,a.T__13=14,a.Brackets=15,a.LexerIdentifier=16,a.ParserIdentifier=17,a.String=18,a.LabelForParserRule=19,a.Newline=20,a.WhiteSpace=21,a.BlockComment=22,a.FragmentComment=23,a.LineComment=24,a.ArrowComment=25,a.prototype.channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"],a.prototype.modeNames=["DEFAULT_MODE"],a.prototype.literalNames=[null,"'grammar'","';'","'statExprSplit : '=== statement ^ === expression v ===' ;'","':'","'|'","'expression'","'?'","'+'","'*'","'MeaningfulSplit : '=== meaningful ^ ===' ;'","'('","')'","'~'","'.'"],a.prototype.symbolicNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"Brackets","LexerIdentifier","ParserIdentifier","String","LabelForParserRule","Newline","WhiteSpace","BlockComment","FragmentComment","LineComment","ArrowComment"],a.prototype.ruleNames=["T__0","T__1","T__2","T__3","T__4","T__5","T__6","T__7","T__8","T__9","T__10","T__11","T__12","T__13","Brackets","LexerIdentifier","ParserIdentifier","String","STRING_double","ESC_double","STRING_single","ESC_single","UNICODE","HEX","LabelForParserRule","Newline","WhiteSpace","BlockComment","FragmentComment","LineComment","ArrowComment"],a.prototype.grammarFileName="BlocklyGrammer.g4",e.BlocklyGrammerLexer=a},function(t,e,n){var r=n(12),i=n(20).BlocklyGrammerVisitor,o=["悋Ꜫ脳맭䅼㯧瞆奤","À\t\t","\t\t\t\t","\b\t\b\t\t\t\n\t\n\v\t\v\f\t\f","\r\t\r\n\f"," \v$\n","\f'\v","","","8\n\r9","@\n\fC\v","F\n","L\n","Q\nS\n\fV\v","\\","\n\f_\vb\n","f\n\f","i\v\b\b\bm\n\b\b\b\bq","\n\b\b\b\bu\n\b\b\bx\n\b\t","\t{\n\t\f\t\t~\v\t\n\n\v\v","\v\v\v\v\v\v","\v\v\vŒ\n\v\r\v\v","\v\v\v\v\v","\v\v\v—\n\v\f\fš\n","\f\r\f\f›\r\r\r\r\r\r","\r\r\r\r\r\r\r\r","\r\r­\n\r\r\r\r\r\r\r","\r\r\r\r\r¹\n\r\r»\n\r","\f\r\r¾\v\r\r%|","\b\n\f","\t\v\n\vÔ",",","0\bE\na","\fcw","|","–™","¬","\b"," ","!",' !%"$',"\n#\"$'","%&%#&(","'%()\t)*","\n*+\t+,-","-.\t.//","011","2334","475668","758997","9::;;F","<==A",">@\b?>@C","A?ABBD","CADFE2","E<F\t","GH\bHKIL\f","JLKIKJ","LTMPNQ\f","OQPNPO","QSRM","SVTRTU","UWVTWb","XYY]Z\\","\b[Z\\_","][]^^`","_]`baG","aXb\v","cg\bdf\bed","figegh","h\rigjl","\bkm\tlk","lmmxnp","oq\tpopq","qxrtsu","\ttstuu","xvxwj","wnwrwv","xy{\v","zy{~|}","|z}~|","€\f€","‚‚ƒ","ƒ„\f„…","…—†‡","‡ˆˆ‹","\f‰ŠŠŒ","\f‹‰Œ","‹Ž","Ž","—‘’","’““”","\r”••—","––†","–‘—","˜š™˜","š››™","›œœ","ž\b\ržŸ\r","Ÿ \r ¡","¡­¢£","£­\r\b¤­","¥¦¦§","§¨¨­","©­ª­","«­¬","¬¢¬¤","¬¥¬©","¬ª¬«","­¼®¯\f\v","¯°°»\r\f±","²\f\n²»\r\v³´\f","\r´»\tµ¶\f\f","¶¸\t·¹\t","¸·¸¹","¹»º®","º±º³","ºµ»¾","¼º¼½","½¾¼","%9AEKPT]aglptw|–›¬¸º¼"].join(""),s=(new r.atn.ATNDeserializer).deserialize(o),a=s.decisionToState.map(function(t,e){return new r.dfa.DFA(t,e)}),l=new r.PredictionContextCache,u=[null,"'grammar'","';'","'statExprSplit : '=== statement ^ === expression v ===' ;'","':'","'|'","'expression'","'?'","'+'","'*'","'MeaningfulSplit : '=== meaningful ^ ===' ;'","'('","')'","'~'","'.'"],c=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"Brackets","LexerIdentifier","ParserIdentifier","String","LabelForParserRule","Newline","WhiteSpace","BlockComment","FragmentComment","LineComment","ArrowComment"],h=["grammarFile","grammerDecl","statExprSplit","statementRule","expressionRule","arithmeticRuleCollection","parserRuleAtom","lexerRuleCollection","meaningfulSplit","lexerRule","strings","lexerRuleAtom"];function p(t){return r.Parser.call(this,t),this._interp=new r.atn.ParserATNSimulator(this,s,a,l),this.ruleNames=h,this.literalNames=u,this.symbolicNames=c,this}function f(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_grammarFile,this}function d(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_grammerDecl,this}function y(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_statExprSplit,this}function g(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_statementRule,this}function v(t,e){return g.call(this,t),g.prototype.copyFrom.call(this,e),this}function x(t,e){return g.call(this,t),g.prototype.copyFrom.call(this,e),this}function m(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_expressionRule,this}function T(t,e){return m.call(this,t),m.prototype.copyFrom.call(this,e),this}function _(t,e){return m.call(this,t),m.prototype.copyFrom.call(this,e),this}function S(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_arithmeticRuleCollection,this}function E(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_parserRuleAtom,this}function C(t,e){return E.call(this,t),E.prototype.copyFrom.call(this,e),this}function A(t,e){return E.call(this,t),E.prototype.copyFrom.call(this,e),this}function k(t,e){return E.call(this,t),E.prototype.copyFrom.call(this,e),this}function b(t,e){return E.call(this,t),E.prototype.copyFrom.call(this,e),this}function R(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_lexerRuleCollection,this}function L(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_meaningfulSplit,this}function N(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_lexerRule,this}function I(t,e){return N.call(this,t),N.prototype.copyFrom.call(this,e),this}function O(t,e){return N.call(this,t),N.prototype.copyFrom.call(this,e),this}function P(t,e){return N.call(this,t),N.prototype.copyFrom.call(this,e),this}function w(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_strings,this}function F(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_lexerRuleAtom,this}p.prototype=Object.create(r.Parser.prototype),p.prototype.constructor=p,Object.defineProperty(p.prototype,"atn",{get:function(){return s}}),p.EOF=r.Token.EOF,p.T__0=1,p.T__1=2,p.T__2=3,p.T__3=4,p.T__4=5,p.T__5=6,p.T__6=7,p.T__7=8,p.T__8=9,p.T__9=10,p.T__10=11,p.T__11=12,p.T__12=13,p.T__13=14,p.Brackets=15,p.LexerIdentifier=16,p.ParserIdentifier=17,p.String=18,p.LabelForParserRule=19,p.Newline=20,p.WhiteSpace=21,p.BlockComment=22,p.FragmentComment=23,p.LineComment=24,p.ArrowComment=25,p.RULE_grammarFile=0,p.RULE_grammerDecl=1,p.RULE_statExprSplit=2,p.RULE_statementRule=3,p.RULE_expressionRule=4,p.RULE_arithmeticRuleCollection=5,p.RULE_parserRuleAtom=6,p.RULE_lexerRuleCollection=7,p.RULE_meaningfulSplit=8,p.RULE_lexerRule=9,p.RULE_strings=10,p.RULE_lexerRuleAtom=11,f.prototype=Object.create(r.ParserRuleContext.prototype),f.prototype.constructor=f,f.prototype.grammerDecl=function(){return this.getTypedRuleContext(d,0)},f.prototype.statExprSplit=function(){return this.getTypedRuleContext(y,0)},f.prototype.lexerRuleCollection=function(t){return void 0===t&&(t=null),null===t?this.getTypedRuleContexts(R):this.getTypedRuleContext(R,t)},f.prototype.meaningfulSplit=function(){return this.getTypedRuleContext(L,0)},f.prototype.statementRule=function(t){return void 0===t&&(t=null),null===t?this.getTypedRuleContexts(g):this.getTypedRuleContext(g,t)},f.prototype.expressionRule=function(t){return void 0===t&&(t=null),null===t?this.getTypedRuleContexts(m):this.getTypedRuleContext(m,t)},f.prototype.accept=function(t){return t instanceof i?t.visitGrammarFile(this):t.visitChildren(this)},p.GrammarFileContext=f,p.prototype.grammarFile=function(){var t=new f(this,this._ctx,this.state);this.enterRule(t,0,p.RULE_grammarFile);try{this.enterOuterAlt(t,1),this.state=24,this.grammerDecl(),this.state=28,this._errHandler.sync(this);for(var e=this._interp.adaptivePredict(this._input,0,this._ctx);1!=e&&e!=r.atn.ATN.INVALID_ALT_NUMBER;)2===e&&(this.state=25,this.statementRule()),this.state=30,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,0,this._ctx);this.state=31,this.statExprSplit(),this.state=35,this._errHandler.sync(this);for(e=this._interp.adaptivePredict(this._input,1,this._ctx);1!=e&&e!=r.atn.ATN.INVALID_ALT_NUMBER;)2===e&&(this.state=32,this.expressionRule()),this.state=37,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,1,this._ctx);this.state=38,this.lexerRuleCollection(),this.state=39,this.meaningfulSplit(),this.state=40,this.lexerRuleCollection()}catch(e){if(!(e instanceof r.error.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t},d.prototype=Object.create(r.ParserRuleContext.prototype),d.prototype.constructor=d,d.prototype.ParserIdentifier=function(){return this.getToken(p.ParserIdentifier,0)},d.prototype.LexerIdentifier=function(){return this.getToken(p.LexerIdentifier,0)},d.prototype.accept=function(t){return t instanceof i?t.visitGrammerDecl(this):t.visitChildren(this)},p.GrammerDeclContext=d,p.prototype.grammerDecl=function(){var t=new d(this,this._ctx,this.state);this.enterRule(t,2,p.RULE_grammerDecl);var e=0;try{this.enterOuterAlt(t,1),this.state=42,this.match(p.T__0),this.state=43,(e=this._input.LA(1))!==p.LexerIdentifier&&e!==p.ParserIdentifier?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=44,this.match(p.T__1)}catch(e){if(!(e instanceof r.error.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t},y.prototype=Object.create(r.ParserRuleContext.prototype),y.prototype.constructor=y,y.prototype.accept=function(t){return t instanceof i?t.visitStatExprSplit(this):t.visitChildren(this)},p.StatExprSplitContext=y,p.prototype.statExprSplit=function(){var t=new y(this,this._ctx,this.state);this.enterRule(t,4,p.RULE_statExprSplit);try{this.enterOuterAlt(t,1),this.state=46,this.match(p.T__2)}catch(e){if(!(e instanceof r.error.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t},g.prototype=Object.create(r.ParserRuleContext.prototype),g.prototype.constructor=g,g.prototype.copyFrom=function(t){r.ParserRuleContext.prototype.copyFrom.call(this,t)},v.prototype=Object.create(g.prototype),v.prototype.constructor=v,p.StatValueContext=v,v.prototype.ParserIdentifier=function(){return this.getToken(p.ParserIdentifier,0)},v.prototype.parserRuleAtom=function(t){return void 0===t&&(t=null),null===t?this.getTypedRuleContexts(E):this.getTypedRuleContext(E,t)},v.prototype.accept=function(t){return t instanceof i?t.visitStatValue(this):t.visitChildren(this)},x.prototype=Object.create(g.prototype),x.prototype.constructor=x,p.StatListContext=x,x.prototype.ParserIdentifier=function(t){return void 0===t&&(t=null),null===t?this.getTokens(p.ParserIdentifier):this.getToken(p.ParserIdentifier,t)},x.prototype.accept=function(t){return t instanceof i?t.visitStatList(this):t.visitChildren(this)},p.StatementRuleContext=g,p.prototype.statementRule=function(){var t=new g(this,this._ctx,this.state);this.enterRule(t,6,p.RULE_statementRule);var e=0;try{switch(this.state=67,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,4,this._ctx)){case 1:t=new x(this,t),this.enterOuterAlt(t,1),this.state=48,this.match(p.ParserIdentifier),this.state=49,this.match(p.T__3),this.state=50,this.match(p.ParserIdentifier),this.state=53,this._errHandler.sync(this),e=this._input.LA(1);do{this.state=51,this.match(p.T__4),this.state=52,this.match(p.ParserIdentifier),this.state=55,this._errHandler.sync(this),e=this._input.LA(1)}while(e===p.T__4);this.state=57,this.match(p.T__1);break;case 2:for(t=new v(this,t),this.enterOuterAlt(t,2),this.state=58,this.match(p.ParserIdentifier),this.state=59,this.match(p.T__3),this.state=63,this._errHandler.sync(this),e=this._input.LA(1);0==(-32&e)&&0!=(1<1)for(var i,o=0;i=t[1][o];o++)e[i]&&this.error("语句 "+i+" 同时在两个语句集合 "+e[i]+" 和 "+t[0]+" 中出现了"),e[i]=t[0],n(this.statementRules,i).length>1&&this.error(t[0]+" 下的子规则 "+i+' 包含了"|"');var s;for(r=0;s=this.expressionRules[r];r++)s[1].length>1&&"expression"!==s[0]&&this.error("表达式 "+s[0]+' 包含了"|"')},SymbolVisitor.prototype.visitGrammarFile=function(t){return this.visit(t.grammerDecl()),this.visit(t.statementRule()),this.visit(t.expressionRule()),this.visit(t.lexerRuleCollection(0)),this},SymbolVisitor.prototype.visitGrammerDecl=function(t){this.grammerName=t.children[1].getText()},SymbolVisitor.prototype.visitStatList=function(t){for(var e,n=t.ParserIdentifier(),r=0;e=n[r];r++)n[r]=e.getText();var i=n.shift();this.statementRules.push([i,n])},SymbolVisitor.prototype.visitStatValue=function(t){var e=t.ParserIdentifier(0).getText();this.statementRules.push([e,[e]])},SymbolVisitor.prototype.visitExprExpression=function(t){var e=[];this.expression_arithmetic_num=t.arithmeticRuleCollection().length;for(var n=0;n1){this.notEntry[t[e]]=!0;for(var n,r=0;n=o.check[r];r++){var i=this.getRule("statement",n);i.blockjs.nextStatement=o.check,this.setRule("statement",n,i),this.notEntry[n]=!0}}for(e=0;o=this.statementRules[t[e]];e++)this.notEntry[t[e]]||(this.notEntry[t[e]]=!1,delete o.blockjs.previousStatement,delete o.blockjs.nextStatement,delete o.blockjs.inputsInline,o.blockjs.colour=this.entryColor);var o,s=[],a=[];for(e=0;o=this.statementRules[t[e]];e++)if(o.check.length>1)a.push([t[e],o]);else{s.push(o),o.type="statement";var l=[],u="",c=function(t){t>0&&(u+=Array(2*t+1).join(" ")),t<0&&(u=u.slice(0,2*t))},h="Blockly."+this.generLanguage+".";l.push(u+"function(block) {\n"),c(1);for(r=0;y=o.blockobj.args[r];r++){var p=this.varPrefix+o.blockobj.vars[r];if(y.id)"value"===y.blockType?(l.push(u+"var "+p+" = "+h+"valueToCode(block, '"),l.push(p+"', \n "+u+h+this.recieveOrder+")")):"statement"===y.blockType?(l.push(u+"var "+p+" = "+h+"statementToCode(block, '"),l.push(p+"')")):(l.push(u+"var "+p+" = block.getFieldValue('"),l.push(p+"')")),"field_checkbox"===y.data.type&&l.push(" === 'TRUE'"),l.push(";\n"),y.multi,{field_checkbox:!0,field_dropdown:!0,field_number:!0}[y.data.type]||y.omitted||(l.push(u+"if ("+p+"==='') {\n"),c(1),l.push(u+"throw new OmitedError(block,'"+p+"','"),l.push(t[e]+"');\n"),c(-1),l.push(u+"}\n")),"field"===y.blockType&&(l.push(u+p+" = "+this.grammerName+"Functions.pre('"),l.push(y.id+"')("+p+");\n"))}o.blockobj.inject.generFunc?(l.push(u+o.blockobj.inject.generFunc.split("\n").join("\n"+u)),l.push("\n")):(l.push(u+"var code = '1111111111;\\n';\n"),l.push(u+"return code;\n")),c(-1),l.push(u+"}"),o.generFunc=l.join("")}t=Object.keys(this.expressionRules);var f;for(e=0;f=this.expressionRules[t[e]];e++)if(f.check.length>1)a.push([t[e],f]);else{s.push(f),f.type="value";l=[],u="",c=function(t){t>0&&(u+=Array(2*t+1).join(" ")),t<0&&(u=u.slice(0,2*t))},h="Blockly."+this.generLanguage+".";l.push(u+"function(block) {\n"),c(1);for(r=0;y=f.blockobj.args[r];r++){p=this.varPrefix+f.blockobj.vars[r];if(y.id)"value"===y.blockType?(l.push(u+"var "+p+" = "+h+"valueToCode(block, '"),l.push(p+"', \n "+u+h+this.recieveOrder+")")):"statement"===y.blockType?(l.push(u+"var "+p+" = "+h+"statementToCode(block, '"),l.push(p+"')")):(l.push(u+"var "+p+" = block.getFieldValue('"),l.push(p+"')")),"field_checkbox"===y.data.type&&l.push(" === 'TRUE'"),l.push(";\n"),y.multi,{field_checkbox:!0,field_dropdown:!0,field_number:!0}[y.data.type]||y.omitted||(l.push(u+"if ("+p+"==='') {\n"),c(1),l.push(u+"throw new OmitedError(block,'"+p+"','"),l.push(t[e]+"');\n"),c(-1),l.push(u+"}\n")),"field"===y.blockType&&(l.push(u+p+" = "+this.grammerName+"Functions.pre('"),l.push(y.id+"')("+p+");\n"))}f.blockobj.inject.generFunc?(l.push(u+f.blockobj.inject.generFunc.split("\n").join("\n"+u)),l.push("\n")):(l.push(u+"var code = 0000000000;\n"),l.push(u+"return [code, "+h+this.sendOrder+"];\n")),c(-1),l.push(u+"}"),f.generFunc=l.join("")}var d;for(e=0;d=s[e];e++){d.args=[],d.argsType=[],d.fieldDefault=[];var y;for(r=0;y=d.blockobj.args[r];r++)y.id&&(d.args.push(d.blockobj.vars[r]),d.argsType.push(y.blockType),d.fieldDefault.push(d.blockobj.fieldDefault[r]));l=[],u="",c=function(t){t>0&&(u+=Array(2*t+1).join(" ")),t<0&&(u=u.slice(0,2*t))};var g=this.grammerName,v=d.check[0];l.push(u+"function (inputs,isShadow) {\n"),c(1),l.push(u+"return "+g+"Functions.xmlText('"),l.push(v+"',inputs,isShadow);\n"),c(-1),l.push(u+"}"),d.xmlText=l.join("")}this.temp_xml=s,this.temp_collection=a},EvalVisitor.prototype.generBlocks=function(){var t=[],e="",n=function(t){t>0&&(e+=Array(2*t+1).join(" ")),t<0&&(e=e.slice(0,2*t))};temp_xml=this.temp_xml,delete this.temp_xml,temp_collection=this.temp_collection,delete this.temp_collection,t.push(e+this.grammerName+"Blocks = {\n"),n(1);for(var r,i=0;r=temp_collection[i];i++)t.push(e+'"'+r[0]+'": '),t.push(JSON.stringify(r[1].check,null,2).split("\n").join("\n"+e)),t.push(",\n");function o(t,e,n){var r=e.blockjs,i=JSON.stringify(r).split("\n").join("\n"+n),o={};r=JSON.parse(i);for(var s,a=0;s=e.blockobj.args[a];a++)if(s.id){var l=t.getRule(s.blockType,s.id);l&&1!==l.check.length&&(r.args0[a].check="1_fry2_3_inrgv"+s.id,o['"1_fry2_3_inrgv'+s.id+'"']=t.grammerName+"Blocks."+s.id)}if(r.nextStatement)for(var u,c=0;u=temp_collection[c];c++)if(-1!==u[1].check.indexOf(r.type)){r.nextStatement="1_fry2_3_inrgv"+u[0],o['"1_fry2_3_inrgv'+u[0]+'"']=t.grammerName+"Blocks."+u[0];break}for(var h in i=JSON.stringify(r,null,2).split("\n").join("\n"+n),o)i=i.split(h).join(o[h]);return i}t.pop(),t.push("\n"),n(-1),t.push(e+"}\n"),t.push(e+this.grammerName+"Blocks = Object.assign("),t.push(this.grammerName+"Blocks,{\n"),n(1);var s;for(i=0;s=temp_xml[i];i++)t.push(e+'"'+s.check[0]+'": {\n'),n(1),t.push(e+'"type": "'+s.type+'",\n'),t.push(e+'"json": '),t.push(o(this,s,e)),t.push(",\n"),t.push(e+'"generFunc": '),t.push(s.generFunc.split("\n").join("\n"+e)),t.push(",\n"),t.push(e+'"args": '),t.push(JSON.stringify(s.args,null,2).split("\n").join("\n"+e)),t.push(",\n"),t.push(e+'"argsType": '),t.push(JSON.stringify(s.argsType,null,0)),t.push(",\n"),t.push(e+'"fieldDefault": '),t.push(JSON.stringify(s.fieldDefault,null,0)),t.push(",\n"),t.push(e+'"xmlText": '),t.push(s.xmlText.split("\n").join("\n"+e)),t.push("\n"),n(-1),t.push(e+"},\n");t.pop(),t.push(e+"}\n"),n(-1),t.push(e+"});\n"),this.blocks=t.join("")},EvalVisitor.prototype.SpeicalLexerRule=function(t){var e={};return"Bool"===t?(e={type:"field_checkbox",checked:!0},this.setRule("lexer",t,e),!0):"Int"===t?(e={type:"field_number",value:0,min:0,precision:1},this.setRule("lexer",t,e),!0):"Number"===t?(e={type:"field_number",value:0},this.setRule("lexer",t,e),!0):"BGNL"===t&&(e={type:"input_dummy"},this.setRule("lexer",t,e),!0)},EvalVisitor.prototype.visitGrammarFile=function(t){this.visit(t.lexerRuleCollection(0)),this.visit(t.statementRule()),this.expression_arithmetic_num=0,this.visit(t.expressionRule()),this.assemble()},EvalVisitor.prototype.visitStrings=function(t){for(var e,n=t.String(),r=0;e=n[r];r++)n[r]=this.escapeString(e.getText());return n.join(" ")},EvalVisitor.prototype.visitLexerRuleStrings=function(t){var e=t.LexerIdentifier(0).getText();if(!this.SpeicalLexerRule(e)){var n=this.visit(t.strings(0));this.setRule("lexer",e,n)}},EvalVisitor.prototype.visitLexerRuleList=function(t){var e=t.LexerIdentifier(0).getText();if(!this.SpeicalLexerRule(e))if("_List"===e.slice(-5)){for(var n,r=t.strings(),i=0;n=r[i];i++){var o=this.visit(n);r[i]=[o,o]}var s={type:"field_dropdown",options:r};this.setRule("lexer",e,s)}else this.visitLexerRuleComplex(t)},EvalVisitor.prototype.visitLexerRuleComplex=function(t){var e=t.LexerIdentifier(0).getText();if(!this.SpeicalLexerRule(e)){var n={type:"field_input",text:e+"_default"};this.setRule("lexer",e,n)}},EvalVisitor.prototype.visitStatValue=function(t){this.status={name:t.ParserIdentifier(0).getText(),type:"statement",message:[],args:[]},this.visitChildren(t);var e=this.status;delete this.status,this.initAssemble(e)},BlocklyGrammerVisitor.prototype.visitArithmeticRuleCollection=function(t){this.status={name:"expression",type:"value",message:["%1"],args:[{id:"expression",blockType:"value",omitted:!1,data:{type:"input_value"}}]},this.visitChildren(t),this.status.name="expression_arithmetic_"+this.expression_arithmetic_num,this.expression_arithmetic_num++;var e=this.status;delete this.status,this.initAssemble(e)},BlocklyGrammerVisitor.prototype.visitExprValue=function(t){this.status={name:t.ParserIdentifier(0).getText(),type:"value",message:[],args:[]},this.visitChildren(t);var e=this.status;delete this.status,this.initAssemble(e)},EvalVisitor.prototype.visitParserAtomExpr=function(t){var e={id:"expression",blockType:"value",omitted:t.children.length>1,data:{type:"input_value"}};this.status.args.push(e),this.status.message.push("%"+this.status.args.length)},EvalVisitor.prototype.visitParserAtomParserId=function(t){var e=t.children[0].getText(),n=t.children.length>1&&t.children[1].getText()||"",r=this.getRule("value",e)?"value":"statement",i={id:e,blockType:r,omitted:"?"===n||"*"===n,multi:"+"===n||"*"===n,data:{type:"input_"+r}};"value"===r&&i.multi&&this.error(this.status.name+" 下出现了复数组合的表达式 "+e+n),this.status.args.push(i),this.status.message.push("%"+this.status.args.length)},EvalVisitor.prototype.visitParserAtomLexerId=function(t){var e=t.children[0].getText(),n=this.getRule("lexer",e);if(n){var r={id:e,blockType:"field",omitted:t.children.length>1,data:n};"BGNL"===e&&(r={data:n}),"string"!=typeof n?(this.status.args.push(r),this.status.message.push("%"+this.status.args.length)):this.status.message.push(n)}},EvalVisitor.prototype.visitParserAtomStr=function(t){var e=this.escapeString(t.String().getText());this.status.message.push(e)},exports.SymbolVisitor=SymbolVisitor,exports.EvalVisitor=EvalVisitor},function(t,e){e.OmitedError=function(){return"//生成代码中,当一个不允许省略的值或块省略时,会抛出这个错误\nfunction OmitedError(block, var_, rule, fileName, lineNumber) {\n var message = 'no omitted '+var_+' at '+rule;\n var instance = new Error(message, fileName, lineNumber);\n instance.block = block;\n instance.varName = var_;\n instance.blockName = rule;\n instance.name = 'OmitedError';\n Object.setPrototypeOf(instance, Object.getPrototypeOf(this));\n if (Error.captureStackTrace) {\n Error.captureStackTrace(instance, OmitedError);\n }\n return instance;\n}\n\nOmitedError.prototype = Object.create(Error.prototype);\nOmitedError.prototype.constructor = OmitedError;\n//处理此错误的omitedcheckUpdateFunction定义在下面"},e.Functions_pre=function(t){return`${t}Functions.Int_pre = function(intstr) {\n return parseInt(intstr);\n}\n\n${t}Functions.Number_pre = function(intstr) {\n return parseFloat(intstr);\n}\n\n//返回各LexerRule文本域的预处理函数,方便用来统一转义等等\n${t}Functions.pre = function(LexerId) {\n if (${t}Functions.hasOwnProperty(LexerId+'_pre')) {\n return ${t}Functions[LexerId+'_pre'];\n }\n return function(obj){return obj}\n}`},e.Functions_xmlText=function(t){return`//构造这个方法是为了能够不借助workspace,从语法树直接构造图块结构\n//inputs的第i个元素是第i个args的xmlText,null或undefined表示空\n//inputs的第rule.args.length个元素是其下一个语句的xmlText\n${t}Functions.xmlText = function (ruleName,inputs,isShadow) {\n var rule = ${t}Blocks[ruleName];\n var blocktext = isShadow?'shadow':'block';\n var xmlText = [];\n xmlText.push('<'+blocktext+' type="'+ruleName+'">');\n if(!inputs)inputs=[];\n for (var ii=0,inputType;inputType=rule.argsType[ii];ii++) {\n var input = inputs[ii];\n var _input = '';\n var noinput = (input===null || input===undefined);\n if(noinput && inputType==='field') continue;\n if(noinput) input = '';\n if(inputType!=='field') {\n var subList = false;\n var subrulename = rule.args[ii];\n subrulename=subrulename.split('_').slice(0,-1).join('_');\n var subrule = ${t}Blocks[subrulename];\n if (subrule instanceof Array) {\n subrulename=subrule[subrule.length-1];\n subrule = ${t}Blocks[subrulename];\n subList = true;\n }\n _input = subrule.xmlText([],true);\n if(noinput && !subList && !isShadow) {\n //无输入的默认行为是: 如果语句块的备选方块只有一个,直接代入方块\n input = subrule.xmlText();\n }\n }\n xmlText.push('<'+inputType+' name="'+rule.args[ii]+'">');\n xmlText.push(_input+input);\n xmlText.push('');\n }\n var next = inputs[rule.args.length];\n if (next) {//next\n xmlText.push('');\n xmlText.push(next);\n xmlText.push('');\n }\n xmlText.push('');\n return xmlText.join('');\n}`},e.Functions_blocksIniter=function(t,e){return`//把各方块的信息注册到Blockly中\n${t}Functions.blocksIniter = function(){\n var blocksobj = ${t}Blocks;\n for(var key in blocksobj) {\n var value = blocksobj[key];\n if(value instanceof Array)continue;\n (function(key,value){\n Blockly.Blocks[key] = {\n init: function() {this.jsonInit(value.json);}\n }\n })(key,value);\n Blockly.${e}[key] = value.generFunc;\n }\n}`},e.mainFileTPL=function(t,e,n,r,i,o,s,a){return[`\n\n\n${t} --antlr-blockly`,'\n diff --git a/libs/core.js b/libs/core.js index 30de90c1..fc595cc4 100644 --- a/libs/core.js +++ b/libs/core.js @@ -151,7 +151,7 @@ function core() { /////////// 系统事件相关 /////////// ////// 初始化 ////// -core.prototype.init = function (coreData) { +core.prototype.init = function (coreData, callback) { for (var key in coreData) { core[key] = coreData[key]; } @@ -281,6 +281,9 @@ core.prototype.init = function (coreData) { core.material.icons.hero.height = core.material.images.hero.height/4; core.setRequestAnimationFrame(); core.showStartAnimate(); + + if (core.isset(callback)) callback(); + }); } diff --git a/libs/items.js b/libs/items.js index df582f25..cc16999a 100644 --- a/libs/items.js +++ b/libs/items.js @@ -41,6 +41,7 @@ items.prototype.getItemEffect = function(itemId, itemNum) { var itemCls = core.material.items[itemId].cls; // 消耗品 if (itemCls === 'items') { + var ratio = parseInt(core.floors[core.status.floorId].item_ratio) || 1; if (itemId in this.itemEffect)eval(this.itemEffect[itemId]); } else { @@ -50,6 +51,7 @@ items.prototype.getItemEffect = function(itemId, itemNum) { ////// “即捡即用类”道具的文字提示 ////// items.prototype.getItemEffectTip = function(itemId) { + var ratio = parseInt(core.floors[core.status.floorId].item_ratio) || 1; if (itemId in this.itemEffectTip && (!this.items[itemId].isEquipment || !core.flags.equipment)) { return eval(this.itemEffectTip[itemId]); } diff --git a/main.js b/main.js index 06887014..693472b1 100644 --- a/main.js +++ b/main.js @@ -109,7 +109,7 @@ function main() { this.canvas = {}; } -main.prototype.init = function (mode) { +main.prototype.init = function (mode, callback) { for (var i = 0; i < main.dom.gameCanvas.length; i++) { main.canvas[main.dom.gameCanvas[i].id] = main.dom.gameCanvas[i].getContext('2d'); } @@ -155,7 +155,7 @@ main.prototype.init = function (mode) { "animates", "bgms", "sounds", "floorIds", "floors"].forEach(function (t) { coreData[t] = main[t]; }) - main.core.init(coreData); + main.core.init(coreData, callback); main.core.resize(main.dom.body.clientWidth, main.dom.body.clientHeight); }); }); diff --git a/project/comment.js b/project/comment.js index 12267989..4bf4c47e 100644 --- a/project/comment.js +++ b/project/comment.js @@ -43,6 +43,7 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "weather": "该层的默认天气。本项可忽略表示晴天,如果写则第一项为\"rain\"或\"snow\"代表雨雪,第二项为1-10之间的数代表强度。 \n$leaf(true)$end", "bgm": "到达该层后默认播放的BGM。本项可忽略。 ", //"map": "地图数据,需要是13x13,建议使用地图生成器来生成 ", + "item_ratio": "每一层的宝石/血瓶效果,即获得宝石和血瓶时框内\"ratio\"的值。", "firstArrive": "第一次到该楼层触发的事件 \n$leaf(true)$end", }, 'loc' : { diff --git a/project/floors/MT0.js b/project/floors/MT0.js index 1c51393b..dc4996fe 100644 --- a/project/floors/MT0.js +++ b/project/floors/MT0.js @@ -13,6 +13,7 @@ main.floors.MT0 = // "color": [0,0,0,0.3], // 该层的默认画面色调。本项可不写(代表无色调),如果写需要是一个RGBA数组。 // "weather": ["snow",5], // 该层的默认天气。本项可忽略表示晴天,如果写则第一项为"rain"或"snow"代表雨雪,第二项为1-10之间的数代表强度。 // "bgm": "bgm.mp3", // 到达该层后默认播放的BGM。本项可忽略。 + "item_ratio": 1, // 该层的宝石/血瓶倍率 "map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成 ], diff --git a/project/floors/sample0.js b/project/floors/sample0.js index 3cbd4a72..d5815cc9 100644 --- a/project/floors/sample0.js +++ b/project/floors/sample0.js @@ -13,6 +13,7 @@ main.floors.sample0 = // "color": [0,0,0,0.3] // 该层的默认画面色调。本项可不写(代表无色调),如果写需要是一个RGBA数组。 // "weather": ["snow",5], // 该层的默认天气。本项可忽略表示晴天,如果写则第一项为"rain"或"snow"代表雨雪,第二项为1-10之间的数代表强度。 "bgm": "bgm.mp3", // 到达该层后默认播放的BGM。本项可忽略。 + "item_ratio": 2, // 该层的宝石/血瓶倍率 "map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成 [0, 0, 220, 0, 0, 20, 87, 3, 65, 64, 44, 43, 42], [0, 246, 0, 246, 0, 20, 0, 3, 58, 59, 60, 61, 41], diff --git a/project/floors/sample1.js b/project/floors/sample1.js index 8764489d..08ce590e 100644 --- a/project/floors/sample1.js +++ b/project/floors/sample1.js @@ -13,6 +13,7 @@ main.floors.sample1 = // "color": [0,0,0,0.3] // 该层的默认画面色调。本项可不写(代表无色调),如果写需要是一个RGBA数组。 "weather": ["snow",6], // 该层的默认天气。本项可忽略表示晴天,如果写则第一项为"rain"或"snow"代表雨雪,第二项为1-10之间的数代表强度。 // "bgm": "bgm.mp3", // 到达该层后默认播放的BGM。本项可忽略。 + "item_ratio": 1, // 该层的宝石/血瓶倍率 "map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成 [7, 131, 8, 152, 9, 130, 10, 152, 166, 165, 132, 165, 166], [0, 0, 0, 0, 0, 0, 0, 152, 165, 164, 0, 162, 165], diff --git a/project/floors/sample2.js b/project/floors/sample2.js index 4b496b83..233473a0 100644 --- a/project/floors/sample2.js +++ b/project/floors/sample2.js @@ -13,6 +13,7 @@ main.floors.sample2 = "color": [255,0,0,0.3], // 该层的默认画面色调。本项可不写(代表无色调),如果写需要是一个RGBA数组。 "weather": ["rain",10], // 该层的默认天气。本项可忽略表示晴天,如果写则第一项为"rain"或"snow"代表雨雪,第二项为1-10之间的数代表强度。 "bgm": "qianjin.mid", // 到达该层后默认播放的BGM。本项可忽略。 + "item_ratio": 1, // 该层的宝石/血瓶倍率 "map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成 [5, 5, 5, 5, 5, 5, 87, 5, 5, 5, 5, 5, 5], [5, 4, 4, 4, 4, 1, 0, 1, 4, 4, 4, 4, 5], diff --git a/project/floors/test.js b/project/floors/test.js deleted file mode 100644 index e2452d33..00000000 --- a/project/floors/test.js +++ /dev/null @@ -1,46 +0,0 @@ -main.floors.test = -{ - "floorId": "test", // 这里需要改楼层名,请和文件名及下面的floorId保持完全一致 - // 楼层唯一标识符仅能由字母、数字、下划线组成,且不能由数字开头 - // 推荐用法:第20层就用MT20,第38层就用MT38,地下6层就用MT_6(用下划线代替负号),隐藏3层用MT3h(h表示隐藏),等等 - // 楼层唯一标识符,需要和名字完全一致 - "title": "test", // 楼层中文名 - "name": "", // 显示在状态栏中的层数 - "canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器) - "canUseQuickShop": true, // 该层是否允许使用快捷商店 - "defaultGround": "ground", // 默认地面的图块ID(terrains中) - "map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成 - [201,201,201,201,201,201,201,201,201,201,201,201,201], - [201,201,201,201,201,201,201,201,201,201,201,201,201], - [201,201,201,201,201,201,201,201,201,201,201,201,201], - [201,201,201,201,201,201,201,201,201,201,201,201,201], - [201,201,201,201,201,201,201,201,201,201,201,201,201], - [201,201,201,201,201,201,201,201,201,201,201,201,201], - [201,201,201,201,201,201,201,201,201,201,201,201,201], - [201,201,201,201,201,201,201,201,201,201,201,201,201], - [201,201,201,201,201,201,201,201,201,201,201,201,201], - [201,201,201,201,201,201,201,201,201,201,201,201,201], - [201,201,201,201,201,201,201,201,201,201,201,201,201], - [201,201,201,201,201,201, 45,201,201,201,201,201,201], - [201,201,201,201,201,201, 0,201,201,201,201,201,201] - ], - "firstArrive": [ // 第一次到该楼层触发的事件 - - ], - "events": { // 该楼的所有可能事件列表 - - }, - "changeFloor": { // 楼层转换事件;该事件不能和上面的events有冲突(同位置点),否则会被覆盖 - - }, - "afterBattle": { // 战斗后可能触发的事件列表 - - }, - "afterGetItem": { // 获得道具后可能触发的事件列表 - - }, - "afterOpenDoor": { // 开完门后可能触发的事件列表 - - } -} - diff --git a/project/items.js b/project/items.js index 84bbcbf7..b68555f5 100644 --- a/project/items.js +++ b/project/items.js @@ -62,16 +62,16 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "itemEffect" : { - "redJewel":"core.status.hero.atk += core.values.redJewel", - "blueJewel":"core.status.hero.def += core.values.blueJewel", - "greenJewel":"core.status.hero.mdef += core.values.greenJewel", + "redJewel":"core.status.hero.atk += core.values.redJewel * ratio", + "blueJewel":"core.status.hero.def += core.values.blueJewel * ratio", + "greenJewel":"core.status.hero.mdef += core.values.greenJewel * ratio", "yellowJewel":"core.status.hero.hp+=1000;core.status.hero.atk+=6;core.status.hero.def+=6;core.status.hero.mdef+=10;", // 黄宝石属性:需自己定义 - "redPotion":"core.status.hero.hp += core.values.redPotion", - "bluePotion":"core.status.hero.hp += core.values.bluePotion", - "yellowPotion":"core.status.hero.hp += core.values.yellowPotion", - "greenPotion":"core.status.hero.hp += core.values.greenPotion", + "redPotion":"core.status.hero.hp += core.values.redPotion * ratio", + "bluePotion":"core.status.hero.hp += core.values.bluePotion * ratio", + "yellowPotion":"core.status.hero.hp += core.values.yellowPotion * ratio", + "greenPotion":"core.status.hero.hp += core.values.greenPotion * ratio", "sword1":"core.status.hero.atk += core.values.sword1", "sword2":"core.status.hero.atk += core.values.sword2", "sword3":"core.status.hero.atk += core.values.sword3", @@ -91,14 +91,14 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "itemEffectTip" : { - "redJewel":"',攻击+'+core.values.redJewel", - "blueJewel":"',防御+'+core.values.blueJewel", - "greenJewel":"',魔防+'+core.values.greenJewel", + "redJewel":"',攻击+'+core.values.redJewel * ratio", + "blueJewel":"',防御+'+core.values.blueJewel * ratio", + "greenJewel":"',魔防+'+core.values.greenJewel * ratio", "yellowJewel":"',全属性提升'", - "redPotion":"',生命+'+core.values.redPotion", - "bluePotion":"',生命+'+core.values.bluePotion", - "yellowPotion":"',生命+'+core.values.yellowPotion", - "greenPotion":"',生命+'+core.values.greenPotion", + "redPotion":"',生命+'+core.values.redPotion * ratio", + "bluePotion":"',生命+'+core.values.bluePotion * ratio", + "yellowPotion":"',生命+'+core.values.yellowPotion * ratio", + "greenPotion":"',生命+'+core.values.greenPotion * ratio", "sword1":"',攻击+'+core.values.sword1", "sword2":"',攻击+'+core.values.sword2", "sword3":"',攻击+'+core.values.sword3", From 39db1cd2352b70179cef817220365e403aac0f5f Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Wed, 7 Mar 2018 17:35:15 +0800 Subject: [PATCH 11/23] =?UTF-8?q?blockly=E6=94=B9=E4=B8=BA=E5=BC=B9?= =?UTF-8?q?=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/README.md | 91 +++++++++++++++++++++++++++++++++++++ _server/css/editor_mode.css | 6 ++- _server/editor_blockly.js | 19 ++++++-- _server/editor_mode.js | 1 + editor.html | 6 ++- 5 files changed, 117 insertions(+), 6 deletions(-) create mode 100644 _server/README.md diff --git a/_server/README.md b/_server/README.md new file mode 100644 index 00000000..9f9a2475 --- /dev/null +++ b/_server/README.md @@ -0,0 +1,91 @@ +# editor + +本目录下所有文件,以及`../editor.html`和`../启动服务.exe`([源码](http://github.com/ckcz123/mota-js-server/))是地图编辑器的所有组件. + +`editor.js`,`editor_file.js`和`editor_mode.js`耦合较强,`editor_blockly.js`和`fs.js`基本可以独立使用. + +## 各组件功能 + +### editor.js + +暂略 + +### editor_file.js +提供了以下函数进行楼层`map`数组相关的操作 +```javascript +editor.file.getFloorFileList +editor.file.loadFloorFile +editor.file.saveFloorFile +editor.file.saveFloorFileAs +``` +5个编辑模式有关的查询 +```javascript +editor.file.editItem('redJewel',[],function(a){console.log(a)}); +editor.file.editEnemy('redBat',[],function(a){console.log(a)}); +editor.file.editLoc(2,0,[],function(a){console.log(a)}); +editor.file.editFloor([],function(a){console.log(a)}); +editor.file.editTower([],function(a){console.log(a)}); +``` +5个编辑模式有关的编辑 +```javascript +editor.info={images: "terrains", y: 9}; +editor.file.changeIdAndIdnum('yellowWall2',16,editor.info,function(a){console.log(a)}); +editor.file.editItem('book',[["change","['items']['name']","怪物手册的新名字"]],function(a){console.log(a)}); +editor.file.editEnemy('redBat',[['change',"['atk']",20]],function(a){console.log(a)}); +editor.file.editLoc(2,6,[["change","['afterBattle']",null]],function(a){console.log(a)}); +editor.file.editFloor([["change","['title']",'样板 33 层']],function(a){console.log(a)}); +editor.file.editTower([["change","['values']['lavaDamage']",200]],function(a){console.log(a)}); +``` + +### editor_mode.js +4个生成表格并绑定事件的函数 +```javascript +editor.mode.loc(); +editor.mode.emenyitem(); +editor.mode.floor(); +editor.mode.tower(); +``` +切换模式 +```javascript +editor.mode.onmode(''); +editor.mode.onmode('loc'); +editor.mode.onmode('emenyitem'); +editor.mode.onmode('floor'); +editor.mode.onmode('tower'); +``` +在切换模式时,改动才会保存到文件,并且需要刷新页面使得`editor`能看到改动 + +表格的`onchange`的实现中,获得当前模式的方式.不注意的话,修改`index.html`中页面的结构,会被坑 +```javascript +var node = thisTr.parentNode; +while (!editor_mode._ids.hasOwnProperty(node.getAttribute('id'))) { + node = node.parentNode; +} +editor_mode.onmode(editor_mode._ids[node.getAttribute('id')]); +``` +### editor_blockly.js +把选定`id_`的事件用blockly编辑 +``` js +editor_blockly.import(id_); +``` +把文本区域的代码转换成图块 +``` js +editor_blockly.parse(); +``` +把当前图块对应的事件返回给调用blockly的`id_` +``` js +editor_blockly.confirm(); +``` + +### 待调整 + +多行文本编辑器独立作为组件 +editor_multi.js + +## z-index + +目前主体部分使用了 0,75,100 + +暂定blockly使用 200 ,多行文本编辑器使用 300 + +完成后再调整 \ No newline at end of file diff --git a/_server/css/editor_mode.css b/_server/css/editor_mode.css index a3c232c9..724bb347 100644 --- a/_server/css/editor_mode.css +++ b/_server/css/editor_mode.css @@ -45,7 +45,11 @@ #left6 { left: 5px; - top: 1930px; + /* top: 1930px; */ + top: 5px; + z-index: 200; + position: fixed; + background-color: rgb(245, 245, 245); width: 1335px; height: 780px; } diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 91a15c61..dbe164d4 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -327,7 +327,13 @@ editor_blockly.import = function(id_){ editor_blockly.show(); } -editor_blockly.show = function(){} +editor_blockly.show = function(){document.getElementById('left6').style='';} +editor_blockly.hide = function(){document.getElementById('left6').style='z-index:-1;opacity: 0;';} + +editor_blockly.cancel = function(){ + editor_blockly.id=''; + editor_blockly.hide(); +} editor_blockly.confirm = function (){ if(!editor_blockly.id){ @@ -339,6 +345,7 @@ editor_blockly.confirm = function (){ editor_blockly.id=''; var input = thisTr.children[2].children[0].children[0]; input.value = value; + editor_blockly.hide(); input.onchange(); } if(document.getElementById('codeArea').value===''){ @@ -357,21 +364,27 @@ var codeEditor = CodeMirror.fromTextArea(document.getElementById("multiLineCode" continueComments: "Enter", extraKeys: {"Ctrl-Q": "toggleComment"} }); +editor_blockly.showCodeEditor = function(){document.getElementById("multiLineDiv").style='';} +editor_blockly.hideCodeEditor = function(){document.getElementById("multiLineDiv").style='z-index:-1;opacity: 0;';} var multiLineArgs=[null,null,null]; editor_blockly.multiLineEdit = function(value,b,f,callback){ - document.getElementById("multiLineDiv").style.display=''; + editor_blockly.showCodeEditor(); codeEditor.setValue(value.split('\\n').join('\n')||''); multiLineArgs[0]=b; multiLineArgs[1]=f; multiLineArgs[2]=callback; } editor_blockly.multiLineDone = function(){ - document.getElementById("multiLineDiv").style.display='none'; + editor_blockly.hideCodeEditor(); if(!multiLineArgs[0] || !multiLineArgs[1] || !multiLineArgs[2])return; var newvalue = codeEditor.getValue()||''; multiLineArgs[2](newvalue,multiLineArgs[0],multiLineArgs[1]) } +editor_blockly.multiLineCancel = function(){ + multiLineArgs=[null,null,null]; + editor_blockly.hideCodeEditor(); +} editor_blockly.doubleClickBlock = function (blockId){ var b=editor_blockly.workspace.getBlockById(blockId); diff --git a/_server/editor_mode.js b/_server/editor_mode.js index 5ef6852d..a0092c85 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -1,4 +1,5 @@ editor_mode = function(editor){ +var core = editor.core; function editor_mode(){ this.ids={ diff --git a/editor.html b/editor.html index 6cde4cea..854ab8cb 100644 --- a/editor.html +++ b/editor.html @@ -99,7 +99,7 @@ -
+

事件编辑器    @@ -115,6 +115,7 @@ +

- From 05982bfaf486e8f129e565921a2648d2f2a1932c Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Wed, 7 Mar 2018 22:44:57 +0800 Subject: [PATCH 12/23] issue #57 #57 --- _server/README.md | 10 ++- _server/css/editor_mode.css | 24 +++++-- _server/editor.js | 2 + _server/editor_blockly.js | 31 +-------- _server/editor_file.js | 119 ++++++++++++++++++++++++++--------- _server/editor_mode.js | 18 +++++- _server/editor_multi.js | 76 ++++++++++++++++++++++ editor.html | 24 +++++-- project/data.comment.js | 2 +- project/functions.comment.js | 2 +- project/functions.js | 13 ++++ 11 files changed, 247 insertions(+), 74 deletions(-) create mode 100644 _server/editor_multi.js diff --git a/_server/README.md b/_server/README.md index 9f9a2475..ec9d1981 100644 --- a/_server/README.md +++ b/_server/README.md @@ -18,15 +18,16 @@ editor.file.loadFloorFile editor.file.saveFloorFile editor.file.saveFloorFileAs ``` -5个编辑模式有关的查询 +6个编辑模式有关的查询 ```javascript editor.file.editItem('redJewel',[],function(a){console.log(a)}); editor.file.editEnemy('redBat',[],function(a){console.log(a)}); editor.file.editLoc(2,0,[],function(a){console.log(a)}); editor.file.editFloor([],function(a){console.log(a)}); editor.file.editTower([],function(a){console.log(a)}); +editor.file.editFunctions([],function(a){console.log(a)}); ``` -5个编辑模式有关的编辑 +6个编辑模式有关的编辑 ```javascript editor.info={images: "terrains", y: 9}; editor.file.changeIdAndIdnum('yellowWall2',16,editor.info,function(a){console.log(a)}); @@ -35,15 +36,17 @@ editor.file.editEnemy('redBat',[['change',"['atk']",20]],function(a){console.log editor.file.editLoc(2,6,[["change","['afterBattle']",null]],function(a){console.log(a)}); editor.file.editFloor([["change","['title']",'样板 33 层']],function(a){console.log(a)}); editor.file.editTower([["change","['values']['lavaDamage']",200]],function(a){console.log(a)}); +editor.file.editFunctions(["change","['events']['afterChangeLight']","function(x,y){console.log(x,y)}"],function(a){console.log(a)}); ``` ### editor_mode.js -4个生成表格并绑定事件的函数 +5个生成表格并绑定事件的函数 ```javascript editor.mode.loc(); editor.mode.emenyitem(); editor.mode.floor(); editor.mode.tower(); +editor.mode.functions(); ``` 切换模式 ```javascript @@ -52,6 +55,7 @@ editor.mode.onmode('loc'); editor.mode.onmode('emenyitem'); editor.mode.onmode('floor'); editor.mode.onmode('tower'); +editor.mode.onmode('functions'); ``` 在切换模式时,改动才会保存到文件,并且需要刷新页面使得`editor`能看到改动 diff --git a/_server/css/editor_mode.css b/_server/css/editor_mode.css index 724bb347..3a6a86cc 100644 --- a/_server/css/editor_mode.css +++ b/_server/css/editor_mode.css @@ -56,13 +56,29 @@ #left6 #blocklyDiv {height: 480px; width: 940px;float:left;} #left6 #codeArea {width: 99.5%; height: 15.4em;overflow:y;/* resize:none; */clear:both;} -#left6 #multiLineDiv {height: 440px; width: 375px;float:left;} -#left6 #multiLineDiv .CodeMirror { + +#left7 { + /* height: 440px; width: 375px;float:left; */ + left: 5px; + top: 5px; + z-index: 200; + position: fixed; + background-color: rgb(245, 245, 245); + width: 1335px; + height: 780px; +} +#left7 .CodeMirror { /* border-top: 1px solid black; border-bottom: 1px solid black; */ border: 1px solid #eee; - height: 438px; - width: 373px; + height: 700px; + width: 940px; +} + +#left8 { + left: 900px; + top: 1290px; + width: 440px; } .etable table, diff --git a/_server/editor.js b/_server/editor.js index d6130e83..718199a7 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -22,6 +22,7 @@ editor.prototype.init = function(callback){ } var afterMainInit = function(){ + core.floors=JSON.parse(JSON.stringify(core.floors,function(k,v){if(v instanceof Function){return v.toString()}else return v})); editor.main=main; editor.core=core; editor.fs=fs; @@ -154,6 +155,7 @@ editor.prototype.mapInit = function(){ editor.currentFloorData.afterBattle={}; editor.currentFloorData.afterGetItem={}; editor.currentFloorData.afterOpenDoor={}; + editor.currentFloorData.cannotMove={}; } editor.prototype.drawMapBg = function(img){ var bgc = bg.getContext('2d'); diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index dbe164d4..214fbb36 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -357,35 +357,6 @@ editor_blockly.confirm = function (){ setvalue(JSON.stringify(obj)); } -var codeEditor = CodeMirror.fromTextArea(document.getElementById("multiLineCode"), { - lineNumbers: true, - matchBrackets: true, - lineWrapping: true, - continueComments: "Enter", - extraKeys: {"Ctrl-Q": "toggleComment"} -}); -editor_blockly.showCodeEditor = function(){document.getElementById("multiLineDiv").style='';} -editor_blockly.hideCodeEditor = function(){document.getElementById("multiLineDiv").style='z-index:-1;opacity: 0;';} - -var multiLineArgs=[null,null,null]; -editor_blockly.multiLineEdit = function(value,b,f,callback){ - editor_blockly.showCodeEditor(); - codeEditor.setValue(value.split('\\n').join('\n')||''); - multiLineArgs[0]=b; - multiLineArgs[1]=f; - multiLineArgs[2]=callback; -} -editor_blockly.multiLineDone = function(){ - editor_blockly.hideCodeEditor(); - if(!multiLineArgs[0] || !multiLineArgs[1] || !multiLineArgs[2])return; - var newvalue = codeEditor.getValue()||''; - multiLineArgs[2](newvalue,multiLineArgs[0],multiLineArgs[1]) -} -editor_blockly.multiLineCancel = function(){ - multiLineArgs=[null,null,null]; - editor_blockly.hideCodeEditor(); -} - editor_blockly.doubleClickBlock = function (blockId){ var b=editor_blockly.workspace.getBlockById(blockId); console.log(b); @@ -400,7 +371,7 @@ editor_blockly.doubleClickBlock = function (blockId){ if(f){ var value = b.getFieldValue(f); //多行编辑 - editor_blockly.multiLineEdit(value,b,f,function(newvalue,b,f){ + editor_multi.multiLineEdit(value,b,f,function(newvalue,b,f){ if(textStringDict[b.type]!=='RawEvalString_0'){} b.setFieldValue(newvalue.split('\n').join('\\n'),f); }); diff --git a/_server/editor_file.js b/_server/editor_file.js index ce340d8a..2667ec0c 100644 --- a/_server/editor_file.js +++ b/_server/editor_file.js @@ -3,35 +3,28 @@ editor_file = function(editor, callback){ var editor_file = {}; - - (function(){ - var script = document.createElement('script'); - if (window.location.href.indexOf('_server')!==-1) - script.src = '../project/comment.js'; - else - script.src = 'project/comment.js'; - document.body.appendChild(script); - script.onload = function () { - editor_file.comment=comment_c456ea59_6018_45ef_8bcc_211a24c627dc; - delete(comment_c456ea59_6018_45ef_8bcc_211a24c627dc); - if (editor_file.comment && editor_file.dataComment && callback) - callback(); - } - })(); - (function(){ - var script = document.createElement('script'); - if (window.location.href.indexOf('_server')!==-1) - script.src = '../project/data.comment.js'; - else - script.src = 'project/data.comment.js'; - document.body.appendChild(script); - script.onload = function () { - editor_file.dataComment=data_comment_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d; - delete(data_comment_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d); - if (editor_file.comment && editor_file.dataComment && callback) - callback(); - } - })(); + var commentjs={ + 'comment':'comment', + 'data.comment':'dataComment', + 'functions.comment':'functionsComment', + } + for(var key in commentjs){ + (function(key){ + var value = commentjs[key]; + var script = document.createElement('script'); + if (window.location.href.indexOf('_server')!==-1) + script.src = '../project/'+key+'.js'; + else + script.src = 'project/'+key+'.js'; + document.body.appendChild(script); + script.onload = function () { + editor_file[value]=eval(key.replace('.','_')+'_c456ea59_6018_45ef_8bcc_211a24c627dc'); + var loaded = Boolean(callback); + for(var key_ in commentjs){loaded = loaded && editor_file[commentjs[key_]]} + if (loaded)callback(); + } + })(key); + } editor_file.getFloorFileList = function(callback){ @@ -396,6 +389,52 @@ editor_file = function(editor, callback){ } //callback([obj,commentObj,err:String]) + //////////////////////////////////////////////////////////////////// + + var fmap = {}; + var fjson = JSON.stringify(functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a,function(k,v){if(v instanceof Function){var id_ = editor.guid();fmap[id_]=v.toString();return id_;}else return v},4); + var fobj = JSON.parse(fjson); + editor_file.functionsMap = fmap; + editor_file.functionsJSON = fjson; + var buildlocobj = function(locObj){ + for(var key in locObj){ + if(typeof(locObj[key])!==typeof(''))buildlocobj(locObj[key]); + else locObj[key]=fmap[locObj[key]]; + } + }; + + editor_file.editFunctions = function(actionList,callback){ + /*actionList:[ + ["change","['events']['afterChangeLight']","function(x,y){console.log(x,y)}"], + ["change","['ui']['drawAbout']","function(){...}"], + ] + 为[]时只查询不修改 + */ + if (!isset(callback)) {printe('未设置callback');throw('未设置callback')}; + if (isset(actionList) && actionList.length > 0){ + saveSetting('functions',actionList,function (err) { + callback([ + (function(){ + var locObj=JSON.parse(fjson); + buildlocobj(locObj); + return locObj; + })(), + editor_file.functionsComment, + err]); + }); + } else { + callback([ + (function(){ + var locObj=JSON.parse(fjson); + buildlocobj(locObj); + return locObj; + })(), + editor_file.functionsComment, + null]); + } + } + //callback([obj,commentObj,err:String]) + //////////////////////////////////////////////////////////////////// var isset = function (val) { @@ -422,6 +461,12 @@ editor_file = function(editor, callback){ } return formatArrStr; } + + var encode = function (str) { + return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) { + return String.fromCharCode(parseInt(p1, 16)) + })) + } var saveSetting = function(file,actionList,callback) { console.log(file); @@ -490,6 +535,22 @@ editor_file = function(editor, callback){ }); return; } + if (file=='functions') { + actionList.forEach(function (value) { + if (value[0]!='change')return; + eval("fmap[fobj"+value[1]+']='+JSON.stringify(value[2])); + }); + var fraw = fjson; + for(var id_ in fmap){ + fraw = fraw.replace('"'+id_+'"',fmap[id_]) + } + var datastr='functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = \n'; + datastr+=fraw; + fs.writeFile('project/functions.js',encode(datastr),'base64',function(err, data){ + callback(err); + }); + return; + } if (file=='floors') { actionList.forEach(function (value) { if (value[0]!='change')return; diff --git a/_server/editor_mode.js b/_server/editor_mode.js index a0092c85..9ad234e8 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -6,7 +6,8 @@ function editor_mode(){ 'loc':'left2', 'emenyitem':'left3', 'floor':'left4', - 'tower':'left5' + 'tower':'left5', + 'functions':'left8' } this._ids={} this.dom={} @@ -74,6 +75,7 @@ editor_mode.prototype.objToTable = function(obj,commentObj){ } input.ondblclick = function(){ editor_blockly.import(guid); + editor_multi.import(guid); } }); } @@ -164,6 +166,10 @@ editor_mode.prototype.doActionList = function(mode,actionList){ editor.file.editTower(actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')}); break; + case 'functions': + + editor.file.editFunctions(actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')}); + break; default: break; } @@ -243,6 +249,16 @@ editor_mode.prototype.tower = function(callback){ if (Boolean(callback))callback(); } +editor_mode.prototype.functions = function(callback){ + var objs=[]; + editor.file.editFunctions([],function(objs_){objs=objs_;console.log(objs_)}); + //只查询不修改时,内部实现不是异步的,所以可以这么写 + var tableinfo=editor_mode.objToTable(objs[0],objs[1]); + document.getElementById('table_e260a2be_5690_476a_b04e_dacddede78b3').innerHTML=tableinfo.HTML; + tableinfo.listen(tableinfo.guids); + if (Boolean(callback))callback(); +} + ///////////////////////////////////////////////////////////////////////////// editor_mode.prototype.listen = function(callback){ diff --git a/_server/editor_multi.js b/_server/editor_multi.js new file mode 100644 index 00000000..3a620b8d --- /dev/null +++ b/_server/editor_multi.js @@ -0,0 +1,76 @@ +editor_multi = function(){ + +var editor_multi = {}; + +var codeEditor = CodeMirror.fromTextArea(document.getElementById("multiLineCode"), { + lineNumbers: true, + matchBrackets: true, + lineWrapping: true, + continueComments: "Enter", + extraKeys: {"Ctrl-Q": "toggleComment"} +}); + +editor_multi.id=''; + +editor_multi.show = function(){document.getElementById('left7').style='';} +editor_multi.hide = function(){document.getElementById('left7').style='z-index:-1;opacity: 0;';} + + +editor_multi.import = function(id_){ + var thisTr = document.getElementById(id_); + if(!thisTr)return; + var input = thisTr.children[2].children[0].children[0]; + var field = thisTr.children[0].getAttribute('title'); + var type = input.value && (input.value.slice(0,11)==='"function ('); + if(!type)return; + editor_multi.id=id_; + codeEditor.setValue(JSON.parse(input.value)||''); + editor_multi.show(); +} + +editor_multi.cancel = function(){ + editor_multi.hide(); + editor_multi.id=''; + multiLineArgs=[null,null,null]; +} + +editor_multi.confirm = function (){ + if(!editor_multi.id){ + editor_multi.id=''; + return; + } + if(editor_multi.id==='callFromBlockly'){ + editor_multi.id=''; + editor_multi.multiLineDone(); + return; + } + var setvalue = function(value){ + var thisTr = document.getElementById(editor_multi.id); + editor_multi.id=''; + var input = thisTr.children[2].children[0].children[0]; + input.value = JSON.stringify(value); + editor_multi.hide(); + input.onchange(); + } + setvalue(codeEditor.getValue()||''); +} + +var multiLineArgs=[null,null,null]; +editor_multi.multiLineEdit = function(value,b,f,callback){ + editor_multi.id='callFromBlockly'; + codeEditor.setValue(value.split('\\n').join('\n')||''); + multiLineArgs[0]=b; + multiLineArgs[1]=f; + multiLineArgs[2]=callback; + editor_multi.show(); +} +editor_multi.multiLineDone = function(){ + editor_multi.hide(); + if(!multiLineArgs[0] || !multiLineArgs[1] || !multiLineArgs[2])return; + var newvalue = codeEditor.getValue()||''; + multiLineArgs[2](newvalue,multiLineArgs[0],multiLineArgs[1]) +} + +return editor_multi; +} +//editor_multi=editor_multi(); \ No newline at end of file diff --git a/editor.html b/editor.html index 854ab8cb..73320236 100644 --- a/editor.html +++ b/editor.html @@ -125,14 +125,24 @@
-
- - - -
+
+ + + +
+
+

脚本编辑

+
+ + + + +
条目注释
+
+
@@ -331,7 +341,9 @@ main.init('editor', function() { editor.mode.emenyitem(); editor.mode.floor(); editor.mode.tower(); + editor.mode.functions(); editor.mode.listen(); + editor_multi=editor_multi(); editor_blockly=editor_blockly(); }); }); @@ -341,6 +353,8 @@ main.init('editor', function() { //main.listen(); + + diff --git a/project/data.comment.js b/project/data.comment.js index 7a901303..00531642 100644 --- a/project/data.comment.js +++ b/project/data.comment.js @@ -1,4 +1,4 @@ -data_comment_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = +data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "main": { "useCompress": " 是否使用压缩文件 \n 当你即将发布你的塔时,请使用“JS代码压缩工具”将所有js代码进行压缩,然后将这里的useCompress改为true。 \n 请注意,只有useCompress是false时才会读取floors目录下的文件,为true时会直接读取libs目录下的floors.min.js文件。 \n 如果要进行剧本的修改请务必将其改成false。 \n$select({\"values\":[false]})$end", diff --git a/project/functions.comment.js b/project/functions.comment.js index 1540f623..8093f009 100644 --- a/project/functions.comment.js +++ b/project/functions.comment.js @@ -1,4 +1,4 @@ -functions_comment_d6ad677b_427a_4623_b50f_a445a3b0ef8a = +functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "events" : { "setInitData" : "不同难度分别设置初始属性", diff --git a/project/functions.js b/project/functions.js index eb97fffe..20059376 100644 --- a/project/functions.js +++ b/project/functions.js @@ -3,6 +3,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = "events":{ ////// 不同难度分别设置初始属性 ////// "setInitData":function (hard) { + // 不同难度分别设置初始属性 if (hard=='Easy') { // 简单难度 core.setFlag('hard', 1); // 可以用flag:hard来获得当前难度 // 可以在此设置一些初始福利,比如设置初始生命值可以调用: @@ -23,6 +24,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = }, ////// 游戏获胜事件 ////// "win" : function(reason) { + // 游戏获胜事件 core.ui.closePanel(); var replaying = core.status.replay.replaying; core.stopReplay(); @@ -38,6 +40,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = }, ////// 游戏失败事件 ////// "lose" : function(reason) { + // 游戏失败事件 core.ui.closePanel(); var replaying = core.status.replay.replaying; core.stopReplay(); @@ -51,6 +54,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = }, ////// 转换楼层结束的事件 ////// "afterChangeFloor" : function (floorId) { + // 转换楼层结束的事件 if (core.isset(core.status.event.id)) return; // 当前存在事件 if (!core.hasFlag("visited_"+floorId)) { @@ -66,6 +70,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = }, ////// 加点事件 ////// "addPoint" : function (enemy) { + // 加点事件 var point = enemy.point; if (!core.isset(point) || point<=0) return []; @@ -88,6 +93,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = }, ////// 战斗结束后触发的事件 ////// "afterBattle" : function(enemyId,x,y,callback) { + // 战斗结束后触发的事件 var enemy = core.material.enemys[enemyId]; @@ -189,6 +195,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = }, ////// 开一个门后触发的事件 ////// "afterOpenDoor" : function(doorId,x,y,callback) { + // 开一个门后触发的事件 var todo = []; if (core.isset(x) && core.isset(y)) { @@ -212,10 +219,12 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = }, ////// 改变亮灯之后,可以触发的事件 ////// "afterChangeLight" : function(x,y) { + // 改变亮灯之后,可以触发的事件 }, ////// 推箱子后的事件 ////// "afterPushBox" : function () { + // 推箱子后的事件 var noBoxLeft = function () { // 地图上是否还存在未推到的箱子,如果不存在则返回true,存在则返回false @@ -239,6 +248,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = }, ////// 使用炸弹/圣锤后的事件 ////// "afterUseBomb" : function () { + // 使用炸弹/圣锤后的事件 // 这是一个使用炸弹也能开门的例子 /* @@ -254,10 +264,12 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = }, ////// 即将存档前可以执行的操作 ////// "beforeSaveData" : function(data) { + // 即将存档前可以执行的操作 }, ////// 读档事件后,载入事件前,可以执行的操作 ////// "afterLoadData" : function(data) { + // 读档事件后,载入事件前,可以执行的操作 } @@ -266,6 +278,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = "ui":{ ////// 绘制“关于”界面 ////// "drawAbout" : function() { + // 绘制“关于”界面 if (!core.isPlaying()) { core.status.event = {'id': null, 'data': null}; From a695dcd6cffcbdfca18cf0abaea91a3dc5a34301 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Thu, 8 Mar 2018 19:00:20 +0800 Subject: [PATCH 13/23] =?UTF-8?q?editor=E5=89=8D=E7=AB=AF=E4=B8=8A?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/css/editor_mode.css | 13 ++++++++++--- _server/editor.js | 4 ++-- _server/editor_mode.js | 20 +++++++++++++++++++- _server/vm.js | 15 ++++++++++++++- editor.html | 30 +++++++++++++++++++++--------- 5 files changed, 66 insertions(+), 16 deletions(-) diff --git a/_server/css/editor_mode.css b/_server/css/editor_mode.css index 3a6a86cc..1985bd23 100644 --- a/_server/css/editor_mode.css +++ b/_server/css/editor_mode.css @@ -13,6 +13,13 @@ .leftTab > :first-child{margin-top:5px;} .leftTab > :last-child{margin-bottom:5px;} +.leftTab { + left: 5px; + top: 10px; + width: 435px; +} + +/* #left1 { left: 5px; top: 650px; @@ -42,7 +49,7 @@ top: 1290px; width: 440px; } - + */ #left6 { left: 5px; /* top: 1930px; */ @@ -74,13 +81,13 @@ height: 700px; width: 940px; } - +/* #left8 { left: 900px; top: 1290px; width: 440px; } - + */ .etable table, .etable table td { color: #000; diff --git a/_server/editor.js b/_server/editor.js index 718199a7..72aee983 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -363,7 +363,7 @@ editor.prototype.listen = function() { if(!selectBox.isSelected) { var loc = eToLoc(e); var pos = locToPos(loc); - editor_mode.onmode('');//为了强制触发doAction + editor_mode.onmode('nextChange');//为了强制触发doAction editor_mode.onmode('loc'); editor_mode.loc(); tip.whichShow = 1; @@ -521,7 +521,7 @@ editor.prototype.listen = function() { } } tip.infos = JSON.parse(JSON.stringify(editor.info)); - editor_mode.onmode('');//为了强制触发doAction + editor_mode.onmode('nextChange');//为了强制触发doAction editor_mode.onmode('emenyitem'); editor_mode.emenyitem(); } diff --git a/_server/editor_mode.js b/_server/editor_mode.js index 9ad234e8..fa06fda7 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -7,7 +7,10 @@ function editor_mode(){ 'emenyitem':'left3', 'floor':'left4', 'tower':'left5', - 'functions':'left8' + 'functions':'left8', + + 'map':'left', + 'appendpic':'left1', } this._ids={} this.dom={} @@ -179,11 +182,20 @@ editor_mode.prototype.onmode = function (mode) { if (editor_mode.mode!=mode) { console.log('change mode into : '+mode); editor_mode.doActionList(editor_mode.mode,editor_mode.actionList); + if(editor_mode.mode==='nextChange' && mode)editor_mode.showMode(mode); editor_mode.mode=mode; editor_mode.actionList=[]; } } +editor_mode.prototype.showMode = function (mode) { + for(var name in this.dom){ + editor_mode.dom[name].style='z-index:-1;opacity: 0;'; + } + editor_mode.dom[mode].style=''; + document.getElementById('editModeSelect').value=mode; +} + editor_mode.prototype.loc = function(callback){ //editor.pos={x: 0, y: 0}; if (!core.isset(editor.pos))return; @@ -448,6 +460,12 @@ editor_mode.prototype.listen = function(callback){ }); } + var editModeSelect = document.getElementById('editModeSelect'); + editModeSelect.onchange = function(){ + editor_mode.onmode('nextChange'); + editor_mode.onmode(editModeSelect.value); + } + if (Boolean(callback))callback(); } diff --git a/_server/vm.js b/_server/vm.js index a034eaf6..de416fed 100644 --- a/_server/vm.js +++ b/_server/vm.js @@ -1,7 +1,20 @@ // vue 相关处理 document.body.onmousedown = function(e){ - selectBox.isSelected = false; + console.log(e); + var eid=[]; + e.path.forEach(function(node){ + if(!node.getAttribute)return; + var id_ = node.getAttribute('id'); + if (id_){ + if(['left','left1','left2','left3','left4','left5','left8'].indexOf(id_)!==-1)eid.push('edit'); + eid.push(id_); + } + }); + console.log(eid); + if(eid.indexOf('edit')===-1){ + if(eid.indexOf('tip')===-1)selectBox.isSelected = false; + } editor_mode.onmode(''); editor.info = {}; } diff --git a/editor.html b/editor.html index 73320236..2b59da98 100644 --- a/editor.html +++ b/editor.html @@ -8,7 +8,7 @@
-
+
@@ -32,7 +32,7 @@
-
+

追加素材

@@ -52,7 +52,7 @@

-
+

地图选点

0,0

@@ -63,7 +63,7 @@
-
+

图块属性

@@ -79,7 +79,7 @@
-
+

楼层属性

@@ -89,7 +89,7 @@
-
+

全塔属性

@@ -128,12 +128,12 @@ -
+
-
+

脚本编辑

@@ -170,7 +170,17 @@ -
+ + +
+ ', '', - '\n', + '\n', ]; return [outstr.join(''),guid]; } diff --git a/_server/editor_multi.js b/_server/editor_multi.js index 3a620b8d..289a5971 100644 --- a/_server/editor_multi.js +++ b/_server/editor_multi.js @@ -11,6 +11,7 @@ var codeEditor = CodeMirror.fromTextArea(document.getElementById("multiLineCode" }); editor_multi.id=''; +editor_multi.isString=false; editor_multi.show = function(){document.getElementById('left7').style='';} editor_multi.hide = function(){document.getElementById('left7').style='z-index:-1;opacity: 0;';} @@ -18,14 +19,20 @@ editor_multi.hide = function(){document.getElementById('left7').style='z-index:- editor_multi.import = function(id_){ var thisTr = document.getElementById(id_); - if(!thisTr)return; + if(!thisTr)return false; var input = thisTr.children[2].children[0].children[0]; var field = thisTr.children[0].getAttribute('title'); - var type = input.value && (input.value.slice(0,11)==='"function ('); - if(!type)return; + if(!input.type || input.type!=='textarea')return false; editor_multi.id=id_; - codeEditor.setValue(JSON.parse(input.value)||''); + editor_multi.isString=false; + if(input.value.slice(0,1)==='"'){ + editor_multi.isString=true; + codeEditor.setValue(JSON.parse(input.value)||''); + } else { + codeEditor.setValue(input.value||''); + } editor_multi.show(); + return true; } editor_multi.cancel = function(){ @@ -48,7 +55,11 @@ editor_multi.confirm = function (){ var thisTr = document.getElementById(editor_multi.id); editor_multi.id=''; var input = thisTr.children[2].children[0].children[0]; - input.value = JSON.stringify(value); + if(editor_multi.isString){ + input.value = JSON.stringify(value); + } else { + input.value = value; + } editor_multi.hide(); input.onchange(); } From 93ee7f04150f1ad4913b342b093be6eaaa94d446 Mon Sep 17 00:00:00 2001 From: oc Date: Fri, 9 Mar 2018 21:11:58 +0800 Subject: [PATCH 19/23] Remove Storage --- libs/actions.js | 78 +++++++++++++++++++++++++++++++++++++++++++------ libs/enemys.js | 4 +++ libs/events.js | 2 +- libs/ui.js | 8 +++++ main.js | 6 ++-- 5 files changed, 85 insertions(+), 13 deletions(-) diff --git a/libs/actions.js b/libs/actions.js index 1a815548..aca775d9 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -128,6 +128,10 @@ actions.prototype.keyDown = function(keyCode) { this.keyDownLocalSaveSelect(keyCode); return; } + if (core.status.event.id=='storageRemove') { + this.keyDownStorageRemove(keyCode); + return; + } if (core.status.event.id=='cursor') { this.keyDownCursor(keyCode); return; @@ -255,7 +259,10 @@ actions.prototype.keyUp = function(keyCode) { this.keyUpLocalSaveSelect(keyCode); return; } - + if (core.status.event.id=='storageRemove') { + this.keyUpStorageRemove(keyCode); + return; + } if (core.status.event.id=='cursor') { this.keyUpCursor(keyCode); return; @@ -649,6 +656,10 @@ actions.prototype.onclick = function (x, y, stepPostfix) { this.clickLocalSaveSelect(x,y); return; } + if (core.status.event.id=='storageRemove') { + this.clickStorageRemove(x,y); + return; + } if (core.status.event.id == 'cursor') { this.clickCursor(x,y); @@ -1628,14 +1639,8 @@ actions.prototype.clickSyncSave = function (x,y) { })); break; case 5: - core.status.event.selection=1; - core.ui.drawConfirmBox("你确定要清空所有存档吗?", function() { - localStorage.clear(); - core.drawText("\t[操作成功]你的所有存档已被清空。"); - }, function() { - core.status.event.selection=5; - core.ui.drawSyncSave(); - }) + core.status.event.selection=0; + core.ui.drawStorageRemove(); break; case 6: core.status.event.selection=3; @@ -1793,6 +1798,61 @@ actions.prototype.keyUpLocalSaveSelect = function (keycode) { } } +////// 存档删除界面时的点击操作 ////// +actions.prototype.clickStorageRemove = function (x, y) { + if (x<5 || x>7) return; + var choices = core.status.event.ui.choices; + + var topIndex = 6 - parseInt((choices.length - 1) / 2); + + if (y>=topIndex && y=1 && x<=11) { diff --git a/libs/enemys.js b/libs/enemys.js index cf284486..7a744b53 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -170,6 +170,10 @@ enemys.prototype.getDefDamage = function (monsterId) { enemys.prototype.calDamage = function (monster, hero_hp, hero_atk, hero_def, hero_mdef) { var mon_hp = monster.hp, mon_atk = monster.atk, mon_def = monster.def, mon_special = monster.special; + hero_hp=Math.max(0, hero_hp); + hero_atk=Math.max(0, hero_atk); + hero_def=Math.max(0, hero_def); + hero_mdef=Math.max(0, hero_mdef); if (this.hasSpecial(mon_special, 20) && !core.hasItem("cross")) // 如果是无敌属性,且勇士未持有十字架 return 999999999; // 返回无限大 diff --git a/libs/events.js b/libs/events.js index 76415798..91a81d5a 100644 --- a/libs/events.js +++ b/libs/events.js @@ -224,9 +224,9 @@ events.prototype.doAction = function() { // 事件处理完毕 if (core.status.event.data.list.length==0) { + core.ui.closePanel(); if (core.isset(core.status.event.data.callback)) core.status.event.data.callback(); - core.ui.closePanel(); core.replay(); return; } diff --git a/libs/ui.js b/libs/ui.js index 47676211..b100b309 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1068,6 +1068,14 @@ ui.prototype.drawLocalSaveSelect = function () { ]); } +////// 绘制存档删除页面 ////// +ui.prototype.drawStorageRemove = function () { + core.status.event.id = 'storageRemove'; + this.drawChoices(null, [ + "清空全部塔的存档", "只清空当前塔的存档", "返回上级菜单" + ]); +} + ////// 绘制分页 ////// ui.prototype.drawPagination = function (page, totalPage) { diff --git a/main.js b/main.js index 693472b1..fee0d1aa 100644 --- a/main.js +++ b/main.js @@ -442,8 +442,9 @@ main.dom.replayGame.onclick = function () { return; } if (core.isset(obj.version) && obj.version!=core.firstData.version) { - alert("游戏版本不一致!"); - return; + // alert("游戏版本不一致!"); + if (!confirm("游戏版本不一致!\n你仍然想播放录像吗?")) + return; } if (!core.isset(obj.route) || !core.isset(obj.hard)) { alert("无效的录像!"); @@ -454,7 +455,6 @@ main.dom.replayGame.onclick = function () { core.resetStatus(core.firstData.hero, obj.hard, core.firstData.floorId, null, core.initStatus.maps); core.events.setInitData(obj.hard); core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() { - //core.setHeroMoveTriggerInterval(); core.startReplay(core.decodeRoute(obj.route)); }, true); }, function () { From 38842a7200a7c855a658508a2a2dfbf20a255533 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Fri, 9 Mar 2018 22:50:59 +0800 Subject: [PATCH 20/23] =?UTF-8?q?editor=E7=BB=86=E8=8A=82=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/editor.js | 4 ++-- _server/editor_mode.js | 13 +++++++++---- _server/vm.js | 18 +++++++++++++----- editor.html | 20 ++++++++++++-------- project/data.comment.js | 8 ++++---- 5 files changed, 40 insertions(+), 23 deletions(-) diff --git a/_server/editor.js b/_server/editor.js index 72aee983..34903d52 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -363,7 +363,7 @@ editor.prototype.listen = function() { if(!selectBox.isSelected) { var loc = eToLoc(e); var pos = locToPos(loc); - editor_mode.onmode('nextChange');//为了强制触发doAction + editor_mode.onmode('nextChange'); editor_mode.onmode('loc'); editor_mode.loc(); tip.whichShow = 1; @@ -521,7 +521,7 @@ editor.prototype.listen = function() { } } tip.infos = JSON.parse(JSON.stringify(editor.info)); - editor_mode.onmode('nextChange');//为了强制触发doAction + editor_mode.onmode('nextChange'); editor_mode.onmode('emenyitem'); editor_mode.emenyitem(); } diff --git a/_server/editor_mode.js b/_server/editor_mode.js index 22201e19..c3f23bc9 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -72,7 +72,7 @@ editor_mode.prototype.objToTable = function(obj,commentObj){ editor_mode.addAction(['change',field,JSON.parse(input.value)]); //尚未完成,不完善,目前还没做$range的检查 - /*临时*/editor_mode.onmode('');/*临时*/ + // /*临时*/editor_mode.onmode('');/*临时*/ //临时改为立刻写入文件,删去此句的时,切换模式才会真正写入 //现阶段这样会更实用,20180218 } @@ -149,6 +149,7 @@ editor_mode.prototype.addAction = function(action){ editor_mode.prototype.doActionList = function(mode,actionList){ if (actionList.length==0)return; + printf('修改中...'); switch (mode) { case 'loc': @@ -182,7 +183,7 @@ editor_mode.prototype.doActionList = function(mode,actionList){ editor_mode.prototype.onmode = function (mode) { if (editor_mode.mode!=mode) { console.log('change mode into : '+mode); - editor_mode.doActionList(editor_mode.mode,editor_mode.actionList); + if(mode==='save')editor_mode.doActionList(editor_mode.mode,editor_mode.actionList); if(editor_mode.mode==='nextChange' && mode)editor_mode.showMode(mode); editor_mode.mode=mode; editor_mode.actionList=[]; @@ -194,6 +195,7 @@ editor_mode.prototype.showMode = function (mode) { editor_mode.dom[name].style='z-index:-1;opacity: 0;'; } editor_mode.dom[mode].style=''; + if(editor_mode[mode])editor_mode[mode](); document.getElementById('editModeSelect').value=mode; } @@ -216,7 +218,8 @@ editor_mode.prototype.loc = function(callback){ editor_mode.prototype.emenyitem = function(callback){ //editor.info=editor.ids[editor.indexs[201]]; if (!core.isset(editor.info))return; - editor_mode.info=editor.info;//避免editor.info被清空导致无法获得是物品还是怪物 + + if(Object.keys(editor.info).length!==0)editor_mode.info=editor.info;//避免editor.info被清空导致无法获得是物品还是怪物 if (!core.isset(editor_mode.info.id)){ document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML=''; @@ -277,7 +280,7 @@ editor_mode.prototype.functions = function(callback){ editor_mode.prototype.listen = function(callback){ var newIdIdnum = document.getElementById('newIdIdnum'); - newIdIdnum.children[0].onchange = newIdIdnum.children[1].onchange = function(){ + newIdIdnum.children[2].onclick = function(){ if (newIdIdnum.children[0].value && newIdIdnum.children[1].value){ var id = newIdIdnum.children[0].value; var idnum = parseInt(newIdIdnum.children[1].value); @@ -285,6 +288,8 @@ editor_mode.prototype.listen = function(callback){ if(err){printe(err);throw(err)} printe('添加id的idnum成功,请F5刷新编辑器'); }); + } else { + printe('请输入id和idnum'); } } diff --git a/_server/vm.js b/_server/vm.js index de416fed..c5b1286e 100644 --- a/_server/vm.js +++ b/_server/vm.js @@ -15,7 +15,7 @@ document.body.onmousedown = function(e){ if(eid.indexOf('edit')===-1){ if(eid.indexOf('tip')===-1)selectBox.isSelected = false; } - editor_mode.onmode(''); + //editor.mode.onmode(''); editor.info = {}; } iconLib.onmousedown = function(e){ @@ -198,13 +198,21 @@ var clear = new Vue({ } }) printf = function(str_,type) { + selectBox.isSelected = false; if(!type){ - tip.msgs[11]=String(str_); - tip.whichShow=12; - } else { - tip.msgs[10]=String(str_); tip.whichShow=11; + } else { + tip.whichShow=12; } + setTimeout(function(){ + if(!type){ + tip.msgs[11]=String(str_); + tip.whichShow=12; + } else { + tip.msgs[10]=String(str_); + tip.whichShow=11; + } + },1); } printe = function(str_){printf(str_,'error')} var tip = new Vue({ diff --git a/editor.html b/editor.html index 2b59da98..494ac186 100644 --- a/editor.html +++ b/editor.html @@ -23,6 +23,10 @@ +
+ + +
@@ -53,7 +57,7 @@
-

地图选点

+

地图选点  

0,0

',shortField,'',shortCommentHTMLescape,'
',editor_mode.objToTd(thiseval,comment),'
',editor_mode.objToTd(thiseval,comment),'
@@ -64,10 +68,11 @@
-

图块属性

+

图块属性  

+
@@ -80,7 +85,7 @@
-

楼层属性

+

楼层属性  

@@ -90,7 +95,7 @@
-

全塔属性

+

全塔属性  

@@ -134,7 +139,7 @@
-

脚本编辑

+

脚本编辑  

@@ -167,16 +172,15 @@

{{ mapMsg }}

- - + diff --git a/project/data.comment.js b/project/data.comment.js index 00531642..9fb6f4da 100644 --- a/project/data.comment.js +++ b/project/data.comment.js @@ -27,11 +27,11 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "money": " 初始金币 ", "experience": " 初始经验 ", "items": { - "keys": { + "keys": " 初始道具个数 \n$leaf(true)$end"/* { "yellowKey": " 初始道具个数 ", "blueKey": "", "redKey": "" - }, + } */, "constants": "\n$leaf(true)$end", "tools": "\n$leaf(true)$end" }, @@ -41,11 +41,11 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "x": "", "y": "" }, - "flags": { + "flags": " 游戏过程中的变量或flags \n$leaf(true)$end"/* { "poison": " 游戏过程中的变量或flags \n 毒 ", "weak": " 衰 ", "curse": " 咒 " - }, + } */, "steps": " 行走步数统计 ", }, "startText": " 游戏开始前剧情。如果无剧情直接留一个空数组即可。 \n$leaf(true)$end", From c9ba70fa9c24f332a527330c5967908680490c70 Mon Sep 17 00:00:00 2001 From: oc Date: Sat, 10 Mar 2018 01:09:07 +0800 Subject: [PATCH 21/23] Replay use full name --- libs/actions.js | 4 ++-- libs/control.js | 9 +++++++-- libs/events.js | 5 +++-- libs/utils.js | 49 ++++++++++++++++++++++++++----------------------- 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/libs/actions.js b/libs/actions.js index aca775d9..e93d5238 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -185,8 +185,8 @@ actions.prototype.keyDown = function(keyCode) { } ////// 根据放开键的code来执行一系列操作 ////// -actions.prototype.keyUp = function(keyCode) { - if (core.isset(core.status.replay)&&core.status.replay.replaying) return; +actions.prototype.keyUp = function(keyCode, fromReplay) { + if (!fromReplay&&core.isset(core.status.replay)&&core.status.replay.replaying) return; if (core.status.lockControl) { core.status.holdingKeys = []; diff --git a/libs/control.js b/libs/control.js index 8e7a992e..ba257bbe 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1485,7 +1485,7 @@ control.prototype.replay = function () { core.events.openShop(shopId, false); var shopInterval = setInterval(function () { - if (!core.events.clickShop(6, topIndex+core.status.event.selection)) { + if (!core.actions.clickShop(6, topIndex+core.status.event.selection)) { clearInterval(shopInterval); core.stopReplay(); core.drawTip("录像文件出错"); @@ -1493,7 +1493,7 @@ control.prototype.replay = function () { } if (selections.length==0) { clearInterval(shopInterval); - core.events.clickShop(6, topIndex+choices.length); + core.actions.clickShop(6, topIndex+choices.length); core.replay(); return; } @@ -1535,6 +1535,11 @@ control.prototype.replay = function () { return; } } + else if (action.indexOf('key:')==0) { + core.actions.keyUp(parseInt(action.substring(4)), true); + core.replay(); + return; + } core.stopReplay(); core.insertAction("录像文件出错"); diff --git a/libs/events.js b/libs/events.js index 91a81d5a..58dae299 100644 --- a/libs/events.js +++ b/libs/events.js @@ -224,9 +224,10 @@ events.prototype.doAction = function() { // 事件处理完毕 if (core.status.event.data.list.length==0) { + var callback = core.status.event.data.callback; core.ui.closePanel(); - if (core.isset(core.status.event.data.callback)) - core.status.event.data.callback(); + if (core.isset(callback)) + callback(); core.replay(); return; } diff --git a/libs/utils.js b/libs/utils.js index 5ad4a9de..56929077 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -158,8 +158,6 @@ utils.prototype.encodeRoute = function (route) { var ans=""; var lastMove = "", cnt=0; - var items=Object.keys(core.material.items).sort(); - var shops=Object.keys(core.initStatus.shops).sort(); route.forEach(function (t) { if (t=='up' || t=='down' || t=='left' || t=='right') { if (t!=lastMove && cnt>0) { @@ -177,15 +175,13 @@ utils.prototype.encodeRoute = function (route) { cnt=0; } if (t.indexOf('item:')==0) - ans+="I"+items.indexOf(t.substring(5)); + ans+="I"+t.substring(5)+":"; else if (t.indexOf('fly:')==0) - ans+="F"+core.floorIds.indexOf(t.substring(4)); + ans+="F"+t.substring(4)+":"; else if (t.indexOf('choices:')==0) ans+="C"+t.substring(8); - else if (t.indexOf('shop:')==0) { - var sp=t.substring(5).split(":"); - ans+="S"+shops.indexOf(sp[0])+":"+sp[1]; - } + else if (t.indexOf('shop:')==0) + ans+="S"+t.substring(5); else if (t=='turn') ans+='T'; else if (t=='getNext') @@ -194,9 +190,10 @@ utils.prototype.encodeRoute = function (route) { ans+="P"+t.substring(6); else if (t=='no') ans+='N'; - else if (t.indexOf('move:')==0) { + else if (t.indexOf('move:')==0) ans+="M"+t.substring(5); - } + else if (t=='key:') + ans+='K'+t.substring(4); } }); if (cnt>0) { @@ -221,27 +218,33 @@ utils.prototype.decodeRoute = function (route) { if (num.length==0) num="1"; return core.isset(noparse)?num:parseInt(num); } + var getString = function () { + var str=""; + while (index Date: Sat, 10 Mar 2018 13:27:13 +0800 Subject: [PATCH 22/23] =?UTF-8?q?editor=E5=AE=9E=E7=8E=B0$range=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E7=BB=86=E8=8A=82=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2.0diff.md | 11 +++----- _server/README.md | 17 ++++++++---- _server/editor_blockly.js | 3 +- _server/editor_mode.js | 58 +++++++++++++++++++++++---------------- project/comment.js | 4 +-- 5 files changed, 54 insertions(+), 39 deletions(-) diff --git a/2.0diff.md b/2.0diff.md index ebc3c1c3..2eb12662 100644 --- a/2.0diff.md +++ b/2.0diff.md @@ -139,14 +139,11 @@ $textarea(evalstr)$end # todo & 目前的bug + `event`,`after...`在地图上没有标记,可以在右下角加类似于无`id`的红问号类似的绿色星号小标记 -+ 添加新图块只对地形好使,添加的新物品还是需要手动在`project/items.js`中加东西 -+ 目前未做$range(evalstr:thiseval)$end的检查 ++ [x] 添加新图块只对地形好使,添加的新物品还是需要手动在`project/items.js`中加东西 ++ [x] 目前未做$range(evalstr:thiseval)$end的检查 + 通过`core.values.redJewel`的方式设置物品加的数值,在全GUI下反而会不直观 + `idnum`上限改到`999`,不需要在`.js`中手动设置`idnum`的话,根据数字范围来约定类型意义不大,而且`400`内随便输个数就发现已经被占了,体验极差 + `editor.html`中独立换背景的功能不再需要,待移除 + 全GUI下编辑要经常保存修改后F5 -+ 目前的报错只是throw,如果不开F12注意不到有错误发生,修改没有生效 -+ 有待美化,以及做成标签页式的模式切换 -+ replay模式,这个功能对于魔塔网站以及贴吧活动很有意义 - -前三条我会尽快修复(添加) \ No newline at end of file ++ [x] 目前的报错只是throw,如果不开F12注意不到有错误发生,修改没有生效 ++ [x] 有待美化,以及做成标签页式的模式切换 \ No newline at end of file diff --git a/_server/README.md b/_server/README.md index ec9d1981..e75cf35d 100644 --- a/_server/README.md +++ b/_server/README.md @@ -18,7 +18,7 @@ editor.file.loadFloorFile editor.file.saveFloorFile editor.file.saveFloorFileAs ``` -6个编辑模式有关的查询 +编辑模式有关的查询 ```javascript editor.file.editItem('redJewel',[],function(a){console.log(a)}); editor.file.editEnemy('redBat',[],function(a){console.log(a)}); @@ -27,7 +27,7 @@ editor.file.editFloor([],function(a){console.log(a)}); editor.file.editTower([],function(a){console.log(a)}); editor.file.editFunctions([],function(a){console.log(a)}); ``` -6个编辑模式有关的编辑 +编辑模式有关的编辑 ```javascript editor.info={images: "terrains", y: 9}; editor.file.changeIdAndIdnum('yellowWall2',16,editor.info,function(a){console.log(a)}); @@ -50,14 +50,19 @@ editor.mode.functions(); ``` 切换模式 ```javascript -editor.mode.onmode(''); +editor.mode.onmode('');//清空 +editor.mode.onmode('save');//保存 +editor.mode.onmode('nextChange');//下次onmode时前端进行切换 + editor.mode.onmode('loc'); editor.mode.onmode('emenyitem'); editor.mode.onmode('floor'); editor.mode.onmode('tower'); editor.mode.onmode('functions'); +editor.mode.onmode('map'); +editor.mode.onmode('appendpic'); ``` -在切换模式时,改动才会保存到文件,并且需要刷新页面使得`editor`能看到改动 +在`onmode('save')`时,改动才会保存到文件,涉及到图片的改动需要刷新页面使得`editor`能看到 表格的`onchange`的实现中,获得当前模式的方式.不注意的话,修改`index.html`中页面的结构,会被坑 ```javascript @@ -83,8 +88,8 @@ editor_blockly.confirm(); ### 待调整 -多行文本编辑器独立作为组件 -editor_multi.js ++ [x] 多行文本编辑器独立作为组件 ++ [x] editor_multi.js ## z-index diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 5348669e..86dbe348 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -312,7 +312,8 @@ editor_blockly.import = function(id_){ "['afterGetItem']":'afterGetItem', "['afterOpenDoor']":'afterOpenDoor', - "['firstData']['shops']":'shop', + //"['firstData']['shops']":'shop', + "--shop--未完成数组的处理":'shop', "['firstArrive']":'firstArrive', "['firstData']['startText']":'firstArrive', diff --git a/_server/editor_mode.js b/_server/editor_mode.js index c3f23bc9..6fffe579 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -38,11 +38,25 @@ editor_mode.prototype.init_dom_ids = function(callback){ editor_mode.prototype.objToTable = function(obj,commentObj){ var outstr=["\n
\n"]; var guids=[]; + var checkIsLeaf = function(obj,commentObj,field){ + var thiseval = eval('obj'+field); + if (thiseval == null || thiseval == undefined)return true;//null,undefined + if (typeof(thiseval) == typeof(''))return true;//字符串 + if (Object.keys(thiseval).length == 0)return true;//数字,true,false,空数组,空对象 + try { + var comment = eval('commentObj'+field); + if( comment.indexOf('$leaf') != -1){ + evalstr = comment.split('$leaf')[1].split('$end')[0]; + if(eval(evalstr) === true)return true; + } + } catch (error) {} + return false; + } //深度优先遍历 var recursionParse = function(tfield) { for(var ii in eval("obj"+tfield)){ var field = tfield+"['"+ii+"']"; - var isleaf = editor_mode.checkIsLeaf(obj,commentObj,field); + var isleaf = checkIsLeaf(obj,commentObj,field); if (isleaf) { var leafnode = editor_mode.objToTr(obj,commentObj,field); outstr.push(leafnode[0]); @@ -54,6 +68,13 @@ editor_mode.prototype.objToTable = function(obj,commentObj){ } } recursionParse(""); + var checkRange = function(comment,thiseval){ + if( comment.indexOf('$range') !== -1){ + var evalstr = comment.split('$range')[1].split('$end')[0]; + return eval(evalstr); + } + return true; + } var listen = function(guids) { guids.forEach(function(guid){ // tr>td[title=field] @@ -69,12 +90,12 @@ editor_mode.prototype.objToTable = function(obj,commentObj){ node = node.parentNode; } editor_mode.onmode(editor_mode._ids[node.getAttribute('id')]); - editor_mode.addAction(['change',field,JSON.parse(input.value)]); - //尚未完成,不完善,目前还没做$range的检查 - - // /*临时*/editor_mode.onmode('');/*临时*/ - //临时改为立刻写入文件,删去此句的时,切换模式才会真正写入 - //现阶段这样会更实用,20180218 + var thiseval = JSON.parse(input.value); + if(checkRange(comment,thiseval)){ + editor_mode.addAction(['change',field,thiseval]); + } else { + printe('输入的值不合要求,请鼠标放置在注释上查看说明'); + } } input.ondblclick = function(){ if(!editor_blockly.import(guid)) @@ -86,21 +107,6 @@ editor_mode.prototype.objToTable = function(obj,commentObj){ return {"HTML":outstr.join(''),"guids":guids,"listen":listen}; } -editor_mode.prototype.checkIsLeaf = function(obj,commentObj,field){ - var thiseval = eval('obj'+field); - if (thiseval == null || thiseval == undefined)return true;//null,undefined - if (typeof(thiseval) == typeof(''))return true;//字符串 - if (Object.keys(thiseval).length == 0)return true;//数字,true,false,空数组,空对象 - try { - var comment = eval('commentObj'+field); - if( comment.indexOf('$leaf') != -1){ - evalstr = comment.split('$leaf')[1].split('$end')[0]; - if(eval(evalstr) === true)return true; - } - } catch (error) {} - return false; -} - editor_mode.prototype.objToTr = function(obj,commentObj,field){ var guid = editor.guid(); var thiseval = eval('obj'+field); @@ -197,6 +203,12 @@ editor_mode.prototype.showMode = function (mode) { editor_mode.dom[mode].style=''; if(editor_mode[mode])editor_mode[mode](); document.getElementById('editModeSelect').value=mode; + var tips = [ + '涉及图片的更改需要F5刷新浏览器来生效', + '文本域可以通过双击,在文本编辑器或事件编辑器中编辑', + '事件编辑器中的显示文本和自定义脚本的方块也可以双击', + ]; + if(!selectBox.isSelected)printf('tips: '+tips[~~(tips.length*Math.random())]); } editor_mode.prototype.loc = function(callback){ @@ -462,7 +474,7 @@ editor_mode.prototype.listen = function(callback){ var imgbase64 = sprite.toDataURL().split(',')[1]; fs.writeFile('./project/images/'+editor_mode.appendPic.imageName+'.png',imgbase64,'base64',function(err,data){ if(err){printe(err);throw(err)} - printe('追加素材成功,请刷新编辑器'); + printe('追加素材成功,请F5刷新编辑器'); }); } diff --git a/project/comment.js b/project/comment.js index 4bf4c47e..dfd1aed8 100644 --- a/project/comment.js +++ b/project/comment.js @@ -37,13 +37,13 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "name": "显示在状态栏中的层数 ", "canFlyTo": "该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器) \n$select({\"values\":[true,false]})$end", "canUseQuickShop": "该层是否允许使用快捷商店 \n$select({\"values\":[true,false]})$end", - "defaultGround": "默认地面的图块ID(terrains中) ", + "defaultGround": "默认地面的图块ID(terrains中) \n$select({\"values\":Object.keys(editor.core.icons.icons.terrains)})$end", "png": "背景图;你可以选择一张png图片来作为背景素材。详细用法请参见文档“自定义素材”中的说明。 \n$leaf(true)$end", "color": "该层的默认画面色调。本项可不写(代表无色调),如果写需要是一个RGBA数组。 \n$leaf(true)$end", "weather": "该层的默认天气。本项可忽略表示晴天,如果写则第一项为\"rain\"或\"snow\"代表雨雪,第二项为1-10之间的数代表强度。 \n$leaf(true)$end", "bgm": "到达该层后默认播放的BGM。本项可忽略。 ", //"map": "地图数据,需要是13x13,建议使用地图生成器来生成 ", - "item_ratio": "每一层的宝石/血瓶效果,即获得宝石和血瓶时框内\"ratio\"的值。", + "item_ratio": "每一层的宝石/血瓶效果,即获得宝石和血瓶时框内\"ratio\"的值。$range((thiseval==~~thiseval && thiseval>0)||thiseval==null)$end", "firstArrive": "第一次到该楼层触发的事件 \n$leaf(true)$end", }, 'loc' : { From 15cdfa0f23555d40c7da25157ad7aa85e71c0b1c Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Sat, 10 Mar 2018 14:10:42 +0800 Subject: [PATCH 23/23] =?UTF-8?q?function=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/editor.js | 2 ++ _server/editor_file.js | 12 ++++++------ project/data.comment.js | 4 ++-- project/data.js | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/_server/editor.js b/_server/editor.js index 34903d52..515a6f73 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -23,6 +23,8 @@ editor.prototype.init = function(callback){ var afterMainInit = function(){ core.floors=JSON.parse(JSON.stringify(core.floors,function(k,v){if(v instanceof Function){return v.toString()}else return v})); + core.data=JSON.parse(JSON.stringify(core.data,function(k,v){if(v instanceof Function){return v.toString()}else return v})); + data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d=JSON.parse(JSON.stringify(data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d,function(k,v){if(v instanceof Function){return v.toString()}else return v})); editor.main=main; editor.core=core; editor.fs=fs; diff --git a/_server/editor_file.js b/_server/editor_file.js index 2667ec0c..966b3b00 100644 --- a/_server/editor_file.js +++ b/_server/editor_file.js @@ -79,7 +79,7 @@ editor_file = function(editor, callback){ } datastr=datastr.concat(['\n}']); datastr=datastr.join(''); - fs.writeFile(filename,datastr,'utf-8',function(err, data){ + fs.writeFile(filename,encode(datastr),'base64',function(err, data){ callback(err); }); } @@ -482,7 +482,7 @@ editor_file = function(editor, callback){ }); var datastr='icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = \n'; datastr+=JSON.stringify(icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1,null,4); - fs.writeFile('project/icons.js',datastr,'utf-8',function(err, data){ + fs.writeFile('project/icons.js',encode(datastr),'base64',function(err, data){ callback(err); }); return; @@ -494,7 +494,7 @@ editor_file = function(editor, callback){ }); var datastr='maps_90f36752_8815_4be8_b32b_d7fad1d0542e = \n'; datastr+=JSON.stringify(maps_90f36752_8815_4be8_b32b_d7fad1d0542e,null,4); - fs.writeFile('project/maps.js',datastr,'utf-8',function(err, data){ + fs.writeFile('project/maps.js',encode(datastr),'base64',function(err, data){ callback(err); }); return; @@ -506,7 +506,7 @@ editor_file = function(editor, callback){ }); var datastr='items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = \n'; datastr+=JSON.stringify(items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a,null,4); - fs.writeFile('project/items.js',datastr,'utf-8',function(err, data){ + fs.writeFile('project/items.js',encode(datastr),'base64',function(err, data){ callback(err); }); return; @@ -518,7 +518,7 @@ editor_file = function(editor, callback){ }); var datastr='enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 = \n'; datastr+=JSON.stringify(enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80,null,4); - fs.writeFile('project/enemys.js',datastr,'utf-8',function(err, data){ + fs.writeFile('project/enemys.js',encode(datastr),'base64',function(err, data){ callback(err); }); return; @@ -530,7 +530,7 @@ editor_file = function(editor, callback){ }); var datastr='data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = \n'; datastr+=JSON.stringify(data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d,null,4); - fs.writeFile('project/data.js',datastr,'utf-8',function(err, data){ + fs.writeFile('project/data.js',encode(datastr),'base64',function(err, data){ callback(err); }); return; diff --git a/project/data.comment.js b/project/data.comment.js index 9fb6f4da..8afb46af 100644 --- a/project/data.comment.js +++ b/project/data.comment.js @@ -102,7 +102,7 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = ] } },*/ - "levelUp": [ + "levelUp": " 经验升级所需要的数值,是一个数组 \n 第一项为初始等级,可以简单留空,也可以写name \n 每一个里面可以含有三个参数 need, name, effect \n need为所需要的经验数值,是一个正整数。请确保need所需的依次递增 \n name为该等级的名称,也可以省略代表使用系统默认值;本项将显示在状态栏中 \n effect为本次升级所执行的操作,可由若干项组成,由分号分开 \n 其中每一项写法和上面的商店完全相同,同样必须是X+=Y的形式,Y是一个表达式,同样可以使用status:xxx或item:xxx代表勇士的某项数值/道具个数 \n$leaf(true)$end"/* [ " 经验升级所需要的数值,是一个数组 \n 第一项为初始等级,可以简单留空,也可以写name \n 每一个里面可以含有三个参数 need, name, effect \n need为所需要的经验数值,是一个正整数。请确保need所需的依次递增 \n name为该等级的名称,也可以省略代表使用系统默认值;本项将显示在状态栏中 \n effect为本次升级所执行的操作,可由若干项组成,由分号分开 \n 其中每一项写法和上面的商店完全相同,同样必须是X+=Y的形式,Y是一个表达式,同样可以使用status:xxx或item:xxx代表勇士的某项数值/道具个数 \n$leaf(true)$end", { "need": "", @@ -113,7 +113,7 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "need": "", "effect": " effect也允许写一个function,代表本次升级将会执行的操作 \n 依次往下写需要的数值即可 " } - ] + ] */ }, "values": { "HPMAX": " 各种数值;一些数值可以在这里设置\n /****** 角色相关 ******/ \n HP上限;-1则无上限 ", diff --git a/project/data.js b/project/data.js index 7aefac99..52d5d324 100644 --- a/project/data.js +++ b/project/data.js @@ -134,12 +134,12 @@ data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = {"need": 20, "name": "第二级", "effect": "status:hp+=2*(status:atk+status:def);status:atk+=10;status:def+=10"}, // 先将生命提升攻防和的2倍;再将攻击+10,防御+10 - {"need": 40, "effect": `function () { + {"need": 40, "effect": function () { core.drawText("恭喜升级!"); core.status.hero.hp *= 2; core.status.hero.atk += 100; core.status.hero.def += 100; - }`}, // effect也允许写一个function,代表本次升级将会执行的操作 + }}, // effect也允许写一个function,代表本次升级将会执行的操作 // 依次往下写需要的数值即可 ]
条目注释