🏷️ 危战&剧诗难度类型定义调整为枚举类

This commit is contained in:
BTMuli
2026-04-01 21:12:11 +08:00
parent 9139c0460f
commit 34dde3b3b9
9 changed files with 171 additions and 70 deletions

View File

@@ -21,7 +21,7 @@
<span>{{ props.pos.hard_challenge_detail.second }}s</span>
<img
:src="`/icon/challenge/UI_LeyLineChallenge_Medal_${props.pos.hard_challenge_detail.difficulty}.webp`"
:title="getHardChallengeDesc(props.pos.hard_challenge_detail.difficulty)"
:title="gameEnum.challenge.diffDesc(props.pos.hard_challenge_detail.difficulty)"
alt="medal"
/>
<div
@@ -114,7 +114,6 @@
</template>
<script lang="ts" setup>
import gameEnum from "@enum/game.js";
import { getHardChallengeDesc } from "@Sql/utils/transUserRecord.js";
import { generateShareImg } from "@utils/TGShare.js";
import { parseHtmlText, stamp2LastTime, timestampToDate } from "@utils/toolFunc.js";
import { computed, onMounted, onUnmounted, ref, useTemplateRef } from "vue";

View File

@@ -7,7 +7,7 @@
<span>最佳记录</span>
<span>{{ props.data.best.second }}s</span>
<img
:title="getHardChallengeDesc(props.data.best.difficulty)"
:title="gameEnum.challenge.diffDesc(props.data.best.difficulty)"
:src="`/icon/challenge/UI_LeyLineChallenge_Medal_${props.data.best.difficulty}.webp`"
alt="medal"
/>
@@ -21,7 +21,7 @@
</div>
</template>
<script lang="ts" setup>
import { getHardChallengeDesc } from "@Sql/utils/transUserRecord.js";
import gameEnum from "@enum/game.js";
import TucChallengeItem from "./tuc-challenge-item.vue";

View File

