1package com.runehive.content.gambling.impl;
3import com.runehive.content.gambling.Flowers;
4import com.runehive.content.gambling.Gamble;
5import com.runehive.content.gambling.GambleStage;
6import com.runehive.game.task.Task;
7import com.runehive.game.world.World;
8import com.runehive.game.world.entity.mob.player.Player;
9import com.runehive.game.world.object.CustomGameObject;
10import com.runehive.game.world.position.Position;
11import com.runehive.util.Utility;
13import java.util.ArrayList;
14import java.util.Collections;
15import java.util.HashMap;
18import static com.runehive.content.gambling.GambleManager.GAMBLING_ZONE;
28 return "Flower Poker";
39 for (
int i = 0; i < 5; i++) {
57 System.out.println(
"Looking for place to play");
58 boolean[] canPlay = {
false,
false };
61 int maxX = GAMBLING_ZONE.getMaximumX() - GAMBLING_ZONE.getMinimumX();
62 int maxY = GAMBLING_ZONE.getMaximumY() - GAMBLING_ZONE.getMinimumY();
63 System.out.println(
"maxX: " + maxX +
", " + maxY);
65 positionTwo = positionOne.
create(positionOne.
getX() + 1, positionOne.
getY());
69 System.out.println(canPlay[0] +
" - " + canPlay[1]);
70 }
while(canPlay[0] ==
false || canPlay[1] ==
false);
72 System.out.println(
"Found a place to play");
74 Position finalPositionOne = positionOne;
75 Position finalPositionTwo = positionTwo;
80 protected void execute() {
94 getHost().
speak(
"I got " + hostResult.name().toLowerCase().replaceAll(
"_",
" "));
95 getOpponent().
speak(
"I got " + opponentResult.name().toLowerCase().replaceAll(
"_",
" "));
117 protected void execute() {
125 for(
Player player : players)
132 if (hostFlower ==
null || opponentFlower ==
null) {
137 for(
Player player : players) {
138 Flowers flowers = player.equals(
getHost()) ? hostFlower : opponentFlower;
142 player.getGambling().getGameFlowers().add(gameFlower);
144 player.movement.walkTo(player.getPosition().south());
149 for(
Player player : players) {
150 Flowers flowers = player.equals(
getHost()) ? hostFlower : opponentFlower;
151 player.speak(
"I planted a " +
Utility.
formatText(flowers.name().toLowerCase()) +
" flower.");
156 if(hostFlower.name().equalsIgnoreCase(
"WHITE") || hostFlower.name().equalsIgnoreCase(
"BLACK") ||
157 opponentFlower.name().equalsIgnoreCase(
"WHITE") || opponentFlower.name().equalsIgnoreCase(
"BLACK")) {
189 ArrayList<Flowers> flowers =
new ArrayList<Flowers>();
191 Collections.sort(flowers);
192 Map<Integer, Integer> pairs =
getPairs(flowers);
193 for (
int i = 0; i < pairs.size(); i++) {
194 if (pairs.get(i) ==
null) {
197 if (pairs.get(i).intValue() == 5) {
201 if (pairs.size() == 2) {
202 if ((pairs.get(0).intValue() == 3 && pairs.get(1).intValue() == 2) || (pairs.get(1).intValue() == 3 && pairs.get(0).intValue() == 2)) {
207 for (
int i = 0; i < pairs.size(); i++) {
208 if (pairs.get(i) ==
null) {
211 if (pairs.get(i).intValue() == 3) {
214 if (pairs.get(i).intValue() == 2) {
218 if (totalPairs == 2) {
221 if (totalPairs == 1) {
227 private static Map<Integer, Integer>
getPairs(ArrayList<Flowers> list) {
228 Map<Integer, Integer> finalPairs =
new HashMap<Integer, Integer>();
229 int[] pairs =
new int[14];
231 pairs[flower.ordinal()]++;
234 for (
int i = 0; i < pairs.length; i++) {
236 finalPairs.put(
slot, pairs[i]);
Gamble(Player host, Player opponent)
Player host
Players inside the 'gamble'.
void finish(Player host, Player opponent, int hostScore, int opponentScore)
Handles finishing up a automated gamble.
ArrayList< Flowers > getFlowers()
boolean canPlayFlowerPokerAtPositon(Player player, Position position)
Checks if the position that was selected is suitable for a game of flower poker.
ArrayList< CustomGameObject > getGameFlowers()
static Ranking getRank(Player player)
void plant(Task gambleTask)
FlowerPoker(Player host, Player opponent)
static Map< Integer, Integer > getPairs(ArrayList< Flowers > list)
A game representing a cyclic unit of work.
synchronized final void cancel()
Cancels all subsequent executions.
Represents the game world.
static void schedule(Task task)
Submits a new event.
void speak(String forceChat)
Sets the mob's forced chat.
void move(Position position)
Moves the mob to a set position.
This class represents a character controlled by a player.
GambleManager getGambling()
Represents a static game object loaded from the map fs.
void register()
Registers an entity to the World.
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.
Handles miscellaneous methods.
static int random(int bound)
static String formatText(String s)