Replay use full name

This commit is contained in:
oc 2018-03-10 01:09:07 +08:00
parent 882446c442
commit c9ba70fa9c
4 changed files with 38 additions and 29 deletions

View File

@ -185,8 +185,8 @@ actions.prototype.keyDown = function(keyCode) {
}
////// 根据放开键的code来执行一系列操作 //////
actions.prototype.keyUp = function(keyCode) {
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
actions.prototype.keyUp = function(keyCode, fromReplay) {
if (!fromReplay&&core.isset(core.status.replay)&&core.status.replay.replaying) return;
if (core.status.lockControl) {
core.status.holdingKeys = [];

View File

@ -1485,7 +1485,7 @@ control.prototype.replay = function () {
core.events.openShop(shopId, false);
var shopInterval = setInterval(function () {
if (!core.events.clickShop(6, topIndex+core.status.event.selection)) {
if (!core.actions.clickShop(6, topIndex+core.status.event.selection)) {
clearInterval(shopInterval);
core.stopReplay();
core.drawTip("录像文件出错");
@ -1493,7 +1493,7 @@ control.prototype.replay = function () {
}
if (selections.length==0) {
clearInterval(shopInterval);
core.events.clickShop(6, topIndex+choices.length);
core.actions.clickShop(6, topIndex+choices.length);
core.replay();
return;
}
@ -1535,6 +1535,11 @@ control.prototype.replay = function () {
return;
}
}
else if (action.indexOf('key:')==0) {
core.actions.keyUp(parseInt(action.substring(4)), true);
core.replay();
return;
}
core.stopReplay();
core.insertAction("录像文件出错");

View File

@ -224,9 +224,10 @@ events.prototype.doAction = function() {
// 事件处理完毕
if (core.status.event.data.list.length==0) {
var callback = core.status.event.data.callback;
core.ui.closePanel();
if (core.isset(core.status.event.data.callback))
core.status.event.data.callback();
if (core.isset(callback))
callback();
core.replay();
return;
}

View File

@ -158,8 +158,6 @@ utils.prototype.encodeRoute = function (route) {
var ans="";
var lastMove = "", cnt=0;
var items=Object.keys(core.material.items).sort();
var shops=Object.keys(core.initStatus.shops).sort();
route.forEach(function (t) {
if (t=='up' || t=='down' || t=='left' || t=='right') {
if (t!=lastMove && cnt>0) {
@ -177,15 +175,13 @@ utils.prototype.encodeRoute = function (route) {
cnt=0;
}
if (t.indexOf('item:')==0)
ans+="I"+items.indexOf(t.substring(5));
ans+="I"+t.substring(5)+":";
else if (t.indexOf('fly:')==0)
ans+="F"+core.floorIds.indexOf(t.substring(4));
ans+="F"+t.substring(4)+":";
else if (t.indexOf('choices:')==0)
ans+="C"+t.substring(8);
else if (t.indexOf('shop:')==0) {
var sp=t.substring(5).split(":");
ans+="S"+shops.indexOf(sp[0])+":"+sp[1];
}
else if (t.indexOf('shop:')==0)
ans+="S"+t.substring(5);
else if (t=='turn')
ans+='T';
else if (t=='getNext')
@ -194,9 +190,10 @@ utils.prototype.encodeRoute = function (route) {
ans+="P"+t.substring(6);
else if (t=='no')
ans+='N';
else if (t.indexOf('move:')==0) {
else if (t.indexOf('move:')==0)
ans+="M"+t.substring(5);
}
else if (t=='key:')
ans+='K'+t.substring(4);
}
});
if (cnt>0) {
@ -221,27 +218,33 @@ utils.prototype.decodeRoute = function (route) {
if (num.length==0) num="1";
return core.isset(noparse)?num:parseInt(num);
}
var getString = function () {
var str="";
while (index<route.length && /\w/.test(route.charAt(index))) {
str+=route.charAt(index++);
}
return str;
}
var items=Object.keys(core.material.items).sort();
var shops=Object.keys(core.initStatus.shops).sort();
while (index<route.length) {
var c=route.charAt(index++);
var number=getNumber();
var nxt=(c=='I'||c=='F'||c=='S')?getString():getNumber();
switch (c) {
case "U": for (var i=0;i<number;i++) ans.push("up"); break;
case "D": for (var i=0;i<number;i++) ans.push("down"); break;
case "L": for (var i=0;i<number;i++) ans.push("left"); break;
case "R": for (var i=0;i<number;i++) ans.push("right"); break;
case "I": ans.push("item:"+items[number]); break;
case "F": ans.push("fly:"+core.floorIds[number]); break;
case "C": ans.push("choices:"+number); break;
case "S": ++index; ans.push("shop:"+shops[number]+":"+getNumber(true)); break;
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 "I": ++index; ans.push("item:"+nxt); break;
case "F": ++index; ans.push("fly:"+nxt); break;
case "C": ans.push("choices:"+nxt); break;
case "S": ++index; ans.push("shop:"+nxt+":"+getNumber(true)); break;
case "T": ans.push("turn"); break;
case "G": ans.push("getNext"); break;
case "P": ans.push("input:"+number); break;
case "P": ans.push("input:"+nxt); break;
case "N": ans.push("no"); break;
case "M": ++index; ans.push("move:"+number+":"+getNumber()); break;
case "M": ++index; ans.push("move:"+nxt+":"+getNumber()); break;
case "K": ans.push("key:"+nxt); break;
}
}
return ans;