RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.gambling.GambleManager Class Reference
Collaboration diagram for com.runehive.content.gambling.GambleManager:

Public Member Functions

void accept (Player player)
 Handles accepting the gamble.
void acceptRequest (Player player, Player other)
 Handles accepting a request.
boolean canGamble (Player player, GambleStage requiredStage)
 Checks if the player is allowed to gamble or not.
boolean canPlayFlowerPokerAtPositon (Player player, Position position)
 Checks if the position that was selected is suitable for a game of flower poker.
void decline (Player player)
 Handles declining the gamble.
void deposit (Player player, int itemId, int slot, int amount)
 Deposit a item into the gamble session.
void finish (Player host, Player opponent, int hostScore, int opponentScore)
 Handles finishing up a automated gamble.
ItemContainer getContainer ()
ArrayList< FlowersgetFlowers ()
Gamble getGame ()
ArrayList< CustomGameObjectgetGameFlowers ()
Player getOther ()
GambleStage getStage ()
GambleType getType ()
void give (GambleType gambleType, char winnerIdentifier, Player winner, Player loser, boolean draw)
 Handles giving the players the winnings or returning the items when its a draw.
void handleModeSelection (Player player, GambleType type)
 Handles setting the different game types.
boolean hasConfirmed ()
void open (Player player, Player other)
 Handles opening the interface.
void removeFlowers (Player player)
void reset (Player player)
 Handles resetting all the gambling variables for a player.
void sendRequest (Player player, Player other)
 Handles sending a request to another player.
void setConfirmed (boolean confirmed)
void setGame (Gamble game)
void setOther (Player other)
void setStage (GambleStage stage)
void setType (GambleType type)
void withdraw (Player player, int itemId, int slot, int amount)
 Withdraw an item from the gamble session.

Static Public Attributes

static final Boundary GAMBLING_ZONE = new Boundary(3148, 3476, 3181, 3505)

Protected Attributes

boolean confirmed
 Checks if the player has confirmed the gamble.
ItemContainer container = new ItemContainer(18, ItemContainer.StackPolicy.STANDARD)
 The container with gambled items of the player.
ArrayList< Flowersflowers = new ArrayList<Flowers>()
Gamble game
 The current gamble going on between the two players.
ArrayList< CustomGameObjectgameFlowers = new ArrayList<CustomGameObject>()
Player other
 The other player within this gamble.
GambleStage stage = GambleStage.NONE
 The current stage of the gamble.
GambleType type = GambleType.NONE
 The gamble type going on.

Private Member Functions

Gamble getGame (Player other, Player player, GambleType type)
 Get thet game based on the gamble type.
void send (GambleType gambleType, char winnerIdentifier, Player winner, Player loser)
 Handles sending the message for who won.
void start (Player player)
 Handles starting the gamble.

Private Attributes

final int CONFIG = 444
 The config used for selecting the game type.
final int INTERFACE_ID = 44750
 The main gambling interface.
final int INVENTORY_ID = 44775
 Interface id for the player's inventory.

Detailed Description

Definition at line 22 of file GambleManager.java.

Member Function Documentation

◆ accept()

void com.runehive.content.gambling.GambleManager.accept ( Player player)

Handles accepting the gamble.

Parameters
player

Definition at line 222 of file GambleManager.java.

222 {
223 Player other = player.getGambling().getOther();
224
225 if (other == null) return;
226
227 if(player.getGambling().getType() == null || player.getGambling().getType().equals(GambleType.NONE)) {
228 player.message("You need to select a game first.");
229 return;
230 }
231
232 if (System.currentTimeMillis() - player.getLastModification() < 5_000) {
233 player.message("@red@Something was changed in the last 5 seconds, you cannot accept yet.");
234 return;
235 }
236
237 if (player.getGambling().getType() != other.getGambling().getType()) return;
238
239 if(player.getGambling().hasConfirmed()) return;
240
241 player.getGambling().setConfirmed(true);
242
243 player.message("You have accepted the gamble with "+String.format(other.getUsername())+".");
244 other.message(String.format(player.getUsername()) + " has accepted the gamble.");
245
246 System.out.println("player: " + String.format(player.getUsername()));
247 System.out.println("other: " + String.format(other.getUsername()));
248
249 if (other.getGambling().hasConfirmed()) {
250 Gamble game = getGame(other, player, other.getGambling().getType());
251
252 player.getGambling().setGame(game);
253 other.getGambling().setGame(game);
254
255 player.getGambling().setStage(GambleStage.SENDING_OFFER);
256
257 player.getGambling().setOther(other);
258
259 System.out.println("Both confirmed start the game...");
260
261 start(player);
262 }
263 }

References game, com.runehive.game.world.entity.mob.player.Player.getGambling(), getGame(), com.runehive.game.world.entity.mob.player.Player.getLastModification(), getOther(), getType(), com.runehive.game.world.entity.mob.player.Player.getUsername(), hasConfirmed(), com.runehive.game.world.entity.mob.player.Player.message(), com.runehive.content.gambling.GambleType.NONE, other, com.runehive.content.gambling.GambleStage.SENDING_OFFER, setConfirmed(), setGame(), setOther(), setStage(), and start().

Here is the call graph for this function:

◆ acceptRequest()

void com.runehive.content.gambling.GambleManager.acceptRequest ( Player player,
Player other )

Handles accepting a request.

Parameters
player
other

Definition at line 183 of file GambleManager.java.

183 {
184 if(player == other) return;
185
186 if (!canGamble(player, GambleStage.NONE) || !canGamble(other, GambleStage.SENDING_OFFER)) return;
187
188 player.getGambling().setStage(GambleStage.SENDING_OFFER);
189 player.getGambling().setOther(other);
190
191 if (other.getGambling().getOther() != null && player.getIndex() == other.getGambling().getOther().getIndex()) {
192 System.out.println("accepted request...");
193 open(other, player);
194 open(player, other);
195 }
196 }

References canGamble(), com.runehive.game.world.entity.mob.player.Player.getGambling(), com.runehive.game.world.entity.Entity.getIndex(), com.runehive.content.gambling.GambleStage.NONE, open(), other, com.runehive.content.gambling.GambleStage.SENDING_OFFER, setOther(), and setStage().

Referenced by sendRequest().

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

◆ canGamble()

boolean com.runehive.content.gambling.GambleManager.canGamble ( Player player,
GambleStage requiredStage )

Checks if the player is allowed to gamble or not.

Parameters
player
requiredStage
Returns

Definition at line 132 of file GambleManager.java.

132 {
133
134 if(!Boundary.isIn(player, GAMBLING_ZONE)) return false;
135
136 if (Objects.nonNull(requiredStage) && !player.getGambling().getStage().equals(requiredStage)) return false;
137
138 return true;
139 }

References GAMBLING_ZONE, com.runehive.game.world.entity.mob.player.Player.getGambling(), getStage(), and com.runehive.game.world.position.Boundary.isIn().

Referenced by acceptRequest(), and start().

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

◆ canPlayFlowerPokerAtPositon()

boolean com.runehive.content.gambling.GambleManager.canPlayFlowerPokerAtPositon ( Player player,
Position position )

Checks if the position that was selected is suitable for a game of flower poker.

Parameters
player
position
Returns

Definition at line 271 of file GambleManager.java.

271 {
272 //Checks if the spot its checking has a object placed there
273 if (!TraversalMap.isTraversable(new Position(position.getX() + 1, position.getY()), Direction.SOUTH, player.width())) return false;
274
275 boolean canPlay = true;
276 for(int index = 0; index < 5; index++) {
277 if (!TraversalMap.isTraversable(position, Direction.SOUTH, player.width())) {
278 canPlay = false;
279 break;
280 }
281 position = position.create(position.getX(), position.getY() + Direction.SOUTH.getDirectionY());
282 }
283 return canPlay;
284 }
int getY()
Gets the absolute y coordinate.
Definition Position.java:46
int getX()
Gets the absolute x coordinate.
Definition Position.java:41
static Position create(int x, int y, int z)
Creates a location.
val index

References com.runehive.game.world.position.Position.create(), com.runehive.game.world.position.Position.getX(), com.runehive.game.world.position.Position.getY(), com.runehive.game.world.pathfinding.TraversalMap.isTraversable(), com.runehive.game.world.entity.mob.Direction.SOUTH, and com.runehive.game.world.entity.Entity.width.

Referenced by com.runehive.content.gambling.impl.FlowerPoker.gamble().

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

◆ decline()

void com.runehive.content.gambling.GambleManager.decline ( Player player)

Handles declining the gamble.

Parameters
player

Definition at line 290 of file GambleManager.java.

290 {
291 Player other = player.getGambling().getOther();
292
293 for(Item item : player.getGambling().getContainer()) {
294 if(item == null || item.getId() == -1) continue;
295
296 if(player.inventory.hasCapacityFor(item))
297 player.inventory.add(item);
298 else {
299 player.bank.add(item);
300 player.message("@red@You had no room for the "+item.getAmount()+" x "+item.getDefinition().getName()+", its been sent to your bank.");
301 }
302 }
303
304 player.getGambling().getContainer().clear();
305 player.inventory.refresh();
306 player.bank.refresh();
307
308 if(other != null) {
309
310 for(Item item : other.getGambling().getContainer()) {
311 if(item == null || item.getId() == -1) continue;
312
313 if(other.inventory.hasCapacityFor(item))
314 other.inventory.add(item);
315 else {
316 other.bank.add(item);
317 other.message("@red@You had no room for the "+item.getAmount()+" x "+item.getDefinition().getName()+", its been sent to your bank.");
318 }
319 }
320
321 other.getGambling().getContainer().clear();
322 other.inventory.refresh();
323 other.bank.refresh();
324
325 reset(other);
326 }
327
328 reset(player);
329 }
boolean add(Item item)
Attempts to deposit item into this container.
final boolean hasCapacityFor(Item... item)
Determines if this container has the capacity for item.
void clear()
Removes all of the items from this container.
void refresh()
Refreshes the bank itemcontainer.
Definition Bank.java:73
void refresh()
Refreshes the players inventory.

References com.runehive.game.world.items.containers.ItemContainer.add(), com.runehive.game.world.entity.mob.player.Player.bank, com.runehive.game.world.items.containers.ItemContainer.clear(), getContainer(), com.runehive.game.world.entity.mob.player.Player.getGambling(), getOther(), com.runehive.game.world.items.containers.ItemContainer.hasCapacityFor(), com.runehive.game.world.entity.mob.player.Player.inventory, com.runehive.game.world.entity.mob.player.Player.message(), other, com.runehive.game.world.items.containers.bank.Bank.refresh(), com.runehive.game.world.items.containers.inventory.Inventory.refresh(), and reset().

Referenced by com.runehive.game.world.entity.mob.player.Player.unregister().

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

◆ deposit()

void com.runehive.content.gambling.GambleManager.deposit ( Player player,
int itemId,
int slot,
int amount )

Deposit a item into the gamble session.

Parameters
player
slot

Definition at line 336 of file GambleManager.java.

336 {
337 Player other = player.getGambling().getOther();
338
339 if(other == null) return;
340
341 ItemDefinition def = ItemDefinition.get(itemId);
342
343 if (!def.isTradeable()) {
344 player.send(new SendMessage("This is item is untradeable!"));
345 return;
346 }
347
348 if(!player.inventory.contains(itemId)) return;
349
350 if(amount > player.inventory.computeAmountForId(itemId))
351 amount = player.inventory.computeAmountForId(itemId);
352
353 if(amount <= 0) return;
354
355 Item item = new Item(itemId, amount);
356 if(player.getGambling().getContainer().hasCapacityFor(item)) {
357 player.inventory.remove(item, slot);
358 player.getGambling().getContainer().add(item);
359 player.inventory.refresh();
360 player.inventory.refresh(player, INVENTORY_ID + 1);
361 } else
362 player.message("Not enough space.");
363
364 player.setLastModification(System.currentTimeMillis());
365 other.setLastModification(System.currentTimeMillis());
366
367 player.send(new SendItemOnInterface(44770, player.getGambling().getContainer().toArray()));
368 player.send(new SendItemOnInterface(44771, other.getGambling().getContainer().toArray()));
369
370 other.send(new SendItemOnInterface(44770, other.getGambling().getContainer().toArray()));
371 other.send(new SendItemOnInterface(44771, player.getGambling().getContainer().toArray()));
372 }
void setLastModification(long lastModification)
Definition Player.java:142
final int computeAmountForId(int id)
Computes the total quantity of the Items in this container with id.
boolean remove(Item item)
Attempts to withdraw item from this container.
boolean contains(int id)
Determines if this container contains id.
final Item[] toArray()
Returns a shallow copy of the backing array.

References com.runehive.game.world.items.containers.ItemContainer.add(), com.runehive.game.world.items.containers.ItemContainer.computeAmountForId(), com.runehive.game.world.items.containers.ItemContainer.contains(), com.runehive.game.world.items.ItemDefinition.get(), getContainer(), com.runehive.game.world.entity.mob.player.Player.getGambling(), getOther(), com.runehive.game.world.items.containers.ItemContainer.hasCapacityFor(), com.runehive.game.world.entity.mob.player.Player.inventory, INVENTORY_ID, com.runehive.game.world.entity.mob.player.Player.message(), other, com.runehive.game.world.items.containers.inventory.Inventory.refresh(), com.runehive.game.world.items.containers.ItemContainer.remove(), com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.game.world.entity.mob.player.Player.setLastModification(), and com.runehive.game.world.items.containers.ItemContainer.toArray().

Here is the call graph for this function:

◆ finish()

void com.runehive.content.gambling.GambleManager.finish ( Player host,
Player opponent,
int hostScore,
int opponentScore )

Handles finishing up a automated gamble.

Parameters
host
opponent
hostScore
opponentScore

Definition at line 465 of file GambleManager.java.

465 {
466 if (host.getGambling().getGame() == null)
467 return;
468
469 if (host.getGambling().getGame().getHost() == null)
470 return;
471
472 if (!World.getPlayers().contains(opponent) && World.getPlayers().contains(host)) {
473 give(host.getGambling().getType(), 'H', host, opponent, false);
474 } else if (World.getPlayers().contains(opponent) && !World.getPlayers().contains(host)) {
475 give(host.getGambling().getType(), 'O', opponent, host, false);
476 } else {
477 if (hostScore == 55) {
478 host.speak("The roll was a draw, rerolling...");
479 opponent.speak("The roll was a draw, rerolling...");
480
481 host.getGambling().setStage(GambleStage.IN_PROGRESS);
482 opponent.getGambling().setStage(GambleStage.IN_PROGRESS);
483 host.getGambling().getGame().gamble();
484 return;
485 }
486
487 boolean hostWon = hostScore > opponentScore;
488 give(host.getGambling().getType(), hostWon ? 'H' : 'O', hostWon ? host : opponent, hostWon ? opponent : host, false);
489 }
490 }
void speak(String forceChat)
Sets the mob's forced chat.
Definition Mob.java:127

References com.runehive.content.gambling.Gamble.gamble(), com.runehive.game.world.entity.mob.player.Player.getGambling(), getGame(), com.runehive.content.gambling.Gamble.getHost(), com.runehive.game.world.World.getPlayers(), getType(), give(), com.runehive.content.gambling.GambleStage.IN_PROGRESS, setStage(), and com.runehive.game.world.entity.mob.Mob.speak().

Referenced by com.runehive.content.gambling.impl.FiftyFive.gamble(), com.runehive.content.gambling.impl.FlowerPoker.gamble(), and com.runehive.content.gambling.impl.FlowerPoker.plant().

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

◆ getContainer()

ItemContainer com.runehive.content.gambling.GambleManager.getContainer ( )

Definition at line 109 of file GambleManager.java.

109 {
110 return container;
111 }

References container.

Referenced by decline(), deposit(), give(), open(), and withdraw().

Here is the caller graph for this function:

◆ getFlowers()

ArrayList< Flowers > com.runehive.content.gambling.GambleManager.getFlowers ( )

Definition at line 122 of file GambleManager.java.

122 {
123 return flowers;
124 }

References flowers.

Referenced by com.runehive.content.gambling.impl.FlowerPoker.gamble(), com.runehive.content.gambling.impl.FlowerPoker.getRank(), com.runehive.content.gambling.impl.FlowerPoker.plant(), and removeFlowers().

Here is the caller graph for this function:

◆ getGame() [1/2]

Gamble com.runehive.content.gambling.GambleManager.getGame ( )

Definition at line 96 of file GambleManager.java.

96 {
97 return game;
98 }

References game.

Referenced by accept(), finish(), give(), and start().

Here is the caller graph for this function:

◆ getGame() [2/2]

Gamble com.runehive.content.gambling.GambleManager.getGame ( Player other,
Player player,
GambleType type )
private

Get thet game based on the gamble type.

Parameters
other
player
type
Returns

Definition at line 419 of file GambleManager.java.

419 {
420 switch (type) {
421 case FIFTY_FIVE:
422 return new FiftyFive(player, other);
423 case FLOWER_POKER:
424 return new FlowerPoker(player, other);
425 }
426 return null;
427 }

References other, and type.

◆ getGameFlowers()

ArrayList< CustomGameObject > com.runehive.content.gambling.GambleManager.getGameFlowers ( )

Definition at line 115 of file GambleManager.java.

115 {
116 return gameFlowers;
117 }

References gameFlowers.

Referenced by com.runehive.content.gambling.impl.FlowerPoker.gamble(), and removeFlowers().

Here is the caller graph for this function:

◆ getOther()

Player com.runehive.content.gambling.GambleManager.getOther ( )

Definition at line 57 of file GambleManager.java.

57 {
58 return other;
59 }

References other.

Referenced by accept(), decline(), deposit(), handleModeSelection(), reset(), start(), and withdraw().

Here is the caller graph for this function:

◆ getStage()

GambleStage com.runehive.content.gambling.GambleManager.getStage ( )

Definition at line 44 of file GambleManager.java.

44 {
45 return stage;
46 }

References stage.

Referenced by canGamble(), com.runehive.net.packet.in.DropItemPacketListener.handlePacket(), and reset().

Here is the caller graph for this function:

◆ getType()

GambleType com.runehive.content.gambling.GambleManager.getType ( )

Definition at line 83 of file GambleManager.java.

83 {
84 return type;
85 }