@@ -5,7 +5,7 @@
<TucTile :val="getBestVal()" title="最佳记录" />
<TucTile :val="props.data.coin_num" title="消耗幻剧之花" />
<TucTile :val="getTime()" title="总耗时" />
<TucTile :title="getRoundTitle()" :val="getRoundVal()" />
<TucTile :title="gameEnum.combat.diffDesc(props.data.difficulty_id)" :val="getRoundVal()" />
</div>
<div class="tuco-line2">
<TucFight :data="props.fights.max_defeat_avatar" label="击败最多敌人" />
@@ -21,6 +21,8 @@
</div>
</template>
<script lang="ts" setup>
import gameEnum from "@enum/game.js";
import TucFight from "./tuc-fight.vue";
import TucTile from "./tuc-tile.vue";
@@ -28,32 +30,17 @@ type TucOverviewProps = { data: TGApp.Game.Combat.Stat; fights: TGApp.Game.Comba
const props = defineProps<TucOverviewProps>();
function getRoundTitle(): string {
switch (props.data.difficulty_id) {
case 0:
return "未选择";
case 1:
return "轻简模式";
case 2:
return "普通模式";
case 3:
return "困难模式";
case 4:
return "卓越模式";
case 5:
return "月谕模式";
default:
return `未知模式${props.data.difficulty_id}`;
}
}
function getBestVal(): string {
if (props.data.difficulty_id < 5) return `${props.data.max_round_id}`;
if (props.data.difficulty_id < gameEnum.combat.diff.TAROT) {
return `${props.data.max_round_id}`;
}
return `${props.data.max_round_id}幕·圣牌${props.data.tarot_finished_cnt}`;
}
function getRoundVal(): string {
if (props.data.difficulty_id < 5) return `${props.data.max_round_id}`;
if (props.data.difficulty_id < gameEnum.combat.diff.TAROT) {
return `${props.data.max_round_id}`;
}
return `${props.data.tarot_finished_cnt + props.data.max_round_id}`;
}

View File

@@ -164,6 +164,87 @@ function getCombatAvatarTypeDesc(avatarType: TGApp.Game.Combat.AvatarTypeEnum):
}
}
/**
* 剧诗难度类型枚举
* @since Beta v0.9.9
* @see TGApp.Game.Combat.DiffEnum
*/
const CombatDiffEnum: typeof TGApp.Game.Combat.Difficulty = {
NONE: 0,
EASY: 1,
NORMAL: 2,
HARD: 3,
MASTER: 4,
TAROT: 5,
};
/**
* 获取剧诗难度描述
* @since Beta v0.9.9
* @param difficultyId - 剧诗难度等级
* @returns 剧诗难度描述
*/
function getCombatDiffDesc(difficultyId: TGApp.Game.Combat.DiffEnum): string {
switch (difficultyId) {
case CombatDiffEnum.NONE:
return "未选择";
case CombatDiffEnum.EASY:
return "轻简模式";
case CombatDiffEnum.NORMAL:
return "普通模式";
case CombatDiffEnum.HARD:
return "困难模式";
case CombatDiffEnum.MASTER:
return "卓越模式";
case CombatDiffEnum.TAROT:
return "月谕模式";
default:
return `未知模式${difficultyId}`;
}
}
/**
* 幽境危战难度类型枚举
* @since Beta v0.9.9
* @see TGApp.Game.Challenge.DiffEnum
*/
const ChallengeDiffEnum: typeof TGApp.Game.Challenge.Difficulty = {
NONE: 0,
NORMAL: 1,
ADVANCED: 2,
HARD: 3,
DANGEROUS: 4,
FEARLESS: 5,
DESPERATE: 6,
};
/**
* 获取幽境危战难度描述
* @since Beta v0.9.9
* @param difficulty - 幽境危战难度
* @returns 幽境危战难度描述
*/
function getChallengeDiffDesc(difficulty: TGApp.Game.Challenge.DiffEnum): string {
switch (difficulty) {
case ChallengeDiffEnum.NONE:
return "未挑战";
case ChallengeDiffEnum.NORMAL:
return "普通";
case ChallengeDiffEnum.ADVANCED:
return "进阶";
case ChallengeDiffEnum.HARD:
return "困难";
case ChallengeDiffEnum.DANGEROUS:
return "险恶";
case ChallengeDiffEnum.FEARLESS:
return "无畏";
case ChallengeDiffEnum.DESPERATE:
return "绝境";
default:
return `难度${difficulty}`;
}
}
/**
* 绘想游迹状态枚举
* @since Beta v0.9.6
@@ -191,6 +272,12 @@ const gameEnum = {
charMasterStat: CombatCharMasterStatEnum,
avatarType: CombatAvatarTypeEnum,
avatarTypeDesc: getCombatAvatarTypeDesc,
diff: CombatDiffEnum,
diffDesc: getCombatDiffDesc,
},
challenge: {
diff: ChallengeDiffEnum,
diffDesc: getChallengeDiffDesc,
},
};

View File

@@ -1,8 +1,9 @@
/**
* 原神战绩数据转换
* @since Beta v0.9.1
* @since Beta v0.9.9
*/
import gameEnum from "@enum/game.js";
import { getZhElement } from "@utils/toolFunc.js";
/**
@@ -61,36 +62,9 @@ function transAvatar(data: TGApp.Game.Record.Avatar): TGApp.Sqlite.Record.Avatar
};
}
/**
* 获取幽境危战难度描述
* @since Beta v0.9.0
* @param difficulty - 幽境危战难度
* @returns 幽境危战难度描述
*/
export function getHardChallengeDesc(difficulty: number): string {
switch (difficulty) {
case 0:
return "未挑战";
case 1:
return "普通";
case 2:
return "进阶";
case 3:
return "困难";
case 4:
return "险恶";
case 5:
return "无畏";
case 6:
return "绝境";
default:
return `难度${difficulty}`;
}
}
/**
* 转换统计信息
* @since Beta v0.8.1
* @since Beta v0.9.9
* @param data - 统计信息
* @returns 转换后的统计信息
*/
@@ -112,7 +86,7 @@ function transStat(data: TGApp.Game.Record.Stats): TGApp.Sqlite.Record.Stats {
sprialAbyss: data.spiral_abyss,
combatRole: data.role_combat.is_unlock ? `${data.role_combat.max_round_id}` : "未解锁",
hardChallenge: data.hard_challenge.is_unlock
? `${data.hard_challenge.name}-${getHardChallengeDesc(data.hard_challenge.difficulty)}`
? `${data.hard_challenge.name}-${gameEnum.challenge.diffDesc(data.hard_challenge.difficulty)}`
: "未解锁",
luxuriousChest: data.luxurious_chest_number,
preciousChest: data.precious_chest_number,

View File

@@ -1,6 +1,6 @@
/**
* 游戏-活动日历相关类型定义文件
* @since Beta v0.8.3
* @since Beta v0.9.9
*/
declare namespace TGApp.Game.ActCalendar {
@@ -221,13 +221,13 @@ declare namespace TGApp.Game.ActCalendar {
/**
* 幽境危战活动详情
* @since Beta v0.8.0
* @since Beta v0.9.9
*/
type ActHardChallenge = {
/** 是否解锁 */
is_unlock: boolean;
/** 当前难度 */
difficulty: number;
difficulty: TGApp.Game.Challenge.DiffEnum;
/** 挑战耗时(秒) */
second: number;
/** 活动图标 */
@@ -260,11 +260,11 @@ declare namespace TGApp.Game.ActCalendar {
/**
* 真境剧诗活动详情
* @since Beta v0.8.3
* @since Beta v0.9.9
*/
type ActRoleCombat = {
/** 难度id */
difficulty_id: number;
difficulty_id: TGApp.Game.Combat.DiffEnum;
/** 是否有数据 */
has_data: boolean;
/** 是否解锁 */

View File

@@ -1,9 +1,37 @@
/**
* 幽境危战
* @since Beta v0.8.0
* @since Beta v0.9.9
*/
declare namespace TGApp.Game.Challenge {
/**
* 幽境危战难度
* @since Beta v0.9.9
* @see TGApp.Game.Challenge.DiffEnum
*/
const Difficulty = <const>{
/** 未挑战 */
NONE: 0,
/** 普通 */
NORMAL: 1,
/** 进阶 */
ADVANCED: 2,
/** 困难 */
HARD: 3,
/** 险恶 */
DANGEROUS: 4,
/** 无畏 */
FEARLESS: 5,
/** 绝境 */
DESPERATE: 6,
};
/**
* 幽境危战难度枚举
* @since Beta v0.9.9
*/
type DiffEnum = (typeof Difficulty)[keyof typeof Difficulty];
/**
* 赋光之人列表返回响应
* @since Beta v0.8.0
@@ -120,11 +148,11 @@ declare namespace TGApp.Game.Challenge {
/**
* 最佳数据
* @since Beta v0.8.0
* @since Beta v0.9.9
*/
type ChallengeBest = {
/** 难度 */
difficulty: number;
difficulty: DiffEnum;
/** 耗时(秒) */
second: number;
/** 图标 */

View File

@@ -42,6 +42,32 @@ declare namespace TGApp.Game.Combat {
is_unlock: boolean;
};
/**
* 剧诗难度等级
* @since Beta v0.9.9
* @see TGApp.Game.Combat.DiffEnum
*/
const Difficulty = <const>{
/** 未选择 */
NONE: 0,
/** 轻简模式 */
EASY: 1,
/** 普通模式 */
NORMAL: 2,
/** 困难模式 */
HARD: 3,
/** 卓越模式 */
MASTER: 4,
/** 月谕模式 */
TAROT: 5,
};
/**
* 剧诗难度等级枚举
* @since Beta v0.9.9
*/
type DiffEnum = (typeof Difficulty)[keyof typeof Difficulty];
/**
* 角色类型
* @since Beta v0.9.9
@@ -148,11 +174,11 @@ declare namespace TGApp.Game.Combat {
/**
* 状态
* @since Beta v0.8.3
* @since Beta v0.9.9
*/
type Stat = {
/** 难度等级 */
difficulty_id: number;
difficulty_id: DiffEnum;
/** 最大层数 */
max_round_id: number;
/** 纹章数 */

View File

@@ -1,8 +1,8 @@
/**
* 原神战绩相关类型定义文件
*
* @since Beta v0.8.1
* @since Beta v0.9.9
*/
declare namespace TGApp.Game.Record {
/**
* 原神战绩数据返回响应
@@ -151,13 +151,13 @@ declare namespace TGApp.Game.Record {
/**
* 幽境危战挑战数据类型
* @since Beta v0.8.0
* @since Beta v0.9.9
*/
type ChallengeStats = {
/** 是否解锁 */
is_unlock: boolean;
/** 挑战难度 */
difficulty: number;
difficulty: TGApp.Game.Challenge.DiffEnum;
/** 是否有数据 */
has_data: boolean;
/** 挑战名称 */