1package com.runehive.content.activity.impl.duelarena;
3import com.runehive.content.activity.Activity;
4import com.runehive.content.activity.ActivityDeathType;
5import com.runehive.content.activity.ActivityType;
6import com.runehive.content.activity.panel.ActivityPanel;
7import com.runehive.content.activity.panel.Activity_Panel;
8import com.runehive.content.consume.FoodData;
9import com.runehive.content.event.impl.ObjectInteractionEvent;
10import com.runehive.game.Animation;
11import com.runehive.game.Graphic;
12import com.runehive.game.world.entity.Entity;
13import com.runehive.game.world.entity.combat.CombatType;
14import com.runehive.game.world.entity.combat.strategy.CombatStrategy;
15import com.runehive.game.world.entity.mob.Mob;
16import com.runehive.game.world.entity.mob.player.Player;
17import com.runehive.game.world.entity.mob.player.exchange.ExchangeSessionType;
18import com.runehive.game.world.entity.mob.player.exchange.duel.StakeSession;
19import com.runehive.game.world.items.Item;
20import com.runehive.game.world.items.containers.ItemContainer;
21import com.runehive.game.world.items.containers.equipment.Equipment;
22import com.runehive.game.world.items.containers.equipment.EquipmentType;
23import com.runehive.game.world.items.containers.pricechecker.PriceType;
24import com.runehive.game.world.pathfinding.TraversalMap;
25import com.runehive.game.world.position.Position;
26import com.runehive.net.packet.out.SendEntityHintArrow;
27import com.runehive.net.packet.out.SendItemOnInterface;
28import com.runehive.net.packet.out.SendMessage;
29import com.runehive.net.packet.out.SendString;
30import com.runehive.util.Utility;
32import java.util.Objects;
33import java.util.Optional;
35import static com.runehive.game.world.entity.combat.attack.FormulaFactory.rollDefensive;
36import static com.runehive.game.world.entity.combat.attack.FormulaFactory.rollOffensive;
159 player.playerAssistant.restore();
168 if (position ==
null) {
174 if (position ==
null) {
197 player.playerAssistant.restore();
207 player.message(
"The duel was a stalemate!");
208 opponent.message(
"The duel was a stalemate!");
218 winner.message(
"You are victorious!");
219 loser.message(
"You lost!");
269 if (
player.equals(
this.player)) {
375 final String name = item.
getName() ==
null ?
"null" : item.
getName().toLowerCase();
376 if (!name.contains(
"dragon dagger") && !name.contains(
"abyssal whip") && !name.contains(
"abyssal tentacle")) {
478 if (
player.equipment.hasWeapon()) {
485 if (
player.equipment.hasShield()) {
510 switch(
event.getObject().getId()) {
532 if (
player.equals(
this.player)) {
565 player.send(
new SendString(stalemate ?
"The duel was a stalemate!" :
player.equals(
loser) ?
"You lost!" :
"You are victorious!", 31705));
566 player.interfaceManager.open(31700,
false);
570 Objects.requireNonNull(
winner);
571 Objects.requireNonNull(
loser);
574 Objects.requireNonNull(winnerContainer);
577 Objects.requireNonNull(loserContainer);
619 super(
player,
"Duel Arena");
633 set(2,
"Your accuracy: <col=FF5500>" +
accuracy(dueler, duelee) +
"</col>");
635 set(5,
"Opponent's accuracy: <col=FF5500>" +
accuracy(duelee, dueler) +
"</col>");
647 dueler.
getCombat().addModifier(strategy);
648 double attackRoll = rollOffensive(dueler, duelee, type.
getFormula());
649 double defenceRoll = rollDefensive(dueler, duelee, type.
getFormula());
650 dueler.
getCombat().removeModifier(strategy);
652 double chance = attackRoll / (attackRoll + defenceRoll);
653 double accuracy = (int) (chance * 10000) / 100.0;
654 return String.valueOf(
accuracy) +
"%";
final int cooldown
The sequencing cooldown.
Activity(int cooldown, int instance)
Constructs a new SequencedMinigame object.
final boolean isPaused()
Checks if the cooldown is paused.
static final int FINISH
The 'finish' cooldown id.
int getTicks()
Gets the current ticks.
final void pause()
Sets the cooldown flag to PAUSE.
void removeAll(Mob... mobs)
Removes all mobs from the activity.
void add(Mob mob)
Adds a mob to the activity.
final void finishCooldown()
Sets the cooldown flag to FINISH.
String accuracy(Player dueler, Player duelee)
final DuelArenaActivity activity
DuelPanel(DuelArenaActivity activity, Player player)
static final Position HOSPITAL_BEDS_SOUTHWEST
The south-west tile of the hospital bed area.
final StakeSession session
The duel stake session (holds items).
void unequipItems(Player player)
void start()
Starts the next activity stage.
void sequence()
Sequences the activity.
boolean canUsePrayer(Player player)
void onDeath(Mob mob)
Called when the player die.
static DuelArenaActivity create(StakeSession session, Player player, Player opponent)
ActivityDeathType deathType()
static final Position[] OBSTACLE_ARENAS
The mid-points of all three obstacle duel arenas.
Player winner
The duel outcome.
void cleanup()
Cleans up the activity when finished.
DuelPanel opponentPanel
The opponent activity panel.
boolean rewarded
Whether or not the reward has been given.
boolean clickObject(Player player, ObjectInteractionEvent event)
boolean started
Whether or not the duel has started.
DuelPanel playerPanel
The player activity panel.
void finish()
Finishes the activity.
final DuelArenaListener listener
The combat listener for the duel.
boolean canDrinkPotions(Player player)
DuelArenaActivity(StakeSession session, Player player, Player opponent)
boolean canLogout(Player player)
static final Position[] ARENAS
The mid-points of all three duel arenas.
boolean canEat(Player player, FoodData foodType)
void update()
The update method.
boolean canUseSpecial(Player player)
final DuelRules rules
The duel rules for this duel session.
final Player opponent
The player accepting the duel.
Optional< DuelArenaListener > getListener()
Gets an Optional of the ActivityListener for this activity.
void reward(Player winner, Player loser, boolean stalemate)
void reward(Player player, Player loser, Item[] reward, long value, boolean stalemate)
final Player player
The player requesting the duel.
boolean canEquipItem(Player player, Item item, EquipmentType type)
void onLogout(Player player)
Called when the player logs out.
static boolean hasFunWeapon(Player player, Item item)
Activity_Panel(Player player, String header)
void setFooter(String footer)
void setProgress(int progress)
Handles the activity panel.
static void update(Player player, int amount, String title, String footer, String... strings)
Sends all the information for the activity panel.
Class that models a single animation used by an entity.
static final Animation RESET
Represents a single graphic that can be used by entities.
static final Graphic RESET
Represents a character in the game world, i.e.
static final int DEFAULT_INSTANCE
abstract boolean equals(Object obj)
abstract CombatType getCombatType()
int getMaxHit(Mob defender, CombatType type)
Gets the max hit of a combat type.
This class represents a character controlled by a player.
CombatStrategy< Player > getStrategy()
The combat strategy of the mob.
String getName()
Gets the name of this entity.
Combat< Player > getCombat()
The combat of the mob.
final PlayerAssistant playerAssistant
The exchange session where two players can agree to a stake.
The container class that represents an item that can be interacted with.
An abstraction game representing a group of Items.
boolean addAll(Collection<? extends Item > items)
Attempts to deposit items in bulk into this container.
long containerValue(PriceType type)
Gets the total worth of the container using the item's values.
final Item[] toArray()
Returns a shallow copy of the backing array.
The container that manages the equipment for a player.
static final int CHEST_SLOT
static final int RING_SLOT
static final int AMULET_SLOT
static final int WEAPON_SLOT
static final int HEAD_SLOT
Equipment slot constants.
static final int SHIELD_SLOT
static final int FEET_SLOT
static final int LEGS_SLOT
static final int ARROWS_SLOT
static final int HANDS_SLOT
static final int CAPE_SLOT
Contains traversal data for a set of regions.
static Position getRandomTraversableTile(Position southWest, int width, int length)
static Position getRandomNonDiagonal(Position from)
Represents a single tile on the game world.
The OutgoingPacket that sends a message to a Players chatbox in the client.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
Handles miscellaneous methods.
static String formatName(final String input)
static String formatDigits(final int amount)
Formats digits for integers.
static double getPercentageAmount(int progress, int total)
Gets a percentage amount.
static String getTime()
Gets the current server time and formats it.
Created by Daniel on 2018-01-28.
Holds all activity types that are timed.
FormulaModifier< Mob > getFormula()
An enumerated type defining policies for stackable Items.
STANDARD
The STANDARD policy, items are only stacked if they are defined as stackable in their ItemDefinition ...
The enumerated types of a players equipped item slots.
VALUE
The value price type.