From: Othmar Gsenger Date: Mon, 4 Jul 2011 18:55:11 +0000 (+0000) Subject: added end game, win, lose X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=d96e3a99d81c498c26e7f000a0bd98953fc40e22;p=svn42.git added end game, win, lose --- diff --git a/dart/Dart.pm b/dart/Dart.pm index 2f38988..7352fc2 100644 --- a/dart/Dart.pm +++ b/dart/Dart.pm @@ -177,6 +177,34 @@ sub next_round return $self->callback('next_round'); } +sub win +{ + my $self=shift; + $self->deactivate_current_player($self->{player_count}-$self->{active_player_count}+1); + $self->shout('win'); + if ($self->{active_player_count}==1) + { + $self->next_player(); + $self->lose(); + } elsif (not $self->{active_player_count}) { + $self->end_game(); + } +} + +sub lose +{ + my $self=shift; + $self->deactivate_current_player($self->{active_player_count}); + $self->shout('lose'); + if ($self->{active_player_count}==1) + { + $self->next_player(); + $self->win(); + } elsif (not $self->{active_player_count}) { + $self->end_game(); + } +} + sub deactivate_current_player { my $self=shift; @@ -191,6 +219,7 @@ sub deactivate_current_player sub end_game { my $self=shift; + $self->shout('end_game'); return $self->callback('end_game'); }