X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=dart%2FDart.pm;h=d9b37954dd1272c2a89bd6a3ef494b710fc31c68;hb=0e5aa9dd0b200a8bd5d9b886debfd9b44c451b0f;hp=ebb36bb1831a904d6b1818a05c89f67b5ff72fe5;hpb=fd324a0bfe9ee3b2a2b0ddcb89b39986071b6215;p=svn42.git diff --git a/dart/Dart.pm b/dart/Dart.pm index ebb36bb..d9b3795 100644 --- a/dart/Dart.pm +++ b/dart/Dart.pm @@ -25,6 +25,18 @@ sub new } +sub get_color +{ + my $self=shift; + my ($mul,$zahl)=@_; + my @zahlen = qw/20 1 18 4 13 6 10 15 2 17 3 19 7 16 8 11 14 9 12 5/; + my $counter=0; + $counter++ while($zahl != shift @zahlen and @zahlen); + $mul=0 if $mul >1; + my $result = ($counter+$mul )%2; + return $result; +} + sub init { my $self=shift; @@ -81,6 +93,7 @@ sub run if ($mult =~/^\d$/) { die "Unexpected input" if not $number=~/^\d+$/; + next if not $self->{current_shoot_count} < $self->{max_shoots_per_player}; $self->shoot($mult,$number); } elsif ($mult eq 'btn') { $self->next_player(); @@ -92,6 +105,9 @@ sub run $self->reset_game(); } elsif ($mult eq 'quit') { return; + } else { + # shitty input + next; } push @history, Clone::clone($self); $self->callback('before_shoot'); @@ -209,7 +225,8 @@ sub win if ($self->{active_player_count}==1) { $self->next_player(); - $self->lose(); + $self->shout('lose'); + $self->deactivate_current_player($self->{player_count}-$self->{active_player_count}+1); } } @@ -221,7 +238,8 @@ sub lose if ($self->{active_player_count}==1) { $self->next_player(); - $self->win(); + $self->shout('win'); + $self->deactivate_current_player($self->{active_player_count}); } }