🏷️ 采用枚举类

This commit is contained in:
BTMuli
2026-03-25 18:31:51 +08:00
parent 47029ce802
commit 789b388a6f
4 changed files with 59 additions and 14 deletions

View File

@@ -30,6 +30,7 @@
<script lang="ts" setup>
import TItembox, { type TItemBoxData } from "@comp/app/t-itemBox.vue";
import TMiImg from "@comp/app/t-mi-img.vue";
import gameEnum from "@enum/game.js";
import { getRcStar, getWikiBrief, getZhElement } from "@utils/toolFunc.js";
type TucAeBoxProps = {
@@ -43,7 +44,7 @@ const props = defineProps<TucAeBoxProps>();
function getAvatarBox(item: TGApp.Game.Combat.Avatar): TItemBoxData {
const findAvatar = getWikiBrief(item.avatar_id);
let innerText = item.avatar_type === 2 ? "试用角色" : item.avatar_type === 3 ? "助演角色" : "";
let innerText = gameEnum.combat.avatarTypeDesc(item.avatar_type);
let findWeapon;
if (findAvatar) {
findWeapon = findAvatar.weapon;

View File

@@ -6,6 +6,7 @@
</template>
<script lang="ts" setup>
import TItemBox, { type TItemBoxData } from "@comp/app/t-itemBox.vue";
import gameEnum from "@enum/game.js";
import { getRcStar, getWikiBrief, getZhElement } from "@utils/toolFunc.js";
type TucAvatarsProps = { modelValue: Array<TGApp.Game.Combat.Avatar>; detail: boolean };
@@ -14,7 +15,7 @@ const props = defineProps<TucAvatarsProps>();
function getItemBox(item: TGApp.Game.Combat.Avatar): TItemBoxData {
const findAvatar = getWikiBrief(item.avatar_id);
let innerText = item.avatar_type === 2 ? "试用角色" : item.avatar_type === 3 ? "助演角色" : "";
let innerText = gameEnum.combat.avatarTypeDesc(item.avatar_type);
let findWeapon;
if (findAvatar) {
findWeapon = findAvatar.weapon;

View File

@@ -1,6 +1,6 @@
/**
* 游戏相关枚举
* @since Beta v0.9.6
* @since Beta v0.9.9
*/
/**
@@ -136,6 +136,34 @@ function getGameAnnoLangDesc(lang: TGApp.Game.Anno.AnnoLangEnum): string {
}
}
/**
* 剧诗角色类型枚举
* @since Beta v0.9.9
* @see TGApp.Game.Combat.AvatarTypeEnum
*/
const CombatAvatarTypeEnum: typeof TGApp.Game.Combat.AvatarType = {
SELF: 1,
TRIAL: 2,
SUPPORT: 3,
};
/**
* 获取剧诗角色类型描述
* @since Beta v0.9.9
* @param avatarType - 剧诗角色类型
* @returns 剧诗角色类型描述
*/
function getCombatAvatarTypeDesc(avatarType: TGApp.Game.Combat.AvatarTypeEnum): string {
switch (avatarType) {
case CombatAvatarTypeEnum.SELF:
return "";
case CombatAvatarTypeEnum.TRIAL:
return "试用角色";
case CombatAvatarTypeEnum.SUPPORT:
return "助演角色";
}
}
/**
* 绘想游迹状态枚举
* @since Beta v0.9.6
@@ -161,6 +189,8 @@ const gameEnum = {
},
combat: {
charMasterStat: CombatCharMasterStatEnum,
avatarType: CombatAvatarTypeEnum,
avatarTypeDesc: getCombatAvatarTypeDesc,
},
};

View File

@@ -1,6 +1,6 @@
/**
* 幻想真境剧诗类型定义
* @since Beta v0.9.6
* @since Beta v0.9.9
*/
declare namespace TGApp.Game.Combat {
@@ -42,22 +42,35 @@ declare namespace TGApp.Game.Combat {
is_unlock: boolean;
};
/**
* 角色类型
* @since Beta v0.9.9
* @see TGApp.Game.Combat.AvatarTypeEnum
*/
const AvatarType = <const>{
/** 自己角色 */
SELF: 1,
/** 试用角色 */
TRIAL: 2,
/** 助演角色 */
SUPPORT: 3,
};
/**
* 角色类型枚举
* @since Beta v0.9.9
*/
type AvatarTypeEnum = (typeof AvatarType)[keyof typeof AvatarType];
/**
* 角色数据
* @since Beta v0.6.3
* @since Beta v0.9.9
*/
type Avatar = {
/** 角色ID */
avatar_id: number;
/**
* 角色类型
* @TODO 枚举类
* @remarks
* - 0: 自己角色
* - 1: 试用角色
* - 2: 助演角色
*/
avatar_type: number;
/** 角色类型 */
avatar_type: AvatarTypeEnum;
/** 角色名称 */
name: string;
/** 角色元素 */