Refactoring locations.
This commit is contained in:
parent
8690a94b3a
commit
aff1619de0
|
@ -27,14 +27,14 @@ my $planets = LasTres::Planets->new;
|
||||||
# The available actions to do in
|
# The available actions to do in
|
||||||
# this location, must return hashref,
|
# this location, must return hashref,
|
||||||
# can be an empty one though.
|
# can be an empty one though.
|
||||||
sub actions($self, $pj) {
|
sub actions ( $self, $pj ) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
## OVERRIDE
|
## OVERRIDE
|
||||||
# The available persons to talk with
|
# The available persons to talk with
|
||||||
# Must return a hashref, can be a empty
|
# Must return a hashref, can be a empty
|
||||||
# one though.
|
# one though.
|
||||||
sub npcs($self, $pj) {
|
sub npcs ( $self, $pj ) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,20 +75,20 @@ sub order ($self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
## OVERRIDE
|
## OVERRIDE
|
||||||
# A place that is a spawn will have a healing action that can be changed
|
# A place that is a spawn will have a healing action that can be changed
|
||||||
# and if a team faints they will be teleported there and the action will
|
# and if a team faints they will be teleported there and the action will
|
||||||
# be triggered, the healing action may cost some resource when the action
|
# be triggered, the healing action may cost some resource when the action
|
||||||
# is triggered manually by the user, if the player cannot pay it the
|
# is triggered manually by the user, if the player cannot pay it the
|
||||||
# action may appear as disabled.
|
# action may appear as disabled.
|
||||||
sub is_spawn($self) {
|
sub is_spawn ($self) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
## OVERRIDE
|
## OVERRIDE
|
||||||
# Return object should ideally extend LasTres::PJAction::DefaultHeal
|
# Return object should ideally extend LasTres::PJAction::DefaultHeal
|
||||||
# following the advice in this file.
|
# following the advice in this file.
|
||||||
sub healing_action($self) {
|
sub healing_action ($self) {
|
||||||
if ($self->is_spawn) {
|
if ( $self->is_spawn ) {
|
||||||
require LasTres::PJAction::DefaultHeal;
|
require LasTres::PJAction::DefaultHeal;
|
||||||
return LasTres::PJAction::DefaultHeal->new;
|
return LasTres::PJAction::DefaultHeal->new;
|
||||||
}
|
}
|
||||||
|
@ -136,10 +136,10 @@ sub show_intro ( $self, $pj ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
## OVERRIDE (Always use $self->SUPER)
|
## OVERRIDE (Always use $self->SUPER)
|
||||||
sub on_leave($self, $team) {
|
sub on_leave ( $self, $team ) {
|
||||||
require LasTres::Vars;
|
require LasTres::Vars;
|
||||||
for my $member ($team->members) {
|
for my $member ( $team->members ) {
|
||||||
$member->clear_var(LasTres::Vars::LOCATION_TEMPORAL());
|
$member->clear_var( LasTres::Vars::LOCATION_TEMPORAL() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ sub on_pj_moving ( $self, $pj ) {
|
||||||
## DO NOT EXTEND NOT SUPPORTED.
|
## DO NOT EXTEND NOT SUPPORTED.
|
||||||
sub place_team ( $self, $team ) {
|
sub place_team ( $self, $team ) {
|
||||||
$team = $team->get_from_storage;
|
$team = $team->get_from_storage;
|
||||||
if ($self->is_spawn) {
|
if ( $self->is_spawn ) {
|
||||||
$team->last_spawn( $self->to_json_array );
|
$team->last_spawn( $self->to_json_array );
|
||||||
}
|
}
|
||||||
$team->location($self);
|
$team->location($self);
|
||||||
|
@ -253,8 +253,10 @@ sub get_available_locations_to_move_to ( $self, $pj = undef ) {
|
||||||
);
|
);
|
||||||
@$connected_places =
|
@$connected_places =
|
||||||
grep { $_->to_json_array ne $location->to_json_array }
|
grep { $_->to_json_array ne $location->to_json_array }
|
||||||
grep { $_->to_json_array; $_->to_json_array ne to_json(from_json($pj->team->moving_to)) }
|
grep {
|
||||||
@$connected_places;
|
$_->to_json_array;
|
||||||
|
$_->to_json_array ne to_json( from_json( $pj->team->moving_to ) )
|
||||||
|
} @$connected_places;
|
||||||
if ( defined $pj ) {
|
if ( defined $pj ) {
|
||||||
@$connected_places = grep { $_->can_visit($pj) } @$connected_places;
|
@$connected_places = grep { $_->can_visit($pj) } @$connected_places;
|
||||||
}
|
}
|
||||||
|
@ -342,4 +344,16 @@ sub hash ($self) {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
my %instances;
|
||||||
|
|
||||||
|
sub instance {
|
||||||
|
my $class = shift;
|
||||||
|
if ( !defined $instances{$class} ) {
|
||||||
|
$instances{$class} = $class->new(@_);
|
||||||
|
}
|
||||||
|
return $instances{$class};
|
||||||
|
}
|
||||||
|
}
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -10,7 +10,7 @@ use Moo;
|
||||||
|
|
||||||
use LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI;
|
use LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI;
|
||||||
|
|
||||||
with 'LasTres::Location';
|
use parent 'LasTres::Location';
|
||||||
|
|
||||||
sub identifier {
|
sub identifier {
|
||||||
return 'llano';
|
return 'llano';
|
||||||
|
@ -32,13 +32,4 @@ sub connected_places {
|
||||||
LasTres::Planet::Bahdder::BosqueDelHeroe::TribuDeLaLima::Entrada->instance,
|
LasTres::Planet::Bahdder::BosqueDelHeroe::TribuDeLaLima::Entrada->instance,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
my $singleton;
|
|
||||||
sub instance {
|
|
||||||
my $class = shift;
|
|
||||||
if (!defined $singleton) {
|
|
||||||
$singleton = $class->new(@_);
|
|
||||||
}
|
|
||||||
return $singleton;
|
|
||||||
}
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -10,7 +10,7 @@ use Moo;
|
||||||
|
|
||||||
use LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI;
|
use LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI;
|
||||||
|
|
||||||
with 'LasTres::Location';
|
use parent 'LasTres::Location';
|
||||||
|
|
||||||
sub identifier {
|
sub identifier {
|
||||||
return 'tribu_de_la_lima';
|
return 'tribu_de_la_lima';
|
||||||
|
@ -35,13 +35,4 @@ sub connected_places {
|
||||||
LasTres::Planet::Bahdder::BosqueDelHeroe::TribuDeLaLima::Entrada->instance,
|
LasTres::Planet::Bahdder::BosqueDelHeroe::TribuDeLaLima::Entrada->instance,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
my $singleton;
|
|
||||||
sub instance {
|
|
||||||
my $class = shift;
|
|
||||||
if (!defined $singleton) {
|
|
||||||
$singleton = $class->new(@_);
|
|
||||||
}
|
|
||||||
return $singleton;
|
|
||||||
}
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -15,7 +15,7 @@ use LasTres::Planet::Bahdder::BosqueDelHeroe::TribuDeLaLima;
|
||||||
use LasTres::PJAction::GolpearArbolCentralTribuDeLaLima;
|
use LasTres::PJAction::GolpearArbolCentralTribuDeLaLima;
|
||||||
use LasTres::TalkingNPC::AncianoTribuLima;
|
use LasTres::TalkingNPC::AncianoTribuLima;
|
||||||
|
|
||||||
with 'LasTres::Location';
|
use parent 'LasTres::Location';
|
||||||
|
|
||||||
sub identifier {
|
sub identifier {
|
||||||
return 'arbol_central';
|
return 'arbol_central';
|
||||||
|
@ -46,16 +46,6 @@ sub connected_places {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
my $singleton;
|
|
||||||
|
|
||||||
sub instance {
|
|
||||||
my $class = shift;
|
|
||||||
if ( !defined $singleton ) {
|
|
||||||
$singleton = $class->new(@_);
|
|
||||||
}
|
|
||||||
return $singleton;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub is_spawn {
|
sub is_spawn {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ use Moo;
|
||||||
use LasTres::Planet::Bahdder::BosqueDelHeroe::TribuDeLaLima;
|
use LasTres::Planet::Bahdder::BosqueDelHeroe::TribuDeLaLima;
|
||||||
use LasTres::TalkingNPC::VeteranoCalizor;
|
use LasTres::TalkingNPC::VeteranoCalizor;
|
||||||
|
|
||||||
with 'LasTres::Location';
|
use parent 'LasTres::Location';
|
||||||
|
|
||||||
sub identifier {
|
sub identifier {
|
||||||
return 'casa_de_piedra';
|
return 'casa_de_piedra';
|
||||||
|
@ -53,16 +53,6 @@ sub connected_places {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
my $singleton;
|
|
||||||
|
|
||||||
sub instance {
|
|
||||||
my $class = shift;
|
|
||||||
if ( !defined $singleton ) {
|
|
||||||
$singleton = $class->new(@_);
|
|
||||||
}
|
|
||||||
return $singleton;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub is_spawn {
|
sub is_spawn {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,14 @@ use utf8;
|
||||||
use Moo;
|
use Moo;
|
||||||
|
|
||||||
use LasTres::Planet::Bahdder::BosqueDelHeroe::TribuDeLaLima;
|
use LasTres::Planet::Bahdder::BosqueDelHeroe::TribuDeLaLima;
|
||||||
|
use LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI::TribuDeLaLima
|
||||||
|
|
||||||
has parent => (
|
has parent => (
|
||||||
is => 'ro',
|
is => 'ro',
|
||||||
builder => \&_build_parent,
|
builder => \&_build_parent,
|
||||||
);
|
);
|
||||||
|
|
||||||
with 'LasTres::Location';
|
use parent 'LasTres::Location';
|
||||||
|
|
||||||
sub is_spawn {
|
sub is_spawn {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -47,13 +48,4 @@ sub connected_places {
|
||||||
LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI::TribuDeLaLima->instance,
|
LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI::TribuDeLaLima->instance,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
my $singleton;
|
|
||||||
sub instance {
|
|
||||||
my $class = shift;
|
|
||||||
if (!defined $singleton) {
|
|
||||||
$singleton = $class->new(@_);
|
|
||||||
}
|
|
||||||
return $singleton;
|
|
||||||
}
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -15,7 +15,7 @@ use LasTres::Planet::Bahdder::BosqueDelHeroe::TribuDeLaLima;
|
||||||
use LasTres::TalkingNPC::Chaman;
|
use LasTres::TalkingNPC::Chaman;
|
||||||
use LasTres::PJAction::RezarAyazelTribuDeLaLima;
|
use LasTres::PJAction::RezarAyazelTribuDeLaLima;
|
||||||
|
|
||||||
with 'LasTres::Location';
|
use parent 'LasTres::Location';
|
||||||
|
|
||||||
sub identifier {
|
sub identifier {
|
||||||
return 'templo_de_ayazel';
|
return 'templo_de_ayazel';
|
||||||
|
@ -53,16 +53,6 @@ sub connected_places {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
my $singleton;
|
|
||||||
|
|
||||||
sub instance {
|
|
||||||
my $class = shift;
|
|
||||||
if ( !defined $singleton ) {
|
|
||||||
$singleton = $class->new(@_);
|
|
||||||
}
|
|
||||||
return $singleton;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub is_spawn {
|
sub is_spawn {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue