RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.activity.lobby.LobbyManager Class Referenceabstract
Inheritance diagram for com.runehive.content.activity.lobby.LobbyManager:

Public Member Functions

boolean canStart (LobbyNode node)
final void enter (Player player)
int getGameCapacity ()
int getGameCooldown ()
int getLobbyCooldown ()
int getMinimumRequired ()
int getPlayerCapacity ()
final void leave (Player player)
final void sequenceActive ()

Protected Member Functions

abstract LobbyNode createLobby ()
void exceededGameCapacity (Player player)
void exceededPlayerCapacity (Player player)
 LobbyManager (int gameCapacity, int playerCapacity, int minimumRequired, int lobbyCooldown, int gameCooldown)
void onEnter (Player player)
void onLeave (Player player)

Private Member Functions

LobbyNode findNode (Player player)
LobbyNode nextLobby ()

Private Attributes

final Deque< LobbyNodeactive = new LinkedList<>()
final int gameCapacity
final int gameCooldown
final int lobbyCooldown
final int minimumRequired
final int playerCapacity

Detailed Description

Definition at line 9 of file LobbyManager.java.

Constructor & Destructor Documentation

◆ LobbyManager()

com.runehive.content.activity.lobby.LobbyManager.LobbyManager ( int gameCapacity,
int playerCapacity,
int minimumRequired,
int lobbyCooldown,
int gameCooldown )
protected

Definition at line 18 of file LobbyManager.java.

18 {
19 this.playerCapacity = playerCapacity;
20 this.gameCapacity = gameCapacity;
21 this.lobbyCooldown = lobbyCooldown;
22 this.gameCooldown = gameCooldown;
23 this.minimumRequired = minimumRequired;
24 }

References gameCapacity, gameCooldown, lobbyCooldown, minimumRequired, and playerCapacity.

Member Function Documentation

◆ canStart()

boolean com.runehive.content.activity.lobby.LobbyManager.canStart ( LobbyNode node)

Definition at line 121 of file LobbyManager.java.

121 {
122 if (!node.lobby) {
123 return false;
124 }
125
126 int activeGames = 0;
127 for (LobbyNode activity : active) {
128 if (!activity.lobby)
129 activeGames++;
130 }
131
132 if (activeGames >= gameCapacity) {
133 node.cooldown(lobbyCooldown);
134 node.forEachActivity((mob, activity) -> {
135 if (mob.isPlayer()) {
136 exceededGameCapacity(mob.getPlayer());
137 }
138 });
139 return false;
140 }
141
142 if (minimumRequired > node.getActiveSize()) {
143 node.cooldown(lobbyCooldown);
144 node.groupMessage("This activity requires at least " + minimumRequired + " players to start.");
145 return false;
146 }
147
148 return true;
149 }

References active, com.runehive.content.activity.Activity.cooldown, exceededGameCapacity(), com.runehive.content.activity.GroupActivity.forEachActivity(), gameCapacity, com.runehive.content.activity.GroupActivity.getActiveSize(), com.runehive.content.activity.GroupActivity.groupMessage(), com.runehive.content.activity.lobby.LobbyNode.lobby, lobbyCooldown, and minimumRequired.

Here is the call graph for this function:

◆ createLobby()

abstract LobbyNode com.runehive.content.activity.lobby.LobbyManager.createLobby ( )
abstractprotected

Reimplemented in com.runehive.content.activity.impl.battleground.BattlegroundLobby, and com.runehive.content.activity.impl.pestcontrol.PestControlLobby.

Referenced by nextLobby().

Here is the caller graph for this function:

◆ enter()

final void com.runehive.content.activity.lobby.LobbyManager.enter ( Player player)

Definition at line 26 of file LobbyManager.java.

26 {
27 LobbyNode lobby = nextLobby();
28
29 if (lobby == null) {
30 return;
31 }
32
33 if (lobby.getActiveSize() >= playerCapacity) {
34 exceededPlayerCapacity(player);
35 return;
36 }
37
38 lobby.addActivity(player, lobby.createActivity(player));
39
40 /* reset lobby cooldown since first player just joined */
41 if (minimumRequired > -1 && lobby.getActiveSize() == 1) {
42 lobby.cooldown(lobbyCooldown);
43 }
44
45 onEnter(player);
46 }

References exceededPlayerCapacity(), lobbyCooldown, minimumRequired, nextLobby(), onEnter(), and playerCapacity.

Here is the call graph for this function:

◆ exceededGameCapacity()

void com.runehive.content.activity.lobby.LobbyManager.exceededGameCapacity ( Player player)
protected

Reimplemented in com.runehive.content.activity.impl.pestcontrol.PestControlLobby.

Definition at line 87 of file LobbyManager.java.

87 {
88 /* do nothing by default */
89 }

Referenced by canStart().

Here is the caller graph for this function:

◆ exceededPlayerCapacity()

void com.runehive.content.activity.lobby.LobbyManager.exceededPlayerCapacity ( Player player)
protected

Reimplemented in com.runehive.content.activity.impl.pestcontrol.PestControlLobby.

Definition at line 91 of file LobbyManager.java.

