diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 9cf927f7..c5fe82ce 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -86,6 +86,7 @@ return code; shoplist : shopsub + | shopitem | shopcommonevent | emptyshop ; @@ -100,7 +101,7 @@ return code; */; shopcommonevent - : '商店 id' IdString '快捷商店栏中名称' EvalString BGNL? '未开启状态则不显示在列表中' Bool BGNL? '执行的公共事件 id' EvalString '参数列表' EvalString? + : '公共事件版商店 id' IdString '快捷商店栏中名称' EvalString BGNL? '未开启状态则不显示在列表中' Bool BGNL? '执行的公共事件 id' EvalString '参数列表' EvalString? /* shopcommonevent tooltip : 全局商店, 执行一个公共事件 @@ -177,6 +178,40 @@ var code = idString_e_0+'+='+expression_0+';' return code; */; +shopitem + : '道具商店 id' IdString '快捷商店栏中名称' EvalString BGNL? '未开启状态则不显示在列表中' Bool BGNL? Newline shopItemChoices+ BEND + + +/* shopitem +tooltip : 道具商店 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=%e5%85%a8%e5%b1%80%e5%95%86%e5%ba%97 +default : ["itemShop","道具商店",false] +var code = { + 'id': IdString_0, + 'item': true, + 'textInList': EvalString_0, + 'mustEnable': Bool_0, + 'choices': 'choices_aqwedsa' +} +code=JSON.stringify(code,null,2).split('"choices_aqwedsa"').join('[\n'+shopItemChoices_0+']\n')+',\n'; +return code; +*/; + +shopItemChoices + : '道具商店选项' '道具名' IdString '存量' Int '买入价格' Int '卖出价格' EvalString? BEND + + + +/* shopItemChoices +tooltip : 道具商店选项,每一项是道具名;卖出价格可不填代表不可卖出 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=%e5%85%a8%e5%b1%80%e5%95%86%e5%ba%97 +default : ["yellowKey","10","10",""] +colour : this.subColor +EvalString_0 = EvalString_0 ? (', "sell": '+(parseInt(EvalString_0) || 0)) : ''; +var code = '{"id": "' + IdString_0 + '", "number": ' + Int_0 + ', "money": ' + Int_1 + EvalString_0 + '},\n'; +return code; +*/; + //afterBattle 事件编辑器入口之一 afterBattle_m : '战斗结束后' BGNL? Newline action+ BEND @@ -2840,11 +2875,25 @@ ActionParser.prototype.parse = function (obj,type) { obj.id,parser.EvalString(obj.textInList),obj.mustEnable,parser.EvalString(obj.commonEvent),obj.args,next ]); } + var builditem = function (obj,parser,next){ + var text_choices = null; + for(var ii=obj.choices.length-1,choice;choice=obj.choices[ii];ii--) { + text_choices = MotaActionBlocks['shopItemChoices'].xmlText([ + choice.id, choice.count, choice.money, choice.sell == null ? "" : (""+choice.sell), + text_choices + ]); + } + return MotaActionBlocks['shopitem'].xmlText([ + obj.id,obj.textInList,obj.mustEnable,text_choices,next + ]); + } var next=null; if(!obj)obj=[]; while(obj.length){ var shopobj=obj.pop() - if(shopobj.choices) + if(shopobj.item) + next=builditem(shopobj,this,next); + else if(shopobj.choices) next=buildsub(shopobj,this,next); else if(shopobj.commonEvent) next=buildcommentevent(shopobj,this,next); diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 5cbf447a..ec338257 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -48,8 +48,13 @@ editor_blockly = function () { "choices": [ {"text": "生命+800", "effect": "status:hp+=800"}, {"text": "攻击+4", "effect": "status:atk+=4"}, - {"text": "防御+4", "effect": "status:def+=4"}, - {"text": "魔防+10", "effect": "status:mdef+=10"} + ] + },{ + "id": "itemShop", + "item": true, + "textInList": "道具商店", + "choices": [ + {"id": "yellowKey", "count": 10, "money": 10} ] },{ "id": "keyShop1", diff --git a/libs/control.js b/libs/control.js index d9d22fee..d1a07b25 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1473,8 +1473,8 @@ control.prototype._replayAction_shop = function (action) { if (selections.length == 0) return false; var shop=core.status.shops[shopId]; if (!shop || !shop.visited) return false; - // --- 判定commonEvent - if (shop.commonEvent) { + // --- 判定commonEvent或item + if (shop.commonEvent || shop.item) { core.openShop(shopId, false); setTimeout(core.replay); return true; diff --git a/libs/events.js b/libs/events.js index f65c5059..6da95c4b 100644 --- a/libs/events.js +++ b/libs/events.js @@ -2469,7 +2469,7 @@ events.prototype.openShop = function (shopId, needVisited) { shop.times = shop.times || 0; if (shop.commonTimes) shop.times = core.getFlag('commonTimes', 0); if (needVisited && !shop.visited) { - if (!core.flags.enableDisabledShop || shop.commonEvent) { + if (!core.flags.enableDisabledShop || shop.commonEvent || shop.item) { if (shop.times == 0) core.drawTip("该项尚未开启"); else core.drawTip("该项已失效"); core.ui.closePanel(); @@ -2481,8 +2481,11 @@ events.prototype.openShop = function (shopId, needVisited) { } else shop.visited = true; - // --- 商店 - if (shop.commonEvent) { + if (shop.item) { + core.status.route.push("shop:" + shopId + ":0"); + core.insertAction({"type": "insert", "name": "道具商店", "args": [shopId]}); + return; + } else if (shop.commonEvent) { core.status.route.push("shop:"+shopId+":0"); core.insertAction({"type": "insert", "name": shop.commonEvent, "args": shop.args}); return; diff --git a/project/data.js b/project/data.js index 247584ff..bd395304 100644 --- a/project/data.js +++ b/project/data.js @@ -266,18 +266,6 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = { "text": "生命+800", "effect": "status:hp+=800" - }, - { - "text": "攻击+4", - "effect": "status:atk+=4" - }, - { - "text": "防御+4", - "effect": "status:def+=4" - }, - { - "text": "魔防+10", - "effect": "status:mdef+=10" } ] }, @@ -295,17 +283,20 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = { "text": "等级+1", "need": "100", - "effect": "status:lv+=1;status:hp+=1000;status:atk+=7;status:def+=7" - }, + "effect": "status:hp+=1000" + } + ] + }, + { + "id": "itemShop", + "item": true, + "textInList": "道具商店", + "mustEnable": false, + "choices": [ { - "text": "攻击+5", - "need": "30", - "effect": "status:atk+=5" - }, - { - "text": "防御+5", - "need": "30", - "effect": "status:def+=5" + "id": "yellowKey", + "number": 10, + "money": 10 } ] },