From 62e8f914360056c59ec246b7056cccc73d51e5fe Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Mon, 31 Jul 2023 20:50:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=9A=E7=82=B9=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- idea.md | 1 + src/plugin/ui/book.tsx | 11 ++++- src/plugin/ui/fixed.ts | 96 +++++++++++++++++++++++------------------- src/ui/book.vue | 11 +---- 4 files changed, 64 insertions(+), 55 deletions(-) diff --git a/idea.md b/idea.md index aa2d06e..92c709f 100644 --- a/idea.md +++ b/idea.md @@ -76,3 +76,4 @@ dam4.png ---- 存档 59 [] 玩家可以设置字体大小 [] 完全删除 functions.js [] 优化插件加载系统 +[] 优化 Scroll 组件 diff --git a/src/plugin/ui/book.tsx b/src/plugin/ui/book.tsx index 7aafe48..b9c38eb 100644 --- a/src/plugin/ui/book.tsx +++ b/src/plugin/ui/book.tsx @@ -21,6 +21,15 @@ interface BookDetailInfo { export const detailInfo: BookDetailInfo = {}; +export const specials = Object.fromEntries( + core.getSpecials().map(v => { + return [v[0], v.slice(1)]; + }) +) as Record< + string, + EnemySpecialDeclaration extends [number, ...infer F] ? F : never +>; + /** * 获取怪物的特殊技能描述 * @param enemy 怪物实例 @@ -51,7 +60,6 @@ export function getDefDamage( addDef: number = 0, addAtk: number = 0 ) { - // todo: 删除 getDamageInfo const ratio = core.status.thisMap.ratio; const res: [number, number][] = []; @@ -95,7 +103,6 @@ export function getCriticalDamage( addAtk: number = 0, addDef: number = 0 ): [number, number][] { - // todo: 删除 getDamageInfo const ratio = core.status.thisMap.ratio; const res: [number, number][] = []; diff --git a/src/plugin/ui/fixed.ts b/src/plugin/ui/fixed.ts index a48dd35..4532063 100644 --- a/src/plugin/ui/fixed.ts +++ b/src/plugin/ui/fixed.ts @@ -1,6 +1,8 @@ import { cloneDeep, debounce } from 'lodash-es'; import { ref } from 'vue'; import { getDamageColor } from '../utils'; +import { ToShowEnemy, detailInfo, specials } from './book'; +import { DamageEnemy } from '../game/enemy/damage'; export const showFixed = ref(false); @@ -11,14 +13,15 @@ const show = debounce((ev: MouseEvent) => { if (!flags.mouseLoc) return; flags.clientLoc = [ev.clientX, ev.clientY]; const [mx, my] = getLocFromMouseLoc(...flags.mouseLoc); - const e = core.getBlockId(mx, my); - if (e !== lastId) showFixed.value = false; - if (!e || !core.getClsFromId(e)?.startsWith('enemy')) return; + const e = core.status.thisMap.enemy.list.find(v => { + v.x === mx && v.y === my; + }); - lastId = e as EnemyIds; - const enemy = core.material.enemys[e as EnemyIds]; - const detail = getDetailedEnemy(enemy, mx, my); - core.plugin.bookDetailEnemy = detail; + if (!e) return; + + lastId = e.id; + const detail = getDetailedEnemy(e); + detailInfo.enemy = detail; showFixed.value = true; }, 200); @@ -47,47 +50,54 @@ export function getLocFromMouseLoc(x: number, y: number): LocArr { return [mx, my]; } -export function getDetailedEnemy( - enemy: Enemy, - x: number, - y: number, +export function getDetailedEnemy( + enemy: DamageEnemy, floorId: FloorIds = core.status.floorId -): DetailedEnemy { +): ToShowEnemy { // todo: 删除 getDamageInfo // todo: 不使用 nextCriticals const ratio = core.status.maps[floorId].ratio; - const enemyInfo = Object.assign( - {}, - enemy, - core.getEnemyInfo(enemy, void 0, x, y, floorId), - core.getDamageInfo(enemy, void 0, x, y, floorId) ?? {} + + const dam = enemy.calEnemyDamage(core.status.hero, 'none')[0].damage; + const cri = enemy.calCritical(1, 'none')[0]?.[0]; + const critical = core.formatBigNumber(cri?.atkDelta); + const criticalDam = core.formatBigNumber(cri?.delta); + const defDam = core.formatBigNumber( + enemy.calDefDamage(ratio, 'none')[0].damage ); - const critical = core.nextCriticals(enemy, 1, x, y, floorId); - const defDamage = core.getDefDamage(enemy, ratio, x, y, floorId); - const specialText = core.getSpecialText(enemyInfo); - let toShowSpecial = cloneDeep(specialText); - if (toShowSpecial.length > 2) { - toShowSpecial = toShowSpecial.slice(0, 2).concat(['...']); - } - const specialColor = core.getSpecialColor(enemyInfo); - let toShowColor = cloneDeep(specialColor); - if (toShowColor.length > 2) { - toShowColor = toShowColor.slice(0, 2).concat(['#fff']); - } - if (toShowSpecial.length === 0) { - toShowSpecial = ['无属性']; - toShowColor = ['#fff']; - } - const damageColor = getDamageColor(enemyInfo.damage); - const detail: DetailedEnemy = Object.assign(enemyInfo, { - critical: critical[0]?.[0] ?? '???', - criticalDamage: critical[0]?.[1] ?? '???', - defDamage, - specialColor, - specialText, - toShowColor, - toShowSpecial, - damageColor + const damage = core.formatBigNumber(dam); + + const fromFunc = ( + func: string | ((enemy: Enemy) => string), + enemy: Enemy + ) => { + return typeof func === 'string' ? func : func(enemy); + }; + const special: [string, string, string][] = enemy.enemy.special.map(vv => { + const s = specials[vv]; + return [ + fromFunc(s[0], enemy.enemy), + fromFunc(s[1], enemy.enemy), + s[2] as string + ]; }); + const showSpecial = + special.length > 2 + ? special.slice(0, 2).concat(['...', '', '#fff']) + : special.slice(); + + const damageColor = getDamageColor(dam) as string; + + const detail: ToShowEnemy = { + enemy, + onMapEnemy: [enemy], + critical, + criticalDam, + defDam, + damageColor, + special, + showSpecial, + damage + }; return detail; } diff --git a/src/ui/book.vue b/src/ui/book.vue index be67333..9f8061b 100644 --- a/src/ui/book.vue +++ b/src/ui/book.vue @@ -47,21 +47,12 @@ import BookDetail from './bookDetail.vue'; import { LeftOutlined } from '@ant-design/icons-vue'; import { KeyCode } from '../plugin/keyCodes'; import { noClosePanel } from '../plugin/uiController'; -import { ToShowEnemy, detailInfo } from '../plugin/ui/book'; +import { ToShowEnemy, detailInfo, specials } from '../plugin/ui/book'; const floorId = // @ts-ignore core.floorIds[core.status.event?.ui?.index] ?? core.status.floorId; -const specials = Object.fromEntries( - core.getSpecials().map(v => { - return [v[0], v.slice(1)]; - }) -) as Record< - string, - EnemySpecialDeclaration extends [number, ...infer F] ? F : never ->; - const enemy = core.getCurrentEnemys(floorId); const toShow: ToShowEnemy[] = enemy.map(v => { const cri = v.enemy.calCritical(1, 'none')[0];