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