X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=dart%2Fdart-red-x01.pl;h=af4491c50738441f10d3d7c537d096980a1c10ff;hb=f505a1c37ea1c76897991f9882de765e34f0cc98;hp=56b4cb28a3e75178dbbd90c71b2cecd0fd03b985;hpb=0e5aa9dd0b200a8bd5d9b886debfd9b44c451b0f;p=svn42.git diff --git a/dart/dart-red-x01.pl b/dart/dart-red-x01.pl index 56b4cb2..af4491c 100755 --- a/dart/dart-red-x01.pl +++ b/dart/dart-red-x01.pl @@ -13,8 +13,10 @@ my $dart = new Dart(player_names=>\@player, next_player=>\&next_player, before_shoot=>\&print_score, init=>\&init, + end_game=>\&Dart::plot_trace_shoot, } ); +$dart->trace_shoot('score'); exit $dart->run(); ### =============================== @@ -22,7 +24,6 @@ exit $dart->run(); sub init { my $self=shift; - for my $player_idx (0..($self->{player_count}-1)) { $self->get_player($player_idx)->{score} = $maxScore; @@ -39,19 +40,16 @@ sub shoot { my $self=shift; my ($mult,$zahl)=@_; - my $color = $self->get_color($mult,$zahl)?1:-1; - if ($self->get_current_player()->{score} >= $mult * $zahl) - { - $self->get_current_player()->{score} -= $color *$mult * $zahl; - $self->shout_last_shoot(); - $self->win() if &win_condition($self); - } - else + my $color = $self->get_color($mult,$zahl)?1:-1; + if ($color <0) { - $self->shout("miss"); - $self->get_current_player()->{score} = $self->get_current_player()->{last_score}; - $self->finish_player_round(); + $self->shout("plus"); + }else{ + $self->shout("minus"); } + $self->get_current_player()->{score} -= $color *$mult * $zahl; + $self->shout_last_shoot(); + $self->win() if &win_condition($self); } sub next_player