<script setup>
defineProps({
  roundResults: {
    type: Array,
    default: () => [],
  },
  bluePoints: {
    type: Number,
    default: 0,
  },
  redPoints: {
    type: Number,
    default: 0,
  },
});
</script>

<template>
  <view class="container">
    <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">
          <text
            >{{ index > 4 ? "决金箭" : "Round" }}
            {{ index > 4 ? `R${index - 4}` : index + 1 }}</text
          >
          <view>
            <text>{{
              result.blueArrows.length
                ? result.blueArrows
                    .map((item) => item.ring)
                    .reduce((last, next) => last + next, 0)
                : ""
            }}</text>
            <text>环</text>
          </view>
        </view>
      </view>
      <view>
        <view v-for="(result, index) in roundResults" :key="index">
          <text
            >{{ index > 4 ? "决金箭" : "Round" }}
            {{ index > 4 ? `R${index - 4}` : index + 1 }}</text
          >
          <view>
            <text>{{
              result.redArrows.length
                ? result.redArrows
                    .map((item) => item.ring)
                    .reduce((last, next) => last + next, 0)
                : ""
            }}</text>
            <text>环</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<style scoped>
.container {
  width: 100%;
  margin-top: 20px;
  overflow: hidden;
}
.container > view:first-child {
  position: relative;
  display: flex;
  justify-content: space-around;
  align-items: center;
  font-size: 13px;
}
.container > view:first-child > image:first-child {
  position: absolute;
  width: 100%;
  top: -6px;
}
.container > view:first-child > text {
  z-index: 1;
  margin-top: 2px;
}
.container > view:first-child > text:nth-child(2) {
  color: #364469;
}
.container > view:first-child > text:nth-child(3) {
  color: #692735;
}
.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 {
  background-color: #364469;
}
.players > view:last-child {
  background-color: #692735;
}
.players > view > view {
  width: 85%;
  padding: 5px 20px;
  margin-bottom: 5px;
  background-image: url("../static/row-bg.png");
  background-size: 90% 100%;
  background-repeat: no-repeat;
  background-position: center;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.players > view > view > text {
  font-size: 14px;
}
.players > view > view > view:last-child {
  font-size: 14px;
  padding-right: 20px;
}
.players > view > view > view:last-child > text:first-child {
  font-size: 20px;
  color: #fed847;
  margin-right: 5px;
}
</style>
