1package com.osroyale.game.world.entity.mob.player.exchange.duel;
3import com.osroyale.content.activity.Activity;
4import com.osroyale.content.activity.impl.duelarena.DuelArenaActivity;
5import com.osroyale.content.activity.impl.duelarena.DuelRule;
6import com.osroyale.content.activity.impl.duelarena.DuelUtils;
7import com.osroyale.game.world.InterfaceConstants;
8import com.osroyale.game.world.entity.mob.player.Player;
9import com.osroyale.game.world.entity.mob.player.PlayerRight;
10import com.osroyale.game.world.entity.mob.player.exchange.ExchangeCompletionType;
11import com.osroyale.game.world.entity.mob.player.exchange.ExchangeSession;
12import com.osroyale.game.world.entity.mob.player.exchange.ExchangeSessionType;
13import com.osroyale.game.world.items.Item;
14import com.osroyale.net.packet.out.*;
15import com.osroyale.util.MessageColor;
16import com.osroyale.util.Utility;
18import java.util.EnumSet;
19import java.util.Optional;
20import java.util.stream.IntStream;
63 public boolean accepted;
75 if(
player.playTime < 6000) {
76 player.message(
"You must have at least 1 hour of play time before duelling.");
79 if(
other.playTime < 6000) {
80 player.message(
"The other player must have at least 1 hour of play time before duelling.");
85 player.exchangeSession.requested_players.add(
other);
87 if (!
other.exchangeSession.requested_players.contains(
player)) {
98 player.exchangeSession.resetRequests();
104 player.attributes.set(
"DUEL_KEY",
true);
121 String username =
other.getName();
133 player.send(
new SendString(
"<col=ffffff>Waiting for other player...", 31009));
134 other.send(
new SendString(
"<col=ffffff>Other player has accepted", 31009));
137 case "SECOND_SCREEN":
142 activity.setPause(
false);
147 player.send(
new SendString(
"<col=ffffff>Waiting for other player...", 31526));
148 other.send(
new SendString(
"<col=ffffff>Other player has accepted", 31526));
166 Optional<DuelRule> rule =
DuelRule.forButton(button);
167 rule.ifPresent(r -> r.set(
player,
true));
183 if (activity !=
null) {
184 EnumSet<DuelRule> flags = activity.rules.getFlags();
185 player.attributes.put(
"duel_rules", flags);
194 if (
player.attributes.has(
"duel_rules") && activity !=
null) {
195 EnumSet<DuelRule> flags =
player.attributes.get(
"duel_rules");
196 activity.rules.reset();
197 flags.forEach(it -> it.set(
player,
true));
230 case "SECOND_SCREEN":
234 p.send(
new SendString(
"Some worn items will be taken off.", 31505));
235 p.send(
new SendString(
"Boosted stats will be restored.", 31506));
236 p.send(
new SendString(
"Existing prayers will be stopped.", 31507));
237 IntStream.range(31509, 31520).forEach(i -> p.send(
new SendString(
"", i)));
238 showDuelRulesOnSecondScreen(p);
239 IntStream.range(31531, 31560).forEach(i -> p.send(
new SendString(
"", i)));
240 IntStream.range(31561, 31589).forEach(i -> p.send(
new SendString(
"", i)));
241 p.send(
new SendString(
DuelUtils.getItemNames(
this.item_containers.get(p).toArray()), 31531));
242 p.send(
new SendString(
DuelUtils.getItemNames(
this.item_containers.get(recipient).toArray()), 31561));
262 p.send(
new SendString(
"Opponent's combat level: <col=ff7000>" +
other.skills.getCombatLevel(), 31006));
274 player.attributes.set(
"DUEL_KEY",
false);
281 private void showDuelRulesOnSecondScreen(
Player p) {
284 if (!result.isPresent()) {
288 DuelArenaActivity activity = result.get();
291 for (DuelRule rule : DuelRule.values()) {
292 if (activity.rules.contains(rule)) {
293 p.send(
new SendString(DuelUtils.getRuleText(rule), 31509 + count));
final Map< Player, ItemContainer > item_containers
ExchangeSession(Player player, Player other, ExchangeSessionType type)
static final Set< ExchangeSession > SESSIONS
Player getOther(Player p)
void finalize(ExchangeCompletionType type)
void forEach(Consumer< Player > action)
void setAttachment(Object attachment)
boolean onButtonClick(Player player, int button)
void accept(Player player, String component)
void updateOfferComponents()
boolean canRemoveItem(Player player, Item item, int slot)
boolean canAddItem(Player player, Item item, int slot)
void updateMainComponents(String component)
static String getCrown(Player player)