projects
/
svn42.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
clear screen works now
[svn42.git]
/
dart
/
Dart.pm
diff --git
a/dart/Dart.pm
b/dart/Dart.pm
index
51f3554
..
ac7775d
100644
(file)
--- a/
dart/Dart.pm
+++ b/
dart/Dart.pm
@@
-3,6
+3,10
@@
package Dart;
use strict;
use base 'Exporter';
use Clone;
use strict;
use base 'Exporter';
use Clone;
+use POSIX;
+use Term::Cap;
+use FileHandle;
+
# new Dart(player_names=>[ 'lala', 'popo' ]);
## Player, Rank, Active,
# new Dart(player_names=>[ 'lala', 'popo' ]);
## Player, Rank, Active,
@@
-20,6
+24,13
@@
sub new
$self->add_player(&create_player(name=>$player_name,rank=>undef,active=>1));
}
$self->{callbacks}=$params{callbacks};
$self->add_player(&create_player(name=>$player_name,rank=>undef,active=>1));
}
$self->{callbacks}=$params{callbacks};
+
+ open($self->{shout_fifo}, '>>', $params{shout_fifo}) or die $!;
+ $self->{shout_fifo}->autoflush(1);
+
+ my $termios = new POSIX::Termios;
+ $termios->getattr;
+ $self->{term} = Term::Cap->Tgetent( { OSPEED => $termios->getospeed } );
$self->init();
return $self;
}
$self->init();
return $self;
}
@@
-83,19
+94,14
@@
sub callback
sub run
{
my $self=shift;
sub run
{
my $self=shift;
- my ($data_in_fh,$sound_out_fh)=@_;
my @history;
my @history;
-# $data_in_fh ||= STDIN;
-# $sound_out_fh ||= STDOUT;
- $self->{sound_out_fh}=$sound_out_fh;
push @history, Clone::clone($self);
push @history, Clone::clone($self);
- print "\033[2J";
+ my $STDOUT = new FileHandle '>-';
+ $self->{term}->Tputs('cl', 1, $STDOUT);
$self->callback('before_shoot');
$self->callback('before_shoot');
- #while ( my $shoot_data = <$data_in_fh>)
while ( my $shoot_data = <STDIN>)
{
while ( my $shoot_data = <STDIN>)
{
- #print STDERR $schuss;
my ($mult,$number) = split /\s+/, $shoot_data;
if ($mult =~/^\d$/)
my ($mult,$number) = split /\s+/, $shoot_data;
if ($mult =~/^\d$/)
@@
-118,7
+124,7
@@
sub run
next;
}
push @history, Clone::clone($self);
next;
}
push @history, Clone::clone($self);
- print "\033[2J";
+ $self->{term}->Tputs('cl', 1, $STDOUT);
$self->callback('before_shoot');
}
}
$self->callback('before_shoot');
}
}
@@
-178,14
+184,13
@@
sub shout
{
my $self=shift;
my ($what)=@_;
{
my $self=shift;
my ($what)=@_;
- my $fh = $self->{sound_out_fh};
+ my $fh = $self->{shout_fifo};
if ($what eq 25)
{
if ($what eq 25)
{
- print "bull\n";
+ print $fh "bull\n";
} else {
} else {
- print "$what\n";
+ print $fh "$what\n";
}
}
-#print $fh "$what\n";
}
sub get_current_player
}
sub get_current_player