highscore
This commit is contained in:
parent
bea4b482b0
commit
bc103a242a
2 changed files with 19 additions and 1 deletions
19
plugins/game
19
plugins/game
|
@ -8,13 +8,18 @@ use Time::HiRes qw( gettimeofday tv_interval);
|
||||||
|
|
||||||
HELP "game" => "Scan-foo game!";
|
HELP "game" => "Scan-foo game!";
|
||||||
|
|
||||||
|
my $fastest=1000;
|
||||||
|
my $fastest_name="nobody";
|
||||||
|
|
||||||
sub command :Tab(game) {
|
sub command :Tab(game) {
|
||||||
|
|
||||||
my ($self, $cart, $command) = @_;
|
my ($self, $cart, $command) = @_;
|
||||||
|
|
||||||
return NEXT if $command !~ /^(?:game)$/;
|
return NEXT if $command !~ /^(?:game)$/;
|
||||||
|
|
||||||
print "\nWelcome to SCAN-FOO \\o/\n";
|
print "\nWelcome to SCAN-FOO \\o/\n";
|
||||||
|
|
||||||
|
print "\nRecord time is $fastest by $fastest_name\n";
|
||||||
|
|
||||||
my $start_time=[gettimeofday];
|
my $start_time=[gettimeofday];
|
||||||
|
|
||||||
|
@ -32,7 +37,19 @@ sub command :Tab(game) {
|
||||||
|
|
||||||
my $elapsed = tv_interval ( $start_time, [gettimeofday]);
|
my $elapsed = tv_interval ( $start_time, [gettimeofday]);
|
||||||
|
|
||||||
print "COMPLETED in $elapsed seconds *tadaah*\n";
|
print "Completed in $elapsed seconds *tadaah*\n";
|
||||||
|
|
||||||
|
if ($elapsed < $fastest)
|
||||||
|
{
|
||||||
|
print " #####################\n";
|
||||||
|
print " #### NEW RECORD! ####\n";
|
||||||
|
print " #####################\n";
|
||||||
|
print " You did it in $elapsed !!!\n";
|
||||||
|
|
||||||
|
print "Enter your name: ";
|
||||||
|
$fastest_name=<STDIN>;
|
||||||
|
$fastest=$elapsed;
|
||||||
|
}
|
||||||
|
|
||||||
return ACCEPT;
|
return ACCEPT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ stock
|
||||||
|
|
||||||
beep_terminal
|
beep_terminal
|
||||||
|
|
||||||
|
game # Scan-foo game
|
||||||
|
|
||||||
# Then, plugins that apply heuristics
|
# Then, plugins that apply heuristics
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue