1package com.runehive.content.gambling;
3import com.runehive.content.gambling.impl.FiftyFive;
4import com.runehive.content.gambling.impl.FlowerPoker;
5import com.runehive.game.world.World;
6import com.runehive.game.world.entity.mob.Direction;
7import com.runehive.game.world.entity.mob.player.Player;
8import com.runehive.game.world.entity.mob.player.PlayerRight;
9import com.runehive.game.world.items.Item;
10import com.runehive.game.world.items.ItemDefinition;
11import com.runehive.game.world.items.containers.ItemContainer;
12import com.runehive.game.world.object.CustomGameObject;
13import com.runehive.game.world.pathfinding.TraversalMap;
14import com.runehive.game.world.position.Boundary;
15import com.runehive.game.world.position.Position;
16import com.runehive.net.packet.out.*;
17import com.runehive.util.Utility;
19import java.util.ArrayList;
20import java.util.Objects;
113 protected ArrayList<CustomGameObject>
gameFlowers =
new ArrayList<CustomGameObject>();
120 protected ArrayList<Flowers>
flowers =
new ArrayList<Flowers>();
136 if (Objects.nonNull(requiredStage) && !player.
getGambling().
getStage().equals(requiredStage))
return false;
149 player.
message(
"You can not gamble as you are an iron man.");
154 player.
message(
other.getName() +
" can not gamble as they are an iron man.");
158 player.
message(
"You must have at least 1 hour of play time to gamble.");
164 if (!Objects.isNull(requested)) {
165 System.out.println(
"Accept...");
175 System.out.println(
"send request...");
184 if(player ==
other)
return;
191 if (
other.getGambling().getOther() !=
null && player.
getIndex() ==
other.getGambling().getOther().getIndex()) {
192 System.out.println(
"accepted request...");
206 System.out.println(
"Open the interface for ["+String.format(player.
getUsername())+
"] and ["+String.format(
other.getUsername())+
"]...");
225 if (
other ==
null)
return;
228 player.
message(
"You need to select a game first.");
233 player.
message(
"@red@Something was changed in the last 5 seconds, you cannot accept yet.");
243 player.
message(
"You have accepted the gamble with "+String.format(
other.getUsername())+
".");
244 other.message(String.format(player.
getUsername()) +
" has accepted the gamble.");
246 System.out.println(
"player: " + String.format(player.
getUsername()));
247 System.out.println(
"other: " + String.format(
other.getUsername()));
249 if (
other.getGambling().hasConfirmed()) {
259 System.out.println(
"Both confirmed start the game...");
275 boolean canPlay =
true;
276 for(
int index = 0; index < 5; index++) {
294 if(item ==
null || item.getId() == -1)
continue;
300 player.
message(
"@red@You had no room for the "+item.getAmount()+
" x "+item.getDefinition().getName()+
", its been sent to your bank.");
310 for(
Item item :
other.getGambling().getContainer()) {
311 if(item ==
null || item.getId() == -1)
continue;
313 if(
other.inventory.hasCapacityFor(item))
314 other.inventory.add(item);
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.");
321 other.getGambling().getContainer().clear();
322 other.inventory.refresh();
323 other.bank.refresh();
339 if(
other ==
null)
return;
343 if (!def.isTradeable()) {
353 if(amount <= 0)
return;
355 Item item =
new Item(itemId, amount);
362 player.
message(
"Not enough space.");
365 other.setLastModification(System.currentTimeMillis());
382 if(
other ==
null)
return;
386 if(clickedItem.
getId() != itemId)
return;
394 if(amount <= 0)
return;
403 other.setLastModification(System.currentTimeMillis());
438 if (
other ==
null)
return;
440 if (
other.getGambling().hasConfirmed()) {
452 other.setGambleLock(
true);
477 if (hostScore == 55) {
478 host.
speak(
"The roll was a draw, rerolling...");
479 opponent.
speak(
"The roll was a draw, rerolling...");
487 boolean hostWon = hostScore > opponentScore;
488 give(host.
getGambling().
getType(), hostWon ?
'H' :
'O', hostWon ? host : opponent, hostWon ? opponent : host,
false);
504 winner.
speak(
"It's a draw!");
505 loser.
speak(
"It's a draw!");
520 if(item ==
null || item.getId() == -1)
continue;
531 if(item ==
null || item.getId() == -1)
continue;
541 send(gambleType, winnerIdentifier, winner, loser);
562 if (winnerIdentifier ==
'H')
563 winner.
speak(
"The roll was under 55, I have won the 55x2.");
565 winner.
speak(
"The roll was higher then 55, I have won the 55x2.");
568 winner.
speak(
"I have won!");
569 loser.
speak(
"I have lost!");
582 if(
other ==
null)
return;
589 other.getGambling().setConfirmed(
false);
592 other.setLastModification(System.currentTimeMillis());
void finish(Player host, Player opponent, int hostScore, int opponentScore)
Handles finishing up a automated gamble.
void send(GambleType gambleType, char winnerIdentifier, Player winner, Player loser)
Handles sending the message for who won.
GambleStage stage
The current stage of the gamble.
void acceptRequest(Player player, Player other)
Handles accepting a request.
Player other
The other player within this gamble.
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 decline(Player player)
Handles declining the gamble.
ItemContainer container
The container with gambled items of the player.
void setConfirmed(boolean confirmed)
void deposit(Player player, int itemId, int slot, int amount)
Deposit a item into the gamble session.
boolean confirmed
Checks if the player has confirmed the gamble.
ArrayList< Flowers > flowers
ArrayList< CustomGameObject > gameFlowers
void setType(GambleType type)
ArrayList< Flowers > getFlowers()
GambleType type
The gamble type going on.
final int INTERFACE_ID
The main gambling interface.
Gamble game
The current gamble going on between the two players.
void reset(Player player)
Handles resetting all the gambling variables for a player.
void accept(Player player)
Handles accepting the gamble.
static final Boundary GAMBLING_ZONE
void setOther(Player other)
void setStage(GambleStage stage)
Gamble getGame(Player other, Player player, GambleType type)
Get thet game based on the gamble type.
void setGame(Gamble game)
void removeFlowers(Player player)
void open(Player player, Player other)
Handles opening the interface.
final int INVENTORY_ID
Interface id for the player's inventory.
void handleModeSelection(Player player, GambleType type)
Handles setting the different game types.
boolean canPlayFlowerPokerAtPositon(Player player, Position position)
Checks if the position that was selected is suitable for a game of flower poker.
ArrayList< CustomGameObject > getGameFlowers()
void start(Player player)
Handles starting the gamble.
final int CONFIG
The config used for selecting the game type.
boolean canGamble(Player player, GambleStage requiredStage)
Checks if the player is allowed to gamble or not.
void withdraw(Player player, int itemId, int slot, int amount)
Withdraw an item from the gamble session.
void sendRequest(Player player, Player other)
Handles sending a request to another player.
ItemContainer getContainer()
Represents the game world.
static MobList< Player > getPlayers()
void speak(String forceChat)
Sets the mob's forced chat.
This class represents a character controlled by a player.
final Inventory inventory
void message(String message)
String getName()
Gets the name of this entity.
long getLastModification()
void send(OutgoingPacket encoder)
void setLastModification(long lastModification)
GambleManager getGambling()
void setGambleLock(boolean gambleLocked)
Represents all of an in-game Item's attributes.
static ItemDefinition get(int id)
Gets an item definition.
The container class that represents an item that can be interacted with.
final int getId()
Gets the identification of this item.
final int getAmount()
Gets the quantity of this item.
ItemDefinition getDefinition()
Gets the item definition for the item identifier.
An abstraction game representing a group of Items.
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.
final Item get(int index)
Gets the Item located on index.
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.
boolean contains(int id)
Determines if this container contains id.
void clear()
Removes all of the items from this container.
final Item[] toArray()
Returns a shallow copy of the backing array.
void refresh()
Refreshes the bank itemcontainer.
void refresh()
Refreshes the players inventory.
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...
Represents a static game object loaded from the map fs.
Contains traversal data for a set of regions.
static boolean isTraversable(Position from, Direction direction, int size)
Tests whether or not a specified position is traversable in the specified direction.
Created by Daniel on 2017-11-24.
static boolean isIn(Mob mob, Boundary... boundaries)
Represents a single tile on the game world.
int getY()
Gets the absolute y coordinate.
int getX()
Gets the absolute x coordinate.
static Position create(int x, int y, int z)
Creates a location.
The OutgoingPacket responsible for changing settings on a client.
The OutgoingPacket that opens the inventory with itemcontainer.
The OutgoingPacket that sends a message to a Players chatbox in the client.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
Handles miscellaneous methods.
static String capitalizeSentence(final String string)
Capitalize each letter after .
Represents the enumerated directions an entity can walk or face.
Holds all the player right data.
static boolean isIronman(Player player)
Checks if the player is an ironman.
An enumerated type defining policies for stackable Items.
STANDARD
The STANDARD policy, items are only stacked if they are defined as stackable in their ItemDefinition ...