包装提示信息

This commit is contained in:
unanmed 2022-12-29 12:02:48 +08:00
parent 5afd1c399f
commit db5ff1b183
3 changed files with 22 additions and 34 deletions

View File

@ -1,5 +1,5 @@
import { reactive, ref } from 'vue';
import { message } from 'ant-design-vue';
import { tip } from './utils';
const markedEnemy = reactive<EnemyIds[]>([]);
@ -61,10 +61,7 @@ export function getMarkInfo(id: EnemyIds, noMessage: boolean = false) {
const info = markInfo[id]!;
if (core.status.hero.atk >= info.nextCritical) {
if (!reached[info.nextCritical] && !noMessage) {
message.success({
content: `踩到了${core.material.enemys[id].name}的临界!`,
class: 'antdv-message'
});
tip('success', `踩到了${core.material.enemys[id].name}的临界!`);
}
reached[info.nextCritical] = true;
const n = core.nextCriticals(id, 1)[0]?.[0];
@ -85,39 +82,25 @@ export function checkMarkedEnemy(noMessage: boolean = false) {
if (damage === -1) return;
const info = enemyDamageInfo[v]!;
const name = core.material.enemys[v].name;
if (damage < 0) {
if (!noMessage) {
message.success({
content: `${name}已经负伤了!`,
class: 'antdv-message'
});
}
if (damage <= 0) {
if (!noMessage) tip('success', `${name}已经零伤了!`);
} else if (damage < hp / 3) {
if (!info[3] && !noMessage) {
message.success({
content: `${name}的伤害已降至勇士生命值的1/3`,
class: 'antdv-message'
});
tip('success', `${name}的伤害已降至勇士生命值的1/3`);
}
info[1] = true;
info[2] = true;
info[3] = true;
} else if (damage < (hp / 3) * 2) {
if (!info[2] && !noMessage) {
message.success({
content: `${name}的伤害已降至勇士生命值的2/3`,
class: 'antdv-message'
});
tip('success', `${name}的伤害已降至勇士生命值的2/3`);
}
info[1] = true;
info[2] = true;
info[3] = false;
} else if (damage < hp) {
if (!info[1] && !noMessage) {
message.success({
content: `你已经能打过${name}了!`,
class: 'antdv-message'
});
tip('success', `你已经能打过${name}了!`);
}
info[1] = true;
info[2] = false;

View File

@ -1,3 +1,5 @@
import { message } from 'ant-design-vue';
import { MessageApi } from 'ant-design-vue/lib/message';
import { isNil } from 'lodash';
import { Animation, TimingFn } from 'mutate-animate';
import { ComputedRef, ref } from 'vue';
@ -121,3 +123,13 @@ export function type(
return content;
}
export function tip(
type: Exclude<keyof MessageApi, 'open' | 'config' | 'destroy'>,
text: string
) {
message[type]({
content: text,
class: 'antdv-message'
});
}

View File

@ -183,10 +183,9 @@ import { computed, onMounted, onUnmounted, reactive, ref, watch } from 'vue';
import Scroll from '../components/scroll.vue';
import { getAddStatus, getEquips, getNowStatus } from '../plugin/ui/equipbox';
import BoxAnimate from '../components/boxAnimate.vue';
import { has, type } from '../plugin/utils';
import { has, tip, type } from '../plugin/utils';
import { cancelGlobalDrag, isMobile, useDrag } from '../plugin/use';
import { hyper, sleep } from 'mutate-animate';
import { message } from 'ant-design-vue';
const equips = ref(getEquips());
const col = ref('all');
@ -310,10 +309,7 @@ function clickList(i: number) {
if (i === selected.value && listClicked.value) {
const id = toShow.value[selected.value]?.[0];
if (!core.canEquip(id)) {
message.warn({
content: '无法装备!',
class: 'antdv-message'
});
tip('warn', '无法装备!');
return;
}
core.loadEquip(id);
@ -359,10 +355,7 @@ function loadEquip() {
const num = toEquipType.value;
if (num < 0) return;
if (!canDragin(num)) {
message.warn({
content: '无法装备!',
class: 'antdv-message'
});
tip('warn', '无法装备!');
return;
}
const now = equiped.value[num];