Skip to content

Commit

Permalink
rearranged Tile to move ::Card class below ::Ownable subclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
jberger committed Nov 22, 2011
1 parent 042706a commit e5145bf
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions lib/Opoly/Board/Tile.pm
Expand Up @@ -178,33 +178,6 @@ class Opoly::Board::Tile::Property

}

class Opoly::Board::Tile::Card
extends Opoly::Board::Tile {

has 'deck' => ( isa => 'Opoly::Deck', is => 'ro', required => 1);
has 'game' => ( isa => 'Opoly', is => 'rw' ); #TODO make required once

augment arrive (Opoly::Player $player) {
my $card = $self->deck->draw;
my @args = $player;
my $others = $card->others;

$self->game->ui->inform( '---- ' . $card->text . "\n" );
my $action = $card->action;

if ($others eq 'all') {
push @args, @{ $self->game->players };
} elsif (ref $others eq 'CODE') {
push @args, grep { $others->($_) } @{ $self->game->players };
}

$action->args( \@args );

return $action;
}

}

class Opoly::Board::Tile::Railroad
extends Opoly::Board::Tile::Ownable {

Expand Down Expand Up @@ -256,6 +229,33 @@ class Opoly::Board::Tile::Utility

}

class Opoly::Board::Tile::Card
extends Opoly::Board::Tile {

has 'deck' => ( isa => 'Opoly::Deck', is => 'ro', required => 1);
has 'game' => ( isa => 'Opoly', is => 'rw' ); #TODO make required once

augment arrive (Opoly::Player $player) {
my $card = $self->deck->draw;
my @args = $player;
my $others = $card->others;

$self->game->ui->inform( '---- ' . $card->text . "\n" );
my $action = $card->action;

if ($others eq 'all') {
push @args, @{ $self->game->players };
} elsif (ref $others eq 'CODE') {
push @args, grep { $others->($_) } @{ $self->game->players };
}

$action->args( \@args );

return $action;
}

}

class Opoly::Board::Tile::Arrest
extends Opoly::Board::Tile {

Expand Down

0 comments on commit e5145bf

Please sign in to comment.