added eet and new start-dart
[svn42.git] / dart / dart-fullcricket.pl
index fc20658..1823624 100755 (executable)
@@ -6,10 +6,12 @@ use strict;
 #my $termios = new POSIX::Termios;
 #$termios->getattr;
 #my $term = Term::Cap->Tgetent( { OSPEED => $termios->getospeed } );
+my $sieb=1;
+my @prim = qw / 2 3 5 7 11 13 17 19 /;
 
 sub gueltig{
     my ($zahl,$mult) = @_;
-    return $zahl<6 || $zahl>20;
+    return $zahl>1;
   };
 
 
@@ -44,7 +46,18 @@ while ( my $schuss = <STDIN>)
       if ($score{$current_player}{$zahl}<3)
       {
         $score{$current_player}{$zahl}++;
-        $self_scored;
+        $self_scored++;
+        if ($sieb && ($score{$current_player}{$zahl} == 3))
+        {
+          for my $count (2..21)
+          {
+            $count = 25 if $count ==21;
+            if ( ($count % $zahl) == 0)
+            {
+              $score{$current_player}{$count} = 3;
+            }
+          }
+        }
       } else {
         $scho++;
         for my $playernum (1..$numplayer)
@@ -57,9 +70,9 @@ while ( my $schuss = <STDIN>)
         }
       }
     }
-    print $schuss if ($scored || $scho || $self_scored);
+    print $schuss if ($scored || $self_scored);
     print "scored\n" if $scored;
-    print "scho\n" if $scho;
+    print "scho\n" if $scho && not $scored;
   } elsif ($mult eq 'btn') {
     print $schuss;
     $current_player++;
@@ -89,8 +102,8 @@ sub print_score
   {
     for my $playernum (1..$numplayer)
     {
-      next if not gueltig($i);
       my $zahl = $i>20?25:$i;
+      next if not gueltig($zahl);
       printf STDERR ("%2d %s    ",$zahl, '#' x $score{$playernum}{$zahl}. '-' x (3-$score{$playernum}{$zahl}));
     }
     print STDERR "\n";