Record & Encode route
This commit is contained in:
parent
7eb05cb44d
commit
c88a31f4c3
50
libs/core.js
50
libs/core.js
@ -79,6 +79,7 @@ function core() {
|
||||
'mouseOutCheck': 1,
|
||||
'moveStepBeforeStop': [],
|
||||
'downTime': null,
|
||||
'route': [], // 当前路线!
|
||||
|
||||
// 勇士状态;中心对称飞行器
|
||||
|
||||
@ -1411,6 +1412,7 @@ core.prototype.setHeroMoveTriggerInterval = function () {
|
||||
y = core.getHeroLoc('y');
|
||||
var noPass = core.noPass(x + scan[direction].x, y + scan[direction].y), canMove = core.canMoveHero();
|
||||
if (noPass || !canMove) {
|
||||
core.status.route.push(direction);
|
||||
if (canMove) // 非箭头:触发
|
||||
core.trigger(x + scan[direction].x, y + scan[direction].y);
|
||||
core.drawHero(direction, x, y, 'stop');
|
||||
@ -1443,6 +1445,7 @@ core.prototype.setHeroMoveTriggerInterval = function () {
|
||||
else if (core.status.heroStop) {
|
||||
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
|
||||
}
|
||||
core.status.route.push(direction);
|
||||
core.trigger(core.getHeroLoc('x'), core.getHeroLoc('y'));
|
||||
clearInterval(core.interval.heroMoveInterval);
|
||||
core.status.heroMoving = false;
|
||||
@ -3598,6 +3601,53 @@ core.prototype.loadData = function (data, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
////// 加密路线 //////
|
||||
core.prototype.encodeRoute = function (route) {
|
||||
var ans="";
|
||||
var lastMove = "", cnt=0;
|
||||
|
||||
var items=Object.keys(core.material.items).sort();
|
||||
var shops=Object.keys(core.status.shops).sort();
|
||||
route.forEach(function (t) {
|
||||
if (t=='up' || t=='down' || t=='left' || t=='right') {
|
||||
if (t!=lastMove && cnt>0) {
|
||||
ans+=lastMove.substring(0,1).toUpperCase();
|
||||
if (cnt>1) ans+=cnt;
|
||||
cnt=0;
|
||||
}
|
||||
lastMove=t;
|
||||
cnt++;
|
||||
}
|
||||
else {
|
||||
if (cnt>0) {
|
||||
ans+=lastMove.substring(0,1).toUpperCase();
|
||||
if (cnt>1) ans+=cnt;
|
||||
cnt=0;
|
||||
}
|
||||
if (t.indexOf('item:')==0)
|
||||
ans+="I"+items.indexOf(t.substring(5));
|
||||
else if (t.indexOf('fly:')==0)
|
||||
ans+="F"+core.floorIds.indexOf(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];
|
||||
}
|
||||
}
|
||||
});
|
||||
if (cnt>0) {
|
||||
ans+=lastMove.substring(0,1).toUpperCase();
|
||||
if (cnt>1) ans+=cnt;
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
////// 解密路线 //////
|
||||
core.prototype.decodeRoute = function (route) {
|
||||
|
||||
}
|
||||
|
||||
////// 设置勇士属性 //////
|
||||
core.prototype.setStatus = function (statusName, statusVal) {
|
||||
core.status.hero[statusName] = statusVal;
|
||||
|
||||
@ -43,7 +43,7 @@ data.prototype.init = function() {
|
||||
{
|
||||
"id": "moneyShop1", // 商店唯一ID
|
||||
"name": "贪婪之神", // 商店名称(标题)
|
||||
"icon": "blueShop", // 商店图标,blueShop为蓝色商店,pinkShop为粉色商店
|
||||
"icon": "blueShop", // 商店图标,在icons.js中的npc一项定义
|
||||
"textInList": "1F金币商店", // 在快捷商店栏中显示的名称
|
||||
"use": "money", // 商店所要使用的。只能是"money"或"experience"。
|
||||
"need": "20+10*times*(times+1)", // 商店需要的金币/经验数值;可以是一个表达式,以times作为参数计算。
|
||||
@ -96,7 +96,7 @@ data.prototype.init = function() {
|
||||
|
||||
// effect也允许写一个function,代表本次升级将会执行的操作
|
||||
{"need": 40, "effect": function () {
|
||||
core.drawText("恭喜升级!");
|
||||
core.insertAction("恭喜升级!");
|
||||
core.status.hero.hp *= 2;
|
||||
core.status.hero.atk += 100;
|
||||
core.status.hero.def += 100;
|
||||
|
||||
@ -433,11 +433,15 @@ events.prototype.openShop = function(shopId, needVisited) {
|
||||
shop.visited = true;
|
||||
|
||||
var selection = core.status.event.selection;
|
||||
var actions = [];
|
||||
if (core.isset(core.status.event.data) && core.isset(core.status.event.data.actions))
|
||||
actions=core.status.event.data.actions;
|
||||
|
||||
core.ui.closePanel();
|
||||
core.lockControl();
|
||||
// core.status.event = {'id': 'shop', 'data': {'id': shopId, 'shop': shop}};
|
||||
core.status.event.id = 'shop';
|
||||
core.status.event.data = {'id': shopId, 'shop': shop};
|
||||
core.status.event.data = {'id': shopId, 'shop': shop, 'actions': actions};
|
||||
core.status.event.selection = selection;
|
||||
|
||||
// 拼词
|
||||
@ -774,6 +778,8 @@ events.prototype.clickAction = function (x,y) {
|
||||
if (x >= 5 && x <= 7) {
|
||||
var topIndex = 6 - parseInt((choices.length - 1) / 2);
|
||||
if (y>=topIndex && y<topIndex+choices.length) {
|
||||
// 选择
|
||||
core.status.route.push("choices:"+(y-topIndex));
|
||||
this.insertAction(choices[y-topIndex].action);
|
||||
this.doAction();
|
||||
}
|
||||
@ -812,6 +818,7 @@ events.prototype.keyUpAction = function (keycode) {
|
||||
var choices = data.choices;
|
||||
if (choices.length>0) {
|
||||
if (keycode==13 || keycode==32 || keycode==67) {
|
||||
core.status.route.push("choices:"+core.status.event.selection);
|
||||
this.insertAction(choices[core.status.event.selection].action);
|
||||
this.doAction();
|
||||
}
|
||||
@ -888,6 +895,7 @@ events.prototype.clickFly = function(x,y) {
|
||||
var index=core.status.hero.flyRange.indexOf(core.status.floorId);
|
||||
var stair=core.status.event.data<index?"upFloor":"downFloor";
|
||||
var floorId=core.status.event.data;
|
||||
core.status.route.push("fly:"+core.status.hero.flyRange[floorId]);
|
||||
core.changeFloor(core.status.hero.flyRange[floorId], stair);
|
||||
core.ui.closePanel();
|
||||
}
|
||||
@ -933,8 +941,9 @@ events.prototype.clickShop = function(x,y) {
|
||||
return;
|
||||
}
|
||||
|
||||
eval(use+'-='+need);
|
||||
core.status.event.data.actions.push(y-topIndex);
|
||||
|
||||
eval(use+'-='+need);
|
||||
core.setStatus('money', money);
|
||||
core.setStatus('experience', experience);
|
||||
|
||||
@ -948,6 +957,10 @@ events.prototype.clickShop = function(x,y) {
|
||||
}
|
||||
// 离开
|
||||
else if (y==topIndex+choices.length) {
|
||||
if (core.status.event.data.actions.length>0) {
|
||||
core.status.route.push("shop:"+core.status.event.data.id+":"+core.status.event.data.actions.join(""));
|
||||
}
|
||||
|
||||
core.status.boxAnimateObjs = [];
|
||||
core.setBoxAnimate();
|
||||
if (core.status.event.data.fromList)
|
||||
|
||||
@ -193,6 +193,12 @@ items.prototype.useItem = function (itemId) {
|
||||
core.setFlag('curse', false);
|
||||
}
|
||||
core.updateStatusBar();
|
||||
|
||||
// 记录路线
|
||||
if (itemId!='book' && itemId!='fly') {
|
||||
core.status.route.push("item:"+itemId);
|
||||
}
|
||||
|
||||
// 道具使用完毕:删除
|
||||
if (itemCls=='tools')
|
||||
core.status.hero.items[itemCls][itemId]--;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user