Quick Shops

This commit is contained in:
ckcz123 2018-10-31 18:18:31 +08:00
parent d98a21f7f9
commit 54b8e7e60d
7 changed files with 41 additions and 16 deletions

View File

@ -63,19 +63,20 @@ return code;
*/;
shopsub
: '商店 id' IdString '标题' EvalString '图标' IdString BGNL? Newline '快捷商店栏中名称' EvalString '共用times' Bool BGNL? Newline '使用' ShopUse_List '消耗' EvalString BGNL? Newline '显示文字' EvalString BGNL? Newline shopChoices+ BEND
: '商店 id' IdString '标题' EvalString '图标' IdString BGNL? Newline '快捷商店栏中名称' EvalString '共用times' Bool BGNL? Newline '未开启状态则不显示在列表中' 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金币商店",false,null,"20+10*times*(times+1)","勇敢的武士啊, 给我${need}金币就可以:"]
default : ["shop1","贪婪之神","blueShop","1F金币商店",false,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,
'mustEnable': Bool_1,
'use': ShopUse_List_0,
'need': EvalString_2,
'text': EvalString_3,
@ -1654,7 +1655,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.commonTimes,obj.use,obj.need,parser.EvalString(obj.text),text_choices,next
obj.id,obj.name,obj.icon,obj.textInList,obj.commonTimes,obj.mustEnable,obj.use,obj.need,parser.EvalString(obj.text),text_choices,next
]);
}
var next=null;

View File

@ -606,6 +606,12 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
"_bool": "bool",
"_data": "是否允许瞬间移动"
},
"enableDisabledShop": {
"_leaf": true,
"_type": "checkbox",
"_bool": "bool",
"_data": "是否允许查看未开启状态的快捷商店内容;如果此项为真,则对于未开启状态的商店允许查看其内容(但不能购买)"
},
}
}
}

View File

@ -1600,6 +1600,7 @@ core.insertAction([
"textInList": "1F金币商店", // 在快捷商店栏中显示的名称
"use": "money", // 商店所要使用的。只能是"money"或"experience"。
"commonTimes": true, // 是否使用全局次数
"mustEnable": true, // 如果未开启则不显示在状态栏中
"need": "20+10*times*(times+1)", // 商店需要的金币/经验数值可以是一个表达式以times作为参数计算。
// 这里用到的times为该商店的已经的访问次数。首次访问该商店时times的值为0。
// 上面的例子是50层商店的计算公式。你也可以写任意其他的计算公式只要以times作为参数即可。
@ -1648,6 +1649,7 @@ core.insertAction([
- textInList 为其在快捷商店栏中显示的名称,如"3楼金币商店"等
- use 为消耗的类型是金币money还是经验experience
- commonTimes 是否使用全局次数如果为true则可以多个快捷商店共享相同的次数
- mustEnable 是否必须是只在开启状态才在列表显示如果此项为true则未开启的快捷商店不予显示
- need 是一个表达式,计算商店所需要用到的数值。
- 可以将times作为参数times为该商店已经访问过的次数第一次访问时times是0。
- 如果对于每个选项都需要不同的数值,这里设为"-1";可参见下面经验商店的例子。

View File

@ -1028,6 +1028,18 @@ actions.prototype.clickShop = function(x,y) {
var topIndex = 6 - parseInt(choices.length / 2);
if (y>=topIndex && y<topIndex+choices.length) {
// 检查能否使用快捷商店
var reason = core.events.canUseQuickShop(shop.id);
if (core.isset(reason)) {
core.drawText(reason);
return false;
}
if (!shop.visited) {
if (shop.times==0) core.drawTip("该商店尚未开启");
else core.drawTip("该商店已失效");
return;
}
core.status.event.selection=y-topIndex;
var money = core.getStatus('money'), experience = core.getStatus('experience');
@ -1117,12 +1129,12 @@ actions.prototype.keyUpShop = function (keycode) {
////// 快捷商店界面时的点击操作 //////
actions.prototype.clickQuickShop = function(x, y) {
var shopList = core.status.shops, keys = Object.keys(shopList);
var shopList = core.status.shops, keys = Object.keys(shopList).filter(function (shopId) {return shopList[shopId].visited || !shopList[shopId].mustEnable});
if (x >= 5 && x <= 7) {
var topIndex = 6 - parseInt(keys.length / 2);
if (y>=topIndex && y<topIndex+keys.length) {
var reason = core.events.canUseQuickShop(keys[y - topIndex]);
if (core.isset(reason)) {
if (!core.flags.enableDisabledShop && core.isset(reason)) {
core.drawText(reason);
return;
}
@ -1154,7 +1166,7 @@ actions.prototype.keyUpQuickShop = function (keycode) {
core.ui.closePanel();
return;
}
var shopList = core.status.shops, keys = Object.keys(shopList);
var shopList = core.status.shops, keys = Object.keys(shopList).filter(function (shopId) {return shopList[shopId].visited || !shopList[shopId].mustEnable});
if (keycode==13 || keycode==32 || keycode==67) {
var topIndex = 6 - parseInt(keys.length / 2);
this.clickQuickShop(6, topIndex+core.status.event.selection);

View File

@ -1588,12 +1588,18 @@ events.prototype.openShop = function(shopId, needVisited) {
if (shop.commonTimes)
shop.times = core.getFlag('commonTimes', 0);
shop.visited = shop.visited || false;
if (needVisited && !shop.visited) {
if (shop.times==0) core.drawTip("该商店尚未开启");
else core.drawTip("该商店已失效");
return;
if (!core.flags.enableDisabledShop) {
if (shop.times==0) core.drawTip("该商店尚未开启");
else core.drawTip("该商店已失效");
return;
}
else {
core.drawTip("该商店尚未开启,只能浏览不可使用");
}
}
shop.visited = true;
else shop.visited = true;
var selection = core.status.event.selection;
var actions = [];

View File

@ -845,12 +845,9 @@ ui.prototype.drawQuickShop = function () {
core.status.event.id = 'selectShop';
var shopList = core.status.shops, keys = Object.keys(shopList);
var shopList = core.status.shops, keys = Object.keys(shopList).filter(function (shopId) {return shopList[shopId].visited || !shopList[shopId].mustEnable});
var choices = keys.map(function (shopId) {return shopList[shopId].textInList});
var choices = [];
for (var i=0;i<keys.length;i++) {
choices.push(shopList[keys[i]].textInList);
}
choices.push("返回游戏");
this.drawChoices(null, choices);
}

View File

@ -231,6 +231,7 @@ data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"potionWhileRouting": false,
"portalWithoutTrigger": true,
"canGoDeadZone": false,
"enableMoveDirectly": true
"enableMoveDirectly": true,
"enableDisabledShop": true
}
}