mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 04:19:30 +08:00
修复一些问题
This commit is contained in:
parent
9771247b79
commit
6034d959e0
@ -1,2 +1,2 @@
|
||||
vite.config.ts
|
||||
public/project/*.js
|
||||
public/project/data.js
|
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,5 @@
|
||||
///<reference path="../../src/types/core.d.ts" />
|
||||
|
||||
var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
|
||||
events: {
|
||||
resetGame: function (hero, hard, floorId, maps, values) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -68,14 +68,15 @@ import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { getCriticalDamage, getDefDamage } from '../plugin/book';
|
||||
import Chart, { ChartConfiguration } from 'chart.js/auto';
|
||||
import { has, setCanvasSize } from '../plugin/utils';
|
||||
import { debounce } from 'lodash';
|
||||
|
||||
const critical = ref<HTMLCanvasElement>();
|
||||
const def = ref<HTMLCanvasElement>();
|
||||
|
||||
const enemy = core.plugin.bookDetailEnemy;
|
||||
|
||||
const originCri = getCriticalDamage(enemy);
|
||||
const originDef = getDefDamage(enemy);
|
||||
let originCri = getCriticalDamage(enemy);
|
||||
let originDef = getDefDamage(enemy);
|
||||
|
||||
// 当前数据
|
||||
const allCri = ref(originCri);
|
||||
@ -93,8 +94,8 @@ const ratio = core.status.thisMap.ratio;
|
||||
|
||||
const nowDamage = computed(() => {
|
||||
const dam = core.getDamageInfo(enemy, {
|
||||
atk: core.status.hero.atk + addAtk.value,
|
||||
def: core.status.hero.def + addDef.value
|
||||
atk: core.status.hero.atk + addAtk.value * ratio,
|
||||
def: core.status.hero.def + addDef.value * ratio
|
||||
});
|
||||
if (!has(dam)) return ['???', '???'];
|
||||
if (!has(originDamage)) return [-dam.damage, dam.damage];
|
||||
@ -104,11 +105,30 @@ const nowDamage = computed(() => {
|
||||
function generateChart(ele: HTMLCanvasElement, data: [number, number][]) {
|
||||
const config: ChartConfiguration = {
|
||||
type: 'line',
|
||||
data: generateData(data)
|
||||
data: generateData(data),
|
||||
options: {
|
||||
elements: {
|
||||
point: {
|
||||
radius: 5,
|
||||
hoverRadius: 7
|
||||
}
|
||||
},
|
||||
scales: {
|
||||
y: {
|
||||
grid: {
|
||||
color: '#ddd3'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
return new Chart(ele, config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成图表数据
|
||||
* @param data 数据
|
||||
*/
|
||||
function generateData(data: [number, number][]) {
|
||||
return {
|
||||
datasets: [
|
||||
@ -117,19 +137,29 @@ function generateData(data: [number, number][]) {
|
||||
data: data.map(v => v[1])
|
||||
}
|
||||
],
|
||||
labels: data.map(v => v[0])
|
||||
labels: data.map(v => Math.round(v[0] / ratio))
|
||||
};
|
||||
}
|
||||
|
||||
function update(atk: Chart, def: Chart) {
|
||||
allCri.value = getCriticalDamage(enemy, addAtk.value, addDef.value);
|
||||
allDef.value = getDefDamage(enemy, addDef.value, addAtk.value);
|
||||
const update = debounce((atk: Chart, def: Chart) => {
|
||||
allCri.value = getCriticalDamage(
|
||||
enemy,
|
||||
addAtk.value * ratio,
|
||||
addDef.value * ratio
|
||||
);
|
||||
allDef.value = getDefDamage(
|
||||
enemy,
|
||||
addDef.value * ratio,
|
||||
addAtk.value * ratio
|
||||
);
|
||||
if (allCri.value.length > originCri.length) originCri = allCri.value;
|
||||
if (allDef.value.length > originDef.length) originDef = allDef.value;
|
||||
|
||||
atk.data = generateData(allCri.value);
|
||||
def.data = generateData(allDef.value);
|
||||
atk.update('resize');
|
||||
def.update('resize');
|
||||
}
|
||||
}, 200);
|
||||
|
||||
onMounted(() => {
|
||||
const div = document.getElementById('critical-main') as HTMLDivElement;
|
||||
|
@ -56,7 +56,9 @@ export function getDefDamage(
|
||||
let origin: number | undefined;
|
||||
let last = 0;
|
||||
|
||||
for (let i = 0; i <= 100; i++) {
|
||||
const max = 100 - Math.floor(addDef / ratio);
|
||||
|
||||
for (let i = 0; i <= max; i++) {
|
||||
const dam = core.getDamageInfo(enemy, {
|
||||
def: core.status.hero.def + ratio * i + addDef,
|
||||
atk: core.status.hero.atk + addAtk
|
||||
@ -77,6 +79,11 @@ export function getDefDamage(
|
||||
last = dam.damage;
|
||||
res.push([ratio * i + addDef, dam.damage]);
|
||||
}
|
||||
|
||||
if ((res.at(-1)?.[1] ?? 1) <= 0) {
|
||||
res.push([res.at(-1)![0] + 1, 0]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -95,16 +102,18 @@ export function getCriticalDamage(
|
||||
let origin: number | undefined;
|
||||
let last = 0;
|
||||
|
||||
for (let i = 0; i <= 100; i++) {
|
||||
const max = 100 - Math.floor(addAtk / ratio);
|
||||
|
||||
for (let i = 0; i <= max; i++) {
|
||||
const dam = core.getDamageInfo(enemy, {
|
||||
atk: core.status.hero.atk + ratio * i + addAtk,
|
||||
def: core.status.hero.def + addDef
|
||||
});
|
||||
|
||||
if (i === 0) {
|
||||
if (res.length === 0) {
|
||||
origin = dam?.damage;
|
||||
if (has(origin)) {
|
||||
res.push([addAtk, origin]);
|
||||
res.push([addAtk + i * ratio, origin]);
|
||||
last = origin;
|
||||
}
|
||||
continue;
|
||||
@ -112,10 +121,14 @@ export function getCriticalDamage(
|
||||
if (!has(dam)) continue;
|
||||
if (dam.damage === origin) continue;
|
||||
if (dam.damage === res.at(-1)?.[1]) continue;
|
||||
if (dam.damage <= 0) break;
|
||||
if (last <= 0) break;
|
||||
last = dam.damage;
|
||||
res.push([ratio * i + addAtk, dam.damage]);
|
||||
}
|
||||
|
||||
if ((res.at(-1)?.[1] ?? 1) <= 0) {
|
||||
res.push([res.at(-1)![0] + 1, 0]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -21,9 +21,8 @@ export default function init() {
|
||||
showApp();
|
||||
} else {
|
||||
const index = uiStack.value.findIndex(v => v === com);
|
||||
uiStack.value.splice(index);
|
||||
if (uiStack.value.length === 0) {
|
||||
hideApp();
|
||||
if (uiStack.value.length === 1) {
|
||||
hideApp(index);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -38,9 +37,10 @@ async function showApp() {
|
||||
core.lockControl();
|
||||
}
|
||||
|
||||
async function hideApp() {
|
||||
async function hideApp(index: number) {
|
||||
app.style.opacity = '0';
|
||||
await sleep(600);
|
||||
uiStack.value.splice(index, 1);
|
||||
app.style.display = 'none';
|
||||
core.unlockControl();
|
||||
}
|
||||
|
13
src/types/core.d.ts
vendored
13
src/types/core.d.ts
vendored
@ -1,3 +1,16 @@
|
||||
/// <reference path="./action.d.ts" />
|
||||
/// <reference path="./control.d.ts" />
|
||||
/// <reference path="./enemy.d.ts" />
|
||||
/// <reference path="./event.d.ts" />
|
||||
/// <reference path="./icon.d.ts" />
|
||||
/// <reference path="./item.d.ts" />
|
||||
/// <reference path="./loader.d.ts" />
|
||||
/// <reference path="./map.d.ts" />
|
||||
/// <reference path="./plugin.d.ts" />
|
||||
/// <reference path="./status.d.ts" />
|
||||
/// <reference path="./ui.d.ts" />
|
||||
/// <reference path="./util.d.ts" />
|
||||
|
||||
type Core = {
|
||||
/** 地图的格子宽度 */
|
||||
readonly _WIDTH_: number;
|
||||
|
@ -1,12 +1,17 @@
|
||||
<!-- 怪物手册ui -->
|
||||
<template>
|
||||
<div id="book">
|
||||
<div id="tools">
|
||||
<span id="back" class="tools" @click="exit"
|
||||
><left-outlined />返回游戏</span
|
||||
>
|
||||
</div>
|
||||
<div v-if="enemy.length === 0" id="none">
|
||||
<div>本层无怪物</div>
|
||||
</div>
|
||||
<Scroll
|
||||
v-else
|
||||
style="width: 100%; height: 100%; font-family: normal"
|
||||
style="width: 100%; height: 95%; font-family: normal"
|
||||
v-model:now="scroll"
|
||||
v-model:drag="drag"
|
||||
>
|
||||
@ -30,6 +35,7 @@ import EnemyOne from '../components/enemyOne.vue';
|
||||
import Scroll from '../components/scroll.vue';
|
||||
import { getDamageColor } from '../plugin/utils';
|
||||
import BookDetail from './bookDetail.vue';
|
||||
import { LeftOutlined } from '@ant-design/icons-vue';
|
||||
|
||||
const floorId = core.floorIds[core.status.event?.ui] ?? core.status.floorId;
|
||||
const enemy = core.getCurrentEnemys(floorId);
|
||||
@ -89,10 +95,15 @@ async function closeDetail() {
|
||||
|
||||
async function show() {
|
||||
const div = document.getElementById('book') as HTMLDivElement;
|
||||
div.style.display = 'block';
|
||||
div.style.display = 'flex';
|
||||
await sleep(50);
|
||||
div.style.opacity = '1';
|
||||
}
|
||||
|
||||
function exit() {
|
||||
core.closePanel();
|
||||
core.plugin.bookOpened.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
@ -104,13 +115,30 @@ async function show() {
|
||||
font-family: 'normal';
|
||||
overflow: hidden;
|
||||
transition: opacity 0.6s linear;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 600px) {
|
||||
#book {
|
||||
width: 100%;
|
||||
padding: 5% 0 5% 5%;
|
||||
}
|
||||
#back {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
#tools {
|
||||
height: 5%;
|
||||
}
|
||||
|
||||
.tools {
|
||||
cursor: pointer;
|
||||
transition: color 0.2s linear;
|
||||
}
|
||||
|
||||
.tools:hover {
|
||||
color: aqua;
|
||||
}
|
||||
|
||||
.tools:active {
|
||||
color: aquamarine;
|
||||
}
|
||||
|
||||
#none {
|
||||
@ -130,4 +158,11 @@ async function show() {
|
||||
width: 100%;
|
||||
padding: 0 1% 0 1%;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 600px) {
|
||||
#book {
|
||||
width: 100%;
|
||||
padding: 5% 0 5% 5%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -19,9 +19,7 @@
|
||||
class="detial-more"
|
||||
v-if="panel === 'special'"
|
||||
>
|
||||
<span id="enemy-pos" class="more"
|
||||
><left-outlined /> 怪物分布情况</span
|
||||
>
|
||||
<span></span>
|
||||
<span
|
||||
id="critical-more"
|
||||
class="more"
|
||||
@ -75,12 +73,15 @@ onMounted(() => {
|
||||
const style = getComputedStyle(div);
|
||||
|
||||
let moved = false;
|
||||
let pos = [0, 0];
|
||||
|
||||
useDrag(
|
||||
div,
|
||||
() => {
|
||||
moved = true;
|
||||
(x, y) => {
|
||||
if ((x - pos[0]) ** 2 + (y - pos[1]) ** 2 >= 100) moved = true;
|
||||
},
|
||||
(x, y) => {
|
||||
pos = [x, y];
|
||||
if (y > (parseFloat(style.height) * 4) / 5) moved = true;
|
||||
},
|
||||
() => {
|
||||
|
Loading…
Reference in New Issue
Block a user