package LasTres::Controller::Race;

use v5.36.0;

use strict;
use warnings;

use Mojo::Base 'Mojolicious::Controller', -signatures;

use LasTres::Races;

sub playable($self) {
    my $races = LasTres::Races->new;
    my $hash;
    eval {
        $hash = $races->hash_all_playable;
    };
    if ($@) {
        say STDERR $@;
        return $self->render(
            status => 500,
            json => { error => 'Error del servidor procesando las razas.' }
        );
    }
    return $self->render(
        json => $hash
    );
}
1;
