102 lines
2.2 KiB
Perl
102 lines
2.2 KiB
Perl
package BurguillosInfo::Schema::Result::ConquerUserCurrentEnemy;
|
|
|
|
use v5.36.0;
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use parent 'DBIx::Class::Core';
|
|
|
|
use feature 'signatures';
|
|
|
|
use JSON;
|
|
use BurguillosInfo::Species;
|
|
|
|
__PACKAGE__->table('conquer_user_current_enemy');
|
|
__PACKAGE__->load_components("TimeStamp");
|
|
|
|
__PACKAGE__->add_columns(
|
|
uuid => {
|
|
data_type => 'uuid',
|
|
is_nullable => 0,
|
|
},
|
|
user => {
|
|
data_type => 'uuid',
|
|
is_nullable => 0,
|
|
},
|
|
species => {
|
|
data_type => 'text',
|
|
is_nullable => 0,
|
|
},
|
|
is_selected_to_battle => {
|
|
data_type => 'boolean',
|
|
is_nullable => 0,
|
|
default_value => \'false',
|
|
},
|
|
is_battled => {
|
|
data_type => 'boolean',
|
|
is_nullable => 0,
|
|
default_value => \'false',
|
|
},
|
|
level => {
|
|
data_type => 'integer',
|
|
is_nullable => 0,
|
|
},
|
|
);
|
|
|
|
sub serialize ($self) {
|
|
my $species = BurguillosInfo::Species->new;
|
|
my $specie = $species->get( $self->species );
|
|
return {
|
|
uuid => $self->uuid,
|
|
species => $specie->serialize,
|
|
level => $self->level,
|
|
max_health => $self->max_health,
|
|
};
|
|
}
|
|
|
|
sub max_health ($self) {
|
|
$self = $self->get_from_storage();
|
|
my $base = 50;
|
|
my $born_value = 31;
|
|
return
|
|
int( ( ( $base * 2 + $born_value ) * $self->level ) / 100 +
|
|
$self->level +
|
|
10 );
|
|
}
|
|
|
|
sub experience_drop ($self) {
|
|
$self = $self->get_from_storage();
|
|
return int( $self->level / 7 * 179 );
|
|
}
|
|
|
|
sub experience ($self) {
|
|
$self = $self->get_from_storage();
|
|
return int( $self->level**(3) );
|
|
}
|
|
|
|
sub attack ($self) {
|
|
$self = $self->get_from_storage();
|
|
my $base = 50;
|
|
my $born_value = 31;
|
|
return int( ( ( $base * 2 + $self->level ) * $self->level ) / 100 );
|
|
}
|
|
|
|
sub defense ($self) {
|
|
$self = $self->get_from_storage();
|
|
my $base = 50;
|
|
my $born_value = 31;
|
|
return int( ( ( $base * 2 + $self->level ) * $self->level ) / 100 );
|
|
}
|
|
|
|
sub health ($self) {
|
|
|
|
# Combat result is decided from the start of battle.
|
|
return $self->max_health;
|
|
}
|
|
|
|
__PACKAGE__->set_primary_key('uuid');
|
|
__PACKAGE__->belongs_to( 'user_object',
|
|
'BurguillosInfo::Schema::Result::ConquerUser', 'user' );
|
|
1;
|