新版房间1v1对战数据调试完成
This commit is contained in:
@@ -5,7 +5,7 @@ import Container from "@/components/Container.vue";
|
||||
import BattleHeader from "@/components/BattleHeader.vue";
|
||||
import Avatar from "@/components/Avatar.vue";
|
||||
import PlayerScore2 from "@/components/PlayerScore2.vue";
|
||||
import { getGameAPI } from "@/apis";
|
||||
import { getBattleAPI } from "@/apis";
|
||||
|
||||
const blueTeam = ref([]);
|
||||
const redTeam = ref([]);
|
||||
@@ -13,79 +13,23 @@ const roundsData = ref([]);
|
||||
const goldenRoundsData = ref([]);
|
||||
const battleId = ref("");
|
||||
const data = ref({
|
||||
players: [],
|
||||
teams: [],
|
||||
rounds: [],
|
||||
});
|
||||
|
||||
onLoad(async (options) => {
|
||||
if (options.id) {
|
||||
battleId.value = options.id || "BATTLE-1755484626207409508-955";
|
||||
const result = await getGameAPI(battleId.value);
|
||||
data.value = result;
|
||||
if (result.mode === 1) {
|
||||
blueTeam.value = Object.values(result.bluePlayers || {});
|
||||
redTeam.value = Object.values(result.redPlayers || {});
|
||||
Object.values(result.roundsData).forEach((item) => {
|
||||
let bluePoint = 1;
|
||||
let redPoint = 1;
|
||||
let blueTotalRings = 0;
|
||||
let redTotalRings = 0;
|
||||
let blueArrows = [];
|
||||
let redArrows = [];
|
||||
blueTeam.value.forEach((p) => {
|
||||
if (!item[p.playerId]) return;
|
||||
blueTotalRings += item[p.playerId].reduce((a, b) => a + b.ring, 0);
|
||||
blueArrows = [...blueArrows, ...item[p.playerId]];
|
||||
});
|
||||
redTeam.value.forEach((p) => {
|
||||
if (!item[p.playerId]) return;
|
||||
redTotalRings += item[p.playerId].reduce((a, b) => a + b.ring, 0);
|
||||
redArrows = [...redArrows, ...item[p.playerId]];
|
||||
});
|
||||
if (blueTotalRings > redTotalRings) {
|
||||
bluePoint = 2;
|
||||
redPoint = 0;
|
||||
} else if (blueTotalRings < redTotalRings) {
|
||||
bluePoint = 0;
|
||||
redPoint = 2;
|
||||
}
|
||||
roundsData.value.push({
|
||||
blue: {
|
||||
avatars: blueTeam.value.map((p) => p.avatar),
|
||||
arrows: blueArrows,
|
||||
totalRing: blueTotalRings,
|
||||
totalScore: bluePoint,
|
||||
},
|
||||
red: {
|
||||
avatars: redTeam.value.map((p) => p.avatar),
|
||||
arrows: redArrows,
|
||||
totalRing: redTotalRings,
|
||||
totalScore: redPoint,
|
||||
},
|
||||
});
|
||||
});
|
||||
result.goldenRounds.forEach((round) => {
|
||||
goldenRoundsData.value.push({
|
||||
blue: {
|
||||
avatars: blueTeam.value.map((p) => p.avatar),
|
||||
arrows: round.arrowHistory.filter((a) => a.team === 1),
|
||||
},
|
||||
red: {
|
||||
avatars: redTeam.value.map((p) => p.avatar),
|
||||
arrows: round.arrowHistory.filter((a) => a.team === 0),
|
||||
},
|
||||
winner: round.winner,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!options.id) return;
|
||||
battleId.value = options.id || "57943107462893568";
|
||||
const result = await getBattleAPI(battleId.value);
|
||||
data.value = result;
|
||||
});
|
||||
|
||||
const checkBowData = () => {
|
||||
if (data.value.mode === 1) {
|
||||
const checkBowData = (selected) => {
|
||||
if (data.value.way === 1) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/team-bow-data?battleId=${battleId.value}`,
|
||||
url: `/pages/team-bow-data?battleId=${battleId.value}&selected=${selected}`,
|
||||
});
|
||||
} else if (data.value.mode === 2) {
|
||||
} else if (data.value.way === 2) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/melee-bow-data?battleId=${battleId.value}`,
|
||||
});
|
||||
@@ -97,13 +41,13 @@ const checkBowData = () => {
|
||||
<Container title="详情">
|
||||
<view class="container">
|
||||
<BattleHeader
|
||||
:winner="data.winner"
|
||||
:blueTeam="blueTeam"
|
||||
:redTeam="redTeam"
|
||||
:winner="data.winTeam"
|
||||
:blueTeam="data.teams[1] ? data.teams[1].players : []"
|
||||
:redTeam="data.teams[2] ? data.teams[2].players : []"
|
||||
:players="data.players"
|
||||
/>
|
||||
<view
|
||||
v-if="data.players && data.players.length"
|
||||
v-if="data.mode > 3"
|
||||
class="score-header"
|
||||
:style="{ border: 'none', padding: '5px 15px' }"
|
||||
>
|
||||
@@ -114,7 +58,7 @@ const checkBowData = () => {
|
||||
</view>
|
||||
</view>
|
||||
<PlayerScore2
|
||||
v-if="data.players && data.players.length"
|
||||
v-if="data.mode > 3"
|
||||
v-for="(player, index) in data.players"
|
||||
:key="index"
|
||||
:name="player.name"
|
||||
@@ -124,131 +68,47 @@ const checkBowData = () => {
|
||||
:totalRing="player.totalRings"
|
||||
:rank="index + 1"
|
||||
/>
|
||||
<block v-for="(round, index) in goldenRoundsData" :key="index">
|
||||
<view
|
||||
v-for="(round, index) in data.rounds"
|
||||
:key="index"
|
||||
:style="{ marginBottom: '5px' }"
|
||||
>
|
||||
<view class="score-header">
|
||||
<text>决金箭轮(环数)</text>
|
||||
<view @click="checkBowData">
|
||||
<text>{{ round.ifGold ? "决金箭" : `第${index + 1}轮` }}</text>
|
||||
<view @click="() => checkBowData(index)">
|
||||
<text>查看靶纸</text>
|
||||
<image src="../static/back.png" mode="widthFix" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="score-row">
|
||||
<view
|
||||
class="score-row"
|
||||
v-for="team in Object.keys(round.shoots)"
|
||||
:key="team"
|
||||
>
|
||||
<view>
|
||||
<view>
|
||||
<image
|
||||
v-for="(src, index) in round.blue.avatars"
|
||||
v-for="(p, index) in data.teams[team].players"
|
||||
:style="{
|
||||
borderColor: '#64BAFF',
|
||||
transform: `translateX(-${index * 15}px)`,
|
||||
}"
|
||||
:src="src"
|
||||
:src="p.avatar || '../static/user-icon.png'"
|
||||
:key="index"
|
||||
mode="widthFix"
|
||||
/>
|
||||
</view>
|
||||
<text v-for="(arrow, index) in round.blue.arrows" :key="index">
|
||||
<text v-for="(arrow, index2) in round.shoots[team]" :key="index2">
|
||||
{{ arrow.ring }}环
|
||||
</text>
|
||||
</view>
|
||||
<image
|
||||
v-if="round.winner === 1"
|
||||
src="../static/winner-badge.png"
|
||||
mode="widthFix"
|
||||
/>
|
||||
</view>
|
||||
<view class="score-row" :style="{ marginBottom: '5px' }">
|
||||
<view>
|
||||
<view>
|
||||
<image
|
||||
v-for="(src, index) in round.red.avatars"
|
||||
:style="{
|
||||
borderColor: '#FF6767',
|
||||
transform: `translateX(-${index * 15}px)`,
|
||||
}"
|
||||
:src="src || '../static/user-icon.png'"
|
||||
:key="index"
|
||||
mode="widthFix"
|
||||
/>
|
||||
</view>
|
||||
<text v-for="(arrow, index) in round.red.arrows" :key="index">
|
||||
{{ arrow.ring }}环
|
||||
<text :style="{ color: team == 1 ? '#64BAFF' : '#FF6767' }">
|
||||
{{ round.shoots[team].reduce((acc, cur) => acc + cur.ring, 0) }}环
|
||||
</text>
|
||||
<text>得分 {{ round.scores[team].totalRing }}</text>
|
||||
</view>
|
||||
<image
|
||||
v-if="round.winner === 0"
|
||||
src="../static/winner-badge.png"
|
||||
mode="widthFix"
|
||||
/>
|
||||
</view>
|
||||
</block>
|
||||
<view
|
||||
v-for="(round, index) in roundsData"
|
||||
:key="index"
|
||||
:style="{ marginBottom: '5px' }"
|
||||
>
|
||||
<block
|
||||
v-if="
|
||||
index < Object.keys(roundsData).length - goldenRoundsData.length
|
||||
"
|
||||
>
|
||||
<view class="score-header">
|
||||
<text>第{{ index + 1 }}轮</text>
|
||||
<view @click="checkBowData">
|
||||
<text>查看靶纸</text>
|
||||
<image src="../static/back.png" mode="widthFix" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="score-row">
|
||||
<view>
|
||||
<view>
|
||||
<image
|
||||
v-for="(src, index) in round.blue.avatars"
|
||||
:style="{
|
||||
borderColor: '#64BAFF',
|
||||
transform: `translateX(-${index * 15}px)`,
|
||||
}"
|
||||
:src="src || '../static/user-icon.png'"
|
||||
:key="index"
|
||||
mode="widthFix"
|
||||
/>
|
||||
</view>
|
||||
<text v-for="(arrow, index2) in round.blue.arrows" :key="index2">
|
||||
{{ arrow.ring }}环
|
||||
</text>
|
||||
</view>
|
||||
<view>
|
||||
<text :style="{ color: '#64BAFF' }">
|
||||
{{ round.blue.totalRing }}环
|
||||
</text>
|
||||
<text>得分 {{ round.blue.totalScore }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="score-row">
|
||||
<view>
|
||||
<view>
|
||||
<image
|
||||
v-for="(src, index) in round.red.avatars"
|
||||
:style="{
|
||||
borderColor: '#FF6767',
|
||||
transform: `translateX(-${index * 15}px)`,
|
||||
}"
|
||||
:src="src || '../static/user-icon.png'"
|
||||
:key="index"
|
||||
mode="widthFix"
|
||||
/>
|
||||
</view>
|
||||
<text v-for="(arrow, index2) in round.red.arrows" :key="index2">
|
||||
{{ arrow.ring }}环
|
||||
</text>
|
||||
</view>
|
||||
<view>
|
||||
<text :style="{ color: '#FF6767' }">
|
||||
{{ round.red.totalRing }}环
|
||||
</text>
|
||||
<text>得分 {{ round.red.totalScore }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<view :style="{ height: '20px' }"></view>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user