Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package twcore.bots.battlebot.PublicOps;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Random;
- import twcore.core.BotAction;
- public class PrizeOps {
- enum PublicPrizes
- {
- Super("*prize #17",2),
- Shields("*prize #18",2),
- Repel("*prize #21",20),
- Burst("*prize #22",18),
- Decoy("*prize #23",30),
- Thor("*prize #24",20),
- Brick("*prize #26",8),
- Rocket("*prize #27",20);
- private String command;
- private int weight;
- private PublicPrizes(String command, int weight)
- {
- this.command = command;
- this.weight = weight;
- }
- }
- // MasterList of all prizes
- private List<PublicPrizes> m_Prizes = new ArrayList<PublicPrizes>();
- // % chance of getting a prize
- private int m_Chance = 50;
- // For random numbers
- Random ran = new Random();
- // Loading prizes into a master list by their weights
- // to try and get a more random prize we load the first half of weights, then again
- // Then we will pull out a random prize by choosing between 1 and list.length()
- public void LoadPrizes()
- {
- for ( int i = 0; i < 2; i+=1)
- {
- for ( int j = 0; j < PublicPrizes.Super.weight/2 ; j+=1)
- m_Prizes.add(PublicPrizes.Super);
- for ( int j = 0; j < PublicPrizes.Shields.weight/2 ; j+=1)
- m_Prizes.add(PublicPrizes.Shields);
- for ( int j = 0; j < PublicPrizes.Repel.weight/2 ; j+=1)
- m_Prizes.add(PublicPrizes.Repel);
- for ( int j = 0; j < PublicPrizes.Burst.weight/2 ; j+=1)
- m_Prizes.add(PublicPrizes.Burst);
- for ( int j = 0; j < PublicPrizes.Decoy.weight/2 ; j+=1)
- m_Prizes.add(PublicPrizes.Decoy);
- for ( int j = 0; j < PublicPrizes.Thor.weight/2 ; j+=1)
- m_Prizes.add(PublicPrizes.Thor);
- for ( int j = 0; j < PublicPrizes.Brick.weight/2 ; j+=1)
- m_Prizes.add(PublicPrizes.Brick);
- for ( int j = 0; j < PublicPrizes.Rocket.weight/2 ; j+=1)
- m_Prizes.add(PublicPrizes.Rocket);
- }
- }
- public void playerGotGreen(PublicPlayer pp, BotAction b)
- {
- // Roll Dice - return on fail
- if (ran.nextInt(100) >= m_Chance) return;
- b.sendUnfilteredPrivateMessage(pp.PlayerName(), m_Prizes.get(ran.nextInt(m_Prizes.size())).command);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment