处理完毕所有需要删除的todo

This commit is contained in:
unanmed 2023-08-06 22:43:58 +08:00
parent 993ff3c669
commit 1854389966
17 changed files with 66 additions and 951 deletions

View File

@ -81,18 +81,6 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
_type: 'textarea', _type: 'textarea',
_lint: true, _lint: true,
_data: '怪物特殊属性' _data: '怪物特殊属性'
},
getEnemyInfo: {
_leaf: true,
_type: 'textarea',
_lint: true,
_data: '怪物真实属性'
},
getDamageInfo: {
_leaf: true,
_type: 'textarea',
_lint: true,
_data: '战斗伤害信息'
} }
} }
}, },

View File

@ -2817,13 +2817,12 @@ control.prototype.getStatusOrDefault = function (status, name) {
////// 获得勇士实际属性(增幅后的) ////// ////// 获得勇士实际属性(增幅后的) //////
control.prototype.getRealStatus = function (name) { control.prototype.getRealStatus = function (name) {
return this.getRealStatusOrDefault(null, name); // Deprecated. See src/plugin/game/hero.ts
}; };
////// 从status中获得实际属性增幅后的如果不存在则从勇士属性中获取 ////// ////// 从status中获得实际属性增幅后的如果不存在则从勇士属性中获取 //////
control.prototype.getRealStatusOrDefault = function (status, name) { control.prototype.getRealStatusOrDefault = function (status, name) {
// todo: 删除 // Deprecated. See src/plugin/game/hero.ts
return core.plugin.hero.getHeroStatusOf(status, name);
}; };
////// 获得勇士原始属性(无装备和衰弱影响) ////// ////// 获得勇士原始属性(无装备和衰弱影响) //////

View File

@ -212,217 +212,43 @@ enemys.prototype.getDamageString = function (enemy, x, y, floorId, hero) {
////// 接下来N个临界值和临界减伤计算 ////// ////// 接下来N个临界值和临界减伤计算 //////
enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId, hero) { enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId, hero) {
// todo: 删除这个函数 // Deprecated. See src/plugin/game/enemy/damage.ts DamageEnemy.calCritical.
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
number = number || 1;
var specialCriticals = this._nextCriticals_special(
enemy,
number,
x,
y,
floorId
);
if (specialCriticals != null) return specialCriticals;
var info = this.getDamageInfo(enemy, hero, x, y, floorId);
if (info == null) {
// 如果未破防...
var overAtk = this._nextCriticals_overAtk(enemy, x, y, floorId);
if (overAtk == null) return [];
if (typeof overAtk[1] == 'number') return [[overAtk[0], -overAtk[1]]];
info = overAtk[1];
info.__over__ = true;
info.__overAtk__ = overAtk[0];
}
if (typeof info == 'number') return [[0, 0]];
if (info.damage <= 0 && !core.flags.enableNegativeDamage) {
return [[info.__overAtk__ || 0, 0]];
}
return this._nextCriticals_useBinarySearch(
enemy,
info,
number,
x,
y,
floorId,
hero
);
}; };
/// 未破防临界采用二分计算 /// 未破防临界采用二分计算
enemys.prototype._nextCriticals_overAtk = function ( enemys.prototype._nextCriticals_overAtk = function (enemy) {
enemy, // Deprecated. See src/plugin/game/enemy/damage.ts DamageEnemy.calCritical.
x,
y,
floorId,
hero
) {
// todo: 删除这个函数
var calNext = function (currAtk, maxAtk) {
var start = currAtk,
end = maxAtk;
if (start > end) return null;
while (start < end) {
var mid = Math.floor((start + end) / 2);
if (mid - start > end - mid) mid--;
var nextInfo = core.enemys.getDamageInfo(
enemy,
{ atk: mid, x: hero?.x, y: hero?.y },
x,
y,
floorId
);
if (nextInfo != null) end = mid;
else start = mid + 1;
}
var nextInfo = core.enemys.getDamageInfo(
enemy,
{ atk: start, x: hero?.x, y: hero?.y },
x,
y,
floorId
);
return nextInfo == null
? null
: [start - core.getStatusOrDefault(hero, 'atk'), nextInfo];
};
return calNext(
core.getStatusOrDefault(hero, 'atk') + 1,
core.getEnemyValue(enemy, 'hp', x, y, floorId) +
core.getEnemyValue(enemy, 'def', x, y, floorId)
);
}; };
enemys.prototype._nextCriticals_special = function ( enemys.prototype._nextCriticals_special = function (enemy) {
enemy, // Deprecated. See src/plugin/game/enemy/damage.ts DamageEnemy.calCritical.
number,
x,
y,
floorId
) {
if (this.hasSpecial(enemy.special, 10) || this.hasSpecial(enemy.special, 3))
return []; // 模仿or坚固临界
return null;
}; };
enemys.prototype._nextCriticals_useBinarySearch = function ( enemys.prototype._nextCriticals_useBinarySearch = function (enemy) {
enemy, // Deprecated. See src/plugin/game/enemy/damage.ts DamageEnemy.calCritical.
info,
number,
x,
y,
floorId,
hero
) {
// todo: 删除这个函数
var mon_hp = info.mon_hp,
hero_atk = core.getStatusOrDefault(hero, '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]);
}
var calNext = function (currAtk, maxAtk) {
var start = Math.floor(currAtk),
end = Math.floor(maxAtk);
if (start > end) return null;
while (start < end) {
var mid = Math.floor((start + end) / 2);
if (mid - start > end - mid) mid--;
var nextInfo = core.enemys.getDamageInfo(
enemy,
{ atk: mid, x: hero?.x, y: hero?.y },
x,
y,
floorId
);
if (nextInfo == null || typeof nextInfo == 'number') return null;
if (pre > nextInfo.damage) end = mid;
else start = mid + 1;
}
var nextInfo = core.enemys.getDamageInfo(
enemy,
{ atk: start, x: hero?.x, y: hero?.y },
x,
y,
floorId
);
return nextInfo == null ||
typeof nextInfo == 'number' ||
nextInfo.damage >= pre
? null
: [start, nextInfo.damage];
};
var currAtk = start_atk;
while (true) {
var next = calNext(currAtk + 1, mon_hp + mon_def, pre);
if (next == null) break;
currAtk = next[0];
pre = next[1];
list.push([currAtk - hero_atk, info.damage - pre]);
if (pre <= 0 && !core.flags.enableNegativeDamage) break;
if (list.length >= number) break;
}
if (list.length == 0) list.push([0, 0]);
return list;
}; };
////// N防减伤计算 ////// ////// N防减伤计算 //////
enemys.prototype.getDefDamage = function (enemy, k, x, y, floorId, hero) { enemys.prototype.getDefDamage = function (enemy, k, x, y, floorId, hero) {
// todo: 删除这个函数 // Deprecated. See src/plugin/game/enemy/damage.ts DamageEnemy.calDefDamage.
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
k = k || 1;
var nowDamage = this._getDamage(enemy, hero, x, y, floorId);
var nextDamage = this._getDamage(
enemy,
Object.assign({}, hero ?? {}, { def: core.getStatus('def') + k }),
x,
y,
floorId
);
if (nowDamage == null || nextDamage == null) return '???';
return nowDamage - nextDamage;
}; };
enemys.prototype.getEnemyInfo = function (enemy, hero, x, y, floorId) { enemys.prototype.getEnemyInfo = function (enemy, hero, x, y, floorId) {
// todo: 删除这个函数 // Deprecated. See src/plugin/game/enemy/damage.ts
if (enemy == null) return null;
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
return this.enemydata.getEnemyInfo(enemy, hero, x, y, floorId);
}; };
////// 获得战斗伤害信息(实际伤害计算函数) ////// ////// 获得战斗伤害信息(实际伤害计算函数) //////
enemys.prototype.getDamageInfo = function (enemy, hero, x, y, floorId) { enemys.prototype.getDamageInfo = function (enemy, hero, x, y, floorId) {
// todo: 删除这个函数 // Deprecated. See src/plugin/game/enemy/damage.ts
if (enemy == null) return null;
// 移动到了脚本编辑 - getDamageInfo中
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
return this.enemydata.getDamageInfo(enemy, hero, x, y, floorId);
}; };
////// 获得在某个勇士属性下怪物伤害 ////// ////// 获得在某个勇士属性下怪物伤害 //////
enemys.prototype.getDamage = function (enemy, x, y, floorId, hero) { enemys.prototype.getDamage = function (enemy, x, y, floorId, hero) {
// todo: 修改这个函数的参数 // Deprecated. See src/plugin/game/enemy/damage.ts
return this._getDamage(enemy, hero, x, y, floorId);
}; };
enemys.prototype._getDamage = function (enemy, hero, x, y, floorId) { enemys.prototype._getDamage = function (enemy, hero, x, y, floorId) {
// todo: 重写这个函数 // Deprecated. See src/plugin/game/enemy/damage.ts
if (enemy == null) enemy = core.getBlockId(x, y, floorId);
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
if (enemy == null) return null;
var info = this.getDamageInfo(enemy, hero, x, y, floorId);
if (info == null) return null;
if (typeof info == 'number') return info;
return info.damage;
}; };
////// 获得当前楼层的怪物列表 ////// ////// 获得当前楼层的怪物列表 //////
@ -431,114 +257,19 @@ enemys.prototype.getCurrentEnemys = function (floorId) {
}; };
enemys.prototype._getCurrentEnemys_getEnemy = function (enemyId) { enemys.prototype._getCurrentEnemys_getEnemy = function (enemyId) {
var enemy = core.material.enemys[enemyId]; // Deprecated. See src/plugin/game/enemy/battle.ts
if (!enemy) return null;
// 检查朝向displayIdInBook
return (
core.material.enemys[enemy.displayIdInBook] ||
core.material.enemys[(enemy.faceIds || {}).down] ||
enemy
);
}; };
enemys.prototype._getCurrentEnemys_addEnemy = function ( enemys.prototype._getCurrentEnemys_addEnemy = function (enemyId) {
enemyId, // Deprecated. See src/plugin/game/enemy/battle.ts
enemys,
used,
x,
y,
floorId
) {
// todo: 删除这个函数
var enemy = this._getCurrentEnemys_getEnemy(enemyId);
if (enemy == null) return;
var id = enemy.id;
var enemyInfo = this.getEnemyInfo(enemy, null, null, null, floorId);
var locEnemyInfo = this.getEnemyInfo(enemy, null, x, y, floorId);
if (
!core.flags.enableEnemyPoint ||
(locEnemyInfo.atk == enemyInfo.atk &&
locEnemyInfo.def == enemyInfo.def &&
locEnemyInfo.hp == enemyInfo.hp)
) {
x = null;
y = null;
} else {
// 检查enemys里面是否使用了存在的内容
for (var i = 0; i < enemys.length; ++i) {
var one = enemys[i];
if (
id == one.id &&
one.locs != null &&
locEnemyInfo.atk == one.atk &&
locEnemyInfo.def == one.def &&
locEnemyInfo.hp == one.hp
) {
one.locs.push([x, y]);
return;
}
}
enemyInfo = locEnemyInfo;
}
var id = enemy.id + ':' + x + ':' + y;
if (used[id]) return;
used[id] = true;
var specialText = core.enemys.getSpecialText(enemy);
var specialColor = core.enemys.getSpecialColor(enemy);
var critical = this.nextCriticals(enemy, 1, x, y, floorId);
if (critical.length > 0) critical = critical[0];
var e = core.clone(enemy);
for (var v in enemyInfo) {
e[v] = enemyInfo[v];
}
if (x != null && y != null) {
e.locs = [[x, y]];
}
e.name = core.getEnemyValue(enemy, 'name', x, y, floorId);
e.specialText = specialText;
e.specialColor = specialColor;
e.damage = this.getDamage(enemy, x, y, floorId);
e.critical = critical[0];
e.criticalDamage = critical[1];
e.defDamage = this._getCurrentEnemys_addEnemy_defDamage(
enemy,
x,
y,
floorId
);
enemys.push(e);
}; };
enemys.prototype._getCurrentEnemys_addEnemy_defDamage = function ( enemys.prototype._getCurrentEnemys_addEnemy_defDamage = function (enemy) {
enemy, // Deprecated. See src/plugin/game/enemy/battle.ts
x,
y,
floorId
) {
var ratio = core.status.maps[floorId || core.status.floorId].ratio || 1;
return this.getDefDamage(enemy, ratio, x, y, floorId);
}; };
enemys.prototype._getCurrentEnemys_sort = function (enemys) { enemys.prototype._getCurrentEnemys_sort = function (enemys) {
return enemys.sort(function (a, b) { // Deprecated. See src/plugin/game/enemy/battle.ts
if (a.damage == b.damage) {
return a.money - b.money;
}
if (a.damage == null) {
return 1;
}
if (b.damage == null) {
return -1;
}
return a.damage - b.damage;
});
}; };
enemys.prototype.hasEnemyLeft = function (enemyId, floorId) { enemys.prototype.hasEnemyLeft = function (enemyId, floorId) {

View File

@ -405,7 +405,6 @@ main.prototype.loadAsync = async function (mode, callback) {
await core.init(coreData, callback); await core.init(coreData, callback);
if (main.mode === 'play') main.loading.emit('coreInit'); if (main.mode === 'play') main.loading.emit('coreInit');
if (main.mode === 'play') { if (main.mode === 'play') {
ancTe.plugin.setting.resetSettings();
ancTe.plugin.mark.showMarkedEnemy.value = true; ancTe.plugin.mark.showMarkedEnemy.value = true;
} }

View File

@ -550,388 +550,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
1 1
] ]
]; ];
},
getEnemyInfo: function (enemy, hero, x, y, floorId) {
// todo: 删除这个函数
// 获得某个怪物变化后的数据;该函数将被伤害计算和怪物手册使用
// 例如:坚固、模仿、仿攻等等
//
// 参数说明:
// enemy该怪物信息
// hero_hp,hero_atk,hero_def,hero_mdef勇士的生命攻防护盾数据
// x,y该怪物的坐标查看手册和强制战斗时为undefined
// floorId该怪物所在的楼层
// 后面三个参数主要是可以在光环等效果上可以适用(也可以按需制作部分范围光环效果)
floorId = floorId || core.status.floorId;
let {
atk: hero_atk,
def: hero_def,
mdef: hero_mdef,
hp: hero_hp
} = core.plugin.hero.getHeroStatusOf(
hero,
['atk', 'def', 'mdef', 'hp'],
hero?.x,
hero?.y,
floorId
);
var mon_hp = core.getEnemyValue(enemy, 'hp', x, y, floorId),
mon_atk = core.getEnemyValue(enemy, 'atk', x, y, floorId),
mon_def = core.getEnemyValue(enemy, 'def', x, y, floorId),
mon_special = core.getEnemyValue(
enemy,
'special',
x,
y,
floorId
);
var mon_money = core.getEnemyValue(enemy, 'money', x, y, floorId),
mon_exp = core.getEnemyValue(enemy, 'exp', x, y, floorId),
mon_point = core.getEnemyValue(enemy, 'point', x, y, floorId);
let iceDecline = 0;
if (typeof enemy === 'number')
core.getBlockByNumber(enemy).event.id;
if (typeof enemy === 'string') enemy = core.material.enemys[enemy];
// 饥渴
if (core.hasSpecial(mon_special, 7)) {
mon_atk += (hero_atk * (enemy.hungry || 0)) / 100;
}
// 智慧之源
if (core.hasSpecial(mon_special, 14) && flags.hard === 2) {
mon_atk += core.getFlag('inte_' + floorId, 0);
}
// 极昼永夜
mon_atk -= flags[`night_${floorId}`] ?? 0;
mon_def -= flags[`night_${floorId}`] ?? 0;
// 坚固
if (core.hasSpecial(mon_special, 3) && mon_def < hero_atk - 1) {
mon_def = hero_atk - 1;
}
var guards = [];
// 光环和支援检查
core.status.checkBlock ??= {};
if (
core.status.checkBlock.needCache &&
core.has(x) &&
core.has(y)
) {
// 从V2.5.4开始,对光环效果增加缓存,以解决多次重复计算的问题,从而大幅提升运行效率。
var hp_buff = 0,
atk_buff = 0,
def_buff = 0;
// 检查光环和支援的缓存
var index = `${x},${y}`;
core.status.checkBlock.cache ??= {};
var cache = core.status.checkBlock.cache[index];
if (!cache) {
// 没有该点的缓存,则遍历每个图块
core.extractBlocks(floorId);
core.status.maps[floorId].blocks.forEach(function (block) {
if (block.disable) return;
// 获得该图块的ID
var id = block.event.id,
e = core.material.enemys[id];
if (!e) return;
var dx = Math.abs(block.x - x),
dy = Math.abs(block.y - y);
// 抱团
if (
core.hasSpecial(mon_special, 8) &&
core.hasSpecial(e.special, 8) &&
!(dx == 0 && dy == 0) &&
dx < 3 &&
dy < 3
) {
atk_buff += enemy.together || 0;
def_buff += enemy.together || 0;
}
// 冰封光环
if (
core.hasSpecial(e.special, 21) &&
dx < 4 &&
dy < 4
) {
iceDecline += e.iceHalo;
}
// 5*5光环
if (dx <= 2 && dy <= 2) {
// 冰封之核
if (core.hasSpecial(e.special, 26)) {
def_buff += e.iceCore;
}
// 火焰之核
if (core.hasSpecial(e.special, 27)) {
atk_buff += e.fireCore;
}
}
});
// 融化怪要在这里判断
if (
core.has(flags[`melt_${floorId}`]) &&
core.has(x) &&
core.has(y)
) {
for (const [loc, per] of Object.entries(
flags[`melt_${floorId}`]
)) {
const [mx, my] = loc
.split(',')
.map(v => parseInt(v));
if (
Math.abs(mx - x) <= 1 &&
Math.abs(my - y) <= 1
) {
atk_buff += per;
def_buff += per;
}
}
}
core.status.checkBlock.cache[index] = {
hp_buff: hp_buff,
atk_buff: atk_buff,
def_buff: def_buff,
guards: guards,
iceHalo: iceDecline
};
} else {
// 直接使用缓存数据
hp_buff = cache.hp_buff;
atk_buff = cache.atk_buff;
def_buff = cache.def_buff;
guards = cache.guards;
iceDecline = cache.iceHalo;
}
// 增加比例;如果要增加数值可以直接在这里修改
mon_hp *= 1 + hp_buff / 100;
mon_atk *= 1 + atk_buff / 100;
mon_def *= 1 + def_buff / 100;
}
return {
hp: Math.floor(mon_hp),
atk: Math.floor(mon_atk),
def: Math.floor(mon_def),
money: Math.floor(mon_money),
exp: Math.floor(mon_exp),
point: Math.floor(mon_point),
special: mon_special,
guards: guards, // 返回支援情况
iceDecline
};
},
getDamageInfo: function (enemy, hero, x, y, floorId) {
// 获得战斗伤害信息(实际伤害计算函数)
//
// 参数说明:
// enemy该怪物信息
// hero勇士的当前数据如果对应项不存在则会从core.status.hero中取
// x,y该怪物的坐标查看手册和强制战斗时为undefined
// floorId该怪物所在的楼层
// 后面三个参数主要是可以在光环等效果上可以适用
floorId = floorId || core.status.floorId;
const { backDir } = core.plugin.utils;
// 勇士位置应该在这里进行计算,四个位置依次遍历,去重
let toMap = [];
// 指定了勇士坐标或者没有怪物坐标时
toMap = ['none'];
function getDamage(h) {
const enemyInfo = core.getEnemyInfo(enemy, hero, x, y, floorId);
let {
hp: mon_hp,
atk: mon_atk,
def: mon_def,
special: mon_special
} = enemyInfo;
let { atk: hero_atk, def: hero_def } =
core.plugin.hero.getHeroStatusOf(
hero,
['atk', 'def'],
x,
y,
floorId
);
let hero_hp = core.getRealStatusOrDefault(hero, 'hp'),
hero_IQ = core.getRealStatusOrDefault(hero, 'mdef'),
hero_recovery = core.getRealStatusOrDefault(hero, 'hpmax'),
hero_extraAtk = core.getRealStatusOrDefault(hero, 'mana');
let damage = 0;
// 饥渴
if (core.hasSpecial(mon_special, 7)) {
hero_atk *= 1 - (enemy.hungry || 0) / 100;
}
// 战前造成的额外伤害(可被护盾抵消)
var init_damage = 0;
// 每回合怪物对勇士造成的战斗伤害
var per_damage = mon_atk - hero_def;
// 魔攻:战斗伤害就是怪物攻击力
if (
core.hasSpecial(mon_special, 2) ||
core.hasSpecial(mon_special, 13)
) {
per_damage = mon_atk;
}
// 战斗伤害不能为负值
if (per_damage < 0) per_damage = 0;
// 先攻
if (core.hasSpecial(mon_special, 17)) damage += per_damage;
// 2连击 & 3连击 & N连击
if (core.hasSpecial(mon_special, 4)) per_damage *= 2;
if (core.hasSpecial(mon_special, 5)) per_damage *= 3;
if (core.hasSpecial(mon_special, 6)) per_damage *= enemy.n || 4;
// 勇士每回合对怪物造成的伤害
let hero_per_damage = Math.max(hero_atk - mon_def, 0);
if (!core.hasSpecial(mon_special, 9)) {
hero_per_damage = Math.max(hero_atk - mon_def, 0);
if (hero_per_damage > 0) hero_per_damage += hero_extraAtk;
} else {
hero_per_damage = Math.max(
hero_atk + hero_extraAtk - mon_def,
0
);
}
// 如果没有破防,则不可战斗
if (hero_per_damage <= 0) return null;
if (
core.hasSpecial(mon_special, 20) &&
!core.hasEquip('I589')
) {
hero_per_damage *= 1 - enemy.ice / 100;
}
hero_per_damage *= 1 - enemyInfo.iceDecline / 100;
if (core.hasSpecial(mon_special, 28)) {
hero_per_damage *= 1 - enemy.paleShield / 100;
}
// 勇士的攻击回合数;为怪物生命除以每回合伤害向上取整
let turn = Math.ceil(mon_hp / hero_per_damage);
// 致命一击
if (core.hasSpecial(mon_special, 1)) {
var times = Math.floor(turn / 5);
damage +=
((times * ((enemy.crit || 100) - 100)) / 100) *
per_damage;
}
// 勇气之刃
if (turn > 1 && core.hasSpecial(mon_special, 10)) {
damage += ((enemy.courage || 100) / 100 - 1) * per_damage;
}
// 勇气冲锋
if (core.hasSpecial(mon_special, 11)) {
damage += ((enemy.charge || 100) / 100) * per_damage;
turn += 5;
}
// 最终伤害:初始伤害 + 怪物对勇士造成的伤害 + 反击伤害
damage += init_damage + (turn - 1) * per_damage;
// 无上之盾
if (core.hasFlag('superSheild')) {
damage -= hero_IQ / 10;
}
// 生命回复
damage -= hero_recovery * turn;
if (core.getFlag('hard') === 1) damage *= 0.9;
return {
mon_hp: Math.floor(mon_hp),
mon_atk: Math.floor(mon_atk),
mon_def: Math.floor(mon_def),
init_damage: Math.floor(init_damage),
per_damage: Math.floor(per_damage),
hero_per_damage: Math.floor(hero_per_damage),
turn: Math.floor(turn),
damage: Math.floor(damage)
};
}
const skills = [
['bladeOn', 'blade'],
['shieldOn', 'shield']
];
function autoSkill(h) {
damageInfo = getDamage(h);
damage = damageInfo?.damage ?? Infinity;
if (flags.autoSkill) {
for (const [unlock, condition] of skills) {
if (!flags[unlock]) continue;
flags[condition] = true;
const info = getDamage(h);
const d = info?.damage;
if (d !== null && d !== void 0) {
if (d < damage) {
damage = d;
damageInfo = info;
}
}
flags[condition] = false;
}
} else {
damageInfo = getDamage(h);
if (damageInfo) damage = damageInfo.damage;
}
}
let dirDamageInfo = null;
let dirMinDamage = Infinity;
let damageInfo = null;
let damage = Infinity;
if (!flags.autoLocate) {
autoSkill(toMap[0][1]);
return damageInfo;
}
const dirDamage = [];
for (const dir of toMap) {
damage = Infinity;
damageInfo = null;
autoSkill();
dirDamage.push([dir, damage]);
if (damage < dirMinDamage) {
dirMinDamage = damage;
dirDamageInfo = damageInfo;
}
if (dirDamageInfo) {
return Object.assign(dirDamageInfo, { dir: dirDamage });
} else return null;
}
} }
}, },
actions: { actions: {

View File

@ -14,7 +14,6 @@ interface AncTePlugin {
utils: ReturnType<typeof import('../plugin/utils').default>; utils: ReturnType<typeof import('../plugin/utils').default>;
status: ReturnType<typeof import('../plugin/ui/statusBar').default>; status: ReturnType<typeof import('../plugin/ui/statusBar').default>;
mark: ReturnType<typeof import('../plugin/mark').default>; mark: ReturnType<typeof import('../plugin/mark').default>;
setting: ReturnType<typeof import('../plugin/settings').default>;
chapter: ReturnType<typeof import('../plugin/ui/chapter').default>; chapter: ReturnType<typeof import('../plugin/ui/chapter').default>;
fly: ReturnType<typeof import('../plugin/ui/fly').default>; fly: ReturnType<typeof import('../plugin/ui/fly').default>;
chase: ReturnType<typeof import('../plugin/chase/chase').default>; chase: ReturnType<typeof import('../plugin/chase/chase').default>;

View File

@ -5,7 +5,6 @@ import animate from '../plugin/animateController';
import utils from '../plugin/utils'; import utils from '../plugin/utils';
import status from '../plugin/ui/statusBar'; import status from '../plugin/ui/statusBar';
import mark from '../plugin/mark'; import mark from '../plugin/mark';
import setting from '../plugin/settings';
import chapter from '../plugin/ui/chapter'; import chapter from '../plugin/ui/chapter';
import fly from '../plugin/ui/fly'; import fly from '../plugin/ui/fly';
import chase from '../plugin/chase/chase'; import chase from '../plugin/chase/chase';
@ -31,7 +30,6 @@ export function resolvePlugin() {
['utils', utils()], ['utils', utils()],
['status', status()], ['status', status()],
['mark', mark()], ['mark', mark()],
['setting', setting()],
['chapter', chapter()], ['chapter', chapter()],
['fly', fly()], ['fly', fly()],
['chase', chase()], ['chase', chase()],

View File

@ -115,6 +115,13 @@ function getRealStatus(
return s; return s;
} }
declare global {
interface PluginDeclaration {
getHeroStatusOf: typeof getHeroStatusOf;
getHeroStatusOn: typeof getHeroStatusOn;
}
}
core.plugin.hero = { core.plugin.hero = {
getHeroStatusOf, getHeroStatusOf,
getHeroStatusOn getHeroStatusOn

View File

@ -45,20 +45,20 @@ core.registerReplayAction('upgradeSkill', name => {
}); });
core.registerReplayAction('study', name => { core.registerReplayAction('study', name => {
// todo: 删除getEnemyInfo // todo
if (!name.startsWith('study:')) return false; // if (!name.startsWith('study:')) return false;
const [num, x, y] = name // const [num, x, y] = name
.slice(6) // .slice(6)
.split(',') // .split(',')
.map(v => parseInt(v)); // .map(v => parseInt(v));
if (!canStudySkill(num)) return false; // if (!canStudySkill(num)) return false;
const id = core.getBlockId(x, y); // const id = core.getBlockId(x, y);
const enemy = core.getEnemyInfo(id, void 0, x, y); // const enemy = core.getEnemyInfo(id, void 0, x, y);
if (!enemy.special.includes(num)) return false; // if (!enemy.special.includes(num)) return false;
studySkill(enemy, num); // studySkill(enemy, num);
core.status.route.push(name); // core.status.route.push(name);
core.replay(); // core.replay();
return true; // return true;
}); });
// 商店 // 商店

View File

@ -1,15 +1,17 @@
import { reactive, ref } from 'vue'; import { reactive, ref } from 'vue';
import { tip } from './utils'; import { tip } from './utils';
import type { DamageEnemy } from './game/enemy/damage';
export const showMarkedEnemy = ref(false); export const showMarkedEnemy = ref(false);
const markedEnemy = reactive<EnemyIds[]>([]); const markedEnemy = reactive<EnemyIds[]>([]);
interface MarkInfo { interface MarkInfo {
enemy: DamageEnemy;
nextCritical: number; nextCritical: number;
} }
const markInfo: Partial<Record<EnemyIds, MarkInfo>> = {}; export const markInfo: Partial<Record<EnemyIds, MarkInfo>> = {};
const criticalReached: Partial<Record<EnemyIds, Record<number, boolean>>> = {}; const criticalReached: Partial<Record<EnemyIds, Record<number, boolean>>> = {};
const enemyDamageInfo: Partial<Record<EnemyIds, Record<number, boolean>>> = {}; const enemyDamageInfo: Partial<Record<EnemyIds, Record<number, boolean>>> = {};
@ -18,12 +20,16 @@ const enemyDamageInfo: Partial<Record<EnemyIds, Record<number, boolean>>> = {};
* @param id id * @param id id
*/ */
export function markEnemy(id: EnemyIds) { export function markEnemy(id: EnemyIds) {
// todo: 不使用 nextCriticals const { Enemy } = core.plugin.damage;
if (hasMarkedEnemy(id)) return; if (hasMarkedEnemy(id)) return;
markedEnemy.push(id); markedEnemy.push(id);
const enemy = new Enemy(core.material.enemys[id]);
enemy.calAttribute();
enemy.getRealInfo();
markInfo[id] = { markInfo[id] = {
nextCritical: nextCritical:
core.nextCriticals(id, 1)[0]?.[0] ?? 0 + core.status.hero.atk enemy.calCritical(1)[0]?.atkDelta ?? 0 + core.status.hero.atk,
enemy
}; };
criticalReached[id] = { 0: true }; criticalReached[id] = { 0: true };
enemyDamageInfo[id] = { 1: false, 2: false, 3: false }; enemyDamageInfo[id] = { 1: false, 2: false, 3: false };
@ -65,7 +71,6 @@ export function getMarkedEnemy() {
* @param id id * @param id id
*/ */
export function getMarkInfo(id: EnemyIds, noMessage: boolean = false) { export function getMarkInfo(id: EnemyIds, noMessage: boolean = false) {
// todo: 不使用 nextCriticals
const reached = criticalReached[id]!; const reached = criticalReached[id]!;
const info = markInfo[id]!; const info = markInfo[id]!;
if (core.status.hero.atk >= info.nextCritical) { if (core.status.hero.atk >= info.nextCritical) {
@ -73,7 +78,7 @@ export function getMarkInfo(id: EnemyIds, noMessage: boolean = false) {
tip('success', `踩到了${core.material.enemys[id].name}的临界!`); tip('success', `踩到了${core.material.enemys[id].name}的临界!`);
} }
reached[info.nextCritical] = true; reached[info.nextCritical] = true;
const n = core.nextCriticals(id, 1, void 0, void 0, 'empty')[0]?.[0]; const n = info.enemy.calCritical(1)[0]?.atkDelta;
const next = (n ?? 0) + core.status.hero.atk; const next = (n ?? 0) + core.status.hero.atk;
info.nextCritical = next; info.nextCritical = next;
} }
@ -83,15 +88,13 @@ export function getMarkInfo(id: EnemyIds, noMessage: boolean = false) {
* *
*/ */
export function checkMarkedEnemy(noMessage: boolean = false) { export function checkMarkedEnemy(noMessage: boolean = false) {
// todo: 删除 getDamageInfo
checkMarkedStatus.value = !checkMarkedStatus.value; checkMarkedStatus.value = !checkMarkedStatus.value;
const hp = core.status.hero.hp; const hp = core.status.hero.hp;
getMarkedEnemy().forEach(v => { getMarkedEnemy().forEach(v => {
getMarkInfo(v); getMarkInfo(v);
const damage = const { enemy } = markInfo[v]!;
core.getDamageInfo(v, void 0, void 0, void 0, 'empty')?.damage ?? const damage = enemy.calDamage().damage;
-1; if (!isFinite(damage)) return;
if (damage === -1) return;
const info = enemyDamageInfo[v]!; const info = enemyDamageInfo[v]!;
const name = core.material.enemys[v].name; const name = core.material.enemys[v].name;
let res = 0; let res = 0;

View File

@ -1,128 +0,0 @@
import { ref, watch } from 'vue';
// todo 优化可以考虑改成reactive
/** 打开和关闭ui时是否展示动画 */
export const transition = ref(false);
/** 道具详细信息 */
export const itemDetail = ref(true);
/** 自动切换技能 */
export const autoSkill = ref(true);
/** 自动放缩 */
export const autoScale = ref(true);
/** 是否在地图上展示范围光环 */
export const showHalo = ref(true);
/** 是否展示已学习的技能 */
export const showStudied = ref(true);
/** 是否使用定点查看功能 */
export const useFixed = ref(true);
/** 是否使用勇士自动定位功能 */
export const autoLocate = ref(true);
/** 是否开启抗锯齿 */
export const antiAliasing = ref(true);
/** 是否开启全屏 */
export const fullscreen = ref(false);
watch(transition, n => {
ancTe.plugin.ui.transition.value = n;
core.setLocalStorage('transition', n);
});
watch(itemDetail, n => {
flags.itemDetail = n;
core.updateStatusBar();
});
watch(autoSkill, n => {
flags.autoSkill = n;
core.updateStatusBar();
core.status.route.push(`set:autoSkill:${n}`);
});
watch(autoScale, n => {
core.setLocalStorage('autoScale', n);
});
watch(showStudied, n => {
core.setLocalStorage('showStudied', n);
});
watch(showHalo, n => {
core.setLocalStorage('showHalo', n);
});
watch(useFixed, n => {
core.setLocalStorage('useFixed', n);
});
watch(autoLocate, n => {
flags.autoLocate = n;
core.updateStatusBar();
core.status.route.push(`set:autoLocate:${n}`);
});
watch(antiAliasing, n => {
core.setLocalStorage('antiAliasing', n);
for (const canvas of core.dom.gameCanvas) {
if (core.domStyle.hdCanvas.includes(canvas.id)) continue;
if (n) {
canvas.classList.remove('no-anti-aliasing');
} else {
canvas.classList.add('no-anti-aliasing');
}
}
});
/**
* localStorage读取即可
*/
function reset() {
const t = core.getLocalStorage('transition', false);
transition.value = t;
ancTe.plugin.ui.transition.value = transition.value;
autoScale.value = core.getLocalStorage('autoScale', true);
showStudied.value = core.getLocalStorage('showStudied', true);
showHalo.value = core.getLocalStorage('showHalo', true);
antiAliasing.value = core.getLocalStorage('antiAliasing', false);
fullscreen.value = !!document.fullscreenElement;
}
function resetFlag() {
flags.autoSkill ??= true;
flags.itemDetail ??= true;
flags.autoLocate ??= true;
itemDetail.value = !!flags.itemDetail;
autoSkill.value = !!flags.autoSkill;
autoLocate.value = !!flags.autoLocate;
}
export async function triggerFullscreen() {
const { maxGameScale } = core.plugin.utils;
if (document.fullscreenElement) {
await document.exitFullscreen();
requestAnimationFrame(() => {
maxGameScale(1);
});
fullscreen.value = false;
} else {
await document.body.requestFullscreen();
requestAnimationFrame(() => {
maxGameScale();
});
fullscreen.value = true;
}
}
export default function init() {
return { resetSettings: reset, resetFlagSettings: resetFlag };
}

View File

@ -67,7 +67,7 @@ export function getNowStatus(nowEquip?: Equip, onCol: boolean = false) {
{toShow.map(v => { {toShow.map(v => {
let status: string; let status: string;
if (v === 'lv') status = core.getLvName() ?? ''; if (v === 'lv') status = core.getLvName() ?? '';
else status = core.getRealStatus(v)?.toString(); else status = core.plugin.getHeroStatusOn(v)?.toString();
let add = 0; let add = 0;
if (has(nowEquip)) { if (has(nowEquip)) {

51
src/types/enemy.d.ts vendored
View File

@ -323,57 +323,6 @@ interface Enemys extends EnemyData {
dir?: Dir | 'none' | (Dir | 'none')[] dir?: Dir | 'none' | (Dir | 'none')[]
): boolean; ): boolean;
/**
*
* @example core.getDamageString('greenSlime', 0, 0, 'MT0') // 绿头怪的地图显伤
* @param enemy id或敌人对象
* @param x
* @param y
* @param floorId
*/
getDamageString(
enemy: EnemyIds | Enemy,
x?: number,
y?: number,
floorId?: FloorIds
): DamageString;
/**
* useLoop开关选择回合法或二分法
* @example core.nextCriticals('greenSlime', 9, 0, 0, 'MT0') // 绿头怪接下来的9个临界
* @param enemy id或敌人对象
* @param number 1
* @param x
* @param y
* @param floorId
* @returns
*/
nextCriticals(
enemy: EnemyIds | Enemy,
number?: number,
x?: number,
y?: number,
floorId?: FloorIds
): [critical: number, damage: number][];
/**
* 使
* @example core.nextCriticals('greenSlime', 10, 0, 0, 'MT0') // 再加10点防御能使绿头怪的伤害降低多少
* @param enemy id或敌人对象
* @param k 1
* @param x
* @param y
* @param floorId
* @returns
*/
getDefDamage(
enemy: EnemyIds | Enemy,
k?: number,
x?: number,
y?: number,
floorId?: FloorIds
): number;
/** /**
* *
* @example core.getDamage('greenSlime',0,0,'MT0') // 绿头怪的总伤害 * @example core.getDamage('greenSlime',0,0,'MT0') // 绿头怪的总伤害

View File

@ -58,38 +58,6 @@ interface EnemyData {
*/ */
getSpecials(): EnemySpecialDeclaration[]; getSpecials(): EnemySpecialDeclaration[];
/**
*
* @param enemy id或敌人对象
* @param hero core.status.hero获取
* @param x
* @param y
* @param floorId
*/
getEnemyInfo(
enemy: EnemyIds | Enemy,
hero?: HeroStatus,
x?: number,
y?: number,
floorId?: FloorIds
): EnemyInfo;
/**
*
* @param enemy id或敌人对象
* @param hero core.status.hero获取
* @param x
* @param y
* @param floorId
*/
getDamageInfo(
enemy: EnemyIds | Enemy,
hero?: Partial<HeroStatus>,
x?: number,
y?: number,
floorId?: FloorIds
): DamageInfo;
/** /**
* *
* @example core.hasSpecial('greenSlime', 1) // 判定绿头怪有无先攻属性 * @example core.hasSpecial('greenSlime', 1) // 判定绿头怪有无先攻属性

10
src/types/plugin.d.ts vendored
View File

@ -84,16 +84,6 @@ interface PluginDeclaration
*/ */
unmarkEnemy(id: EnemyIds): void; unmarkEnemy(id: EnemyIds): void;
/**
*
*/
resetSettings(): void;
/**
*
*/
resetFlagSettings(): void;
/** /**
* undefined或null * undefined或null
* @param value * @param value

View File

@ -56,7 +56,12 @@
<script lang="ts" setup> <script lang="ts" setup>
import { reactive, ref, watch } from 'vue'; import { reactive, ref, watch } from 'vue';
import { checkMarkedStatus, getMarkedEnemy, unmarkEnemy } from '../plugin/mark'; import {
checkMarkedStatus,
getMarkedEnemy,
markInfo,
unmarkEnemy
} from '../plugin/mark';
import { has } from '../plugin/utils'; import { has } from '../plugin/utils';
import Box from '../components/box.vue'; import Box from '../components/box.vue';
import Scroll from '../components/scroll.vue'; import Scroll from '../components/scroll.vue';
@ -102,27 +107,16 @@ function getName(id: EnemyIds) {
} }
function getDamage(id: EnemyIds) { function getDamage(id: EnemyIds) {
// todo: getDamageInfo return core.formatBigNumber(markInfo[id]!.enemy.calDamage().damage);
return (
core.formatBigNumber(
core.getDamageInfo(id, void 0, void 0, void 0, 'empty')?.damage
) ?? '???'
);
} }
function getCritical(id: EnemyIds) { function getCritical(id: EnemyIds) {
// todo: 使 nextCriticals const { delta, atkDelta } = markInfo[id]!.enemy.calCritical(1)[0];
return ( return [-delta, atkDelta];
core
.nextCriticals(id, 1, void 0, void 0, 'empty')[0]
?.map(v => core.formatBigNumber(v)) ?? [0, 0]
);
} }
function getDefDamage(id: EnemyIds) { function getDefDamage(id: EnemyIds) {
return core.formatBigNumber( return core.formatBigNumber(markInfo[id]!.enemy.calDefDamage(ratio).delta);
core.getDefDamage(id, ratio, void 0, void 0, 'empty')
);
} }
</script> </script>

View File

@ -179,7 +179,7 @@ watch(status, update);
*/ */
function update() { function update() {
toShow.forEach(v => { toShow.forEach(v => {
hero[v] = core.getRealStatus(v); hero[v] = core.plugin.getHeroStatusOn(v);
}); });
keys[0] = core.itemCount('yellowKey'); keys[0] = core.itemCount('yellowKey');
keys[1] = core.itemCount('blueKey'); keys[1] = core.itemCount('blueKey');