重回比赛逻辑优化
This commit is contained in:
@@ -79,12 +79,15 @@ onLoad(async (options) => {
|
||||
if (battleInfo) {
|
||||
battleId.value = battleInfo.id;
|
||||
battleType.value = battleInfo.config.mode;
|
||||
start.value = true;
|
||||
step.value = 3;
|
||||
step.value = 2;
|
||||
if (battleInfo.config.mode === 1) {
|
||||
redTeam.value = battleInfo.redTeam;
|
||||
blueTeam.value = battleInfo.blueTeam;
|
||||
currentRound.value = battleInfo.currentRound;
|
||||
totalRounds.value = battleInfo.maxRound;
|
||||
if (battleInfo.startTime < 0) return;
|
||||
start.value = true;
|
||||
step.value = 3;
|
||||
battleInfo.roundResults.forEach((round) => {
|
||||
if (round.blueTotal && round.redTotal) {
|
||||
if (round.blueTotal === round.redTotal) {
|
||||
@@ -97,19 +100,16 @@ onLoad(async (options) => {
|
||||
}
|
||||
}
|
||||
});
|
||||
totalRounds.value = battleInfo.maxRound;
|
||||
roundResults.value = battleInfo.roundResults;
|
||||
currentShooterId.value = battleInfo.firePlayerIndex;
|
||||
setTimeout(() => {
|
||||
if (battleInfo.roundResults[battleInfo.roundResults.length - 1]) {
|
||||
scores.value =
|
||||
battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].redArrows;
|
||||
blueScores.value =
|
||||
battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].blueArrows;
|
||||
scores.value = battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].redArrows.filter((item) => !!item.playerId);
|
||||
blueScores.value = battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].blueArrows.filter((item) => !!item.playerId);
|
||||
}
|
||||
}, 300);
|
||||
if (
|
||||
@@ -117,10 +117,12 @@ onLoad(async (options) => {
|
||||
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound]
|
||||
) {
|
||||
roundResults.value.push({
|
||||
redArrows:
|
||||
battleInfo.redTeam[0].shotHistory[battleInfo.currentRound],
|
||||
blueArrows:
|
||||
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound],
|
||||
redArrows: battleInfo.redTeam[0].shotHistory[
|
||||
battleInfo.currentRound
|
||||
].filter((item) => !!item.playerId),
|
||||
blueArrows: battleInfo.blueTeam[0].shotHistory[
|
||||
battleInfo.currentRound
|
||||
].filter((item) => !!item.playerId),
|
||||
});
|
||||
} else if (battleInfo.currentRound < 5) {
|
||||
roundResults.value.push({
|
||||
@@ -146,32 +148,36 @@ onLoad(async (options) => {
|
||||
}
|
||||
}
|
||||
} else if (battleInfo.config.mode === 2) {
|
||||
tips.value = "请连续射出6支箭";
|
||||
players.value = [...battleInfo.blueTeam, ...battleInfo.redTeam];
|
||||
players.value.forEach((p) => {
|
||||
playersScores.value[p.id] = [];
|
||||
});
|
||||
if (battleInfo.startTime < 0) return;
|
||||
start.value = true;
|
||||
step.value = 3;
|
||||
tips.value = "请连续射出6支箭";
|
||||
players.value.forEach((p) => {
|
||||
playersScores.value[p.id] = p.arrows;
|
||||
if (p.id === user.value.id) {
|
||||
scores.value = p.arrows;
|
||||
}
|
||||
});
|
||||
if (battleInfo.startTime > 0) {
|
||||
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;
|
||||
total.value = 20;
|
||||
tips.value = "准备下半场";
|
||||
setTimeout(() => {
|
||||
uni.$emit("update-ramain", 110 - remain);
|
||||
}, 300);
|
||||
} else if (remain > 110) {
|
||||
setTimeout(() => {
|
||||
uni.$emit("update-ramain", remain - 110);
|
||||
}, 300);
|
||||
}
|
||||
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;
|
||||
total.value = 20;
|
||||
tips.value = "准备下半场";
|
||||
setTimeout(() => {
|
||||
uni.$emit("update-ramain", 110 - remain);
|
||||
}, 300);
|
||||
} else if (remain > 110) {
|
||||
setTimeout(() => {
|
||||
uni.$emit("update-ramain", remain - 110);
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -328,11 +334,10 @@ async function onReceiveMessage(messages = []) {
|
||||
scores.value = [];
|
||||
totalRounds.value = msg.groupUserStatus.config.maxRounds;
|
||||
step.value = 3;
|
||||
if (!roundResults.value.length)
|
||||
roundResults.value.push({
|
||||
redArrows: [],
|
||||
blueArrows: [],
|
||||
});
|
||||
roundResults.value.push({
|
||||
redArrows: [],
|
||||
blueArrows: [],
|
||||
});
|
||||
total.value = 15;
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
||||
|
||||
@@ -57,30 +57,31 @@ onLoad(async (options) => {
|
||||
console.log("----battleInfo", battleInfo);
|
||||
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) => {
|
||||
playersScores.value[p.id] = [];
|
||||
});
|
||||
if (battleInfo.startTime <= 0) return;
|
||||
start.value = true;
|
||||
tips.value = "请连续射出6支箭";
|
||||
players.value.forEach((p) => {
|
||||
playersScores.value[p.id] = p.arrows;
|
||||
if (p.id === user.value.id) {
|
||||
scores.value = p.arrows;
|
||||
}
|
||||
});
|
||||
if (battleInfo.startTime > 0) {
|
||||
const remain = Date.now() / 1000 - battleInfo.startTime;
|
||||
if (remain <= 90) {
|
||||
setTimeout(() => {
|
||||
uni.$emit("update-ramain", remain);
|
||||
}, 300);
|
||||
} else if (remain > 90 && remain <= 110) {
|
||||
startCount.value = false;
|
||||
tips.value = "准备下半场";
|
||||
} else if (remain > 110) {
|
||||
setTimeout(() => {
|
||||
uni.$emit("update-ramain", remain - 110);
|
||||
}, 300);
|
||||
}
|
||||
const remain = Date.now() / 1000 - battleInfo.startTime;
|
||||
if (remain <= 90) {
|
||||
setTimeout(() => {
|
||||
uni.$emit("update-ramain", remain);
|
||||
}, 300);
|
||||
} else if (remain > 90 && remain <= 110) {
|
||||
startCount.value = false;
|
||||
tips.value = "准备下半场";
|
||||
} else if (remain > 110) {
|
||||
setTimeout(() => {
|
||||
uni.$emit("update-ramain", remain - 110);
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -50,9 +50,10 @@ onLoad(async (options) => {
|
||||
console.log("----battleInfo", battleInfo);
|
||||
if (battleInfo) {
|
||||
battleId.value = battleInfo.id;
|
||||
start.value = true;
|
||||
redTeam.value = battleInfo.redTeam;
|
||||
blueTeam.value = battleInfo.blueTeam;
|
||||
if (battleInfo.startTime < 0) return;
|
||||
start.value = true;
|
||||
currentRound.value = battleInfo.currentRound;
|
||||
battleInfo.roundResults.forEach((round) => {
|
||||
if (round.blueTotal && round.redTotal) {
|
||||
@@ -70,14 +71,12 @@ onLoad(async (options) => {
|
||||
roundResults.value = battleInfo.roundResults;
|
||||
setTimeout(() => {
|
||||
if (battleInfo.roundResults[battleInfo.roundResults.length - 1]) {
|
||||
scores.value =
|
||||
battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].redArrows;
|
||||
blueScores.value =
|
||||
battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].blueArrows;
|
||||
scores.value = battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].redArrows.filter((item) => !!item.playerId);
|
||||
blueScores.value = battleInfo.roundResults[
|
||||
battleInfo.roundResults.length - 1
|
||||
].blueArrows.filter((item) => !!item.playerId);
|
||||
}
|
||||
}, 300);
|
||||
if (
|
||||
@@ -85,9 +84,12 @@ onLoad(async (options) => {
|
||||
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound]
|
||||
) {
|
||||
roundResults.value.push({
|
||||
redArrows: battleInfo.redTeam[0].shotHistory[battleInfo.currentRound],
|
||||
blueArrows:
|
||||
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound],
|
||||
redArrows: battleInfo.redTeam[0].shotHistory[
|
||||
battleInfo.currentRound
|
||||
].filter((item) => !!item.playerId),
|
||||
blueArrows: battleInfo.blueTeam[0].shotHistory[
|
||||
battleInfo.currentRound
|
||||
].filter((item) => !!item.playerId),
|
||||
});
|
||||
} else if (battleInfo.currentRound < 5) {
|
||||
roundResults.value.push({
|
||||
@@ -157,12 +159,10 @@ async function onReceiveMessage(messages = []) {
|
||||
timerSeq.value = 0;
|
||||
scores.value = [];
|
||||
totalRounds.value = msg.groupUserStatus.config.maxRounds;
|
||||
// 返回游戏时候会加上,加了就不用再加了
|
||||
if (!roundResults.value.length)
|
||||
roundResults.value.push({
|
||||
redArrows: [],
|
||||
blueArrows: [],
|
||||
});
|
||||
roundResults.value.push({
|
||||
redArrows: [],
|
||||
blueArrows: [],
|
||||
});
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) {
|
||||
if (currentShooterId.value !== msg.userId) {
|
||||
|
||||
Reference in New Issue
Block a user