diff --git a/libs/control.js b/libs/control.js index 6eed9e72..a59adf5a 100644 --- a/libs/control.js +++ b/libs/control.js @@ -752,7 +752,14 @@ control.prototype.moveAction = function (callback) { } ////// 转向 ////// -control.prototype.turnHero = function() { +control.prototype.turnHero = function(direction) { + if (core.isset(direction)) { + core.setHeroLoc('direction', direction); + core.drawHero(); + core.clearMap('route'); + core.status.route.push("turn:"+direction); + return; + } if (core.status.hero.loc.direction == 'up') core.status.hero.loc.direction = 'right'; else if (core.status.hero.loc.direction == 'right') core.status.hero.loc.direction = 'down'; else if (core.status.hero.loc.direction == 'down') core.status.hero.loc.direction = 'left'; @@ -2008,6 +2015,11 @@ control.prototype.replay = function () { core.replay(); return; } + else if (action.indexOf("turn:")==0) { + core.turnHero(action.substring(5)); + core.replay(); + return; + } else if (action=='getNext') { if (core.flags.enableGentleClick && core.getBlock(core.nextX(), core.nextY())!=null) { var nextX = core.nextX(), nextY = core.nextY(); @@ -2180,7 +2192,10 @@ control.prototype.autosave = function (removeLast) { var x=null; if (removeLast) x=core.status.route.pop(); + // 加入当前方向 + core.status.route.push("turn:"+core.getHeroLoc('direction')); core.setLocalForage("autoSave", core.saveData()) + core.status.route.pop(); if (removeLast && core.isset(x)) core.status.route.push(x); } diff --git a/libs/core.js b/libs/core.js index 24adfd2a..ee47c077 100644 --- a/libs/core.js +++ b/libs/core.js @@ -474,8 +474,8 @@ core.prototype.moveAction = function (callback) { } ////// 转向 ////// -core.prototype.turnHero = function() { - core.control.turnHero(); +core.prototype.turnHero = function(direction) { + core.control.turnHero(direction); } ////// 勇士能否前往某方向 ////// diff --git a/libs/utils.js b/libs/utils.js index b8ed902c..d7e0881f 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -332,6 +332,8 @@ utils.prototype.encodeRoute = function (route) { ans+="S"+t.substring(5); else if (t=='turn') ans+='T'; + else if (t.indexOf('turn:')==0) + ans+="t"+t.substring(5).substring(0,1).toUpperCase()+":"; else if (t=='getNext') ans+='G'; else if (t.indexOf('input:')==0) @@ -381,18 +383,23 @@ utils.prototype.decodeRoute = function (route) { while (index