1package com.runehive.game.world.entity.mob.player.exchange.duel;
3import com.runehive.content.activity.Activity;
4import com.runehive.content.activity.impl.duelarena.DuelArenaActivity;
5import com.runehive.content.activity.impl.duelarena.DuelRule;
6import com.runehive.content.activity.impl.duelarena.DuelUtils;
7import com.runehive.game.world.InterfaceConstants;
8import com.runehive.game.world.entity.mob.player.Player;
9import com.runehive.game.world.entity.mob.player.PlayerRight;
10import com.runehive.game.world.entity.mob.player.exchange.ExchangeCompletionType;
11import com.runehive.game.world.entity.mob.player.exchange.ExchangeSession;
12import com.runehive.game.world.entity.mob.player.exchange.ExchangeSessionType;
13import com.runehive.game.world.items.Item;
14import com.runehive.net.packet.out.*;
15import com.runehive.util.MessageColor;
16import com.runehive.util.Utility;
18import java.util.EnumSet;
19import java.util.Optional;
20import java.util.stream.IntStream;
43 if(
player.playTime < 6000) {
44 player.message(
"You must have at least 1 hour of play time before duelling.");
47 if(
other.playTime < 6000) {
48 player.message(
"The other player must have at least 1 hour of play time before duelling.");
53 player.exchangeSession.requested_players.add(
other);
55 if (!
other.exchangeSession.requested_players.contains(
player)) {
66 player.exchangeSession.resetRequests();
72 player.attributes.set(
"DUEL_KEY",
true);
89 String username =
other.getName();
101 player.send(
new SendString(
"<col=ffffff>Waiting for other player...", 31009));
102 other.send(
new SendString(
"<col=ffffff>Other player has accepted", 31009));
105 case "SECOND_SCREEN":
115 player.send(
new SendString(
"<col=ffffff>Waiting for other player...", 31526));
116 other.send(
new SendString(
"<col=ffffff>Other player has accepted", 31526));
135 rule.ifPresent(r -> r.set(
player,
true));
152 EnumSet<DuelRule> flags =
activity.rules.getFlags();
153 player.attributes.put(
"duel_rules", flags);
163 EnumSet<DuelRule> flags =
player.attributes.get(
"duel_rules");
165 flags.forEach(it -> it.set(
player,
true));
198 case "SECOND_SCREEN":
202 p.send(
new SendString(
"Some worn items will be taken off.", 31505));
203 p.send(
new SendString(
"Boosted stats will be restored.", 31506));
204 p.send(
new SendString(
"Existing prayers will be stopped.", 31507));
205 IntStream.range(31509, 31520).forEach(i -> p.send(
new SendString(
"", i)));
207 IntStream.range(31531, 31560).forEach(i -> p.send(
new SendString(
"", i)));
208 IntStream.range(31561, 31589).forEach(i -> p.send(
new SendString(
"", i)));
230 p.send(
new SendString(
"Opponent's combat level: <col=ff7000>" +
other.skills.getCombatLevel(), 31006));
242 player.attributes.set(
"DUEL_KEY",
false);
252 if (!result.isPresent()) {
260 if (
activity.rules.contains(rule)) {
A Activity object constructs an in-game activity and sequences it through the start() and finish() me...
static< T extends Activity > Optional< T > search(Player player, Class< T > clazz)
static DuelArenaActivity create(StakeSession session, Player player, Player opponent)
static String getItemNames(Item[] items)
static String getRuleText(DuelRule rule)
The class that contains helpful information on interfaces.
static final int OTHER_STAKE_CONTAINER
static final int FIRST_DUEL_SCREEN
static final int PLAYER_STAKE_CONTAINER
static final int SECOND_DUEL_SCREEN
This class represents a character controlled by a player.
String getName()
Gets the name of this entity.
void send(OutgoingPacket encoder)
boolean hasAttachment()
Determines if the trade stage has an attachment.
final Player other
The other player in this session.
final Player player
The controller of this session.
static final Set< ExchangeSession > SESSIONS
The collection of sessions.
Object getAttachment()
Retrieves the attachment object to this class.
final Map< Player, ItemContainer > item_containers
The items which are in this exchange session.
ExchangeSession(Player player, Player other, ExchangeSessionType type)
Constructs a new ExchangeSession.
void setAttachment(Object attachment)
Assigns an attachment to this stage object.
void finalize(ExchangeCompletionType type)
Finalizes the exchange session procedure for the specified player in a session.
void forEach(Consumer< Player > action)
Executes the specified action for every player in this session.
Player getOther(Player p)
Gets the other player in the exchange session.
void showDuelRulesOnSecondScreen(Player p)
boolean canAddItem(Player player, Item item, int slot)
Checks if the item can be added to the container.
DuelArenaActivity activity
boolean onButtonClick(Player player, int button)
The method invoked when a button is clicked.
void accept(Player player, String component)
The method invoked when a PLAYER accepts a certain exchange component.
boolean onRequest()
The method invoked when a player requests the other player.
void updateOfferComponents()
Updates the itemcontainer when an item is offered or removed.
void updateMainComponents(String component)
Updates the main components of the itemcontainer.
boolean canRemoveItem(Player player, Item item, int slot)
Checks if the item can be removed from the container.
void onReset()
Any functionality that should be handled when the itemcontainer closes.
StakeSession(Player owner, Player other)
The container class that represents an item that can be interacted with.
The OutgoingPacket responsible for changing settings on a client.
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 Optional< DuelRule > forButton(int button)
static void showRules(DuelArenaActivity activity, Player player, Player other)
Holds all the player right data.
static String getCrown(Player player)
Gets the crown display.
HALT
Determines the items should be halted.
Represents the state a minimap can be in.
UNCLICKABLE
The state where the map is visible, but clicking is disabled.
NORMAL
The default state where the map is visible and clicking is enabled.
Holds an enum of colors for ease.