Fix autoSave+turn
This commit is contained in:
parent
a6e9be4fd4
commit
56bb87c64e
@ -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';
|
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 == 'right') core.status.hero.loc.direction = 'down';
|
||||||
else if (core.status.hero.loc.direction == 'down') core.status.hero.loc.direction = 'left';
|
else if (core.status.hero.loc.direction == 'down') core.status.hero.loc.direction = 'left';
|
||||||
@ -2008,6 +2015,11 @@ control.prototype.replay = function () {
|
|||||||
core.replay();
|
core.replay();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if (action.indexOf("turn:")==0) {
|
||||||
|
core.turnHero(action.substring(5));
|
||||||
|
core.replay();
|
||||||
|
return;
|
||||||
|
}
|
||||||
else if (action=='getNext') {
|
else if (action=='getNext') {
|
||||||
if (core.flags.enableGentleClick && core.getBlock(core.nextX(), core.nextY())!=null) {
|
if (core.flags.enableGentleClick && core.getBlock(core.nextX(), core.nextY())!=null) {
|
||||||
var nextX = core.nextX(), nextY = core.nextY();
|
var nextX = core.nextX(), nextY = core.nextY();
|
||||||
@ -2180,7 +2192,10 @@ control.prototype.autosave = function (removeLast) {
|
|||||||
var x=null;
|
var x=null;
|
||||||
if (removeLast)
|
if (removeLast)
|
||||||
x=core.status.route.pop();
|
x=core.status.route.pop();
|
||||||
|
// 加入当前方向
|
||||||
|
core.status.route.push("turn:"+core.getHeroLoc('direction'));
|
||||||
core.setLocalForage("autoSave", core.saveData())
|
core.setLocalForage("autoSave", core.saveData())
|
||||||
|
core.status.route.pop();
|
||||||
if (removeLast && core.isset(x))
|
if (removeLast && core.isset(x))
|
||||||
core.status.route.push(x);
|
core.status.route.push(x);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -474,8 +474,8 @@ core.prototype.moveAction = function (callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
////// 转向 //////
|
////// 转向 //////
|
||||||
core.prototype.turnHero = function() {
|
core.prototype.turnHero = function(direction) {
|
||||||
core.control.turnHero();
|
core.control.turnHero(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 勇士能否前往某方向 //////
|
////// 勇士能否前往某方向 //////
|
||||||
|
|||||||
@ -332,6 +332,8 @@ utils.prototype.encodeRoute = function (route) {
|
|||||||
ans+="S"+t.substring(5);
|
ans+="S"+t.substring(5);
|
||||||
else if (t=='turn')
|
else if (t=='turn')
|
||||||
ans+='T';
|
ans+='T';
|
||||||
|
else if (t.indexOf('turn:')==0)
|
||||||
|
ans+="t"+t.substring(5).substring(0,1).toUpperCase()+":";
|
||||||
else if (t=='getNext')
|
else if (t=='getNext')
|
||||||
ans+='G';
|
ans+='G';
|
||||||
else if (t.indexOf('input:')==0)
|
else if (t.indexOf('input:')==0)
|
||||||
@ -381,18 +383,23 @@ utils.prototype.decodeRoute = function (route) {
|
|||||||
|
|
||||||
while (index<route.length) {
|
while (index<route.length) {
|
||||||
var c=route.charAt(index++);
|
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) {
|
switch (c) {
|
||||||
case "U": for (var i=0;i<nxt;i++) ans.push("up"); break;
|
case "U": case "D": case "L": case "R": for (var i=0;i<nxt;i++) ans.push(mp[c]); 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 "I": ans.push("item:"+nxt); break;
|
case "I": ans.push("item:"+nxt); break;
|
||||||
case "F": ans.push("fly:"+nxt); break;
|
case "F": ans.push("fly:"+nxt); break;
|
||||||
case "C": ans.push("choices:"+nxt); break;
|
case "C": ans.push("choices:"+nxt); break;
|
||||||
case "S": ans.push("shop:"+nxt+":"+getNumber(true)); break;
|
case "S": ans.push("shop:"+nxt+":"+getNumber(true)); break;
|
||||||
case "T": ans.push("turn"); break;
|
case "T": ans.push("turn"); break;
|
||||||
|
case "t": ans.push("turn:"+mp[nxt]); break;
|
||||||
case "G": ans.push("getNext"); break;
|
case "G": ans.push("getNext"); break;
|
||||||
case "P": ans.push("input:"+nxt); break;
|
case "P": ans.push("input:"+nxt); break;
|
||||||
case "Q": ans.push("input2:"+nxt); break;
|
case "Q": ans.push("input2:"+nxt); break;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user