Fix autoSave+turn

This commit is contained in:
ckcz123 2018-09-06 15:15:50 +08:00
parent a6e9be4fd4
commit 56bb87c64e
3 changed files with 30 additions and 8 deletions

View File

@ -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);
}

View File

@ -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);
}
////// 勇士能否前往某方向 //////

View File

@ -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<route.length) {
var c=route.charAt(index++);
var nxt=(c=='I'||c=='F'||c=='S'||c=='Q')?getString():getNumber();
var nxt=(c=='I'||c=='F'||c=='S'||c=='Q'||c=='t')?getString():getNumber();
var mp = {
"U": "up",
"D": "down",
"L": "left",
"R": "right"
}
switch (c) {
case "U": for (var i=0;i<nxt;i++) ans.push("up"); break;
case "D": for (var i=0;i<nxt;i++) ans.push("down"); break;
case "L": for (var i=0;i<nxt;i++) ans.push("left"); break;
case "R": for (var i=0;i<nxt;i++) ans.push("right"); break;
case "U": case "D": case "L": case "R": for (var i=0;i<nxt;i++) ans.push(mp[c]); break;
case "I": ans.push("item:"+nxt); break;
case "F": ans.push("fly:"+nxt); break;
case "C": ans.push("choices:"+nxt); break;
case "S": ans.push("shop:"+nxt+":"+getNumber(true)); break;
case "T": ans.push("turn"); break;
case "t": ans.push("turn:"+mp[nxt]); break;
case "G": ans.push("getNext"); break;
case "P": ans.push("input:"+nxt); break;
case "Q": ans.push("input2:"+nxt); break;