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
|
||||
# this location, must return hashref,
|
||||
# can be an empty one though.
|
||||
sub actions($self, $pj) {
|
||||
sub actions ( $self, $pj ) {
|
||||
return [];
|
||||
}
|
||||
## OVERRIDE
|
||||
# The available persons to talk with
|
||||
# Must return a hashref, can be a empty
|
||||
# one though.
|
||||
sub npcs($self, $pj) {
|
||||
sub npcs ( $self, $pj ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -75,20 +75,20 @@ sub order ($self) {
|
|||
}
|
||||
|
||||
## 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
|
||||
# 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
|
||||
# action may appear as disabled.
|
||||
sub is_spawn($self) {
|
||||
sub is_spawn ($self) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
## OVERRIDE
|
||||
# Return object should ideally extend LasTres::PJAction::DefaultHeal
|
||||
# following the advice in this file.
|
||||
sub healing_action($self) {
|
||||
if ($self->is_spawn) {
|
||||
sub healing_action ($self) {
|
||||
if ( $self->is_spawn ) {
|
||||
require LasTres::PJAction::DefaultHeal;
|
||||
return LasTres::PJAction::DefaultHeal->new;
|
||||
}
|
||||
|
@ -136,10 +136,10 @@ sub show_intro ( $self, $pj ) {
|
|||
}
|
||||
|
||||
## OVERRIDE (Always use $self->SUPER)
|
||||
sub on_leave($self, $team) {
|
||||
sub on_leave ( $self, $team ) {
|
||||
require LasTres::Vars;
|
||||
for my $member ($team->members) {
|
||||
$member->clear_var(LasTres::Vars::LOCATION_TEMPORAL());
|
||||
for my $member ( $team->members ) {
|
||||
$member->clear_var( LasTres::Vars::LOCATION_TEMPORAL() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ sub on_pj_moving ( $self, $pj ) {
|
|||
## DO NOT EXTEND NOT SUPPORTED.
|
||||
sub place_team ( $self, $team ) {
|
||||
$team = $team->get_from_storage;
|
||||
if ($self->is_spawn) {
|
||||
if ( $self->is_spawn ) {
|
||||
$team->last_spawn( $self->to_json_array );
|
||||
}
|
||||
$team->location($self);
|
||||
|
@ -253,8 +253,10 @@ sub get_available_locations_to_move_to ( $self, $pj = undef ) {
|
|||
);
|
||||
@$connected_places =
|
||||
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)) }
|
||||
@$connected_places;
|
||||
grep {
|
||||
$_->to_json_array;
|
||||
$_->to_json_array ne to_json( from_json( $pj->team->moving_to ) )
|
||||
} @$connected_places;
|
||||
if ( defined $pj ) {
|
||||
@$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;
|
||||
|
|
|
@ -10,7 +10,7 @@ use Moo;
|
|||
|
||||
use LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI;
|
||||
|
||||
with 'LasTres::Location';
|
||||
use parent 'LasTres::Location';
|
||||
|
||||
sub identifier {
|
||||
return 'llano';
|
||||
|
@ -32,13 +32,4 @@ sub connected_places {
|
|||
LasTres::Planet::Bahdder::BosqueDelHeroe::TribuDeLaLima::Entrada->instance,
|
||||
];
|
||||
}
|
||||
|
||||
my $singleton;
|
||||
sub instance {
|
||||
my $class = shift;
|
||||
if (!defined $singleton) {
|
||||
$singleton = $class->new(@_);
|
||||
}
|
||||
return $singleton;
|
||||
}
|
||||
1;
|
||||
|
|
|
@ -10,7 +10,7 @@ use Moo;
|
|||
|
||||
use LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI;
|
||||
|
||||
with 'LasTres::Location';
|
||||
use parent 'LasTres::Location';
|
||||
|
||||
sub identifier {
|
||||
return 'tribu_de_la_lima';
|
||||
|
@ -35,13 +35,4 @@ sub connected_places {
|
|||
LasTres::Planet::Bahdder::BosqueDelHeroe::TribuDeLaLima::Entrada->instance,
|
||||
];
|
||||
}
|
||||
|
||||
my $singleton;
|
||||
sub instance {
|
||||
my $class = shift;
|
||||
if (!defined $singleton) {
|
||||
$singleton = $class->new(@_);
|
||||
}
|
||||
return $singleton;
|
||||
}
|
||||
1;
|
||||
|
|
|
@ -15,7 +15,7 @@ use LasTres::Planet::Bahdder::BosqueDelHeroe::TribuDeLaLima;
|
|||
use LasTres::PJAction::GolpearArbolCentralTribuDeLaLima;
|
||||
use LasTres::TalkingNPC::AncianoTribuLima;
|
||||
|
||||
with 'LasTres::Location';
|
||||
use parent 'LasTres::Location';
|
||||
|
||||
sub identifier {
|
||||
return 'arbol_central';
|
||||
|
@ -46,16 +46,6 @@ sub connected_places {
|
|||
return [];
|
||||
}
|
||||
|
||||
my $singleton;
|
||||
|
||||
sub instance {
|
||||
my $class = shift;
|
||||
if ( !defined $singleton ) {
|
||||
$singleton = $class->new(@_);
|
||||
}
|
||||
return $singleton;
|
||||
}
|
||||
|
||||
sub is_spawn {
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ use Moo;
|
|||
use LasTres::Planet::Bahdder::BosqueDelHeroe::TribuDeLaLima;
|
||||
use LasTres::TalkingNPC::VeteranoCalizor;
|
||||
|
||||
with 'LasTres::Location';
|
||||
use parent 'LasTres::Location';
|
||||
|
||||
sub identifier {
|
||||
return 'casa_de_piedra';
|
||||
|
@ -53,16 +53,6 @@ sub connected_places {
|
|||
return [];
|
||||
}
|
||||
|
||||
my $singleton;
|
||||
|
||||
sub instance {
|
||||
my $class = shift;
|
||||
if ( !defined $singleton ) {
|
||||
$singleton = $class->new(@_);
|
||||
}
|
||||
return $singleton;
|
||||
}
|
||||
|
||||
sub is_spawn {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -12,13 +12,14 @@ use utf8;
|
|||
use Moo;
|
||||
|
||||
use LasTres::Planet::Bahdder::BosqueDelHeroe::TribuDeLaLima;
|
||||
use LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI::TribuDeLaLima
|
||||
|
||||
has parent => (
|
||||
is => 'ro',
|
||||
builder => \&_build_parent,
|
||||
);
|
||||
|
||||
with 'LasTres::Location';
|
||||
use parent 'LasTres::Location';
|
||||
|
||||
sub is_spawn {
|
||||
return 0;
|
||||
|
@ -47,13 +48,4 @@ sub connected_places {
|
|||
LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI::TribuDeLaLima->instance,
|
||||
];
|
||||
}
|
||||
|
||||
my $singleton;
|
||||
sub instance {
|
||||
my $class = shift;
|
||||
if (!defined $singleton) {
|
||||
$singleton = $class->new(@_);
|
||||
}
|
||||
return $singleton;
|
||||
}
|
||||
1;
|
||||
|
|
|
@ -15,7 +15,7 @@ use LasTres::Planet::Bahdder::BosqueDelHeroe::TribuDeLaLima;
|
|||
use LasTres::TalkingNPC::Chaman;
|
||||
use LasTres::PJAction::RezarAyazelTribuDeLaLima;
|
||||
|
||||
with 'LasTres::Location';
|
||||
use parent 'LasTres::Location';
|
||||
|
||||
sub identifier {
|
||||
return 'templo_de_ayazel';
|
||||
|
@ -53,16 +53,6 @@ sub connected_places {
|
|||
return [];
|
||||
}
|
||||
|
||||
my $singleton;
|
||||
|
||||
sub instance {
|
||||
my $class = shift;
|
||||
if ( !defined $singleton ) {
|
||||
$singleton = $class->new(@_);
|
||||
}
|
||||
return $singleton;
|
||||
}
|
||||
|
||||
sub is_spawn {
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue