RuneHive-Game
Loading...
Searching...
No Matches
CurrencyType.java
Go to the documentation of this file.
1package com.runehive.content.store.currency;
2
3import com.google.common.collect.ImmutableSet;
4import com.runehive.content.store.currency.impl.*;
5import com.runehive.game.world.entity.mob.player.Player;
6import com.runehive.util.Utility;
7
8import java.util.Arrays;
9import java.util.Optional;
10
11/**
12 * The enumerated type whom holds all the currencies usable for a server.
13 *
14 * @author <a href="http://www.rune-server.org/members/stand+up/">Stand Up</a>
15 * @since 4-1-2017.
16 */
17public enum CurrencyType {
18 COINS(0, new ItemCurrency(995)),
19 TOKKUL(1, new ItemCurrency(6529)),
20 BLOOD_MONEY(2, new ItemCurrency(13307)),
23 STARDUST(6, new ItemCurrency(25527)),
33 ROYALE_TOKEN(14, new ItemCurrency(20527)),
35
36 private static final ImmutableSet<CurrencyType> VALUES = ImmutableSet.copyOf(values());
37
38 public final Currency currency;
39
40 public final int id;
41
43 this.id = id;
44 this.currency = currency;
45
46 }
47
48 public static Optional<CurrencyType> lookup(int id) {
49 return Arrays.stream(values()).filter(it -> it.getId() == id).findFirst();
50 }
51
52 public int getId() {
53 return id;
54 }
55
56 public static boolean isCurrency(int id) {
57 return VALUES.stream().filter(i -> i.currency.tangible()).anyMatch(i -> ((ItemCurrency) i.currency).itemId == id);
58 }
59
60 public static String getValue(Player player, CurrencyType currency) {
61 String value = "";
62 switch (currency) {
63 case COINS:
64 value = "Coins: " + Utility.formatDigits(player.inventory.contains(995) ? player.inventory.computeAmountForId(995) : 0);
65 break;
66 case TOKKUL:
67 value = "Tokkuls: " + Utility.formatDigits(player.inventory.contains(6529) ? player.inventory.computeAmountForId(6529) : 0);
68 break;
69 case GRACEFUL_TOKEN:
70 value = "Tokens: " + Utility.formatDigits(player.inventory.contains(11849) ? player.inventory.computeAmountForId(11849) : 0);
71 break;
72 case KOLODION_POINTS:
73 value = "Points: " + Utility.formatDigits(player.mageArenaPoints);
74 break;
75 case BLOOD_MONEY:
76 value = "BM: " + Utility.formatDigits(player.inventory.contains(13307) ? player.inventory.computeAmountForId(13307) : 0);
77 break;
78 case PLATINUM_TOKEN:
79 value = "Platinum Token: " + Utility.formatDigits(player.inventory.contains(13204) ? player.inventory.computeAmountForId(13204) : 0);
80 break;
81 case ROYALE_TOKEN:
82 value = "Royale Token: " + Utility.formatDigits(player.inventory.contains(20527) ? player.inventory.computeAmountForId(20527) : 0);
83 break;
84 case SLAYER_POINTS:
85 value = "Points: " + Utility.formatDigits(player.slayer.getPoints());
86 break;
87 case VOTE_POINTS:
88 value = "Points: " + Utility.formatDigits(player.votePoints);
89 break;
90 case PEST_POINTS:
91 value = "Points: " + Utility.formatDigits(player.pestPoints);
92 break;
93 case LMS_POINTS:
94 value = "Points: " + Utility.formatDigits(player.lmsPoints);
95 break;
96 case PRESTIGE_POINTS:
97 value = "Points: " + Utility.formatDigits(player.prestige.getPrestigePoint());
98 break;
99 case DONATOR_POINTS:
100 value = "Credits: " + Utility.formatDigits(player.donation.getCredits());
101 break;
102 case SKILLING_POINTS:
103 value = "Points: " + Utility.formatDigits(player.skillingPoints);
104 break;
105 case STARDUST:
106 value = "Stardust: " + Utility.formatDigits(player.inventory.contains(25527) ? player.inventory.computeAmountForId(25527) : 0);
107 break;
108 case CLAN_POINTS:
109 if (player.clanChannel == null) {
110 value = "0";
111 } else {
112 value = "CP: " + Utility.formatDigits(player.clanChannel.getDetails().points);
113 }
114 break;
115 }
116 return value;
117 }
118
119 @Override
120 public String toString() {
121 return name().toLowerCase().replace("_", " ");
122 }
123}
The currency that provides basic functionality for all tangible currencies.
This class represents a character controlled by a player.
Definition Player.java:125
final int computeAmountForId(int id)
Computes the total quantity of the Items in this container with id.
boolean contains(int id)
Determines if this container contains id.
Handles miscellaneous methods.
Definition Utility.java:27
static String formatDigits(final int amount)
Formats digits for integers.
Definition Utility.java:41
static Optional< CurrencyType > lookup(int id)
static final ImmutableSet< CurrencyType > VALUES
static String getValue(Player player, CurrencyType currency)
The parent class of all currencies that provides basic functionality for any general currency.
Definition Currency.java:11