diff --git a/libs/enemys.js b/libs/enemys.js index 9dc0470f..3c90d768 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -35,8 +35,18 @@ enemys.prototype.getEnemys = function () { if (enemys[id].faceIds) { var downId = enemys[id].faceIds.down; if (downId != null && downId != id && enemys[downId]) { - enemys[id] = core.clone(enemys[downId]); - enemys[id].id = id; + enemys[id] = {id: id}; + for (var property in enemys[downId]) { + if (property != 'id' && enemys[downId].hasOwnProperty(property)) { + (function (id, downId, property) { + Object.defineProperty(enemys[id], property, { + get: function () { return enemys[downId][property] }, + set: function (v) { enemys[downId][property] = v }, + enumerable: true + }) + })(id, downId, property); + } + } } } } diff --git a/libs/utils.js b/libs/utils.js index 021c1bd7..521c688e 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -803,17 +803,20 @@ utils.prototype.strlen = function (str) { utils.prototype.turnDirection = function (turn, direction) { direction = direction || core.getHeroLoc('direction'); - var directionList = ["left", "up", "right", "down"]; + var directionList = ["left", "leftup", "up", "rightup", "right", "rightdown", "down", "leftdown"]; if (directionList.indexOf(turn) >= 0) return turn; - switch (turn) { - case ':left': turn = 3; break; // turn left - case ':right': turn = 1; break; // turn right - case ':back': turn = 2; break; // turn back - default: turn = 0; break; + if (typeof turn === 'number' && turn % 45 == 0) turn /= 45; + else { + switch (turn) { + case ':left': turn = 6; break; // turn left + case ':right': turn = 2; break; // turn right + case ':back': turn = 4; break; // turn back + default: turn = 0; break; + } } var index = directionList.indexOf(direction); if (index < 0) return direction; - return directionList[(index + (turn || 0)) % 4]; + return directionList[(index + (turn || 0)) % directionList.length]; } utils.prototype.matchWildcard = function (pattern, string) {