RuneHive-Game
Loading...
Searching...
No Matches
ClanmasterDialogue.java
Go to the documentation of this file.
1package com.runehive.content.dialogue.impl;
2
3import com.runehive.content.clanchannel.ClanMember;
4import com.runehive.content.clanchannel.channel.ClanChannel;
5import com.runehive.content.clanchannel.content.ClanLevel;
6import com.runehive.content.clanchannel.content.ClanTask;
7import com.runehive.content.clanchannel.content.ClanViewer;
8import com.runehive.content.dialogue.Dialogue;
9import com.runehive.content.dialogue.DialogueFactory;
10import com.runehive.content.store.Store;
11import com.runehive.game.world.entity.mob.player.Player;
12import com.runehive.net.packet.out.SendItemOnInterface;
13import com.runehive.net.packet.out.SendScrollbar;
14import com.runehive.net.packet.out.SendString;
15import com.runehive.util.Difficulty;
16import com.runehive.util.Utility;
17
18import java.util.Optional;
19
20/**
21 * Handles the clan master dialogue.
22 *
23 * @author Daniel
24 */
25public class ClanmasterDialogue extends Dialogue {
26
27 @Override
28 public void sendDialogues(DialogueFactory factory) {
29 Player player = factory.getPlayer();
30 factory.sendNpcChat(3841, "Ello mate!", "What can I do you for today?");
31 factory.sendOption("Information on Clans", () -> clanInformation(factory),
32 "World Clan List", () -> player.clanViewer.open(ClanViewer.ClanTab.OVERVIEW),
33 "Clan Management", () -> clanManagement(factory),
34 "Clan Levels", () -> clanLevel(factory.getPlayer()),
35 "Nevermind", factory::clear);
36 factory.execute();
37 }
38
39 private void mainOptions(DialogueFactory factory) {
40 }
41
42 /** The clan information dialogue. */
43 private void clanInformation(DialogueFactory factory) {
44 factory.sendOption("What is a clan?", () -> clanDefinition(factory),
45 "What are clan perks?", () -> clanPerks(factory),
46 "Nevermind", factory::clear);
47 }
48
49 private void clanDefinition(DialogueFactory factory) {
50 factory.sendNpcChat(3841, "A clan is a united group or syndicate of players",
51 "who work together to complete various tasks depending on the", "clan type. Clans members can identify one another",
52 "by the purple dot on the minimap or their clan tag.");
53 }
54
55 private void clanPerks(DialogueFactory factory) {
56 factory.sendNpcChat(3841,
57 "I offer many perks and items to be used for clans.",
58 "Clan perks affect all online clan members when used.",
59 "These perks vary from rewarding everyone with",
60 "random experience in a random skill to having a drop modifier");
61 factory.sendNpcChat(3841, "for a certain amount of time.");
62 }
63
64 /** The clan management dialogue. */
65 private void clanManagement(DialogueFactory factory) {
66 Player player = factory.getPlayer();
67 ClanChannel channel = player.clanChannel;
68
69 if (channel == null) {
70 factory.sendNpcChat(3841, "You must be in a clan in order to do this!");
71 return;
72 }
73
74 Optional<ClanMember> member = channel.getMember(player.getName());
75
76 if (!member.isPresent() || !channel.canManage(member.get())) {
77 factory.sendNpcChat(3841, "You do not have the proper authorization to manage", "the clan " + channel.getName() + "! If you want to manage your own clan", "please join your own clan and then speak to me again.");
78 return;
79 }
80
81 factory.sendOption("View store", () -> Store.STORES.get("The Clanmaster's Store").open(player), "Manage tasks", () -> clanTask(channel, factory), "Nevermind", factory::clear);
82 }
83
84 /** The clan task dialogue. */
85 private void clanTask(ClanChannel channel, DialogueFactory factory) {
86 ClanTask task = channel.getDetails().clanTask;
87 factory.sendOption("Task Information", () -> {
88 if (task == null) {
89 factory.sendStatement("Your clan currently does not have a task assigned!");
90 return;
91 }
92
93 factory.sendStatement("Your current task is to:", task.getName(channel));
94 }, "Obtain Clan Task", () -> {
95 if (task != null) {
96 factory.sendNpcChat(3841, "Your clan currently has a task assigned!", "Cancel or complete it to obtain another one.");
97 return;
98 }
99 factory.sendOption("Easy Task - <col=255>2 CP</col> Reward", () -> channel.receiveTask(Difficulty.EASY), "Medium Task - <col=255>3 CP</col> Reward", () -> channel.receiveTask(Difficulty.MEDIUM), "Hard Task - <col=255>5 CP</col> Reward", () -> channel.receiveTask(Difficulty.HARD));
100 }, "Cancel Clan Task (<col=FF2929>5 CP</col>)", () -> {
101 if (task == null) {
102 factory.sendStatement("Your clan currently does not have a task assigned!");
103 return;
104 }
105 if (channel.getDetails().points < 5) {
106 factory.sendStatement("You do not have enough points to cancel your task.", "Current CP: " + channel.getDetails().points);
107 return;
108 }
109 channel.getDetails().points -= 5;
110 channel.getDetails().taskAmount = -1;
111 channel.getDetails().clanTask = null;
112 channel.message("Our clan task was cancelled for 25 CP. We have <col=255>" + Utility.formatDigits(channel.getDetails().points) + "</col> remaining.");
113 }, "Nevermind", factory::clear);
114 }
115
116 /** Displays all the clan level information. */
117 private void clanLevel(Player player) {
118 int size = ClanLevel.values().length;
119 for (int index = 0, string = 37111; index < size; index++) {
120 ClanLevel level = ClanLevel.values()[index];
121 String color = "<col=" + level.getColor() + ">";
122 String experience = "Experience: <col=7A6856>" + Utility.formatDigits(level.getExperience()) + "</col>";
123 String points = "Points: <col=7A6856>" + Utility.formatDigits(level.getPoints()) + "</col>";
124 player.send(new SendString(color + Utility.formatEnum(level.name()), string));
125 string++;
126 player.send(new SendString(experience + " <col=000000>|</col> " + points, string));
127 string++;
128 player.send(new SendString("", string));
129 string++;
130 }
131 player.send(new SendString("", 37107));
132 player.send(new SendString("Clan Levels Information", 37103));
133 player.send(new SendScrollbar(37110, 750));
134 player.send(new SendItemOnInterface(37199));
135 player.interfaceManager.open(37100);
136 }
137}
Optional< ClanMember > getMember(String name)
void message(Object... messages)
Handles messaging all the members in the clan channel.
Represents a factory class that contains important functions for building dialogues.
final DialogueFactory execute()
Retrieves the next dialogue in the chain and executes it.
Player getPlayer()
The player that owns this factory.
final DialogueFactory sendNpcChat(int id, String... lines)
Appends an NpcDialogue to the current dialogue chain.
final DialogueFactory sendStatement(String... lines)
Appends a StatementDialogue to the current dialogue chain.
final DialogueFactory sendOption(String option1, Runnable action1, String option2, Runnable action2)
Appends the OptionDialogue onto the current dialogue chain.
Represents an abstract dialogue, in which extending classes will be able to construct and send dialog...
Definition Dialogue.java:11
void clanManagement(DialogueFactory factory)
The clan management dialogue.
void clanInformation(DialogueFactory factory)
The clan information dialogue.
void sendDialogues(DialogueFactory factory)
Sends a player a dialogue.
void clanLevel(Player player)
Displays all the clan level information.
void clanTask(ClanChannel channel, DialogueFactory factory)
The clan task dialogue.
The class which holds support for further abstraction for shops.
Definition Store.java:20
static Map< String, Store > STORES
A mapping of each shop by it's name.
Definition Store.java:23
void open(int identification)
Opens an interface for the player.
This class represents a character controlled by a player.
Definition Player.java:125
String getName()
Gets the name of this entity.
Definition Player.java:774
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
Handles miscellaneous methods.
Definition Utility.java:27
static String formatDigits(final int amount)
Formats digits for integers.
Definition Utility.java:41
static String formatEnum(final String string)
Formats name of enum.
Definition Utility.java:89
Handles the clan levels (based off the total experience earned).
Definition ClanLevel.java:8
int getPoints()
Gets the points rewarded for leveling up.
long getExperience()
Gets the experience of the clan level.
String getColor()
Gets the clan level color.
Created by Daniel on 2017-11-27.