added startdart script and modes soundonly, nocheckcrickte
authorrealraum <realraum@realraum.at>
Sat, 2 Jul 2011 19:13:40 +0000 (19:13 +0000)
committerrealraum <realraum@realraum.at>
Sat, 2 Jul 2011 19:13:40 +0000 (19:13 +0000)
dart/dart-nochecricket.pl [new file with mode: 0755]
dart/dart-soundonly.pl [new file with mode: 0755]
dart/start-dart.sh [new file with mode: 0755]

diff --git a/dart/dart-nochecricket.pl b/dart/dart-nochecricket.pl
new file mode 100755 (executable)
index 0000000..5e8b897
--- /dev/null
@@ -0,0 +1,100 @@
+#!/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 $round =0;
+my %score;
+my $unlock=6;
+my $unlock_mult=1;
+my $current_player=1;
+my $last_shot=6;
+my $last_shot_mult=1;
+while ( my $schuss = <STDIN>)
+{
+  print $schuss;
+       my ($mult,$zahl) = split /\s+/, $schuss;
+   
+  if ($mult =~/^\d$/)
+       {
+ $last_shot=$zahl;
+ $last_shot_mult=$mult;
+               if ($unlock == $zahl && $unlock_mult== $mult)
+               {
+                       $unlock =0;
+                       $unlock_mult=0;
+               }
+         if($zahl >14 && $zahl <21 && ! $unlock)
+               {
+                       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++;
+    $round++ if $current_player > $numplayer;
+    $current_player=1 if $current_player > $numplayer;
+               if (!$unlock)
+               {
+                 $unlock=$last_shot;
+                 $unlock_mult=$last_shot_mult;
+                       }
+       }
+       print_score($schuss);
+}
+
+
+
+sub print_score
+{
+ my ($schuss) =@_;
+# $term->Tputs('cl', 1, <STDERR>);
+ printf STDERR "\n\n";
+ printf STDERR "$schuss $unlock_mult x $unlock Runde\t$round\n\n";
+                               for my $playernum (1..$numplayer)
+                               {
+
+                                                               printf STDERR "%s\t", ($playernum == $current_player)?"(".$player[$playernum-1].")":$player[$playernum-1];
+                               }
+                               print STDERR "\n";
+                               for my $i (15..20)
+                               {
+                                                               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});
+                               }
+}
diff --git a/dart/dart-soundonly.pl b/dart/dart-soundonly.pl
new file mode 100755 (executable)
index 0000000..83c2d85
--- /dev/null
@@ -0,0 +1,34 @@
+#!/usr/bin/perl -T -w
+use strict;
+$ENV{PATH}='';
+$| = 1;
+&main();
+exit 0;
+
+sub main
+{
+  while (my $schuss = <STDIN>)
+  {
+    chomp $schuss;
+               
+    my ($mult,$zahl)=split /\s+/,$schuss or next;
+
+    if ($mult==2)
+    {
+      print "double\n";
+    } elsif ($mult==3) {
+      print "triple\n";
+    } elsif ($mult eq "btn") {
+      print "player\n";
+      next;
+    }
+    ($zahl) = $zahl =~ m/(\d+)/;
+    if ($zahl >0 && $zahl < 21)
+    {
+      print $zahl . "\n";
+    } else {
+      print "bull\n";
+    }
+  } 
+}
+
diff --git a/dart/start-dart.sh b/dart/start-dart.sh
new file mode 100755 (executable)
index 0000000..006d0a1
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+if [ -z "$1" ]; then
+  echo "Usage $0 <mode>"
+  exit 1
+fi
+
+mode=$1
+
+ssh dart stty -F /dev/ttyDart 57600
+ssh dart cat /dev/ttyDart | ./dart-$mode.pl | ../dart-sounds/src/dart-sounds ../dart-sounds/media