细节修改

This commit is contained in:
kron
2025-07-16 15:32:49 +08:00
parent 77dca00ce7
commit 492412ce4b
5 changed files with 91 additions and 19 deletions

View File

@@ -44,7 +44,6 @@ const sound = ref(true);
const currentSound = ref("");
const currentRound = ref(props.currentRound);
const currentRoundEnded = ref(!props.battleId);
const halfTimeTip = ref(false);
const ended = ref(false);
watch(
@@ -143,11 +142,10 @@ async function onReceiveMessage(messages = []) {
} else if (msg.constructor === MESSAGETYPES.AllReady) {
audioManager.play("比赛开始");
} else if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
if (!halfTimeTip.value) audioManager.play("比赛开始");
audioManager.play("比赛开始");
} else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
currentRoundEnded.value = true;
} else if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
halfTimeTip.value = true;
audioManager.play("中场休息");
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
audioManager.play("比赛结束");

View File

@@ -88,3 +88,75 @@ export const directionAdjusts = {
AdjustUpperRight: "向右上方调瞄",
AdjustRight: "向右侧调瞄",
};
export const getBattleResultTips = (
gameMode,
mode,
{ rank = 0, score = 0, win = false }
) => {
const getRandomIndex = (len) => Math.floor(Math.random() * len);
if (gameMode === 1) {
if (mode === 1) {
if (win) {
const tests = [
"你是朋友中的佼佼者哟!",
"你成功击败好友,成为大赢家!",
"你将好友“一举拿下”,超神无疑!",
];
return tests[getRandomIndex(3)];
} else {
const tests = [
"失误啦失误啦,再多来几局吧~",
"惜败好友,下次再战定能反超!",
"友谊第一,下场胜利属于你!",
];
return tests[getRandomIndex(3)];
}
} else if (mode === 2) {
if (score > 0) {
const tests = [
"王者一定属于你!",
"高光时刻!继续保持!",
"射灵世界的佼佼者!",
];
return tests[getRandomIndex(3)];
} else {
const tests = [
"再来一次,定能脱颖而出!",
"加强练习,争取越战越勇",
"人生走过的每一步都算数",
];
return tests[getRandomIndex(3)];
}
}
} else if (gameMode === 2) {
if (mode === 1) {
if (win) {
const tests = [
"你已经奔跑在通向王者的路上了!",
"射灵星球最闪耀的前进者!",
"赞!你真是越战越勇",
];
return tests[getRandomIndex(3)];
} else {
const tests = [
"失败是成功之母,儿子在等你!",
"人生得意须尽欢,不过此关心不甘!",
"这回一定是打开方式不对。再来!",
];
return tests[getRandomIndex(3)];
}
} else if (mode === 2) {
if (rank <= 3) {
const tests = [
"好成绩!全国排位赛等着你!",
"持续练习,就会迎来更多高光时刻!",
];
return tests[getRandomIndex(2)];
} else {
return "每日练习打卡,争取下次脱颖而出!";
}
}
}
return "";
};

View File

@@ -3,7 +3,7 @@ import { ref, onMounted } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import Avatar from "@/components/Avatar.vue";
import { getGameAPI, getHomeData } from "@/apis";
import { topThreeColors } from "@/constants";
import { topThreeColors, getBattleResultTips } from "@/constants";
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
@@ -13,6 +13,7 @@ const { updateUser, getLvlName } = store;
const ifWin = ref(false);
const data = ref({});
const totalPoints = ref(0);
const rank = ref(0);
// onLoad(async (options) => {
// battleId.value = options.battleId;
@@ -40,9 +41,11 @@ function exit() {
}
onMounted(async () => {
const battleInfo = uni.getStorageSync("last-battle");
console.log("----battleInfo", battleInfo);
// console.log("----battleInfo", battleInfo);
data.value = battleInfo;
const mine = battleInfo.playerStats.find((p) => p.id === user.value.id);
rank.value =
battleInfo.playerStats.findIndex((p) => p.id === user.value.id) + 1;
if (mine) {
if (battleInfo.mode === 1) {
totalPoints.value = mine.roundStats.reduce(
@@ -172,12 +175,15 @@ const checkBowData = () => {
积分 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }}
</text>
</view>
<text v-if="data.mode === 1" class="description">{{
ifWin ? "你已经奔跑在通向王者的路上了" : "失败是成功之母儿子在等你"
}}</text>
<text v-if="data.mode === 2" class="description"
>好成绩全国排位赛等着你</text
>
<text class="description">
{{
getBattleResultTips(data.battleMode, data.mode, {
win: ifWin,
score: totalPoints,
rank,
})
}}
</text>
<view class="op-btn">
<view @click="checkBowData">查看靶纸</view>
<view @click="exit">退出</view>

View File

@@ -59,6 +59,7 @@ onLoad(async (options) => {
if (battleInfo) {
battleId.value = battleInfo.id;
start.value = true;
startCount.value = true;
tips.value = "请连续射出6支箭";
players.value = [...battleInfo.blueTeam, ...battleInfo.redTeam];
players.value.forEach((p) => {
@@ -72,11 +73,8 @@ onLoad(async (options) => {
}, 300);
} else if (remain > 90 && remain <= 110) {
halfTimeTip.value = true;
total.value = 20;
startCount.value = false;
tips.value = "准备下半场";
setTimeout(() => {
uni.$emit("update-ramain", 110 - remain);
}, 300);
} else if (remain > 110) {
setTimeout(() => {
uni.$emit("update-ramain", remain - 110);
@@ -135,7 +133,6 @@ async function onReceiveMessage(messages = []) {
timerSeq.value = 0;
tips.value = "请连续射出6支箭";
scores.value = [];
total.value = 90;
}
if (msg.constructor === MESSAGETYPES.ShootResult) {
if (msg.userId === user.value.id) {
@@ -147,7 +144,6 @@ async function onReceiveMessage(messages = []) {
if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
startCount.value = false;
halfTimeTip.value = true;
total.value = 20;
tips.value = "准备下半场";
}
if (msg.constructor === MESSAGETYPES.MatchOver) {
@@ -210,7 +206,7 @@ onUnmounted(() => {
:currentRound="scores.length"
:totalRound="start ? 12 : 0"
:scores="scores"
:stop="halfTimeTip && !startCount"
:stop="!startCount"
/>
<view :style="{ paddingBottom: '20px' }">
<PlayerScore

View File

@@ -143,7 +143,7 @@ onHide(() => {
</script>
<template>
<Container title="排赛">
<Container title="排赛">
<view class="container" @click="() => (showSeasonList = false)">
<view class="ranking-my-data" v-if="user.id">
<view>