RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.skill.impl.ProducingSkillAction Class Referenceabstract

The skill action that represents an action where one item in an inventory is replaced with a new one. More...

Inheritance diagram for com.runehive.content.skill.impl.ProducingSkillAction:
Collaboration diagram for com.runehive.content.skill.impl.ProducingSkillAction:

Public Member Functions

final boolean canRun ()
 Determines if the task can be ran.
Optional< String > message ()
 The message that will be sent when the player doesn't have the items required.
final void onExecute ()
 The method which is called on intervals of the specified #delay;.
void onProduce (boolean success)
 The method executed upon production of an item.
abstract Optional< Item[]> produceItem ()
 The item that will be added upon production.
 ProducingSkillAction (Player player, Optional< Position > position, boolean instant)
 Creates a new ProducingSkillAction.
 ProducingSkillAction (Player player, Optional< Position > position, int delay, boolean instant)
 Creates a new ProducingSkillAction.
abstract Optional< Item[]> removeItem ()
 The item that will be removed upon production.
Public Member Functions inherited from com.runehive.content.skill.SkillAction
abstract Optional< SkillAnimationanimation ()
 The skill animation to execute.
abstract boolean canInit ()
 Determines if this action can be initialized.
abstract double experience ()
 The experience given from this action.
boolean ignore ()
 Determines if future skill actions from the same type should be ignored.
abstract void init ()
 Any functionality that should be handled when this action is submitted.
abstract int skill ()
 The skill we should hand to experience to.
 SkillAction (Mob mob, Optional< Position > position, boolean instant)
 Creates a new Action randomevent.
 SkillAction (Mob mob, Optional< Position > position, int delay, boolean instant)
 Creates a new Action randomevent.
final void start ()
 Attempts to start the skill.
Public Member Functions inherited from com.runehive.game.action.Action< T extends Mob >
 Action (T mob, int delay)
 Creates a new Action randomevent.
 Action (T mob, int delay, boolean instant)
 Creates a new Action randomevent.
boolean cancellableInProgress ()
getMob ()
 Gets the player.
abstract String getName ()
 Gets the name of this action.
abstract WalkablePolicy getWalkablePolicy ()
 Gets the WalkablePolicy of this action.
boolean prioritized ()
 Determines if this action is prioritized.
Public Member Functions inherited from com.runehive.game.task.Task
Task attach (Object newKey)
 Attaches a new key.
synchronized final void cancel ()
 Cancels all subsequent executions.
synchronized final void cancel (boolean logout)
 Cancels all subsequent executions.
Optional< Object > getAttachment ()
String getCreationStackTraceStr ()
int getDelay ()
Long getElapsedTimeFromRunStartTime ()
Optional< Long > getRunStartTime ()
long getTaskCreationTime ()
String getTaskId ()
boolean isInstant ()
boolean isRunning ()
void setDelay (int delay)
 Sets the cyclic delay.
void setExecutionTime ()
 Task (boolean instant, int delay)
 Creates a new Task.
 Task (int delay)
 Creates a new Task that doesn't execute instantly.

Additional Inherited Members

Protected Member Functions inherited from com.runehive.content.skill.SkillAction
final void execute ()
 A function representing the unit of work that will be carried out.
final void onSchedule ()
 A function executed on registration.
Protected Member Functions inherited from com.runehive.game.task.Task
void baseExecute ()
boolean canSchedule ()
 A function executed on registration.
void onCancel (boolean logout)
 A function executed on cancellation.
Package Functions inherited from com.runehive.game.task.Task
void onException (Exception e)
 A function executed on thrown exceptions.
void onLoop ()
 A function executed when iterated over.
final synchronized void process ()
synchronized void setRunning (boolean running)

Detailed Description

The skill action that represents an action where one item in an inventory is replaced with a new one.

This type of skill action is somewhat basic and requires that a player have the item to be removed.

The skills that may use this type skill action include, but are not limited to COOKING.

Author
lare96 http://github.com/lare96
See also
SkillAction
DestructionSkillAction
HarvestingSkillAction

Definition at line 26 of file ProducingSkillAction.java.

Constructor & Destructor Documentation

◆ ProducingSkillAction() [1/2]

com.runehive.content.skill.impl.ProducingSkillAction.ProducingSkillAction ( Player player,
Optional< Position > position,
boolean instant )

Creates a new ProducingSkillAction.

Parameters
playerthe player this skill action is for.
positionthe position the player should face.
instantdetermines if this action should be ran instantly.

Definition at line 34 of file ProducingSkillAction.java.

34 {
35 super(player, position, instant);
36 }

References com.runehive.game.task.Task.instant, and com.runehive.content.skill.SkillAction.position.

◆ ProducingSkillAction() [2/2]

