PsyOps

PrizeOps

May 14th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.13 KB | None | 0 0
  1. package twcore.bots.battlebot.PublicOps;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.Random;
  6.  
  7. import twcore.core.BotAction;
  8.  
  9. public class PrizeOps {
  10.     enum PublicPrizes
  11.     {
  12.         Super("*prize #17",2),
  13.         Shields("*prize #18",2),
  14.         Repel("*prize #21",20),
  15.         Burst("*prize #22",18),
  16.         Decoy("*prize #23",30),
  17.         Thor("*prize #24",20),
  18.         Brick("*prize #26",8),
  19.         Rocket("*prize #27",20);
  20.         private String command;
  21.         private int weight;
  22.         private PublicPrizes(String command, int weight)
  23.         {
  24.             this.command = command;
  25.             this.weight = weight;
  26.         }
  27.     }
  28.    
  29.     // MasterList of all prizes
  30.     private List<PublicPrizes> m_Prizes = new ArrayList<PublicPrizes>();
  31.     // % chance of getting a prize
  32.     private int m_Chance = 50;
  33.     // For random numbers
  34.     Random ran = new Random();
  35.  
  36.     // Loading prizes into a master list by their weights
  37.     // to try and get a more random prize we load the first half of weights, then again
  38.     // Then we will pull out a random prize by choosing between 1 and list.length()
  39.     public void LoadPrizes()
  40.     {
  41.         for ( int i = 0; i < 2; i+=1)
  42.         {
  43.             for ( int j = 0; j < PublicPrizes.Super.weight/2 ; j+=1)
  44.                 m_Prizes.add(PublicPrizes.Super);
  45.             for ( int j = 0; j < PublicPrizes.Shields.weight/2 ; j+=1)
  46.                 m_Prizes.add(PublicPrizes.Shields);
  47.             for ( int j = 0; j < PublicPrizes.Repel.weight/2 ; j+=1)
  48.                 m_Prizes.add(PublicPrizes.Repel);
  49.             for ( int j = 0; j < PublicPrizes.Burst.weight/2 ; j+=1)
  50.                 m_Prizes.add(PublicPrizes.Burst);
  51.             for ( int j = 0; j < PublicPrizes.Decoy.weight/2 ; j+=1)
  52.                 m_Prizes.add(PublicPrizes.Decoy);
  53.             for ( int j = 0; j < PublicPrizes.Thor.weight/2 ; j+=1)
  54.                 m_Prizes.add(PublicPrizes.Thor);
  55.             for ( int j = 0; j < PublicPrizes.Brick.weight/2 ; j+=1)
  56.                 m_Prizes.add(PublicPrizes.Brick);
  57.             for ( int j = 0; j < PublicPrizes.Rocket.weight/2 ; j+=1)
  58.                 m_Prizes.add(PublicPrizes.Rocket);
  59.         }
  60.     }
  61.    
  62.     public void playerGotGreen(PublicPlayer pp, BotAction b)
  63.     {
  64.         // Roll Dice - return on fail
  65.         if (ran.nextInt(100) >= m_Chance) return;
  66.        
  67.         b.sendUnfilteredPrivateMessage(pp.PlayerName(), m_Prizes.get(ran.nextInt(m_Prizes.size())).command);
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment