RuneHive-Game
Loading...
Searching...
No Matches
Killstreak.java
Go to the documentation of this file.
1package com.runehive.content.combat;
2
3import com.runehive.content.achievement.AchievementHandler;
4import com.runehive.content.achievement.AchievementKey;
5import com.runehive.game.world.World;
6import com.runehive.game.world.entity.mob.player.Player;
7import com.runehive.game.world.entity.mob.player.PlayerRight;
8import com.runehive.game.world.items.Item;
9import com.runehive.util.Utility;
10
11public class Killstreak {
12 private final Player player;
13 public int streak;
14
16 this.player = player;
17 }
18
19 public void add() {
20 streak++;
21
22 if (announcementNeeded()) {
23 reward();
24 announce();
25 }
26 }
27
28 public void end(Player killer) {
29 if (announcementNeeded()) {
30 String icon = "<icon=0>";
31 String name = PlayerRight.getCrown(player) + " " + player.getName();
32 int bounty = streak * 150;
33 World.sendMessage("" + icon + " <col=FF0000>" + name + "</col> has lost their kill streak of <col=FF0000>" + streak + "</col> to <col=FF0000>" + killer.getName() + "</col>!");
34 killer.inventory.addOrDrop(new Item(13307, bounty));
35 killer.message("You were rewarded with " + Utility.formatDigits(bounty) + " blood money for claiming " + player.getName() + "'s bounty!");
36 }
37
38 streak = 0;
39 }
40
41 public void reward() {
42 int bm = streak * 500;
43 player.inventory.addOrDrop(new Item(13307, bm));
44 player.message("<col=FF0000>You are rewarded with " + Utility.formatDigits(bm) + " blood money.");
45 }
46
47 private void announce() {
48 String icon = "<icon=0>";
49 String name = PlayerRight.getCrown(player) + " " + player.getName();
50 int bounty = streak * 150;
51 World.sendMessage("<col=FF0000>" + icon + " " + name + " </col>is now on a killstreak of <col=FF0000>" + streak + "</col>. Bounty: <col=FF0000>" + Utility.formatDigits(bounty) + "</col> BM.");
52
53 if (streak == 5) {
55 } else if (streak == 10) {
57 } else if (streak == 15) {
59 } else if (streak == 25) {
61 }
62 }
63
64 private boolean announcementNeeded() {
65 return streak >= 5;
66 }
67}
static void activate(Player player, AchievementKey achievement)
Activates the achievement for the individual player.
Represents the game world.
Definition World.java:46
static void sendMessage(String... messages)
Sends a global message.
Definition World.java:396
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 container class that represents an item that can be interacted with.
Definition Item.java:21
void addOrDrop(List< Item > items)
Attempts to deposit an item to the players inventory, if there is no space it'll bank the item instea...
Handles miscellaneous methods.
Definition Utility.java:27
static String formatDigits(final int amount)
Formats digits for integers.
Definition Utility.java:41
static String getCrown(Player player)
Gets the crown display.