added new cricket allstar
authorOthmar Gsenger <otti@realraum.at>
Thu, 30 Jun 2011 21:08:24 +0000 (21:08 +0000)
committerOthmar Gsenger <otti@realraum.at>
Thu, 30 Jun 2011 21:08:24 +0000 (21:08 +0000)
dart/dart-fullcricket.pl [new file with mode: 0755]

diff --git a/dart/dart-fullcricket.pl b/dart/dart-fullcricket.pl
new file mode 100755 (executable)
index 0000000..38eb707
--- /dev/null
@@ -0,0 +1,77 @@
+#!/usr/bin/perl
+use strict;
+use POSIX;
+use Term::Cap;
+# General terminal line I/O
+my $termios = new POSIX::Termios;
+$termios->getattr;
+my $term = Term::Cap->Tgetent( { OSPEED => $termios->getospeed } );
+
+
+
+# Extract the entry of the terminal type
+
+# clear
+
+my (@player) = @ARGV;
+
+my $numplayer = @player;
+
+my %score;
+my $current_player=1;
+while ( my $schuss = <STDIN>)
+{
+  print $schuss;
+       my ($mult,$zahl) = split /\s+/, $schuss;
+   
+  if ($mult =~/^\d$/)
+       {
+    while($mult--)
+               {
+                       if ($score{$current_player}{$zahl}<3)
+                       {
+                               $score{$current_player}{$zahl}++;
+                       } else {
+                               for my $playernum (1..$numplayer)
+                               {
+                                       if ($score{$playernum}{$zahl}<3)
+                                       {
+                                               $score{$playernum}{0}+=$zahl;
+                                               print "score\n";
+                                       }
+                               }
+                       }
+               }
+       } else {
+    $current_player++;
+    $current_player=1 if $current_player > $numplayer;
+       }
+       print_score();
+}
+
+
+
+sub print_score
+{
+# $term->Tputs('cl', 1, <STDERR>);
+                               for my $playernum (1..$numplayer)
+                               {
+
+                                                               printf STDERR "%s\t", ($playernum == $current_player)?"(".$player[$playernum-1].")":$player[$playernum-1];
+                               }
+                               print STDERR "\n";
+                               for my $i (1..21)
+                               {
+                                                               for my $playernum (1..$numplayer)
+                                                               {
+                                                                                               my $zahl = $i>20?25:$i;
+                                                                                               printf STDERR ("%2d %s    ",$zahl, '#' x $score{$playernum}{$zahl}. '-' x (3-$score{$playernum}{$zahl}));
+                                                               }
+                                                               print STDERR "\n";
+                               }
+                               for my $playernum (1..$numplayer)
+                               {
+
+                                                               printf STDERR ("%3d\t", $score{$playernum}{0});
+                               }
+}