Announcements

 view release on metacpan or  search on metacpan

lib/Announcements.pm  view on Meta::CPAN

    $character->add_subscription(
        criterion => 'NetHack::Announcement::Teleporting',
        action    => sub {
            my ($announcement, $character) = @_;
            $character->has_ever_teleported(1);
        },
    );

=head2 Communication

Teleports always send you to a random spot on the map. But say you want
to implement an artifact that grants teleport control. If the character
is holding this artifact and is teleported, then the player can pick
the teleport's destination.

    package NetHack::Item::MasterKeyOfThievery;
    use Moose;
    with 'NetHack::Item::Artifact';

    sub 

Some levels in our game forbid teleportation for various reasons. Let's
say we want to implement that behavior as an announcement to avoid
polluting the character's teleport method with "are we on a level
that blocks teleportation?" logic.

    package NetHack::Announcement::Teleporting;
    use Moose;

    has current_x => (is => 'ro', isa => 'Num', required => 1);
    has current_y => (is => 'ro', isa => 'Num', required => 1);

    has new_x     => (is => 'rw', isa => 'Num', default => sub { rand() });



( run in 2.284 seconds using v1.01-cache-2.11-cpan-b301d465b3d )