mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-04-08 13:37:06 +08:00
重构怪物手册的一部分
This commit is contained in:
parent
dae43498ca
commit
112ce4c4ef
@ -427,24 +427,7 @@ enemys.prototype._getDamage = function (enemy, hero, x, y, floorId) {
|
||||
|
||||
////// 获得当前楼层的怪物列表 //////
|
||||
enemys.prototype.getCurrentEnemys = function (floorId) {
|
||||
// todo: 重写这个函数
|
||||
floorId = floorId || core.status.floorId;
|
||||
var enemys = [],
|
||||
used = {};
|
||||
core.extractBlocks(floorId);
|
||||
core.status.maps[floorId].blocks.forEach(function (block) {
|
||||
if (!block.disable && block.event.cls.indexOf('enemy') == 0) {
|
||||
this._getCurrentEnemys_addEnemy(
|
||||
block.event.id,
|
||||
enemys,
|
||||
used,
|
||||
block.x,
|
||||
block.y,
|
||||
floorId
|
||||
);
|
||||
}
|
||||
}, this);
|
||||
return this._getCurrentEnemys_sort(enemys);
|
||||
// Deprecated. See src/plugin/game/enemy/battle.ts
|
||||
};
|
||||
|
||||
enemys.prototype._getCurrentEnemys_getEnemy = function (enemyId) {
|
||||
|
@ -3531,64 +3531,7 @@ maps.prototype.resetMap = function (floorId) {
|
||||
|
||||
////// 初始化独立的block canvas //////
|
||||
maps.prototype._initDetachedBlock = function (blockInfo, x, y, displayDamage) {
|
||||
// todo: 不使用 nextCriticals 和 getDamageString
|
||||
var headCanvas = null,
|
||||
bodyCanvas = '__body_' + x + '_' + y,
|
||||
damageCanvas = null;
|
||||
// head
|
||||
if (!blockInfo.bigImage && blockInfo.height > 32) {
|
||||
headCanvas = '__head_' + x + '_' + y;
|
||||
core.createCanvas(headCanvas, 0, 0, 32, blockInfo.height - 32, 55);
|
||||
}
|
||||
// body
|
||||
if (blockInfo.bigImage) {
|
||||
var bigImageInfo = this._getBigImageInfo(
|
||||
blockInfo.bigImage,
|
||||
blockInfo.face,
|
||||
blockInfo.posX
|
||||
);
|
||||
core.createCanvas(
|
||||
bodyCanvas,
|
||||
0,
|
||||
0,
|
||||
bigImageInfo.per_width,
|
||||
bigImageInfo.per_height,
|
||||
35
|
||||
);
|
||||
} else {
|
||||
core.createCanvas(bodyCanvas, 0, 0, 32, 32, 35);
|
||||
}
|
||||
// damage
|
||||
var damage = null,
|
||||
damageColor = null;
|
||||
if (
|
||||
blockInfo.cls.indexOf('enemy') == 0 &&
|
||||
core.hasItem('book') &&
|
||||
displayDamage
|
||||
) {
|
||||
var damageString = core.enemys.getDamageString(blockInfo.id, x, y);
|
||||
damage = damageString.damage;
|
||||
damageColor = damageString.color;
|
||||
}
|
||||
if (damage != null) {
|
||||
damageCanvas = '__damage_' + x + '_' + y;
|
||||
var ctx = core.createCanvas(damageCanvas, 0, 0, 32, 32, 65);
|
||||
ctx.textAlign = 'left';
|
||||
ctx.font = 'bold 11px Arial';
|
||||
core.fillBoldText(ctx, damage, 1, 31, damageColor);
|
||||
if (core.flags.displayCritical) {
|
||||
var critical = core.enemys.nextCriticals(blockInfo.id);
|
||||
if (critical.length > 0) critical = critical[0];
|
||||
critical = core.formatBigNumber(critical[0], true);
|
||||
if (critical == '???') critical = '?';
|
||||
core.fillBoldText(ctx, critical, 1, 21, '#FFFFFF');
|
||||
}
|
||||
}
|
||||
return {
|
||||
headCanvas: headCanvas,
|
||||
bodyCanvas: bodyCanvas,
|
||||
damageCanvas: damageCanvas
|
||||
};
|
||||
// Deprecated. See src/plugin/game/fx/rewrite.ts
|
||||
};
|
||||
|
||||
////// 移动独立的block canvas //////
|
||||
|
@ -18,6 +18,7 @@ import { uiStack } from './plugin/uiController';
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 600px) {
|
||||
|
@ -7,9 +7,9 @@
|
||||
>
|
||||
<div class="info">
|
||||
<div class="leftbar">
|
||||
<span class="name">{{ enemy.name }}</span>
|
||||
<span class="name">{{ enemy.enemy.enemy.name }}</span>
|
||||
<BoxAnimate
|
||||
:id="enemy.id"
|
||||
:id="enemy.enemy.id"
|
||||
:width="isMobile ? 32 : w"
|
||||
:height="isMobile ? 32 : w"
|
||||
style="margin: 5%"
|
||||
@ -19,9 +19,9 @@
|
||||
v-if="has(enemy.special) && enemy.special.length > 0"
|
||||
>
|
||||
<span
|
||||
v-for="(text, i) in enemy.toShowSpecial"
|
||||
:style="{ color: enemy.toShowColor![i] as string }"
|
||||
> {{ text }} </span
|
||||
v-for="(text, i) in enemy.showSpecial"
|
||||
:style="{ color: text[2] }"
|
||||
> {{ text[0] }} </span
|
||||
>
|
||||
</div>
|
||||
<div class="special-text" v-else>无属性</div>
|
||||
@ -36,42 +36,42 @@
|
||||
<div class="detail-info">
|
||||
<span style="color: lightgreen"
|
||||
>生命 {{
|
||||
core.formatBigNumber(enemy.hp)
|
||||
core.formatBigNumber(enemy.enemy.info.hp)
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
<div class="detail-info">
|
||||
<span style="color: lightcoral"
|
||||
>攻击 {{
|
||||
core.formatBigNumber(enemy.atk)
|
||||
core.formatBigNumber(enemy.enemy.info.atk)
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
<div class="detail-info">
|
||||
<span style="color: lightblue"
|
||||
>防御 {{
|
||||
core.formatBigNumber(enemy.def)
|
||||
core.formatBigNumber(enemy.enemy.info.def)
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
<div class="detail-info">
|
||||
<span style="color: lightyellow"
|
||||
>金币 {{
|
||||
core.formatBigNumber(enemy.money)
|
||||
core.formatBigNumber(enemy.enemy.enemy.money)
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
<div class="detail-info">
|
||||
<span style="color: lawngreen"
|
||||
>经验 {{
|
||||
core.formatBigNumber(enemy.exp)
|
||||
core.formatBigNumber(enemy.enemy.enemy.exp)
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
<div class="detail-info">
|
||||
<span :style="{color: enemy.damageColor! as string}"
|
||||
<span :style="{ color: enemy.damageColor }"
|
||||
>伤害 {{
|
||||
core.formatBigNumber(enemy.damage!)
|
||||
enemy.damage
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
@ -79,7 +79,7 @@
|
||||
<div class="detail-info">
|
||||
<span style="color: lightsalmon"
|
||||
>临界 {{
|
||||
core.formatBigNumber(enemy.critical)
|
||||
enemy.critical
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
@ -87,27 +87,9 @@
|
||||
<span style="color: lightpink"
|
||||
>减伤 <span
|
||||
:style="{
|
||||
color:
|
||||
enemy.criticalDamage < 0 &&
|
||||
!has(enemy.damage)
|
||||
? 'gold'
|
||||
: 'lightpink'
|
||||
color: 'lightpink'
|
||||
}"
|
||||
><span style="font-family: 'Fira Code'">{{
|
||||
enemy.criticalDamage < 0 &&
|
||||
!has(enemy.damage)
|
||||
? isMobile
|
||||
? '-'
|
||||
: '=>'
|
||||
: ''
|
||||
}}</span
|
||||
>{{
|
||||
core.formatBigNumber(
|
||||
enemy.criticalDamage < 0
|
||||
? -enemy.criticalDamage
|
||||
: enemy.criticalDamage
|
||||
)
|
||||
}}</span
|
||||
>{{ enemy.criticalDam }}</span
|
||||
></span
|
||||
>
|
||||
</div>
|
||||
@ -116,7 +98,7 @@
|
||||
>{{
|
||||
core.formatBigNumber(core.status.thisMap.ratio)
|
||||
}}防 {{
|
||||
core.formatBigNumber(enemy.defDamage)
|
||||
core.formatBigNumber(enemy.defDam)
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
@ -130,9 +112,10 @@
|
||||
import { has } from '../plugin/utils';
|
||||
import BoxAnimate from '../components/boxAnimate.vue';
|
||||
import { isMobile } from '../plugin/use';
|
||||
import { ToShowEnemy } from '../plugin/ui/book';
|
||||
|
||||
const props = defineProps<{
|
||||
enemy: DetailedEnemy;
|
||||
enemy: ToShowEnemy;
|
||||
selected?: boolean;
|
||||
}>();
|
||||
|
||||
|
@ -88,14 +88,12 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { getCriticalDamage, getDefDamage } from '../plugin/ui/book';
|
||||
import { detailInfo, getCriticalDamage, getDefDamage } from '../plugin/ui/book';
|
||||
import Chart, { ChartConfiguration } from 'chart.js/auto';
|
||||
import { has, setCanvasSize } from '../plugin/utils';
|
||||
import { debounce } from 'lodash-es';
|
||||
import { isMobile } from '../plugin/use';
|
||||
|
||||
// todo: 删除 getDamageInfo
|
||||
|
||||
const props = defineProps<{
|
||||
fromBook?: boolean;
|
||||
}>();
|
||||
@ -103,7 +101,7 @@ const props = defineProps<{
|
||||
const critical = ref<HTMLCanvasElement>();
|
||||
const def = ref<HTMLCanvasElement>();
|
||||
|
||||
const enemy = core.plugin.bookDetailEnemy;
|
||||
const enemy = detailInfo.enemy!;
|
||||
const ceil = Math.ceil;
|
||||
|
||||
const x = ref(props.fromBook ? void 0 : flags.mouseLoc[0]);
|
||||
@ -115,8 +113,8 @@ y.value = has(y.value)
|
||||
? Math.round(y.value + core.bigmap.offsetY / 32)
|
||||
: void 0;
|
||||
|
||||
let originCri = getCriticalDamage(enemy, 0, 0, x.value, y.value);
|
||||
let originDef = getDefDamage(enemy, 0, 0, x.value, y.value);
|
||||
let originCri = getCriticalDamage(enemy, 0, 0);
|
||||
let originDef = getDefDamage(enemy, 0, 0);
|
||||
|
||||
// 当前数据
|
||||
const allCri = ref(originCri);
|
||||
@ -126,25 +124,24 @@ const allDef = ref(originDef);
|
||||
const addAtk = ref(0);
|
||||
const addDef = ref(0);
|
||||
|
||||
const originDamage = core.getDamageInfo(enemy.id, void 0, x.value, y.value);
|
||||
const originDamage = enemy.enemy.calEnemyDamage(core.status.hero, 'none')[0]
|
||||
.damage;
|
||||
|
||||
// 转发core上的内容至当前作用域
|
||||
const format = core.formatBigNumber;
|
||||
const ratio = core.status.thisMap.ratio;
|
||||
|
||||
const nowDamage = computed(() => {
|
||||
const dam = core.getDamageInfo(
|
||||
enemy.id,
|
||||
const dam = enemy.enemy.calEnemyDamage(
|
||||
{
|
||||
atk: core.getStatus('atk') + addAtk.value * ratio,
|
||||
def: core.getStatus('def') + addDef.value * ratio
|
||||
atk: core.status.hero.atk + addAtk.value * ratio,
|
||||
def: core.status.hero.def + addDef.value * ratio
|
||||
},
|
||||
x.value,
|
||||
y.value
|
||||
);
|
||||
if (!has(dam)) return ['???', '???'];
|
||||
if (!has(originDamage)) return [-dam.damage, dam.damage];
|
||||
return [originDamage.damage - dam.damage, dam.damage];
|
||||
'none'
|
||||
)[0].damage;
|
||||
if (!isFinite(dam)) return ['???', '???'];
|
||||
if (!isFinite(originDamage)) return [-dam, dam];
|
||||
return [originDamage - dam, dam];
|
||||
});
|
||||
|
||||
function generateChart(ele: HTMLCanvasElement, data: [number, number][]) {
|
||||
@ -199,16 +196,12 @@ const update = debounce((atk: Chart, def: Chart) => {
|
||||
allCri.value = getCriticalDamage(
|
||||
enemy,
|
||||
addAtk.value * ratio,
|
||||
addDef.value * ratio,
|
||||
x.value,
|
||||
y.value
|
||||
addDef.value * ratio
|
||||
);
|
||||
allDef.value = getDefDamage(
|
||||
enemy,
|
||||
addDef.value * ratio,
|
||||
addAtk.value * ratio,
|
||||
x.value,
|
||||
y.value
|
||||
addAtk.value * ratio
|
||||
);
|
||||
if (allCri.value.length > originCri.length) originCri = allCri.value;
|
||||
if (allDef.value.length > originDef.length) originDef = allDef.value;
|
||||
|
@ -18,14 +18,9 @@
|
||||
<span>加攻</span>
|
||||
<span>减伤</span>
|
||||
</div>
|
||||
<div v-for="[atk, dam] of criticals" class="critical">
|
||||
<span class="critical-atk">{{ format(atk) }}</span>
|
||||
<span
|
||||
><span style="font-family: 'Fira Code'">{{
|
||||
dam < 0 ? '=>' : ''
|
||||
}}</span
|
||||
>{{ dam < 0 ? `${format(-dam)}` : format(dam) }}</span
|
||||
>
|
||||
<div v-for="cri of criticals[0]" class="critical">
|
||||
<span class="critical-atk">{{ format(cri.atkDelta) }}</span>
|
||||
<span>{{ format(cri.delta) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -34,23 +29,17 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { isMobile } from '../plugin/use';
|
||||
import { getSpecialHint } from '../plugin/ui/book';
|
||||
import { has } from '../plugin/utils';
|
||||
import { detailInfo, getSpecialHint } from '../plugin/ui/book';
|
||||
|
||||
const props = defineProps<{
|
||||
fromBook?: boolean;
|
||||
}>();
|
||||
|
||||
const [x, y] = props.fromBook ? [void 0, void 0] : flags.mouseLoc;
|
||||
const mx = has(x) ? Math.round(x + core.bigmap.offsetX / 32) : void 0;
|
||||
const my = has(y) ? Math.round(y + core.bigmap.offsetY / 32) : void 0;
|
||||
|
||||
const enemy = core.plugin.bookDetailEnemy;
|
||||
const enemy = detailInfo.enemy!;
|
||||
|
||||
const info = getSpecialHint(enemy);
|
||||
|
||||
// todo: 不使用 nextCriticals
|
||||
const criticals = core.nextCriticals(enemy, isMobile ? 4 : 8, mx, my);
|
||||
const criticals = enemy.enemy.calCritical(isMobile ? 4 : 8, 'none');
|
||||
|
||||
const format = core.formatBigNumber;
|
||||
</script>
|
||||
|
@ -3,7 +3,11 @@
|
||||
<div id="enemy-desc">
|
||||
<span>怪物描述</span>
|
||||
<Scroll id="enemy-desc-scroll">
|
||||
<span> {{ enemy.description }}</span>
|
||||
<span
|
||||
> {{
|
||||
enemy.enemy.enemy.description
|
||||
}}</span
|
||||
>
|
||||
</Scroll>
|
||||
</div>
|
||||
<a-divider dashed style="border-color: #ddd4"></a-divider>
|
||||
@ -26,14 +30,15 @@
|
||||
import { ref } from 'vue';
|
||||
import Scroll from '../components/scroll.vue';
|
||||
import { hasMarkedEnemy, markEnemy, unmarkEnemy } from '../plugin/mark';
|
||||
import { detailInfo } from '../plugin/ui/book';
|
||||
|
||||
const enemy = core.plugin.bookDetailEnemy;
|
||||
const marked = ref(hasMarkedEnemy(enemy.id));
|
||||
const enemy = detailInfo.enemy!;
|
||||
const marked = ref(hasMarkedEnemy(enemy.enemy.id));
|
||||
|
||||
function mark() {
|
||||
if (marked.value) unmarkEnemy(enemy.id);
|
||||
if (!marked.value) markEnemy(enemy.id);
|
||||
marked.value = hasMarkedEnemy(enemy.id);
|
||||
if (marked.value) unmarkEnemy(enemy.enemy.id);
|
||||
if (!marked.value) markEnemy(enemy.enemy.id);
|
||||
marked.value = hasMarkedEnemy(enemy.enemy.id);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -1,11 +1,17 @@
|
||||
import {
|
||||
DamageDir,
|
||||
DamageEnemy,
|
||||
ensureFloorDamage,
|
||||
getNeedCalDir,
|
||||
getSingleEnemy
|
||||
} from './damage';
|
||||
import { findDir, has } from '../utils';
|
||||
|
||||
export interface CurrentEnemy {
|
||||
enemy: DamageEnemy;
|
||||
onMapEnemy: DamageEnemy[];
|
||||
}
|
||||
|
||||
export function getEnemy(
|
||||
x: number,
|
||||
y: number,
|
||||
@ -228,13 +234,39 @@ core.events._action_battle = function (data, x, y, prefix) {
|
||||
}
|
||||
};
|
||||
|
||||
core.enemys.getCurrentEnemys = function (floorId = core.status.floorId) {
|
||||
floorId = floorId || core.status.floorId;
|
||||
const enemys: CurrentEnemy[] = [];
|
||||
const used: Record<string, DamageEnemy[]> = {};
|
||||
ensureFloorDamage(floorId);
|
||||
const floor = core.status.maps[floorId];
|
||||
floor.enemy.list.forEach(v => {
|
||||
if (!(v.id in used)) {
|
||||
const e = new DamageEnemy(v.enemy);
|
||||
e.calAttribute();
|
||||
e.getRealInfo();
|
||||
e.calDamage();
|
||||
const curr: CurrentEnemy = {
|
||||
enemy: e,
|
||||
onMapEnemy: [v]
|
||||
};
|
||||
enemys.push(curr);
|
||||
used[v.id] = curr.onMapEnemy;
|
||||
} else {
|
||||
used[v.id].push(v);
|
||||
}
|
||||
});
|
||||
|
||||
return enemys.sort((a, b) => {
|
||||
return (
|
||||
(a.enemy.damage?.[0]?.damage ?? Infinity) -
|
||||
(b.enemy.damage?.[0]?.damage ?? Infinity)
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
declare global {
|
||||
interface Events {
|
||||
/**
|
||||
* 与怪物战斗前
|
||||
* @param x 怪物横坐标
|
||||
* @param y 怪物纵坐标
|
||||
*/
|
||||
beforeBattle(
|
||||
enemy: DamageEnemy,
|
||||
x: number,
|
||||
@ -242,9 +274,6 @@ declare global {
|
||||
dir: DamageDir
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* 与怪物战斗后
|
||||
*/
|
||||
afterBattle(
|
||||
enemy: DamageEnemy,
|
||||
x: number,
|
||||
@ -252,4 +281,8 @@ declare global {
|
||||
dir: DamageDir
|
||||
): void;
|
||||
}
|
||||
|
||||
interface Enemys {
|
||||
getCurrentEnemys(floorId?: FloorIds): CurrentEnemy[];
|
||||
}
|
||||
}
|
||||
|
@ -417,7 +417,7 @@ export class DamageEnemy<T extends EnemyIds = EnemyIds> {
|
||||
* 计算怪物在不计光环下的属性,在inject光环之前,预平衡光环之后执行
|
||||
*/
|
||||
calAttribute() {
|
||||
if (this.progress !== 1) return;
|
||||
if (this.progress !== 1 && has(this.x) && has(this.floorId)) return;
|
||||
this.progress = 2;
|
||||
const special = this.info.special;
|
||||
const info = this.info;
|
||||
@ -448,7 +448,7 @@ export class DamageEnemy<T extends EnemyIds = EnemyIds> {
|
||||
* 获取怪物的真实属性信息,在inject光环后执行
|
||||
*/
|
||||
getRealInfo() {
|
||||
if (this.progress < 3) {
|
||||
if (this.progress < 3 && has(this.x) && has(this.floorId)) {
|
||||
throw new Error(
|
||||
`Unexpected early real info calculating. Progress: ${this.progress}`
|
||||
);
|
||||
@ -804,6 +804,7 @@ export class DamageEnemy<T extends EnemyIds = EnemyIds> {
|
||||
x?: number,
|
||||
y?: number
|
||||
): CriticalDamageDelta[] {
|
||||
// todo: 可以优化,根据之前的计算可以直接确定下一个临界的范围
|
||||
if (!isFinite(seckill)) return [];
|
||||
const res: CriticalDamageDelta[] = [];
|
||||
const def = hero.def!;
|
||||
|
@ -2,8 +2,6 @@ import { getEnemy } from '../enemy/battle';
|
||||
import { DamageDir, getNeedCalDir } from '../enemy/damage';
|
||||
import { formatDamage } from '../utils';
|
||||
|
||||
export {};
|
||||
|
||||
core.maps._initDetachedBlock = function (
|
||||
info: BlockInfo,
|
||||
x: number,
|
||||
|
@ -1,39 +1,40 @@
|
||||
import { CurrentEnemy } from '../game/enemy/battle';
|
||||
import { has } from '../utils';
|
||||
|
||||
export interface ToShowEnemy extends CurrentEnemy {
|
||||
critical: string;
|
||||
criticalDam: string;
|
||||
defDam: string;
|
||||
/** [名称, 描述, 颜色] */
|
||||
special: [string, string, string][];
|
||||
damageColor: string;
|
||||
showSpecial: [string, string, string][];
|
||||
damage: string;
|
||||
}
|
||||
|
||||
interface BookDetailInfo {
|
||||
/** 怪物手册详细信息展示的怪物 */
|
||||
enemy?: ToShowEnemy;
|
||||
/** 怪物手册的怪物详细信息的初始位置 */
|
||||
pos?: number;
|
||||
}
|
||||
|
||||
export const detailInfo: BookDetailInfo = {};
|
||||
|
||||
/**
|
||||
* 获取怪物的特殊技能描述
|
||||
* @param enemy 怪物实例
|
||||
*/
|
||||
export function getSpecialHint(enemy: Enemy & DetailedEnemy) {
|
||||
const all = core
|
||||
.getSpecials()
|
||||
.filter(v => enemy.special.includes(v[0]))
|
||||
.sort((a, b) => a[0] - b[0]);
|
||||
|
||||
const des = all.map(v => {
|
||||
const des = v[2];
|
||||
if (des instanceof Function) {
|
||||
return des(enemy);
|
||||
}
|
||||
return des;
|
||||
});
|
||||
const name = all.map(v => {
|
||||
const name = v[1];
|
||||
if (name instanceof Function) {
|
||||
return name(enemy);
|
||||
}
|
||||
return name;
|
||||
});
|
||||
|
||||
export function getSpecialHint(enemy: ToShowEnemy) {
|
||||
return (
|
||||
<div>
|
||||
{all.map((v, i) => {
|
||||
{enemy.showSpecial.map((v, i) => {
|
||||
return (
|
||||
<div class="special">
|
||||
<span style={{ color: core.arrayToRGBA(v[3]) }}>
|
||||
{name[i]}:
|
||||
<span style={{ color: v[2] }}>
|
||||
{v[0]}:
|
||||
</span>
|
||||
<span innerHTML={des[i]}></span>
|
||||
<span innerHTML={v[1]}></span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
@ -46,12 +47,9 @@ export function getSpecialHint(enemy: Enemy & DetailedEnemy) {
|
||||
* @param enemy 怪物实例
|
||||
*/
|
||||
export function getDefDamage(
|
||||
enemy: DetailedEnemy,
|
||||
enemy: ToShowEnemy,
|
||||
addDef: number = 0,
|
||||
addAtk: number = 0,
|
||||
x?: number,
|
||||
y?: number,
|
||||
floorId?: FloorIds
|
||||
addAtk: number = 0
|
||||
) {
|
||||
// todo: 删除 getDamageInfo
|
||||
const ratio = core.status.thisMap.ratio;
|
||||
@ -63,29 +61,26 @@ export function getDefDamage(
|
||||
const max = 100 - Math.floor(addDef / ratio);
|
||||
|
||||
for (let i = 0; i <= max; i++) {
|
||||
const dam = core.getDamageInfo(
|
||||
enemy.id,
|
||||
const dam = enemy.enemy.calEnemyDamage(
|
||||
{
|
||||
def: core.getStatus('def') + ratio * i + addDef,
|
||||
atk: core.getStatus('atk') + addAtk
|
||||
atk: core.status.hero.atk + addAtk,
|
||||
def: core.status.hero.def + addDef + i * ratio
|
||||
},
|
||||
x,
|
||||
y,
|
||||
floorId
|
||||
'none'
|
||||
);
|
||||
|
||||
if (res.length === 0) {
|
||||
origin = dam?.damage;
|
||||
origin = dam[0].damage;
|
||||
if (has(origin)) {
|
||||
res.push([addDef + i * ratio, origin]);
|
||||
last = origin;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!has(dam)) continue;
|
||||
if (dam.damage === res.at(-1)?.[1]) continue;
|
||||
last = dam.damage;
|
||||
res.push([ratio * i + addDef, dam.damage]);
|
||||
if (!isFinite(dam[0].damage)) continue;
|
||||
if (dam[0].damage === res.at(-1)?.[1]) continue;
|
||||
last = dam[0].damage;
|
||||
res.push([ratio * i + addDef, dam[0].damage]);
|
||||
}
|
||||
|
||||
return res;
|
||||
@ -96,12 +91,9 @@ export function getDefDamage(
|
||||
* @param enemy 怪物实例
|
||||
*/
|
||||
export function getCriticalDamage(
|
||||
enemy: DetailedEnemy,
|
||||
enemy: ToShowEnemy,
|
||||
addAtk: number = 0,
|
||||
addDef: number = 0,
|
||||
x?: number,
|
||||
y?: number,
|
||||
floorId?: FloorIds
|
||||
addDef: number = 0
|
||||
): [number, number][] {
|
||||
// todo: 删除 getDamageInfo
|
||||
const ratio = core.status.thisMap.ratio;
|
||||
@ -113,29 +105,26 @@ export function getCriticalDamage(
|
||||
const max = 100 - Math.floor(addAtk / ratio);
|
||||
|
||||
for (let i = 0; i <= max; i++) {
|
||||
const dam = core.getDamageInfo(
|
||||
enemy.id,
|
||||
const dam = enemy.enemy.calEnemyDamage(
|
||||
{
|
||||
atk: core.getStatus('atk') + ratio * i + addAtk,
|
||||
def: core.getStatus('def') + addDef
|
||||
atk: core.status.hero.atk + addAtk + i * ratio,
|
||||
def: core.status.hero.def + addDef
|
||||
},
|
||||
x,
|
||||
y,
|
||||
floorId
|
||||
'none'
|
||||
);
|
||||
|
||||
if (res.length === 0) {
|
||||
origin = dam?.damage;
|
||||
origin = dam[0].damage;
|
||||
if (has(origin)) {
|
||||
res.push([addAtk + i * ratio, origin]);
|
||||
last = origin;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!has(dam)) continue;
|
||||
if (dam.damage === res.at(-1)?.[1]) continue;
|
||||
last = dam.damage;
|
||||
res.push([ratio * i + addAtk, dam.damage]);
|
||||
if (!isFinite(dam[0].damage)) continue;
|
||||
if (dam[0].damage === res.at(-1)?.[1]) continue;
|
||||
last = dam[0].damage;
|
||||
res.push([ratio * i + addAtk, dam[0].damage]);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
8
src/types/enemy.d.ts
vendored
8
src/types/enemy.d.ts
vendored
@ -390,14 +390,6 @@ interface Enemys extends EnemyData {
|
||||
floorId?: FloorIds
|
||||
): number;
|
||||
|
||||
/**
|
||||
* 获得某张地图的敌人集合,用于手册绘制
|
||||
* @example core.getCurrentEnemys('MT0') // 主塔0层的敌人集合
|
||||
* @param floorId 地图id
|
||||
* @returns 敌人集合,按伤害升序排列,支持多朝向怪合并
|
||||
*/
|
||||
getCurrentEnemys(floorId?: FloorIds): DetailedEnemy[];
|
||||
|
||||
/**
|
||||
* 检查某些楼层是否还有漏打的(某种)敌人
|
||||
* @example core.hasEnemyLeft('greenSlime', ['sample0', 'sample1']) // 样板0层和1层是否有漏打的绿头怪
|
||||
|
6
src/types/plugin.d.ts
vendored
6
src/types/plugin.d.ts
vendored
@ -168,12 +168,6 @@ interface PluginUtils {
|
||||
}
|
||||
|
||||
interface PluginUis {
|
||||
/** 怪物手册的怪物详细信息的初始位置 */
|
||||
bookDetailPos: number;
|
||||
|
||||
/** 怪物手册详细信息展示的怪物 */
|
||||
bookDetailEnemy: DetailedEnemy;
|
||||
|
||||
/** 定点查看的界面,特殊属性还是临界 */
|
||||
fixedDetailPanel: 'special' | 'critical';
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
v-model:now="scroll"
|
||||
v-model:drag="drag"
|
||||
>
|
||||
<div v-for="(e, i) of enemy" class="enemy">
|
||||
<div v-for="(e, i) of toShow" class="enemy">
|
||||
<EnemyOne
|
||||
:selected="i === selected"
|
||||
:enemy="e"
|
||||
@ -38,7 +38,6 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import { sleep } from 'mutate-animate';
|
||||
import { onMounted, onUnmounted, ref } from 'vue';
|
||||
import EnemyOne from '../components/enemyOne.vue';
|
||||
@ -48,46 +47,87 @@ 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';
|
||||
|
||||
// todo: 不使用 core.status.checkBlock
|
||||
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];
|
||||
const critical = core.formatBigNumber(cri[0]?.atkDelta);
|
||||
const criticalDam = core.formatBigNumber(-cri[0]?.delta);
|
||||
const ratio = core.status.maps[floorId].ratio;
|
||||
const defDam = core.formatBigNumber(
|
||||
-v.enemy.calDefDamage(ratio, 'none')[0]?.delta
|
||||
);
|
||||
const damage = core.formatBigNumber(
|
||||
v.enemy.damage?.[0]?.damage ?? Infinity
|
||||
);
|
||||
|
||||
const fromFunc = (
|
||||
func: string | ((enemy: Enemy) => string),
|
||||
enemy: Enemy
|
||||
) => {
|
||||
return typeof func === 'string' ? func : func(enemy);
|
||||
};
|
||||
const special: [string, string, string][] = v.enemy.enemy.special.map(
|
||||
vv => {
|
||||
const s = specials[vv];
|
||||
return [
|
||||
fromFunc(s[0], v.enemy.enemy),
|
||||
fromFunc(s[1], v.enemy.enemy),
|
||||
s[2] as string
|
||||
];
|
||||
}
|
||||
);
|
||||
const showSpecial =
|
||||
special.length > 2
|
||||
? special.slice(0, 2).concat(['...', '', '#fff'])
|
||||
: special.slice();
|
||||
|
||||
const damageColor = getDamageColor(
|
||||
v.enemy.damage?.[0]?.damage ?? Infinity
|
||||
) as string;
|
||||
|
||||
return {
|
||||
critical,
|
||||
criticalDam,
|
||||
defDam,
|
||||
special,
|
||||
damageColor,
|
||||
showSpecial,
|
||||
damage,
|
||||
...v
|
||||
};
|
||||
});
|
||||
|
||||
const scroll = ref(0);
|
||||
const drag = ref(false);
|
||||
const detail = ref(false);
|
||||
const selected = ref(0);
|
||||
|
||||
// 解析
|
||||
enemy.forEach(v => {
|
||||
const l = v.specialText.length;
|
||||
v.toShowSpecial = cloneDeep(v.specialText);
|
||||
v.toShowColor = cloneDeep(v.specialColor);
|
||||
if (l >= 3) {
|
||||
v.toShowSpecial = v.specialText.slice(0, 2).concat(['...']);
|
||||
v.toShowColor = v.specialColor.slice(0, 2).concat(['#fff']);
|
||||
}
|
||||
v.toShowColor = v.toShowColor.map(v => {
|
||||
if (typeof v === 'string') return v;
|
||||
else return core.arrayToRGBA(v);
|
||||
});
|
||||
v.damageColor = getDamageColor(v.damage!);
|
||||
});
|
||||
|
||||
/**
|
||||
* 选择怪物,展示详细信息
|
||||
* @param enemy 选择的怪物
|
||||
* @param index 选择的怪物索引
|
||||
*/
|
||||
function select(enemy: Enemy & DetailedEnemy, index: number) {
|
||||
function select(enemy: ToShowEnemy, index: number) {
|
||||
if (drag.value) return;
|
||||
const h = window.innerHeight;
|
||||
const y = index * h * 0.2 - scroll.value;
|
||||
core.plugin.bookDetailEnemy = enemy;
|
||||
core.plugin.bookDetailPos = y;
|
||||
detailInfo.enemy = enemy;
|
||||
detailInfo.pos = y;
|
||||
detail.value = true;
|
||||
hide();
|
||||
}
|
||||
@ -161,7 +201,7 @@ function keyup(e: KeyboardEvent) {
|
||||
(c === KeyCode.Enter || c === KeyCode.KeyC || c === KeyCode.Space) &&
|
||||
!detail.value
|
||||
) {
|
||||
select(enemy[selected.value], selected.value);
|
||||
select(toShow[selected.value], selected.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
<template>
|
||||
<div id="detail">
|
||||
<div id="info" :style="{ top: `${top}px` }">
|
||||
<EnemyOne :enemy="enemy"></EnemyOne>
|
||||
<EnemyOne :enemy="enemy!"></EnemyOne>
|
||||
<a-divider
|
||||
dashed
|
||||
style="margin: 2vh 0 2vh 0; border-color: #ddd4; width: 100%"
|
||||
@ -80,14 +80,15 @@ import { KeyCode } from '../plugin/keyCodes';
|
||||
import { keycode } from '../plugin/utils';
|
||||
import { sleep } from 'mutate-animate';
|
||||
import EnemyTarget from '../panel/enemyTarget.vue';
|
||||
import { detailInfo } from '../plugin/ui/book';
|
||||
|
||||
const props = defineProps<{
|
||||
fromBook?: boolean;
|
||||
defaultPanel?: 'special' | 'critical' | 'target';
|
||||
}>();
|
||||
|
||||
const enemy = core.plugin.bookDetailEnemy;
|
||||
const top = ref(core.plugin.bookDetailPos);
|
||||
const enemy = detailInfo.enemy;
|
||||
const top = ref(detailInfo.pos);
|
||||
const panel = ref<string>(props.defaultPanel ?? 'special');
|
||||
|
||||
let detail: HTMLDivElement;
|
||||
@ -102,7 +103,7 @@ function changePanel(e: MouseEvent, to: string) {
|
||||
}
|
||||
|
||||
function close() {
|
||||
top.value = core.plugin.bookDetailPos;
|
||||
top.value = detailInfo.pos;
|
||||
detail.style.opacity = '0';
|
||||
emits('close');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user