Remove isset

This commit is contained in:
oc 2019-03-17 01:33:40 +08:00
parent 87cd6a09de
commit 415267fc25
9 changed files with 331 additions and 410 deletions

View File

@ -92,7 +92,7 @@ actions.prototype.unregisterAction = function (action, name) {
////// 执行一个用户交互行为 //////
actions.prototype.doRegisteredAction = function (action) {
var actions = this.actions[action];
if (!core.isset(actions)) return false;
if (!actions) return false;
for (var i = 0; i < actions.length; ++i) {
if (actions[i].func.apply(this, Array.prototype.slice.call(arguments, 1)))
return true;
@ -118,7 +118,7 @@ actions.prototype.onkeyDown = function (e) {
}
actions.prototype._sys_onkeyDown = function (e) {
if (!core.isset(core.status.holdingKeys)) core.status.holdingKeys = [];
core.status.holdingKeys = core.status.holdingKeys || []
var isArrow = {37: true, 38: true, 39: true, 40: true}[e.keyCode]
if (isArrow && !core.status.lockControl) {
for (var ii = 0; ii < core.status.holdingKeys.length; ii++) {
@ -382,7 +382,7 @@ actions.prototype._sys_keyUp = function (keyCode, altKey) {
if (!core.status.played)
return true;
this.actionsdata.onKeyUp(keyCode, altKey);
if (core.isset(core.status.automaticRoute) && core.status.automaticRoute.autoHeroMove) {
if (core.status.automaticRoute && core.status.automaticRoute.autoHeroMove) {
core.stopAutomaticRoute();
}
core.stopHero();
@ -712,7 +712,7 @@ actions.prototype._sys_keyDownCtrl = function () {
}
if (core.status.event.id == 'action' && core.status.event.data.type == 'sleep'
&& !core.status.event.data.current.noSkip) {
if (core.isset(core.timeout.sleepTimeout) && Object.keys(core.animateFrame.asyncId).length == 0) {
if (core.timeout.sleepTimeout && Object.keys(core.animateFrame.asyncId).length == 0) {
clearTimeout(core.timeout.sleepTimeout);
core.timeout.sleepTimeout = null;
core.doAction();
@ -747,7 +747,7 @@ actions.prototype._sys_longClick_lockControl = function (x, y) {
// 长按可以跳过等待事件
if (core.status.event.id == 'action' && core.status.event.data.type == 'sleep'
&& !core.status.event.data.current.noSkip) {
if (core.isset(core.timeout.sleepTimeout) && Object.keys(core.animateFrame.asyncId).length == 0) {
if (core.timeout.sleepTimeout && Object.keys(core.animateFrame.asyncId).length == 0) {
clearTimeout(core.timeout.sleepTimeout);
core.timeout.sleepTimeout = null;
core.doAction();
@ -824,9 +824,9 @@ actions.prototype._keyUpCenterFly = function (keycode) {
////// 点击确认框时 //////
actions.prototype._clickConfirmBox = function (x, y) {
if ((x == 4 || x == 5) && y == 7 && core.isset(core.status.event.data.yes))
if ((x == 4 || x == 5) && y == 7 && core.status.event.data.yes)
core.status.event.data.yes();
if ((x == 7 || x == 8) && y == 7 && core.isset(core.status.event.data.no))
if ((x == 7 || x == 8) && y == 7 && core.status.event.data.no)
core.status.event.data.no();
}
@ -845,12 +845,12 @@ actions.prototype._keyUpConfirmBox = function (keycode) {
}
if (keycode == 13 || keycode == 32 || keycode == 67) {
if (core.status.event.selection == 0 && core.isset(core.status.event.data.yes)) {
if (core.status.event.selection == 0 && core.status.event.data.yes) {
core.status.event.selection = null;
core.status.event.data.yes();
return;
}
if (core.status.event.selection == 1 && core.isset(core.status.event.data.no)) {
if (core.status.event.selection == 1 && core.status.event.data.no) {
core.status.event.selection = null;
core.status.event.data.no();
return;
@ -948,7 +948,7 @@ actions.prototype._clickBook = function (x, y) {
}
// 怪物信息
var data = core.status.event.data;
if (core.isset(data) && y < 12) {
if (data != null && y < 12) {
var page = parseInt(data / 6);
var index = 6 * page + parseInt(y / 2);
core.ui.drawBook(index);
@ -983,7 +983,7 @@ actions.prototype._keyUpBook = function (keycode) {
}
if (keycode == 13 || keycode == 32 || keycode == 67) {
var data = core.status.event.data;
if (core.isset(data)) {
if (data != null) {
this._clickBook(6, 2 * (data % 6));
}
return;
@ -1018,7 +1018,7 @@ actions.prototype._keyDownFly = function (keycode) {
}
actions.prototype._getNextFlyFloor = function (delta, index) {
if (!core.isset(index)) index = core.status.event.data;
if (index == null) index = core.status.event.data;
if (delta == 0) return index;
var sign = Math.sign(delta);
delta = Math.abs(delta);
@ -1047,7 +1047,7 @@ actions.prototype._keyUpFly = function (keycode) {
////// 查看地图界面时的点击操作 //////
actions.prototype._clickViewMaps = function (x, y) {
if (!core.isset(core.status.event.data)) {
if (core.status.event.data == null) {
core.ui.drawMaps(core.floorIds.indexOf(core.status.floorId));
return;
}
@ -1112,7 +1112,7 @@ actions.prototype._clickViewMaps = function (x, y) {
////// 查看地图界面时,按下某个键的操作 //////
actions.prototype._keyDownViewMaps = function (keycode) {
if (!core.isset(core.status.event.data)) return;
if (core.status.event.data == null) return;
var floorId = core.floorIds[core.status.event.data.index], mh = core.floors[floorId].height;
@ -1127,7 +1127,7 @@ actions.prototype._keyDownViewMaps = function (keycode) {
////// 查看地图界面时,放开某个键的操作 //////
actions.prototype._keyUpViewMaps = function (keycode) {
if (!core.isset(core.status.event.data)) {
if (core.status.event.data == null) {
core.ui.drawMaps(core.floorIds.indexOf(core.status.floorId));
return;
}
@ -1200,7 +1200,7 @@ actions.prototype._clickQuickShop = function (x, y) {
var topIndex = 6 - parseInt(keys.length / 2);
if (y >= topIndex && y < topIndex + keys.length) {
var reason = core.events.canUseQuickShop(keys[y - topIndex]);
if (!core.flags.enableDisabledShop && core.isset(reason)) {
if (!core.flags.enableDisabledShop && reason) {
core.drawText(reason);
return;
}
@ -1302,7 +1302,7 @@ actions.prototype._clickToolboxIndex = function (index) {
////// 工具栏界面时,按下某个键的操作 //////
actions.prototype._keyDownToolbox = function (keycode) {
if (!core.isset(core.status.event.data)) return;
if (core.status.event.data == null) return;
var tools = Object.keys(core.status.hero.items.tools).sort();
var constants = Object.keys(core.status.hero.items.constants).sort();
@ -1399,7 +1399,7 @@ actions.prototype._keyUpToolbox = function (keycode) {
core.ui.closePanel();
return;
}
if (!core.isset(core.status.event.data)) return;
if (core.status.event.data == null) return;
if (keycode == 13 || keycode == 32 || keycode == 67) {
this._clickToolboxIndex(core.status.event.selection);
@ -1459,7 +1459,7 @@ actions.prototype._clickEquipbox = function (x, y) {
actions.prototype._clickEquipboxIndex = function (index) {
if (index < 6) {
if (index >= core.status.globalAttribute.equipName.length) return;
if (index == core.status.event.selection && core.isset(core.status.hero.equipment[index])) {
if (index == core.status.event.selection && core.status.hero.equipment[index]) {
core.unloadEquip(index);
core.status.route.push("unEquip:" + index);
}
@ -1477,7 +1477,7 @@ actions.prototype._clickEquipboxIndex = function (index) {
////// 装备栏界面时,按下某个键的操作 //////
actions.prototype._keyDownEquipbox = function (keycode) {
if (!core.isset(core.status.event.data)) return;
if (core.status.event.data != null) return;
var equipCapacity = core.status.globalAttribute.equipName.length;
var ownEquipment = Object.keys(core.status.hero.items.equips).sort();
@ -1563,7 +1563,7 @@ actions.prototype._keyUpEquipbox = function (keycode, altKey) {
core.ui.closePanel();
return;
}
if (!core.isset(core.status.event.data.selectId)) return;
if (!core.status.event.data.selectId) return;
if (keycode == 13 || keycode == 32 || keycode == 67) {
this._clickEquipboxIndex(core.status.event.selection);
@ -1905,7 +1905,7 @@ actions.prototype._clickSyncSave = function (x, y) {
alert("游戏版本不一致!");
return;
}
if (!core.isset(obj.data)) {
if (!obj.data) {
alert("无效的存档!");
return;
}
@ -2023,7 +2023,7 @@ actions.prototype._clickLocalSaveSelect = function (x, y) {
var selection = y - topIndex;
if (selection < 2) {
core.control.getSaves(selection == 0 ? null : core.saves.saveIndex, function (saves) {
if (core.isset(saves)) {
if (saves) {
var content = {
"name": core.firstData.name,
"version": core.firstData.version,
@ -2408,7 +2408,7 @@ actions.prototype.clearPaint = function () {
actions.prototype.savePaint = function () {
var data = {};
for (var floorId in core.paint) {
if (core.isset(core.paint[floorId]))
if (core.paint[floorId])
data[floorId] = lzw_decode(core.paint[floorId]);
}
core.download(core.firstData.name + ".h5paint", JSON.stringify({
@ -2423,19 +2423,19 @@ actions.prototype.loadPaint = function () {
alert("绘图文件和游戏不一致!");
return;
}
if (!core.isset(obj.paint)) {
if (!obj.paint) {
alert("无效的绘图文件!");
return;
}
core.paint = {};
for (var floorId in obj.paint) {
if (core.isset(obj.paint[floorId]))
if (obj.paint[floorId])
core.paint[floorId] = lzw_encode(obj.paint[floorId]);
}
core.clearMap('paint');
var value = core.paint[core.status.floorId];
if (core.isset(value)) value = lzw_decode(value).split(",");
if (value) value = lzw_decode(value).split(",");
core.utils.decodeCanvas(value, 32 * core.bigmap.width, 32 * core.bigmap.height);
core.drawImage('paint', core.bigmap.tempCanvas.canvas, 0, 0);

View File

@ -93,8 +93,8 @@ function core() {
canvas: ["bg", "event", "event2", "fg", "damage"],
offsetX: 0, // in pixel
offsetY: 0,
width: 13, // map width and height
height: 13,
width: this.__SIZE__, // map width and height
height: this.__SIZE__,
tempCanvas: null, // A temp canvas for drawing
}
this.paint = {};
@ -229,7 +229,7 @@ core.prototype.init = function (coreData, callback) {
if (!core.flags.enableLevelUp)
core.flags.levelUpLeftMode = false;
if (core.isset(core.firstData.shops)) {
if (core.firstData.shops) {
core.firstData.shops.forEach(function (t) {
core.initStatus.shops[t.id] = t;
})
@ -274,7 +274,7 @@ core.prototype.init = function (coreData, callback) {
}
var chrome = /Chrome\/(\d+)\./i.exec(navigator.userAgent);
if (core.isset(chrome) && parseInt(chrome[1]) >= 50)
if (chrome && parseInt(chrome[1]) >= 50)
core.platform.isChrome = true;
core.platform.isSafari = /Safari/i.test(navigator.userAgent) && !/Chrome/i.test(navigator.userAgent);
core.platform.isQQ = /QQ/i.test(navigator.userAgent);
@ -327,7 +327,7 @@ core.prototype.init = function (coreData, callback) {
core.readFileContent(core.platform.fileReader.result);
};
core.platform.fileReader.onerror = function () {
if (core.isset(core.platform.errorCallback))
if (core.platform.errorCallback)
core.platform.errorCallback();
}
}
@ -379,7 +379,7 @@ core.prototype.init = function (coreData, callback) {
if (main.mode == 'play')
core.events.initGame();
if (core.isset(functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.plugins)) {
if (functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.plugins) {
core.plugin = new function () {
this.__renderFrameFuncs = [];
};
@ -390,7 +390,7 @@ core.prototype.init = function (coreData, callback) {
core.showStartAnimate();
if (core.isset(callback)) callback();
if (callback) callback();
});
}

View File

@ -24,7 +24,7 @@ enemys.prototype.getEnemys = function () {
////// 判断是否含有某特殊属性 //////
enemys.prototype.hasSpecial = function (special, test) {
if (!core.isset(special)) return false;
if (special == null) return false;
if (special instanceof Array) {
return special.indexOf(test) >= 0;
@ -38,7 +38,7 @@ enemys.prototype.hasSpecial = function (special, test) {
return this.hasSpecial(core.material.enemys[special], test);
}
if (core.isset(special.special)) {
if (special.special != null) {
return this.hasSpecial(special.special, test);
}
@ -52,12 +52,12 @@ enemys.prototype.getSpecials = function () {
////// 获得所有特殊属性的名称 //////
enemys.prototype.getSpecialText = function (enemy) {
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
if (!core.isset(enemy)) return [];
if (!enemy) return [];
var special = enemy.special;
var text = [];
var specials = this.getSpecials();
if (core.isset(specials)) {
if (specials) {
for (var i = 0; i < specials.length; i++) {
if (this.hasSpecial(special, specials[i][0]))
text.push(this._calSpecialContent(enemy, specials[i][1]));
@ -70,8 +70,8 @@ enemys.prototype.getSpecialText = function (enemy) {
enemys.prototype.getSpecialHint = function (enemy, special) {
var specials = this.getSpecials();
if (!core.isset(special)) {
if (!core.isset(specials)) return [];
if (special == null) {
if (specials == null) return [];
var hints = [];
for (var i = 0; i < specials.length; i++) {
if (this.hasSpecial(enemy, specials[i][0]))
@ -80,7 +80,7 @@ enemys.prototype.getSpecialHint = function (enemy, special) {
return hints;
}
if (!core.isset(specials)) return "";
if (specials == null) return "";
for (var i = 0; i < specials.length; i++) {
if (special == specials[i][0])
return this._calSpecialContent(enemy, specials[i][1]) + "" + this._calSpecialContent(enemy, specials[i][2]);
@ -304,8 +304,7 @@ enemys.prototype.getCurrentEnemys = function (floorId) {
var enemys = [], used = {};
var mapBlocks = core.status.maps[floorId].blocks;
for (var b = 0; b < mapBlocks.length; b++) {
if (core.isset(mapBlocks[b].event) && !mapBlocks[b].disable
&& mapBlocks[b].event.cls.indexOf('enemy') == 0) {
if (!mapBlocks[b].disable && mapBlocks[b].event.cls.indexOf('enemy') == 0) {
this._getCurrentEnemys_addEnemy(mapBlocks[b].event.id, enemys, used, floorId);
}
}
@ -314,14 +313,10 @@ enemys.prototype.getCurrentEnemys = function (floorId) {
enemys.prototype._getCurrentEnemys_getEnemy = function (enemyId) {
var enemy = core.material.enemys[enemyId];
if (!core.isset(enemy)) return null;
if (!enemy) return null;
// 检查displayIdInBook
var tmpId = enemy.displayIdInBook;
if (core.isset(core.material.enemys[tmpId])) {
enemy = core.material.enemys[tmpId];
}
return enemy;
return core.material.enemys[enemy.displayIdInBook] || enemy;
}
enemys.prototype._getCurrentEnemys_addEnemy = function (enemyId, enemys, used, floorId) {

View File

@ -27,7 +27,7 @@ events.prototype.startGame = function (hard, seed, route, callback) {
if (main.mode != 'play') return;
// 无动画的开始游戏
if (core.flags.startUsingCanvas || core.isset(route)) {
if (core.flags.startUsingCanvas || route != null) {
core.dom.startPanel.style.display = 'none';
this._startGame_start(hard, seed, route, callback);
}
@ -45,7 +45,7 @@ events.prototype._startGame_start = function (hard, seed, route, callback) {
core.setHeroLoc('x', -1);
core.setHeroLoc('y', -1);
if (core.isset(seed)) {
if (seed != null) {
core.setFlag('__seed__', seed);
core.setFlag('__rand__', seed);
}
@ -67,7 +67,7 @@ events.prototype._startGame_start = function (hard, seed, route, callback) {
core.events._startGame_afterStart(nowLoc, callback);
});
if (core.isset(route)) core.startReplay(route);
if (route != null) core.startReplay(route);
}
events.prototype._startGame_afterStart = function (nowLoc, callback) {
@ -117,7 +117,7 @@ events.prototype.gameOver = function (ending, fromReplay, norank) {
core.setWeather();
core.ui.closePanel();
if (main.isCompetition && core.isset(ending)) {
if (main.isCompetition && ending != null) {
if (ending == "") ending = "恭喜通关";
ending += "[比赛]";
}
@ -136,7 +136,7 @@ events.prototype.gameOver = function (ending, fromReplay, norank) {
events.prototype._gameOver_confirmUpload = function (ending, norank) {
core.ui.closePanel();
if (!core.isset(ending)) {
if (ending == null) {
this._gameOver_confirmDownload(ending);
return;
}
@ -153,7 +153,7 @@ events.prototype._gameOver_confirmUpload = function (ending, norank) {
events.prototype._gameOver_doUpload = function (username, ending, norank) {
var hp = core.status.hero.hp;
if (!core.isset(username)) hp = 1;
if (username == null) hp = 1;
core.ui.closePanel();
// upload
var formData = new FormData();
@ -206,7 +206,7 @@ events.prototype._gameOver_confirmDownload = function (ending) {
}
events.prototype._gameOver_askRate = function (ending) {
if (!core.isset(ending)) {
if (ending == null) {
core.restart();
return;
}
@ -275,7 +275,7 @@ events.prototype._trigger = function (x, y) {
events.prototype._trigger_ignoreChangeFloor = function (block) {
var able = core.flags.ignoreChangeFloor;
if (core.isset(block.event.data) && core.isset(block.event.data.ignoreChangeFloor))
if (block.event.data && block.event.data.ignoreChangeFloor != null)
able = block.event.data.ignoreChangeFloor;
if (able) {
if (core.isReplaying()) {
@ -302,14 +302,14 @@ events.prototype._sys_battle = function (data, callback) {
events.prototype.battle = function (id, x, y, force, callback) {
core.saveAndStopAutomaticRoute();
id = id || core.getBlockId(x, y);
if (!core.isset(id)) return core.clearContinueAutomaticRoute(callback);
if (!id) return core.clearContinueAutomaticRoute(callback);
// 非强制战斗
if (!core.enemys.canBattle(id, x, y) && !force && !core.isset(core.status.event.id)) {
if (!core.enemys.canBattle(id, x, y) && !force && !core.status.event.id) {
core.drawTip("你打不过此怪物!");
return core.clearContinueAutomaticRoute(callback);
}
// 自动存档
if (!core.isset(core.status.event.id)) core.autosave(true);
if (!core.status.event.id) core.autosave(true);
// 战前事件
if (!this.beforeBattle(id, x, y))
return core.clearContinueAutomaticRoute(callback);
@ -344,7 +344,7 @@ events.prototype.openDoor = function (id, x, y, needKey, callback) {
events.prototype._openDoor_check = function (id, x, y, needKey) {
// 是否存在门或暗墙
if (!core.terrainExists(x, y, id) || !(id.endsWith("Door") || id.endsWith("Wall"))
|| !core.isset(core.material.icons.animates[id])) {
|| !core.material.icons.animates[id]) {
core.clearContinueAutomaticRoute();
return false;
}
@ -428,10 +428,8 @@ events.prototype.getNextItem = function () {
events.prototype._sys_changeFloor = function (data, callback) {
data = data.event.data;
var heroLoc = {};
if (core.isset(data.loc))
heroLoc = {'x': data.loc[0], 'y': data.loc[1]};
if (core.isset(data.direction))
heroLoc.direction = data.direction;
if (data.loc) heroLoc = {'x': data.loc[0], 'y': data.loc[1]};
if (data.direction) heroLoc.direction = data.direction;
if (core.status.event.id != 'action') core.status.event.id = null;
core.changeFloor(data.floorId, data.stair, heroLoc, data.time, callback);
}
@ -473,8 +471,8 @@ events.prototype._changeFloor_getInfo = function (floorId, stair, heroLoc, time)
}
if (main.mode != 'play' || core.isReplaying()) time = 0;
if (!core.isset(time)) time = core.values.floorChangeTime;
if (!core.isset(time)) time = 800;
if (time == null) time = core.values.floorChangeTime;
if (time == null) time = 800;
if (time < 100) time = 0;
time /= 20;
@ -486,11 +484,11 @@ events.prototype._changeFloor_getInfo = function (floorId, stair, heroLoc, time)
}
events.prototype._changeFloor_getHeroLoc = function (floorId, stair, heroLoc) {
if (!core.isset(heroLoc))
if (!heroLoc)
heroLoc = core.clone(core.status.hero.loc);
if (core.isset(stair)) {
if (stair) {
// 检查该层地图的 upFloor & downFloor
if (core.isset(core.status.maps[floorId][stair])) {
if (core.status.maps[floorId][stair]) {
heroLoc.x = core.status.maps[floorId][stair][0];
heroLoc.y = core.status.maps[floorId][stair][1];
}
@ -506,7 +504,7 @@ events.prototype._changeFloor_getHeroLoc = function (floorId, stair, heroLoc) {
}
}
['x', 'y', 'direction'].forEach(function (name) {
if (!core.isset(heroLoc[name]))
if (!heroLoc[name])
heroLoc[name] = core.getHeroLoc(name);
});
return heroLoc;
@ -663,7 +661,7 @@ events.prototype._sys_ski = function (data, callback) {
////// 滑冰 //////
events.prototype.ski = function (direction) {
if (!core.isset(direction))
if (!direction)
direction = core.status.automaticRoute.lastDirection || core.getHeroLoc('direction');
if (core.status.event.id != 'ski') {
core.waitHeroToStop(function () {
@ -688,7 +686,7 @@ events.prototype._sys_action = function (data, callback) {
if (ex == core.nextX() && ey == core.nextY()) {
var dir = {"up": "down", "down": "up", "left": "right", "right": "left"}[core.getHeroLoc('direction')];
var id = data.event.id, toId = (data.event.faceIds || {})[dir];
if (core.isset(toId) && id != toId) {
if (toId && id != toId) {
var number = core.icons.getNumberById(toId);
if (number > 0)
core.setBlock(number, ex, ey);
@ -724,7 +722,7 @@ events.prototype.doEvent = function (data, x, y, prefix) {
////// 开始执行一系列自定义事件 //////
events.prototype.doEvents = function (list, x, y, callback) {
if (!core.isset(list)) return;
if (!list) return;
if (!(list instanceof Array)) {
list = [list];
}
@ -738,11 +736,11 @@ events.prototype.doEvents = function (list, x, y, callback) {
events.prototype.setEvents = function (list, x, y, callback) {
var data = core.status.event.data || {};
if (core.isset(list))
if (list)
data.list = [{todo: core.clone(list), total: core.clone(list), condition: "false"}];
if (core.isset(x)) data.x = x;
if (core.isset(y)) data.y = y;
if (core.isset(callback)) data.callback = callback;
if (x != null) data.x = x;
if (y != null) data.y = y;
if (callback) data.callback = callback;
core.status.event = {id: 'action', data: data};
}
@ -757,7 +755,7 @@ events.prototype.doAction = function () {
if (this._doAction_finishEvents()) return;
// 当前点坐标和前缀
var x = core.status.event.data.x, y = core.status.event.data.y;
var prefix = [core.status.floorId || "f", core.isset(x) ? x : "x", core.isset(y) ? y : "y"].join("@");
var prefix = [core.status.floorId || "f", x != null ? x : "x", y != null ? y : "y"].join("@");
var current = core.status.event.data.list[0];
if (this._popEvents(current, prefix)) return;
// 当前要执行的事件
@ -775,8 +773,7 @@ events.prototype._doAction_finishEvents = function () {
if (core.status.event.data.list.length == 0) {
var callback = core.status.event.data.callback;
core.ui.closePanel();
if (core.isset(callback))
callback();
if (callback) callback();
core.replay();
return true;
}
@ -804,7 +801,7 @@ events.prototype.insertAction = function (action, x, y, callback) {
// ------ 判定commonEvent
var commonEvent = this.getCommonEvent(action);
if (commonEvent instanceof Array) action = commonEvent;
if (!core.isset(action)) return;
if (!action) return;
if (core.status.event.id != 'action') {
this.doEvents(action, x, y, callback);
@ -817,13 +814,13 @@ events.prototype.insertAction = function (action, x, y, callback) {
////// 获得一个公共事件 //////
events.prototype.getCommonEvent = function (name) {
if (!core.isset(name) || typeof name !== 'string') return null;
if (!name || typeof name !== 'string') return null;
return this.commonEvent[name] || null;
}
////// 恢复一个事件 //////
events.prototype.recoverEvents = function (data) {
if (core.isset(data)) {
if (data) {
core.ui.closePanel();
core.lockControl();
core.status.event.id = 'action';
@ -897,16 +894,16 @@ events.prototype._action_comment = function (data, x, y, prefix) {
events.prototype._action_setText = function (data, x, y, prefix) {
["position", "offset", "bold", "titlefont", "textfont", "time"].forEach(function (t) {
if (core.isset(data[t])) core.status.textAttribute[t] = data[t];
if (data[t] != null) core.status.textAttribute[t] = data[t];
});
["background", "title", "text"].forEach(function (t) {
if (core.isset(data[t]) && (data[t] instanceof Array) && data[t].length >= 3) {
if ((data[t] instanceof Array) && data[t].length >= 3) {
if (data[t].length == 3) data[t].push(1);
core.status.textAttribute[t] = data[t];
}
if (t == 'background' && core.isset(data[t])) {
if (t == 'background') {
var img = core.material.images.images[data[t]];
if (core.isset(img) && img.width == 192 && img.height == 128) {
if (img && img.width == 192 && img.height == 128) {
core.status.textAttribute[t] = data[t];
}
}
@ -1035,10 +1032,8 @@ events.prototype._action_changePos = function (data, x, y, prefix) {
events.prototype._action_showImage = function (data, x, y, prefix) {
var loc = this.__action_getLoc(data.loc, 0, 0, prefix);
if (core.isReplaying()) data.time = 0;
var image = core.material.images.images[data.image];
if (!core.isset(image)) return core.doAction();
this.__action_doAsyncFunc(data.async || data.time == 0, this.showImage,
data.code, image, loc[0], loc[1], data.dw, data.dh, data.opacity, data.time);
data.code, data.image, loc[0], loc[1], data.dw, data.dh, data.opacity, data.time);
}
events.prototype._action_showTextImage = function (data, x, y, prefix) {
@ -1157,17 +1152,14 @@ events.prototype._action_trigger = function (data, x, y, prefix) {
}
events.prototype._action_insert = function (data, x, y, prefix) {
if (core.isset(data.name)) { // 公共事件
if (data.name) { // 公共事件
core.insertAction(this.getCommonEvent(data.name));
}
else {
var loc = this.__action_getLoc(data.loc, x, y, prefix);
var floorId = data.floorId || core.status.floorId;
var event = core.floors[floorId].events[loc[0] + "," + loc[1]];
if (core.isset(event)) {
if (core.isset(event.data)) event = event.data;
this.insertAction(event);
}
if (event) this.insertAction(event.data || event);
}
core.doAction();
}
@ -1285,8 +1277,7 @@ events.prototype.__action_getInput = function (hint, isText) {
}
else {
core.interval.onDownInterval = 'tmp';
value = prompt(core.replaceText(hint));
if (!core.isset(value)) value = "";
value = prompt(core.replaceText(hint)) || "";
}
return value;
}
@ -1514,7 +1505,7 @@ events.prototype._action_exit = function (data, x, y, prefix) {
////// 跟随 //////
events.prototype.follow = function (name) {
core.status.hero.followers = core.status.hero.followers || [];
if (core.isset(core.material.images.images[name])
if (core.material.images.images[name]
&& core.material.images.images[name].width == 128) {
core.status.hero.followers.push({"img": name});
core.control.gatherFollowers();
@ -1526,7 +1517,7 @@ events.prototype.follow = function (name) {
////// 取消跟随 //////
events.prototype.unfollow = function (name) {
core.status.hero.followers = core.status.hero.followers || [];
if (!core.isset(name)) {
if (!name) {
core.status.heroMoving.followers = [];
}
else {
@ -1685,7 +1676,7 @@ events.prototype.moveImage = function (code, to, opacityVal, time, callback) {
}
var getOrDefault = function (a, b) {
a = core.calValue(a);
return core.isset(a) ? a : b;
return a != null ? a : b;
}
var canvas = core.dymCanvas[name].canvas;
var fromX = parseFloat(canvas.getAttribute("_left")),
@ -1728,7 +1719,7 @@ events.prototype.setVolume = function (value, time, callback) {
if (core.musicStatus.playingBgm)
core.material.bgms[core.musicStatus.playingBgm].volume = value;
}
if (!core.isset(time) || time < 100) {
if (!time || time < 100) {
set(value);
if (callback) callback();
return;
@ -1753,7 +1744,7 @@ events.prototype.vibrate = function (time, callback) {
if (callback) callback();
return;
}
if (!core.isset(time) || time < 1000) time = 1000;
if (!time || time < 1000) time = 1000;
// --- 将time调整为500的倍数上整不然会出错
time = Math.ceil(time / 500) * 500;
var shakeInfo = {duration: time * 3 / 50, speed: 5, power: 5, direction: 1, shake: 0};
@ -1880,12 +1871,12 @@ events.prototype.checkLvUp = function () {
}
events.prototype._checkLvUp_check = function () {
if (!core.flags.enableLevelUp || !core.isset(core.firstData.levelUp)
if (!core.flags.enableLevelUp || !core.firstData.levelUp
|| core.status.hero.lv >= core.firstData.levelUp.length) return null;
// 计算下一个所需要的数值
var next = (core.firstData.levelUp[core.status.hero.lv] || {});
var need = core.calValue(next.need);
if (!core.isset(need)) return null;
if (need == null) return null;
if (core.status.hero.experience >= need) {
// 升级
core.status.hero.lv++;

View File

@ -64,7 +64,7 @@ items.prototype.getItemEffectTip = function (itemId) {
////// 使用道具 //////
items.prototype.useItem = function (itemId, noRoute, callback) {
if (!this.canUseItem(itemId)) {
if (core.isset(callback)) callback();
if (callback) callback();
return;
}
// 执行道具效果
@ -73,7 +73,7 @@ items.prototype.useItem = function (itemId, noRoute, callback) {
this._afterUseItem(itemId);
// 记录路线
if (!noRoute) core.status.route.push("item:" + itemId);
if (core.isset(callback)) callback();
if (callback) callback();
}
items.prototype._useItemEffect = function (itemId) {
@ -127,8 +127,7 @@ items.prototype.canUseItem = function (itemId) {
////// 获得某个物品的个数 //////
items.prototype.itemCount = function (itemId) {
if (!core.isset(core.status.hero)) return 0;
if (!core.isset(itemId) || !core.isset(core.material.items[itemId])) return 0;
if (!core.material.items[itemId]) return 0;
var itemCls = core.material.items[itemId].cls;
if (itemCls == "items") return 0;
return core.status.hero.items[itemCls][itemId] || 0;
@ -141,12 +140,9 @@ items.prototype.hasItem = function (itemId) {
////// 是否装备某件装备 //////
items.prototype.hasEquip = function (itemId) {
if (!core.isset(core.status.hero)) return null;
if (!(core.material.items[itemId] || {}).equip) return null;
if (!core.isset(itemId)) return null;
if (!core.isset((core.material.items[itemId] || {}).equip)) return null;
for (var i in core.status.hero.equipment || [])
for (var i in core.status.hero.equipment)
if (core.status.hero.equipment[i] == itemId)
return true;
return false
@ -154,19 +150,15 @@ items.prototype.hasEquip = function (itemId) {
////// 获得某个装备类型的当前装备 //////
items.prototype.getEquip = function (equipType) {
if (!core.isset(core.status.hero)) return null;
return (core.status.hero.equipment || [])[equipType] || null;
return core.status.hero.equipment[equipType] || null;
}
////// 设置某个物品的个数 //////
items.prototype.setItem = function (itemId, itemNum) {
if (!core.isset(core.status.hero)) return null;
itemNum = itemNum || 0;
var itemCls = core.material.items[itemId].cls;
if (itemCls == 'items') return;
if (!core.isset(core.status.hero.items[itemCls])) {
core.status.hero.items[itemCls] = {};
}
core.status.hero.items[itemCls][itemId] = itemNum;
if (core.status.hero.items[itemCls][itemId] <= 0) {
if (itemCls != 'keys') delete core.status.hero.items[itemCls][itemId];
@ -177,8 +169,7 @@ items.prototype.setItem = function (itemId, itemNum) {
////// 删除某个物品 //////
items.prototype.removeItem = function (itemId, itemNum) {
if (!core.isset(core.status.hero)) return null;
if (!core.isset(itemNum)) itemNum = 1;
if (itemNum == null) itemNum = 1;
if (!core.hasItem(itemId)) return false;
var itemCls = core.material.items[itemId].cls;
core.status.hero.items[itemCls][itemId] -= itemNum;
@ -192,16 +183,11 @@ items.prototype.removeItem = function (itemId, itemNum) {
////// 增加某个物品的个数 //////
items.prototype.addItem = function (itemId, itemNum) {
if (!core.isset(core.status.hero)) return null;
if (!core.isset(itemNum)) itemNum = 1;
if (itemNum == null) itemNum = 1;
var itemData = core.material.items[itemId];
var itemCls = itemData.cls;
if (itemCls == 'items') return;
if (!core.isset(core.status.hero.items[itemCls])) {
core.status.hero.items[itemCls] = {};
core.status.hero.items[itemCls][itemId] = 0;
}
else if (!core.isset(core.status.hero.items[itemCls][itemId])) {
if (core.status.hero.items[itemCls][itemId] == null) {
core.status.hero.items[itemCls][itemId] = 0;
}
core.status.hero.items[itemCls][itemId] += itemNum;
@ -227,7 +213,7 @@ items.prototype.getEquipTypeById = function (equipId) {
items.prototype.getEquipTypeByName = function (name) {
var names = core.status.globalAttribute.equipName;
for (var i = 0; i < names.length; ++i) {
if (names[i] === name && !core.isset((core.status.hero.equipment || [])[i])) {
if (names[i] === name && !core.status.hero.equipment[i]) {
return i;
}
}
@ -238,7 +224,7 @@ items.prototype.getEquipTypeByName = function (name) {
items.prototype.canEquip = function (equipId, hint) {
// 装备是否合法
var equip = core.material.items[equipId] || {};
if (!core.isset(equip.equip)) {
if (!equip.equip) {
if (hint) core.drawTip("不合法的装备!");
return false;
}
@ -251,7 +237,7 @@ items.prototype.canEquip = function (equipId, hint) {
// 可装备条件
var condition = this.equipCondition[equipId];
if (core.isset(condition) && condition.length > 0) {
if (condition) {
try {
if (!eval(condition)) {
if (hint) core.drawTip("当前不可换上" + equip.name);
@ -268,10 +254,8 @@ items.prototype.canEquip = function (equipId, hint) {
////// 换上 //////
items.prototype.loadEquip = function (equipId, callback) {
if (!core.isset(core.status.hero)) return null;
if (!core.isset(core.status.hero.equipment)) core.status.hero.equipment = [];
if (!this.canEquip(equipId, true)) {
if (core.isset(callback)) callback();
if (callback) callback();
return;
}
@ -279,7 +263,7 @@ items.prototype.loadEquip = function (equipId, callback) {
var type = this.getEquipTypeById(equipId);
if (type < 0) {
core.drawTip("当前没有" + loadEquip.equip.type + "的空位!");
if (core.isset(callback)) callback();
if (callback) callback();
return;
}
@ -288,12 +272,9 @@ items.prototype.loadEquip = function (equipId, callback) {
////// 卸下 //////
items.prototype.unloadEquip = function (equipType, callback) {
if (!core.isset(core.status.hero)) return null;
if (!core.isset(core.status.hero.equipment)) core.status.hero.equipment = [];
var unloadEquipId = core.status.hero.equipment[equipType];
if (!core.isset(unloadEquipId)) {
if (core.isset(callback)) callback();
if (!unloadEquipId) {
if (callback) callback();
return;
}
@ -302,13 +283,13 @@ items.prototype.unloadEquip = function (equipType, callback) {
items.prototype.compareEquipment = function (compareEquipId, beComparedEquipId) {
var compareAtk = 0, compareDef = 0, compareMdef = 0;
if (core.isset(compareEquipId)) {
if (compareEquipId) {
var compareEquip = core.material.items[compareEquipId];
compareAtk += (compareEquip.equip || {}).atk || 0;
compareDef += (compareEquip.equip || {}).def || 0;
compareMdef += (compareEquip.equip || {}).mdef || 0;
}
if (core.isset(beComparedEquipId)) {
if (beComparedEquipId) {
var beComparedEquip = core.material.items[beComparedEquipId];
compareAtk -= (beComparedEquip.equip || {}).atk || 0;
compareDef -= (beComparedEquip.equip || {}).def || 0;
@ -334,15 +315,15 @@ items.prototype._loadEquipEffect = function (equipId, unloadEquipId, isPercentag
items.prototype._realLoadEquip = function (type, loadId, unloadId, callback) {
var loadEquip = core.material.items[loadId] || {}, unloadEquip = core.material.items[unloadId] || {};
if (!core.isset(loadEquip.equip)) loadEquip.equip = {};
if (!core.isset(unloadEquip.equip)) unloadEquip.equip = {};
loadEquip.equip = loadEquip.equip || {};
unloadEquip.equip = unloadEquip.equip || {}
var loadPercentage = loadEquip.equip.percentage, unloadPercentage = unloadEquip.equip.percentage;
if (loadPercentage != null && unloadPercentage != null && loadPercentage != unloadPercentage) {
this.unloadEquip(type);
this.loadEquip(loadId);
if (core.isset(callback)) callback();
if (callback) callback();
return;
}
@ -361,12 +342,11 @@ items.prototype._realLoadEquip = function (type, loadId, unloadId, callback) {
if (loadId) core.drawTip("已装备上" + loadEquip.name, core.material.icons.items[loadId]);
else if (unloadId) core.drawTip("已卸下" + unloadEquip.name, core.material.icons.items[unloadId]);
if (core.isset(callback)) callback();
if (callback) callback();
}
////// 保存装备 //////
items.prototype.quickSaveEquip = function (index) {
if (!core.isset(core.status.hero.equipment)) core.status.hero.equipment = [];
var saveEquips = core.getFlag("saveEquips", []);
saveEquips[index] = core.clone(core.status.hero.equipment);
core.setFlag("saveEquips", saveEquips);
@ -376,7 +356,7 @@ items.prototype.quickSaveEquip = function (index) {
////// 读取装备 //////
items.prototype.quickLoadEquip = function (index) {
var current = core.getFlag("saveEquips", [])[index];
if (!core.isset(current)) {
if (!current) {
core.drawTip(index + "号套装不存在");
return;
}
@ -384,21 +364,20 @@ items.prototype.quickLoadEquip = function (index) {
var equipSize = core.status.globalAttribute.equipName.length;
for (var i = 0; i < equipSize; i++) {
var v = current[i];
if (core.isset(v) && !this.canEquip(v, true))
if (v && !this.canEquip(v, true))
return;
}
// 快速换装
if (!core.isset(core.status.hero.equipment)) core.status.hero.equipment = [];
for (var i = 0; i < equipSize; i++) {
var now = core.status.hero.equipment[i] || null;
if (now != null) {
var now = core.status.hero.equipment[i];
if (now) {
this.unloadEquip(i);
core.status.route.push("unEquip:" + i);
}
}
for (var i = 0; i < equipSize; i++) {
var to = current[i] || null;
if (to != null) {
var to = current[i];
if (to) {
this.loadEquip(to);
core.status.route.push("equip:" + to);
}

View File

@ -42,7 +42,7 @@ loader.prototype._loadIcons = function () {
for (var key in core.statusBar.icons) {
if (typeof core.statusBar.icons[key] == 'number') {
core.statusBar.icons[key] = images[core.statusBar.icons[key]];
if (core.isset(core.statusBar.image[key]))
if (core.statusBar.image[key] != null)
core.statusBar.image[key].src = core.statusBar.icons[key].src;
}
}
@ -82,7 +82,7 @@ loader.prototype._loadAutotiles = function (callback) {
loader.prototype._loadTilesets = function (callback) {
core.material.images.tilesets = {};
if (!core.isset(core.tilesets)) core.tilesets = [];
core.tilesets = core.tilesets || [];
core.loader.loadImages(core.clone(core.tilesets), core.material.images.tilesets, function () {
// 检查宽高是32倍数如果出错在控制台报错
for (var imgName in core.material.images.tilesets) {
@ -99,8 +99,8 @@ loader.prototype._loadTilesets = function (callback) {
}
loader.prototype.loadImages = function (names, toSave, callback) {
if (!core.isset(names) || names.length == 0) {
if (core.isset(callback)) callback();
if (!names || names.length == 0) {
if (callback) callback();
return;
}
var items = 0;
@ -111,7 +111,7 @@ loader.prototype.loadImages = function (names, toSave, callback) {
items++;
core.loader._setStartProgressVal(items * (100 / names.length));
if (items == names.length) {
if (core.isset(callback)) callback();
if (callback) callback();
}
})
}
@ -144,7 +144,7 @@ loader.prototype._loadAnimates = function () {
data.images = [];
data.images_rev = [];
content.bitmaps.forEach(function (t2) {
if (!core.isset(t2) || t2 == "") {
if (!t2) {
data.images.push(null);
}
else {
@ -238,7 +238,7 @@ loader.prototype.loadOneSound = function (name) {
}
loader.prototype.loadBgm = function (name) {
if (!core.isset(core.material.bgms[name])) return;
if (!core.material.bgms[name]) return;
// 如果没开启音乐,则不预加载
if (!core.musicStatus.bgmStatus) return;
// 是否已经预加载过
@ -265,7 +265,7 @@ loader.prototype._preloadBgm = function (bgm) {
}
loader.prototype.freeBgm = function (name) {
if (!core.isset(core.material.bgms[name])) return;
if (!core.material.bgms[name]) return;
// 从cachedBgms中删除
core.musicStatus.cachedBgms = core.musicStatus.cachedBgms.filter(function (t) {
return t != name;

View File

@ -10,7 +10,7 @@ maps.prototype._init = function () {
}
maps.prototype._setFloorSize = function (floorId) {
if (!core.isset(floorId)) {
if (!floorId) {
core.floorIds.forEach(function (floorId) {
core.maps._setFloorSize(floorId);
});
@ -25,14 +25,14 @@ maps.prototype._setFloorSize = function (floorId) {
////// 加载某个楼层(从剧本或存档中) //////
maps.prototype.loadFloor = function (floorId, map) {
var floor = core.floors[floorId];
if (!core.isset(map)) map = floor.map;
if (!map) map = floor.map;
if (map instanceof Array) {
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 (core.isset(map[e])) content[e] = core.clone(map[e]);
if (map[e] != null) content[e] = core.clone(map[e]);
else content[e] = core.clone(floor[e]);
});
map = this.decompressMap(map.map, floorId);
@ -98,18 +98,18 @@ maps.prototype.initBlock = function (x, y, id, addInfo, eventFloor) {
////// 添加一些信息到block上 //////
maps.prototype._addInfo = function (block) {
if (block.event.cls.indexOf("enemy") == 0 && !core.isset(block.event.trigger)) {
if (block.event.cls.indexOf("enemy") == 0 && !block.event.trigger) {
block.event.trigger = 'battle';
}
if (block.event.cls == 'items' && !core.isset(block.event.trigger)) {
if (block.event.cls == 'items' && !block.event.trigger) {
block.event.trigger = 'getItem';
}
if (!core.isset(block.event.noPass)) {
if (block.event.noPass == null) {
if (block.event.cls != 'items') {
block.event.noPass = true;
}
}
if (!core.isset(block.event.animate)) {
if (block.event.animate == null) {
block.event.animate = core.icons._getAnimateFrames(block.event.cls, false);
}
block.event.height = 32;
@ -119,7 +119,7 @@ maps.prototype._addInfo = function (block) {
////// 向该楼层添加剧本的自定义事件 //////
maps.prototype._addEvent = function (block, x, y, event) {
if (!core.isset(event)) return;
if (!event) return;
// event是字符串或数组
if (typeof event == "string") {
event = {"data": [event]};
@ -127,11 +127,10 @@ maps.prototype._addEvent = function (block, x, y, event) {
else if (event instanceof Array) {
event = {"data": event};
}
if (!core.isset(event.data))
event.data = [];
event.data = event.data || [];
// 覆盖enable
if (!core.isset(block.disable) && core.isset(event.enable)) {
if (block.disable == null && event.enable != null) {
block.disable = !event.enable;
}
// 覆盖animate
@ -140,12 +139,12 @@ maps.prototype._addEvent = function (block, x, y, event) {
}
// 覆盖所有属性
for (var key in event) {
if (key != "enable" && key != "animate" && core.isset(event[key])) {
if (key != "enable" && key != "animate" && event[key] != null) {
block.event[key] = core.clone(event[key]);
}
}
// 给无trigger的增加trigger:action
if (!core.isset(block.event.trigger)) {
if (!block.event.trigger) {
block.event.trigger = 'action';
}
}
@ -167,12 +166,12 @@ maps.prototype._initFloorMap = function (floorId) {
var mh = core.floors[floorId].height;
for (var x = 0; x < mh; x++) {
if (!core.isset(map[x])) map[x] = [];
if (map[x] == null) map[x] = [];
for (var y = 0; y < mw; y++) {
if (!core.isset(map[x][y])) map[x][y] = 0;
if (map[x][y] == null) map[x][y] = 0;
// check "disable"
var event = core.floors[floorId].events[y + "," + x];
if (core.isset(event) && event.enable === false && main.mode == 'play') {
if (event && event.enable === false && main.mode == 'play') {
map[x][y] += ":f";
}
}
@ -208,7 +207,7 @@ maps.prototype.compressMap = function (mapArr, floorId) {
////// 解压缩地图
maps.prototype.decompressMap = function (mapArr, floorId) {
var floorMap = this._initFloorMap(floorId);
if (!core.isset(mapArr)) return floorMap;
if (!mapArr) return floorMap;
var mw = core.floors[floorId].width;
var mh = core.floors[floorId].height;
@ -230,7 +229,7 @@ maps.prototype.decompressMap = function (mapArr, floorId) {
////// 将当前地图重新变成数字,以便于存档 //////
maps.prototype.saveMap = function (floorId) {
var maps = core.status.maps;
if (!core.isset(floorId)) {
if (!floorId) {
var map = {};
for (var id in maps) {
map[id] = this.saveMap(id);
@ -262,7 +261,7 @@ maps.prototype._compressFloorData = function (map, floor) {
////// 将存档中的地图信息重新读取出来 //////
maps.prototype.loadMap = function (data, floorId) {
if (!core.isset(floorId)) {
if (!floorId) {
var map = {};
core.floorIds.forEach(function (id) {
map[id] = core.maps.loadFloor(id, data[id]);
@ -275,7 +274,7 @@ maps.prototype.loadMap = function (data, floorId) {
////// 更改地图画布的尺寸
maps.prototype.resizeMap = function (floorId) {
floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) return;
if (!floorId) return;
core.bigmap.width = core.floors[floorId].width;
core.bigmap.height = core.floors[floorId].height;
var cwidth = core.bigmap.width * 32;
@ -334,11 +333,11 @@ maps.prototype.getMapBlocksObj = function (floorId, showDisable) {
////// 将背景前景层变成二维数组的形式 //////
maps.prototype.getBgFgMapArray = function (name, floorId, useCache) {
floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) return [];
if (!floorId) return [];
var width = core.floors[floorId].width;
var height = core.floors[floorId].height;
if (useCache && core.isset(core.status[name + "maps"][floorId]))
if (useCache && core.status[name + "maps"][floorId])
return core.status[name + "maps"][floorId];
var arr = core.clone(core.floors[floorId][name + "map"] || []);
@ -363,7 +362,7 @@ maps.prototype.getBgFgMapArray = function (name, floorId, useCache) {
////// 生成全图的当前可移动信息 //////
maps.prototype.generateMovableArray = function (floorId, x, y) {
floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) return null;
if (!floorId) return null;
var width = core.floors[floorId].width, height = core.floors[floorId].height;
var bgArray = this.getBgFgMapArray('bg', floorId, true),
fgArray = this.getBgFgMapArray('fg', floorId, true),
@ -377,7 +376,7 @@ maps.prototype.generateMovableArray = function (floorId, x, y) {
});
}
if (core.isset(x) && core.isset(y)) return generate(x, y);
if (x != null && y != null) return generate(x, y);
var array = [];
for (var x = 0; x < width; x++) {
array[x] = [];
@ -390,9 +389,9 @@ maps.prototype.generateMovableArray = function (floorId, x, y) {
////// 勇士能否前往某方向 //////
maps.prototype.canMoveHero = function (x, y, direction, floorId) {
if (!core.isset(x)) x = core.getHeroLoc('x');
if (!core.isset(y)) y = core.getHeroLoc('y');
if (!core.isset(direction)) direction = core.getHeroLoc('direction');
if (x == null) x = core.getHeroLoc('x');
if (y == null) y = core.getHeroLoc('y');
direction = direction || core.getHeroLoc('direction');
return core.inArray(this.generateMovableArray(floorId, x, y), direction);
}
@ -513,7 +512,7 @@ maps.prototype._canMoveDirectly_checkNextPoint = function (blocksObj, x, y) {
////// 绘制一个图块 //////
maps.prototype.drawBlock = function (block, animate) {
if (block.event.id == 'none') return;
var redraw = core.isset(animate);
var redraw = animate != null;
if (!redraw) animate = 0;
var x = block.x, y = block.y;
// --- 在界面外的动画不绘制
@ -526,7 +525,7 @@ maps.prototype.drawBlock = function (block, animate) {
var blockInfo = this.getBlockInfo(block);
if (blockInfo == null) return;
if (blockInfo.cls != 'tileset') blockInfo.posX = animate % block.event.animate;
if (!core.isset(block.name))
if (!block.name)
this._drawBlockInfo(blockInfo, block.x, block.y);
else
this._drawBlockInfo_bgfg(blockInfo, block.name, block.x, block.y);
@ -571,8 +570,8 @@ maps.prototype.generateGroundPattern = function (floorId) {
////// 绘制某张地图 //////
maps.prototype.drawMap = function (floorId, callback) {
floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) {
if (core.isset(callback)) callback();
if (!floorId) {
if (callback) callback();
return;
}
core.clearMap('all');
@ -581,14 +580,13 @@ maps.prototype.drawMap = function (floorId, callback) {
core.status.thisMap = core.status.maps[floorId];
this._drawMap_drawAll();
if (core.isset(core.status.curtainColor)) {
if (core.status.curtainColor) {
core.fillRect('curtain', 0, 0, core.__PIXELS__, core.__PIXELS__,
core.arrayToRGBA(core.status.curtainColor));
}
core.drawHero();
core.updateStatusBar();
if (core.isset(callback))
callback();
if (callback) callback();
}
maps.prototype._drawMap_drawAll = function (floorId) {
@ -616,7 +614,7 @@ maps.prototype._drawMap_drawBlockInfo = function (ctx, block, blockInfo, arr, on
////// 绘制背景层 //////
maps.prototype.drawBg = function (floorId, ctx) {
var onMap = !core.isset(ctx);
var onMap = ctx == null;
if (onMap) {
ctx = core.canvas.bg;
core.clearMap(ctx);
@ -631,7 +629,7 @@ maps.prototype._drawBg_drawBackground = function (floorId, ctx) {
var width = core.floors[floorId].width, height = core.floors[floorId].height;
var groundId = (core.status.maps || core.floors)[floorId].defaultGround || "ground";
var yOffset = core.material.icons.terrains[groundId];
if (core.isset(yOffset)) {
if (yOffset != null) {
for (var i = 0; i < width; i++) {
for (var j = 0; j < height; j++) {
ctx.drawImage(core.material.images.terrains, 0, yOffset * 32, 32, 32, i * 32, j * 32, 32, 32);
@ -643,9 +641,9 @@ maps.prototype._drawBg_drawBackground = function (floorId, ctx) {
////// 绘制事件层 //////
maps.prototype.drawEvents = function (floorId, blocks, ctx) {
floorId = floorId || core.status.floorId;
if (!core.isset(blocks)) blocks = core.status.maps[floorId].blocks;
if (!blocks) blocks = core.status.maps[floorId].blocks;
var arr = this.getMapArray(blocks, core.floors[floorId].width, core.floors[floorId].height);
var onMap = !core.isset(ctx);
var onMap = ctx == null;
if (onMap) ctx = core.canvas.event;
blocks.filter(function (block) {
return block.event && !block.disable;
@ -657,7 +655,7 @@ maps.prototype.drawEvents = function (floorId, blocks, ctx) {
////// 绘制前景层 //////
maps.prototype.drawFg = function (floorId, ctx) {
var onMap = !core.isset(ctx);
var onMap = ctx == null;
if (onMap) ctx = core.canvas.fg;
// ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制背景图块;后绘制的覆盖先绘制的。
this._drawFloorImages(floorId, ctx, 'fg');
@ -667,11 +665,11 @@ maps.prototype.drawFg = function (floorId, ctx) {
////// 实际的背景/前景图块的绘制 //////
maps.prototype._drawBgFgMap = function (floorId, ctx, name, onMap) {
floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) return;
if (!floorId) return;
var width = core.floors[floorId].width;
var height = core.floors[floorId].height;
if (!core.isset(core.status[name + "maps"]))
if (!core.status[name + "maps"])
core.status[name + "maps"] = {};
var arr = this.getBgFgMapArray(name, floorId);
@ -680,7 +678,7 @@ maps.prototype._drawBgFgMap = function (floorId, ctx, name, onMap) {
var block = this.initBlock(x, y, arr[y][x], true);
block.name = name;
var blockInfo = this.getBlockInfo(block);
if (!core.isset(blockInfo)) continue;
if (!blockInfo) continue;
this._drawMap_drawBlockInfo(ctx, block, blockInfo, arr, onMap);
}
}
@ -691,8 +689,8 @@ maps.prototype._drawBgFgMap = function (floorId, ctx, name, onMap) {
////// 绘制楼层贴图 //////
maps.prototype._drawFloorImages = function (floorId, ctx, name, images, currStatus) {
floorId = floorId || core.status.floorId;
if (!core.isset(images)) images = this._getFloorImages(floorId);
var redraw = core.isset(currStatus);
if (!images) images = this._getFloorImages(floorId);
var redraw = currStatus != null;
if (!redraw) core.status.floorAnimateObjs = core.clone(images);
images.forEach(function (t) {
if (typeof t == 'string') t = [0, 0, t];
@ -700,7 +698,7 @@ maps.prototype._drawFloorImages = function (floorId, ctx, name, images, currStat
var image = core.material.images.images[imageName];
if (redraw && frame == 1) return; // 不重绘
if (core.isset(dx) && core.isset(dy) && core.isset(image) &&
if (core.isset(dx) && core.isset(dy) && image &&
!core.hasFlag("__floorImg__" + floorId + "_" + dx + "_" + dy)) {
var width = parseInt(image.width / frame), offsetX = (currStatus || 0) % frame * width;
if (/.*\.gif/i.test(imageName) && main.mode == 'play') {
@ -716,7 +714,7 @@ maps.prototype._drawFloorImages = function (floorId, ctx, name, images, currStat
maps.prototype._getFloorImages = function (floorId) {
floorId = floorId || core.status.floorId;
var images = [];
if (core.isset((core.status.maps || core.floors)[floorId].images)) {
if ((core.status.maps || core.floors)[floorId].images) {
images = (core.status.maps || core.floors)[floorId].images;
if (typeof images == 'string') {
images = [[0, 0, images]];
@ -897,7 +895,7 @@ maps.prototype._makeAutotileEdges = function () {
// all是否绘制全图默认falsecenterX,centerY截取中心默认为地图正中心
maps.prototype.drawThumbnail = function (floorId, blocks, options, toDraw) {
floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) return;
if (!floorId) return;
// Step1绘制到tempCanvas上
this._drawThumbnail_drawTempCanvas(floorId, blocks, options);
// Step2从tempCanvas绘制到对应的画布上
@ -905,8 +903,8 @@ maps.prototype.drawThumbnail = function (floorId, blocks, options, toDraw) {
}
maps.prototype._drawThumbnail_drawTempCanvas = function (floorId, blocks, options) {
if (!core.isset(blocks)) blocks = core.status.maps[floorId].blocks;
if (!core.isset(options)) options = {};
blocks = blocks || core.status.maps[floorId].blocks;
options = options || {}
var width = core.floors[floorId].width;
var height = core.floors[floorId].height;
@ -918,7 +916,7 @@ maps.prototype._drawThumbnail_drawTempCanvas = function (floorId, blocks, option
tempCanvas.clearRect(0, 0, tempWidth, tempHeight);
// --- 暂存 flags
var hasHero = core.isset(core.status.hero), flags = null;
var hasHero = core.status.hero != null, flags = null;
if (options.flags) {
if (!hasHero) core.status.hero = {};
flags = core.status.hero.flags;
@ -953,15 +951,15 @@ maps.prototype._drawThumbnail_realDrawTempCanvas = function (floorId, blocks, op
}
maps.prototype._drawThumbnail_drawToTarget = function (floorId, toDraw) {
if (!core.isset(toDraw)) return;
if (toDraw == null) return;
if (typeof toDraw == 'string' || toDraw.canvas) toDraw = {ctx: toDraw};
var ctx = core.getContextByName(toDraw.ctx);
if (ctx == null) return;
var x = toDraw.x || 0, y = toDraw.y || 0, size = toDraw.size || core.__PIXELS__;
var width = core.floors[floorId].width, height = core.floors[floorId].height;
var centerX = toDraw.centerX, centerY = toDraw.centerY;
if (!core.isset(centerX)) centerX = Math.floor(width / 2);
if (!core.isset(centerY)) centerY = Math.floor(height / 2);
if (centerX == null) centerX = Math.floor(width / 2);
if (centerY == null) centerY = Math.floor(height / 2);
var tempCanvas = core.bigmap.tempCanvas, tempWidth = 32 * width, tempHeight = 32 * height;
core.clearMap(ctx, x, y, size, size);
@ -996,7 +994,7 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, toDraw) {
maps.prototype.noPass = function (x, y, floorId) {
var block = core.getBlock(x, y, floorId);
if (block == null) return false;
return core.isset(block.block.event.noPass) && block.block.event.noPass;
return block.block.event.noPass;
}
////// 某个点是否存在NPC //////
@ -1010,7 +1008,7 @@ maps.prototype.npcExists = function (x, y, floorId) {
maps.prototype.terrainExists = function (x, y, id, floorId) {
var block = this.getBlock(x, y, floorId);
if (block == null) return false;
return block.block.event.cls == 'terrains' && (core.isset(id) ? block.block.event.id == id : true);
return block.block.event.cls == 'terrains' && (id ? block.block.event.id == id : true);
}
////// 某个点是否存在楼梯 //////
@ -1030,16 +1028,16 @@ maps.prototype.nearStair = function () {
maps.prototype.enemyExists = function (x, y, id, floorId) {
var block = this.getBlock(x, y, floorId);
if (block == null) return false;
return block.block.event.cls.indexOf('enemy') == 0 && (core.isset(id) ? block.block.event.id == id : true);
return block.block.event.cls.indexOf('enemy') == 0 && (id ? block.block.event.id == id : true);
}
////// 获得某个点的block //////
maps.prototype.getBlock = function (x, y, floorId, showDisable) {
floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) return null;
if (!floorId) return null;
var blocks = core.status.maps[floorId].blocks;
for (var n = 0; n < blocks.length; n++) {
if (blocks[n].x == x && blocks[n].y == y && core.isset(blocks[n].event)) {
if (blocks[n].x == x && blocks[n].y == y) {
if (!showDisable && blocks[n].disable) return null;
return {"index": n, "block": blocks[n]};
}
@ -1061,7 +1059,7 @@ maps.prototype.getBlockCls = function (x, y, floorId, showDisable) {
////// 获得某个图块或素材的信息,包括 IDcls图片坐标faceIds 等等 //////
maps.prototype.getBlockInfo = function (block) {
if (!core.isset(block)) return null;
if (!block) return null;
if (typeof block == 'string') { // 参数是ID
block = this.getNumberById(block);
}
@ -1075,7 +1073,7 @@ maps.prototype.getBlockInfo = function (block) {
if (id == 'none') return null;
else if (id == 'airwall') {
if (!core.isset(core.material.images.airwall)) return null;
if (!core.material.images.airwall) return null;
image = core.material.images.airwall;
}
else if (cls == 'tileset') {
@ -1121,7 +1119,7 @@ maps.prototype.searchBlock = function (id, floorId, showDisable) {
////// 将某个块从禁用变成启用状态 //////
maps.prototype.showBlock = function (x, y, floorId) {
floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) return;
if (!floorId) return;
var block = core.getBlock(x, y, floorId, true);
if (block == null) return; // 不存在
block = block.block;
@ -1140,7 +1138,7 @@ maps.prototype.showBlock = function (x, y, floorId) {
////// 只隐藏但不删除某块 //////
maps.prototype.hideBlock = function (x, y, floorId) {
floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) return;
if (!floorId) return;
var block = core.getBlock(x, y, floorId, true);
if (block == null) return; // 不存在
@ -1161,7 +1159,7 @@ maps.prototype.hideBlock = function (x, y, floorId) {
////// 将某个块从启用变成禁用状态 //////
maps.prototype.removeBlock = function (x, y, floorId) {
floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) return;
if (!floorId) return;
var block = core.getBlock(x, y, floorId, true);
if (block == null) return; // 不存在
@ -1185,7 +1183,7 @@ maps.prototype.removeBlock = function (x, y, floorId) {
////// 根据block的索引尽可能删除该块 //////
maps.prototype.removeBlockById = function (index, floorId) {
floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) return;
if (!floorId) return;
var blocks = core.status.maps[floorId].blocks, block = blocks[index];
@ -1213,7 +1211,7 @@ maps.prototype.canRemoveBlock = function (block, floorId) {
////// 一次性删除多个block //////
maps.prototype.removeBlockByIds = function (floorId, ids) {
floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) return;
if (!floorId) return;
ids.sort(function (a, b) {
return b - a
}).forEach(function (id) {
@ -1258,7 +1256,7 @@ maps.prototype._triggerBgFgMap = function (type, name, loc, floorId, callback) {
if (typeof loc[0] == 'number' && typeof loc[1] == 'number')
loc = [loc];
floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) return;
if (!floorId) return;
if (loc.length == 0) return;
loc.forEach(function (t) {
@ -1273,7 +1271,7 @@ maps.prototype._triggerBgFgMap = function (type, name, loc, floorId, callback) {
core.drawMap(floorId, callback);
}
else {
if (core.isset(callback)) callback();
if (callback) callback();
}
}
@ -1293,7 +1291,7 @@ maps.prototype._triggerFloorImage = function (type, loc, floorId, callback) {
if (typeof loc[0] == 'number' && typeof loc[1] == 'number')
loc = [loc];
floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) return;
if (!floorId) return;
if (loc.length == 0) return;
loc.forEach(function (t) {
@ -1307,15 +1305,14 @@ maps.prototype._triggerFloorImage = function (type, loc, floorId, callback) {
core.drawMap(floorId, callback);
}
else {
if (core.isset(callback)) callback();
if (callback) callback();
}
}
////// 改变图块 //////
maps.prototype.setBlock = function (number, x, y, floorId) {
floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) return;
if (!core.isset(number) || !core.isset(x) || !core.isset(y)) return;
if (!floorId || number == null || x == null || y == null) return;
if (x < 0 || x >= core.floors[floorId].width || y < 0 || y >= core.floors[floorId].height) return;
var originBlock = core.getBlock(x, y, floorId, true);
@ -1347,8 +1344,7 @@ maps.prototype.setBlock = function (number, x, y, floorId) {
////// 改变前景背景的图块 //////
maps.prototype.setBgFgBlock = function (name, number, x, y, floorId) {
floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) return;
if (!core.isset(number) || !core.isset(x) || !core.isset(y)) return;
if (!floorId || number == null || x == null || y == null) return;
if (x < 0 || x >= core.floors[floorId].width || y < 0 || y >= core.floors[floorId].height) return;
if (name != 'bg' && name != 'fg') return;
@ -1363,7 +1359,7 @@ maps.prototype.setBgFgBlock = function (name, number, x, y, floorId) {
////// 重置地图 //////
maps.prototype.resetMap = function (floorId) {
floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) return;
if (!floorId) return;
if (typeof floorId == 'string') floorId = [floorId];
var needRefresh = false;
floorId.forEach(function (t) {
@ -1458,7 +1454,7 @@ maps.prototype.moveBlock = function (x, y, steps, time, keep, callback) {
time = time || 500;
var blockArr = this._getAndRemoveBlock(x, y);
if (blockArr == null) {
if (core.isset(callback)) callback();
if (callback) callback();
return;
}
var block = blockArr[0], blockInfo = blockArr[1];
@ -1499,9 +1495,9 @@ maps.prototype._moveBlock_moving = function (blockInfo, canvases, moveInfo) {
moveInfo.y += core.utils.scan[direction].y;
// 根据faceIds修改朝向
var currid = blockInfo.faceIds[direction];
if (core.isset(currid)) {
if (currid) {
var posY = core.material.icons[blockInfo.cls][currid];
if (core.isset(posY)) blockInfo.posY = posY;
if (posY != null) blockInfo.posY = posY;
}
}
moveInfo.step++;
@ -1519,7 +1515,7 @@ maps.prototype.jumpBlock = function (sx, sy, ex, ey, time, keep, callback) {
time = time || 500;
var blockArr = this._getAndRemoveBlock(sx, sy);
if (blockArr == null) {
if (core.isset(callback)) callback();
if (callback) callback();
return;
}
var block = blockArr[0], blockInfo = blockArr[1];
@ -1579,7 +1575,7 @@ maps.prototype._moveJumpBlock_finished = function (blockInfo, canvases, info, an
core.setBlock(blockInfo.number, info.x, info.y);
core.showBlock(info.x, info.y);
}
if (core.isset(callback)) callback();
if (callback) callback();
}
else {
this._moveDetachedBlock(blockInfo, info.px, info.py, info.opacity, canvases);
@ -1593,7 +1589,7 @@ maps.prototype.animateBlock = function (loc, type, time, callback) {
loc = [loc];
var list = this._animateBlock_getList(loc);
if (list.length == 0) {
if (core.isset(callback)) callback();
if (callback) callback();
return;
}
this._animateBlock_drawList(list, isHide ? 1 : 0);
@ -1615,7 +1611,7 @@ maps.prototype._animateBlock_doAnimate = function (loc, list, isHide, delta, cal
if (isHide) core.removeBlock(t[0], t[1]);
else core.showBlock(t[0], t[1]);
});
if (core.isset(callback)) callback();
if (callback) callback();
}
}, 10);
@ -1651,14 +1647,14 @@ maps.prototype._animateBlock_drawList = function (list, opacity) {
////// 添加一个全局动画 //////
maps.prototype.addGlobalAnimate = function (b) {
if (!core.isset(b.event) || !core.isset(b.event.animate)) return;
if (!b.event || b.event.animate == null) return;
if (b.event.cls == 'autotile') {
var id = b.event.id, img = core.material.images.autotile[id];
if (!core.isset(img) || img.width == 96) return;
if (!img || img.width == 96) return;
core.status.autotileAnimateObjs.blocks.push(b);
}
else {
if (!core.isset(b.event.animate) || b.event.animate == 1) return;
if (!b.event.animate || b.event.animate == 1) return;
core.status.globalAnimateObjs.push(b);
}
}
@ -1666,7 +1662,7 @@ maps.prototype.addGlobalAnimate = function (b) {
////// 删除一个或所有全局动画 //////
maps.prototype.removeGlobalAnimate = function (x, y, name) {
// 没有定义xy则全部删除
if (!core.isset(x) || !core.isset(y)) {
if (x == null || y == null) {
core.status.globalAnimateStatus = 0;
core.status.globalAnimateObjs = [];
core.status.autotileAnimateObjs = {"blocks": [], "map": null, "bgmap": null, "fgmap": null};
@ -1679,7 +1675,7 @@ maps.prototype.removeGlobalAnimate = function (x, y, name) {
});
// 检查Autotile
if (core.isset(core.status.autotileAnimateObjs.blocks)) {
if (core.status.autotileAnimateObjs.blocks) {
core.status.autotileAnimateObjs.blocks = core.status.autotileAnimateObjs.blocks.filter(function (block) {
return block.x != x || block.y != y || block.name != name;
});
@ -1703,13 +1699,13 @@ maps.prototype.drawAnimate = function (name, x, y, callback) {
// 正在播放录像:不显示动画
if (core.isReplaying()) {
if (core.isset(callback)) callback();
if (callback) callback();
return -1;
}
// 检测动画是否存在
if (!core.isset(core.material.animates[name]) || !core.isset(x) || !core.isset(y)) {
if (core.isset(callback)) callback();
if (!core.material.animates[name] || x == null || y == null) {
if (callback) callback();
return -1;
}
@ -1738,7 +1734,7 @@ maps.prototype._drawAnimateFrame = function (animate, centerX, centerY, index) {
var ratio = animate.ratio;
frame.forEach(function (t) {
var image = animate.images[t.index];
if (!core.isset(image)) return;
if (!image) return;
var realWidth = image.width * ratio * t.zoom / 100;
var realHeight = image.height * ratio * t.zoom / 100;
core.setAlpha('animate', t.opacity / 255);
@ -1771,8 +1767,7 @@ maps.prototype.stopAnimate = function (id, doCallback) {
if (doCallback) {
(function (callback) {
setTimeout(function () {
if (core.isset(callback))
callback();
if (callback) callback();
});
})(obj.callback);
}

View File

@ -61,7 +61,7 @@ utils.prototype.replaceText = function (text, need, times) {
////// 计算表达式的值 //////
utils.prototype.calValue = function (value, prefix, need, times) {
if (!core.isset(value)) return value;
if (!core.isset(value)) return null;
if (typeof value === 'string') {
value = value.replace(/status:([\w\d_]+)/g, "core.getStatus('$1')");
value = value.replace(/item:([\w\d_]+)/g, "core.itemCount('$1')");
@ -77,7 +77,7 @@ utils.prototype.calValue = function (value, prefix, need, times) {
////// 字符串自动换行的分割 //////
utils.prototype.splitLines = function (canvas, text, maxLength, font) {
if (core.isset(font)) core.setFont(canvas, font);
if (font) core.setFont(canvas, font);
var contents = [];
var last = 0;
@ -94,7 +94,7 @@ utils.prototype.splitLines = function (canvas, text, maxLength, font) {
else {
var toAdd = text.substring(last, i + 1);
var width = core.calWidth(canvas, toAdd);
if (core.isset(maxLength) && width > maxLength) {
if (maxLength && width > maxLength) {
contents.push(text.substring(last, i));
last = i;
}
@ -106,7 +106,7 @@ utils.prototype.splitLines = function (canvas, text, maxLength, font) {
////// 向某个数组前插入另一个数组或元素 //////
utils.prototype.unshift = function (a, b) {
if (!(a instanceof Array) || !core.isset(b)) return;
if (!(a instanceof Array) || b == null) return;
if (b instanceof Array) {
core.clone(b).reverse().forEach(function (e) {
a.unshift(e);
@ -118,7 +118,7 @@ utils.prototype.unshift = function (a, b) {
////// 向某个数组后插入另一个数组或元素 //////
utils.prototype.push = function (a, b) {
if (!(a instanceof Array) || !core.isset(b)) return;
if (!(a instanceof Array) || b == null) return;
if (b instanceof Array) {
core.clone(b).forEach(function (e) {
a.push(e);
@ -131,7 +131,7 @@ utils.prototype.push = function (a, b) {
////// 设置本地存储 //////
utils.prototype.setLocalStorage = function (key, value) {
try {
if (!core.isset(value)) {
if (value == null) {
this.removeLocalStorage(key);
return;
}
@ -166,15 +166,13 @@ utils.prototype.setLocalStorage = function (key, value) {
utils.prototype.decompress = function (value) {
try {
var output = lzw_decode(value);
if (core.isset(output) && output.length > 0)
return JSON.parse(output);
if (output) return JSON.parse(output);
}
catch (e) {
}
try {
var output = LZString.decompress(value);
if (core.isset(output) && output.length > 0)
return JSON.parse(output);
if (output) return JSON.parse(output);
}
catch (e) {
}
@ -204,15 +202,15 @@ utils.prototype.setLocalForage = function (key, value, successCallback, errorCal
if (!core.platform.useLocalForage) {
if (this.setLocalStorage(key, value)) {
if (core.isset(successCallback)) successCallback();
if (successCallback) successCallback();
}
else {
if (core.isset(errorCallback)) errorCallback();
if (errorCallback) errorCallback();
}
return;
}
if (!core.isset(value)) {
if (value == null) {
this.removeLocalForage(key);
return;
}
@ -222,13 +220,13 @@ utils.prototype.setLocalForage = function (key, value, successCallback, errorCal
return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4)
}));
localforage.setItem(core.firstData.name + "_" + key, compressed, function (err) {
if (core.isset(err)) {
if (core.isset(errorCallback)) errorCallback(err);
if (err) {
if (errorCallback) errorCallback(err);
}
else {
if (key == 'autoSave') core.saves.ids[0] = true;
else if (/^save\d+$/.test(key)) core.saves.ids[parseInt(key.substring(4))] = true;
if (core.isset(successCallback)) successCallback();
if (successCallback) successCallback();
}
});
}
@ -237,19 +235,17 @@ utils.prototype.getLocalForage = function (key, defaultValue, successCallback, e
if (!core.platform.useLocalForage) {
var value = this.getLocalStorage(key, defaultValue);
if (core.isset(successCallback)) {
successCallback(value);
}
if (successCallback) successCallback(value);
return;
}
localforage.getItem(core.firstData.name + "_" + key, function (err, value) {
if (core.isset(err)) {
if (core.isset(errorCallback)) errorCallback(err);
if (err) {
if (errorCallback) errorCallback(err);
}
else {
if (!core.isset(successCallback)) return;
if (core.isset(value)) {
if (!successCallback) return;
if (value != null) {
var res = core.utils.decompress(value);
successCallback(res == null ? defaultValue : res);
return;
@ -263,25 +259,25 @@ utils.prototype.removeLocalForage = function (key, successCallback, errorCallbac
if (!core.platform.useLocalForage) {
this.removeLocalStorage(key);
if (core.isset(successCallback)) successCallback();
if (successCallback) successCallback();
return;
}
localforage.removeItem(core.firstData.name + "_" + key, function (err) {
if (core.isset(err)) {
if (core.isset(errorCallback)) errorCallback(err);
if (err) {
if (errorCallback) errorCallback(err);
}
else {
if (key == 'autoSave') delete core.saves.ids[0];
else if (/^save\d+$/.test(key)) delete core.saves.ids[parseInt(key.substring(4))];
if (core.isset(successCallback)) successCallback();
if (successCallback) successCallback();
}
})
}
////// 深拷贝一个对象 //////
utils.prototype.clone = function (data) {
if (!core.isset(data)) return data;
if (!core.isset(data)) return null;
// date
if (data instanceof Date) {
var copy = new Date();
@ -334,14 +330,14 @@ utils.prototype.cropImage = function (image, size) {
////// 格式化时间为字符串 //////
utils.prototype.formatDate = function (date) {
if (!core.isset(date)) return "";
if (!date) date = new Date();
return "" + date.getFullYear() + "-" + core.setTwoDigits(date.getMonth() + 1) + "-" + core.setTwoDigits(date.getDate()) + " "
+ core.setTwoDigits(date.getHours()) + ":" + core.setTwoDigits(date.getMinutes()) + ":" + core.setTwoDigits(date.getSeconds());
}
////// 格式化时间为最简字符串 //////
utils.prototype.formatDate2 = function (date) {
if (!core.isset(date)) return "";
if (!date) date = new Date();
return "" + date.getFullYear() + core.setTwoDigits(date.getMonth() + 1) + core.setTwoDigits(date.getDate())
+ core.setTwoDigits(date.getHours()) + core.setTwoDigits(date.getMinutes()) + core.setTwoDigits(date.getSeconds());
}
@ -395,7 +391,7 @@ utils.prototype.arrayToRGB = function (color) {
}
utils.prototype.arrayToRGBA = function (color) {
if (!this.isset(color[3])) color[3] = 1;
if (color[3] == null) color[3] = 1;
var nowR = this.clamp(parseInt(color[0]), 0, 255), nowG = this.clamp(parseInt(color[1]), 0, 255),
nowB = this.clamp(parseInt(color[2]), 0, 255), nowA = this.clamp(parseFloat(color[3]), 0, 1);
return "rgba(" + nowR + "," + nowG + "," + nowB + "," + nowA + ")";
@ -472,12 +468,12 @@ utils.prototype._encodeRoute_encodeOne = function (t) {
////// 解密路线 //////
utils.prototype.decodeRoute = function (route) {
if (!core.isset(route)) return route;
if (!route) return route;
// 解压缩
try {
var v = LZString.decompressFromBase64(route);
if (core.isset(v) && /^[a-zA-Z0-9+\/=:]*$/.test(v)) {
if (/^[a-zA-Z0-9+\/=:]*$/.test(v)) {
route = v;
}
} catch (e) {
@ -496,7 +492,7 @@ utils.prototype._decodeRoute_getNumber = function (decodeObj, noparse) {
num += decodeObj.route.charAt(decodeObj.index++);
}
if (num.length == 0) num = "1";
return core.isset(noparse) ? num : parseInt(num);
return noparse ? num : parseInt(num);
}
utils.prototype._decodeRoute_getString = function (decodeObj) {
@ -511,7 +507,7 @@ utils.prototype._decodeRoute_getString = function (decodeObj) {
utils.prototype._decodeRoute_number2id = function (number) {
if (/^\d+$/.test(number)) {
var info = core.maps.blocksInfo[number];
if (core.isset(info)) return info.id;
if (info) return info.id;
}
return number;
}
@ -578,17 +574,14 @@ utils.prototype._decodeRoute_decodeOne = function (decodeObj, c) {
}
}
////// 判断某对象是否不为undefined也不会null //////
////// 判断某对象是否不为null也不为NaN //////
utils.prototype.isset = function (val) {
if (val == undefined || val == null || (typeof val == 'number' && isNaN(val))) {
return false;
}
return true
return val != null && !(typeof val == 'number' && isNaN(val));
}
////// 获得子数组 //////
utils.prototype.subarray = function (a, b) {
if (!core.isset(a) || !core.isset(b) || !(a instanceof Array) || !(b instanceof Array) || a.length < b.length)
if (!(a instanceof Array) || !(b instanceof Array) || a.length < b.length)
return null;
var na = core.clone(a), nb = core.clone(b);
while (nb.length > 0) {
@ -598,7 +591,7 @@ utils.prototype.subarray = function (a, b) {
}
utils.prototype.inArray = function (array, element) {
return this.isset(array) && (array instanceof Array) && array.indexOf(element) >= 0;
return (array instanceof Array) && array.indexOf(element) >= 0;
}
utils.prototype.clamp = function (x, a, b) {
@ -618,7 +611,7 @@ utils.prototype.expandMoveSteps = function (steps) {
moveSteps.push(e);
}
else {
if (!core.isset(e.value)) {
if (e.value == null) {
moveSteps.push(e.direction)
}
else {
@ -640,7 +633,7 @@ utils.prototype.setStatusBarInnerHTML = function (name, value, css) {
// 判定是否需要缩放
var length = this.strlen(value) || 1;
style += 'font-size: ' + Math.min(1, 7 / length) + 'em; ';
if (core.isset(css)) style += css;
if (css) style += css;
core.statusBar[name].innerHTML = "<span class='_status' style='" + style + "'>" + value + "</span>";
}
@ -691,7 +684,7 @@ utils.prototype.rand = function (num) {
rand = this.__next_rand(rand);
core.setFlag('__rand__', rand);
var ans = rand / 2147483647;
if (core.isset(num) && num > 0)
if (num && num > 0)
return Math.floor(ans * num);
return ans;
}
@ -740,7 +733,7 @@ utils.prototype.readFile = function (success, error, readType) {
core.platform.successCallback = success;
core.platform.errorCallback = error;
if (core.isset(window.jsinterface)) {
if (window.jsinterface) {
window.jsinterface.readFile();
return;
}
@ -748,14 +741,14 @@ utils.prototype.readFile = function (success, error, readType) {
// step 0: 不为http/https直接不支持
if (!core.platform.isOnline) {
alert("离线状态下不支持文件读取!");
if (core.isset(error)) error();
if (error) error();
return;
}
// Step 1: 如果不支持FileReader直接不支持
if (core.platform.fileReader == null) {
alert("当前浏览器不支持FileReader");
if (core.isset(error)) error();
if (error) error();
return;
}
@ -766,7 +759,7 @@ utils.prototype.readFile = function (success, error, readType) {
core.platform.fileInput.onchange = function () {
var files = core.platform.fileInput.files;
if (files.length == 0) {
if (core.isset(core.platform.errorCallback))
if (core.platform.errorCallback)
core.platform.errorCallback();
return;
}
@ -783,14 +776,14 @@ utils.prototype.readFile = function (success, error, readType) {
utils.prototype.readFileContent = function (content) {
var obj = null;
if (content.slice(0, 4) === 'data') {
if (core.isset(core.platform.successCallback))
if (core.platform.successCallback)
core.platform.successCallback(content);
return;
}
try {
obj = JSON.parse(content);
if (core.isset(obj)) {
if (core.isset(core.platform.successCallback))
if (obj) {
if (core.platform.successCallback)
core.platform.successCallback(obj);
return;
}
@ -801,14 +794,14 @@ utils.prototype.readFileContent = function (content) {
}
alert("不是有效的JSON文件");
if (core.isset(core.platform.errorCallback))
if (core.platform.errorCallback)
core.platform.errorCallback();
}
////// 下载文件到本地 //////
utils.prototype.download = function (filename, content) {
if (core.isset(window.jsinterface)) {
if (window.jsinterface) {
window.jsinterface.download(filename, content);
return;
}
@ -873,8 +866,8 @@ utils.prototype.download = function (filename, content) {
////// 复制一段内容到剪切板 //////
utils.prototype.copy = function (data) {
if (core.isset(window.jsinterface)) {
window.jsinterface.copy(filename, content);
if (window.jsinterface) {
window.jsinterface.copy(data);
return true;
}
@ -909,9 +902,9 @@ utils.prototype.copy = function (data) {
////// 动画显示某对象 //////
utils.prototype.show = function (obj, speed, callback) {
obj.style.display = 'block';
if (!core.isset(speed) && main.mode != 'play') {
if (!speed && main.mode != 'play') {
obj.style.opacity = 1;
if (core.isset(callback)) callback();
if (callback) callback();
return;
}
obj.style.opacity = 0;
@ -921,18 +914,16 @@ utils.prototype.show = function (obj, speed, callback) {
obj.style.opacity = opacityVal;
if (opacityVal > 1) {
clearInterval(showAnimate);
if (core.isset(callback)) {
callback();
}
if (callback) callback();
}
}, speed);
}
////// 动画使某对象消失 //////
utils.prototype.hide = function (obj, speed, callback) {
if (!core.isset(speed) || main.mode != 'play') {
if (!speed || main.mode != 'play') {
obj.style.display = 'none';
if (core.isset(callback)) callback();
if (callback) callback();
return;
}
obj.style.opacity = 1;
@ -943,9 +934,7 @@ utils.prototype.hide = function (obj, speed, callback) {
if (opacityVal < 0) {
obj.style.display = 'none';
clearInterval(hideAnimate);
if (core.isset(callback)) {
callback();
}
if (callback) callback();
}
}, speed);
}
@ -984,7 +973,7 @@ utils.prototype.decodeCanvas = function (arr, width, height) {
tempCanvas.canvas.height = height;
tempCanvas.clearRect(0, 0, width, height);
if (!core.isset(arr)) return null;
if (!arr) return null;
// to byte array
var curr = 0, list = [];
arr.forEach(function (x) {
@ -1028,8 +1017,8 @@ utils.prototype.hashCode = function (obj) {
}
utils.prototype.same = function (a, b) {
if (!core.isset(a) && !core.isset(b)) return true;
if (!core.isset(a) || !core.isset(b)) return false;
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (a === b) return true;
if (a instanceof Array && b instanceof Array) {
if (a.length != b.length) return false;
@ -1051,14 +1040,14 @@ utils.prototype.same = function (a, b) {
}
utils.prototype._export = function (floorIds) {
if (!core.isset(floorIds)) floorIds = [core.status.floorId];
if (!floorIds) floorIds = [core.status.floorId];
else if (floorIds == 'all') floorIds = core.clone(core.floorIds);
else if (typeof floorIds == 'string') floorIds = [floorIds];
var monsterMap = {};
// map
var content = floorIds.length + "\n13 13\n\n";
var content = floorIds.length + "\n" + core.__SIZE__ + " " + core.__SIZE__ + "\n\n";
floorIds.forEach(function (floorId) {
var arr = core.maps.getMapArray(core.status.maps[floorId].blocks, 13, 13);
content += arr.map(function (x) {
@ -1098,34 +1087,26 @@ utils.prototype._export = function (floorIds) {
utils.prototype.http = function (type, url, formData, success, error, mimeType, responseType) {
var xhr = new XMLHttpRequest();
xhr.open(type, url, true);
if (core.isset(mimeType))
xhr.overrideMimeType(mimeType);
if (core.isset(responseType))
xhr.responseType = responseType;
if (mimeType) xhr.overrideMimeType(mimeType);
if (responseType) xhr.responseType = responseType;
xhr.onload = function (e) {
if (xhr.status == 200) {
if (core.isset(success)) {
success(xhr.response);
}
if (success) success(xhr.response);
}
else {
if (core.isset(error))
error("HTTP " + xhr.status);
if (error) error("HTTP " + xhr.status);
}
};
xhr.onabort = function () {
if (core.isset(error))
error("Abort");
if (error) error("Abort");
}
xhr.ontimeout = function () {
if (core.isset(error))
error("Timeout");
if (error) error("Timeout");
}
xhr.onerror = function () {
if (core.isset(error))
error("Error on Connection");
if (error) error("Error on Connection");
}
if (core.isset(formData))
if (formData)
xhr.send(formData);
else xhr.send();
}

View File

@ -122,25 +122,23 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
core.drawMap(floorId);
// 切换楼层BGM
if (core.isset(core.status.maps[floorId].bgm)) {
if (core.status.maps[floorId].bgm) {
var bgm = core.status.maps[floorId].bgm;
if (bgm instanceof Array) bgm = bgm[0];
core.playBgm(bgm);
}
// 更改画面色调
var color = core.getFlag('__color__', null);
if (!core.isset(color) && core.isset(core.status.maps[floorId].color))
if (!color && core.status.maps[floorId].color)
color = core.status.maps[floorId].color;
core.clearMap('curtain');
core.status.curtainColor = color;
if (core.isset(color)) {
core.fillRect('curtain',0,0,416,416,core.arrayToRGBA(color));
}
if (color) core.fillRect('curtain', 0, 0, core.__SIZE__, core.__SIZE__, core.arrayToRGBA(color));
// 更改天气
var weather = core.getFlag('__weather__', null);
if (!core.isset(weather) && core.isset(core.status.maps[floorId].weather))
if (!weather && core.status.maps[floorId].weather)
weather = core.status.maps[floorId].weather;
if (core.isset(weather))
if (weather)
core.setWeather(weather[0], weather[1]);
else core.setWeather();
@ -172,7 +170,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 返回true则将继续战斗返回false将不再战斗。
// ------ 支援技能 ------ //
if (core.isset(x) && core.isset(y)) {
if (x != null && y != null) {
var index = x + "," + y,
cache = (core.status.checkBlock.cache || {})[index] || {},
guards = cache.guards || [];
@ -204,13 +202,13 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 播放战斗音效和动画
var equipAnimate = 'hand',
equipId = (core.status.hero.equipment || [])[0];
if (core.isset(equipId) && core.isset((core.material.items[equipId].equip || {}).animate))
if (equipId && (core.material.items[equipId].equip || {}).animate)
equipAnimate = core.material.items[equipId].equip.animate;
// 检查equipAnimate是否存在SE如果不存在则使用默认音效
if (!core.isset((core.material.animates[equipAnimate] || {}).se))
if (!(core.material.animates[equipAnimate] || {}).se)
core.playSound('attack.mp3');
// 强制战斗的战斗动画
core.drawAnimate(equipAnimate, core.isset(x) ? x : core.getHeroLoc('x'), core.isset(y) ? y : core.getHeroLoc('y'));
core.drawAnimate(equipAnimate, x != null ? x : core.getHeroLoc('x'), y != null ? y : core.getHeroLoc('y'));
var damage = core.enemys.getDamage(enemyId, x, y);
if (damage == null) damage = core.status.hero.hp + 1;
@ -231,7 +229,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 删除该块
var guards = []; // 支援
if (core.isset(x) && core.isset(y)) {
if (x != null && y != null) {
core.removeBlock(x, y);
guards = core.getFlag("__guards__" + x + "_" + y, []);
core.removeFlag("__guards__" + x + "_" + y);
@ -310,15 +308,13 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 如果有加点
var point = core.material.enemys[enemyId].point;
if (core.flags.enableAddPoint && core.isset(point) && point > 0) {
if (core.flags.enableAddPoint && point > 0) {
core.push(todo, [{ "type": "setValue", "name": "flag:point", "value": point }]);
core.push(todo, [{ "type": "insert", "name": "加点事件" }]);
}
// 如果该点存在,且有事件 -- V2.5.4 以后阻击怪也可以有战后事件了
if (core.isset(x) && core.isset(y)) {
// 如果该点存在事件 -- V2.5.4 以后阻击怪也可以有战后事件了
core.push(todo, core.floors[core.status.floorId].afterBattle[x + "," + y]);
}
// 在这里增加其他的自定义事件需求
/*
@ -330,58 +326,44 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
*/
// 如果事件不为空,将其插入
if (todo.length > 0) {
core.events.insertAction(todo, x, y);
}
if (todo.length > 0) core.insertAction(todo, x, y);
// 如果已有事件正在处理中
if (core.status.event.id == null) {
if (core.status.event.id == null)
core.continueAutomaticRoute();
} else {
else
core.clearContinueAutomaticRoute();
}
if (core.isset(callback)) callback();
if (callback) callback();
},
"afterOpenDoor": function (doorId, x, y, callback) {
// 开一个门后触发的事件
var todo = [];
if (core.isset(x) && core.isset(y)) {
var event = core.floors[core.status.floorId].afterOpenDoor[x + "," + y];
if (core.isset(event)) {
core.unshift(todo, event);
}
}
if (event) core.unshift(todo, event);
if (todo.length > 0) {
core.events.insertAction(todo, x, y);
}
if (todo.length > 0) core.insertAction(todo, x, y);
if (core.status.event.id == null) {
if (core.status.event.id == null)
core.continueAutomaticRoute();
} else {
else
core.clearContinueAutomaticRoute();
}
if (core.isset(callback)) callback();
if (callback) callback();
},
"afterGetItem": function (itemId, x, y, callback) {
// 获得一个道具后触发的事件
core.playSound('item.mp3');
var todo = [];
if (core.isset(x) && core.isset(y)) {
var event = core.floors[core.status.floorId].afterGetItem[x + "," + y];
if (core.isset(event)) {
core.unshift(todo, event);
}
}
if (event) core.unshift(todo, event);
if (todo.length > 0) {
core.events.insertAction(todo, x, y);
}
if (todo.length > 0) core.insertAction(todo, x, y);
if (core.isset(callback)) callback();
if (callback) callback();
},
"afterChangeLight": function(x,y) {
// 改变亮灯之后,可以触发的事件
@ -516,10 +498,10 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// ------ 支援 ------
var guards = [];
// 检查光环缓存
if (!core.isset(core.status.checkBlock.cache)) core.status.checkBlock.cache = {};
var index = core.isset(x) && core.isset(y) ? (x + "," + y) : "floor";
if (!core.status.checkBlock.cache) core.status.checkBlock.cache = {};
var index = x != null && y != null ? (x + "," + y) : "floor";
var cache = core.status.checkBlock.cache[index];
if (!core.isset(cache)) {
if (!cache) {
// 没有该点的缓存,则遍历每个图块
core.status.maps[floorId].blocks.forEach(function (block) {
if (!block.disable) {
@ -527,7 +509,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
var id = block.event.id,
enemy = core.material.enemys[id];
// 检查是不是怪物,且是否拥有该特殊属性
if (core.isset(enemy) && core.hasSpecial(enemy.special, 25)) {
if (enemy && core.hasSpecial(enemy.special, 25)) {
// 检查是否可叠加
if (enemy.add || cnt == 0) {
hp_buff += enemy.value || 0;
@ -537,10 +519,10 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
}
}
// 检查【支援】技能
if (core.isset(enemy) && core.hasSpecial(enemy.special, 26) &&
if (enemy && core.hasSpecial(enemy.special, 26) &&
// 检查支援条件坐标存在距离为1且不能是自己
// 其他类型的支援怪,比如十字之类的话.... 看着做是一样的
core.isset(x) && core.isset(y) && Math.abs(block.x - x) <= 1 && Math.abs(block.y - y) <= 1 && !(x == block.x && y == block.y)) {
x != null && y != null && Math.abs(block.x - x) <= 1 && Math.abs(block.y - y) <= 1 && !(x == block.x && y == block.y)) {
// 记录怪物的x,yID
guards.push([block.x, block.y, id]);
}
@ -959,7 +941,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
var statusList = ['hpmax', 'hp', 'mana', 'atk', 'def', 'mdef', 'money', 'experience'];
statusList.forEach(function (item) {
// 向下取整
if (core.isset(core.status.hero[item]))
core.status.hero[item] = Math.floor(core.status.hero[item]);
// 大数据格式化
core.setStatusBarInnerHTML(item, core.getRealStatus(item));
@ -1022,7 +1003,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
"updateCheckBlock": function (floorId) {
// 领域、夹击、阻击等的伤害值计算
floorId = floorId || core.status.floorId;
if (!core.isset(floorId) || !core.isset(core.status.maps)) return;
if (!floorId || !core.status.maps) return;
var blocks = core.status.maps[floorId].blocks;
var width = core.floors[floorId].width, height = core.floors[floorId].height;
@ -1035,9 +1017,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
if (!block.disable && block.event.cls.indexOf('enemy') == 0) {
var id = block.event.id,
enemy = core.material.enemys[id];
if (core.isset(enemy)) {
core.status.checkBlock.map[block.x + width * block.y] = id;
}
if (enemy) core.status.checkBlock.map[block.x + width * block.y] = id;
}
// 血网
if (!block.disable &&
@ -1054,7 +1034,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) {
var id = core.status.checkBlock.map[x + width * y];
if (core.isset(id)) {
if (id) {
// 如果是血网,直接加上伤害值
if (id == "lavaNet") {
@ -1070,7 +1050,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
var range = enemy.range || 1;
// 是否是九宫格领域
var zoneSquare = false;
if (core.isset(enemy.zoneSquare)) zoneSquare = enemy.zoneSquare;
if (enemy.zoneSquare != null) zoneSquare = enemy.zoneSquare;
// 在范围内进行搜索,增加领域伤害值
for (var dx = -range; dx <= range; dx++) {
for (var dy = -range; dy <= range; dy++) {
@ -1115,7 +1095,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
var nx = x + core.utils.scan[dir].x,
ny = y + core.utils.scan[dir].y;
if (nx < 0 || nx >= width || ny < 0 || ny >= height) continue;
if (!core.isset(core.status.checkBlock.ambush[nx + ny * width]))
if (!core.status.checkBlock.ambush[nx + ny * width])
core.status.checkBlock.ambush[nx + ny * width] = [];
core.status.checkBlock.ambush[nx + ny * width].push([x, y, id, dir]);
}
@ -1136,9 +1116,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
if (x > 0 && x < width - 1) {
var id1 = core.status.checkBlock.map[x - 1 +width * y],
id2 = core.status.checkBlock.map[x + 1 + width * y];
if (core.isset(id1) && core.isset(id2) && id1 == id2) {
if (id1 != null && id2 != null && id1 == id2) {
var enemy = core.material.enemys[id1];
if (core.isset(enemy) && core.enemys.hasSpecial(enemy.special, 16)) {
if (enemy && core.enemys.hasSpecial(enemy.special, 16)) {
has = true;
}
}
@ -1147,9 +1127,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
if (y > 0 && y < height - 1) {
var id1 = core.status.checkBlock.map[x + width * (y - 1)],
id2 = core.status.checkBlock.map[x + width * (y + 1)];
if (core.isset(id1) && core.isset(id2) && id1 == id2) {
if (id1 != null && id2 != null && id1 == id2) {
var enemy = core.material.enemys[id1];
if (core.isset(enemy) && core.enemys.hasSpecial(enemy.special, 16)) {
if (enemy && core.enemys.hasSpecial(enemy.special, 16)) {
has = true;
}
}
@ -1308,7 +1288,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
if (!core.isPlaying()) return;
// 执行当前楼层的并行事件处理
if (core.isset(core.status.floorId)) {
if (core.status.floorId) {
try {
eval(core.floors[core.status.floorId].parallelDo);
} catch (e) {
@ -1377,7 +1357,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
core.clearMap(name);
// 绘制色调层,默认不透明度
if (!core.isset(color)) color = 0.9;
if (color == null) color = 0.9;
ctx.fillStyle = "rgba(0,0,0,"+color+")";
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);