移动鼠标查看怪物信息

This commit is contained in:
AncTe committed 2023-01-06 21:51:58 +08:00
1 parent b84b1e6137
commit ac55517d57
21 files changed
+476 -141

No files matched your search

+9
View File
@@ -30,6 +30,11 @@ export const showHalo = ref(true);
*/
export const showStudied = ref(true);
/**
* 是否使用定点查看功能
*/
export const useFixed = ref(true);
watch(transition, n => {
core.plugin.transition.value = n;
core.setLocalStorage('transition', n);
@@ -58,6 +63,10 @@ watch(showHalo, n => {
core.setLocalStorage('showHalo', n);
});
watch(useFixed, n => {
core.setLocalStorage('useFixed', n);
});
/**
* 重置设置信息,从localStorage读取即可
*/
+4 -4
View File
@@ -60,8 +60,8 @@ export function getDefDamage(
for (let i = 0; i <= max; i++) {
const dam = core.getDamageInfo(enemy.id, {
def: core.status.hero.def + ratio * i + addDef,
atk: core.status.hero.atk + addAtk
def: core.getStatus('def') + ratio * i + addDef,
atk: core.getStatus('atk') + addAtk
});
if (res.length === 0) {
@@ -100,8 +100,8 @@ export function getCriticalDamage(
for (let i = 0; i <= max; i++) {
const dam = core.getDamageInfo(enemy.id, {
atk: core.status.hero.atk + ratio * i + addAtk,
def: core.status.hero.def + addDef
atk: core.getStatus('atk') + ratio * i + addAtk,
def: core.getStatus('def') + addDef
});
if (res.length === 0) {
+64
View File
@@ -0,0 +1,64 @@
import { cloneDeep, debounce } from 'lodash';
import { ref } from 'vue';
import { getDamageColor } from '../utils';
export const showFixed = ref(false);
const show = debounce((ev: MouseEvent) => {
if (!window.flags) return;
if (!flags.mouseLoc) return;
flags.clientLoc = [ev.clientX, ev.clientY];
const [x, y] = flags.mouseLoc;
const e = core.getBlockId(x, y);
if (!e || !core.getClsFromId(e)?.startsWith('enemy')) return;
const enemy = core.material.enemys[e as EnemyIds];
const detail = getDetailedEnemy(enemy, x, y);
core.plugin.bookDetailEnemy = detail;
showFixed.value = true;
}, 200);
export default function init() {
const data = core.canvas.data.canvas;
data.addEventListener('mousemove', ev => {
showFixed.value = false;
show(ev);
});
}
export function getDetailedEnemy<I extends EnemyIds>(
enemy: Enemy<I>,
x: number,
y: number,
floorId: FloorIds = core.status.floorId
): DetailedEnemy<I> {
const ratio = core.status.maps[floorId].ratio;
const enemyInfo = Object.assign(
core.getEnemyInfo(enemy, void 0, x, y),
core.getDamageInfo(enemy, void 0, x, y) ?? {},
enemy
);
const critical = core.nextCriticals(enemy, 1, x, y);
const defDamage = core.getDefDamage(enemy, ratio, x, y);
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']);
}
const damageColor = getDamageColor(enemyInfo.damage);
const detail: DetailedEnemy<I> = Object.assign(enemyInfo, {
critical: critical[0][0],
criticalDamage: critical[0][1],
defDamage,
specialColor,
specialText,
toShowColor,
toShowSpecial,
damageColor
});
return detail;
}