Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse altar alignment from the floor message #118

Open
doy opened this issue Dec 25, 2013 · 3 comments
Open

parse altar alignment from the floor message #118

doy opened this issue Dec 25, 2013 · 3 comments

Comments

@doy
Copy link
Member

doy commented Dec 25, 2013

See TAEB/TAEB-AI-Behavioral#77.

@seankelly
Copy link
Member

There is an announcement for it:

    [
        qr/^There is an altar to [\w\- ]+ \((law|neu|cha|unaligned)\w*\) here\./ =>
            ['dungeon_feature' => sub { ucfirst($1) .' altar' } ],
    ],

This appears to affect the tile properly:

<T9318> 2013-12-24 12:13:01 [DEBUG:publisher] Announcing dungeon_feature with arguments Law altar.
<T9318> 2013-12-24 12:13:01 [DEBUG:cartographer] msg_dungeon_feature('Law altar') caused the current tile to be updated from ('@', 'obscured') to ('_', 'altar')
<T9318> 2013-12-24 12:13:01 [DEBUG:publisher] Announcing tile_type_change with arguments TAEB::Announcement::Dungeon::Tile::TypeChange=HASH(0x80cfc5018).
<T9318> 2013-12-24 12:13:01 [DEBUG:moose] Reblessing a TAEB::World::Tile into TAEB::World::Tile::Altar.
<T9318> 2013-12-24 12:13:01 [DEBUG:publisher] Announcing check with arguments tile [TAEB::World::Tile::Altar: (47,5) Altar t=altar g<@> i< > f<_> i=9].

@seankelly
Copy link
Member

From the msg_dungeon_feature method:

    elsif ($feature =~ /\baltar$/) {
        $floor = '_';
        $type = 'altar';
        $subtype = shift;
    }
    ...
    $tile->change_type($type => $floor, $subtype);

But change_type doesn't do anything with the subtype:

sub change_type {
    my $self     = shift;
    my $newtype  = shift;
    my $newglyph = shift;

(No other shifts in the method.)

So, the message is parsed but the alignment is lost.

@seankelly
Copy link
Member

Wait. The change_type method ends with:

    $self->rebless("TAEB::World::Tile::\L\u$newtype", @_);

Going to Altar->rebless:

sub reblessed {
    my $self = shift;
    my ($old_class, $align) = @_;

    if ($align) {
        $self->align($align);
        return;
    }

    TAEB->send_message(check => tile => $self);
}

So, maybe the alignment isn't lost?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants