dynamic choices & startReaply save & global flag

This commit is contained in:
oc 2019-07-05 23:20:25 +08:00
parent 0e877bd1b9
commit 5d279e375d
7 changed files with 39 additions and 11 deletions

View File

@ -1,4 +1,4 @@
附录API列表V2.6版)
附录API列表V2.6.3版)
这里将列出所有被转发到core的API没有被转发的函数此处不会列出请自行在代码中查看。

View File

@ -1716,13 +1716,13 @@ return code;
*/;
choicesContext
: '子选项' EvalString '图标' IdString? '颜色' EvalString? Colour BGNL? Newline action+
: '子选项' EvalString '图标' IdString? '颜色' EvalString? Colour '出现条件' EvalString? BGNL? Newline action+
/* choicesContext
tooltip : 选项的选择
helpUrl : https://h5mota.com/games/template/_docs/#/event?id=choices%EF%BC%9A%E7%BB%99%E7%94%A8%E6%88%B7%E6%8F%90%E4%BE%9B%E9%80%89%E9%A1%B9
default : ["提示文字:红钥匙","",""]
default : ["提示文字:红钥匙","","",""]
colour : this.subColor
if (EvalString_1) {
var colorRe = MotaActionFunctions.pattern.colorRe;
@ -1731,8 +1731,9 @@ if (EvalString_1) {
else
EvalString_1 = ', "color": "'+EvalString_1+'"';
}
EvalString_2 = EvalString_2 && (', "condition": "'+EvalString_2+'"')
IdString_0 = IdString_0?(', "icon": "'+IdString_0+'"'):'';
var code = '{"text": "'+EvalString_0+'"'+IdString_0+EvalString_1+', "action": [\n'+action_0+']},\n';
var code = '{"text": "'+EvalString_0+'"'+IdString_0+EvalString_1+EvalString_2+', "action": [\n'+action_0+']},\n';
return code;
*/;
@ -3169,7 +3170,7 @@ ActionParser.prototype.parseAction = function() {
for(var ii=data.choices.length-1,choice;choice=data.choices[ii];ii--) {
choice.color = this.Colour(choice.color);
text_choices=MotaActionBlocks['choicesContext'].xmlText([
choice.text,choice.icon,choice.color,'rgba('+choice.color+')',this.insertActionList(choice.action),text_choices]);
choice.text,choice.icon,choice.color,'rgba('+choice.color+')',choice.condition||'',this.insertActionList(choice.action),text_choices]);
}
if (!this.isset(data.text)) data.text = '';
var info = this.getTitleAndPosition(data.text);

View File

@ -76,9 +76,9 @@ editor_blockly = function () {
MotaActionBlocks['confirm_s'].xmlText(),
MotaActionBlocks['choices_s'].xmlText([
'选择剑或者盾','流浪者','man',MotaActionBlocks['choicesContext'].xmlText([
'剑','','',null,MotaActionFunctions.actionParser.parseList([{"type": "openDoor", "loc": [3,3]}]),
'剑','','',null,'',MotaActionFunctions.actionParser.parseList([{"type": "openDoor", "loc": [3,3]}]),
MotaActionBlocks['choicesContext'].xmlText([
'盾','','',null,MotaActionFunctions.actionParser.parseList([{"type": "openDoor", "loc": [9,3]}]),
'盾','','',null,'',MotaActionFunctions.actionParser.parseList([{"type": "openDoor", "loc": [9,3]}]),
])
])
]),

View File

@ -1317,7 +1317,7 @@ control.prototype._replay_finished = function () {
control.prototype._replay_save = function () {
core.status.replay.steps++;
if (core.status.replay.steps%50==0) {
if (core.status.replay.steps%40==1) {
if (core.status.replay.save.length == 30)
core.status.replay.save.shift();
core.status.replay.save.push({"data": core.saveData(), "replay": {

View File

@ -458,6 +458,24 @@ events.prototype.getItem = function (id, num, x, y, callback) {
if (num > 1) text += "x" + num;
if (itemCls === 'items') text += core.items.getItemEffectTip(id);
core.drawTip(text, id);
// --- 首次获得道具的提示
if (!core.hasFlag("__itemHint__")) core.setFlag("__itemHint__", []);
var itemHint = core.getFlag("__itemHint__");
if (itemHint.indexOf(id) < 0 && itemCls != 'items') {
var hint = core.material.items[id].text || "该道具暂无描述";
try {
hint = core.replaceText(hint);
} catch (e) {}
core.insertAction("\t["+core.material.items[id].name+","+id+"]" + hint + "\n"
+ (itemCls == 'keys' || id == 'greenKey' || id == 'steelKey' ? "(钥匙类道具,遇到对应的门时自动打开)"
: itemCls == 'tools' ? "消耗类道具请按T在道具栏使用"
: itemCls == 'constants' ? "永久类道具请按T在道具栏使用"
: itemCls == 'equips' ? "装备类道具请按Q在装备栏进行装备" : ""))
itemHint.push(id);
}
core.updateStatusBar();
this.afterGetItem(id, x, y, callback);
@ -1385,6 +1403,11 @@ events.prototype._action_switch = function (data, x, y, prefix) {
}
events.prototype._action_choices = function (data, x, y, prefix) {
data.choices = data.choices.filter(function (x) {
if (x.condition == null || x.condition == '') return true;
try { return core.calValue(x.condition, prefix); } catch (e) { return true; }
})
if (data.choices.length == 0) return this.doAction();
if (core.isReplaying()) {
var action = core.status.replay.toReplay.shift(), index;
// --- 忽略可能的turn事件

View File

@ -15,6 +15,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
core.status.played = true;
// 初始化人物,图标,统计信息
core.status.hero = core.clone(hero);
window.flags = core.status.hero.flags;
core.events.setHeroIcon(core.getFlag('heroIcon', 'hero.png'), true);
core.control._initStatistics(core.animateFrame.totalTime);
core.status.hero.statistics.totalTime = core.animateFrame.totalTime =

View File

@ -3,15 +3,18 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"items": {
"yellowKey": {
"cls": "keys",
"name": "黄钥匙"
"name": "黄钥匙",
"text": "可以打开一扇黄门"
},
"blueKey": {
"cls": "keys",
"name": "蓝钥匙"
"name": "蓝钥匙",
"text": "可以打开一扇蓝门"
},
"redKey": {
"cls": "keys",
"name": "红钥匙"
"name": "红钥匙",
"text": "可以打开一扇红门"
},
"redJewel": {
"cls": "items",