Reformat code
This commit is contained in:
parent
8144ca8d17
commit
02934cad46
@ -84,7 +84,9 @@ actions.prototype.registerAction = function (action, name, func, priority) {
|
|||||||
////// 注销一个用户交互行为 //////
|
////// 注销一个用户交互行为 //////
|
||||||
actions.prototype.unregisterAction = function (action, name) {
|
actions.prototype.unregisterAction = function (action, name) {
|
||||||
if (!this.actions[action]) return;
|
if (!this.actions[action]) return;
|
||||||
this.actions[action] = this.actions[action].filter(function (x) { return x.name != name; });
|
this.actions[action] = this.actions[action].filter(function (x) {
|
||||||
|
return x.name != name;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 执行一个用户交互行为 //////
|
////// 执行一个用户交互行为 //////
|
||||||
@ -192,7 +194,9 @@ actions.prototype.pressKey = function (keyCode) {
|
|||||||
actions.prototype._sys_pressKey = function (keyCode) {
|
actions.prototype._sys_pressKey = function (keyCode) {
|
||||||
if (keyCode === core.status.holdingKeys.slice(-1)[0]) {
|
if (keyCode === core.status.holdingKeys.slice(-1)[0]) {
|
||||||
this.keyDown(keyCode);
|
this.keyDown(keyCode);
|
||||||
window.setTimeout(function(){core.pressKey(keyCode);},30);
|
window.setTimeout(function () {
|
||||||
|
core.pressKey(keyCode);
|
||||||
|
}, 30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,7 +510,11 @@ actions.prototype._sys_onup = function () {
|
|||||||
for (var ii = 1; ii < core.status.stepPostfix.length; ii++) {
|
for (var ii = 1; ii < core.status.stepPostfix.length; ii++) {
|
||||||
var pos0 = core.status.stepPostfix[ii - 1];
|
var pos0 = core.status.stepPostfix[ii - 1];
|
||||||
var pos = core.status.stepPostfix[ii];
|
var pos = core.status.stepPostfix[ii];
|
||||||
stepPostfix.push({'direction': direction[pos.x-pos0.x][pos.y-pos0.y], 'x': pos.x+parseInt(core.bigmap.offsetX/32), 'y': pos.y+parseInt(core.bigmap.offsetY/32)});
|
stepPostfix.push({
|
||||||
|
'direction': direction[pos.x - pos0.x][pos.y - pos0.y],
|
||||||
|
'x': pos.x + parseInt(core.bigmap.offsetX / 32),
|
||||||
|
'y': pos.y + parseInt(core.bigmap.offsetY / 32)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
var posx = core.status.stepPostfix[0].x;
|
var posx = core.status.stepPostfix[0].x;
|
||||||
var posy = core.status.stepPostfix[0].y;
|
var posy = core.status.stepPostfix[0].y;
|
||||||
@ -1185,7 +1193,9 @@ actions.prototype._keyUpShop = function (keycode) {
|
|||||||
|
|
||||||
////// 快捷商店界面时的点击操作 //////
|
////// 快捷商店界面时的点击操作 //////
|
||||||
actions.prototype._clickQuickShop = function (x, y) {
|
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 shopList = core.status.shops, keys = Object.keys(shopList).filter(function (shopId) {
|
||||||
|
return shopList[shopId].visited || !shopList[shopId].mustEnable
|
||||||
|
});
|
||||||
if (x >= 5 && x <= 7) {
|
if (x >= 5 && x <= 7) {
|
||||||
var topIndex = 6 - parseInt(keys.length / 2);
|
var topIndex = 6 - parseInt(keys.length / 2);
|
||||||
if (y >= topIndex && y < topIndex + keys.length) {
|
if (y >= topIndex && y < topIndex + keys.length) {
|
||||||
@ -1210,7 +1220,9 @@ actions.prototype._keyUpQuickShop = function (keycode) {
|
|||||||
core.ui.closePanel();
|
core.ui.closePanel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var shopList = core.status.shops, keys = Object.keys(shopList).filter(function (shopId) {return shopList[shopId].visited || !shopList[shopId].mustEnable});
|
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);
|
this._selectChoices(keys.length + 1, keycode, this._clickQuickShop);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1253,7 +1265,8 @@ actions.prototype._clickToolbox = function(x,y) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var index=parseInt(x/2);;
|
var index = parseInt(x / 2);
|
||||||
|
;
|
||||||
if (y == 4) index += 0;
|
if (y == 4) index += 0;
|
||||||
else if (y == 6) index += 6;
|
else if (y == 6) index += 6;
|
||||||
else if (y == 9) index += 12;
|
else if (y == 9) index += 12;
|
||||||
@ -2120,14 +2133,12 @@ actions.prototype._clickReplay = function (x, y) {
|
|||||||
if (y >= topIndex && y < topIndex + choices.length) {
|
if (y >= topIndex && y < topIndex + choices.length) {
|
||||||
var selection = y - topIndex;
|
var selection = y - topIndex;
|
||||||
switch (selection) {
|
switch (selection) {
|
||||||
case 0:
|
case 0: {
|
||||||
{
|
|
||||||
core.ui.closePanel();
|
core.ui.closePanel();
|
||||||
core.startGame(core.status.hard, core.getFlag('__seed__'), core.clone(core.status.route));
|
core.startGame(core.status.hard, core.getFlag('__seed__'), core.clone(core.status.route));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1:
|
case 1: {
|
||||||
{
|
|
||||||
core.status.event.id = 'replayLoad';
|
core.status.event.id = 'replayLoad';
|
||||||
core.status.event.selection = null;
|
core.status.event.selection = null;
|
||||||
core.ui.clearLastEvent();
|
core.ui.clearLastEvent();
|
||||||
@ -2239,7 +2250,8 @@ actions.prototype._clickKeyBoard = function (x, y) {
|
|||||||
try {
|
try {
|
||||||
eval(val);
|
eval(val);
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (y == 4 && x >= 1 && x <= 10) {
|
if (y == 4 && x >= 1 && x <= 10) {
|
||||||
|
|||||||
25
libs/core.js
25
libs/core.js
@ -292,13 +292,28 @@ core.prototype.init = function (coreData, callback) {
|
|||||||
core.removeLocalForage("__test__");
|
core.removeLocalForage("__test__");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {main.log(e); core.platform.useLocalForage=false;}
|
catch (e) {
|
||||||
}, function(e) {main.log(e); core.platform.useLocalForage=false;})
|
main.log(e);
|
||||||
|
core.platform.useLocalForage = false;
|
||||||
}
|
}
|
||||||
catch (e) {main.log(e); core.platform.useLocalForage=false;}
|
}, function (e) {
|
||||||
}, function(e) {main.log(e); core.platform.useLocalForage=false;})
|
main.log(e);
|
||||||
|
core.platform.useLocalForage = false;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
main.log(e);
|
||||||
|
core.platform.useLocalForage = false;
|
||||||
|
}
|
||||||
|
}, function (e) {
|
||||||
|
main.log(e);
|
||||||
|
core.platform.useLocalForage = false;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
main.log(e);
|
||||||
|
core.platform.useLocalForage = false;
|
||||||
}
|
}
|
||||||
catch (e) {main.log(e); core.platform.useLocalForage=false;}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
core.platform.extendKeyboard = core.getLocalStorage("extendKeyboard", false);
|
core.platform.extendKeyboard = core.getLocalStorage("extendKeyboard", false);
|
||||||
|
|||||||
@ -9,7 +9,9 @@ enemys.prototype._init = function () {
|
|||||||
this.enemys = enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80;
|
this.enemys = enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80;
|
||||||
this.enemydata = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.enemys;
|
this.enemydata = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.enemys;
|
||||||
if (main.mode == 'play') {
|
if (main.mode == 'play') {
|
||||||
this.enemydata.hasSpecial = function (a, b) {return core.enemys.hasSpecial(a, b)};
|
this.enemydata.hasSpecial = function (a, b) {
|
||||||
|
return core.enemys.hasSpecial(a, b)
|
||||||
|
};
|
||||||
for (var enemyId in this.enemys) {
|
for (var enemyId in this.enemys) {
|
||||||
this.enemys[enemyId].id = enemyId;
|
this.enemys[enemyId].id = enemyId;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -267,7 +267,9 @@ loader.prototype._preloadBgm = function (bgm) {
|
|||||||
loader.prototype.freeBgm = function (name) {
|
loader.prototype.freeBgm = function (name) {
|
||||||
if (!core.isset(core.material.bgms[name])) return;
|
if (!core.isset(core.material.bgms[name])) return;
|
||||||
// 从cachedBgms中删除
|
// 从cachedBgms中删除
|
||||||
core.musicStatus.cachedBgms = core.musicStatus.cachedBgms.filter(function (t) {return t!=name; });
|
core.musicStatus.cachedBgms = core.musicStatus.cachedBgms.filter(function (t) {
|
||||||
|
return t != name;
|
||||||
|
});
|
||||||
// 清掉缓存
|
// 清掉缓存
|
||||||
core.material.bgms[name].removeAttribute("src");
|
core.material.bgms[name].removeAttribute("src");
|
||||||
core.material.bgms[name].load();
|
core.material.bgms[name].load();
|
||||||
|
|||||||
@ -169,17 +169,21 @@ utils.prototype.decompress = function (value) {
|
|||||||
if (core.isset(output) && output.length > 0)
|
if (core.isset(output) && output.length > 0)
|
||||||
return JSON.parse(output);
|
return JSON.parse(output);
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
var output = LZString.decompress(value);
|
var output = LZString.decompress(value);
|
||||||
if (core.isset(output) && output.length > 0)
|
if (core.isset(output) && output.length > 0)
|
||||||
return JSON.parse(output);
|
return JSON.parse(output);
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return JSON.parse(value);
|
return JSON.parse(value);
|
||||||
}
|
}
|
||||||
catch (e) {main.log(e);}
|
catch (e) {
|
||||||
|
main.log(e);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,7 +480,8 @@ utils.prototype.decodeRoute = function (route) {
|
|||||||
if (core.isset(v) && /^[a-zA-Z0-9+\/=:]*$/.test(v)) {
|
if (core.isset(v) && /^[a-zA-Z0-9+\/=:]*$/.test(v)) {
|
||||||
route = v;
|
route = v;
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
|
}
|
||||||
|
|
||||||
var decodeObj = {route: route, index: 0, ans: []};
|
var decodeObj = {route: route, index: 0, ans: []};
|
||||||
while (decodeObj.index < decodeObj.route.length) {
|
while (decodeObj.index < decodeObj.route.length) {
|
||||||
@ -518,22 +523,58 @@ utils.prototype._decodeRoute_decodeOne = function (decodeObj, c) {
|
|||||||
var mp = {"U": "up", "D": "down", "L": "left", "R": "right"};
|
var mp = {"U": "up", "D": "down", "L": "left", "R": "right"};
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case "U": case "D": case "L": case "R": for (var i=0;i<nxt;i++) decodeObj.ans.push(mp[c]); break;
|
case "U":
|
||||||
case "I": decodeObj.ans.push("item:"+this._decodeRoute_number2id(nxt)); break;
|
case "D":
|
||||||
case "u": decodeObj.ans.push("unEquip:"+nxt); break;
|
case "L":
|
||||||
case "e": decodeObj.ans.push("equip:"+this._decodeRoute_number2id(nxt)); break;
|
case "R":
|
||||||
case "F": decodeObj.ans.push("fly:"+nxt); break;
|
for (var i = 0; i < nxt; i++) decodeObj.ans.push(mp[c]);
|
||||||
case "C": decodeObj.ans.push("choices:"+nxt); break;
|
break;
|
||||||
case "S": decodeObj.ans.push("shop:"+nxt+":"+this._decodeRoute_getNumber(decodeObj, true)); break;
|
case "I":
|
||||||
case "T": decodeObj.ans.push("turn"); break;
|
decodeObj.ans.push("item:" + this._decodeRoute_number2id(nxt));
|
||||||
case "t": decodeObj.ans.push("turn:"+mp[nxt]); break;
|
break;
|
||||||
case "G": decodeObj.ans.push("getNext"); break;
|
case "u":
|
||||||
case "P": decodeObj.ans.push("input:"+nxt); break;
|
decodeObj.ans.push("unEquip:" + nxt);
|
||||||
case "Q": decodeObj.ans.push("input2:"+nxt); break;
|
break;
|
||||||
case "N": decodeObj.ans.push("no"); break;
|
case "e":
|
||||||
case "M": ++decodeObj.index; decodeObj.ans.push("move:"+nxt+":"+this._decodeRoute_getNumber(decodeObj)); break;
|
decodeObj.ans.push("equip:" + this._decodeRoute_number2id(nxt));
|
||||||
case "K": decodeObj.ans.push("key:"+nxt); break;
|
break;
|
||||||
case "X": decodeObj.ans.push("random:"+nxt); break;
|
case "F":
|
||||||
|
decodeObj.ans.push("fly:" + nxt);
|
||||||
|
break;
|
||||||
|
case "C":
|
||||||
|
decodeObj.ans.push("choices:" + nxt);
|
||||||
|
break;
|
||||||
|
case "S":
|
||||||
|
decodeObj.ans.push("shop:" + nxt + ":" + this._decodeRoute_getNumber(decodeObj, true));
|
||||||
|
break;
|
||||||
|
case "T":
|
||||||
|
decodeObj.ans.push("turn");
|
||||||
|
break;
|
||||||
|
case "t":
|
||||||
|
decodeObj.ans.push("turn:" + mp[nxt]);
|
||||||
|
break;
|
||||||
|
case "G":
|
||||||
|
decodeObj.ans.push("getNext");
|
||||||
|
break;
|
||||||
|
case "P":
|
||||||
|
decodeObj.ans.push("input:" + nxt);
|
||||||
|
break;
|
||||||
|
case "Q":
|
||||||
|
decodeObj.ans.push("input2:" + nxt);
|
||||||
|
break;
|
||||||
|
case "N":
|
||||||
|
decodeObj.ans.push("no");
|
||||||
|
break;
|
||||||
|
case "M":
|
||||||
|
++decodeObj.index;
|
||||||
|
decodeObj.ans.push("move:" + nxt + ":" + this._decodeRoute_getNumber(decodeObj));
|
||||||
|
break;
|
||||||
|
case "K":
|
||||||
|
decodeObj.ans.push("key:" + nxt);
|
||||||
|
break;
|
||||||
|
case "X":
|
||||||
|
decodeObj.ans.push("random:" + nxt);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1034,7 +1075,9 @@ utils.prototype._export = function (floorIds) {
|
|||||||
|
|
||||||
// values
|
// values
|
||||||
content += ["redJewel", "blueJewel", "greenJewel", "redPotion", "bluePotion",
|
content += ["redJewel", "blueJewel", "greenJewel", "redPotion", "bluePotion",
|
||||||
"yellowPotion", "greenPotion", "sword1", "shield1"].map(function (x) {return core.values[x]}).join(" ") + "\n\n";
|
"yellowPotion", "greenPotion", "sword1", "shield1"].map(function (x) {
|
||||||
|
return core.values[x]
|
||||||
|
}).join(" ") + "\n\n";
|
||||||
|
|
||||||
// monster
|
// monster
|
||||||
content += Object.keys(monsterMap).length + "\n";
|
content += Object.keys(monsterMap).length + "\n";
|
||||||
|
|||||||
@ -864,7 +864,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
break;
|
break;
|
||||||
case 51: // 快捷键3: 飞
|
case 51: // 快捷键3: 飞
|
||||||
if (core.hasItem('centerFly')) {
|
if (core.hasItem('centerFly')) {
|
||||||
core.events.tryUseItem('centerFly');
|
core.ui.drawCenterFly();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 52: // 快捷键4:破冰/冰冻/地震/上下楼器/... 其他道具依次判断
|
case 52: // 快捷键4:破冰/冰冻/地震/上下楼器/... 其他道具依次判断
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user