Adding to the Info packet known_words.

This commit is contained in:
Sergiotarxz 2023-07-12 18:54:21 +02:00
parent f43070ffee
commit 206a934d2d
2 changed files with 14 additions and 6 deletions

View File

@ -28,6 +28,7 @@ has is_battling => ( is => 'rw' );
has remaining_frames => ( is => 'rw' );
has available_actions => ( is => 'rw' );
has npcs => ( is => 'rw' );
has known_words => ( is => 'rw' );
sub identifier {
return 'info';
@ -44,11 +45,16 @@ sub data ($self) {
my $is_battling = $self->is_battling;
my $available_actions = $self->available_actions;
my $npcs = $self->npcs;
my $known_words = $self->known_words;
if ( defined $is_battling ) {
$is_battling = $is_battling ? $JSON::true : $JSON::false;
}
return {
(
( defined $known_words ) ? ( known_words => $known_words )
: ()
),
(
( defined $clear ) ? ( clear => $clear )
: ()
@ -85,8 +91,7 @@ sub data ($self) {
: ()
),
(
(defined $npcs)
? ( npcs => $npcs)
( defined $npcs ) ? ( npcs => $npcs )
: ()
)
};

View File

@ -18,6 +18,8 @@ use JSON qw/to_json/;
use Moo;
use LasTres::Words;
__PACKAGE__->table('player_pjs');
__PACKAGE__->add_columns(
@ -159,7 +161,8 @@ sub known_words_hash ($self) {
sub known_words_hash_serialized ($self) {
my %words = %{ $self->known_words_hash };
my @identifiers = keys %words;
%words = map { ($_->identifier => $_->serialize) } @identifiers;
%words =
map { ( $words{$_}->identifier => $words{$_}->serialize ) } @identifiers;
return \%words;
}