重回比赛逻辑优化
This commit is contained in:
@@ -39,11 +39,11 @@ const toRankListPage = () => {
|
|||||||
watch(
|
watch(
|
||||||
() => [config.value, user.value],
|
() => [config.value, user.value],
|
||||||
([n_config, n_user]) => {
|
([n_config, n_user]) => {
|
||||||
const rankInfos = n_config.randInfos || [];
|
const list = n_config.levelInfo || [];
|
||||||
if (n_user.id && rankInfos.length) {
|
if (n_user.id && list.length) {
|
||||||
rankInfos.some((r, index) => {
|
list.some((r, index) => {
|
||||||
if (r.upgrade_scores && r.upgrade_scores > n_user.scores) {
|
if (r.exp_required && r.exp_required > n_user.lvlPoints) {
|
||||||
nextLvlPoints.value = r.upgrade_scores;
|
nextLvlPoints.value = r.exp_required;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -75,17 +75,17 @@ watch(
|
|||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
<view class="user-stats">
|
<view class="user-stats">
|
||||||
<text class="level-tag level-tag-first">{{ user.lvlName }}</text>
|
<!-- <text class="level-tag level-tag-first">{{ user.lvlName }}</text> -->
|
||||||
<text class="level-tag level-tag-second">L{{ user.lvl }}</text>
|
<text class="level-tag level-tag-second">LV{{ user.lvl }}</text>
|
||||||
<view class="rank-tag">
|
<view class="rank-tag">
|
||||||
<view
|
<view
|
||||||
class="rank-tag-progress"
|
class="rank-tag-progress"
|
||||||
:style="{
|
:style="{
|
||||||
width: `${(Math.max(user.scores, 0) / nextLvlPoints) * 100}%`,
|
width: `${(user.lvlPoints / nextLvlPoints) * 100}%`,
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
<text class="rank-tag-text">
|
<text class="rank-tag-text">
|
||||||
{{ Math.max(user.scores, 0) }}/{{ nextLvlPoints }}
|
{{ user.lvlPoints }}{{ nextLvlPoints ? `/${nextLvlPoints}` : "" }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -175,7 +175,7 @@ watch(
|
|||||||
}
|
}
|
||||||
|
|
||||||
.level-tag-second {
|
.level-tag-second {
|
||||||
width: 25px;
|
width: 60rpx;
|
||||||
background: #09c504;
|
background: #09c504;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@ watch(
|
|||||||
.rank-tag {
|
.rank-tag {
|
||||||
position: relative;
|
position: relative;
|
||||||
background-color: #00000038;
|
background-color: #00000038;
|
||||||
width: 100rpx;
|
width: 150rpx;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,6 +233,7 @@ watch(
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.signin > image {
|
.signin > image {
|
||||||
|
border-radius: 50%;
|
||||||
width: 40px;
|
width: 40px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,12 +79,15 @@ onLoad(async (options) => {
|
|||||||
if (battleInfo) {
|
if (battleInfo) {
|
||||||
battleId.value = battleInfo.id;
|
battleId.value = battleInfo.id;
|
||||||
battleType.value = battleInfo.config.mode;
|
battleType.value = battleInfo.config.mode;
|
||||||
start.value = true;
|
step.value = 2;
|
||||||
step.value = 3;
|
|
||||||
if (battleInfo.config.mode === 1) {
|
if (battleInfo.config.mode === 1) {
|
||||||
redTeam.value = battleInfo.redTeam;
|
redTeam.value = battleInfo.redTeam;
|
||||||
blueTeam.value = battleInfo.blueTeam;
|
blueTeam.value = battleInfo.blueTeam;
|
||||||
currentRound.value = battleInfo.currentRound;
|
currentRound.value = battleInfo.currentRound;
|
||||||
|
totalRounds.value = battleInfo.maxRound;
|
||||||
|
if (battleInfo.startTime < 0) return;
|
||||||
|
start.value = true;
|
||||||
|
step.value = 3;
|
||||||
battleInfo.roundResults.forEach((round) => {
|
battleInfo.roundResults.forEach((round) => {
|
||||||
if (round.blueTotal && round.redTotal) {
|
if (round.blueTotal && round.redTotal) {
|
||||||
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;
|
roundResults.value = battleInfo.roundResults;
|
||||||
currentShooterId.value = battleInfo.firePlayerIndex;
|
currentShooterId.value = battleInfo.firePlayerIndex;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (battleInfo.roundResults[battleInfo.roundResults.length - 1]) {
|
if (battleInfo.roundResults[battleInfo.roundResults.length - 1]) {
|
||||||
scores.value =
|
scores.value = battleInfo.roundResults[
|
||||||
battleInfo.roundResults[
|
battleInfo.roundResults.length - 1
|
||||||
battleInfo.roundResults.length - 1
|
].redArrows.filter((item) => !!item.playerId);
|
||||||
].redArrows;
|
blueScores.value = battleInfo.roundResults[
|
||||||
blueScores.value =
|
battleInfo.roundResults.length - 1
|
||||||
battleInfo.roundResults[
|
].blueArrows.filter((item) => !!item.playerId);
|
||||||
battleInfo.roundResults.length - 1
|
|
||||||
].blueArrows;
|
|
||||||
}
|
}
|
||||||
}, 300);
|
}, 300);
|
||||||
if (
|
if (
|
||||||
@@ -117,10 +117,12 @@ onLoad(async (options) => {
|
|||||||
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound]
|
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound]
|
||||||
) {
|
) {
|
||||||
roundResults.value.push({
|
roundResults.value.push({
|
||||||
redArrows:
|
redArrows: battleInfo.redTeam[0].shotHistory[
|
||||||
battleInfo.redTeam[0].shotHistory[battleInfo.currentRound],
|
battleInfo.currentRound
|
||||||
blueArrows:
|
].filter((item) => !!item.playerId),
|
||||||
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound],
|
blueArrows: battleInfo.blueTeam[0].shotHistory[
|
||||||
|
battleInfo.currentRound
|
||||||
|
].filter((item) => !!item.playerId),
|
||||||
});
|
});
|
||||||
} else if (battleInfo.currentRound < 5) {
|
} else if (battleInfo.currentRound < 5) {
|
||||||
roundResults.value.push({
|
roundResults.value.push({
|
||||||
@@ -146,32 +148,36 @@ onLoad(async (options) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (battleInfo.config.mode === 2) {
|
} else if (battleInfo.config.mode === 2) {
|
||||||
tips.value = "请连续射出6支箭";
|
|
||||||
players.value = [...battleInfo.blueTeam, ...battleInfo.redTeam];
|
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) => {
|
players.value.forEach((p) => {
|
||||||
playersScores.value[p.id] = p.arrows;
|
playersScores.value[p.id] = p.arrows;
|
||||||
if (p.id === user.value.id) {
|
if (p.id === user.value.id) {
|
||||||
scores.value = p.arrows;
|
scores.value = p.arrows;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (battleInfo.startTime > 0) {
|
const remain = Date.now() / 1000 - battleInfo.startTime;
|
||||||
const remain = Date.now() / 1000 - battleInfo.startTime;
|
if (remain <= 90) {
|
||||||
if (remain <= 90) {
|
setTimeout(() => {
|
||||||
setTimeout(() => {
|
uni.$emit("update-ramain", remain);
|
||||||
uni.$emit("update-ramain", remain);
|
}, 300);
|
||||||
}, 300);
|
} else if (remain > 90 && remain <= 110) {
|
||||||
} else if (remain > 90 && remain <= 110) {
|
halfTimeTip.value = true;
|
||||||
halfTimeTip.value = true;
|
total.value = 20;
|
||||||
total.value = 20;
|
tips.value = "准备下半场";
|
||||||
tips.value = "准备下半场";
|
setTimeout(() => {
|
||||||
setTimeout(() => {
|
uni.$emit("update-ramain", 110 - remain);
|
||||||
uni.$emit("update-ramain", 110 - remain);
|
}, 300);
|
||||||
}, 300);
|
} else if (remain > 110) {
|
||||||
} else if (remain > 110) {
|
setTimeout(() => {
|
||||||
setTimeout(() => {
|
uni.$emit("update-ramain", remain - 110);
|
||||||
uni.$emit("update-ramain", remain - 110);
|
}, 300);
|
||||||
}, 300);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -328,11 +334,10 @@ async function onReceiveMessage(messages = []) {
|
|||||||
scores.value = [];
|
scores.value = [];
|
||||||
totalRounds.value = msg.groupUserStatus.config.maxRounds;
|
totalRounds.value = msg.groupUserStatus.config.maxRounds;
|
||||||
step.value = 3;
|
step.value = 3;
|
||||||
if (!roundResults.value.length)
|
roundResults.value.push({
|
||||||
roundResults.value.push({
|
redArrows: [],
|
||||||
redArrows: [],
|
blueArrows: [],
|
||||||
blueArrows: [],
|
});
|
||||||
});
|
|
||||||
total.value = 15;
|
total.value = 15;
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
||||||
|
|||||||
@@ -57,30 +57,31 @@ onLoad(async (options) => {
|
|||||||
console.log("----battleInfo", battleInfo);
|
console.log("----battleInfo", battleInfo);
|
||||||
if (battleInfo) {
|
if (battleInfo) {
|
||||||
battleId.value = battleInfo.id;
|
battleId.value = battleInfo.id;
|
||||||
start.value = true;
|
|
||||||
startCount.value = true;
|
|
||||||
tips.value = "请连续射出6支箭";
|
|
||||||
players.value = [...battleInfo.blueTeam, ...battleInfo.redTeam];
|
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) => {
|
players.value.forEach((p) => {
|
||||||
playersScores.value[p.id] = p.arrows;
|
playersScores.value[p.id] = p.arrows;
|
||||||
if (p.id === user.value.id) {
|
if (p.id === user.value.id) {
|
||||||
scores.value = p.arrows;
|
scores.value = p.arrows;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (battleInfo.startTime > 0) {
|
const remain = Date.now() / 1000 - battleInfo.startTime;
|
||||||
const remain = Date.now() / 1000 - battleInfo.startTime;
|
if (remain <= 90) {
|
||||||
if (remain <= 90) {
|
setTimeout(() => {
|
||||||
setTimeout(() => {
|
uni.$emit("update-ramain", remain);
|
||||||
uni.$emit("update-ramain", remain);
|
}, 300);
|
||||||
}, 300);
|
} else if (remain > 90 && remain <= 110) {
|
||||||
} else if (remain > 90 && remain <= 110) {
|
startCount.value = false;
|
||||||
startCount.value = false;
|
tips.value = "准备下半场";
|
||||||
tips.value = "准备下半场";
|
} else if (remain > 110) {
|
||||||
} else if (remain > 110) {
|
setTimeout(() => {
|
||||||
setTimeout(() => {
|
uni.$emit("update-ramain", remain - 110);
|
||||||
uni.$emit("update-ramain", remain - 110);
|
}, 300);
|
||||||
}, 300);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -50,9 +50,10 @@ onLoad(async (options) => {
|
|||||||
console.log("----battleInfo", battleInfo);
|
console.log("----battleInfo", battleInfo);
|
||||||
if (battleInfo) {
|
if (battleInfo) {
|
||||||
battleId.value = battleInfo.id;
|
battleId.value = battleInfo.id;
|
||||||
start.value = true;
|
|
||||||
redTeam.value = battleInfo.redTeam;
|
redTeam.value = battleInfo.redTeam;
|
||||||
blueTeam.value = battleInfo.blueTeam;
|
blueTeam.value = battleInfo.blueTeam;
|
||||||
|
if (battleInfo.startTime < 0) return;
|
||||||
|
start.value = true;
|
||||||
currentRound.value = battleInfo.currentRound;
|
currentRound.value = battleInfo.currentRound;
|
||||||
battleInfo.roundResults.forEach((round) => {
|
battleInfo.roundResults.forEach((round) => {
|
||||||
if (round.blueTotal && round.redTotal) {
|
if (round.blueTotal && round.redTotal) {
|
||||||
@@ -70,14 +71,12 @@ onLoad(async (options) => {
|
|||||||
roundResults.value = battleInfo.roundResults;
|
roundResults.value = battleInfo.roundResults;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (battleInfo.roundResults[battleInfo.roundResults.length - 1]) {
|
if (battleInfo.roundResults[battleInfo.roundResults.length - 1]) {
|
||||||
scores.value =
|
scores.value = battleInfo.roundResults[
|
||||||
battleInfo.roundResults[
|
battleInfo.roundResults.length - 1
|
||||||
battleInfo.roundResults.length - 1
|
].redArrows.filter((item) => !!item.playerId);
|
||||||
].redArrows;
|
blueScores.value = battleInfo.roundResults[
|
||||||
blueScores.value =
|
battleInfo.roundResults.length - 1
|
||||||
battleInfo.roundResults[
|
].blueArrows.filter((item) => !!item.playerId);
|
||||||
battleInfo.roundResults.length - 1
|
|
||||||
].blueArrows;
|
|
||||||
}
|
}
|
||||||
}, 300);
|
}, 300);
|
||||||
if (
|
if (
|
||||||
@@ -85,9 +84,12 @@ onLoad(async (options) => {
|
|||||||
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound]
|
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound]
|
||||||
) {
|
) {
|
||||||
roundResults.value.push({
|
roundResults.value.push({
|
||||||
redArrows: battleInfo.redTeam[0].shotHistory[battleInfo.currentRound],
|
redArrows: battleInfo.redTeam[0].shotHistory[
|
||||||
blueArrows:
|
battleInfo.currentRound
|
||||||
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound],
|
].filter((item) => !!item.playerId),
|
||||||
|
blueArrows: battleInfo.blueTeam[0].shotHistory[
|
||||||
|
battleInfo.currentRound
|
||||||
|
].filter((item) => !!item.playerId),
|
||||||
});
|
});
|
||||||
} else if (battleInfo.currentRound < 5) {
|
} else if (battleInfo.currentRound < 5) {
|
||||||
roundResults.value.push({
|
roundResults.value.push({
|
||||||
@@ -157,12 +159,10 @@ async function onReceiveMessage(messages = []) {
|
|||||||
timerSeq.value = 0;
|
timerSeq.value = 0;
|
||||||
scores.value = [];
|
scores.value = [];
|
||||||
totalRounds.value = msg.groupUserStatus.config.maxRounds;
|
totalRounds.value = msg.groupUserStatus.config.maxRounds;
|
||||||
// 返回游戏时候会加上,加了就不用再加了
|
roundResults.value.push({
|
||||||
if (!roundResults.value.length)
|
redArrows: [],
|
||||||
roundResults.value.push({
|
blueArrows: [],
|
||||||
redArrows: [],
|
});
|
||||||
blueArrows: [],
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) {
|
if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) {
|
||||||
if (currentShooterId.value !== msg.userId) {
|
if (currentShooterId.value !== msg.userId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user