1package com.runehive.content.skill.impl.farming.patches;
3import com.google.gson.JsonObject;
4import com.runehive.Config;
5import com.runehive.content.skill.impl.farming.CompostType;
6import com.runehive.content.skill.impl.farming.FarmingConstants;
7import com.runehive.content.skill.impl.farming.FarmingStage;
8import com.runehive.content.skill.impl.farming.FarmingState;
9import com.runehive.content.skill.impl.farming.plants.Plant;
10import com.runehive.content.skill.impl.farming.zones.FarmingZone;
11import com.runehive.game.action.Action;
12import com.runehive.game.action.policy.WalkablePolicy;
13import com.runehive.game.task.Task;
14import com.runehive.game.world.Interactable;
15import com.runehive.game.world.World;
16import com.runehive.game.world.entity.mob.player.Player;
17import com.runehive.game.world.entity.skill.Skill;
18import com.runehive.game.world.items.Item;
19import com.runehive.game.world.position.Position;
20import com.runehive.util.Stopwatch;
21import com.runehive.util.Utility;
23import java.util.concurrent.TimeUnit;
64 int elapsed = (int)
timer.elapsedTime(TimeUnit.SECONDS) / 12;
65 int growthStates =
plant.getEndingState() -
plant.getStartingState();
66 int growthTime =
plant.getGrowthTime();
68 if (elapsed > growthTime) {
72 int completed = growthStates * elapsed / growthTime;
91 int growthStates =
plant.getEndingState() -
plant.getStartingState();
92 int growthTime =
plant.getGrowthTime();
94 if (elapsed > growthTime) {
98 int completed = (int) (growthStates * elapsed / growthTime);
100 for (
int i =
growth; i <= completed; i++) {
135 int animation, delay;
138 player.dialogueFactory.sendStatement(
"This patch is already empty.").execute();
144 player.dialogueFactory.sendStatement(
"You need a spade to clear this patch.").execute();
152 player.dialogueFactory.sendStatement(
"You need a rake to clear this patch.").execute();
164 if (
player.locking.locked()) {
170 if (toPlant ==
null) {
175 player.message(
"You can't plant a seed here.");
180 player.dialogueFactory.sendStatement(
"You need a farming level of " + toPlant.
getLevelRequired() +
" to plant this seed.").execute();
185 player.dialogueFactory.sendStatement(
"You need a seed dibber to plant seeds here.").execute();
190 player.dialogueFactory.sendStatement(
"You need at least " + toPlant.
getSeedAmount() +
" seeds to plant here.").execute();
198 player.locking.lock(3 * 3 / 5);
211 if (
player.locking.locked()) {
222 player.message(
"This patch doesn't need compost.");
226 player.locking.lock(7 * 3 / 5);
230 player.message(
"You pour some " + type.name().toLowerCase() +
" on the patch.");
238 player.dialogueFactory.sendStatement(
"This plant is diseased. Use a plant cure on it to cure it, ",
"or clear the patch with a spade.").execute();
241 player.dialogueFactory.sendStatement(
"This plant is dead. You did not cure it while it was diseased.",
"Clear the patch with a spade.").execute();
245 String patch = getClass().getSimpleName().replace(
"Patch",
"").toLowerCase();
249 player.dialogueFactory.sendStatement(
"This is " + patch +
" patch. The soil has not been treated.",
"The patches needs weeding.").execute();
252 player.dialogueFactory.sendStatement(
"This is " + patch +
" patch. The soil has been treated with water",
"and compost. The patches is empty and weeded.").execute();
254 player.dialogueFactory.sendStatement(
"This is " + patch +
" patch. The soil has been treated with water",
"and supercompost. The patches is empty and weeded.").execute();
256 player.dialogueFactory.sendStatement(
"This is " + patch +
" patch. The soil has been treated with water",
"and ultracompost. The patches is empty and weeded.").execute();
258 player.dialogueFactory.sendStatement(
"This is " + patch +
" patch. The soil has been treated with water.",
"The patches is empty and weeded.").execute();
262 player.dialogueFactory.sendStatement(
"This is " + patch +
" patch. The soil has been treated with compost.",
"The patches is empty and weeded.").execute();
264 player.dialogueFactory.sendStatement(
"This is " + patch +
" patch. The soil has been treated with supercompost.",
"The patches is empty and weeded.").execute();
266 player.dialogueFactory.sendStatement(
"This is " + patch +
" patch. The soil has been treated with ultracompost.",
"The patches is empty and weeded.").execute();
269 player.dialogueFactory.sendStatement(
"This is " + patch +
" patch. The soil has not been treated.",
"The patches is empty and weeded.").execute();
272 player.message(
"You bend down and start to inspect the patch...");
277 public void execute() {
278 int index =
growth %
plant.getInspectMessages().length;
280 player.dialogueFactory.sendStatement(
plant.getInspectMessages()[index]).execute();
285 public void onCancel(
boolean logout) {
294 return stage.ordinal();
375 protected void onSchedule() {
376 player.animate(animation);
380 public void execute() {
383 player.inventory.add(6055, 1);
389 player.animate(animation);
394 player.message(
"You clear the patch.");
402 public void onCancel(
boolean logut) {
412 public String getName() {
413 return "Farming Clear";
419 JsonObject
object =
new JsonObject();
420 object.addProperty(
"stage",
stage.name());
421 object.addProperty(
"state",
state.name());
422 object.addProperty(
"compost",
compost.name());
423 object.addProperty(
"timer",
timer.getCachedTime());
424 object.addProperty(
"fully-grown",
fullyGrown);
425 object.addProperty(
"growth",
growth);
427 object.addProperty(
"plant",
plant.getSeedId());
436 fullyGrown =
object.get(
"fully-grown").getAsBoolean();
437 growth =
object.get(
"growth").getAsInt();
439 if (
object.has(
"plant")) {
443 long cached =
object.get(
"timer").getAsLong();
444 simulate(TimeUnit.SECONDS.convert(System.nanoTime() - cached, TimeUnit.NANOSECONDS) / 12);
445 timer.setCachedTime(cached);
The class that contains setting-related constants for the server.
static final double FARMING_MODIFICATION
The experience modification for farming.
static final int RAKING_ANIM
static final int SPADE_ANIM
static final int SEED_DIBBING
static final int SEED_DIBBER
static final int PUTTING_COMPOST
static final double CLEARING_EXPERIENCE
final Interactable[] boundaries
boolean itemOnObject(Item item, int index)
boolean plantSeed(int seedId, int slot)
boolean clickObject(int opcode)
void fromJson(JsonObject object)
Action< Player > createClearingAction(Player player, int animation, int delay)
abstract Plant plantForSeed(int seedId)
FarmingPatch(Player player, FarmingZone zone, Interactable[] boundaries)
boolean putCompost(int itemId, int slot)
void simulate(long elapsed)
boolean within(Position position)
A zone that manages farming patches.
Represents an action an entity can execute.
A game representing a cyclic unit of work.
Represents the game world.
static void schedule(Task task)
Submits a new event.
This class represents a character controlled by a player.
Represents a trainable and usable skill.
static final int FARMING
The farming skill id.
The container class that represents an item that can be interacted with.
final int getId()
Gets the identification of this item.
boolean matchesId(int id)
Represents a single tile on the game world.
Handles miscellaneous methods.
static boolean inside(Interactable source, Interactable target)
static String getAOrAn(String nextWord)
A or an.
static CompostType forItem(int item)
The farming stage of a patch.
TWO_THIRDS_WEEDS
The patch needs to be weeded two more times.
FULL_WEEDS
The patch is full of weeds.
EMPTY
The patch is empty of weeds.
ONE_THIRD_WEEDS
The patch needs to be weeded one more time.
The farming state of a patch.
DISEASED
The patch is diseased.
WATERED
The patch is watered.
NORMAL
The patch is empty and ready to be used.
A queue policy determines whether the action can occur while walking.
NON_WALKABLE
This indicates actions cannot occur while walking.
An object implementing Interactable has uses.