References type.

Referenced by accept(), and finish().

Here is the caller graph for this function:

◆ give()

void com.runehive.content.gambling.GambleManager.give ( GambleType gambleType,
char winnerIdentifier,
Player winner,
Player loser,
boolean draw )

Handles giving the players the winnings or returning the items when its a draw.

Parameters
gambleType
winnerIdentifier
winner
loser
draw

Definition at line 500 of file GambleManager.java.

500 {
501
502 if(draw) {
503
504 winner.speak("It's a draw!");
505 loser.speak("It's a draw!");
506
507 removeFlowers(winner);
508 removeFlowers(loser);
509
510 winner.getGambling().setStage(GambleStage.IN_PROGRESS);
511 loser.getGambling().setStage(GambleStage.IN_PROGRESS);
512
513 winner.getGambling().getGame().gamble();
514
515 return;
516 } else {
517
518 //Handle giving the winner the items
519 for(Item item : winner.getGambling().getContainer()) {
520 if(item == null || item.getId() == -1) continue;
521
522 if(winner.inventory.hasCapacityFor(item))
523 winner.inventory.add(item);
524 else {
525 winner.inventory.addOrDrop(item);
526 winner.bank.refresh();
527 }
528 }
529
530 for(Item item : loser.getGambling().getContainer()) {
531 if(item == null || item.getId() == -1) continue;
532
533 if(winner.inventory.hasCapacityFor(item))
534 winner.inventory.add(item);
535 else {
536 winner.inventory.addOrDrop(item);
537 winner.bank.refresh();
538 }
539 }
540
541 send(gambleType, winnerIdentifier, winner, loser);
542
543 }
544
545 loser.getGambling().container.clear();
546 winner.getGambling().container.clear();
547
548 reset(loser);
549 reset(winner);
550 }
ItemContainer container
The container with gambled items of the player.
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...

References com.runehive.game.world.items.containers.ItemContainer.add(), com.runehive.game.world.items.containers.inventory.Inventory.addOrDrop(), com.runehive.game.world.entity.mob.player.Player.bank, com.runehive.game.world.items.containers.ItemContainer.clear(), container, com.runehive.content.gambling.Gamble.gamble(), getContainer(), com.runehive.game.world.entity.mob.player.Player.getGambling(), getGame(), com.runehive.game.world.items.containers.ItemContainer.hasCapacityFor(), com.runehive.content.gambling.GambleStage.IN_PROGRESS, com.runehive.game.world.entity.mob.player.Player.inventory, com.runehive.game.world.items.containers.bank.Bank.refresh(), removeFlowers(), reset(), send(), setStage(), and com.runehive.game.world.entity.mob.Mob.speak().

Referenced by finish().

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

◆ handleModeSelection()

void com.runehive.content.gambling.GambleManager.handleModeSelection ( Player player,
GambleType type )

Handles setting the different game types.

Parameters
player
type

Definition at line 579 of file GambleManager.java.

579 {
580 Player other = player.getGambling().getOther();
581
582 if(other == null) return;
583
584 player.getGambling().setConfirmed(false);
585 player.getGambling().setType(type);
586 player.send(new SendConfig(CONFIG, type.ordinal()));
587 player.setLastModification(System.currentTimeMillis());
588
589 other.getGambling().setConfirmed(false);
590 other.getGambling().setType(type);
591 other.send(new SendConfig(CONFIG, type.ordinal()));
592 other.setLastModification(System.currentTimeMillis());
593 }

References CONFIG, com.runehive.game.world.entity.mob.player.Player.getGambling(), getOther(), other, com.runehive.game.world.entity.mob.player.Player.send(), setConfirmed(), com.runehive.game.world.entity.mob.player.Player.setLastModification(), setType(), and type.

Here is the call graph for this function:

◆ hasConfirmed()

boolean com.runehive.content.gambling.GambleManager.hasConfirmed ( )

Definition at line 70 of file GambleManager.java.

70 {
71 return confirmed;
72 }

References confirmed.

Referenced by accept().

Here is the caller graph for this function:

◆ open()

void com.runehive.content.gambling.GambleManager.open ( Player player,
Player other )

Handles opening the interface.

Parameters
player
other

Definition at line 203 of file GambleManager.java.

203 {
204 player.getGambling().setConfirmed(false);
205 player.getGambling().setStage(GambleStage.PLACING_BET);
206 System.out.println("Open the interface for ["+String.format(player.getUsername())+"] and ["+String.format(other.getUsername())+"]...");
207
208 player.send(new SendInventoryInterface(INTERFACE_ID, INVENTORY_ID));
209 player.send(new SendItemOnInterface(44770, player.getGambling().getContainer().toArray()));
210 player.send(new SendItemOnInterface(44771, other.getGambling().getContainer().toArray()));
211 player.send(new SendItemOnInterface(INVENTORY_ID + 1, player.inventory.getItems()));
212
213 player.send(new SendString("" + String.format(player.getUsername()), 44768));
214 player.send(new SendString("" + String.format(other.getUsername()), 44769));
215 player.send(new SendConfig(CONFIG, 0));
216 }

