Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.28 KB | None | 0 0
  1. #pyramid feature for fit races
  2. #e.g. .setgoal 40 pushups; .sets 4 pyramid
  3. #display set sequence at start of race
  4. #Set 1 - 40 pushups
  5. #Set 2 - 30 pushups
  6. #Set 3 - 20 pushups
  7. #Set 4 - 10 pushups
  8.  
  9. #first add new global variable - pyramid flag
  10. our $pyramid = 0;
  11.  
  12. #activated by command '.sets <number> pyramid'
  13. elsif ($command eq 'sets')
  14. {
  15.     my @setbreakup = split(/ /, $extra,2);
  16.     my $setnumber = @setbreakup[0];
  17.     my $setworkout = @setbreakup[1];
  18.    
  19.     if (int($setnumber) == 1)
  20.     {
  21.         $inrace = 1;
  22.         $rest = 0;
  23.         $sets = int($setnumber);
  24.         $bot->say(
  25.         channel => "$channel",
  26.         body => "$sets set.");
  27.         return;
  28.     }
  29.  
  30.     elsif (int($setnumber) > 1 && int($setnumber) <= 10)
  31.     {
  32.         if ($rest == 0)
  33.         {
  34.             $rest = 10;
  35.         }
  36.        
  37.         #check for pyramid style race
  38.         if ($setworkout eq 'pyramid')
  39.         {
  40.        
  41.             #sets must equally divide into amount
  42.             if (($amount % $setnumber) != 0)
  43.             {
  44.                 $bot->say(
  45.                 channel => "$channel",
  46.                 body => "Sets must equally divide into number of reps for pyramid race");
  47.                 return;
  48.             }
  49.            
  50.             else
  51.             {
  52.                 #set pyramid flag
  53.                 $pyramid = 1;
  54.             }
  55.         }
  56.        
  57.         $inrace = 4;
  58.         $sets = int($setnumber);
  59.         $bot->say(
  60.         channel => "$channel",
  61.         body => "$sets sets - $rest second rest per set.");
  62.         return;
  63.     }
  64.    
  65.     else
  66.     {
  67.         $bot->say(
  68.         channel => "$channel",
  69.         body => "Sets must be a valid number between 1-10.");
  70.         return;
  71.     }
  72.    
  73. }
  74.  
  75. #then display the set sequence of pushups at start of race
  76. sub startRace {
  77.    
  78.     #if pyramid race
  79.     if ($pyramid == 1)
  80.     {
  81.         $inrace = 5;
  82.         $bot->say(
  83.         channel => "$channel",
  84.         body => "Pyramid $workout! $rest second rest per set. Sets are as follows:");
  85.        
  86.         #first set is normal
  87.         $bot->say(
  88.         channel => "$channel",
  89.         body => "Set 1: $amount $workout");
  90.        
  91.         #display amounts for each remaining set
  92.         my $displaySets = 2;   
  93.         my $setDiff = $amount/$sets;    #difference in amount for each set after 1
  94.         while ($displaySets < $sets) {
  95.             $bot->say(
  96.             channel => "$channel",
  97.             body => "Set $displaySets: ($setDiff*($displaySets-1)) $workout");
  98.             $displaySets++;
  99.         }
  100.     }
  101.    
  102.     #if normal multi race
  103.     elsif ($inrace == 4 && $sets > 1)
  104.     {
  105.     $inrace = 5;
  106.     $bot->say(
  107.     channel => "$channel",
  108.     body => "Race starting in 5 seconds - $sets sets of $amount $workout - $rest second rest per set.");
  109.  
  110.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement