=
<script setup>
import { computed } from "vue";
import BowPower from "@/components/BowPower.vue";
import { RoundImages } from "@/constants";
const props = defineProps({
  roundResults: {
    type: Array,
    default: () => [],
  },
  bluePoints: {
    type: Number,
    default: 0,
  },
  redPoints: {
    type: Number,
    default: 0,
  },
  goldenRound: {
    type: Number,
    default: 0,
  },
});

const normalRounds = computed(() => {
  const count = props.roundResults.findIndex((item) => !!item.ifGold);
  return count > 0 ? count : props.roundResults.length;
});
</script>

<template>
  <view class="container">
    <view class="guide-row">
      <image src="../static/shooter.png" mode="widthFix" />
      <view
        :style="{
          marginBottom: '10px',
          transform: 'scale(0.8) translateX(10px)',
        }"
      >
        <BowPower />
      </view>
    </view>
    <view>
      <image src="../static/battle-header-melee.png" mode="widthFix" />
      <text>蓝队({{ bluePoints }})</text>
      <text>红队({{ redPoints }})</text>
    </view>
    <view class="players">
      <view>
        <view v-for="(result, index) in roundResults" :key="index">
          <block v-if="index + 1 > normalRounds">
            <image
              :src="RoundImages[`gold${index + 1 - normalRounds}`]"
              mode="widthFix"
            />
          </block>
          <block v-else>
            <image :src="RoundImages[`round${index + 1}`]" mode="widthFix" />
          </block>
          <view>
            <text>{{
              result.shoots[1] && result.shoots[1].length
                ? result.shoots[1]
                    .map((item) => item.ring)
                    .reduce((last, next) => last + next, 0)
                : ""
            }}</text>
            <text>环</text>
          </view>
        </view>
        <block v-if="roundResults.length < 3">
          <view v-for="i in 3 - roundResults.length" :key="i">
            <image
              :src="RoundImages[`round${i + roundResults.length}`]"
              mode="widthFix"
            />
            <view>
              <text></text>
              <text>环</text>
            </view>
          </view>
        </block>
      </view>
      <view>
        <view v-for="(result, index) in roundResults" :key="index">
          <block v-if="index + 1 > normalRounds">
            <image
              :src="RoundImages[`gold${index + 1 - normalRounds}`]"
              mode="widthFix"
            />
          </block>
          <block v-else>
            <image :src="RoundImages[`round${index + 1}`]" mode="widthFix" />
          </block>
          <view>
            <text>{{
              result.shoots[2] && result.shoots[2].length
                ? result.shoots[2]
                    .map((item) => item.ring)
                    .reduce((last, next) => last + next, 0)
                : ""
            }}</text>
            <text>环</text>
          </view>
        </view>
        <block v-if="roundResults.length < 3">
          <view v-for="i in 3 - roundResults.length" :key="i">
            <image
              :src="RoundImages[`round${i + roundResults.length}`]"
              mode="widthFix"
            />
            <view>
              <text></text>
              <text>环</text>
            </view>
          </view>
        </block>
      </view>
    </view>
  </view>
</template>

<style scoped>
.container {
  width: 100%;
  overflow: hidden;
  margin-top: -100rpx;
}
.container > view:nth-child(2) {
  position: relative;
  display: flex;
  justify-content: space-around;
  align-items: center;
  font-size: 13px;
}
.container > view:nth-child(2) > image:first-child {
  position: absolute;
  width: 100%;
  top: -6px;
}
.container > view:nth-child(2) > text {
  z-index: 1;
  margin-top: 2px;
  color: #8a323e;
  font-weight: 500;
}
.container > view:nth-child(2) > text:nth-child(2) {
  color: #004ac1;
}
.players {
  display: flex;
}
.players > view {
  width: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  padding-top: 5px;
}
.players > view:first-child > view {
  background: linear-gradient(270deg, #172a86 0%, #0000 100%);
}
.players > view:last-child > view {
  background: linear-gradient(270deg, #0000 0%, #6a1212 100%);
}
.players > view > view {
  min-height: 52rpx;
  width: calc(100% - 40px);
  padding: 2px 20px;
  margin-bottom: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.players > view > view > image:first-child {
  width: 135rpx;
  height: 20px;
}
.players > view > view > view:last-child {
  font-size: 10px;
}
.players > view > view > view:last-child > text:first-child {
  font-size: 16px;
  color: #fed847;
  margin-right: 5px;
  font-weight: 500;
}
.guide-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 5vw;
  margin-bottom: -4px;
  z-index: 2;
  position: relative;
}
.guide-row > image {
  width: 140rpx;
}
</style>
