RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.WellOfGoodwill Class Reference

Handles contribution towards the well of goodwill. More...

Classes

class  Contributor

Static Public Member Functions

static void activate ()
 Handles activating the well.
static void add (String name, PlayerRight rank, int amount)
static void contribute (Player player, int amount)
 Handles contributing to the well.
static String getInformation ()
 The information displayed on information tab.
static String isActivated ()
static boolean isActive ()
static void open (Player player)
 Opens the well itemcontainer.

Static Public Attributes

static boolean active
static int activeTime = -1
static int CONTRIBUTION
 The current contribution amount for the well.
static TreeSet< Contributorcontributors = new TreeSet<>()
 The array list of contributors.
static String lastContributor
 The last contributor to the well.
static final int MAXIMUM = 15_000_000
 The maximum contribution limit for the well.

Detailed Description

Handles contribution towards the well of goodwill.

Author
Daniel.

Definition at line 24 of file WellOfGoodwill.java.

Member Function Documentation

◆ activate()

void com.runehive.content.WellOfGoodwill.activate ( )
static

Handles activating the well.

Definition at line 118 of file WellOfGoodwill.java.

118 {
119 activeTime = 0;
120 World.schedule(new DoubleExperienceEvent());
121 World.sendMessage("<col=2b58a0>WOG</col>: The well has been fully replenished. 30 minutes of double XP is active.");
122 active = true;
123 }

References active, activeTime, com.runehive.game.world.World.schedule(), and com.runehive.game.world.World.sendMessage().

Referenced by contribute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add()

void com.runehive.content.WellOfGoodwill.add ( String name,
PlayerRight rank,
int amount )
static

Definition at line 125 of file WellOfGoodwill.java.

125 {
126 Contributor contributor = new Contributor(name, rank, amount);
127 for (Iterator<Contributor> iterator = contributors.iterator(); iterator.hasNext(); ) {
128 Contributor other = iterator.next();
129 if (contributor.name.equals(other.name)) {
130 contributor.add(other.contribution);
131 iterator.remove();
132 break;
133 }
134 }
135 contributors.add(contributor);
136 }

References com.runehive.content.WellOfGoodwill.Contributor.add(), com.runehive.content.WellOfGoodwill.Contributor.contribution, contributors, and com.runehive.content.WellOfGoodwill.Contributor.name.

Referenced by contribute(), and com.runehive.util.GameSaver.load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ contribute()

void com.runehive.content.WellOfGoodwill.contribute ( Player player,
int amount )
static

Handles contributing to the well.

Definition at line 71 of file WellOfGoodwill.java.

71 {
72 /* if (PlayerRight.isAdministrator(player)) {
73 player.message("Administrators cannot contribute.");
74 return;
75 }
76*/
77 if (Config.DOUBLE_EXPERIENCE) {
78 player.message("Double experience is currently active which has temporarily disabled the wog.");
79 return;
80 }
81
82 if (amount < 100_000) {
83 player.message("You must contribute at least 100k into the well.");
84 return;
85 }
86
87 if (isActive()) {
88 player.message("The well is currently active and does not need", "any contribution.");
89 return;
90 }
91
92 if (amount > MAXIMUM - CONTRIBUTION) {
93 amount = MAXIMUM - CONTRIBUTION;
94 }
95
96 if (!player.inventory.contains(new Item(995, amount))) {
97 player.message("You do not have the required funds to contribute!");
98 return;
99 }
100
101 player.inventory.remove(new Item(995, amount));
102 CONTRIBUTION += amount;
103
104 add(player.getName(), player.right, amount);
105 lastContributor = PlayerRight.getCrown(player) + " <col=ffb83f>" + player.getName() + "</col> (" + Utility.formatDigits(amount) + ")";
106
107 player.message("Thank you! Your contribution of " + Utility.formatDigits(amount) + "gp to the well is appreciated!");
108
109 if (amount >= 250000) {
110 World.sendMessage("<col=2b58a0>WOG</col>: " + PlayerRight.getCrown(player) + "<col=2b58a0>" + player.getName() + "</col> has just contributed <col=2b58a0>" + Utility.formatDigits(amount) + "</col> coins.");
111 }
112
113 if (CONTRIBUTION >= MAXIMUM) activate();
114 open(player);
115 }

References activate(), add(), com.runehive.game.world.items.containers.ItemContainer.contains(), CONTRIBUTION, com.runehive.Config.DOUBLE_EXPERIENCE, com.runehive.util.Utility.formatDigits(), com.runehive.game.world.entity.mob.player.PlayerRight.getCrown(), com.runehive.game.world.entity.mob.player.Player.getName(), com.runehive.game.world.entity.mob.player.Player.inventory, isActive(), lastContributor, MAXIMUM, com.runehive.game.world.entity.mob.player.Player.message(), open(), com.runehive.game.world.items.containers.ItemContainer.remove(), com.runehive.game.world.entity.mob.player.Player.right, and com.runehive.game.world.World.sendMessage().

