package LasTres::CombatCapableTeam;

use v5.36.0;

use strict;
use warnings;

use feature 'signatures';

use Moo::Role;

requires
  qw/uuid combat_members current_battle to_serializable from_serializable update is_defeated on_win_combat on_lose_combat on_end_combat combat_members_serializable/;

sub get_from_storage ($self) {
    return $self;
}

sub battle ($self) {
    my $current_battle = $self->current_battle;
    if ( !defined $current_battle ) {
        return;
    }
    my $battle = LasTres::Battle->get_redis($current_battle);
    if ( !defined $battle ) {
        return;
    }
    return $battle;
}

sub enemy_team ($self) {
    my $battle = $self->battle;
    return if !defined $battle;
    my $enemy_team = $battle->get_enemy_team($self);
    return $enemy_team;
}

1;
