<script setup>
import Avatar from "@/components/Avatar.vue";
defineProps({
  isMelee: {
    type: Boolean,
    default: false,
  },
  blueTeam: {
    type: Array,
    default: () => [],
  },
  redTeam: {
    type: Array,
    default: () => [],
  },
});
</script>

<template>
  <view class="container">
    <image
      :src="`../static/battle-header${isMelee ? '-melee' : ''}.png`"
      mode="widthFix"
    />
    <view v-if="isMelee" class="players-melee">
      <view></view>
    </view>
    <view v-if="!isMelee" class="players">
      <view>
        <block v-if="blueTeam[0]">
          <Avatar :src="blueTeam[0].avatar" frame />
          <text>{{ blueTeam[0].name }}</text>
          <image
            v-if="blueTeam[0].winner"
            src="../static/winner-badge.png"
            mode="widthFix"
          />
        </block>
      </view>
      <view>
        <block v-if="redTeam[0]">
          <Avatar v-if="redTeam[0]" :src="redTeam[0].avatar" frame />
          <text>{{ redTeam[0].name }}</text>
          <image
            v-if="redTeam[0].winner"
            src="../static/winner-badge.png"
            mode="widthFix"
          />
        </block>
      </view>
    </view>
  </view>
</template>

<style scoped>
.container {
  width: 100%;
  position: relative;
  margin-bottom: 10px;
}
.container > image:first-child {
  position: absolute;
  width: 100%;
  top: -5px;
  z-index: 1;
}
.players {
  display: flex;
}
.players > view {
  width: 50%;
  height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff9;
  font-size: 14px;
  margin-top: 20px;
  padding-top: 5px;
  overflow: hidden;
  position: relative;
}
.players > view:first-child {
  background-color: #364469;
}
.players > view:last-child {
  background-color: #692735;
}
.players > view > text {
  margin-top: 5px;
}
.players > view > image:last-child {
  position: absolute;
  width: 60px;
  right: 0;
  bottom: 0;
}
</style>