91 {
92 /* do nothing by default */
93 }

Referenced by enter().

Here is the caller graph for this function:

◆ findNode()

LobbyNode com.runehive.content.activity.lobby.LobbyManager.findNode ( Player player)
private

Definition at line 95 of file LobbyManager.java.

95 {
96 for (LobbyNode node : active) {
97 if (node.contains(player)) {
98 return node;
99 }
100 }
101 return null;
102 }

References active.

Referenced by leave().

Here is the caller graph for this function:

◆ getGameCapacity()

int com.runehive.content.activity.lobby.LobbyManager.getGameCapacity ( )

Definition at line 151 of file LobbyManager.java.

151 {
152 return gameCapacity;
153 }

References gameCapacity.

◆ getGameCooldown()

int com.runehive.content.activity.lobby.LobbyManager.getGameCooldown ( )

Definition at line 163 of file LobbyManager.java.

163 {
164 return gameCooldown;
165 }

References gameCooldown.

◆ getLobbyCooldown()

int com.runehive.content.activity.lobby.LobbyManager.getLobbyCooldown ( )

Definition at line 167 of file LobbyManager.java.

167 {
168 return lobbyCooldown;
169 }

References lobbyCooldown.

◆ getMinimumRequired()

int com.runehive.content.activity.lobby.LobbyManager.getMinimumRequired ( )

Definition at line 159 of file LobbyManager.java.

159 {
160 return minimumRequired;
161 }

References minimumRequired.

◆ getPlayerCapacity()

int com.runehive.content.activity.lobby.LobbyManager.getPlayerCapacity ( )

Definition at line 155 of file LobbyManager.java.

155 {
156 return playerCapacity;
157 }

References playerCapacity.

◆ leave()

final void com.runehive.content.activity.lobby.LobbyManager.leave ( Player player)

Definition at line 48 of file LobbyManager.java.

48 {
49 LobbyNode lobby = findNode(player);
50
51 if (lobby == null) {
52 return;
53 }
54
55 lobby.removeActivity(player);
56 onLeave(player);
57 }

References findNode(), and onLeave().

Here is the call graph for this function:

◆ nextLobby()

LobbyNode com.runehive.content.activity.lobby.LobbyManager.nextLobby ( )
private

Definition at line 104 of file LobbyManager.java.

104 {
105 for (LobbyNode node : active) {
106 if (node.inLobby()) {
107 return node;
108 }
109 }
110
111 if (active.size() >= 1 + gameCapacity) {
112 return null;
113 }
114
115 LobbyNode activity = createLobby();
116 active.addFirst(activity);
117 activity.lobby = true;
118 return activity;
119 }

References active, createLobby(), and gameCapacity.

Referenced by enter().

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

◆ onEnter()

void com.runehive.content.activity.lobby.LobbyManager.onEnter ( Player player)
protected

Reimplemented in com.runehive.content.activity.impl.pestcontrol.PestControlLobby.

Definition at line 79 of file LobbyManager.java.

79 {
80 /* do nothing by default */
81 }

Referenced by enter().

Here is the caller graph for this function:

◆ onLeave()

void com.runehive.content.activity.lobby.LobbyManager.onLeave ( Player player)
protected

Reimplemented in com.runehive.content.activity.impl.pestcontrol.PestControlLobby.

Definition at line 83 of file LobbyManager.java.

83 {
84 /* do nothing by default */
85 }

Referenced by leave().

Here is the caller graph for this function:

◆ sequenceActive()

final void com.runehive.content.activity.lobby.LobbyManager.sequenceActive ( )

Definition at line 59 of file LobbyManager.java.

59 {
60 Iterator<LobbyNode> iterator = active.iterator();
61
62 while (iterator.hasNext()) {
63 LobbyNode node = iterator.next();
64
65 if (node.finished()) {
66 node.finish();
67 node.removeAll();
68 node.cleanup();
69 iterator.remove();
70 continue;
71 }
72
73 node.sequence();
74 }
75 }

References active, com.runehive.content.activity.GroupActivity.cleanup(), com.runehive.content.activity.GroupActivity.finish(), com.runehive.content.activity.lobby.LobbyNode.finished(), com.runehive.content.activity.GroupActivity.removeAll(), and com.runehive.content.activity.Activity.sequence().

Here is the call graph for this function:

Member Data Documentation

◆ active

final Deque<LobbyNode> com.runehive.content.activity.lobby.LobbyManager.active = new LinkedList<>()
private

Definition at line 10 of file LobbyManager.java.

Referenced by canStart(), findNode(), nextLobby(), and sequenceActive().

◆ gameCapacity

final int com.runehive.content.activity.lobby.LobbyManager.gameCapacity
private

◆ gameCooldown

final int com.runehive.content.activity.lobby.LobbyManager.gameCooldown
private

◆ lobbyCooldown

final int com.runehive.content.activity.lobby.LobbyManager.lobbyCooldown
private

◆ minimumRequired

final int com.runehive.content.activity.lobby.LobbyManager.minimumRequired
private

◆ playerCapacity

final int com.runehive.content.activity.lobby.LobbyManager.playerCapacity
private

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