Merge remote-tracking branch 'refs/remotes/ckcz123/v2.0' into events

This commit is contained in:
YouWei Zhao 2019-03-30 09:29:13 -04:00
commit 3568fc11b7
19 changed files with 427 additions and 274 deletions

View File

@ -682,6 +682,12 @@ revisit常常使用在一些商人之类的地方当用户购买物品后不
]
```
### addToList将本公共事件插入到快捷列表中
使用 `{"type": "addToList"}` 可以将当前公共事件插入到快捷商店列表中。
此项只能在公共事件中被执行。详见[公共事件](personalization#公共事件)。
### setBlock设置某个图块
我们可以采用 `{"type": "setBlock"}` 来改变某个地图块。

View File

@ -240,6 +240,7 @@ action
| insert_2_s
| revisit_s
| exit_s
| addToList_s
| setBlock_s
| showFloorImg_s
| hideFloorImg_s
@ -693,6 +694,18 @@ var code = '{"type": "exit"},\n';
return code;
*/;
addToList_s
: '将本公共事件插入到快捷列表中' Newline
/* addToList_s
tooltip : addToList: 将本公共事件插入到快捷列表中
helpUrl : https://h5mota.com/games/template/docs/#/event?id=exit%EF%BC%9A%E7%AB%8B%E5%88%BB%E7%BB%93%E6%9D%9F%E5%BD%93%E5%89%8D%E4%BA%8B%E4%BB%B6
colour : this.eventColor
var code = '{"type": "addToList"},\n';
return code;
*/;
setBlock_s
: '转变图块为' Int 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline
@ -2604,6 +2617,10 @@ ActionParser.prototype.parseAction = function() {
this.next = MotaActionBlocks['exit_s'].xmlText([
this.next]);
break;
case "addToList": // 立刻结束事件
this.next = MotaActionBlocks['addToList_s'].xmlText([
this.next]);
break;
case "animateImage": // 兼容 animateImage
break;
default:

View File

@ -660,6 +660,12 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
"_bool": "bool",
"_data": "是否在经过领域/夹击/路障等伤害后禁用快捷商店。"
},
"quickCommonEvents": {
"_leaf": true,
"_type": "checkbox",
"_bool": "bool",
"_data": "是否使用自定义的公共事件列表来代替快捷商店列表。\n如果此项开启则快捷商店列表中将会显示加入的公共事件。"
},
"checkConsole": {
"_leaf": true,
"_type": "checkbox",

View File

@ -123,6 +123,7 @@ editor_blockly = function () {
MotaActionBlocks['hideBgFgMap_s'].xmlText(),
MotaActionBlocks['trigger_s'].xmlText(),
MotaActionBlocks['insert_1_s'].xmlText(),
MotaActionBlocks['addToList_s'].xmlText(),
MotaActionBlocks['insert_2_s'].xmlText(),
MotaActionBlocks['move_s'].xmlText(),
MotaActionBlocks['jump_s'].xmlText(),

View File

@ -1198,20 +1198,35 @@ actions.prototype._keyUpShop = function (keycode) {
////// 快捷商店界面时的点击操作 //////
actions.prototype._clickQuickShop = function (x, y) {
var shopList = core.status.shops, keys = Object.keys(shopList).filter(function (shopId) {
return shopList[shopId].visited || !shopList[shopId].mustEnable
});
var keys = [];
if (core.flags.quickCommonEvents) {
keys = core.getFlag("__commonEventList__", []);
}
else {
keys = Object.keys(core.status.shops).filter(function (shopId) {
return core.status.shops[shopId].visited || !core.status.shops[shopId].mustEnable
});
}
if (x >= this.CHOICES_LEFT && x <= this.CHOICES_RIGHT) {
var topIndex = this.HSIZE - parseInt(keys.length / 2);
if (y >= topIndex && y < topIndex + keys.length) {
var reason = core.events.canUseQuickShop(keys[y - topIndex]);
if (!core.flags.enableDisabledShop && reason) {
core.drawText(reason);
return;
if (core.flags.quickCommonEvents) {
var name = keys[y - topIndex];
core.ui.closePanel();
core.status.route.push("common:" + core.encodeBase64(name));
core.insertAction(name);
}
else {
var reason = core.events.canUseQuickShop(keys[y - topIndex]);
if (!core.flags.enableDisabledShop && reason) {
core.drawText(reason);
return;
}
core.events.openShop(keys[y - topIndex], true);
if (core.status.event.id == 'shop')
core.status.event.data.fromList = true;
}
core.events.openShop(keys[y - topIndex], true);
if (core.status.event.id == 'shop')
core.status.event.data.fromList = true;
}
// 离开
else if (y == topIndex + keys.length)
@ -1225,10 +1240,17 @@ actions.prototype._keyUpQuickShop = function (keycode) {
core.ui.closePanel();
return;
}
var shopList = core.status.shops, keys = Object.keys(shopList).filter(function (shopId) {
return shopList[shopId].visited || !shopList[shopId].mustEnable
});
this._selectChoices(keys.length + 1, keycode, this._clickQuickShop);
var length = 0;
if (core.flags.quickCommonEvents) {
length = core.getFlag("__commonEventList__", []).length;
}
else {
var shopList = core.status.shops, keys = Object.keys(shopList).filter(function (shopId) {
return shopList[shopId].visited || !shopList[shopId].mustEnable
});
length = keys.length;
}
this._selectChoices(length + 1, keycode, this._clickQuickShop);
return;
}
@ -1416,64 +1438,65 @@ actions.prototype._keyUpToolbox = function (keycode) {
////// 装备栏界面时的点击操作 //////
actions.prototype._clickEquipbox = function (x, y) {
// 道具栏
if (x >= 10 && x <= 12 && y == 0) {
if (x >= this.LAST - 2 && y == 0) {
core.ui.closePanel();
core.openToolbox();
return;
}
// 返回
if (x >= 10 && x <= 12 && y == 12) {
if (x >= this.LAST - 2 && y == this.LAST) {
core.ui.closePanel();
return;
}
// 当前页面
var page = core.status.event.data.page;
// 上一页
if ((x == 3 || x == 4) && y == 12) {
if (page > 1) {
if ((x == this.HSIZE-2 || x == this.HSIZE-3) && y == this.LAST) {
if (core.status.event.data.page > 1) {
core.status.event.data.page--;
core.ui.drawEquipbox(core.status.event.selection);
}
return;
}
// 下一页
if ((x == 8 || x == 9) && y == 12) {
var lastPage = Math.ceil(Object.keys(core.status.hero.items.equips).length / 12);
if (page < lastPage) {
if ((x == this.HSIZE+2 || x == this.HSIZE+3) && y == this.LAST) {
var lastPage = Math.ceil(Object.keys(core.status.hero.items.equips).length / this.LAST);
if (core.status.event.data.page < lastPage) {
core.status.event.data.page++;
core.ui.drawEquipbox(core.status.event.selection);
}
return;
}
var index = parseInt(x / 2);
if (y == 4) index += 0;
else if (y == 6) index += 6;
else if (y == 9) index += 12;
else if (y == 11) index += 18;
else index = -1;
if (index >= 0) {
if (index < 12) index = parseInt(index / 2);
this._clickEquipboxIndex(index);
var per_page = this.HSIZE - 3, v = this.SIZE / per_page;
if (y == this.LAST - 8) {
for (var i = 0; i < per_page; ++i)
if (x >= i * v && x <= (i + 1) * v)
return this._clickEquipboxIndex(i);
}
else if (y == this.LAST - 6) {
for (var i = 0; i < per_page; ++i)
if (x >= i * v && x <= (i + 1) * v)
return this._clickEquipboxIndex(per_page + i);
}
else if (y == this.LAST - 3)
this._clickEquipboxIndex(this.LAST + parseInt(x / 2))
else if (y == this.LAST - 1)
this._clickEquipboxIndex(this.LAST + this.HSIZE + parseInt(x / 2));
}
////// 选择装备栏界面中某个Index后的操作 //////
actions.prototype._clickEquipboxIndex = function (index) {
if (index < 6) {
if (index < this.LAST) {
if (index >= core.status.globalAttribute.equipName.length) return;
if (index == core.status.event.selection && core.status.hero.equipment[index]) {
core.unloadEquip(index);
core.status.route.push("unEquip:" + index);
}
}
else if (index >= 12) {
else {
var equips = Object.keys(core.status.hero.items.equips || {}).sort();
if (index == core.status.event.selection) {
var equipId = equips[index - 12 + (core.status.event.data.page - 1) * 12];
var equipId = equips[index - this.LAST + (core.status.event.data.page - 1) * this.LAST];
core.loadEquip(equipId);
core.status.route.push("equip:" + equipId);
}
@ -1483,21 +1506,23 @@ actions.prototype._clickEquipboxIndex = function (index) {
////// 装备栏界面时,按下某个键的操作 //////
actions.prototype._keyDownEquipbox = function (keycode) {
if (core.status.event.data != null) return;
if (core.status.event.data == null) return;
var last_index = this.LAST - 1;
var per_line = this.HSIZE - 3;
var equipCapacity = core.status.globalAttribute.equipName.length;
var ownEquipment = Object.keys(core.status.hero.items.equips).sort();
var index = core.status.event.selection;
var page = core.status.event.data.page;
var totalPage = Math.ceil(ownEquipment.length / 12);
var totalLastIndex = 12 + (page < totalPage ? 11 : (ownEquipment.length + 11) % 12);
var totalPage = Math.ceil(ownEquipment.length / this.LAST);
var totalLastIndex = this.LAST + (page < totalPage ? last_index : (ownEquipment.length + last_index) % this.LAST);
if (keycode == 37) { // left
if (index == 0) return;
if (index == 12) {
if (index == this.LAST) {
if (page > 1) {
core.status.event.data.page--;
index = 23;
index = this.LAST + last_index;
}
else if (page == 1)
index = equipCapacity - 1;
@ -1508,25 +1533,25 @@ actions.prototype._keyDownEquipbox = function (keycode) {
return;
}
if (keycode == 38) { // up
if (index < 3) return;
else if (index < 6) index -= 3;
else if (index < 18) {
index = parseInt((index - 12) / 2);
if (equipCapacity > 3) index = Math.min(equipCapacity - 1, index + 3);
if (index < per_line) return;
else if (index < 2 * per_line) index -= per_line;
else if (index < this.LAST + this.HSIZE) {
index = parseInt((index - this.LAST) / 2);
if (equipCapacity > per_line) index = Math.min(equipCapacity - 1, index + per_line);
else index = Math.min(equipCapacity - 1, index);
}
else index -= 6;
else index -= this.HSIZE;
this._clickEquipboxIndex(index);
return;
}
if (keycode == 39) { // right
if (page < totalPage && index == 23) {
if (page < totalPage && index == this.LAST + last_index) {
core.status.event.data.page++;
index = 12;
index = this.LAST;
}
else if (index == equipCapacity - 1) {
if (totalPage == 0) return;
index = 12;
index = this.LAST;
}
else if (index == totalLastIndex)
return;
@ -1535,19 +1560,19 @@ actions.prototype._keyDownEquipbox = function (keycode) {
return;
}
if (keycode == 40) { // down
if (index < 3) {
if (equipCapacity > 3) index = Math.min(index + 3, equipCapacity - 1);
if (index < per_line) {
if (equipCapacity > per_line) index = Math.min(index + per_line, equipCapacity - 1);
else {
if (totalPage == 0) return;
index = Math.min(2 * index + 1 + 12, totalLastIndex);
index = Math.min(2 * index + 1 + this.LAST, totalLastIndex);
}
}
else if (index < 6) {
else if (index < 2 * per_line) {
if (totalPage == 0) return;
index = Math.min(2 * (index - 3) + 1 + 12, totalLastIndex);
index = Math.min(2 * (index - per_line) + 1 + this.LAST, totalLastIndex);
}
else if (index < 18)
index = Math.min(index + 6, totalLastIndex);
else if (index < this.LAST + this.HSIZE)
index = Math.min(index + this.HSIZE, totalLastIndex);
else return;
this._clickEquipboxIndex(index);
return;

View File

@ -33,6 +33,7 @@ control.prototype._init = function () {
this.registerReplayAction("fly", this._replayAction_fly);
this.registerReplayAction("shop", this._replayAction_shop);
this.registerReplayAction("turn", this._replayAction_turn);
this.registerReplayAction("common", this._replayAction_common);
this.registerReplayAction("getNext", this._replayAction_getNext);
this.registerReplayAction("moveDirectly", this._replayAction_moveDirectly);
this.registerReplayAction("key", this._replayAction_key);
@ -1301,8 +1302,12 @@ control.prototype._replay_save = function () {
control.prototype._replay_error = function (action) {
core.status.replay.replaying = false;
main.log("录像文件出错,当前操作:" + action +
"\n接下来10个操作是"+core.status.replay.toReplay.slice(0, 10).toString());
var len = core.status.replay.toReplay.length;
var prevList = core.status.replay.totalList.slice(-len - 11, -len - 1);
var nextList = core.status.replay.toReplay.slice(0, 10);
main.log("录像文件出错,当前操作:" + action);
main.log("之前的10个操作是\n" + prevList.toString());
main.log("接下来10个操作是\n" + nextList.toString());
core.ui.drawConfirmBox("录像文件出错,你想回到上个节点吗?", function () {
core.ui.closePanel();
if (core.status.replay.save.length > 0) {
@ -1441,6 +1446,16 @@ control.prototype._replayAction_turn = function (action) {
return true;
}
control.prototype._replayAction_common = function (action) {
if (action.indexOf("common:") != 0) return false;
var name = core.decodeBase64(action.substring(7));
if (core.getFlag("__commonEventList__").indexOf(name) == -1) return false;
core.status.route.push(action);
core.insertAction(name);
setTimeout(core.replay);
return true;
}
control.prototype._replayAction_getNext = function (action) {
if (action != "getNext") return false;
if (!core.getNextItem()) return false;
@ -1841,7 +1856,7 @@ control.prototype.addStatus = function (name, value) {
control.prototype.getStatus = function (name) {
if (!core.status.hero) return null;
if (name == 'x' || name == 'y' || name == 'direction')
return this.getHeroLoc('x');
return this.getHeroLoc(name);
if (name == 'exp') name = 'experience';
return core.status.hero[name];
}
@ -1865,12 +1880,12 @@ control.prototype.getRealStatusOrDefault = function (status, name) {
////// 设置某个属性的增幅值 //////
control.prototype.setBuff = function (name, value) {
this.setFlag('flag:__'+name+'_buff__', value);
this.setFlag('__'+name+'_buff__', value);
}
////// 加减某个属性的增幅值 //////
control.prototype.addBuff = function (name, value) {
this.setFlag('flag:__'+name+'_buff__', this.getBuff(name) + value);
this.setFlag('__'+name+'_buff__', this.getBuff(name) + value);
}
////// 获得某个属性的增幅值 //////

View File

@ -103,7 +103,9 @@ function core() {
"data": null,
"time": 0,
"updated": false,
}
},
"favorite": [],
"favoriteName": {}
}
this.initStatus = {
'played': false,
@ -295,7 +297,7 @@ core.prototype._init_platform = function () {
}
core.prototype._init_checkLocalForage = function () {
core.platform.useLocalForage = core.getLocalStorage('useLocalForage', !core.platform.isIOS);
core.platform.useLocalForage = core.getLocalStorage('useLocalForage', true);
var _error = function (e) {
main.log(e);
core.platform.useLocalForage = false;
@ -384,13 +386,16 @@ core.prototype._forwardFunc = function (name, funcname) {
}
if (core[funcname]) {
console.error("ERROR: Cannot forward function " + funcname + " from " + name + "!");
console.error("ERROR: 无法转发 "+name+" 中的函数 "+funcname+" 到 core 中!同名函数已存在。");
return;
}
var parameterInfo = /^\s*function\s*[\w_$]*\(([\w_,$\s]*)\)\s*\{/.exec(core[name][funcname].toString());
var parameters = (parameterInfo == null ? "" : parameterInfo[1]).replace(/\s*/g, '').replace(/,/g, ', ');
// core[funcname] = new Function(parameters, "return core."+name+"."+funcname+"("+parameters+");");
eval("core." + funcname + " = function (" + parameters + ") {\n\treturn core." + name + "." + funcname + "(" + parameters + ");\n}");
if (name == 'plugin') {
main.log("插件函数转发core."+funcname+" = core.plugin."+funcname);
}
}
core.prototype.doFunc = function (func, _this) {

View File

@ -806,7 +806,10 @@ events.prototype.insertAction = function (action, x, y, callback, addToLast) {
// ------ 判定commonEvent
var commonEvent = this.getCommonEvent(action);
if (commonEvent instanceof Array) action = commonEvent;
if (commonEvent instanceof Array) {
this._addCommentEventToList(action, commonEvent);
action = commonEvent;
}
if (!action) return;
if (core.status.event.id != 'action') {
@ -827,6 +830,22 @@ events.prototype.getCommonEvent = function (name) {
return this.commonEvent[name] || null;
}
events.prototype._addCommentEventToList = function (name, list) {
if (list == null) list = this.getCommonEvent(name);
if (!list || !core.flags.quickCommonEvents) return;
var addToList = false;
for (var x in list) {
if (list[x].type == 'addToList') {
addToList = true;
break;
}
}
if (!addToList) return;
var obj = core.getFlag("__commonEventList__", []);
if (obj.indexOf(name) == -1) obj.push(name);
core.setFlag("__commonEventList__", obj);
}
////// 恢复一个事件 //////
events.prototype.recoverEvents = function (data) {
if (data) {
@ -1175,7 +1194,7 @@ events.prototype._action_insert = function (data, x, y, prefix) {
}
if (data.name) { // 公共事件
core.setFlag('arg0', data.name);
core.insertAction(this.getCommonEvent(data.name));
core.insertAction(data.name);
}
else {
var loc = this.__action_getLoc(data.loc, x, y, prefix);
@ -1188,6 +1207,10 @@ events.prototype._action_insert = function (data, x, y, prefix) {
core.doAction();
}
events.prototype._action_addToList = function (data, x, y, prefix) {
core.doAction();
}
events.prototype._action_playBgm = function (data, x, y, prefix) {
core.playBgm(data.name);
core.doAction();

View File

@ -311,20 +311,17 @@ items.prototype.unloadEquip = function (equipType, callback) {
}
items.prototype.compareEquipment = function (compareEquipId, beComparedEquipId) {
var compareAtk = 0, compareDef = 0, compareMdef = 0;
if (compareEquipId) {
var compareEquip = core.material.items[compareEquipId];
compareAtk += (compareEquip.equip || {}).atk || 0;
compareDef += (compareEquip.equip || {}).def || 0;
compareMdef += (compareEquip.equip || {}).mdef || 0;
var result = {};
var first = core.material.items[compareEquipId], second = core.material.items[beComparedEquipId];
for (var name in core.status.hero) {
if (typeof core.status.hero[name] == 'number') {
var ans = 0;
if (first) ans += (first.equip || {})[name] || 0;
if (second) ans -= (second.equip || {})[name] || 0;
if (ans != 0) result[name] = ans;
}
}
if (beComparedEquipId) {
var beComparedEquip = core.material.items[beComparedEquipId];
compareAtk -= (beComparedEquip.equip || {}).atk || 0;
compareDef -= (beComparedEquip.equip || {}).def || 0;
compareMdef -= (beComparedEquip.equip || {}).mdef || 0;
}
return {"atk": compareAtk, "def": compareDef, "mdef": compareMdef};
return result;
}
////// 实际换装的效果 //////
@ -349,7 +346,7 @@ items.prototype._realLoadEquip = function (type, loadId, unloadId, callback) {
var loadPercentage = loadEquip.equip.percentage, unloadPercentage = unloadEquip.equip.percentage;
if (loadPercentage != null && unloadPercentage != null && loadPercentage != unloadPercentage) {
if (loadId && unloadId && (loadPercentage || false) != (unloadPercentage || false)) {
this.unloadEquip(type);
this.loadEquip(loadId);
if (callback) callback();

View File

@ -30,11 +30,14 @@ maps.prototype.loadFloor = function (floorId, map) {
map = {"map": map};
}
var content = {};
["floorId", "title", "name", "canFlyTo", "canUseQuickShop", "cannotViewMap", "cannotMoveDirectly", "color", "weather",
"defaultGround", "images", "item_ratio", "upFloor", "bgm", "downFloor", "underGround"].forEach(function (e) {
if (map[e] != null) content[e] = core.clone(map[e]);
else content[e] = core.clone(floor[e]);
});
for (var name in floor) {
if (name != 'map' && name != 'bgmap' && name != 'fgmap' && floor[name] != null)
content[name] = core.clone(floor[name]);
}
for (var name in map) {
if (name != 'map' && name != 'bgmap' && name != 'fgmap' && map[name] != null)
content[name] = core.clone(map[name]);
}
map = this.decompressMap(map.map, floorId);
// 事件处理
content['blocks'] = this._mapIntoBlocks(map, floor, floorId);

View File

@ -1118,12 +1118,18 @@ ui.prototype.drawSettings = function () {
////// 绘制快捷商店选择栏 //////
ui.prototype.drawQuickShop = function () {
core.status.event.id = 'selectShop';
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 {"text": shopList[shopId].textInList, "color": shopList[shopId].visited?null:"#999999"};
});
var choices;
if (core.flags.quickCommonEvents) {
choices = core.clone(core.getFlag("__commonEventList__", []));
}
else {
var shopList = core.status.shops, keys = Object.keys(shopList).filter(function (shopId) {
return shopList[shopId].visited || !shopList[shopId].mustEnable
});
choices = keys.map(function (shopId) {
return {"text": shopList[shopId].textInList, "color": shopList[shopId].visited?null:"#999999"};
});
}
choices.push("返回游戏");
this.drawChoices(null, choices);
}
@ -1733,7 +1739,7 @@ ui.prototype.drawToolbox = function(index) {
core.setTextAlign('ui', 'center');
core.fillText('ui', '[装备栏]', this.PIXEL - 46, 25, '#DDDDDD', this._buildFont(15, true));
core.fillText('ui', '返回游戏', this.PIXEL - 46, this.PIXEL - 13,'#DDDDDD');
core.fillText('ui', '返回游戏', this.PIXEL - 46, this.PIXEL - 13);
}
ui.prototype._drawToolbox_getInfo = function (index) {
@ -1796,27 +1802,25 @@ ui.prototype._drawToolbox_drawLine = function (yoffset, text) {
ui.prototype._drawToolbox_drawDescription = function (info, max_height) {
core.setTextAlign('ui', 'left');
// 描述
if (info.selectId) {
var item=core.material.items[info.selectId];
core.fillText('ui', item.name, 10, 32, '#FFD700', this._buildFont(20, true))
var text = item.text||"该道具暂无描述。";
try {
// 检查能否eval
text = core.replaceText(text);
} catch (e) {}
var lines = core.splitLines('ui', text, this.PIXEL - 15, this._buildFont(17, false));
// --- 开始逐行绘制
var curr = 62, line_height = 25;
core.setFillStyle('ui', '#FFFFFF');
for (var i=0;i<lines.length;++i) {
core.fillText('ui', lines[i], 10, curr);
curr += line_height;
if (curr>=max_height) break;
}
if (curr < max_height) {
core.fillText('ui', '<继续点击该道具即可进行使用>', 10, curr, '#CCCCCC', this._buildFont(14, false));
}
if (!info.selectId) return;
var item=core.material.items[info.selectId];
core.fillText('ui', item.name, 10, 32, '#FFD700', this._buildFont(20, true))
var text = item.text||"该道具暂无描述。";
try {
// 检查能否eval
text = core.replaceText(text);
} catch (e) {}
var lines = core.splitLines('ui', text, this.PIXEL - 15, this._buildFont(17, false));
// --- 开始逐行绘制
var curr = 62, line_height = 25;
core.setFillStyle('ui', '#FFFFFF');
for (var i=0;i<lines.length;++i) {
core.fillText('ui', lines[i], 10, curr);
curr += line_height;
if (curr>=max_height) break;
}
if (curr < max_height) {
core.fillText('ui', '<继续点击该道具即可进行使用>', 10, curr, '#CCCCCC', this._buildFont(14, false));
}
}
@ -1837,187 +1841,155 @@ ui.prototype._drawToolbox_drawContent = function (info, line, items, page, drawC
////// 绘制装备界面 //////
ui.prototype.drawEquipbox = function(index) {
// 设定eventdata
if (!core.isset(core.status.event.data) || !core.isset(core.status.event.data.page))
core.status.event.data = {"page":1, "selectId":null};
var info = this._drawEquipbox_getInfo(index);
this._drawToolbox_drawBackground();
core.setAlpha('ui', 1);
core.setStrokeStyle('ui', '#DDDDDD');
core.canvas.ui.lineWidth = 2;
core.canvas.ui.strokeWidth = 2;
core.setTextAlign('ui', 'right');
var line1 = this.PIXEL - 306;
this._drawToolbox_drawLine(line1, "当前装备");
var line2 = this.PIXEL - 146;
this._drawToolbox_drawLine(line2, "拥有装备");
this._drawEquipbox_description(info, line1);
this._drawEquipbox_drawEquiped(info, line1);
this._drawToolbox_drawContent(info, line2, info.ownEquipment, info.page, true);
this.drawPagination(info.page, info.totalPage);
core.setTextAlign('ui', 'center');
core.fillText('ui', '[道具栏]', this.PIXEL - 46, 25, '#DDDDDD', this._buildFont(15, true));
core.fillText('ui', '返回游戏', this.PIXEL - 46, this.PIXEL - 13);
}
ui.prototype._drawEquipbox_getInfo = function (index) {
if (!core.status.event.data || core.status.event.data.page == null)
core.status.event.data = {"page":1, "selectId":null};
var allEquips = core.status.globalAttribute.equipName;
var equipLength = allEquips.length;
if (!core.isset(core.status.hero.equipment)) core.status.hero.equipment = [];
if (!core.status.hero.equipment) core.status.hero.equipment = [];
var equipEquipment = core.status.hero.equipment;
var ownEquipment = Object.keys(core.status.hero.items.equips).sort();
var page = core.status.event.data.page;
var totalPage = Math.ceil(ownEquipment.length/12);
var totalPage = Math.ceil(ownEquipment.length / this.LAST);
// 处理index
if (!core.isset(index)) {
if (equipLength>0 && core.isset(equipEquipment[0])) index=0;
else if (ownEquipment.length>0) index=12;
else index=0;
if (index == null) {
if (equipLength > 0 && equipEquipment[0]) index = 0;
else if (ownEquipment.length > 0) index = this.LAST;
else index = 0;
}
if (index>=12 && ownEquipment.length==0) index = 0;
if (index >= this.LAST && ownEquipment.length == 0) index = 0;
var selectId=null;
if (index<12) {
if (index < this.LAST) {
if (index >= equipLength) index=Math.max(0, equipLength - 1);
selectId = equipEquipment[index]||null;
selectId = equipEquipment[index] || null;
}
else {
if (page == totalPage) index = Math.min(index, (ownEquipment.length+11)%12+12);
selectId = ownEquipment[index-12 + (page-1)*12];
if (page == totalPage) index = Math.min(index, (ownEquipment.length+this.LAST-1)%this.LAST+this.LAST);
selectId = ownEquipment[index - this.LAST + (page - 1) * this.LAST];
if (!core.hasItem(selectId)) selectId=null;
}
core.status.event.selection=index;
core.status.event.data.selectId=selectId;
return { index: index, selectId: selectId, page: page, totalPage: totalPage, allEquips: allEquips,
equipLength: equipLength, equipEquipment: equipEquipment, ownEquipment: ownEquipment};
}
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 0.85);
core.fillRect('ui', 0, 0, 416, 416, '#000000');
core.setAlpha('ui', 1);
core.setFillStyle('ui', '#DDDDDD');
core.setStrokeStyle('ui', '#DDDDDD');
core.canvas.ui.lineWidth = 2;
core.canvas.ui.strokeWidth = 2;
var ydelta = 20;
// 画线
core.canvas.ui.beginPath();
core.canvas.ui.moveTo(0, 130-ydelta);
core.canvas.ui.lineTo(416, 130-ydelta);
core.canvas.ui.stroke();
core.canvas.ui.beginPath();
core.canvas.ui.moveTo(416,129-ydelta);
core.canvas.ui.lineTo(416,105-ydelta);
core.canvas.ui.lineTo(416-72,105-ydelta);
core.canvas.ui.lineTo(416-102,129-ydelta);
core.canvas.ui.fill();
core.canvas.ui.beginPath();
core.canvas.ui.moveTo(0, 290-ydelta);
core.canvas.ui.lineTo(416, 290-ydelta);
core.canvas.ui.stroke();
core.canvas.ui.beginPath();
core.canvas.ui.moveTo(416,289-ydelta);
core.canvas.ui.lineTo(416,265-ydelta);
core.canvas.ui.lineTo(416-72,265-ydelta);
core.canvas.ui.lineTo(416-102,289-ydelta);
core.canvas.ui.fill();
// 文字
core.setTextAlign('ui', 'right');
var globalFont = core.status.globalAttribute.font;
core.fillText('ui', "当前装备", 411, 124-ydelta, '#333333', "bold 16px "+globalFont);
core.fillText('ui', "拥有装备", 411, 284-ydelta);
ui.prototype._drawEquipbox_description = function (info, max_height) {
core.setTextAlign('ui', 'left');
if (!info.selectId) return;
var equip=core.material.items[info.selectId];
// --- 标题
if (!equip.equip) equip.equip = {"type": 0};
var equipType = equip.equip.type, equipString;
if (typeof equipType === 'string') {
equipString = equipType || "未知部位";
equipType = core.items.getEquipTypeByName(equipType);
}
else equipString = info.allEquips[equipType] || "未知部位";
core.fillText('ui', equip.name + "" + equipString + "", 10, 32, '#FFD700', this._buildFont(20, true))
// --- 描述
var text = equip.text || "该装备暂无描述。";
try {
text = core.replaceText(text);
} catch (e) {}
var lines = core.splitLines('ui', text, this.PIXEL - 15, this._buildFont(17, false));
var curr = 62, line_height = 25;
core.setFillStyle('ui', '#FFFFFF');
for (var i = 0; i < lines.length; ++i) {
core.fillText('ui', lines[i], 10, curr);
curr += line_height;
if (curr >= max_height) break;
}
// --- 变化值
if (curr >= max_height) return;
this._drawEquipbox_drawStatusChanged(info, curr, equip, equipType);
}
// 描述
if (core.isset(selectId)) {
var equip=core.material.items[selectId];
if (!core.isset(equip.equip)) equip.equip = {"type": 0};
var equipType = equip.equip.type;
var equipString;
if (typeof equipType === 'string') {
equipString = equipType||"未知部位";
equipType = core.items.getEquipTypeByName(equipType);
}
else equipString = allEquips[equipType]||"未知部位";
core.fillText('ui', equip.name + "" + equipString + "", 10, 32, '#FFD700', "bold 20px "+globalFont)
var text = equip.text||"该装备暂无描述。";
try {
text = core.replaceText(text);
} catch (e) {}
var lines = core.splitLines('ui', text, 406, '17px '+globalFont);
core.fillText('ui', lines[0], 10, 62, '#FFFFFF', '17px '+globalFont);
// 比较属性
if (lines.length==1) {
var compare, differentMode = null;
if (index<12) compare = core.compareEquipment(null, selectId);
else {
if (equipType<0) {
differentMode = '<当前没有该装备的空位,请先卸下装备>';
}
else {
var last = core.material.items[equipEquipment[equipType]]||{};
// 检查是不是数值模式和比例模式之间的切换
if (core.isset(last.equip) && (last.equip.percentage||false) != (equip.equip.percentage||false)) {
differentMode = '<数值和比例模式之间的切换不显示属性变化>';
}
else {
compare = core.compareEquipment(selectId, equipEquipment[equipType]);
}
}
}
if (differentMode != null) {
core.fillText('ui', differentMode, 10, 89, '#CCCCCC', '14px '+globalFont);
}
else {
var drawOffset = 10;
[['攻击','atk'], ['防御','def'], ['魔防','mdef']].forEach(function (t) {
var title = t[0], name = t[1];
if (!core.isset(compare[name]) || compare[name]==0) return;
var color = '#00FF00';
if (compare[name]<0) color = '#FF0000';
var nowValue = core.getStatus(name), newValue = nowValue + compare[name];
if (equip.equip.percentage) {
var nowBuff = core.getBuff(name), newBuff = nowBuff+compare[name]/100;
nowValue = Math.floor(nowBuff*core.getStatus(name));
newValue = Math.floor(newBuff*core.getStatus(name));
}
var content = title + ' ' + nowValue + '->';
core.fillText('ui', content, drawOffset, 89, '#CCCCCC', 'bold 14px '+globalFont);
drawOffset += core.calWidth('ui', content);
core.fillText('ui', newValue, drawOffset, 89, color);
drawOffset += core.calWidth('ui', newValue) + 15;
})
}
}
ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipType) {
var compare, differentMode = null;
if (info.index < this.LAST) compare = core.compareEquipment(null, info.selectId);
else {
if (equipType<0) differentMode = '<当前没有该装备的空位,请先卸下装备>';
else {
var leftText = text.substring(lines[0].length);
core.fillText('ui', leftText, 10, 89, '#FFFFFF', '17px '+globalFont);
var last = core.material.items[info.equipEquipment[equipType]]||{};
if (last.equip && (last.equip.percentage || false) != (equip.equip.percentage || false))
differentMode = '<数值和比例模式之间的切换不显示属性变化>';
else
compare = core.compareEquipment(info.selectId, info.equipEquipment[equipType]);
}
}
if (differentMode != null) {
core.fillText('ui', differentMode, 10, y, '#CCCCCC', this._buildFont(14, false));
return;
}
var drawOffset = 10;
// --- 变化值...
core.setFont('ui', this._buildFont(14, true));
for (var name in compare) {
var img = core.statusBar.icons[name];
if (img) { // 绘制图标
core.drawImage('ui', img, 0, 0, 32, 32, drawOffset, y - 13, 16, 16);
drawOffset += 20;
}
else { // 绘制文字
core.fillText('ui', name + " ", drawOffset, y, '#CCCCCC');
drawOffset += core.calWidth('ui', name + " ");
}
var nowValue = core.getStatus(name) * core.getBuff(name), newValue = (nowValue + compare[name]) * core.getBuff(name);
if (equip.equip.percentage) {
var nowBuff = core.getBuff(name), newBuff = nowBuff + compare[name] / 100;
nowValue = Math.floor(nowBuff * core.getStatus(name));
newValue = Math.floor(newBuff * core.getStatus(name));
}
nowValue = core.formatBigNumber(nowValue);
newValue = core.formatBigNumber(newValue);
core.fillText('ui', nowValue + "->", drawOffset, y, '#CCCCCC');
drawOffset += core.calWidth('ui', nowValue + "->");
core.fillText('ui', newValue, drawOffset, y, compare[name]>0?'#00FF00':'#FF0000');
drawOffset += core.calWidth('ui', newValue) + 8;
}
}
ui.prototype._drawEquipbox_drawEquiped = function (info, line) {
core.setTextAlign('ui', 'right');
var images = core.material.images.items;
var per_line = this.HSIZE - 3, width = Math.floor(this.PIXEL / (per_line + 0.25));
// 当前装备
for (var i = 0 ; i < equipLength ; i++) {
var equipId = equipEquipment[i] || null;
if (core.isset(equipId)) {
for (var i = 0; i < info.equipLength ; i++) {
var equipId = info.equipEquipment[i] || null;
var offset_text = width * (i % per_line) + 56;
var offset_image = width * (i % per_line) + width * 2 / 3;
var y = line + 54 * Math.floor(i / per_line) + 19;
if (equipId) {
var icon = core.material.icons.items[equipId];
core.drawImage('ui', images, 0, icon*32, 32, 32, 16*(8*(i%3)+5)+5, 144+Math.floor(i/3)*54+5-ydelta, 32, 32);
core.drawImage('ui', core.material.images.items, 0, 32 * icon, 32, 32, offset_image, y, 32, 32);
}
core.fillText('ui', allEquips[i]||"未知", 16*(8*(i%3)+1)+40, 144+Math.floor(i/3)*54+32-ydelta, '#FFFFFF', "bold 16px "+globalFont);
core.strokeRect('ui', 16*(8*(i%3)+5)+1, 144+Math.floor(i/3)*54+1-ydelta, 40, 40, index==i?'#FFD700':"#FFFFFF");
core.fillText('ui', info.allEquips[i] || "未知", offset_text, y + 27, '#FFFFFF', this._buildFont(16, true))
core.strokeRect('ui', offset_image - 4, y - 4, 40, 40, info.index==i?'#FFD700':"#FFFFFF");
}
// 现有装备
for (var i=0;i<12;i++) {
var ownEquip=ownEquipment[12*(page-1)+i];
if (!core.isset(ownEquip)) continue;
var icon=core.material.icons.items[ownEquip];
core.drawImage('ui', images, 0, icon*32, 32, 32, 16*(4*(i%6)+1)+5, 304+Math.floor(i/6)*54+5-ydelta, 32, 32)
// 个数
if (core.itemCount(ownEquip)>1)
core.fillText('ui', core.itemCount(ownEquip), 16*(4*(i%6)+1)+40, 304+Math.floor(i/6)*54+38-ydelta, '#FFFFFF', "bold 14px "+globalFont);
if (index>=12 && selectId == ownEquip)
core.strokeRect('ui', 16*(4*(i%6)+1)+1, 304+Math.floor(i/6)*54+1-ydelta, 40, 40, '#FFD700');
}
this.drawPagination(page, totalPage, 12);
// 道具栏
core.setTextAlign('ui', 'center');
core.fillText('ui', '[道具栏]', 370, 25,'#DDDDDD', 'bold 15px '+globalFont);
// 退出按钮
core.fillText('ui', '返回游戏', 370, 403,'#DDDDDD', 'bold 15px '+globalFont);
}
////// 绘制存档/读档界面 //////

View File

@ -467,6 +467,8 @@ utils.prototype._encodeRoute_encodeOne = function (t) {
return "P" + t.substring(6);
else if (t.indexOf('input2:') == 0)
return "Q" + t.substring(7) + ":";
else if (t.indexOf('common:') == 0)
return "c" + t.substring(7) + ":";
else if (t == 'no')
return 'N';
else if (t.indexOf('move:') == 0)
@ -525,7 +527,7 @@ utils.prototype._decodeRoute_number2id = function (number) {
}
utils.prototype._decodeRoute_decodeOne = function (decodeObj, c) {
var nxt = (c == 'I' || c == 'e' || c == 'F' || c == 'S' || c == 'Q' || c == 't') ?
var nxt = (c == 'I' || c == 'e' || c == 'F' || c == 'S' || c == 'Q' || c == 't' || c == 'c') ?
this._decodeRoute_getString(decodeObj) : this._decodeRoute_getNumber(decodeObj);
var mp = {"U": "up", "D": "down", "L": "left", "R": "right"};
@ -570,6 +572,9 @@ utils.prototype._decodeRoute_decodeOne = function (decodeObj, c) {
case "Q":
decodeObj.ans.push("input2:" + nxt);
break;
case "c":
decodeObj.ans.push("common:" + nxt);
break;
case "N":
decodeObj.ans.push("no");
break;

View File

@ -675,7 +675,7 @@ window.onblur = function () {
if (main.core && main.core.control) {
try {
main.core.control.checkAutosave();
} catch (e) {main.log(e);}
} catch (e) {}
}
}

View File

@ -397,6 +397,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"enableMoveDirectly": true,
"enableDisabledShop": true,
"disableShopOnDamage": false,
"quickCommonEvents": false,
"checkConsole": false
}
}

View File

@ -237,6 +237,83 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 =
],
"false": []
}
],
"回收钥匙商店": [
{
"type": "comment",
"text": "公共事件:回收钥匙商店"
},
{
"type": "addToList"
},
{
"type": "comment",
"text": "使用上述事件并在全塔属性打开quickCommonEvent开关"
},
{
"type": "comment",
"text": "就可以在快捷列表V键中使用本公共事件"
},
{
"type": "while",
"condition": "1",
"data": [
{
"type": "choices",
"text": "\t[商人,woman]你有多余的钥匙想要出售吗?",
"choices": [
{
"text": "黄钥匙10金币",
"color": [
255,
255,
0,
1
],
"action": [
{
"type": "if",
"condition": "item:yellowKey >= 1",
"true": [
{
"type": "addValue",
"name": "item:yellowKey",
"value": "-1"
},
{
"type": "addValue",
"name": "status:money",
"value": "10"
}
],
"false": [
"\t[商人,woman]你没有黄钥匙!"
]
}
]
},
{
"text": "蓝钥匙50金币",
"color": [
0,
0,
255,
1
],
"action": []
},
{
"text": "离开",
"action": [
{
"type": "exit"
}
]
}
]
}
]
}
]
}
}

View File

@ -699,7 +699,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
gid = guards[i][2];
// 递归计算支援怪伤害信息这里不传x,y保证不会重复调用
// 这里的mdef传0因为护盾应该只会被计算一次
var info = core.enemys.getDamageInfo(core.material.enemys[gid], origin_hero_hp, origin_hero_atk, origin_hero_def, 0);
var info = core.enemys.getDamageInfo(core.material.enemys[gid], { hp: origin_hero_hp, atk: origin_hero_atk, def: origin_hero_def, mdef: 0 });
if (info == null) { // 小队中任何一个怪物不可战斗直接返回null
return null;
}

View File

@ -259,7 +259,7 @@ var icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 =
"hammer": 48,
"jumpShoes": 49,
"skill1": 30,
"I73": 10
"wand": 10
},
"autotile": {
"autotile": 0,

View File

@ -303,7 +303,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"text": "可以打开或关闭主动技能二倍斩",
"hideInReplay": true
},
"I73": {
"wand": {
"cls": "items",
"name": "新物品"
}

View File

@ -67,7 +67,7 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e =
"70": {"cls":"items","id":"sword0"},
"71": {"cls":"items","id":"shield0"},
"72": {"cls":"items","id":"skill1"},
"73": {"cls":"items","id":"I73"},
"73": {"cls":"items","id":"wand"},
"81": {"cls":"terrains","id":"yellowDoor","trigger":"openDoor"},
"82": {"cls":"terrains","id":"blueDoor","trigger":"openDoor"},
"83": {"cls":"terrains","id":"redDoor","trigger":"openDoor"},