From a6260d9edd3ae21695d826a7ef970d4818666fb4 Mon Sep 17 00:00:00 2001 From: oc Date: Tue, 11 Dec 2018 01:44:01 +0800 Subject: [PATCH] clear exp in levelUp --- _server/blockly/MotaAction.g4 | 9 +++++---- libs/events.js | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/_server/blockly/MotaAction.g4 b/_server/blockly/MotaAction.g4 index 09bde8b4..5f44aef1 100644 --- a/_server/blockly/MotaAction.g4 +++ b/_server/blockly/MotaAction.g4 @@ -50,15 +50,16 @@ return code; */; levelCase - : '需求' expression '称号' EvalString? BGNL? Newline action+ + : '需求' expression '称号' EvalString? '是否扣除经验' Bool BGNL? Newline action+ /* levelCase tooltip : 升级设定 helpUrl : https://h5mota.com/games/template/docs/#/event?id=%e7%bb%8f%e9%aa%8c%e5%8d%87%e7%ba%a7%ef%bc%88%e8%bf%9b%e9%98%b6%2f%e5%a2%83%e7%95%8c%e5%a1%94%ef%bc%89 -default : [0,"",null] +default : [0,"",false,null] colour : this.subColor -var code = '{"need": "'+expression_0+'", "title": "'+EvalString_0+'", "action": [\n'+action_0+']},\n'; +Bool_0 = Bool_0?', "clear": true':''; +var code = '{"need": "'+expression_0+'", "title": "'+EvalString_0+'"'+Bool_0+', "action": [\n'+action_0+']},\n'; return code; */; @@ -1832,7 +1833,7 @@ ActionParser.prototype.parse = function (obj,type) { var text_choices = null; for(var ii=obj.length-1,choice;choice=obj[ii];ii--) { text_choices=MotaActionBlocks['levelCase'].xmlText([ - MotaActionBlocks['evalString_e'].xmlText([choice.need]),choice.title,this.parseList(choice.action),text_choices]); + MotaActionBlocks['evalString_e'].xmlText([choice.need]),choice.title,choice.clear||false,this.parseList(choice.action),text_choices]); } return MotaActionBlocks['level_m'].xmlText([text_choices]); diff --git a/libs/events.js b/libs/events.js index 6f37b4d3..97fb8201 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1822,14 +1822,15 @@ events.prototype.checkLvUp = function () { if (!core.flags.enableLevelUp || !core.isset(core.firstData.levelUp) || core.status.hero.lv>=core.firstData.levelUp.length) return; // 计算下一个所需要的数值 - var need=core.calValue((core.firstData.levelUp[core.status.hero.lv]||{}).need); + var next = (core.firstData.levelUp[core.status.hero.lv]||{}); + var need = core.calValue(next.need); if (!core.isset(need)) return; if (core.status.hero.experience>=need) { // 升级 core.status.hero.lv++; - core.insertAction(core.firstData.levelUp[core.status.hero.lv-1].action, null, null, function() { - core.events.checkLvUp(); - }); + if (next.clear) core.status.hero.experience -= need; + core.insertAction(next.action); + this.checkLvUp(); } }