From 1f221a16000b549f5d9da43d27db467de7806554 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Thu, 15 Mar 2018 16:25:16 +0800 Subject: [PATCH] =?UTF-8?q?editor=E4=B8=AD=E6=98=BE=E7=A4=BAuseItem?= =?UTF-8?q?=E5=92=8CcanUseItem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/editor_file.js | 50 +++++++++++++++++++++++++++--------------- libs/items.js | 4 ++-- project/comment.js | 4 ++-- project/items.js | 4 ++-- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/_server/editor_file.js b/_server/editor_file.js index 30916699..86629fe3 100644 --- a/_server/editor_file.js +++ b/_server/editor_file.js @@ -174,33 +174,47 @@ editor_file = function(editor, callback){ }); saveSetting('items',actionList,function (err) { callback([ - {'items':(function(){ - var locObj=Object.assign({},editor.core.items.items[id]); - Object.keys(editor_file.comment.items.items).forEach(function(v){ - if (!isset(editor.core.items.items[id][v])) - /* locObj[v]=editor.core.items.items[id][v]; - else */ - locObj[v]=null; + (function(){ + var locObj_ ={}; + Object.keys(editor_file.comment.items).forEach(function(v){ + if (isset(editor.core.items[v][id]) && v!=='items') + locObj_[v]=editor.core.items[v][id]; + else + locObj_[v]=null; }); - return locObj; + locObj_['items']=(function(){ + var locObj=Object.assign({},editor.core.items.items[id]); + Object.keys(editor_file.comment.items.items).forEach(function(v){ + if (!isset(editor.core.items.items[id][v])) + locObj[v]=null; + }); + return locObj; + })(); + return locObj_; })(), - 'itemEffect':editor.core.items.itemEffect[id],'itemEffectTip':editor.core.items.itemEffectTip[id]}, editor_file.comment.items, err]); }); } else { callback([ - {'items':(function(){ - var locObj=Object.assign({},editor.core.items.items[id]); - Object.keys(editor_file.comment.items.items).forEach(function(v){ - if (!isset(editor.core.items.items[id][v])) - /* locObj[v]=editor.core.items.items[id][v]; - else */ - locObj[v]=null; + (function(){ + var locObj_ ={}; + Object.keys(editor_file.comment.items).forEach(function(v){ + if (isset(editor.core.items[v][id]) && v!=='items') + locObj_[v]=editor.core.items[v][id]; + else + locObj_[v]=null; }); - return locObj; + locObj_['items']=(function(){ + var locObj=Object.assign({},editor.core.items.items[id]); + Object.keys(editor_file.comment.items.items).forEach(function(v){ + if (!isset(editor.core.items.items[id][v])) + locObj[v]=null; + }); + return locObj; + })(); + return locObj_; })(), - 'itemEffect':editor.core.items.itemEffect[id],'itemEffectTip':editor.core.items.itemEffectTip[id]}, editor_file.comment.items, null]); } diff --git a/libs/items.js b/libs/items.js index 55462352..9f6d05b5 100644 --- a/libs/items.js +++ b/libs/items.js @@ -7,8 +7,8 @@ items.prototype.init = function () { this.items = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.items; this.itemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.itemEffect; this.itemEffectTip = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.itemEffectTip; - this.useItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.useItem; - this.canUseItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canUseItem; + this.useItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.useItemEffect; + this.canUseItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canUseItemEffect; //delete(items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a); } diff --git a/project/comment.js b/project/comment.js index 9eabe777..908a7c6e 100644 --- a/project/comment.js +++ b/project/comment.js @@ -9,8 +9,8 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc = }, 'itemEffect':'cls为items的即捡即用类物品的效果,执行时会对这里的字符串执行eval()', 'itemEffectTip':'cls为items的即捡即用类物品,在获得时左上角额外显示的文字,执行时会对这里的字符串执行eval()得到字符串', - 'useItem':'cls为tools或contants时的使用物品效果,执行时会对这里的字符串执行eval()', - 'canUseItem':'cls为tools或contants时能否使用物品的判断,执行时会return这里的字符串执行eval()后的结果', + 'useItemEffect':'cls为tools或contants时的使用物品效果,执行时会对这里的字符串执行eval()', + 'canUseItemEffect':'cls为tools或contants时能否使用物品的判断,执行时会return这里的字符串执行eval()后的结果', }, "items_template" : {'cls': 'items', 'name': '新物品'}, "enemys" : { diff --git a/project/items.js b/project/items.js index 0580c610..c04b1fe8 100644 --- a/project/items.js +++ b/project/items.js @@ -114,7 +114,7 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "moneyPocket":"',金币+'+core.values.moneyPocket", }, -"useItem": { +"useItemEffect": { "book": "core.ui.drawBook(0);", "fly": "core.ui.drawFly(core.status.hero.flyRange.indexOf(core.status.floorId));", "earthquake": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});", @@ -145,7 +145,7 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "shield5": "core.plugin.useEquipment(itemId)", }, -"canUseItem": { +"canUseItemEffect": { "book": "true", "fly": "core.status.hero.flyRange.indexOf(core.status.floorId)>=0", "pickaxe": "var able=false;\nvar ids = [];\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) &&\n (block.event.id == 'yellowWall' || block.event.id=='whiteWall' || block.event.id=='blueWall')) // 能破哪些墙\n {\n // 四个方向\n if (core.flags.pickaxeFourDirections) {\n if (Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {\n ids.push(i);\n }\n }\n else {\n if (block.x == core.nextX() && block.y == core.nextY()) {\n ids.push(i);\n }\n }\n }\n}\nif (ids.length>0) {\n core.status.event.data = ids;\n able=true;\n}\nable",