mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-13 01:51:37 -07:00
Merge branch 'fix-dairy-churn' into 'master'
Dairy churning fixes: See merge request 2009scape/2009scape!293
This commit is contained in:
commit
ef1d86eaaf
2 changed files with 53 additions and 31 deletions
|
|
@ -1,13 +1,15 @@
|
||||||
package core.game.node.entity.skill.cooking.dairy;
|
package core.game.node.entity.skill.cooking.dairy;
|
||||||
|
|
||||||
|
import core.game.node.entity.player.Player;
|
||||||
import core.game.node.entity.player.link.diary.DiaryType;
|
import core.game.node.entity.player.link.diary.DiaryType;
|
||||||
import core.game.world.map.Location;
|
|
||||||
import core.game.node.entity.skill.SkillPulse;
|
import core.game.node.entity.skill.SkillPulse;
|
||||||
import core.game.node.entity.skill.Skills;
|
import core.game.node.entity.skill.Skills;
|
||||||
import core.game.node.entity.player.Player;
|
import core.game.node.item.GroundItemManager;
|
||||||
import core.game.node.item.Item;
|
import core.game.node.item.Item;
|
||||||
|
import core.game.world.map.Location;
|
||||||
import core.game.world.update.flag.context.Animation;
|
import core.game.world.update.flag.context.Animation;
|
||||||
import core.tools.StringUtils;
|
import core.tools.StringUtils;
|
||||||
|
import org.rs09.consts.Items;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the skill pulse used to make a dairy product.
|
* Represents the skill pulse used to make a dairy product.
|
||||||
|
|
@ -57,14 +59,18 @@ public final class DairyChurnPulse extends SkillPulse<Item> {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkRequirements() {
|
public boolean checkRequirements() {
|
||||||
player.getInterfaceManager().closeChatbox();
|
player.getInterfaceManager().closeChatbox();
|
||||||
if (!player.getInventory().contains(1927, 1)) {
|
boolean hasAnyInput = false;
|
||||||
|
for(Item input : dairy.getInputs()) {
|
||||||
|
if(player.getInventory().containsItem(input)) {
|
||||||
|
hasAnyInput = true;
|
||||||
|
node = input;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasAnyInput) {
|
||||||
player.getPacketDispatch().sendMessage("You need a bucket of milk.");
|
player.getPacketDispatch().sendMessage("You need a bucket of milk.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (player.getInventory().freeSlots() < 1) {
|
|
||||||
player.getPacketDispatch().sendMessage("You don't have enough inventory space.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (player.getSkills().getLevel(Skills.COOKING) < dairy.getLevel()) {
|
if (player.getSkills().getLevel(Skills.COOKING) < dairy.getLevel()) {
|
||||||
player.getPacketDispatch().sendMessage("You need a cooking level of " + dairy.getLevel() + " to cook this.");
|
player.getPacketDispatch().sendMessage("You need a cooking level of " + dairy.getLevel() + " to cook this.");
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -87,30 +93,31 @@ public final class DairyChurnPulse extends SkillPulse<Item> {
|
||||||
@Override
|
@Override
|
||||||
public boolean reward() {
|
public boolean reward() {
|
||||||
amount--;
|
amount--;
|
||||||
if (player.getInventory().containsItem(BUCKET_OF_MILK)) {
|
for(Item input : dairy.getInputs()) {
|
||||||
if (player.getInventory().remove(BUCKET_OF_MILK)) {
|
if (player.getInventory().remove(input)) {
|
||||||
if (player.getInventory().freeSlots() > 1) {
|
// Since we've just removed the input, there's always enough room for the primary output
|
||||||
player.getInventory().add(dairy.getProduct());
|
player.getInventory().add(dairy.getProduct());
|
||||||
player.getInventory().add(BUCKET);
|
// But if we were churning milk, we might need to drop the bucket on the floor if there isn't enough space
|
||||||
}
|
if(input.getId() == Items.BUCKET_OF_MILK_1927) {
|
||||||
player.getPacketDispatch().sendMessage("You make " + (StringUtils.isPlusN(dairy.getProduct().getName().toLowerCase()) ? "an" : "a") + " " + dairy.getProduct().getName().toLowerCase() + ".");
|
if(!player.getInventory().add(BUCKET)) {
|
||||||
player.getSkills().addExperience(Skills.COOKING, dairy.getExperience(), true);
|
// https://runescape.wiki/w/Pat_of_butter?oldid=2043294
|
||||||
|
// "using milk with a full inventory will auto-drop the buckets"
|
||||||
|
GroundItemManager.create(BUCKET, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
player.getPacketDispatch().sendMessage("You make " + (StringUtils.isPlusN(dairy.getProduct().getName().toLowerCase()) ? "an" : "a") + " " + dairy.getProduct().getName().toLowerCase() + ".");
|
||||||
|
player.getSkills().addExperience(Skills.COOKING, dairy.getExperience(), true);
|
||||||
|
|
||||||
// Seers village diary
|
// Seers village diary
|
||||||
if (player.getLocation().withinDistance(new Location(2730, 3578, 0))
|
if (player.getLocation().withinDistance(new Location(2730, 3578, 0))
|
||||||
&& !player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(0,8)) {
|
&& !player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(0,8)) {
|
||||||
player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).updateTask(player,0,8,true);
|
player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).updateTask(player,0,8,true);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
return amount < 1;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (player.getInventory().freeSlots() < 1) {
|
|
||||||
player.getPacketDispatch().sendMessage("You don't have enough inventory space.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return amount < 1 || player.getInventory().freeSlots() < 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,18 @@
|
||||||
package core.game.node.entity.skill.cooking.dairy;
|
package core.game.node.entity.skill.cooking.dairy;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import core.game.node.item.Item;
|
import core.game.node.item.Item;
|
||||||
|
import org.rs09.consts.Items;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an enumeration of dairy products.
|
* Represents an enumeration of dairy products.
|
||||||
* @author 'Vexia
|
* @author 'Vexia
|
||||||
*/
|
*/
|
||||||
public enum DairyProduct {
|
public enum DairyProduct {
|
||||||
POT_OF_CREAM(21, 18, new Item(2130, 1)), PAT_OF_BUTTER(38, 40.5, new Item(6697, 1)), CHEESE(48, 64, new Item(1985, 1));
|
POT_OF_CREAM(21, 18, new Item(Items.POT_OF_CREAM_2130, 1), new Integer[] { Items.BUCKET_OF_MILK_1927 }),
|
||||||
|
PAT_OF_BUTTER(38, 40.5, new Item(Items.PAT_OF_BUTTER_6697, 1), new Integer[] { Items.BUCKET_OF_MILK_1927, Items.POT_OF_CREAM_2130 }),
|
||||||
|
CHEESE(48, 64, new Item(Items.CHEESE_1985, 1), new Integer[] { Items.BUCKET_OF_MILK_1927, Items.POT_OF_CREAM_2130, Items.PAT_OF_BUTTER_6697 });
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The prodct <code>Item</code>.
|
* The prodct <code>Item</code>.
|
||||||
|
|
@ -24,16 +29,22 @@ public enum DairyProduct {
|
||||||
*/
|
*/
|
||||||
private double experience;
|
private double experience;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The possible inputs for making this dairy product
|
||||||
|
*/
|
||||||
|
private Item[] inputs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new {@code DairyProduct.java} {@code Object}.
|
* Constructs a new {@code DairyProduct.java} {@code Object}.
|
||||||
* @param level
|
* @param level
|
||||||
* @param experience
|
* @param experience
|
||||||
* @param product
|
* @param product
|
||||||
*/
|
*/
|
||||||
DairyProduct(int level, double experience, Item product) {
|
DairyProduct(int level, double experience, Item product, Integer[] inputs) {
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.experience = experience;
|
this.experience = experience;
|
||||||
this.product = product;
|
this.product = product;
|
||||||
|
this.inputs = Arrays.stream(inputs).map(id -> new Item(id, 1)).toArray(len -> new Item[len]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -56,4 +67,8 @@ public enum DairyProduct {
|
||||||
public double getExperience() {
|
public double getExperience() {
|
||||||
return experience;
|
return experience;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Item[] getInputs() {
|
||||||
|
return inputs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue