added undo in perl framework
[svn42.git] / dart / dart-cricket.pl
index b026b04..91431d9 100755 (executable)
@@ -1,7 +1,8 @@
 #!/usr/bin/perl
-# use strict;
+use strict;
 use Dart;
 
+our $sieb =1; # Spielmodus Zahlensieb
 
 
 $|=1;
@@ -11,13 +12,13 @@ my $dart = new Dart(player_names=>\@player,
                     callbacks => {
                       shoot=>\&shoot,   
                       next_player=>\&next_player,
+                      before_shoot=>\&print_score,
                     }
                   );
-exit $dart->run(STDIN,STDOUT);
+exit $dart->run();
 
 ### ===============================
 
-my $sieb =1; # Spielmodus Zahlensieb
 sub gueltig
 {
   my ($zahl,$mult) = @_;
@@ -44,7 +45,7 @@ sub shoot
     {
       $score->{$zahl}++;
       $self_scored++;
-      if ($sieb && ($score->{$zahl} == 3))
+      if ($main::sieb && ($score->{$zahl} == 3))
       {
         for my $count (2..21)
         {
@@ -71,13 +72,11 @@ sub shoot
   $self->shout_last_shoot() if ($scored || $self_scored);
   $self->shout("scored") if $scored;
   $self->shout("scho") if $scho && not $scored;
-  &print_score($self);
 }
 
 sub next_player
 {
   my $self=shift;
-  &print_score($self);
 }
 
 sub print_score