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

<template>
  <view class="container">
    <image src="../static/battle-header.png" mode="widthFix" />
    <view class="players">
      <view>
        <view v-for="(result, index) in roundResults" :key="index">
          <text>Round {{ index + 1 }}</text>
          <view>
            <text>{{
              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>Round {{ index + 1 }}</text>
          <view>
            <text>{{ 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%;
  position: relative;
  margin-top: 20px;
}
.container > image:first-child {
  position: absolute;
  width: 100%;
  top: -10px;
}
.players {
  display: flex;
}
.players > view {
  width: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  padding-top: 20px;
}
.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>
