From 3e380365610d4b3246783da917fcf91f2dcfa6a5 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Mon, 28 Oct 2019 10:57:25 +0800 Subject: [PATCH] itemShop --- _server/MotaAction.g4 | 13 +++++++------ project/plugins.js | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index b2069c62..6a6bd555 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -198,21 +198,22 @@ return code; */; shopItemChoices - : '道具商店选项' '道具名' IdString '存量' EvalString? '买入价格' EvalString? '卖出价格' EvalString? BEND + : '道具名' IdString '存量' EvalString? '买入价格' EvalString? '卖出价格' EvalString? '出现条件' 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",""] +default : ["yellowKey","","10","",""] colour : this.subColor if (EvalString_0 && !/^\d+$/.test(EvalString_0)) throw "存量必须不填或非负整数"; EvalString_0 = EvalString_0 ? (', "number": '+EvalString_0) : ''; -EvalString_1 = EvalString_1 ? (', "money": "'+EvalString_1+'"') : ''; -EvalString_2 = EvalString_2 ? (', "sell": "'+EvalString_2+'"') : ''; +EvalString_1 = EvalString_1 ? (', "money": "'+EvalString_1+'"') : ''; +EvalString_2 = EvalString_2 ? (', "sell": "'+EvalString_2+'"') : ''; if (!EvalString_1 && !EvalString_2) throw "买入金额和卖出金额至少需要填写一个"; -var code = '{"id": "' + IdString_0 + '"' + EvalString_0 + EvalString_1 + EvalString_2 + '},\n'; +EvalString_3 = EvalString_3 ? (', "condition": "'+EvalString_3+'"') : ''; +var code = '{"id": "' + IdString_0 + '"' + EvalString_0 + EvalString_1 + EvalString_2 + EvalString_3 + '},\n'; return code; */; @@ -2884,7 +2885,7 @@ ActionParser.prototype.parse = function (obj,type) { for(var ii=obj.choices.length-1,choice;choice=obj.choices[ii];ii--) { text_choices = MotaActionBlocks['shopItemChoices'].xmlText([ choice.id, choice.number == null ? "" : (""+choice.number), choice.money == null ? "" : (""+choice.money), - choice.sell == null ? "" : (""+choice.sell), text_choices + choice.sell == null ? "" : (""+choice.sell), choice.condition || "", text_choices ]); } return MotaActionBlocks['shopitem'].xmlText([ diff --git a/project/plugins.js b/project/plugins.js index e8de6f9f..232bbaae 100644 --- a/project/plugins.js +++ b/project/plugins.js @@ -138,6 +138,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = // Step 2:获得列表并展示 var choices = core.status.shops[shopId].choices; list = choices.filter(function (one) { + if (one.condition != null) { + try { if (!core.calValue(one.condition)) return false; } catch (e) {} + } return (type == 0 && one.money != null) || (type == 1 && one.sell != null); }); var per_page = 6;