Guest User

Untitled

a guest
Apr 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.57 KB | None | 0 0
  1. package server.model.players;
  2.  
  3. import java.util.HashMap;
  4.  
  5. /**
  6.  * @author Sanity
  7.  */
  8.  
  9. public class Food {
  10.  
  11.  
  12.   private Client c;
  13.  
  14.   public Food (Client c) {
  15.     this.c = c;  
  16.   }
  17.   public static enum FoodToEat {    
  18.    
  19.     ROCKTAIL(15272,24,"Rocktail"),
  20.     MANTA(391,22,"Manta Ray"),
  21.     SHARK(385,20,"Shark"),
  22.     LOBSTER(379,12,"Lobster"),
  23.     TROUT(333,7,"Trout"),
  24.     SALMON(329,9,"Salmon"),
  25.     SWORDFISH(373,14,"Swordfish"),
  26.     TUNA(361,10,"Tuna"),
  27.     MONKFISH(7946,16,"Monkfish"),
  28.     SEA_TURTLE(397,21,"Sea Turtle"),
  29.     CAKE(1891,4,"Cake"),
  30.     BASS(365,13,"Bass"),
  31.     COD(339,7,"Cod"),
  32.     POTATO(1942,1,"Potato"),
  33.     BAKED_POTATO(6701,4,"Baked Potato"),
  34.     POTATO_WITH_CHEESE(6705,16,"Potato with Cheese"),
  35.     EGG_POTATO(7056,16,"Egg Potato"),
  36.     CHILLI_POTATO(7054,14,"Chilli Potato"),
  37.     MUSHROOM_POTATO(7058,20,"Mushroom Potato"),
  38.     TUNA_POTATO(7060,22,"Tuna Potato"),
  39.     SHRIMPS(315,3,"Shrimps"),
  40.     HERRING(347,5,"Herring"),
  41.     SARDINE(325,4,"Sardine"),
  42.     CHOCOLATE_CAKE(1897,5,"Chocolate Cake"),
  43.     ANCHOVIES(319,1,"Anchovies"),
  44.     PLAIN_PIZZA(2289,7,"Plain Pizza"),
  45.     MEAT_PIZZA(2293,8,"Meat Pizza"),
  46.     ANCHOVY_PIZZA(2297,9,"Anchovy Pizza"),
  47.     PINEAPPLE_PIZZA(2301,11,"Pineapple Pizza"),
  48.     BREAD(2309,5,"Bread"),
  49.     APPLE_PIE(2323,7,"Apple Pie"),
  50.     REDBERRY_PIE(2325,5,"Redberry Pie"),
  51.     MEAT_PIE(2327,6,"Meat Pie"),
  52.     PIKE(351,8,"Pike"),
  53.     POTATO_WITH_BUTTER(6703,14,"Potato with Butter"),
  54.     BANANA(1963,2,"Banana"),
  55.     PEACH(6883,8,"Peach"),
  56.     ORANGE(2108,2,"Orange"),
  57.     PINEAPPLE_RINGS(2118,2,"Pineapple Rings"),
  58.     PINEAPPLE_CHUNKS(2116,2,"Pineapple Chunks"),
  59.  
  60.     /*
  61.      * Dungeoneering Food
  62.      */
  63.     WEB_SNIPPER(18169,15, "Web snipper"),
  64.     BOULDABASS(18171,17, "Bouldabass"),
  65.     BLUE_CRAB(18175,22, "Blue crab"),
  66.     CAVE_MORAY(18177,25, "Cave moray"),
  67.     DUSK_EEL(18163,7, "Dusk eel"),
  68.     GIANT_FLATFISH(18165,10, "Giant flatfish"),
  69.     SHORT_FINNED_EEL(18167,12, "Short-finned eel"),
  70.     RED_EYE(18161,5, "Red-eye"),
  71.     HEIM_CRAB(18159,2, "Heim crab"),
  72.     SALVE_EEL(18173,20, "Salve eel");  
  73.  
  74.  
  75.     private int id; private int heal; private String name;
  76.  
  77.     private FoodToEat(int id, int heal, String name) {
  78.       this.id = id;
  79.       this.heal = heal;
  80.       this.name = name;    
  81.     }
  82.  
  83.     public int getId() {
  84.       return id;
  85.     }
  86.  
  87.     public int getHeal() {
  88.       return heal;
  89.     }
  90.  
  91.     public String getName() {
  92.       return name;
  93.     }
  94.     public static HashMap <Integer,FoodToEat> food = new HashMap<Integer,FoodToEat>();
  95.  
  96.     public static FoodToEat forId(int id) {
  97.       return food.get(id);
  98.     }
  99.  
  100.     static {
  101.     for (FoodToEat f : FoodToEat.values())
  102.       food.put(f.getId(), f);
  103.     }
  104.   }
  105.   public int gwdarmourStat(double amount) {
  106.         return (int)(c.getLevelForXP(c.playerXP[3]) * amount);
  107.     }
  108.   public boolean hasFullPrimal() {
  109.     return c.playerEquipment[c.playerHat] == 13362 && c.playerEquipment[c.playerChest] == 13360 && c.playerEquipment[c.playerLegs] == 13361;
  110.   }
  111.  
  112.   public boolean torva() {
  113.     return c.playerEquipment[c.playerHat] == 13362 && c.playerEquipment[c.playerChest] == 13360 && c.playerEquipment[c.playerLegs] == 13361;
  114.   }
  115.  
  116.         public void eat(int id, int slot) {
  117.         if (c.duelRule[6]) {
  118.             c.sendMessage("You may not eat in this duel.");
  119.             return;
  120.         }
  121.         if (System.currentTimeMillis() - c.foodDelay >= 1500 && c.playerLevel[3] > 0) {
  122.             c.getCombat().resetPlayerAttack();
  123.             c.attackTimer += 2;
  124.             c.startAnimation(829);
  125.             c.getItems().deleteItem(id,slot,1);
  126.             FoodToEat f = FoodToEat.food.get(id);
  127.             if (c.playerLevel[3] < gwdarmourStat(1.41) && c.torva()) {
  128.                 c.playerLevel[3] += f.getHeal();
  129.                 if (c.playerLevel[3] > gwdarmourStat(1.41))
  130.                     c.playerLevel[3] = gwdarmourStat(1.41);
  131.             }
  132.             else if (c.playerLevel[3] < c.getLevelForXP(c.playerXP[3]) && !c.torva()) {
  133.                 c.playerLevel[3] += f.getHeal();
  134.                 if(id != 15272) {
  135.                 if (c.playerLevel[3] > c.getLevelForXP(c.playerXP[3]))
  136.                     c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
  137. //this makes sure normal food doesn't overload
  138.             } else {
  139. // this says if their eating rocktails and their hp level is more then their player xp + 10, then make it playerxp + 10. If it isnt then it will overload anyway.
  140.             if ((c.playerLevel[3] > (c.getLevelForXP(c.playerXP[3])))) {
  141.                     c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]) + 10;
  142.             }
  143.             }
  144.             }
  145.             c.foodDelay = System.currentTimeMillis();
  146.             c.getPA().refreshSkill(3);
  147.             c.sendMessage("You eat the " + f.getName() + ".");
  148.         }          
  149.     }
  150.  
  151.  
  152.   public boolean isFood(int id) {
  153.     return FoodToEat.food.containsKey(id);
  154.   }  
  155.  
  156.  
  157. }
Add Comment
Please, Sign In to add comment