diff --git a/src/App.vue b/src/App.vue
index a8aaa81..4e4c22e 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -172,4 +172,12 @@ button::after {
overflow: hidden;
text-overflow: ellipsis;
}
+
+.modal {
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+}
diff --git a/src/components/Container.vue b/src/components/Container.vue
index f5e4bf0..627c7ff 100644
--- a/src/components/Container.vue
+++ b/src/components/Container.vue
@@ -1,9 +1,11 @@
diff --git a/src/components/ScreenHint.vue b/src/components/ScreenHint.vue
index 4098c48..be340c4 100644
--- a/src/components/ScreenHint.vue
+++ b/src/components/ScreenHint.vue
@@ -18,7 +18,7 @@ const props = defineProps({
const getContentHeight = () => {
if (props.mode === "tall") return "47vw";
if (props.mode === "square") return "74vw";
- return '36vw'
+ return "36vw";
};
diff --git a/src/components/ShootProgress.vue b/src/components/ShootProgress.vue
index 6ea8372..d3e71f5 100644
--- a/src/components/ShootProgress.vue
+++ b/src/components/ShootProgress.vue
@@ -1,5 +1,5 @@
diff --git a/src/pages/battle-room.vue b/src/pages/battle-room.vue
index 8fb285e..2ae59fc 100644
--- a/src/pages/battle-room.vue
+++ b/src/pages/battle-room.vue
@@ -67,6 +67,14 @@ onLoad(async (options) => {
redPoints.value = battleInfo.redScore;
totalRounds.value = battleInfo.maxRound;
roundResults.value = battleInfo.roundResults;
+ currentShooterId.value = battleInfo.firePlayerIndex;
+ const remain = Date.now() / 1000 - battleInfo.fireTime;
+ if (remain > 0 && remain < 15) {
+ // 等渲染好再通知
+ setTimeout(() => {
+ uni.$emit("update-ramain", remain);
+ }, 300);
+ }
}
}
if (options.roomNumber) {
diff --git a/src/pages/friend-battle.vue b/src/pages/friend-battle.vue
index 26b1b1e..75f778c 100644
--- a/src/pages/friend-battle.vue
+++ b/src/pages/friend-battle.vue
@@ -43,7 +43,12 @@ const enterRoom = debounce(async () => {
}
}
});
-const onCreateRoom = () => {
+const onCreateRoom = async () => {
+ const isGaming = await isGamingAPI();
+ if (isGaming) {
+ uni.$showHint(1);
+ return;
+ }
warnning.value = "";
showModal.value = true;
};
diff --git a/src/pages/melee-match.vue b/src/pages/melee-match.vue
index 1178f1c..e985063 100644
--- a/src/pages/melee-match.vue
+++ b/src/pages/melee-match.vue
@@ -23,7 +23,7 @@ const { user } = storeToRefs(store);
const gameType = ref(0);
const teamSize = ref(0);
const start = ref(false);
-const startCount = ref(false);
+const countDown = ref(90);
const battleId = ref("");
const currentRound = ref(1);
const totalRounds = ref(0);
@@ -39,10 +39,43 @@ const onComplete = ref(null);
const showModal = ref(false);
onLoad(async (options) => {
- gameType.value = options.gameType;
- teamSize.value = options.teamSize;
- if (gameType.value && teamSize.value) {
- await matchGameAPI(true, gameType.value, teamSize.value);
+ if (options.battleId) {
+ const battleInfo = uni.getStorageSync(`battle-${options.battleId}`);
+ console.log("----battleInfo", battleInfo);
+ if (battleInfo) {
+ battleId.value = battleInfo.id;
+ start.value = true;
+ tips.value = "请连续射出6支箭";
+ players.value = [...battleInfo.blueTeam, ...battleInfo.redTeam];
+ players.value.forEach((p) => {
+ playersScores.value[p.id] = p.arrows;
+ });
+ if (battleInfo.startTime) {
+ const remain = Date.now() / 1000 - battleInfo.startTime;
+ if (remain <= 90) {
+ setTimeout(() => {
+ uni.$emit("update-ramain", remain);
+ }, 300);
+ } else if (remain > 90 && remain <= 110) {
+ halfTimeTip.value = true;
+ countDown.value = 20;
+ tips.value = "准备下半场";
+ setTimeout(() => {
+ uni.$emit("update-ramain", 110 - remain);
+ }, 300);
+ } else if (remain > 110) {
+ setTimeout(() => {
+ uni.$emit("update-ramain", remain - 110);
+ }, 300);
+ }
+ }
+ }
+ } else {
+ gameType.value = options.gameType;
+ teamSize.value = options.teamSize;
+ if (gameType.value && teamSize.value) {
+ await matchGameAPI(true, gameType.value, teamSize.value);
+ }
}
});
async function stopMatch() {
@@ -83,11 +116,11 @@ async function onReceiveMessage(messages = []) {
if (msg.id !== battleId.value) return;
if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
start.value = true;
- startCount.value = true;
seq.value += 1;
timerSeq.value = 0;
tips.value = "请连续射出6支箭";
scores.value = [];
+ countDown.value = 90;
}
if (msg.constructor === MESSAGETYPES.ShootResult) {
if (msg.userId === user.value.id) {
@@ -97,8 +130,8 @@ async function onReceiveMessage(messages = []) {
playersScores.value[msg.userId].push(msg.target);
}
if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
- startCount.value = false;
halfTimeTip.value = true;
+ countDown.value = 20;
tips.value = "准备下半场";
}
if (msg.constructor === MESSAGETYPES.MatchOver) {
@@ -142,8 +175,9 @@ onUnmounted(() => {
@@ -220,7 +254,6 @@ onUnmounted(() => {
flex-direction: column;
justify-content: center;
align-items: center;
- padding-top: 52px;
}
.half-time-tip > text:last-child {
margin-top: 20px;
diff --git a/src/pages/team-match.vue b/src/pages/team-match.vue
index 98fa972..225b557 100644
--- a/src/pages/team-match.vue
+++ b/src/pages/team-match.vue
@@ -46,10 +46,41 @@ const onComplete = ref(null);
const showModal = ref(false);
onLoad(async (options) => {
- gameType.value = options.gameType;
- teamSize.value = options.teamSize;
- if (gameType.value && teamSize.value) {
- await matchGameAPI(true, gameType.value, teamSize.value);
+ if (options.battleId) {
+ const battleInfo = uni.getStorageSync(`battle-${options.battleId}`);
+ console.log("----battleInfo", battleInfo);
+ if (battleInfo) {
+ battleId.value = battleInfo.id;
+ start.value = true;
+ redTeam.value = battleInfo.redTeam;
+ blueTeam.value = battleInfo.blueTeam;
+ currentRound.value = battleInfo.currentRound;
+ bluePoints.value = battleInfo.blueScore;
+ redPoints.value = battleInfo.redScore;
+ totalRounds.value = battleInfo.maxRound;
+ roundResults.value = battleInfo.roundResults;
+ if (battleInfo.firePlayerIndex) {
+ currentShooterId.value = battleInfo.firePlayerIndex;
+ if (redTeam.value[0].id === currentShooterId.value) {
+ tips.value = `请红队射箭-第${roundsName[currentRound.value]}轮`;
+ } else {
+ tips.value = `请蓝队射箭-第${roundsName[currentRound.value]}轮`;
+ }
+ }
+ const remain = Date.now() / 1000 - battleInfo.fireTime;
+ if (remain > 0 && remain <= 15) {
+ // 等渲染好再通知
+ setTimeout(() => {
+ uni.$emit("update-ramain", remain);
+ }, 300);
+ }
+ }
+ } else {
+ gameType.value = options.gameType;
+ teamSize.value = options.teamSize;
+ if (gameType.value && teamSize.value) {
+ await matchGameAPI(true, gameType.value, teamSize.value);
+ }
}
});
async function stopMatch() {
@@ -227,11 +258,4 @@ onUnmounted(() => {
width: 100%;
height: 100%;
}
-.modal {
- height: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
-}