From 1854389966ca970ecd9df4a03158c00f42331f73 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Sun, 6 Aug 2023 22:43:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=AE=8C=E6=AF=95=E6=89=80?= =?UTF-8?q?=E6=9C=89=E9=9C=80=E8=A6=81=E5=88=A0=E9=99=A4=E7=9A=84todo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/_server/table/functions.comment.js | 12 - public/libs/control.js | 5 +- public/libs/enemys.js | 305 +---------------- public/main.js | 1 - public/project/functions.js | 382 ---------------------- src/core/index.ts | 1 - src/core/plugin.ts | 2 - src/plugin/game/hero.ts | 7 + src/plugin/game/replay.js | 28 +- src/plugin/mark.ts | 23 +- src/plugin/settings.ts | 128 -------- src/plugin/ui/equipbox.tsx | 2 +- src/types/enemy.d.ts | 51 --- src/types/function.d.ts | 32 -- src/types/plugin.d.ts | 10 - src/ui/markedEnemy.vue | 26 +- src/ui/statusBar.vue | 2 +- 17 files changed, 66 insertions(+), 951 deletions(-) delete mode 100644 src/plugin/settings.ts diff --git a/public/_server/table/functions.comment.js b/public/_server/table/functions.comment.js index adb3444..3d6728d 100644 --- a/public/_server/table/functions.comment.js +++ b/public/_server/table/functions.comment.js @@ -81,18 +81,6 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { _type: 'textarea', _lint: true, _data: '怪物特殊属性' - }, - getEnemyInfo: { - _leaf: true, - _type: 'textarea', - _lint: true, - _data: '怪物真实属性' - }, - getDamageInfo: { - _leaf: true, - _type: 'textarea', - _lint: true, - _data: '战斗伤害信息' } } }, diff --git a/public/libs/control.js b/public/libs/control.js index 5005aa2..71f0e9f 100644 --- a/public/libs/control.js +++ b/public/libs/control.js @@ -2817,13 +2817,12 @@ control.prototype.getStatusOrDefault = function (status, name) { ////// 获得勇士实际属性(增幅后的) ////// control.prototype.getRealStatus = function (name) { - return this.getRealStatusOrDefault(null, name); + // Deprecated. See src/plugin/game/hero.ts }; ////// 从status中获得实际属性(增幅后的),如果不存在则从勇士属性中获取 ////// control.prototype.getRealStatusOrDefault = function (status, name) { - // todo: 删除 - return core.plugin.hero.getHeroStatusOf(status, name); + // Deprecated. See src/plugin/game/hero.ts }; ////// 获得勇士原始属性(无装备和衰弱影响) ////// diff --git a/public/libs/enemys.js b/public/libs/enemys.js index a006a85..b6aea6d 100644 --- a/public/libs/enemys.js +++ b/public/libs/enemys.js @@ -212,217 +212,43 @@ enemys.prototype.getDamageString = function (enemy, x, y, floorId, hero) { ////// 接下来N个临界值和临界减伤计算 ////// enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId, hero) { - // todo: 删除这个函数 - 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 - ); + // Deprecated. See src/plugin/game/enemy/damage.ts DamageEnemy.calCritical. }; /// 未破防临界采用二分计算 -enemys.prototype._nextCriticals_overAtk = function ( - enemy, - 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_overAtk = function (enemy) { + // Deprecated. See src/plugin/game/enemy/damage.ts DamageEnemy.calCritical. }; -enemys.prototype._nextCriticals_special = function ( - enemy, - number, - x, - y, - floorId -) { - if (this.hasSpecial(enemy.special, 10) || this.hasSpecial(enemy.special, 3)) - return []; // 模仿or坚固临界 - return null; +enemys.prototype._nextCriticals_special = function (enemy) { + // Deprecated. See src/plugin/game/enemy/damage.ts DamageEnemy.calCritical. }; -enemys.prototype._nextCriticals_useBinarySearch = function ( - enemy, - 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; +enemys.prototype._nextCriticals_useBinarySearch = function (enemy) { + // Deprecated. See src/plugin/game/enemy/damage.ts DamageEnemy.calCritical. }; ////// N防减伤计算 ////// enemys.prototype.getDefDamage = function (enemy, k, x, y, floorId, hero) { - // todo: 删除这个函数 - 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; + // Deprecated. See src/plugin/game/enemy/damage.ts DamageEnemy.calDefDamage. }; enemys.prototype.getEnemyInfo = function (enemy, hero, x, y, floorId) { - // todo: 删除这个函数 - if (enemy == null) return null; - if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; - return this.enemydata.getEnemyInfo(enemy, hero, x, y, floorId); + // Deprecated. See src/plugin/game/enemy/damage.ts }; ////// 获得战斗伤害信息(实际伤害计算函数) ////// enemys.prototype.getDamageInfo = function (enemy, hero, x, y, floorId) { - // todo: 删除这个函数 - if (enemy == null) return null; - // 移动到了脚本编辑 - getDamageInfo中 - if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; - return this.enemydata.getDamageInfo(enemy, hero, x, y, floorId); + // Deprecated. See src/plugin/game/enemy/damage.ts }; ////// 获得在某个勇士属性下怪物伤害 ////// enemys.prototype.getDamage = function (enemy, x, y, floorId, hero) { - // todo: 修改这个函数的参数 - return this._getDamage(enemy, hero, x, y, floorId); + // Deprecated. See src/plugin/game/enemy/damage.ts }; enemys.prototype._getDamage = function (enemy, hero, x, y, floorId) { - // todo: 重写这个函数 - 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; + // Deprecated. See src/plugin/game/enemy/damage.ts }; ////// 获得当前楼层的怪物列表 ////// @@ -431,114 +257,19 @@ enemys.prototype.getCurrentEnemys = function (floorId) { }; enemys.prototype._getCurrentEnemys_getEnemy = function (enemyId) { - var enemy = core.material.enemys[enemyId]; - if (!enemy) return null; - - // 检查朝向;displayIdInBook - return ( - core.material.enemys[enemy.displayIdInBook] || - core.material.enemys[(enemy.faceIds || {}).down] || - enemy - ); + // Deprecated. See src/plugin/game/enemy/battle.ts }; -enemys.prototype._getCurrentEnemys_addEnemy = function ( - enemyId, - 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 = function (enemyId) { + // Deprecated. See src/plugin/game/enemy/battle.ts }; -enemys.prototype._getCurrentEnemys_addEnemy_defDamage = function ( - enemy, - 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_addEnemy_defDamage = function (enemy) { + // Deprecated. See src/plugin/game/enemy/battle.ts }; enemys.prototype._getCurrentEnemys_sort = function (enemys) { - return enemys.sort(function (a, b) { - 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; - }); + // Deprecated. See src/plugin/game/enemy/battle.ts }; enemys.prototype.hasEnemyLeft = function (enemyId, floorId) { diff --git a/public/main.js b/public/main.js index c3db4f0..884801b 100644 --- a/public/main.js +++ b/public/main.js @@ -405,7 +405,6 @@ main.prototype.loadAsync = async function (mode, callback) { await core.init(coreData, callback); if (main.mode === 'play') main.loading.emit('coreInit'); if (main.mode === 'play') { - ancTe.plugin.setting.resetSettings(); ancTe.plugin.mark.showMarkedEnemy.value = true; } diff --git a/public/project/functions.js b/public/project/functions.js index 9194834..e06327a 100644 --- a/public/project/functions.js +++ b/public/project/functions.js @@ -550,388 +550,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { 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: { diff --git a/src/core/index.ts b/src/core/index.ts index ebb6929..a2c823c 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -14,7 +14,6 @@ interface AncTePlugin { utils: ReturnType; status: ReturnType; mark: ReturnType; - setting: ReturnType; chapter: ReturnType; fly: ReturnType; chase: ReturnType; diff --git a/src/core/plugin.ts b/src/core/plugin.ts index f5434f0..dd8da0f 100644 --- a/src/core/plugin.ts +++ b/src/core/plugin.ts @@ -5,7 +5,6 @@ import animate from '../plugin/animateController'; import utils from '../plugin/utils'; import status from '../plugin/ui/statusBar'; import mark from '../plugin/mark'; -import setting from '../plugin/settings'; import chapter from '../plugin/ui/chapter'; import fly from '../plugin/ui/fly'; import chase from '../plugin/chase/chase'; @@ -31,7 +30,6 @@ export function resolvePlugin() { ['utils', utils()], ['status', status()], ['mark', mark()], - ['setting', setting()], ['chapter', chapter()], ['fly', fly()], ['chase', chase()], diff --git a/src/plugin/game/hero.ts b/src/plugin/game/hero.ts index 45c6329..f097f8b 100644 --- a/src/plugin/game/hero.ts +++ b/src/plugin/game/hero.ts @@ -115,6 +115,13 @@ function getRealStatus( return s; } +declare global { + interface PluginDeclaration { + getHeroStatusOf: typeof getHeroStatusOf; + getHeroStatusOn: typeof getHeroStatusOn; + } +} + core.plugin.hero = { getHeroStatusOf, getHeroStatusOn diff --git a/src/plugin/game/replay.js b/src/plugin/game/replay.js index 6c254f1..c63e634 100644 --- a/src/plugin/game/replay.js +++ b/src/plugin/game/replay.js @@ -45,20 +45,20 @@ core.registerReplayAction('upgradeSkill', name => { }); core.registerReplayAction('study', name => { - // todo: 删除getEnemyInfo - if (!name.startsWith('study:')) return false; - const [num, x, y] = name - .slice(6) - .split(',') - .map(v => parseInt(v)); - if (!canStudySkill(num)) return false; - const id = core.getBlockId(x, y); - const enemy = core.getEnemyInfo(id, void 0, x, y); - if (!enemy.special.includes(num)) return false; - studySkill(enemy, num); - core.status.route.push(name); - core.replay(); - return true; + // todo + // if (!name.startsWith('study:')) return false; + // const [num, x, y] = name + // .slice(6) + // .split(',') + // .map(v => parseInt(v)); + // if (!canStudySkill(num)) return false; + // const id = core.getBlockId(x, y); + // const enemy = core.getEnemyInfo(id, void 0, x, y); + // if (!enemy.special.includes(num)) return false; + // studySkill(enemy, num); + // core.status.route.push(name); + // core.replay(); + // return true; }); // 商店 diff --git a/src/plugin/mark.ts b/src/plugin/mark.ts index f2d03cf..5cb8421 100644 --- a/src/plugin/mark.ts +++ b/src/plugin/mark.ts @@ -1,15 +1,17 @@ import { reactive, ref } from 'vue'; import { tip } from './utils'; +import type { DamageEnemy } from './game/enemy/damage'; export const showMarkedEnemy = ref(false); const markedEnemy = reactive([]); interface MarkInfo { + enemy: DamageEnemy; nextCritical: number; } -const markInfo: Partial> = {}; +export const markInfo: Partial> = {}; const criticalReached: Partial>> = {}; const enemyDamageInfo: Partial>> = {}; @@ -18,12 +20,16 @@ const enemyDamageInfo: Partial>> = {}; * @param id 标记的怪物id */ export function markEnemy(id: EnemyIds) { - // todo: 不使用 nextCriticals + const { Enemy } = core.plugin.damage; if (hasMarkedEnemy(id)) return; markedEnemy.push(id); + const enemy = new Enemy(core.material.enemys[id]); + enemy.calAttribute(); + enemy.getRealInfo(); markInfo[id] = { 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 }; enemyDamageInfo[id] = { 1: false, 2: false, 3: false }; @@ -65,7 +71,6 @@ export function getMarkedEnemy() { * @param id 怪物id */ export function getMarkInfo(id: EnemyIds, noMessage: boolean = false) { - // todo: 不使用 nextCriticals const reached = criticalReached[id]!; const info = markInfo[id]!; 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}的临界!`); } 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; info.nextCritical = next; } @@ -83,15 +88,13 @@ export function getMarkInfo(id: EnemyIds, noMessage: boolean = false) { * 检查被标记怪物的状态 */ export function checkMarkedEnemy(noMessage: boolean = false) { - // todo: 删除 getDamageInfo checkMarkedStatus.value = !checkMarkedStatus.value; const hp = core.status.hero.hp; getMarkedEnemy().forEach(v => { getMarkInfo(v); - const damage = - core.getDamageInfo(v, void 0, void 0, void 0, 'empty')?.damage ?? - -1; - if (damage === -1) return; + const { enemy } = markInfo[v]!; + const damage = enemy.calDamage().damage; + if (!isFinite(damage)) return; const info = enemyDamageInfo[v]!; const name = core.material.enemys[v].name; let res = 0; diff --git a/src/plugin/settings.ts b/src/plugin/settings.ts deleted file mode 100644 index 1ebcd25..0000000 --- a/src/plugin/settings.ts +++ /dev/null @@ -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 }; -} diff --git a/src/plugin/ui/equipbox.tsx b/src/plugin/ui/equipbox.tsx index 4f9406c..ae5ff98 100644 --- a/src/plugin/ui/equipbox.tsx +++ b/src/plugin/ui/equipbox.tsx @@ -67,7 +67,7 @@ export function getNowStatus(nowEquip?: Equip, onCol: boolean = false) { {toShow.map(v => { let status: string; if (v === 'lv') status = core.getLvName() ?? ''; - else status = core.getRealStatus(v)?.toString(); + else status = core.plugin.getHeroStatusOn(v)?.toString(); let add = 0; if (has(nowEquip)) { diff --git a/src/types/enemy.d.ts b/src/types/enemy.d.ts index 3535b4c..c5b11d9 100644 --- a/src/types/enemy.d.ts +++ b/src/types/enemy.d.ts @@ -323,57 +323,6 @@ interface Enemys extends EnemyData { dir?: Dir | 'none' | (Dir | 'none')[] ): 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') // 绿头怪的总伤害 diff --git a/src/types/function.d.ts b/src/types/function.d.ts index ae90b56..8bafbfd 100644 --- a/src/types/function.d.ts +++ b/src/types/function.d.ts @@ -58,38 +58,6 @@ interface EnemyData { */ 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, - x?: number, - y?: number, - floorId?: FloorIds - ): DamageInfo; - /** * 判定某种特殊属性的有无 * @example core.hasSpecial('greenSlime', 1) // 判定绿头怪有无先攻属性 diff --git a/src/types/plugin.d.ts b/src/types/plugin.d.ts index ae39ca3..cbf1dc6 100644 --- a/src/types/plugin.d.ts +++ b/src/types/plugin.d.ts @@ -84,16 +84,6 @@ interface PluginDeclaration */ unmarkEnemy(id: EnemyIds): void; - /** - * 重置设置信息 - */ - resetSettings(): void; - - /** - * 重置变量的设置信息 - */ - resetFlagSettings(): void; - /** * 判定一个值是否不是undefined或null * @param value 要判断的值 diff --git a/src/ui/markedEnemy.vue b/src/ui/markedEnemy.vue index d7afbb1..7de36a2 100644 --- a/src/ui/markedEnemy.vue +++ b/src/ui/markedEnemy.vue @@ -56,7 +56,12 @@ diff --git a/src/ui/statusBar.vue b/src/ui/statusBar.vue index 528b8e1..6816013 100644 --- a/src/ui/statusBar.vue +++ b/src/ui/statusBar.vue @@ -179,7 +179,7 @@ watch(status, update); */ function update() { toShow.forEach(v => { - hero[v] = core.getRealStatus(v); + hero[v] = core.plugin.getHeroStatusOn(v); }); keys[0] = core.itemCount('yellowKey'); keys[1] = core.itemCount('blueKey');