Here is the call graph for this function:

◆ getInformation()

String com.runehive.content.WellOfGoodwill.getInformation ( )
static

The information displayed on information tab.

Definition at line 188 of file WellOfGoodwill.java.

188 {
189 return !active ? "Not Active" : isActivated();
190 }

References active, and isActivated().

Here is the call graph for this function:

◆ isActivated()

String com.runehive.content.WellOfGoodwill.isActivated ( )
static

Definition at line 141 of file WellOfGoodwill.java.

141 {
142 return "Active";
143 }

Referenced by getInformation().

Here is the caller graph for this function:

◆ isActive()

boolean com.runehive.content.WellOfGoodwill.isActive ( )
static

Definition at line 138 of file WellOfGoodwill.java.

138 {
139 return activeTime != -1;
140 }

References activeTime.

Referenced by com.runehive.game.world.entity.skill.SkillManager.addExperience(), contribute(), com.runehive.game.task.impl.DoubleExperienceEvent.execute(), com.runehive.RuneHive.onStart(), open(), and com.runehive.content.dialogue.impl.WellOfGoodwillDialogue.sendDialogues().

Here is the caller graph for this function:

◆ open()

void com.runehive.content.WellOfGoodwill.open ( Player player)
static

Opens the well itemcontainer.

Definition at line 44 of file WellOfGoodwill.java.

44 {
45 int progress = (int) Utility.getPercentageAmount(CONTRIBUTION, MAXIMUM);
46 int id = 43708;
47 int count = 0;
48
49 Iterator<Contributor> iterator = contributors.iterator();
50 while (count++ < 3 && iterator.hasNext()) {
51 Contributor contributor = iterator.next();
52 String rank = contributor.rank.getCrownText();
53 player.send(new SendString("Latest contributor:", 43711));
54 player.send(new SendString(rank + "<col=ffb83f>" + contributor.name + "</col> (" + Utility.formatDigits(contributor.contribution) + ")", id++));
55 }
56
57 for (int index = count; index < 3; index++) {
58 player.send(new SendString("", id + index));
59 }
60
61 if (isActive())
62 player.send(new SendMessage("The well will be active for " + (30 - activeTime) + " minutes."));
63
64 player.send(new SendProgressBar(43706, progress));
65 player.send(new SendString(lastContributor == null ? "" : lastContributor, 43712));
66 player.send(new SendString(progress + "%", 43717));
67 player.interfaceManager.open(43700);
68 }
val index

References activeTime, CONTRIBUTION, com.runehive.content.WellOfGoodwill.Contributor.contribution, contributors, com.runehive.util.Utility.formatDigits(), com.runehive.game.world.entity.mob.player.PlayerRight.getCrownText(), com.runehive.util.Utility.getPercentageAmount(), com.runehive.game.world.entity.mob.player.Player.interfaceManager, isActive(), lastContributor, MAXIMUM, com.runehive.content.WellOfGoodwill.Contributor.name, com.runehive.game.world.entity.mob.player.InterfaceManager.open(), com.runehive.content.WellOfGoodwill.Contributor.rank, and com.runehive.game.world.entity.mob.player.Player.send().

Referenced by contribute(), and com.runehive.content.dialogue.impl.WellOfGoodwillDialogue.sendDialogues().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ active

boolean com.runehive.content.WellOfGoodwill.active
static

Definition at line 30 of file WellOfGoodwill.java.

Referenced by activate(), and getInformation().

◆ activeTime

◆ CONTRIBUTION

int com.runehive.content.WellOfGoodwill.CONTRIBUTION
static

◆ contributors

TreeSet<Contributor> com.runehive.content.WellOfGoodwill.contributors = new TreeSet<>()
static

The array list of contributors.

Definition at line 34 of file WellOfGoodwill.java.

Referenced by add(), open(), and com.runehive.util.GameSaver.toJson().

◆ lastContributor

String com.runehive.content.WellOfGoodwill.lastContributor
static

The last contributor to the well.

Definition at line 37 of file WellOfGoodwill.java.

Referenced by contribute(), com.runehive.util.GameSaver.load(), open(), and com.runehive.util.GameSaver.toJson().

◆ MAXIMUM

final int com.runehive.content.WellOfGoodwill.MAXIMUM = 15_000_000
static

The maximum contribution limit for the well.

Definition at line 41 of file WellOfGoodwill.java.

Referenced by contribute(), open(), and com.runehive.content.dialogue.impl.WellOfGoodwillDialogue.sendDialogues().


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