References CONFIG, getContainer(), com.runehive.game.world.entity.mob.player.Player.getGambling(), com.runehive.game.world.items.containers.ItemContainer.getItems(), com.runehive.game.world.entity.mob.player.Player.getUsername(), INTERFACE_ID, com.runehive.game.world.entity.mob.player.Player.inventory, INVENTORY_ID, other, com.runehive.content.gambling.GambleStage.PLACING_BET, com.runehive.game.world.entity.mob.player.Player.send(), setConfirmed(), setStage(), and com.runehive.game.world.items.containers.ItemContainer.toArray().

Referenced by acceptRequest().

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

◆ removeFlowers()

void com.runehive.content.gambling.GambleManager.removeFlowers ( Player player)

Definition at line 619 of file GambleManager.java.

619 {
620 for(CustomGameObject flowers : player.getGambling().getGameFlowers())
621 flowers.unregister();
622
623 player.getGambling().getGameFlowers().clear();
624 player.getGambling().getFlowers().clear();
625 }
ArrayList< CustomGameObject > getGameFlowers()

References flowers, getFlowers(), com.runehive.game.world.entity.mob.player.Player.getGambling(), and getGameFlowers().

Referenced by give(), and reset().

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

◆ reset()

void com.runehive.content.gambling.GambleManager.reset ( Player player)

Handles resetting all the gambling variables for a player.

Parameters
player

Definition at line 599 of file GambleManager.java.

599 {
600
601 if(player.getGambling().getStage().equals(GambleStage.NONE))
602 return;
603
604 player.getGambling().setConfirmed(false);
605 player.getGambling().setGame(null);
606 player.getGambling().setType(null);
607 player.getGambling().setStage(GambleStage.NONE);
608 player.setGambleLock(false);
609 player.send(new SendRemoveInterface());
610 player.send(new SendConfig(CONFIG, 0));
611 removeFlowers(player);
612
613 if(player.getGambling().getOther() != null)
614 reset(player.getGambling().getOther());
615
616 player.getGambling().setOther(null);
617 }

References CONFIG, com.runehive.game.world.entity.mob.player.Player.getGambling(), getOther(), getStage(), com.runehive.content.gambling.GambleStage.NONE, removeFlowers(), reset(), com.runehive.game.world.entity.mob.player.Player.send(), setConfirmed(), com.runehive.game.world.entity.mob.player.Player.setGambleLock(), setGame(), setOther(), setStage(), and setType().

Referenced by decline(), give(), and reset().

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

◆ send()

void com.runehive.content.gambling.GambleManager.send ( GambleType gambleType,
char winnerIdentifier,
Player winner,
Player loser )
private

Handles sending the message for who won.

Parameters
gambleType
winnerIdentifier
winner
loser

Definition at line 559 of file GambleManager.java.

559 {
560 switch(gambleType) {
561 case FIFTY_FIVE -> {
562 if (winnerIdentifier == 'H')
563 winner.speak("The roll was under 55, I have won the 55x2.");
564 else
565 winner.speak("The roll was higher then 55, I have won the 55x2.");
566 }
567 default -> {
568 winner.speak("I have won!");
569 loser.speak("I have lost!");
570 }
571 }
572 }

References com.runehive.game.world.entity.mob.Mob.speak().

Referenced by give().

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

◆ sendRequest()

void com.runehive.content.gambling.GambleManager.sendRequest ( Player player,
Player other )

Handles sending a request to another player.

Parameters
player
other

Definition at line 146 of file GambleManager.java.

146 {
147
148 if (PlayerRight.isIronman(player)) {
149 player.message("You can not gamble as you are an iron man.");
150 return;
151 }
152
153 if (PlayerRight.isIronman(other)) {
154 player.message(other.getName() + " can not gamble as they are an iron man.");
155 return;
156 }
157 if(player.playTime < 6000) {
158 player.message("You must have at least 1 hour of play time to gamble.");
159 return;
160 }
161
162 Player requested = other.getGambling().getOther();
163
164 if (!Objects.isNull(requested)) {
165 System.out.println("Accept...");
166 acceptRequest(player, other);
167 return;
168 }
169
170 player.message("You've sent a gamble invite to " + Utility.capitalizeSentence(other.getName()) + ".");
171 other.message(Utility.capitalizeSentence(player.getName()) + ":gamblereq:");
172 player.send(new SendRemoveInterface());
173 player.getGambling().setOther(other);
174 player.getGambling().setStage(GambleStage.SENDING_OFFER);
175 System.out.println("send request...");
176 }
String getName()
Gets the name of this entity.
Definition Player.java:774

