68 lines
1.7 KiB
Perl
68 lines
1.7 KiB
Perl
package L3TDE::Player;
|
|
|
|
use v5.34.1;
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use Moo;
|
|
use L3TDE::Help;
|
|
|
|
with 'L3TDE::Model';
|
|
|
|
# TODO: Help texts installation.
|
|
my %RACES = (
|
|
aldimor => {
|
|
base => {
|
|
body => 1,
|
|
magic => 5,
|
|
strength => 3,
|
|
quickness => 2,
|
|
wisdom => 4,
|
|
intelligence => 4,
|
|
charisma => 4,
|
|
attack => 2,
|
|
luck => 0
|
|
},
|
|
extra => { magic => 3, wisdom => 3 },
|
|
help =>
|
|
'The aldimors are the race of the magic, they are sightly greenish and love the nature. Damaging a tree is a crime punished with death for them.',
|
|
}
|
|
);
|
|
|
|
for my $key ( keys %RACES ) {
|
|
my $sum_base = 0;
|
|
my $sum_extra = 0;
|
|
my $base = $RACES{$key}{base};
|
|
my $extra = $RACES{$key}{extra};
|
|
for my $key ( keys %$base ) {
|
|
$sum_base += $base->{$key};
|
|
}
|
|
for my $key ( keys %$extra ) {
|
|
$sum_extra += $extra->{$key};
|
|
}
|
|
warn("$key base is unbalanced") if $sum_base != 25;
|
|
warn("$key extra is unbalanced") if $sum_extra != 6;
|
|
my $help = L3TDE::Help::singleton();
|
|
$help->install_help( $key, $RACES{$key}{help} );
|
|
}
|
|
|
|
sub table { 'players' }
|
|
sub not_defaulted_fields { [qw/username bot_id party_uuid/] }
|
|
sub defaulted_fields { [qw/uuid/] }
|
|
sub jsonb_fields { [qw/data/] }
|
|
sub find_fields { [qw/uuid username bot_id party_uuid/] }
|
|
sub id_fields { [qw/uuid/] }
|
|
|
|
has [qw/uuid username bot_id party_uuid data/] => ( is => 'rw' );
|
|
|
|
sub bot {
|
|
my $self = shift;
|
|
if ( !exists $self->{bot} ) {
|
|
require L3TDE::Bot;
|
|
$self->{bot} = L3TDE::Bot->find_one( id => $self->bot_id );
|
|
}
|
|
return $self->{bot};
|
|
}
|
|
1;
|