Guest User

Jools

a guest
Nov 4th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.35 KB | None | 0 0
  1. package CountDown;
  2.  
  3. use strict;
  4. use Storable qw/store retrieve/;
  5. use SpadsPluginApi;
  6. use Data::Dumper;
  7. use POSIX qw(strftime);
  8. use POSIX;
  9.  
  10. use Scalar::Util qw(looks_like_number);
  11.  
  12. no warnings 'redefine';
  13.  
  14. my $pluginVersion='0.1';
  15. my $requiredSpadsVersion='0.11.2';
  16.  
  17. my %globalPluginParams = (      helpFile        => ['notNull'] );
  18. my %presetPluginParams = (      countDownSeconds    => ['integer','integerRange']);
  19.  
  20. sub getVersion { return $pluginVersion; }
  21. sub getRequiredSpadsVersion { return $requiredSpadsVersion; }
  22. sub getParams { return [\%globalPluginParams,\%presetPluginParams]; }
  23.  
  24. sub new {
  25.   my $class=shift;
  26.   my $self = {};
  27.   bless($self,$class);
  28.      
  29.   slog("Plugin loaded (version $pluginVersion)",3);
  30.  
  31.   return $self;
  32. }
  33.  
  34. sub onUnload {
  35.   my $self=shift;
  36.  
  37.   slog("Plugin unloaded",3);
  38. }
  39.  
  40. sub beforeStart {
  41.     my ($self,$automatic,$force)=@_;
  42.     $automatic = 0 if (!$automatic);
  43.    
  44.     slog("beforeStart: auto = $automatic and force = $force",3);
  45.    
  46.     my $lobby=getLobbyInterface();
  47.  
  48.     # skip processing if battle is closed or spring is running
  49.     return 1 unless(getLobbyState() > 5 && %{$lobby->{battle}} && getSpringPid() == 0);
  50.    
  51.     #fechez la vache
  52.     my $p_conf=getPluginConf();
  53.     my $seconds = $p_conf->{countDownSeconds};
  54.    
  55.     answer("Preparing to launch the game in $seconds seconds...");
  56.     sleep($seconds);
  57.     return 1;
  58. }
  59.  
  60. 1;
Advertisement
Add Comment
Please, Sign In to add comment