Jump to content

foodid healing values


Dreamliner

Recommended Posts

private int getFoodHeal(int food) {
      int val = 0;
      switch (food) {
         case 6701: // baked potato
            val = 4;
            break;
         case 2309: // bread
            val = 5;
            break;
         case 333:
         case 2289: // plain pizza
         case 2291: // half plain pizza
            val = 7; // trout
            break;
         case 351: // pike
         case 2293: // meat pizza
         case 2295: // half meat pizza
         case 2297: // anchovy pizza
         case 2299: // half anchovy pizza
            val = 8;
            break;
         case 329: // salmon
            val = 9;
            break;
         case 361:
            val = 10; // tuna
            break;
         case 1993: // wine
         case 2301: // pineapple pizza
         case 2303: // half pineapple pizza
            val = 11;
            break;
         case 379:
            val = 12; // lobster
            break;
         case 365: // bass
            val = 13;
            break;
         case 373: // swordfish
         case 6703: // Potato with butter
         case 7054: // chilli potato
            val = 14;
            break;
         case 6705: // potato with cheese
         case 7496: // monkfish
            val = 16;
            break;
         case 385: // shark
         case 7058: // Mushroom potato
            val = 20;
            break;
         case 7060: //tuna potato
            val = 22;
            break;
         default:
            val = 7;
            break;
      
      }
      return val;
   }

thought this would be useful to others

Link to comment
Share on other sites

haha thx for sharing this with. Always cool to see people working to make everything easier and better! ^^

 

btw why is defaul val 7? xD you should return 0 or -1 to let it know it didn't find the food xD

H0ppy

 

default value is 7 incase it's an unknown food type.  If it returned 0, your script could possibly eat everything in your inventory 

So this heals certain foods?

 

getDogFood();

 

get food for dog

 

getFoodHeal();

 

get heal for food

Link to comment
Share on other sites

You guys are making this way harder than it needs to be.  There's a reason comments exist

the way it is now is fine and there is no problem with it but just kinda messy. and enum are not hard and it was just a suggestion you dont have to use it. happy.png

  

public enum food{

  
TUNA("Tuna", 10, 361),
BREAD("Bread", 5, 2309);


food(String name, int value, int id){



this.name = name;



this.value = value;



this.id = id;



}


private String name;



private int value;



private int id;


/*Name of the item*/



public String toString(){



return name;



}



/*gets the id of the food item*/



public int getId(){



return id;



}



/*get the healing value of the food item*/



public int getValue(){



return value;



}


}



public int getHealValue(int id){

for(food f : food.values()){

if(f.getId() == id) return f.getValue();

}

return -1;

}


public int getFoodHealValue(String name){
for(food f : food.values()){
if(f.toString().equalsIgnoreCase(name)) return f.getValue();

}
return -1;
}



simple and less messy? and sorry if i got somethings wrong

as i said just an example dont have to use it.

Edited by Cyro
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...