References acceptRequest(), com.runehive.util.Utility.capitalizeSentence(), com.runehive.game.world.entity.mob.player.Player.getGambling(), com.runehive.game.world.entity.mob.player.Player.getName(), com.runehive.game.world.entity.mob.player.PlayerRight.isIronman(), com.runehive.game.world.entity.mob.player.Player.message(), other, com.runehive.game.world.entity.mob.player.Player.playTime, com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.content.gambling.GambleStage.SENDING_OFFER, setOther(), and setStage().

Here is the call graph for this function:

◆ setConfirmed()

void com.runehive.content.gambling.GambleManager.setConfirmed ( boolean confirmed)

Definition at line 74 of file GambleManager.java.

74 {
75 this.confirmed = confirmed;
76 }

References confirmed.

Referenced by accept(), handleModeSelection(), open(), and reset().

Here is the caller graph for this function:

◆ setGame()

void com.runehive.content.gambling.GambleManager.setGame ( Gamble game)

Definition at line 100 of file GambleManager.java.

100 {
101 this.game = game;
102 }

References game.

Referenced by accept(), and reset().

Here is the caller graph for this function:

◆ setOther()

void com.runehive.content.gambling.GambleManager.setOther ( Player other)

Definition at line 61 of file GambleManager.java.

61 {
62 this.other = other;
63 }

References other.

Referenced by accept(), acceptRequest(), reset(), and sendRequest().

Here is the caller graph for this function:

◆ setStage()

void com.runehive.content.gambling.GambleManager.setStage ( GambleStage stage)

Definition at line 48 of file GambleManager.java.

48 {
49 this.stage = stage;
50 }

References stage.

Referenced by accept(), acceptRequest(), finish(), give(), open(), reset(), sendRequest(), and start().

Here is the caller graph for this function:

◆ setType()

void com.runehive.content.gambling.GambleManager.setType ( GambleType type)

Definition at line 87 of file GambleManager.java.

87 {
88 this.type = type;
89 }

References type.

Referenced by handleModeSelection(), and reset().

Here is the caller graph for this function:

◆ start()

void com.runehive.content.gambling.GambleManager.start ( Player player)
private

Handles starting the gamble.

Parameters
player

Definition at line 433 of file GambleManager.java.

433 {
434 if (!canGamble(player, GambleStage.SENDING_OFFER)) return;
435
436 Player other = player.getGambling().getOther();
437
438 if (other == null) return;
439
440 if (other.getGambling().hasConfirmed()) {
441 if (player.getGambling().getGame() == null) return;
442
443 if (player.getGambling().getGame().getHost() == null) return;
444
445 player.send(new SendRemoveInterface());
446 other.send(new SendRemoveInterface());
447
448 player.getGambling().setStage(GambleStage.IN_PROGRESS);
449 other.getGambling().setStage(GambleStage.IN_PROGRESS);
450
451 player.setGambleLock(true);
452 other.setGambleLock(true);
453
454 player.getGambling().getGame().gamble();
455 }
456 }

References canGamble(), com.runehive.content.gambling.Gamble.gamble(), com.runehive.game.world.entity.mob.player.Player.getGambling(), getGame(), com.runehive.content.gambling.Gamble.getHost(), getOther(), com.runehive.content.gambling.GambleStage.IN_PROGRESS, other, com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.content.gambling.GambleStage.SENDING_OFFER, com.runehive.game.world.entity.mob.player.Player.setGambleLock(), and setStage().

Referenced by accept().

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

◆ withdraw()

void com.runehive.content.gambling.GambleManager.withdraw ( Player player,
int itemId,
int slot,
int amount )

Withdraw an item from the gamble session.

Parameters
player
slot

Definition at line 379 of file GambleManager.java.

