mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-03-13 10:27:06 +08:00
修复取消方向伤害造成的错误
This commit is contained in:
parent
b8711e2014
commit
7ce6acb664
@ -124,21 +124,17 @@ const allDef = ref(originDef);
|
||||
const addAtk = ref(0);
|
||||
const addDef = ref(0);
|
||||
|
||||
const originDamage = enemy.enemy.calEnemyDamage(core.status.hero, 'none')[0]
|
||||
.damage;
|
||||
const originDamage = enemy.enemy.calDamage(core.status.hero).damage;
|
||||
|
||||
// 转发core上的内容至当前作用域
|
||||
const format = core.formatBigNumber;
|
||||
const ratio = core.status.thisMap.ratio;
|
||||
|
||||
const nowDamage = computed(() => {
|
||||
const dam = enemy.enemy.calEnemyDamage(
|
||||
{
|
||||
atk: core.status.hero.atk + addAtk.value * ratio,
|
||||
def: core.status.hero.def + addDef.value * ratio
|
||||
},
|
||||
'none'
|
||||
)[0].damage;
|
||||
const dam = enemy.enemy.calDamage({
|
||||
atk: core.status.hero.atk + addAtk.value * ratio,
|
||||
def: core.status.hero.def + addDef.value * ratio
|
||||
}).damage;
|
||||
if (!isFinite(dam)) return ['???', '???'];
|
||||
if (!isFinite(originDamage)) return [-dam, dam];
|
||||
return [originDamage - dam, dam];
|
||||
|
@ -18,7 +18,7 @@
|
||||
<span>加攻</span>
|
||||
<span>减伤</span>
|
||||
</div>
|
||||
<div v-for="cri of criticals[0]" class="critical">
|
||||
<div v-for="cri of criticals" class="critical">
|
||||
<span class="critical-atk">{{ format(cri.atkDelta) }}</span>
|
||||
<span>{{ format(cri.delta) }}</span>
|
||||
</div>
|
||||
@ -39,7 +39,7 @@ const enemy = detailInfo.enemy!;
|
||||
|
||||
const info = getSpecialHint(enemy);
|
||||
|
||||
const criticals = enemy.enemy.calCritical(isMobile ? 4 : 8, 'none');
|
||||
const criticals = enemy.enemy.calCritical(isMobile ? 4 : 8);
|
||||
|
||||
const format = core.formatBigNumber;
|
||||
</script>
|
||||
|
@ -712,7 +712,7 @@ export class DamageEnemy<T extends EnemyIds = EnemyIds> {
|
||||
if (i++ >= 10000) {
|
||||
throw new Error(
|
||||
`Unexpected endless loop in calculating critical.` +
|
||||
`Enemy loc: ${this.x},${this.y}. Floor: ${this.floorId}`
|
||||
`Enemy Id: ${this.id}. Loc: ${this.x},${this.y}. Floor: ${this.floorId}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -60,26 +60,23 @@ export function getDefDamage(
|
||||
const max = 100 - Math.floor(addDef / ratio);
|
||||
|
||||
for (let i = 0; i <= max; i++) {
|
||||
const dam = enemy.enemy.calEnemyDamage(
|
||||
{
|
||||
atk: core.status.hero.atk + addAtk,
|
||||
def: core.status.hero.def + addDef + i * ratio
|
||||
},
|
||||
'none'
|
||||
);
|
||||
const dam = enemy.enemy.calDamage({
|
||||
atk: core.status.hero.atk + addAtk,
|
||||
def: core.status.hero.def + addDef + i * ratio
|
||||
});
|
||||
|
||||
if (res.length === 0) {
|
||||
origin = dam[0].damage;
|
||||
origin = dam.damage;
|
||||
if (has(origin)) {
|
||||
res.push([addDef + i * ratio, origin]);
|
||||
last = origin;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
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]);
|
||||
if (!isFinite(dam.damage)) continue;
|
||||
if (dam.damage === res.at(-1)?.[1]) continue;
|
||||
last = dam.damage;
|
||||
res.push([ratio * i + addDef, dam.damage]);
|
||||
}
|
||||
|
||||
return res;
|
||||
@ -103,26 +100,23 @@ export function getCriticalDamage(
|
||||
const max = 100 - Math.floor(addAtk / ratio);
|
||||
|
||||
for (let i = 0; i <= max; i++) {
|
||||
const dam = enemy.enemy.calEnemyDamage(
|
||||
{
|
||||
atk: core.status.hero.atk + addAtk + i * ratio,
|
||||
def: core.status.hero.def + addDef
|
||||
},
|
||||
'none'
|
||||
);
|
||||
const dam = enemy.enemy.calDamage({
|
||||
atk: core.status.hero.atk + addAtk + i * ratio,
|
||||
def: core.status.hero.def + addDef
|
||||
});
|
||||
|
||||
if (res.length === 0) {
|
||||
origin = dam[0].damage;
|
||||
origin = dam.damage;
|
||||
if (has(origin)) {
|
||||
res.push([addAtk + i * ratio, origin]);
|
||||
last = origin;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
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]);
|
||||
if (!isFinite(dam.damage)) continue;
|
||||
if (dam.damage === res.at(-1)?.[1]) continue;
|
||||
last = dam.damage;
|
||||
res.push([ratio * i + addAtk, dam.damage]);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -13,8 +13,9 @@ const show = debounce((ev: MouseEvent) => {
|
||||
if (!flags.mouseLoc) return;
|
||||
flags.clientLoc = [ev.clientX, ev.clientY];
|
||||
const [mx, my] = getLocFromMouseLoc(...flags.mouseLoc);
|
||||
|
||||
const e = core.status.thisMap.enemy.list.find(v => {
|
||||
v.x === mx && v.y === my;
|
||||
return v.x === mx && v.y === my;
|
||||
});
|
||||
|
||||
if (!e) return;
|
||||
@ -68,8 +69,8 @@ export function getDetailedEnemy(
|
||||
const dam = enemy.calDamage().damage;
|
||||
const cri = enemy.calCritical(1)[0];
|
||||
const critical = core.formatBigNumber(cri?.atkDelta);
|
||||
const criticalDam = core.formatBigNumber(cri?.delta);
|
||||
const defDam = core.formatBigNumber(enemy.calDefDamage(ratio).damage);
|
||||
const criticalDam = core.formatBigNumber(-cri?.delta);
|
||||
const defDam = core.formatBigNumber(-enemy.calDefDamage(ratio).delta);
|
||||
const damage = core.formatBigNumber(dam);
|
||||
|
||||
const fromFunc = (
|
||||
|
@ -64,16 +64,14 @@ const specials = Object.fromEntries(
|
||||
|
||||
const enemy = core.getCurrentEnemys(floorId);
|
||||
const toShow: ToShowEnemy[] = enemy.map(v => {
|
||||
const cri = v.enemy.calCritical(1, 'none')[0];
|
||||
const e = v.enemy;
|
||||
const dam = e.calDamage().damage;
|
||||
const cri = e.calCritical(1);
|
||||
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 defDam = core.formatBigNumber(-e.calDefDamage(ratio).delta);
|
||||
const damage = core.formatBigNumber(dam);
|
||||
|
||||
const fromFunc = (
|
||||
func: string | ((enemy: Enemy) => string),
|
||||
@ -96,9 +94,7 @@ const toShow: ToShowEnemy[] = enemy.map(v => {
|
||||
? special.slice(0, 2).concat(['...', '', '#fff'])
|
||||
: special.slice();
|
||||
|
||||
const damageColor = getDamageColor(
|
||||
v.enemy.damage?.[0]?.damage ?? Infinity
|
||||
) as string;
|
||||
const damageColor = getDamageColor(dam) as string;
|
||||
|
||||
return {
|
||||
critical,
|
||||
|
@ -9,25 +9,21 @@
|
||||
v-model:width="width"
|
||||
>
|
||||
<div id="enemy-fixed">
|
||||
<span id="enemy-name">{{ enemy.name }}</span>
|
||||
<span id="enemy-name">{{ enemy.enemy.enemy.name }}</span>
|
||||
<div id="enemy-special">
|
||||
<span
|
||||
v-for="(text, i) of enemy.toShowSpecial"
|
||||
:style="{color: (enemy.toShowColor[i] as string)} "
|
||||
>{{ text }}</span
|
||||
v-for="(text, i) of enemy.showSpecial"
|
||||
:style="{ color: text[2] }"
|
||||
>{{ text[0] }}</span
|
||||
>
|
||||
</div>
|
||||
<div class="enemy-attr" v-for="(a, i) of toShowAttrs">
|
||||
<span
|
||||
class="attr-name"
|
||||
:style="{ color: attrColor[i] }"
|
||||
>{{ getLabel(a) }}</span
|
||||
>
|
||||
<span
|
||||
class="attr-value"
|
||||
:style="{ color: attrColor[i] }"
|
||||
>{{ format(enemy[a] as number) }}</span
|
||||
>
|
||||
<span class="attr-name" :style="{ color: a[2] }">{{
|
||||
a[1]
|
||||
}}</span>
|
||||
<span class="attr-value" :style="{ color: a[2] }">{{
|
||||
format(a[0])
|
||||
}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</Box>
|
||||
@ -36,9 +32,10 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, onUpdated, ref, watch } from 'vue';
|
||||
import { ComputedRef, computed, onMounted, onUpdated, ref, watch } from 'vue';
|
||||
import Box from '../components/box.vue';
|
||||
import { showFixed } from '../plugin/ui/fixed';
|
||||
import { ToShowEnemy, detailInfo } from '../plugin/ui/book';
|
||||
|
||||
watch(showFixed, n => {
|
||||
if (n) calHeight();
|
||||
@ -47,29 +44,20 @@ watch(showFixed, n => {
|
||||
let main: HTMLDivElement;
|
||||
|
||||
const format = core.formatBigNumber;
|
||||
const enemy = ref(detailInfo.enemy!);
|
||||
|
||||
const toShowAttrs: (keyof DetailedEnemy)[] = [
|
||||
'hp',
|
||||
'atk',
|
||||
'def',
|
||||
'money',
|
||||
'exp',
|
||||
'critical',
|
||||
'criticalDamage',
|
||||
'defDamage'
|
||||
];
|
||||
const attrColor = [
|
||||
'lightgreen',
|
||||
'lightcoral',
|
||||
'lightblue',
|
||||
'lightyellow',
|
||||
'lawngreen',
|
||||
'lightsalmon',
|
||||
'lightpink',
|
||||
'cyan'
|
||||
];
|
||||
|
||||
const enemy = ref(core.plugin.bookDetailEnemy);
|
||||
const toShowAttrs: ComputedRef<[number | string, string, string][]> = computed(
|
||||
() => [
|
||||
[enemy.value.enemy.info.hp, '生命', 'lightgreen'],
|
||||
[enemy.value.enemy.info.atk, '攻击', 'lightcoral'],
|
||||
[enemy.value.enemy.info.def, '防御', 'lightblue'],
|
||||
[enemy.value.enemy.enemy.money, '金币', 'lightyellow'],
|
||||
[enemy.value.enemy.enemy.exp, '经验', 'lawgreen'],
|
||||
[enemy.value.critical, '临界', 'lightsalmon'],
|
||||
[enemy.value.criticalDam, '减伤', 'lightpink'],
|
||||
[enemy.value.defDam, `${core.status.thisMap?.ratio ?? 1}防`, 'cyan']
|
||||
]
|
||||
);
|
||||
|
||||
const left = ref(0);
|
||||
const top = ref(0);
|
||||
@ -79,7 +67,7 @@ let vh = window.innerHeight;
|
||||
let vw = window.innerWidth;
|
||||
|
||||
async function calHeight() {
|
||||
enemy.value = core.plugin.bookDetailEnemy;
|
||||
enemy.value = detailInfo.enemy!;
|
||||
vh = window.innerHeight;
|
||||
vw = window.innerWidth;
|
||||
width.value = vh * 0.28;
|
||||
@ -99,13 +87,6 @@ async function calHeight() {
|
||||
height.value = h;
|
||||
}
|
||||
|
||||
function getLabel(attr: keyof DetailedEnemy) {
|
||||
if (attr === 'critical') return '临界';
|
||||
if (attr === 'criticalDamage') return '临界减伤';
|
||||
if (attr === 'defDamage') return `${core.status?.thisMap?.ratio ?? 1}防`;
|
||||
return core.getStatusLabel(attr);
|
||||
}
|
||||
|
||||
function updateMain() {
|
||||
main = document.getElementById('enemy-fixed') as HTMLDivElement;
|
||||
if (main) {
|
||||
|
@ -9,22 +9,22 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { getDetailedEnemy } from '../plugin/ui/fixed';
|
||||
import { getDetailedEnemy, getLocFromMouseLoc } from '../plugin/ui/fixed';
|
||||
import BookDetail from './bookDetail.vue';
|
||||
import { detailInfo } from '../plugin/ui/book';
|
||||
|
||||
const panel = core.plugin.fixedDetailPanel ?? 'special';
|
||||
|
||||
core.plugin.bookDetailPos = 0;
|
||||
detailInfo.pos = 0;
|
||||
|
||||
const [x, y] = flags.mouseLoc;
|
||||
const mx = Math.round(x + core.bigmap.offsetX / 32);
|
||||
const my = Math.round(y + core.bigmap.offsetY / 32);
|
||||
const e = core.getBlockId(mx, my);
|
||||
if (e && core.getClsFromId(e)?.startsWith('enemy')) {
|
||||
const enemy = core.material.enemys[e as EnemyIds];
|
||||
const detail = getDetailedEnemy(enemy, mx, my);
|
||||
core.plugin.bookDetailEnemy = detail;
|
||||
const [mx, my] = getLocFromMouseLoc(x, y);
|
||||
const enemy = core.status.thisMap.enemy.list.find(v => {
|
||||
return v.x === mx && v.y === my;
|
||||
});
|
||||
if (enemy) {
|
||||
const detail = getDetailedEnemy(enemy);
|
||||
detailInfo.enemy = detail;
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user