blockly: shop
This commit is contained in:
parent
3629c8485a
commit
d4a427b477
@ -39,10 +39,34 @@ return code;
|
|||||||
|
|
||||||
//商店 事件编辑器入口之一
|
//商店 事件编辑器入口之一
|
||||||
shop_m
|
shop_m
|
||||||
|
: '全局商店列表' BGNL? Newline shoplist+
|
||||||
|
;
|
||||||
|
/* shop_m
|
||||||
|
tooltip : 全局商店列表
|
||||||
|
helpUrl : https://ckcz123.github.io/mota-js/#/event?id=%e5%85%a8%e5%b1%80%e5%95%86%e5%ba%97
|
||||||
|
var code = '['+shoplist_0+']\n';
|
||||||
|
return code;
|
||||||
|
*/
|
||||||
|
|
||||||
|
shoplist
|
||||||
|
: shopsub
|
||||||
|
| emptyshop
|
||||||
|
;
|
||||||
|
|
||||||
|
emptyshop
|
||||||
|
: Newline
|
||||||
|
;
|
||||||
|
|
||||||
|
/* emptyshop
|
||||||
|
var code = ' \n';
|
||||||
|
return code;
|
||||||
|
*/
|
||||||
|
|
||||||
|
shopsub
|
||||||
: '商店 id' IdString '标题' EvalString '图标' IdString BGNL? Newline '快捷商店栏中名称' EvalString BGNL? Newline '使用' ShopUse_List '消耗' EvalString BGNL? Newline '显示文字' EvalString BGNL? Newline shopChoices+ BEND
|
: '商店 id' IdString '标题' EvalString '图标' IdString BGNL? Newline '快捷商店栏中名称' EvalString BGNL? Newline '使用' ShopUse_List '消耗' EvalString BGNL? Newline '显示文字' EvalString BGNL? Newline shopChoices+ BEND
|
||||||
;
|
;
|
||||||
|
|
||||||
/* shop_m
|
/* shopsub
|
||||||
tooltip : 全局商店,消耗填-1表示每个选项的消耗不同,正数表示消耗数值
|
tooltip : 全局商店,消耗填-1表示每个选项的消耗不同,正数表示消耗数值
|
||||||
helpUrl : https://ckcz123.github.io/mota-js/#/event?id=%e5%85%a8%e5%b1%80%e5%95%86%e5%ba%97
|
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金币商店",null,"20+10*times*(times+1)","勇敢的武士啊, 给我${need}金币就可以:"]
|
default : ["shop1","贪婪之神","blueShop","1F金币商店",null,"20+10*times*(times+1)","勇敢的武士啊, 给我${need}金币就可以:"]
|
||||||
@ -56,7 +80,7 @@ var code = {
|
|||||||
'text': EvalString_3,
|
'text': EvalString_3,
|
||||||
'choices': 'choices_asdfefw'
|
'choices': 'choices_asdfefw'
|
||||||
}
|
}
|
||||||
code=JSON.stringify(code,null,2).split('"choices_asdfefw"').join('[\n'+shopChoices_0+']\n');
|
code=JSON.stringify(code,null,2).split('"choices_asdfefw"').join('[\n'+shopChoices_0+']\n')+',\n';
|
||||||
return code;
|
return code;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -1183,25 +1207,33 @@ ActionParser.prototype.parse = function (obj,type) {
|
|||||||
return MotaActionBlocks['point_m'].xmlText([text_choices]);
|
return MotaActionBlocks['point_m'].xmlText([text_choices]);
|
||||||
|
|
||||||
case 'shop':
|
case 'shop':
|
||||||
var text_choices = null;
|
var buildsub = function(obj,parser,next){
|
||||||
for(var ii=obj.choices.length-1,choice;choice=obj.choices[ii];ii--) {
|
var text_choices = null;
|
||||||
var text_effect = null;
|
for(var ii=obj.choices.length-1,choice;choice=obj.choices[ii];ii--) {
|
||||||
var effectList = choice.effect.split(';');
|
var text_effect = null;
|
||||||
for(var jj=effectList.length-1,effect;effect=effectList[jj];jj--) {
|
var effectList = choice.effect.split(';');
|
||||||
if(effect.split('+=').length!==2){
|
for(var jj=effectList.length-1,effect;effect=effectList[jj];jj--) {
|
||||||
throw new Error('一个商店效果中必须包含恰好一个"+="');
|
if(effect.split('+=').length!==2){
|
||||||
|
throw new Error('一个商店效果中必须包含恰好一个"+="');
|
||||||
|
}
|
||||||
|
text_effect=MotaActionBlocks['shopEffect'].xmlText([
|
||||||
|
MotaActionBlocks['idString_e'].xmlText([effect.split('+=')[0]]),
|
||||||
|
MotaActionBlocks['evalString_e'].xmlText([effect.split('+=')[1]]),
|
||||||
|
text_effect]);
|
||||||
}
|
}
|
||||||
text_effect=MotaActionBlocks['shopEffect'].xmlText([
|
text_choices=MotaActionBlocks['shopChoices'].xmlText([
|
||||||
MotaActionBlocks['idString_e'].xmlText([effect.split('+=')[0]]),
|
choice.text,choice.need||'',text_effect,text_choices]);
|
||||||
MotaActionBlocks['evalString_e'].xmlText([effect.split('+=')[1]]),
|
|
||||||
text_effect]);
|
|
||||||
}
|
}
|
||||||
text_choices=MotaActionBlocks['shopChoices'].xmlText([
|
return MotaActionBlocks['shopsub'].xmlText([
|
||||||
choice.text,choice.need||'',text_effect,text_choices]);
|
obj.id,obj.name,obj.icon,obj.textInList,obj.use,obj.need,parser.EvalString(obj.text),text_choices,next
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
return MotaActionBlocks['shop_m'].xmlText([
|
var next=null;
|
||||||
obj.id,obj.name,obj.icon,obj.textInList,obj.use,obj.need,this.EvalString(obj.text),text_choices
|
if(!obj)obj=[];
|
||||||
]);
|
while(obj.length){
|
||||||
|
next=buildsub(obj.pop(),this,next);
|
||||||
|
}
|
||||||
|
return MotaActionBlocks['shop_m'].xmlText([next]);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return MotaActionBlocks[type+'_m'].xmlText([this.parseList(obj)]);
|
return MotaActionBlocks[type+'_m'].xmlText([this.parseList(obj)]);
|
||||||
|
|||||||
@ -190,7 +190,8 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
|||||||
},
|
},
|
||||||
"shops": {
|
"shops": {
|
||||||
"_leaf": true,
|
"_leaf": true,
|
||||||
"_type": "textarea",
|
"_type": "event",
|
||||||
|
"_event": "shop",
|
||||||
"_data": "全局商店,是一个数组 \n 每一项是一个Object代表一个全局商店 \n id 为商店的唯一标识符(ID),请确保任何两个商店的id都不相同 \n name 为商店的名称(打开商店后的标题) \n icon 为商店的图标,在icons.js的npcs中定义。如blueShop可代表蓝色商店。 \n textInList 为其在快捷商店栏中显示的名称,如\"3楼金币商店\"等 \n use 为消耗的类型,是金币(money)还是经验(experience)。 \n need 是一个表达式,计算商店所需要用到的数值,可以以times作为参数。 \n text 为商店所说的话。可以用${need}表示需要的数值。\n choices 为商店的各个选项,是一个list,每一项是一个选项,里面text为显示文字,effect为选项的效果,只能用+=,分号分开。"
|
"_data": "全局商店,是一个数组 \n 每一项是一个Object代表一个全局商店 \n id 为商店的唯一标识符(ID),请确保任何两个商店的id都不相同 \n name 为商店的名称(打开商店后的标题) \n icon 为商店的图标,在icons.js的npcs中定义。如blueShop可代表蓝色商店。 \n textInList 为其在快捷商店栏中显示的名称,如\"3楼金币商店\"等 \n use 为消耗的类型,是金币(money)还是经验(experience)。 \n need 是一个表达式,计算商店所需要用到的数值,可以以times作为参数。 \n text 为商店所说的话。可以用${need}表示需要的数值。\n choices 为商店的各个选项,是一个list,每一项是一个选项,里面text为显示文字,effect为选项的效果,只能用+=,分号分开。"
|
||||||
},
|
},
|
||||||
"levelUp": {
|
"levelUp": {
|
||||||
|
|||||||
@ -29,7 +29,7 @@ editor_blockly = function () {
|
|||||||
{"type": "setValue", "name": "status:hp", "value": "status:hp+\${200*point}"},
|
{"type": "setValue", "name": "status:hp", "value": "status:hp+\${200*point}"},
|
||||||
]},
|
]},
|
||||||
]},'point'),
|
]},'point'),
|
||||||
MotaActionFunctions.actionParser.parse({
|
MotaActionFunctions.actionParser.parse([{
|
||||||
"id": "moneyShop1",
|
"id": "moneyShop1",
|
||||||
"name": "贪婪之神",
|
"name": "贪婪之神",
|
||||||
"icon": "blueShop",
|
"icon": "blueShop",
|
||||||
@ -43,7 +43,7 @@ editor_blockly = function () {
|
|||||||
{"text": "防御+4", "effect": "status:def+=4"},
|
{"text": "防御+4", "effect": "status:def+=4"},
|
||||||
{"text": "魔防+10", "effect": "status:mdef+=10"}
|
{"text": "魔防+10", "effect": "status:mdef+=10"}
|
||||||
]
|
]
|
||||||
},'shop'),
|
}],'shop'),
|
||||||
MotaActionBlocks['afterBattle_m'].xmlText(),
|
MotaActionBlocks['afterBattle_m'].xmlText(),
|
||||||
MotaActionBlocks['afterGetItem_m'].xmlText(),
|
MotaActionBlocks['afterGetItem_m'].xmlText(),
|
||||||
MotaActionBlocks['afterOpenDoor_m'].xmlText(),
|
MotaActionBlocks['afterOpenDoor_m'].xmlText(),
|
||||||
@ -427,6 +427,7 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){
|
|||||||
'autoText_s': 'EvalString_2',
|
'autoText_s': 'EvalString_2',
|
||||||
'choices_s': 'EvalString_0',
|
'choices_s': 'EvalString_0',
|
||||||
'function_s': 'RawEvalString_0',
|
'function_s': 'RawEvalString_0',
|
||||||
|
'shopsub': 'EvalString_3',
|
||||||
}
|
}
|
||||||
var f = b ? textStringDict[b.type] : null;
|
var f = b ? textStringDict[b.type] : null;
|
||||||
if (f) {
|
if (f) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user