update:新增房间重连逻辑,优化tententen语音,修复mvp斩获环
This commit is contained in:
@@ -48,7 +48,6 @@ const AUDIO_TIMEOUT_PER_KEY = 2600;
|
||||
const AUDIO_TIMEOUT_MAX = 12000;
|
||||
const BATTLE_CANCEL_RETURN_DELAY = 2000;
|
||||
const ROUND_AUDIO_NAMES = ["一", "二", "三", "四", "五"];
|
||||
const X_RING_STREAKS_KEY = "team-battle-x-ring-streaks";
|
||||
const MATCH_READY_SNAPSHOT_PREFIX = "match-ready-snapshot:";
|
||||
const MATCH_STATUS_BY_TEXT = {
|
||||
MATCH_STATUS_READY: 0,
|
||||
@@ -85,7 +84,6 @@ const shootTimeTotal = ref(DEFAULT_SHOOT_TIME);
|
||||
const readyTime = ref(DEFAULT_READY_TIME);
|
||||
const showOfflineModal = ref(false);
|
||||
const restoreLoading = ref(false);
|
||||
const xRingStreaks = ref({});
|
||||
|
||||
// 消息队列:只保存“待执行”的战况消息,页面展示统一由队列串行驱动。
|
||||
const battleQueue = ref([]);
|
||||
@@ -128,21 +126,6 @@ watch(online, (newVal, oldVal) => {
|
||||
});
|
||||
|
||||
// 统一把秒级或毫秒级时间戳转成毫秒,方便和本机时间比较。
|
||||
function loadXRingStreaks() {
|
||||
const cached = uni.getStorageSync(X_RING_STREAKS_KEY);
|
||||
xRingStreaks.value =
|
||||
cached && typeof cached === "object" && !Array.isArray(cached) ? cached : {};
|
||||
}
|
||||
|
||||
function saveXRingStreaks() {
|
||||
uni.setStorageSync(X_RING_STREAKS_KEY, xRingStreaks.value);
|
||||
}
|
||||
|
||||
function clearXRingStreaks() {
|
||||
xRingStreaks.value = {};
|
||||
uni.removeStorageSync(X_RING_STREAKS_KEY);
|
||||
}
|
||||
|
||||
function normalizeTimestamp(value) {
|
||||
const numberValue = Number(value || 0);
|
||||
if (!numberValue) return 0;
|
||||
@@ -933,7 +916,6 @@ function applyBattleSnapshot(battleInfo, { restore = false, restoreEventType = 0
|
||||
// 开局任务:切换到正式比赛态,并播报“比赛开始”。
|
||||
async function runBattleStartTask(task, runId) {
|
||||
// 开赛任务只负责切换正式态并播“比赛开始”,后续进入队列顺序。
|
||||
clearXRingStreaks();
|
||||
applyBattleBase(task.message);
|
||||
start.value = true;
|
||||
pendingRoundAudio = true;
|
||||
@@ -1009,29 +991,6 @@ async function runToSomeoneShootTask(task, runId) {
|
||||
});
|
||||
}
|
||||
|
||||
function isTenPlusRing(shot) {
|
||||
return !!(shot?.ringX || Number(shot?.ring) >= 10);
|
||||
}
|
||||
|
||||
function updateXRingStreak(shooterId, isTenPlusRingShot) {
|
||||
if (!shooterId) return false;
|
||||
const id = String(shooterId);
|
||||
if (!isTenPlusRingShot) {
|
||||
xRingStreaks.value[id] = 0;
|
||||
saveXRingStreaks();
|
||||
return false;
|
||||
}
|
||||
|
||||
xRingStreaks.value[id] = (xRingStreaks.value[id] || 0) + 1;
|
||||
if (xRingStreaks.value[id] < 3) {
|
||||
saveXRingStreaks();
|
||||
return false;
|
||||
}
|
||||
xRingStreaks.value[id] = 0;
|
||||
saveXRingStreaks();
|
||||
return true;
|
||||
}
|
||||
|
||||
function buildShootResultAudioKeys(shootData) {
|
||||
if (!shootData) return [];
|
||||
const audioKeys = [
|
||||
@@ -1040,6 +999,9 @@ function buildShootResultAudioKeys(shootData) {
|
||||
if (shootData.angle !== null && shootData.angle !== undefined) {
|
||||
audioKeys.push(`向${getDirectionText(shootData.angle)}调整`);
|
||||
}
|
||||
if (shootData.threeConsecutive10Rings === true) {
|
||||
audioKeys.push("tententen");
|
||||
}
|
||||
return audioKeys;
|
||||
}
|
||||
|
||||
@@ -1059,12 +1021,7 @@ async function runShootResultTask(task) {
|
||||
};
|
||||
}
|
||||
|
||||
const isTententen = updateXRingStreak(
|
||||
currentShooterId.value,
|
||||
isTenPlusRing(battleInfo.shootData)
|
||||
);
|
||||
const audioKeys = buildShootResultAudioKeys(battleInfo.shootData);
|
||||
if (isTententen) audioKeys.push("tententen");
|
||||
await playAudioKeys(audioKeys, { interrupt: false });
|
||||
notifyMatchAudioAck(task);
|
||||
}
|
||||
@@ -1141,7 +1098,6 @@ async function runBattleEndTask(task, runId) {
|
||||
const battleInfo = task.message;
|
||||
applyBattleBase(battleInfo);
|
||||
battleEnded = true;
|
||||
clearXRingStreaks();
|
||||
matchStatus.value = battleInfo.status;
|
||||
if (battleInfo.status === 4) {
|
||||
showRoundTip.value = true;
|
||||
@@ -1223,15 +1179,11 @@ async function restoreLatestBattle() {
|
||||
const restoreEventType = Number(result?.eventType || 0);
|
||||
|
||||
if (result.status === 2) {
|
||||
clearXRingStreaks();
|
||||
hideRestoreLoading();
|
||||
battleEnded = true;
|
||||
if (!battleEndTaskRunning) navigateToBattleResultOnce(result.matchId);
|
||||
return;
|
||||
}
|
||||
if (result.status === 4) {
|
||||
clearXRingStreaks();
|
||||
}
|
||||
reconnectMatchServer(result);
|
||||
|
||||
if (restoreEventType === MESSAGETYPESV2.NewRound) {
|
||||
@@ -1326,7 +1278,6 @@ onLoad((options) => {
|
||||
shootTimeTotal.value = DEFAULT_SHOOT_TIME;
|
||||
showOfflineModal.value = false;
|
||||
hideRestoreLoading();
|
||||
loadXRingStreaks();
|
||||
queueGeneration += 1;
|
||||
battleQueue.value = [];
|
||||
queueRunning.value = false;
|
||||
|
||||
Reference in New Issue
Block a user