This commit is contained in:
ckcz123 2019-10-22 21:42:40 +08:00
parent 103f2c6415
commit fe6e331fb0
5 changed files with 79 additions and 31 deletions

View File

@ -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);

View File

@ -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",

View File

@ -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;

View File

@ -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;

View File

@ -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
}
]
},