RuneHive-Game
Loading...
Searching...
No Matches
Killstreak.java
Go to the documentation of this file.
1
package
com.runehive.content.combat;
2
3
import
com.runehive.content.achievement.AchievementHandler;
4
import
com.runehive.content.achievement.AchievementKey;
5
import
com.runehive.game.world.World;
6
import
com.runehive.game.world.entity.mob.player.Player;
7
import
com.runehive.game.world.entity.mob.player.PlayerRight;
8
import
com.runehive.game.world.items.Item;
9
import
com.runehive.util.Utility;
10
11
public
class
Killstreak
{
12
private
final
Player
player
;
13
public
int
streak
;
14
15
public
Killstreak
(
Player
player
) {
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) {
54
AchievementHandler
.
activate
(
player
,
AchievementKey
.
KILLSTKREAK_5
);
55
}
else
if
(
streak
== 10) {
56
AchievementHandler
.
activate
(
player
,
AchievementKey
.
KILLSTKREAK_10
);
57
}
else
if
(
streak
== 15) {
58
AchievementHandler
.
activate
(
player
,
AchievementKey
.
KILLSTKREAK_15
);
59
}
else
if
(
streak
== 25) {
60
AchievementHandler
.
activate
(
player
,
AchievementKey
.
KILLSTKREAK_25
);
61
}
62
}
63
64
private
boolean
announcementNeeded
() {
65
return
streak
>= 5;
66
}
67
}
com.runehive.content.achievement.AchievementHandler
Handles the achievements.
Definition
AchievementHandler.java:13
com.runehive.content.achievement.AchievementHandler.activate
static void activate(Player player, AchievementKey achievement)
Activates the achievement for the individual player.
Definition
AchievementHandler.java:20
com.runehive.content.combat.Killstreak.player
final Player player
Definition
Killstreak.java:12
com.runehive.content.combat.Killstreak.Killstreak
Killstreak(Player player)
Definition
Killstreak.java:15
com.runehive.content.combat.Killstreak.reward
void reward()
Definition
Killstreak.java:41
com.runehive.content.combat.Killstreak.add
void add()
Definition
Killstreak.java:19
com.runehive.content.combat.Killstreak.streak
int streak
Definition
Killstreak.java:13
com.runehive.content.combat.Killstreak.end
void end(Player killer)
Definition
Killstreak.java:28
com.runehive.content.combat.Killstreak.announcementNeeded
boolean announcementNeeded()
Definition
Killstreak.java:64
com.runehive.content.combat.Killstreak.announce
void announce()
Definition
Killstreak.java:47
com.runehive.game.world.World
Represents the game world.
Definition
World.java:46
com.runehive.game.world.World.sendMessage
static void sendMessage(String... messages)
Sends a global message.
Definition
World.java:396
com.runehive.game.world.entity.mob.player.Player
This class represents a character controlled by a player.
Definition
Player.java:125
com.runehive.game.world.entity.mob.player.Player.inventory
final Inventory inventory
Definition
Player.java:325
com.runehive.game.world.entity.mob.player.Player.message
void message(String message)
Definition
Player.java:572
com.runehive.game.world.entity.mob.player.Player.getName
String getName()
Gets the name of this entity.
Definition
Player.java:774
com.runehive.game.world.items.Item
The container class that represents an item that can be interacted with.
Definition
Item.java:21
com.runehive.game.world.items.containers.inventory.Inventory.addOrDrop
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...
Definition
Inventory.java:118
com.runehive.util.Utility
Handles miscellaneous methods.
Definition
Utility.java:27
com.runehive.util.Utility.formatDigits
static String formatDigits(final int amount)
Formats digits for integers.
Definition
Utility.java:41
com.runehive.content.achievement.AchievementKey
Definition
AchievementKey.java:3
com.runehive.content.achievement.AchievementKey.KILLSTKREAK_25
KILLSTKREAK_25
Definition
AchievementKey.java:18
com.runehive.content.achievement.AchievementKey.KILLSTKREAK_15
KILLSTKREAK_15
Definition
AchievementKey.java:17
com.runehive.content.achievement.AchievementKey.KILLSTKREAK_5
KILLSTKREAK_5
Definition
AchievementKey.java:15
com.runehive.content.achievement.AchievementKey.KILLSTKREAK_10
KILLSTKREAK_10
Definition
AchievementKey.java:16
com.runehive.game.world.entity.mob.player.PlayerRight
Holds all the player right data.
Definition
PlayerRight.java:11
com.runehive.game.world.entity.mob.player.PlayerRight.getCrown
static String getCrown(Player player)
Gets the crown display.
Definition
PlayerRight.java:153