From 54b8e7e60d1a1bf9a345148f8dfc5425c590c540 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Wed, 31 Oct 2018 18:18:31 +0800 Subject: [PATCH] Quick Shops --- _server/blockly/MotaAction.g4 | 7 ++++--- _server/data.comment.js | 6 ++++++ docs/event.md | 2 ++ libs/actions.js | 18 +++++++++++++++--- libs/events.js | 14 ++++++++++---- libs/ui.js | 7 ++----- project/data.js | 3 ++- 7 files changed, 41 insertions(+), 16 deletions(-) diff --git a/_server/blockly/MotaAction.g4 b/_server/blockly/MotaAction.g4 index 3eb1d13f..add43d86 100644 --- a/_server/blockly/MotaAction.g4 +++ b/_server/blockly/MotaAction.g4 @@ -63,19 +63,20 @@ return code; */; shopsub - : '商店 id' IdString '标题' EvalString '图标' IdString BGNL? Newline '快捷商店栏中名称' EvalString '共用times' Bool BGNL? Newline '使用' ShopUse_List '消耗' EvalString BGNL? Newline '显示文字' EvalString BGNL? Newline shopChoices+ BEND + : '商店 id' IdString '标题' EvalString '图标' IdString BGNL? Newline '快捷商店栏中名称' EvalString '共用times' Bool BGNL? Newline '未开启状态则不显示在列表中' Bool BGNL? NewLine '使用' ShopUse_List '消耗' EvalString BGNL? Newline '显示文字' EvalString BGNL? Newline shopChoices+ BEND /* shopsub tooltip : 全局商店,消耗填-1表示每个选项的消耗不同,正数表示消耗数值 helpUrl : https://ckcz123.github.io/mota-js/#/event?id=%e5%85%a8%e5%b1%80%e5%95%86%e5%ba%97 -default : ["shop1","贪婪之神","blueShop","1F金币商店",false,null,"20+10*times*(times+1)","勇敢的武士啊, 给我${need}金币就可以:"] +default : ["shop1","贪婪之神","blueShop","1F金币商店",false,false,null,"20+10*times*(times+1)","勇敢的武士啊, 给我${need}金币就可以:"] var code = { 'id': IdString_0, 'name': EvalString_0, 'icon': IdString_1, 'textInList': EvalString_1, 'commonTimes': Bool_0, + 'mustEnable': Bool_1, 'use': ShopUse_List_0, 'need': EvalString_2, 'text': EvalString_3, @@ -1654,7 +1655,7 @@ ActionParser.prototype.parse = function (obj,type) { choice.text,choice.need||'',text_effect,text_choices]); } return MotaActionBlocks['shopsub'].xmlText([ - obj.id,obj.name,obj.icon,obj.textInList,obj.commonTimes,obj.use,obj.need,parser.EvalString(obj.text),text_choices,next + obj.id,obj.name,obj.icon,obj.textInList,obj.commonTimes,obj.mustEnable,obj.use,obj.need,parser.EvalString(obj.text),text_choices,next ]); } var next=null; diff --git a/_server/data.comment.js b/_server/data.comment.js index 4c7dcd92..af1c0b4b 100644 --- a/_server/data.comment.js +++ b/_server/data.comment.js @@ -606,6 +606,12 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_bool": "bool", "_data": "是否允许瞬间移动" }, + "enableDisabledShop": { + "_leaf": true, + "_type": "checkbox", + "_bool": "bool", + "_data": "是否允许查看未开启状态的快捷商店内容;如果此项为真,则对于未开启状态的商店允许查看其内容(但不能购买)" + }, } } } diff --git a/docs/event.md b/docs/event.md index 61521133..f326ae6f 100644 --- a/docs/event.md +++ b/docs/event.md @@ -1600,6 +1600,7 @@ core.insertAction([ "textInList": "1F金币商店", // 在快捷商店栏中显示的名称 "use": "money", // 商店所要使用的。只能是"money"或"experience"。 "commonTimes": true, // 是否使用全局次数 + "mustEnable": true, // 如果未开启则不显示在状态栏中 "need": "20+10*times*(times+1)", // 商店需要的金币/经验数值;可以是一个表达式,以times作为参数计算。 // 这里用到的times为该商店的已经的访问次数。首次访问该商店时times的值为0。 // 上面的例子是50层商店的计算公式。你也可以写任意其他的计算公式,只要以times作为参数即可。 @@ -1648,6 +1649,7 @@ core.insertAction([ - textInList 为其在快捷商店栏中显示的名称,如"3楼金币商店"等 - use 为消耗的类型,是金币(money)还是经验(experience)。 - commonTimes 是否使用全局次数;如果为true则可以多个快捷商店共享相同的次数 +- mustEnable 是否必须是只在开启状态才在列表显示;如果此项为true则未开启的快捷商店不予显示 - need 是一个表达式,计算商店所需要用到的数值。 - 可以将times作为参数,times为该商店已经访问过的次数,第一次访问时times是0。 - 如果对于每个选项都需要不同的数值,这里设为"-1";可参见下面经验商店的例子。 diff --git a/libs/actions.js b/libs/actions.js index add9551f..7c5d595a 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -1028,6 +1028,18 @@ actions.prototype.clickShop = function(x,y) { var topIndex = 6 - parseInt(choices.length / 2); if (y>=topIndex && y= 5 && x <= 7) { var topIndex = 6 - parseInt(keys.length / 2); if (y>=topIndex && y