Deploying to gh-pages from @ eaa8644df6 🚀

This commit is contained in:
unanmed committed 2023-01-11 01:47:19 +00:00
1 parent 686dec1364
commit 849a8ea4b3
19 files changed
+272 -316

No files matched your search

+7 -11
View File
@@ -1030,7 +1030,10 @@ control.prototype.tryMoveDirectly = function (destX, destY) {
if (dir && !core.inArray(canMoveArray[dx][dy], dir)) continue;
if (canMoveDirectlyArray[i] < 0) continue;
if (core.control.moveDirectly(dx, dy, canMoveDirectlyArray[i])) {
if (dir) core.moveHero(dir, function () {});
if (dir) {
console.log(dir);
core.moveHero(dir, function () {});
}
return true;
}
}
@@ -4288,19 +4291,12 @@ control.prototype._resize_canvas = function (obj) {
// resize bigmap
core.bigmap.canvas.forEach(function (cn) {
var ratio = core.canvas[cn].canvas.hasAttribute('isHD')
? core.domStyle.ratio
? core.domStyle.scale * devicePixelRatio
: 1;
core.canvas[cn].canvas.style.width =
(core.canvas[cn].canvas.width /
devicePixelRatio /
core.domStyle.ratio) *
core.domStyle.scale +
'px';
(core.canvas[cn].canvas.width / ratio) * core.domStyle.scale + 'px';
core.canvas[cn].canvas.style.height =
(core.canvas[cn].canvas.height /
devicePixelRatio /
core.domStyle.ratio) *
core.domStyle.scale +
(core.canvas[cn].canvas.height / ratio) * core.domStyle.scale +
'px';
});
// resize dynamic canvas
+12 -6
View File
@@ -108,7 +108,8 @@ function core() {
availableScale: [],
isVertical: false,
showStatusBar: true,
toolbarBtn: false
toolbarBtn: false,
hdCanvas: ['damage', 'ui', 'data']
};
this.bigmap = {
canvas: ['bg', 'event', 'event2', 'fg', 'damage'],
@@ -294,11 +295,16 @@ core.prototype.init = function (coreData, callback) {
var b = main.mode == 'editor';
// 初始化画布
for (var name in core.canvas) {
core.maps._setHDCanvasSize(
core.canvas[name],
b ? core.__PIXELS__ : core._PX_,
b ? core.__PIXELS__ : core._PY_
);
if (core.domStyle.hdCanvas.includes(name))
core.maps._setHDCanvasSize(
core.canvas[name],
b ? core.__PIXELS__ : core._PX_,
b ? core.__PIXELS__ : core._PY_
);
else {
core.canvas[name].canvas.width = b ? core.__PIXELS__ : core._PX_;
core.canvas[name].canvas.height = b ? core.__PIXELS__ : core._PY_;
}
}
core.loader._load(function () {
+27 -111
View File
@@ -208,9 +208,9 @@ enemys.prototype.canBattle = function (enemy, x, y, floorId) {
return damage != null && damage < core.status.hero.hp;
};
enemys.prototype.getDamageString = function (enemy, x, y, floorId) {
enemys.prototype.getDamageString = function (enemy, x, y, floorId, hero) {
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
var damage = this.getDamage(enemy, x, y, floorId);
var damage = this.getDamage(enemy, x, y, floorId, hero);
var color = '#000000';
@@ -234,7 +234,7 @@ enemys.prototype.getDamageString = function (enemy, x, y, floorId) {
};
////// 接下来N个临界值和临界减伤计算 //////
enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) {
enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId, hero) {
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
number = number || 1;
@@ -246,7 +246,7 @@ enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) {
floorId
);
if (specialCriticals != null) return specialCriticals;
var info = this.getDamageInfo(enemy, null, x, y, floorId);
var info = this.getDamageInfo(enemy, hero, x, y, floorId);
if (info == null) {
// 如果未破防...
var overAtk = this._nextCriticals_overAtk(enemy, x, y, floorId);
@@ -268,12 +268,19 @@ enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) {
number,
x,
y,
floorId
floorId,
hero
);
};
/// 未破防临界采用二分计算
enemys.prototype._nextCriticals_overAtk = function (enemy, x, y, floorId) {
enemys.prototype._nextCriticals_overAtk = function (
enemy,
x,
y,
floorId,
hero
) {
var calNext = function (currAtk, maxAtk) {
var start = currAtk,
end = maxAtk;
@@ -284,7 +291,7 @@ enemys.prototype._nextCriticals_overAtk = function (enemy, x, y, floorId) {
if (mid - start > end - mid) mid--;
var nextInfo = core.enemys.getDamageInfo(
enemy,
{ atk: mid },
{ atk: mid, x: hero?.x, y: hero?.y },
x,
y,
floorId
@@ -294,17 +301,17 @@ enemys.prototype._nextCriticals_overAtk = function (enemy, x, y, floorId) {
}
var nextInfo = core.enemys.getDamageInfo(
enemy,
{ atk: start },
{ atk: start, x: hero?.x, y: hero?.y },
x,
y,
floorId
);
return nextInfo == null
? null
: [start - core.getStatus('atk'), nextInfo];
: [start - core.getStatusOrDefault(hero, 'atk'), nextInfo];
};
return calNext(
core.getStatus('atk') + 1,
core.getStatusOrDefault(hero, 'atk') + 1,
core.getEnemyValue(enemy, 'hp', x, y, floorId) +
core.getEnemyValue(enemy, 'def', x, y, floorId)
);
@@ -322,48 +329,17 @@ enemys.prototype._nextCriticals_special = function (
return null;
};
enemys.prototype._nextCriticals_useLoop = function (
enemy,
info,
number,
x,
y,
floorId
) {
var mon_hp = info.mon_hp,
hero_atk = core.getStatus('atk'),
mon_def = info.mon_def,
pre = info.damage;
var list = [];
var start_atk = hero_atk;
if (info.__over__) {
start_atk += info.__overAtk__;
list.push([info.__overAtk__, -info.damage]);
}
for (var atk = start_atk + 1; atk <= mon_hp + mon_def; atk++) {
var nextInfo = this.getDamageInfo(enemy, { atk: atk }, x, y, floorId);
if (nextInfo == null || typeof nextInfo == 'number') break;
if (pre > nextInfo.damage) {
pre = nextInfo.damage;
list.push([atk - hero_atk, info.damage - nextInfo.damage]);
if (nextInfo.damage <= 0 && !core.flags.enableNegativeDamage) break;
if (list.length >= number) break;
}
}
if (list.length == 0) list.push([0, 0]);
return list;
};
enemys.prototype._nextCriticals_useBinarySearch = function (
enemy,
info,
number,
x,
y,
floorId
floorId,
hero
) {
var mon_hp = info.mon_hp,
hero_atk = core.getStatus('atk'),
hero_atk = core.getStatusOrDefault(hero, 'atk'),
mon_def = info.mon_def,
pre = info.damage;
var list = [];
@@ -382,7 +358,7 @@ enemys.prototype._nextCriticals_useBinarySearch = function (
if (mid - start > end - mid) mid--;
var nextInfo = core.enemys.getDamageInfo(
enemy,
{ atk: mid },
{ atk: mid, x: hero?.x, y: hero?.y },
x,
y,
floorId
@@ -393,7 +369,7 @@ enemys.prototype._nextCriticals_useBinarySearch = function (
}
var nextInfo = core.enemys.getDamageInfo(
enemy,
{ atk: start },
{ atk: start, x: hero?.x, y: hero?.y },
x,
y,
floorId
@@ -418,73 +394,14 @@ enemys.prototype._nextCriticals_useBinarySearch = function (
return list;
};
enemys.prototype._nextCriticals_useTurn = function (
enemy,
info,
number,
x,
y,
floorId
) {
var mon_hp = info.mon_hp,
hero_atk = core.getStatus('atk'),
mon_def = info.mon_def,
turn = info.turn;
// ------ 超大回合数强制使用二分算临界
// 以避免1攻10e回合,2攻5e回合导致下述循环卡死问题
if (turn >= 1e6) {
// 100w回合以上强制二分计算临界
return this._nextCriticals_useBinarySearch(
enemy,
info,
number,
x,
y,
floorId
);
}
var list = [],
pre = null;
var start_atk = hero_atk;
if (info.__over__) {
start_atk += info.__overAtk__;
list.push([info.__overAtk__, -info.damage]);
}
for (var t = turn - 1; t >= 1; t--) {
var nextAtk = Math.ceil(mon_hp / t) + mon_def;
// 装备提升比例的计算临界
nextAtk = Math.ceil(nextAtk / core.getBuff('atk'));
if (nextAtk <= start_atk) break;
if (nextAtk != pre) {
var nextInfo = this.getDamageInfo(
enemy,
{ atk: nextAtk },
x,
y,
floorId
);
if (nextInfo == null || typeof nextInfo == 'number') break;
list.push([
nextAtk - hero_atk,
Math.floor(info.damage - nextInfo.damage)
]);
if (nextInfo.damage <= 0 && !core.flags.enableNegativeDamage) break;
pre = nextAtk;
}
if (list.length >= number) break;
}
if (list.length == 0) list.push([0, 0]);
return list;
};
////// N防减伤计算 //////
enemys.prototype.getDefDamage = function (enemy, k, x, y, floorId) {
enemys.prototype.getDefDamage = function (enemy, k, x, y, floorId, hero) {
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
k = k || 1;
var nowDamage = this._getDamage(enemy, null, x, y, floorId);
var nowDamage = this._getDamage(enemy, hero, x, y, floorId);
var nextDamage = this._getDamage(
enemy,
{ def: core.getStatus('def') + k },
Object.assign({}, hero ?? {}, { def: core.getStatus('def') + k }),
x,
y,
floorId
@@ -508,8 +425,8 @@ enemys.prototype.getDamageInfo = function (enemy, hero, x, y, floorId) {
};
////// 获得在某个勇士属性下怪物伤害 //////
enemys.prototype.getDamage = function (enemy, x, y, floorId) {
return this._getDamage(enemy, null, x, y, floorId);
enemys.prototype.getDamage = function (enemy, x, y, floorId, hero) {
return this._getDamage(enemy, hero, x, y, floorId);
};
enemys.prototype._getDamage = function (enemy, hero, x, y, floorId) {
@@ -517,7 +434,6 @@ enemys.prototype._getDamage = function (enemy, hero, x, y, floorId) {
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
if (enemy == null) return null;
if (x === 9 && y === 3) debugger;
var info = this.getDamageInfo(enemy, hero, x, y, floorId);
if (info == null) return null;
if (typeof info == 'number') return info;
+18 -5
View File
@@ -634,7 +634,12 @@ maps.prototype.resizeMap = function (floorId) {
var height = core.bigmap.v2 ? core._PY_ + 64 : core.bigmap.height * 32;
core.bigmap.canvas.forEach(function (cn) {
core.maps._setHDCanvasSize(core.canvas[cn], width, height);
if (core.domStyle.hdCanvas.includes(cn))
core.maps._setHDCanvasSize(core.canvas[cn], width, height);
else {
core.canvas[cn].canvas.width = width;
core.canvas[cn].canvas.height = height;
}
core.canvas[cn].canvas.style.width = width * core.domStyle.scale + 'px';
core.canvas[cn].canvas.style.height =
@@ -2581,7 +2586,7 @@ maps.prototype._drawThumbnail_drawTempCanvas = function (
tempCanvas.canvas.height = height * 32;
tempCanvas.canvas.removeAttribute('isHD');
} else {
core.resizeCanvas(tempCanvas, width * 32, height * 32, false, true);
core.maps._setHDCanvasSize(tempCanvas, width * 32, height * 32);
}
} else if (width * height > core.bigmap.threshold) {
options.v2 = true;
@@ -2589,7 +2594,7 @@ maps.prototype._drawThumbnail_drawTempCanvas = function (
tempCanvas.canvas.width = core._PX_;
tempCanvas.canvas.height = core._PY_;
tempCanvas.canvas.removeAttribute('isHD');
} else core.resizeCanvas(tempCanvas, core._PX_, core._PY_);
} else core.maps._setHDCanvasSize(tempCanvas, width * 32, height * 32);
var centerX = options.centerX,
centerY = options.centerY;
if (centerX == null) centerX = Math.floor(width / 2);
@@ -2611,8 +2616,7 @@ maps.prototype._drawThumbnail_drawTempCanvas = function (
tempCanvas.canvas.width = width * 32;
tempCanvas.canvas.height = height * 32;
tempCanvas.canvas.removeAttribute('isHD');
} else
core.resizeCanvas(tempCanvas, width * 32, height * 32, false, true);
} else core.maps._setHDCanvasSize(tempCanvas, width * 32, height * 32);
}
options.ctx = tempCanvas;
@@ -2695,6 +2699,10 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) {
if (centerY == null) centerY = Math.floor(height / 2);
var tempCanvas = core.bigmap.tempCanvas;
if (!core.getLocalStorage('antiAliasing')) {
ctx.imageSmoothingEnabled = false;
}
if (options.inFlyMap) {
ctx.drawImage(
tempCanvas.canvas,
@@ -2707,6 +2715,7 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) {
options.w,
options.h
);
ctx.imageSmoothingEnabled = true;
return;
}
@@ -2752,6 +2761,7 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) {
realHeight
);
}
ctx.imageSmoothingEnabled = true;
} else {
// 只绘制可见窗口
var pw = core._PX_,
@@ -2793,6 +2803,7 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) {
h
);
}
ctx.imageSmoothingEnabled = true;
} else {
var offsetX = core.clamp(centerX - hw, 0, width - W),
offsetY = core.clamp(centerY - hh, 0, height - H);
@@ -2809,6 +2820,7 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) {
w,
h
);
ctx.imageSmoothingEnabled = true;
return;
}
core.drawImage(
@@ -2823,6 +2835,7 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) {
w,
h
);
ctx.imageSmoothingEnabled = true;
}
}
};
+2 -2
View File
@@ -4203,12 +4203,12 @@ ui.prototype.resizeCanvas = function (
var ctx = core.getContextByName(name);
if (!ctx) return null;
if (width != null) {
if (!styleOnly)
if (!styleOnly && ctx.canvas.hasAttribute('isHD'))
core.maps._setHDCanvasSize(ctx, width, null, isTempCanvas);
ctx.canvas.style.width = width * core.domStyle.scale + 'px';
}
if (height != null) {
if (!styleOnly)
if (!styleOnly && ctx.canvas.hasAttribute('isHD'))
core.maps._setHDCanvasSize(ctx, null, height, isTempCanvas);
ctx.canvas.style.height = height * core.domStyle.scale + 'px';
}