379 {
380 Player other = player.getGambling().getOther();
381
382 if(other == null) return;
383
384 Item clickedItem = player.getGambling().getContainer().get(slot);
385
386 if(clickedItem.getId() != itemId) return;
387
388 if(amount > clickedItem.getAmount())
389 amount = clickedItem.getAmount();
390
391 if(!clickedItem.getDefinition().isStackable() && amount > player.inventory.getFreeSlots())
392 amount = player.inventory.getFreeSlots();
393
394 if(amount <= 0) return;
395
396 player.getGambling().getContainer().remove(itemId, amount);
397 player.inventory.add(itemId, amount);
398
399 player.inventory.refresh();
400 player.inventory.refresh(player, INVENTORY_ID + 1);
401
402 player.setLastModification(System.currentTimeMillis());
403 other.setLastModification(System.currentTimeMillis());
404
405 player.send(new SendItemOnInterface(44770, player.getGambling().getContainer().toArray()));
406 player.send(new SendItemOnInterface(44771, other.getGambling().getContainer().toArray()));
407
408 other.send(new SendItemOnInterface(44770, other.getGambling().getContainer().toArray()));
409 other.send(new SendItemOnInterface(44771, player.getGambling().getContainer().toArray()));
410 }
final int getId()
Gets the identification of this item.
Definition Item.java:324
final int getAmount()
Gets the quantity of this item.
Definition Item.java:342
ItemDefinition getDefinition()
Gets the item definition for the item identifier.
Definition Item.java:315
final Item get(int index)
Gets the Item located on index.

References com.runehive.game.world.items.containers.ItemContainer.add(), com.runehive.game.world.items.containers.ItemContainer.get(), com.runehive.game.world.items.Item.getAmount(), getContainer(), com.runehive.game.world.items.Item.getDefinition(), com.runehive.game.world.items.containers.ItemContainer.getFreeSlots(), com.runehive.game.world.entity.mob.player.Player.getGambling(), com.runehive.game.world.items.Item.getId(), getOther(), com.runehive.game.world.entity.mob.player.Player.inventory, INVENTORY_ID, other, com.runehive.game.world.items.containers.inventory.Inventory.refresh(), com.runehive.game.world.items.containers.ItemContainer.remove(), com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.game.world.entity.mob.player.Player.setLastModification(), and com.runehive.game.world.items.containers.ItemContainer.toArray().

Here is the call graph for this function:

Member Data Documentation

◆ CONFIG

final int com.runehive.content.gambling.GambleManager.CONFIG = 444
private

The config used for selecting the game type.

Definition at line 35 of file GambleManager.java.

Referenced by handleModeSelection(), open(), and reset().

◆ confirmed

boolean com.runehive.content.gambling.GambleManager.confirmed
protected

Checks if the player has confirmed the gamble.

Definition at line 68 of file GambleManager.java.

Referenced by hasConfirmed(), and setConfirmed().

◆ container

ItemContainer com.runehive.content.gambling.GambleManager.container = new ItemContainer(18, ItemContainer.StackPolicy.STANDARD)
protected

The container with gambled items of the player.

Definition at line 107 of file GambleManager.java.

Referenced by getContainer(), and give().

◆ flowers

ArrayList<Flowers> com.runehive.content.gambling.GambleManager.flowers = new ArrayList<Flowers>()
protected

Definition at line 120 of file GambleManager.java.

Referenced by getFlowers(), and removeFlowers().

◆ GAMBLING_ZONE

final Boundary com.runehive.content.gambling.GambleManager.GAMBLING_ZONE = new Boundary(3148, 3476, 3181, 3505)
static

◆ game

Gamble com.runehive.content.gambling.GambleManager.game
protected

The current gamble going on between the two players.

Definition at line 94 of file GambleManager.java.

Referenced by accept(), getGame(), and setGame().

◆ gameFlowers

ArrayList<CustomGameObject> com.runehive.content.gambling.GambleManager.gameFlowers = new ArrayList<CustomGameObject>()
protected

Definition at line 113 of file GambleManager.java.

Referenced by getGameFlowers().

◆ INTERFACE_ID

final int com.runehive.content.gambling.GambleManager.INTERFACE_ID = 44750
private

The main gambling interface.

Definition at line 27 of file GambleManager.java.

Referenced by open().

◆ INVENTORY_ID

final int com.runehive.content.gambling.GambleManager.INVENTORY_ID = 44775
private

Interface id for the player's inventory.

Definition at line 31 of file GambleManager.java.

Referenced by deposit(), open(), and withdraw().

◆ other

Player com.runehive.content.gambling.GambleManager.other
protected

The other player within this gamble.

Definition at line 55 of file GambleManager.java.

Referenced by accept(), acceptRequest(), decline(), deposit(), getGame(), getOther(), handleModeSelection(), open(), sendRequest(), setOther(), start(), and withdraw().

◆ stage

GambleStage com.runehive.content.gambling.GambleManager.stage = GambleStage.NONE
protected

The current stage of the gamble.

Definition at line 42 of file GambleManager.java.

Referenced by getStage(), and setStage().

◆ type

GambleType com.runehive.content.gambling.GambleManager.type = GambleType.NONE
protected

The gamble type going on.

Definition at line 81 of file GambleManager.java.

Referenced by getGame(), getType(), handleModeSelection(), and setType().


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