From ca1c5a00ece2573afc287eede9adee9408316cd6 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Tue, 30 Oct 2018 14:39:15 +0800 Subject: [PATCH] QuickShop common times --- _server/blockly/MotaAction.g4 | 7 ++++--- libs/actions.js | 2 ++ libs/events.js | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/_server/blockly/MotaAction.g4 b/_server/blockly/MotaAction.g4 index 18cd0c30..892bd536 100644 --- a/_server/blockly/MotaAction.g4 +++ b/_server/blockly/MotaAction.g4 @@ -63,18 +63,19 @@ return code; */; shopsub - : '商店 id' IdString '标题' EvalString '图标' IdString BGNL? Newline '快捷商店栏中名称' EvalString BGNL? Newline '使用' ShopUse_List '消耗' EvalString BGNL? Newline '显示文字' EvalString BGNL? Newline shopChoices+ BEND + : '商店 id' IdString '标题' EvalString '图标' IdString BGNL? Newline '快捷商店栏中名称' EvalString '共用times' 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金币商店",null,"20+10*times*(times+1)","勇敢的武士啊, 给我${need}金币就可以:"] +default : ["shop1","贪婪之神","blueShop","1F金币商店",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, 'use': ShopUse_List_0, 'need': EvalString_2, 'text': EvalString_3, @@ -1638,7 +1639,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.use,obj.need,parser.EvalString(obj.text),text_choices,next + obj.id,obj.name,obj.icon,obj.textInList,obj.commonTimes,obj.use,obj.need,parser.EvalString(obj.text),text_choices,next ]); } var next=null; diff --git a/libs/actions.js b/libs/actions.js index a2af8038..9c70ab75 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -1056,6 +1056,8 @@ actions.prototype.clickShop = function(x,y) { }); core.updateStatusBar(); shop.times++; + if (shop.commonTimes) + core.setFlag('commonTimes', shop.times); core.events.openShop(core.status.event.data.id); } // 离开 diff --git a/libs/events.js b/libs/events.js index 56907f27..73397f40 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1532,6 +1532,8 @@ events.prototype.vibrate = function(time, callback) { events.prototype.openShop = function(shopId, needVisited) { var shop = core.status.shops[shopId]; shop.times = shop.times || 0; + if (shop.commonTimes) + shop.times = core.getFlag('commonTimes', 0); shop.visited = shop.visited || false; if (needVisited && !shop.visited) { if (shop.times==0) core.drawTip("该商店尚未开启");