com.runehive.content.skill.impl.ProducingSkillAction.ProducingSkillAction ( Player player,
Optional< Position > position,
int delay,
boolean instant )

Creates a new ProducingSkillAction.

Parameters
playerthe player this skill action is for.
positionthe position the player should face.
delaythe delay between these producing skill actions.
instantdetermines if this action should be ran instantly.

Definition at line 45 of file ProducingSkillAction.java.

45 {
46 super(player, position, delay, instant);
47 }

References com.runehive.game.task.Task.delay, com.runehive.game.task.Task.instant, and com.runehive.content.skill.SkillAction.position.

Member Function Documentation

◆ canRun()

final boolean com.runehive.content.skill.impl.ProducingSkillAction.canRun ( )

Determines if the task can be ran.

Reimplemented from com.runehive.game.task.Task.

Definition at line 50 of file ProducingSkillAction.java.

50 {
51 Optional<Item[]> removeItem = removeItem();
52
53 if(!removeItem.isPresent())
54 return true;
55
56 ItemContainer container = getMob().getPlayer().inventory.copy();
57 if(container.removeAll(removeItem.get()) && !container.hasCapacityFor(produceItem().get())) {
58 container.fireCapacityExceededEvent();
59 return false;
60 }
61 if(getMob().getPlayer().inventory.containsAll(removeItem.get()))
62 return true;
63
64 if(!message().isPresent()) {
65 for(Item item : removeItem.get()) {
66 if(!getMob().getPlayer().inventory.contains(item)) {
67 String anyOrEnough = item.getAmount() == 1 ? "any" : "enough";
68 getMob().getPlayer().send(new SendMessage("You don't have " + anyOrEnough + " " + StringUtils.appendPluralCheck(item.getName()) + " left."));
69 return false;
70 }
71 }
72 } else {
73 getMob().getPlayer().send(new SendMessage(message().get()));
74 }
75
76 onProduce(false);
77 return false;
78 }

References com.runehive.util.StringUtils.appendPluralCheck(), com.runehive.game.world.items.containers.ItemContainer.copy(), com.runehive.game.world.items.containers.ItemContainer.fireCapacityExceededEvent(), com.runehive.game.action.Action< T extends Mob >.getMob(), com.runehive.game.world.items.containers.ItemContainer.hasCapacityFor(), message(), onProduce(), produceItem(), com.runehive.game.world.items.containers.ItemContainer.removeAll(), and removeItem().

Here is the call graph for this function:

◆ message()

Optional< String > com.runehive.content.skill.impl.ProducingSkillAction.message ( )

The message that will be sent when the player doesn't have the items required.

Returns
the alphabetic value which represents the message.

Definition at line 113 of file ProducingSkillAction.java.

113 {
114 return Optional.empty();
115 }

Referenced by canRun().

Here is the caller graph for this function:

◆ onExecute()

final void com.runehive.content.skill.impl.ProducingSkillAction.onExecute ( )

The method which is called on intervals of the specified #delay;.

Reimplemented from com.runehive.content.skill.SkillAction.

Definition at line 81 of file ProducingSkillAction.java.

81 {
82 getMob().skills.addExperience(skill(), experience());
83 removeItem().ifPresent(getMob().getPlayer().inventory::removeAll);
84 produceItem().ifPresent(getMob().getPlayer().inventory::addAll);
85 onProduce(true);
86 }

References com.runehive.content.skill.SkillAction.experience(), com.runehive.game.action.Action< T extends Mob >.getMob(), onProduce(), produceItem(), removeItem(), and com.runehive.content.skill.SkillAction.skill().

Here is the call graph for this function:

◆ onProduce()

void com.runehive.content.skill.impl.ProducingSkillAction.onProduce ( boolean success)

The method executed upon production of an item.

Parameters
successdetermines if the production was successful or not.

Reimplemented in com.runehive.content.skill.impl.smithing.SmithingArmour.

Definition at line 92 of file ProducingSkillAction.java.

92 {
93
94 }

Referenced by canRun(), and onExecute().

Here is the caller graph for this function:

◆ produceItem()

abstract Optional< Item[]> com.runehive.content.skill.impl.ProducingSkillAction.produceItem ( )
abstract

The item that will be added upon production.

Returns
the item that will be added.

Reimplemented in com.runehive.content.skill.impl.smithing.SmithingArmour.

Referenced by canRun(), and onExecute().

Here is the caller graph for this function:

◆ removeItem()

abstract Optional< Item[]> com.runehive.content.skill.impl.ProducingSkillAction.removeItem ( )
abstract

The item that will be removed upon production.

Returns
the item that will be removed.

Reimplemented in com.runehive.content.skill.impl.smithing.SmithingArmour.

Referenced by canRun(), and onExecute().

Here is the caller graph for this function:

The documentation for this class was generated from the following file: