Adjust order
This commit is contained in:
parent
d440987345
commit
6a22e27e09
@ -395,7 +395,7 @@ actions.prototype.ondown = function (loc) {
|
|||||||
actions.prototype._sys_ondown_paint = function (x, y, px, py) {
|
actions.prototype._sys_ondown_paint = function (x, y, px, py) {
|
||||||
// 画板
|
// 画板
|
||||||
if (core.status.played && (core.status.event || {}).id == 'paint') {
|
if (core.status.played && (core.status.event || {}).id == 'paint') {
|
||||||
this.ondownPaint(px, py);
|
this._ondownPaint(px, py);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -452,7 +452,7 @@ actions.prototype.onmove = function (loc) {
|
|||||||
actions.prototype._sys_onmove_paint = function (x, y, px, py) {
|
actions.prototype._sys_onmove_paint = function (x, y, px, py) {
|
||||||
// 画板
|
// 画板
|
||||||
if (core.status.played && (core.status.event || {}).id == 'paint') {
|
if (core.status.played && (core.status.event || {}).id == 'paint') {
|
||||||
this.onmovePaint(px, py);
|
this._onmovePaint(px, py);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -488,7 +488,7 @@ actions.prototype.onup = function () {
|
|||||||
actions.prototype._sys_onup_paint = function () {
|
actions.prototype._sys_onup_paint = function () {
|
||||||
// 画板
|
// 画板
|
||||||
if (core.status.played && (core.status.event || {}).id == 'paint') {
|
if (core.status.played && (core.status.event || {}).id == 'paint') {
|
||||||
this.onupPaint();
|
this._onupPaint();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2327,7 +2327,7 @@ actions.prototype._keyUpCursor = function (keycode) {
|
|||||||
|
|
||||||
////// 绘图相关 //////
|
////// 绘图相关 //////
|
||||||
|
|
||||||
actions.prototype.ondownPaint = function (x, y) {
|
actions.prototype._ondownPaint = function (x, y) {
|
||||||
x+=core.bigmap.offsetX;
|
x+=core.bigmap.offsetX;
|
||||||
y+=core.bigmap.offsetY;
|
y+=core.bigmap.offsetY;
|
||||||
if (!core.status.event.data.erase) {
|
if (!core.status.event.data.erase) {
|
||||||
@ -2338,7 +2338,7 @@ actions.prototype.ondownPaint = function (x, y) {
|
|||||||
core.status.event.data.y = y;
|
core.status.event.data.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
actions.prototype.onmovePaint = function (x, y) {
|
actions.prototype._onmovePaint = function (x, y) {
|
||||||
if (core.status.event.data.x==null) return;
|
if (core.status.event.data.x==null) return;
|
||||||
x+=core.bigmap.offsetX;
|
x+=core.bigmap.offsetX;
|
||||||
y+=core.bigmap.offsetY;
|
y+=core.bigmap.offsetY;
|
||||||
@ -2353,7 +2353,7 @@ actions.prototype.onmovePaint = function (x, y) {
|
|||||||
core.status.event.data.y = y;
|
core.status.event.data.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
actions.prototype.onupPaint = function () {
|
actions.prototype._onupPaint = function () {
|
||||||
core.status.event.data.x = null;
|
core.status.event.data.x = null;
|
||||||
core.status.event.data.y = null;
|
core.status.event.data.y = null;
|
||||||
// 保存
|
// 保存
|
||||||
|
|||||||
@ -47,15 +47,6 @@ enemys.prototype.getSpecials = function () {
|
|||||||
return this.enemydata.getSpecials();
|
return this.enemydata.getSpecials();
|
||||||
}
|
}
|
||||||
|
|
||||||
enemys.prototype._calSpecialContent = function (enemy, content) {
|
|
||||||
if (typeof content == 'string') return content;
|
|
||||||
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
|
||||||
if (content instanceof Function) {
|
|
||||||
return content(enemy);
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
////// 获得所有特殊属性的名称 //////
|
////// 获得所有特殊属性的名称 //////
|
||||||
enemys.prototype.getSpecialText = function (enemy) {
|
enemys.prototype.getSpecialText = function (enemy) {
|
||||||
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
||||||
@ -95,6 +86,15 @@ enemys.prototype.getSpecialHint = function (enemy, special) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enemys.prototype._calSpecialContent = function (enemy, content) {
|
||||||
|
if (typeof content == 'string') return content;
|
||||||
|
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
||||||
|
if (content instanceof Function) {
|
||||||
|
return content(enemy);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
////// 能否获胜 //////
|
////// 能否获胜 //////
|
||||||
enemys.prototype.canBattle = function (enemy, x, y, floorId) {
|
enemys.prototype.canBattle = function (enemy, x, y, floorId) {
|
||||||
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
||||||
@ -155,6 +155,40 @@ enemys.prototype.getDamageString = function (enemy, x, y, floorId) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////// 接下来N个临界值和临界减伤计算 //////
|
||||||
|
enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) {
|
||||||
|
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
||||||
|
number = number||1;
|
||||||
|
|
||||||
|
if (this.hasSpecial(enemy.special, 10)) return []; // 模仿怪物临界
|
||||||
|
var info = this.getDamageInfo(enemy, null, x, y, floorId);
|
||||||
|
if (info == null || this.hasSpecial(enemy.special, 3)) { // 未破防,或是坚固怪
|
||||||
|
info = this.getEnemyInfo(enemy, null, x, y, floorId);
|
||||||
|
if (core.status.hero.atk<=info.def) {
|
||||||
|
return [[info.def+1-core.status.hero.atk,'?']];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// getDamageInfo直接返回数字;0伤且无负伤
|
||||||
|
if (typeof info == 'number' || (info.damage<=0 && !core.flags.enableNegativeDamage)) {
|
||||||
|
return [[0,0]];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (core.flags.useLoop) {
|
||||||
|
var LOOP_MAX_VALUE = 1;
|
||||||
|
if (core.status.hero.atk <= LOOP_MAX_VALUE) {
|
||||||
|
return this._nextCriticals_useLoop(enemy, info, number, x, y, floorId);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return this._nextCriticals_useBinarySearch(enemy, info, number, x, y, floorId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return this._nextCriticals_useTurn(enemy, info, number, x, y, floorId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enemys.prototype._nextCriticals_useLoop = function (enemy, info, number, x, y, floorId) {
|
enemys.prototype._nextCriticals_useLoop = function (enemy, info, number, x, y, floorId) {
|
||||||
var mon_hp = info.mon_hp, hero_atk = core.status.hero.atk, mon_def = info.mon_def, pre = info.damage;
|
var mon_hp = info.mon_hp, hero_atk = core.status.hero.atk, mon_def = info.mon_def, pre = info.damage;
|
||||||
var list = [];
|
var list = [];
|
||||||
@ -225,40 +259,6 @@ enemys.prototype._nextCriticals_useTurn = function (enemy, info, number, x, y, f
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 接下来N个临界值和临界减伤计算 //////
|
|
||||||
enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) {
|
|
||||||
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
|
||||||
number = number||1;
|
|
||||||
|
|
||||||
if (this.hasSpecial(enemy.special, 10)) return []; // 模仿怪物临界
|
|
||||||
var info = this.getDamageInfo(enemy, null, x, y, floorId);
|
|
||||||
if (info == null || this.hasSpecial(enemy.special, 3)) { // 未破防,或是坚固怪
|
|
||||||
info = this.getEnemyInfo(enemy, null, x, y, floorId);
|
|
||||||
if (core.status.hero.atk<=info.def) {
|
|
||||||
return [[info.def+1-core.status.hero.atk,'?']];
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
// getDamageInfo直接返回数字;0伤且无负伤
|
|
||||||
if (typeof info == 'number' || (info.damage<=0 && !core.flags.enableNegativeDamage)) {
|
|
||||||
return [[0,0]];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (core.flags.useLoop) {
|
|
||||||
var LOOP_MAX_VALUE = 1;
|
|
||||||
if (core.status.hero.atk <= LOOP_MAX_VALUE) {
|
|
||||||
return this._nextCriticals_useLoop(enemy, info, number, x, y, floorId);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return this._nextCriticals_useBinarySearch(enemy, info, number, x, y, floorId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return this._nextCriticals_useTurn(enemy, info, number, x, y, floorId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////// N防减伤计算 //////
|
////// N防减伤计算 //////
|
||||||
enemys.prototype.getDefDamage = function (enemy, k, x, y, floorId) {
|
enemys.prototype.getDefDamage = function (enemy, k, x, y, floorId) {
|
||||||
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
|
||||||
|
|||||||
124
libs/items.js
124
libs/items.js
@ -61,6 +61,21 @@ items.prototype.getItemEffectTip = function(itemId) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////// 使用道具 //////
|
||||||
|
items.prototype.useItem = function (itemId, noRoute, callback) {
|
||||||
|
if (!this.canUseItem(itemId)) {
|
||||||
|
if (core.isset(callback)) callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 执行道具效果
|
||||||
|
this._useItemEffect(itemId);
|
||||||
|
// 执行完毕
|
||||||
|
this._afterUseItem(itemId);
|
||||||
|
// 记录路线
|
||||||
|
if (!noRoute) core.status.route.push("item:"+itemId);
|
||||||
|
if (core.isset(callback)) callback();
|
||||||
|
}
|
||||||
|
|
||||||
items.prototype._useItemEffect = function (itemId) {
|
items.prototype._useItemEffect = function (itemId) {
|
||||||
if (itemId in this.useItemEffect) {
|
if (itemId in this.useItemEffect) {
|
||||||
try {
|
try {
|
||||||
@ -88,21 +103,6 @@ items.prototype._afterUseItem = function (itemId) {
|
|||||||
core.updateStatusBar();
|
core.updateStatusBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 使用道具 //////
|
|
||||||
items.prototype.useItem = function (itemId, noRoute, callback) {
|
|
||||||
if (!this.canUseItem(itemId)) {
|
|
||||||
if (core.isset(callback)) callback();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 执行道具效果
|
|
||||||
this._useItemEffect(itemId);
|
|
||||||
// 执行完毕
|
|
||||||
this._afterUseItem(itemId);
|
|
||||||
// 记录路线
|
|
||||||
if (!noRoute) core.status.route.push("item:"+itemId);
|
|
||||||
if (core.isset(callback)) callback();
|
|
||||||
}
|
|
||||||
|
|
||||||
////// 当前能否使用道具 //////
|
////// 当前能否使用道具 //////
|
||||||
items.prototype.canUseItem = function (itemId) {
|
items.prototype.canUseItem = function (itemId) {
|
||||||
// 没有道具
|
// 没有道具
|
||||||
@ -266,53 +266,6 @@ items.prototype.canEquip = function (equipId, hint) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 实际换装的效果 //////
|
|
||||||
items.prototype._loadEquipEffect = function (equipId, unloadEquipId, isPercentage) {
|
|
||||||
// 比较能力值
|
|
||||||
var result = core.compareEquipment(equipId, unloadEquipId);
|
|
||||||
|
|
||||||
if (isPercentage) {
|
|
||||||
for (var v in result)
|
|
||||||
core.addFlag('__'+v+'_buff__', result[v]/100);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (var v in result)
|
|
||||||
core.status.hero[v] += result[v];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
items.prototype._realLoadEquip = function (type, loadId, unloadId, callback) {
|
|
||||||
var loadEquip = core.material.items[loadId] || {}, unloadEquip = core.material.items[unloadId] || {};
|
|
||||||
if (!core.isset(loadEquip.equip)) loadEquip.equip = {};
|
|
||||||
if (!core.isset(unloadEquip.equip)) unloadEquip.equip = {};
|
|
||||||
|
|
||||||
var loadPercentage = loadEquip.equip.percentage, unloadPercentage = unloadEquip.equip.percentage;
|
|
||||||
|
|
||||||
if (loadPercentage != null && unloadPercentage != null && loadPercentage != unloadPercentage) {
|
|
||||||
this.unloadEquip(type);
|
|
||||||
this.loadEquip(loadId);
|
|
||||||
if (core.isset(callback)) callback();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- 音效
|
|
||||||
core.playSound('equip.mp3');
|
|
||||||
|
|
||||||
// --- 实际换装
|
|
||||||
this._loadEquipEffect(loadId, unloadId, loadPercentage==null?unloadPercentage:loadPercentage);
|
|
||||||
|
|
||||||
// --- 加减
|
|
||||||
if (loadId) core.removeItem(loadId);
|
|
||||||
if (unloadId) core.addItem(unloadId);
|
|
||||||
core.status.hero.equipment[type] = loadId||null;
|
|
||||||
|
|
||||||
// --- 提示
|
|
||||||
if (loadId) core.drawTip("已装备上"+loadEquip.name, core.material.icons.items[loadId]);
|
|
||||||
else if (unloadId) core.drawTip("已卸下"+unloadEquip.name, core.material.icons.items[unloadId]);
|
|
||||||
|
|
||||||
if (core.isset(callback)) callback();
|
|
||||||
}
|
|
||||||
|
|
||||||
////// 换上 //////
|
////// 换上 //////
|
||||||
items.prototype.loadEquip = function (equipId, callback) {
|
items.prototype.loadEquip = function (equipId, callback) {
|
||||||
if (!core.isset(core.status.hero)) return null;
|
if (!core.isset(core.status.hero)) return null;
|
||||||
@ -364,6 +317,53 @@ items.prototype.compareEquipment = function (compareEquipId, beComparedEquipId)
|
|||||||
return {"atk":compareAtk,"def":compareDef,"mdef":compareMdef};
|
return {"atk":compareAtk,"def":compareDef,"mdef":compareMdef};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////// 实际换装的效果 //////
|
||||||
|
items.prototype._loadEquipEffect = function (equipId, unloadEquipId, isPercentage) {
|
||||||
|
// 比较能力值
|
||||||
|
var result = core.compareEquipment(equipId, unloadEquipId);
|
||||||
|
|
||||||
|
if (isPercentage) {
|
||||||
|
for (var v in result)
|
||||||
|
core.addFlag('__'+v+'_buff__', result[v]/100);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (var v in result)
|
||||||
|
core.status.hero[v] += result[v];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
items.prototype._realLoadEquip = function (type, loadId, unloadId, callback) {
|
||||||
|
var loadEquip = core.material.items[loadId] || {}, unloadEquip = core.material.items[unloadId] || {};
|
||||||
|
if (!core.isset(loadEquip.equip)) loadEquip.equip = {};
|
||||||
|
if (!core.isset(unloadEquip.equip)) unloadEquip.equip = {};
|
||||||
|
|
||||||
|
var loadPercentage = loadEquip.equip.percentage, unloadPercentage = unloadEquip.equip.percentage;
|
||||||
|
|
||||||
|
if (loadPercentage != null && unloadPercentage != null && loadPercentage != unloadPercentage) {
|
||||||
|
this.unloadEquip(type);
|
||||||
|
this.loadEquip(loadId);
|
||||||
|
if (core.isset(callback)) callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- 音效
|
||||||
|
core.playSound('equip.mp3');
|
||||||
|
|
||||||
|
// --- 实际换装
|
||||||
|
this._loadEquipEffect(loadId, unloadId, loadPercentage==null?unloadPercentage:loadPercentage);
|
||||||
|
|
||||||
|
// --- 加减
|
||||||
|
if (loadId) core.removeItem(loadId);
|
||||||
|
if (unloadId) core.addItem(unloadId);
|
||||||
|
core.status.hero.equipment[type] = loadId||null;
|
||||||
|
|
||||||
|
// --- 提示
|
||||||
|
if (loadId) core.drawTip("已装备上"+loadEquip.name, core.material.icons.items[loadId]);
|
||||||
|
else if (unloadId) core.drawTip("已卸下"+unloadEquip.name, core.material.icons.items[unloadId]);
|
||||||
|
|
||||||
|
if (core.isset(callback)) callback();
|
||||||
|
}
|
||||||
|
|
||||||
////// 保存装备 //////
|
////// 保存装备 //////
|
||||||
items.prototype.quickSaveEquip = function (index) {
|
items.prototype.quickSaveEquip = function (index) {
|
||||||
if (!core.isset(core.status.hero.equipment)) core.status.hero.equipment = [];
|
if (!core.isset(core.status.hero.equipment)) core.status.hero.equipment = [];
|
||||||
|
|||||||
@ -13,12 +13,12 @@ loader.prototype._init = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
////// 设置加载进度条进度 //////
|
////// 设置加载进度条进度 //////
|
||||||
loader.prototype.setStartProgressVal = function (val) {
|
loader.prototype._setStartProgressVal = function (val) {
|
||||||
core.dom.startTopProgress.style.width = val + '%';
|
core.dom.startTopProgress.style.width = val + '%';
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 设置加载进度条提示文字 //////
|
////// 设置加载进度条提示文字 //////
|
||||||
loader.prototype.setStartLoadTipText = function (text) {
|
loader.prototype._setStartLoadTipText = function (text) {
|
||||||
core.dom.startTopLoadTips.innerHTML = text;
|
core.dom.startTopLoadTips.innerHTML = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,10 +106,10 @@ loader.prototype.loadImages = function (names, toSave, callback) {
|
|||||||
var items = 0;
|
var items = 0;
|
||||||
for (var i=0;i<names.length;i++) {
|
for (var i=0;i<names.length;i++) {
|
||||||
this.loadImage(names[i], function (id, image) {
|
this.loadImage(names[i], function (id, image) {
|
||||||
core.loader.setStartLoadTipText('正在加载图片 ' + id + "...");
|
core.loader._setStartLoadTipText('正在加载图片 ' + id + "...");
|
||||||
toSave[id] = image;
|
toSave[id] = image;
|
||||||
items++;
|
items++;
|
||||||
core.loader.setStartProgressVal(items * (100 / names.length));
|
core.loader._setStartProgressVal(items * (100 / names.length));
|
||||||
if (items == names.length) {
|
if (items == names.length) {
|
||||||
if (core.isset(callback)) callback();
|
if (core.isset(callback)) callback();
|
||||||
}
|
}
|
||||||
@ -237,28 +237,6 @@ loader.prototype.loadOneSound = function (name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loader.prototype.freeBgm = function (name) {
|
|
||||||
if (!core.isset(core.material.bgms[name])) return;
|
|
||||||
// 从cachedBgms中删除
|
|
||||||
core.musicStatus.cachedBgms = core.musicStatus.cachedBgms.filter(function (t) {return t!=name; });
|
|
||||||
// 清掉缓存
|
|
||||||
core.material.bgms[name].removeAttribute("src");
|
|
||||||
core.material.bgms[name].load();
|
|
||||||
core.material.bgms[name] = null;
|
|
||||||
if (name == core.musicStatus.playingBgm) {
|
|
||||||
core.musicStatus.playingBgm = null;
|
|
||||||
}
|
|
||||||
// 三秒后重新加载
|
|
||||||
setTimeout(function () {
|
|
||||||
core.loader.loadOneMusic(name);
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
|
|
||||||
loader.prototype._preloadBgm = function (bgm) {
|
|
||||||
bgm.volume = 0;
|
|
||||||
bgm.play();
|
|
||||||
}
|
|
||||||
|
|
||||||
loader.prototype.loadBgm = function (name) {
|
loader.prototype.loadBgm = function (name) {
|
||||||
if (!core.isset(core.material.bgms[name])) return;
|
if (!core.isset(core.material.bgms[name])) return;
|
||||||
// 如果没开启音乐,则不预加载
|
// 如果没开启音乐,则不预加载
|
||||||
@ -279,4 +257,26 @@ loader.prototype.loadBgm = function (name) {
|
|||||||
}
|
}
|
||||||
// 移动到缓存最前方
|
// 移动到缓存最前方
|
||||||
core.musicStatus.cachedBgms.unshift(name);
|
core.musicStatus.cachedBgms.unshift(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
loader.prototype._preloadBgm = function (bgm) {
|
||||||
|
bgm.volume = 0;
|
||||||
|
bgm.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
loader.prototype.freeBgm = function (name) {
|
||||||
|
if (!core.isset(core.material.bgms[name])) return;
|
||||||
|
// 从cachedBgms中删除
|
||||||
|
core.musicStatus.cachedBgms = core.musicStatus.cachedBgms.filter(function (t) {return t!=name; });
|
||||||
|
// 清掉缓存
|
||||||
|
core.material.bgms[name].removeAttribute("src");
|
||||||
|
core.material.bgms[name].load();
|
||||||
|
core.material.bgms[name] = null;
|
||||||
|
if (name == core.musicStatus.playingBgm) {
|
||||||
|
core.musicStatus.playingBgm = null;
|
||||||
|
}
|
||||||
|
// 三秒后重新加载
|
||||||
|
setTimeout(function () {
|
||||||
|
core.loader.loadOneMusic(name);
|
||||||
|
}, 3000);
|
||||||
}
|
}
|
||||||
118
libs/utils.js
118
libs/utils.js
@ -397,6 +397,36 @@ utils.prototype.arrayToRGBA = function (color) {
|
|||||||
return "rgba("+nowR+","+nowG+","+nowB+","+nowA+")";
|
return "rgba("+nowR+","+nowG+","+nowB+","+nowA+")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////// 加密路线 //////
|
||||||
|
utils.prototype.encodeRoute = function (route) {
|
||||||
|
var ans="", lastMove = "", cnt=0;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
ans += core.utils._encodeRoute_encodeOne(t);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (cnt>0) {
|
||||||
|
ans+=lastMove.substring(0,1).toUpperCase();
|
||||||
|
if (cnt>1) ans+=cnt;
|
||||||
|
}
|
||||||
|
return LZString.compressToBase64(ans);
|
||||||
|
}
|
||||||
|
|
||||||
utils.prototype._encodeRoute_id2number = function (id) {
|
utils.prototype._encodeRoute_id2number = function (id) {
|
||||||
var number = core.maps.getNumberById(id);
|
var number = core.maps.getNumberById(id);
|
||||||
return number==0?id:number;
|
return number==0?id:number;
|
||||||
@ -436,34 +466,23 @@ utils.prototype._encodeRoute_encodeOne = function (t) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 加密路线 //////
|
////// 解密路线 //////
|
||||||
utils.prototype.encodeRoute = function (route) {
|
utils.prototype.decodeRoute = function (route) {
|
||||||
var ans="", lastMove = "", cnt=0;
|
if (!core.isset(route)) return route;
|
||||||
|
|
||||||
route.forEach(function (t) {
|
// 解压缩
|
||||||
if (t=='up' || t=='down' || t=='left' || t=='right') {
|
try {
|
||||||
if (t!=lastMove && cnt>0) {
|
var v = LZString.decompressFromBase64(route);
|
||||||
ans+=lastMove.substring(0,1).toUpperCase();
|
if (core.isset(v) && /^[a-zA-Z0-9+\/=:]*$/.test(v)) {
|
||||||
if (cnt>1) ans+=cnt;
|
route = v;
|
||||||
cnt=0;
|
|
||||||
}
|
|
||||||
lastMove=t;
|
|
||||||
cnt++;
|
|
||||||
}
|
}
|
||||||
else {
|
} catch (e) {}
|
||||||
if (cnt>0) {
|
|
||||||
ans+=lastMove.substring(0,1).toUpperCase();
|
var decodeObj = {route: route, index: 0, ans: []};
|
||||||
if (cnt>1) ans+=cnt;
|
while (decodeObj.index < decodeObj.route.length) {
|
||||||
cnt=0;
|
this._decodeRoute_decodeOne(decodeObj, decodeObj.route.charAt(decodeObj.index++));
|
||||||
}
|
|
||||||
ans += core.utils._encodeRoute_encodeOne(t);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (cnt>0) {
|
|
||||||
ans+=lastMove.substring(0,1).toUpperCase();
|
|
||||||
if (cnt>1) ans+=cnt;
|
|
||||||
}
|
}
|
||||||
return LZString.compressToBase64(ans);
|
return decodeObj.ans;
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.prototype._decodeRoute_getNumber = function (decodeObj, noparse) {
|
utils.prototype._decodeRoute_getNumber = function (decodeObj, noparse) {
|
||||||
@ -518,25 +537,6 @@ utils.prototype._decodeRoute_decodeOne = function (decodeObj, c) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 解密路线 //////
|
|
||||||
utils.prototype.decodeRoute = function (route) {
|
|
||||||
if (!core.isset(route)) return route;
|
|
||||||
|
|
||||||
// 解压缩
|
|
||||||
try {
|
|
||||||
var v = LZString.decompressFromBase64(route);
|
|
||||||
if (core.isset(v) && /^[a-zA-Z0-9+\/=:]*$/.test(v)) {
|
|
||||||
route = v;
|
|
||||||
}
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
var decodeObj = {route: route, index: 0, ans: []};
|
|
||||||
while (decodeObj.index < decodeObj.route.length) {
|
|
||||||
this._decodeRoute_decodeOne(decodeObj, decodeObj.route.charAt(decodeObj.index++));
|
|
||||||
}
|
|
||||||
return decodeObj.ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
////// 判断某对象是否不为undefined也不会null //////
|
////// 判断某对象是否不为undefined也不会null //////
|
||||||
utils.prototype.isset = function (val) {
|
utils.prototype.isset = function (val) {
|
||||||
if (val == undefined || val == null || (typeof val=='number' && isNaN(val))) {
|
if (val == undefined || val == null || (typeof val=='number' && isNaN(val))) {
|
||||||
@ -624,21 +624,6 @@ utils.prototype.convertBase = function (str, fromBase, toBase) {
|
|||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.prototype.__init_seed = function () {
|
|
||||||
var rand = new Date().getTime()%34834795 + 3534;
|
|
||||||
rand = this.__next_rand(rand);
|
|
||||||
rand = this.__next_rand(rand);
|
|
||||||
rand = this.__next_rand(rand);
|
|
||||||
core.setFlag('__seed__', rand);
|
|
||||||
core.setFlag('__rand__', rand);
|
|
||||||
}
|
|
||||||
|
|
||||||
utils.prototype.__next_rand = function (_rand) {
|
|
||||||
_rand=(_rand%127773)*16807-~~(_rand/127773)*2836;
|
|
||||||
_rand+=_rand<0?2147483647:0;
|
|
||||||
return _rand;
|
|
||||||
}
|
|
||||||
|
|
||||||
utils.prototype.rand = function (num) {
|
utils.prototype.rand = function (num) {
|
||||||
var rand = core.getFlag('__rand__');
|
var rand = core.getFlag('__rand__');
|
||||||
rand = this.__next_rand(rand);
|
rand = this.__next_rand(rand);
|
||||||
@ -672,6 +657,21 @@ utils.prototype.rand2 = function (num) {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
utils.prototype.__init_seed = function () {
|
||||||
|
var rand = new Date().getTime()%34834795 + 3534;
|
||||||
|
rand = this.__next_rand(rand);
|
||||||
|
rand = this.__next_rand(rand);
|
||||||
|
rand = this.__next_rand(rand);
|
||||||
|
core.setFlag('__seed__', rand);
|
||||||
|
core.setFlag('__rand__', rand);
|
||||||
|
}
|
||||||
|
|
||||||
|
utils.prototype.__next_rand = function (_rand) {
|
||||||
|
_rand=(_rand%127773)*16807-~~(_rand/127773)*2836;
|
||||||
|
_rand+=_rand<0?2147483647:0;
|
||||||
|
return _rand;
|
||||||
|
}
|
||||||
|
|
||||||
////// 读取一个本地文件内容 //////
|
////// 读取一个本地文件内容 //////
|
||||||
utils.prototype.readFile = function (success, error, readType) {
|
utils.prototype.readFile = function (success, error, readType) {
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user