From dd485674d90d1306a1607eab47659e1cdff673bc Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 21 Feb 2021 11:35:21 -0800 Subject: [PATCH 01/22] Set up poker bot --- pom.xml | 1 - .../java/org/jointheleague/discord_bot_example/Bot.java | 6 +++--- src/main/java/org/jointheleague/modules/Poker.java | 5 +++++ src/main/resources/config.json | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 src/main/java/org/jointheleague/modules/Poker.java diff --git a/pom.xml b/pom.xml index a19a17c8..cd7afd5d 100644 --- a/pom.xml +++ b/pom.xml @@ -122,7 +122,6 @@ org.apache.maven.plugins maven-dependency-plugin - 3.0.3 copy-dependencies diff --git a/src/main/java/org/jointheleague/discord_bot_example/Bot.java b/src/main/java/org/jointheleague/discord_bot_example/Bot.java index e1205704..d68c9bfa 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -114,9 +114,9 @@ public void connect(boolean printInvite) { api.addMessageCreateListener(mttt); helpListener.addHelpEmbed(mttt.getHelpEmbed()); - Greeter g = new Greeter(channelName); - api.addMessageCreateListener(g); - helpListener.addHelpEmbed(g.getHelpEmbed()); + //Greeter g = new Greeter(channelName); + //api.addMessageCreateListener(g); + //helpListener.addHelpEmbed(g.getHelpEmbed()); pythagcalc pythagCalc = new pythagcalc(channelName); api.addMessageCreateListener(pythagCalc); diff --git a/src/main/java/org/jointheleague/modules/Poker.java b/src/main/java/org/jointheleague/modules/Poker.java new file mode 100644 index 00000000..3e241ce7 --- /dev/null +++ b/src/main/java/org/jointheleague/modules/Poker.java @@ -0,0 +1,5 @@ +package org.jointheleague.modules; + +public class Poker { + +} diff --git a/src/main/resources/config.json b/src/main/resources/config.json index 66444aee..287c3bb8 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,4 +1,4 @@ { - "channels": ["ellabot"], - "token": "" + "channels": ["jake-m"], + "token": "ODA4MDQwODE4NzgyNjM0MDA0.YCAwpw.zvB3OJwFAFd82DjgJVEpScWNq3w" } From 48431a2f90f6ec631e57ad032d6e3dae2f3da927 Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 21 Feb 2021 11:36:07 -0800 Subject: [PATCH 02/22] Added commands --- .../discord_bot_example/Bot.java | 4 ++ .../java/org/jointheleague/modules/Poker.java | 38 ++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jointheleague/discord_bot_example/Bot.java b/src/main/java/org/jointheleague/discord_bot_example/Bot.java index d68c9bfa..4857c851 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -126,6 +126,10 @@ public void connect(boolean printInvite) { //api.addMessageCreateListener(g); //helpListener.addHelpEmbed(g.getHelpEmbed()); + Poker poker = new Poker(channelName); + api.addMessageCreateListener(poker); + helpListener.addHelpEmbed(poker.getHelpEmbed()); + CovidCaseGetter covid = new CovidCaseGetter(channelName); api.addMessageCreateListener(covid); helpListener.addHelpEmbed(covid.getHelpEmbed()); diff --git a/src/main/java/org/jointheleague/modules/Poker.java b/src/main/java/org/jointheleague/modules/Poker.java index 3e241ce7..0a6424e3 100644 --- a/src/main/java/org/jointheleague/modules/Poker.java +++ b/src/main/java/org/jointheleague/modules/Poker.java @@ -1,5 +1,41 @@ package org.jointheleague.modules; -public class Poker { +import org.javacord.api.event.message.MessageCreateEvent; +import org.javacord.api.listener.message.MessageCreateListener; + +import net.aksingh.owmjapis.api.APIException; + +public class Poker extends CustomMessageCreateListener { + + public Poker(String channelName) { + // TODO Auto-generated constructor stub + super(channelName); + } + private static final String command = "!gamble"; + int balance=50; + int wager; + @Override + public void handle(MessageCreateEvent event) throws APIException { + // TODO Auto-generated method stub + if(event.getMessageContent().contains(command)) { + String content = event.getMessageContent().replaceAll(" ", "").replace("!random",""); + if(content.contains("poker")) { + content=content.replace("poker", ""); + try { + wager=Integer.parseInt(content); + balance-=wager; + if(balance<0) { + event.getChannel().sendMessage("You don't have enough money to wager that much."); + } + else { + //send photos of cards + } + } + catch(Exception e){ + event.getChannel().sendMessage("Choose a number"); + } + } + } + } } From f657d78dfe05d784a469e2fd47a3f2ad84ecdbbb Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sat, 27 Feb 2021 11:58:57 -0800 Subject: [PATCH 03/22] creating cards and logic --- pom.xml | 1 + .../java/org/jointheleague/modules/Poker.java | 180 +++++++++++++++++- 2 files changed, 176 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index cd7afd5d..e80449e4 100644 --- a/pom.xml +++ b/pom.xml @@ -122,6 +122,7 @@ org.apache.maven.plugins maven-dependency-plugin + 3.1.1 copy-dependencies diff --git a/src/main/java/org/jointheleague/modules/Poker.java b/src/main/java/org/jointheleague/modules/Poker.java index 0a6424e3..972d982c 100644 --- a/src/main/java/org/jointheleague/modules/Poker.java +++ b/src/main/java/org/jointheleague/modules/Poker.java @@ -1,5 +1,7 @@ package org.jointheleague.modules; +import java.util.Random; + import org.javacord.api.event.message.MessageCreateEvent; import org.javacord.api.listener.message.MessageCreateListener; @@ -14,11 +16,77 @@ public Poker(String channelName) { private static final String command = "!gamble"; int balance=50; int wager; + Random randCards=new Random(); + String[] cards=new String[52]; + int[] usedCards=new int[7]; + int playerCard1; + int playerCard2; + int middleCard1; + int middleCard2; + int middleCard3; + int middleCard4; + int middleCard5; + int botCard1; + int botCard2; + boolean userCooporates=false; + boolean isUsed=false; @Override public void handle(MessageCreateEvent event) throws APIException { // TODO Auto-generated method stub + cards[0]="ace of spades"; + cards[1]="2 of spades"; + cards[2]="3 of spades"; + cards[3]="4 of spades"; + cards[4]="5 of spades"; + cards[5]="6 of spades"; + cards[6]="7 of spades"; + cards[7]="8 of spades"; + cards[8]="9 of spades"; + cards[9]="10 of spades"; + cards[10]="jack of spades"; + cards[11]="queen of spades"; + cards[12]="king of spades"; + cards[13]="ace of hearts"; + cards[14]="2 of hearts"; + cards[15]="3 of hearts"; + cards[16]="4 of hearts"; + cards[17]="5 of hearts"; + cards[18]="6 of hearts"; + cards[19]="7 of hearts"; + cards[20]="8 of hearts"; + cards[21]="9 of hearts"; + cards[22]="10 of hearts"; + cards[23]="jack of hearts"; + cards[24]="queen of hearts"; + cards[25]="king of hearts"; + cards[26]="ace of diamonds"; + cards[27]="2 of diamonds"; + cards[28]="3 of diamonds"; + cards[29]="4 of diamonds"; + cards[30]="5 of diamonds"; + cards[31]="6 of diamonds"; + cards[32]="7 of diamonds"; + cards[33]="8 of diamonds"; + cards[34]="9 of diamonds"; + cards[35]="10 of diamonds"; + cards[36]="jack of diamonds"; + cards[37]="queen of diamonds"; + cards[38]="king of diamonds"; + cards[39]="ace of clubs"; + cards[40]="2 of clubs"; + cards[41]="3 of clubs"; + cards[42]="4 of clubs"; + cards[43]="5 of clubs"; + cards[44]="6 of clubs"; + cards[45]="7 of clubs"; + cards[46]="8 of clubs"; + cards[47]="9 of clubs"; + cards[48]="10 of clubs"; + cards[49]="jack of clubs"; + cards[50]="queen of clubs"; + cards[51]="king of clubs"; if(event.getMessageContent().contains(command)) { - String content = event.getMessageContent().replaceAll(" ", "").replace("!random",""); + String content = event.getMessageContent().replaceAll(" ", "").replace("!gamble",""); if(content.contains("poker")) { content=content.replace("poker", ""); try { @@ -28,14 +96,116 @@ public void handle(MessageCreateEvent event) throws APIException { event.getChannel().sendMessage("You don't have enough money to wager that much."); } else { - //send photos of cards + event.getChannel().sendMessage("Your balance is "+balance); + //send photos of cards in the middle, its only text currently + middleCard1=randCards.nextInt(52); + usedCards[0]=middleCard1; + middleCard2=randCards.nextInt(52); + for(int i=0; i Date: Sat, 13 Mar 2021 11:58:26 -0800 Subject: [PATCH 04/22] Added logic to the bot for calling and folding. It needs to be debugged. --- .../java/org/jointheleague/modules/Poker.java | 430 +++++++++++++++++- 1 file changed, 426 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/Poker.java b/src/main/java/org/jointheleague/modules/Poker.java index 972d982c..9eb09a8f 100644 --- a/src/main/java/org/jointheleague/modules/Poker.java +++ b/src/main/java/org/jointheleague/modules/Poker.java @@ -18,6 +18,7 @@ public Poker(String channelName) { int wager; Random randCards=new Random(); String[] cards=new String[52]; + String[] botAndMiddleCards=new String[5]; int[] usedCards=new int[7]; int playerCard1; int playerCard2; @@ -28,8 +29,11 @@ public Poker(String channelName) { int middleCard5; int botCard1; int botCard2; + int numberSameCards; boolean userCooporates=false; boolean isUsed=false; + int highestCallChance=0; + int botCallChance=0; @Override public void handle(MessageCreateEvent event) throws APIException { // TODO Auto-generated method stub @@ -91,6 +95,10 @@ public void handle(MessageCreateEvent event) throws APIException { content=content.replace("poker", ""); try { wager=Integer.parseInt(content); + } + catch(Exception e){ + event.getChannel().sendMessage("Choose a number after the command to gamble"); + } balance-=wager; if(balance<0) { event.getChannel().sendMessage("You don't have enough money to wager that much."); @@ -178,12 +186,426 @@ public void handle(MessageCreateEvent event) throws APIException { } } usedCards[6]=botCard2; + + //shows bot's cards + event.getChannel().sendMessage("Temporary: Bot's cards are the "+ cards[botCard1]+" and the "+cards[botCard2]); + + + if(cards[middleCard1].contains("ace")) { + botAndMiddleCards[0]="ace"; + } + else if(cards[middleCard1].contains("2")) { + botAndMiddleCards[0]="2"; + } + else if(cards[middleCard1].contains("3")) { + botAndMiddleCards[0]="3"; + } + else if(cards[middleCard1].contains("4")) { + botAndMiddleCards[0]="4"; + } + else if(cards[middleCard1].contains("5")) { + botAndMiddleCards[0]="5"; + } + else if(cards[middleCard1].contains("6")) { + botAndMiddleCards[0]="6"; + } + else if(cards[middleCard1].contains("7")) { + botAndMiddleCards[0]="7"; + } + else if(cards[middleCard1].contains("8")) { + botAndMiddleCards[0]="8"; + } + else if(cards[middleCard1].contains("9")) { + botAndMiddleCards[0]="9"; + } + else if(cards[middleCard1].contains("10")) { + botAndMiddleCards[0]="10"; + } + else if(cards[middleCard1].contains("jack")) { + botAndMiddleCards[0]="jack"; + } + else if(cards[middleCard1].contains("queen")) { + botAndMiddleCards[0]="queen"; + } + else if(cards[middleCard1].contains("king")) { + botAndMiddleCards[0]="king"; + } + + if(cards[middleCard2].contains("ace")) { + botAndMiddleCards[1]="ace"; + } + else if(cards[middleCard2].contains("2")) { + botAndMiddleCards[1]="2"; + } + else if(cards[middleCard2].contains("3")) { + botAndMiddleCards[1]="3"; + } + else if(cards[middleCard2].contains("4")) { + botAndMiddleCards[1]="4"; + } + else if(cards[middleCard2].contains("5")) { + botAndMiddleCards[1]="5"; + } + else if(cards[middleCard2].contains("6")) { + botAndMiddleCards[1]="6"; + } + else if(cards[middleCard2].contains("7")) { + botAndMiddleCards[1]="7"; + } + else if(cards[middleCard2].contains("8")) { + botAndMiddleCards[1]="8"; + } + else if(cards[middleCard2].contains("9")) { + botAndMiddleCards[1]="9"; + } + else if(cards[middleCard2].contains("10")) { + botAndMiddleCards[1]="10"; + } + else if(cards[middleCard2].contains("jack")) { + botAndMiddleCards[1]="jack"; + } + else if(cards[middleCard2].contains("queen")) { + botAndMiddleCards[1]="queen"; + } + else if(cards[middleCard2].contains("king")) { + botAndMiddleCards[1]="king"; + } + if(cards[middleCard3].contains("ace")) { + botAndMiddleCards[2]="ace"; + } + else if(cards[middleCard3].contains("2")) { + botAndMiddleCards[2]="2"; + } + else if(cards[middleCard3].contains("3")) { + botAndMiddleCards[2]="3"; + } + else if(cards[middleCard3].contains("4")) { + botAndMiddleCards[2]="4"; + } + else if(cards[middleCard3].contains("5")) { + botAndMiddleCards[2]="5"; + } + else if(cards[middleCard3].contains("6")) { + botAndMiddleCards[2]="6"; + } + else if(cards[middleCard3].contains("7")) { + botAndMiddleCards[2]="7"; + } + else if(cards[middleCard3].contains("8")) { + botAndMiddleCards[2]="8"; + } + else if(cards[middleCard3].contains("9")) { + botAndMiddleCards[2]="9"; + } + else if(cards[middleCard3].contains("10")) { + botAndMiddleCards[2]="10"; + } + else if(cards[middleCard3].contains("jack")) { + botAndMiddleCards[2]="jack"; + } + else if(cards[middleCard3].contains("queen")) { + botAndMiddleCards[2]="queen"; + } + else if(cards[middleCard3].contains("king")) { + botAndMiddleCards[2]="king"; + } + + if(cards[botCard1].contains("ace")) { + botAndMiddleCards[3]="ace"; + } + else if(cards[botCard1].contains("2")) { + botAndMiddleCards[3]="2"; + } + else if(cards[botCard1].contains("3")) { + botAndMiddleCards[3]="3"; + } + else if(cards[botCard1].contains("4")) { + botAndMiddleCards[3]="4"; + } + else if(cards[botCard1].contains("5")) { + botAndMiddleCards[3]="5"; + } + else if(cards[botCard1].contains("6")) { + botAndMiddleCards[3]="6"; + } + else if(cards[botCard1].contains("7")) { + botAndMiddleCards[3]="7"; + } + else if(cards[botCard1].contains("8")) { + botAndMiddleCards[3]="8"; + } + else if(cards[botCard1].contains("9")) { + botAndMiddleCards[3]="9"; + } + else if(cards[botCard1].contains("10")) { + botAndMiddleCards[3]="10"; + } + else if(cards[botCard1].contains("jack")) { + botAndMiddleCards[3]="jack"; + } + else if(cards[botCard1].contains("queen")) { + botAndMiddleCards[3]="queen"; + } + else if(cards[botCard1].contains("king")) { + botAndMiddleCards[3]="king"; + } + + if(cards[botCard2].contains("ace")) { + botAndMiddleCards[4]="ace"; + } + else if(cards[botCard2].contains("2")) { + botAndMiddleCards[4]="2"; + } + else if(cards[botCard2].contains("3")) { + botAndMiddleCards[4]="3"; + } + else if(cards[botCard2].contains("4")) { + botAndMiddleCards[4]="4"; + } + else if(cards[botCard2].contains("5")) { + botAndMiddleCards[4]="5"; + } + else if(cards[botCard2].contains("6")) { + botAndMiddleCards[4]="6"; + } + else if(cards[botCard2].contains("7")) { + botAndMiddleCards[4]="7"; + } + else if(cards[botCard2].contains("8")) { + botAndMiddleCards[4]="8"; + } + else if(cards[botCard2].contains("9")) { + botAndMiddleCards[4]="9"; + } + else if(cards[botCard2].contains("10")) { + botAndMiddleCards[4]="10"; + } + else if(cards[botCard2].contains("jack")) { + botAndMiddleCards[4]="jack"; + } + else if(cards[botCard2].contains("queen")) { + botAndMiddleCards[4]="queen"; + } + else if(cards[botCard2].contains("king")) { + botAndMiddleCards[4]="king"; + } + event.getChannel().sendMessage("The bot has "+botAndMiddleCards[0]+botAndMiddleCards[1]+botAndMiddleCards[2]+botAndMiddleCards[3]+botAndMiddleCards[4]); + + numberSameCards=0; + for(int j=0; jhighestCallChance) { + highestCallChance=100; + } + } + else if(numberSameCards==3 || numberSameCards==4) { + highestCallChance=100; + } + + numberSameCards=0; + for(int j=0; jhighestCallChance) { + highestCallChance=70; + } + } + else if(numberSameCards==3 || numberSameCards==4) { + highestCallChance=100; + } + + numberSameCards=0; + for(int j=0; jhighestCallChance) { + highestCallChance=75; + } + } + else if(numberSameCards==3 || numberSameCards==4) { + highestCallChance=100; + } + + numberSameCards=0; + for(int j=0; jhighestCallChance) { + highestCallChance=75; + } + } + else if(numberSameCards==3 || numberSameCards==4) { + highestCallChance=100; + } + + numberSameCards=0; + for(int j=0; jhighestCallChance) { + highestCallChance=80; + } + } + else if(numberSameCards==3 || numberSameCards==4) { + highestCallChance=100; + } + + numberSameCards=0; + for(int j=0; jhighestCallChance) { + highestCallChance=80; + } + } + else if(numberSameCards==3 || numberSameCards==4) { + highestCallChance=100; + } + + numberSameCards=0; + for(int j=0; jhighestCallChance) { + highestCallChance=85; + } + } + else if(numberSameCards==3 || numberSameCards==4) { + highestCallChance=100; + } + + numberSameCards=0; + for(int j=0; jhighestCallChance) { + highestCallChance=85; + } + } + else if(numberSameCards==3 || numberSameCards==4) { + highestCallChance=100; + } + + numberSameCards=0; + for(int j=0; jhighestCallChance) { + highestCallChance=85; + } + } + else if(numberSameCards==3 || numberSameCards==4) { + highestCallChance=100; + } + + numberSameCards=0; + for(int j=0; jhighestCallChance) { + highestCallChance=90; + } + } + else if(numberSameCards==3 || numberSameCards==4) { + highestCallChance=100; + } + + numberSameCards=0; + for(int j=0; jhighestCallChance) { + highestCallChance=90; + } + } + else if(numberSameCards==3 || numberSameCards==4) { + highestCallChance=100; + } + + numberSameCards=0; + for(int j=0; jhighestCallChance) { + highestCallChance=95; + } + } + else if(numberSameCards==3 || numberSameCards==4) { + highestCallChance=100; + } + + numberSameCards=0; + for(int j=0; jhighestCallChance) { + highestCallChance=95; + } + } + else if(numberSameCards==3 || numberSameCards==4) { + highestCallChance=100; + } + + + //add more ways of having good hand here + + if(50>highestCallChance) { + highestCallChance=50; + } + botCallChance=highestCallChance; + Random callRandom=new Random(); + int i=callRandom.nextInt(100); + if(botCallChance>=i) { + //bot calls + event.getChannel().sendMessage("Bot calls. Bot chance of calling was "+botCallChance+". The random was "+i); + } + else { + balance+=(wager*2); + event.getChannel().sendMessage("The bot folded, you win "+wager*2+". Your balance is now "+balance); + } //in the future maybe add a choice to add players } - } - catch(Exception e){ - event.getChannel().sendMessage("Choose a number after the command to gamble"); - } + } //I don't know why this while loop doesn't work System.out.println(userCooporates); From dec1a1dbcf353d4b7c95dd5a6d8f6131c0030638 Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 14 Mar 2021 11:29:41 -0700 Subject: [PATCH 05/22] Added 4th card --- .../java/org/jointheleague/modules/Poker.java | 1092 ++++++++--------- 1 file changed, 536 insertions(+), 556 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/Poker.java b/src/main/java/org/jointheleague/modules/Poker.java index 9eb09a8f..09dadc6f 100644 --- a/src/main/java/org/jointheleague/modules/Poker.java +++ b/src/main/java/org/jointheleague/modules/Poker.java @@ -1,5 +1,6 @@ package org.jointheleague.modules; +import java.lang.reflect.Array; import java.util.Random; import org.javacord.api.event.message.MessageCreateEvent; @@ -13,13 +14,15 @@ public Poker(String channelName) { // TODO Auto-generated constructor stub super(channelName); } + private static final String command = "!gamble"; - int balance=50; + int balance = 50; int wager; - Random randCards=new Random(); - String[] cards=new String[52]; - String[] botAndMiddleCards=new String[5]; - int[] usedCards=new int[7]; + int totalBet; + Random randCards = new Random(); + String[] cards = new String[52]; + String[] botAndMiddleCards = new String[8]; + int[] usedCards = new int[8]; int playerCard1; int playerCard2; int middleCard1; @@ -30,604 +33,581 @@ public Poker(String channelName) { int botCard1; int botCard2; int numberSameCards; - boolean userCooporates=false; - boolean isUsed=false; - int highestCallChance=0; - int botCallChance=0; + boolean userCooporates = false; + boolean isUsed = false; + int highestCallChance = 0; + int botCallChance = 0; + @Override public void handle(MessageCreateEvent event) throws APIException { // TODO Auto-generated method stub - cards[0]="ace of spades"; - cards[1]="2 of spades"; - cards[2]="3 of spades"; - cards[3]="4 of spades"; - cards[4]="5 of spades"; - cards[5]="6 of spades"; - cards[6]="7 of spades"; - cards[7]="8 of spades"; - cards[8]="9 of spades"; - cards[9]="10 of spades"; - cards[10]="jack of spades"; - cards[11]="queen of spades"; - cards[12]="king of spades"; - cards[13]="ace of hearts"; - cards[14]="2 of hearts"; - cards[15]="3 of hearts"; - cards[16]="4 of hearts"; - cards[17]="5 of hearts"; - cards[18]="6 of hearts"; - cards[19]="7 of hearts"; - cards[20]="8 of hearts"; - cards[21]="9 of hearts"; - cards[22]="10 of hearts"; - cards[23]="jack of hearts"; - cards[24]="queen of hearts"; - cards[25]="king of hearts"; - cards[26]="ace of diamonds"; - cards[27]="2 of diamonds"; - cards[28]="3 of diamonds"; - cards[29]="4 of diamonds"; - cards[30]="5 of diamonds"; - cards[31]="6 of diamonds"; - cards[32]="7 of diamonds"; - cards[33]="8 of diamonds"; - cards[34]="9 of diamonds"; - cards[35]="10 of diamonds"; - cards[36]="jack of diamonds"; - cards[37]="queen of diamonds"; - cards[38]="king of diamonds"; - cards[39]="ace of clubs"; - cards[40]="2 of clubs"; - cards[41]="3 of clubs"; - cards[42]="4 of clubs"; - cards[43]="5 of clubs"; - cards[44]="6 of clubs"; - cards[45]="7 of clubs"; - cards[46]="8 of clubs"; - cards[47]="9 of clubs"; - cards[48]="10 of clubs"; - cards[49]="jack of clubs"; - cards[50]="queen of clubs"; - cards[51]="king of clubs"; - if(event.getMessageContent().contains(command)) { - String content = event.getMessageContent().replaceAll(" ", "").replace("!gamble",""); - if(content.contains("poker")) { - content=content.replace("poker", ""); + cards[0] = "ace of spades"; + cards[1] = "2 of spades"; + cards[2] = "3 of spades"; + cards[3] = "4 of spades"; + cards[4] = "5 of spades"; + cards[5] = "6 of spades"; + cards[6] = "7 of spades"; + cards[7] = "8 of spades"; + cards[8] = "9 of spades"; + cards[9] = "10 of spades"; + cards[10] = "jack of spades"; + cards[11] = "queen of spades"; + cards[12] = "king of spades"; + cards[13] = "ace of hearts"; + cards[14] = "2 of hearts"; + cards[15] = "3 of hearts"; + cards[16] = "4 of hearts"; + cards[17] = "5 of hearts"; + cards[18] = "6 of hearts"; + cards[19] = "7 of hearts"; + cards[20] = "8 of hearts"; + cards[21] = "9 of hearts"; + cards[22] = "10 of hearts"; + cards[23] = "jack of hearts"; + cards[24] = "queen of hearts"; + cards[25] = "king of hearts"; + cards[26] = "ace of diamonds"; + cards[27] = "2 of diamonds"; + cards[28] = "3 of diamonds"; + cards[29] = "4 of diamonds"; + cards[30] = "5 of diamonds"; + cards[31] = "6 of diamonds"; + cards[32] = "7 of diamonds"; + cards[33] = "8 of diamonds"; + cards[34] = "9 of diamonds"; + cards[35] = "10 of diamonds"; + cards[36] = "jack of diamonds"; + cards[37] = "queen of diamonds"; + cards[38] = "king of diamonds"; + cards[39] = "ace of clubs"; + cards[40] = "2 of clubs"; + cards[41] = "3 of clubs"; + cards[42] = "4 of clubs"; + cards[43] = "5 of clubs"; + cards[44] = "6 of clubs"; + cards[45] = "7 of clubs"; + cards[46] = "8 of clubs"; + cards[47] = "9 of clubs"; + cards[48] = "10 of clubs"; + cards[49] = "jack of clubs"; + cards[50] = "queen of clubs"; + cards[51] = "king of clubs"; + if (event.getMessageContent().contains(command)) { + String content = event.getMessageContent().replaceAll(" ", "").replace("!gamble", ""); + if (content.contains("poker")) { + totalBet=0; + content = content.replace("poker", ""); try { - wager=Integer.parseInt(content); - } - catch(Exception e){ + wager = Integer.parseInt(content); + } catch (Exception e) { event.getChannel().sendMessage("Choose a number after the command to gamble"); } - balance-=wager; - if(balance<0) { + balance -= wager; + totalBet+=wager; + if (balance < 0) { event.getChannel().sendMessage("You don't have enough money to wager that much."); - } - else { - event.getChannel().sendMessage("Your balance is "+balance); - //send photos of cards in the middle, its only text currently - middleCard1=randCards.nextInt(52); - usedCards[0]=middleCard1; - middleCard2=randCards.nextInt(52); - for(int i=0; ihighestCallChance) { - highestCallChance=100; - } - } - else if(numberSameCards==3 || numberSameCards==4) { - highestCallChance=100; - } - - numberSameCards=0; - for(int j=0; jhighestCallChance) { - highestCallChance=70; - } - } - else if(numberSameCards==3 || numberSameCards==4) { - highestCallChance=100; - } - - numberSameCards=0; - for(int j=0; jhighestCallChance) { - highestCallChance=75; - } - } - else if(numberSameCards==3 || numberSameCards==4) { - highestCallChance=100; - } + } else { + event.getChannel().sendMessage("Your balance is " + balance); + // send photos of cards in the middle, its only text currently + middleCard1 = randCards.nextInt(52); + usedCards[0] = middleCard1; + middleCard2 = randCards.nextInt(52); + for (int i = 0; i < usedCards.length; i++) { + if (usedCards[i] == middleCard2) { + isUsed = true; - numberSameCards=0; - for(int j=0; jhighestCallChance) { - highestCallChance=75; + while (isUsed == true) { + middleCard2 = randCards.nextInt(52); + isUsed = false; } } - else if(numberSameCards==3 || numberSameCards==4) { - highestCallChance=100; - } + usedCards[1] = middleCard2; + middleCard3 = randCards.nextInt(52); + for (int i = 0; i < usedCards.length; i++) { + if (usedCards[i] == middleCard3) { + isUsed = true; - numberSameCards=0; - for(int j=0; jhighestCallChance) { - highestCallChance=80; + while (isUsed == true) { + middleCard3 = randCards.nextInt(52); + isUsed = false; } } - else if(numberSameCards==3 || numberSameCards==4) { - highestCallChance=100; - } + usedCards[2] = middleCard3; + event.getChannel().sendMessage("The middle cards are the " + cards[middleCard1] + ", the " + + cards[middleCard2] + " and the " + cards[middleCard3]); - numberSameCards=0; - for(int j=0; jhighestCallChance) { - highestCallChance=80; - } - } - else if(numberSameCards==3 || numberSameCards==4) { - highestCallChance=100; - } + // send photo of player cards, its only text currently + playerCard1 = randCards.nextInt(52); + for (int i = 0; i < usedCards.length; i++) { + if (usedCards[i] == playerCard1) { + isUsed = true; - numberSameCards=0; - for(int j=0; jhighestCallChance) { - highestCallChance=85; + while (isUsed == true) { + playerCard1 = randCards.nextInt(52); + isUsed = false; } } - else if(numberSameCards==3 || numberSameCards==4) { - highestCallChance=100; - } + usedCards[3] = playerCard1; + playerCard2 = randCards.nextInt(52); + for (int i = 0; i < usedCards.length; i++) { + if (usedCards[i] == playerCard2) { + isUsed = true; - numberSameCards=0; - for(int j=0; jhighestCallChance) { - highestCallChance=85; + while (isUsed == true) { + playerCard2 = randCards.nextInt(52); + isUsed = false; } } - else if(numberSameCards==3 || numberSameCards==4) { - highestCallChance=100; - } + usedCards[4] = playerCard2; + event.getChannel() + .sendMessage("Your cards are the " + cards[playerCard1] + " and the " + cards[playerCard2]); - numberSameCards=0; - for(int j=0; jhighestCallChance) { - highestCallChance=85; - } - } - else if(numberSameCards==3 || numberSameCards==4) { - highestCallChance=100; - } + // bot logic + botCard1 = randCards.nextInt(52); + for (int i = 0; i < usedCards.length; i++) { + if (usedCards[i] == botCard1) { + isUsed = true; - numberSameCards=0; - for(int j=0; jhighestCallChance) { - highestCallChance=90; + while (isUsed == true) { + botCard1 = randCards.nextInt(52); + isUsed = false; } } - else if(numberSameCards==3 || numberSameCards==4) { - highestCallChance=100; - } + usedCards[5] = botCard1; + botCard2 = randCards.nextInt(52); + for (int i = 0; i < usedCards.length; i++) { + if (usedCards[i] == botCard2) { + isUsed = true; - numberSameCards=0; - for(int j=0; jhighestCallChance) { - highestCallChance=90; + while (isUsed == true) { + botCard2 = randCards.nextInt(52); + isUsed = false; } } - else if(numberSameCards==3 || numberSameCards==4) { - highestCallChance=100; - } + usedCards[6] = botCard2; - numberSameCards=0; - for(int j=0; jhighestCallChance) { - highestCallChance=95; - } - } - else if(numberSameCards==3 || numberSameCards==4) { - highestCallChance=100; - } + // shows bot's cards + event.getChannel().sendMessage( + "Temporary: Bot's cards are the " + cards[botCard1] + " and the " + cards[botCard2]); - numberSameCards=0; - for(int j=0; jhighestCallChance) { - highestCallChance=95; - } - } - else if(numberSameCards==3 || numberSameCards==4) { - highestCallChance=100; - } - - - //add more ways of having good hand here - - if(50>highestCallChance) { - highestCallChance=50; - } - botCallChance=highestCallChance; - Random callRandom=new Random(); - int i=callRandom.nextInt(100); - if(botCallChance>=i) { - //bot calls - event.getChannel().sendMessage("Bot calls. Bot chance of calling was "+botCallChance+". The random was "+i); + + if (cards[middleCard2].contains("ace")) { + botAndMiddleCards[1] = "ace"; + } else if (cards[middleCard2].contains("2")) { + botAndMiddleCards[1] = "2"; + } else if (cards[middleCard2].contains("3")) { + botAndMiddleCards[1] = "3"; + } else if (cards[middleCard2].contains("4")) { + botAndMiddleCards[1] = "4"; + } else if (cards[middleCard2].contains("5")) { + botAndMiddleCards[1] = "5"; + } else if (cards[middleCard2].contains("6")) { + botAndMiddleCards[1] = "6"; + } else if (cards[middleCard2].contains("7")) { + botAndMiddleCards[1] = "7"; + } else if (cards[middleCard2].contains("8")) { + botAndMiddleCards[1] = "8"; + } else if (cards[middleCard2].contains("9")) { + botAndMiddleCards[1] = "9"; + } else if (cards[middleCard2].contains("10")) { + botAndMiddleCards[1] = "10"; + } else if (cards[middleCard2].contains("jack")) { + botAndMiddleCards[1] = "jack"; + } else if (cards[middleCard2].contains("queen")) { + botAndMiddleCards[1] = "queen"; + } else if (cards[middleCard2].contains("king")) { + botAndMiddleCards[1] = "king"; + } + if (cards[middleCard3].contains("ace")) { + botAndMiddleCards[2] = "ace"; + } else if (cards[middleCard3].contains("2")) { + botAndMiddleCards[2] = "2"; + } else if (cards[middleCard3].contains("3")) { + botAndMiddleCards[2] = "3"; + } else if (cards[middleCard3].contains("4")) { + botAndMiddleCards[2] = "4"; + } else if (cards[middleCard3].contains("5")) { + botAndMiddleCards[2] = "5"; + } else if (cards[middleCard3].contains("6")) { + botAndMiddleCards[2] = "6"; + } else if (cards[middleCard3].contains("7")) { + botAndMiddleCards[2] = "7"; + } else if (cards[middleCard3].contains("8")) { + botAndMiddleCards[2] = "8"; + } else if (cards[middleCard3].contains("9")) { + botAndMiddleCards[2] = "9"; + } else if (cards[middleCard3].contains("10")) { + botAndMiddleCards[2] = "10"; + } else if (cards[middleCard3].contains("jack")) { + botAndMiddleCards[2] = "jack"; + } else if (cards[middleCard3].contains("queen")) { + botAndMiddleCards[2] = "queen"; + } else if (cards[middleCard3].contains("king")) { + botAndMiddleCards[2] = "king"; } - else { - balance+=(wager*2); - event.getChannel().sendMessage("The bot folded, you win "+wager*2+". Your balance is now "+balance); + + if (cards[botCard1].contains("ace")) { + botAndMiddleCards[3] = "ace"; + } else if (cards[botCard1].contains("2")) { + botAndMiddleCards[3] = "2"; + } else if (cards[botCard1].contains("3")) { + botAndMiddleCards[3] = "3"; + } else if (cards[botCard1].contains("4")) { + botAndMiddleCards[3] = "4"; + } else if (cards[botCard1].contains("5")) { + botAndMiddleCards[3] = "5"; + } else if (cards[botCard1].contains("6")) { + botAndMiddleCards[3] = "6"; + } else if (cards[botCard1].contains("7")) { + botAndMiddleCards[3] = "7"; + } else if (cards[botCard1].contains("8")) { + botAndMiddleCards[3] = "8"; + } else if (cards[botCard1].contains("9")) { + botAndMiddleCards[3] = "9"; + } else if (cards[botCard1].contains("10")) { + botAndMiddleCards[3] = "10"; + } else if (cards[botCard1].contains("jack")) { + botAndMiddleCards[3] = "jack"; + } else if (cards[botCard1].contains("queen")) { + botAndMiddleCards[3] = "queen"; + } else if (cards[botCard1].contains("king")) { + botAndMiddleCards[3] = "king"; } - //in the future maybe add a choice to add players + + if (cards[botCard2].contains("ace")) { + botAndMiddleCards[4] = "ace"; + } else if (cards[botCard2].contains("2")) { + botAndMiddleCards[4] = "2"; + } else if (cards[botCard2].contains("3")) { + botAndMiddleCards[4] = "3"; + } else if (cards[botCard2].contains("4")) { + botAndMiddleCards[4] = "4"; + } else if (cards[botCard2].contains("5")) { + botAndMiddleCards[4] = "5"; + } else if (cards[botCard2].contains("6")) { + botAndMiddleCards[4] = "6"; + } else if (cards[botCard2].contains("7")) { + botAndMiddleCards[4] = "7"; + } else if (cards[botCard2].contains("8")) { + botAndMiddleCards[4] = "8"; + } else if (cards[botCard2].contains("9")) { + botAndMiddleCards[4] = "9"; + } else if (cards[botCard2].contains("10")) { + botAndMiddleCards[4] = "10"; + } else if (cards[botCard2].contains("jack")) { + botAndMiddleCards[4] = "jack"; + } else if (cards[botCard2].contains("queen")) { + botAndMiddleCards[4] = "queen"; + } else if (cards[botCard2].contains("king")) { + botAndMiddleCards[4] = "king"; + } + event.getChannel().sendMessage("The bot has " + botAndMiddleCards[0] + botAndMiddleCards[1] + + botAndMiddleCards[2] + botAndMiddleCards[3] + botAndMiddleCards[4]); + event.getChannel().sendMessage("How much would you like to bet"); } + } + else if(content.contains("bet")) { + content = content.replace("bet", ""); + try { + wager = Integer.parseInt(content); + } catch (Exception e) { + event.getChannel().sendMessage("Choose a number after the command to gamble"); + } + balance -= wager; + totalBet+=wager; + System.out.println(totalBet); + if (balance < 0) { + event.getChannel().sendMessage("You don't have enough money to wager that much."); + } else { + event.getChannel().sendMessage("Your balance is " + balance); + + highestCallChance=botAlgorithm(botAndMiddleCards); + + // add more ways of having good hand here + if (50 > highestCallChance) { + highestCallChance = 50; } - //I don't know why this while loop doesn't work - System.out.println(userCooporates); - while(userCooporates=false) { - event.getChannel().sendMessage("Would you like to check, raise, or fold"); - userCooporates=true; - if(event.getMessageContent().contains("check")) { - - } - else if(event.getMessageContent().contains("raise")) { - - } - else if(event.getMessageContent().contains("fold")) { - + botCallChance = highestCallChance; + Random callRandom = new Random(); + int i = callRandom.nextInt(100); + if (botCallChance >= i) { + // bot calls + event.getChannel() + .sendMessage("Bot calls. Bot chance of calling was " + botCallChance + ". The random was " + i); + for (int k = 0; k < usedCards.length; k++) { + if (usedCards[k] == middleCard4) { + isUsed = true; + } - else { - userCooporates=false; + while (isUsed == true) { + middleCard4 = randCards.nextInt(52); + isUsed = false; } } + usedCards[7] = middleCard4; + event.getChannel().sendMessage("The middle cards are now the " + cards[middleCard1] + ", the " + + cards[middleCard2] + ", the " + cards[middleCard3]+" and the "+cards[middleCard4]); + + if (cards[middleCard4].contains("ace")) { + botAndMiddleCards[5] = "ace"; + } else if (cards[middleCard4].contains("2")) { + botAndMiddleCards[5] = "2"; + } else if (cards[middleCard4].contains("3")) { + botAndMiddleCards[5] = "3"; + } else if (cards[middleCard4].contains("4")) { + botAndMiddleCards[5] = "4"; + } else if (cards[middleCard4].contains("5")) { + botAndMiddleCards[5] = "5"; + } else if (cards[middleCard4].contains("6")) { + botAndMiddleCards[5] = "6"; + } else if (cards[middleCard4].contains("7")) { + botAndMiddleCards[5] = "7"; + } else if (cards[middleCard4].contains("8")) { + botAndMiddleCards[5] = "8"; + } else if (cards[middleCard4].contains("9")) { + botAndMiddleCards[5] = "9"; + } else if (cards[middleCard4].contains("10")) { + botAndMiddleCards[5] = "10"; + } else if (cards[middleCard4].contains("jack")) { + botAndMiddleCards[5] = "jack"; + } else if (cards[middleCard4].contains("queen")) { + botAndMiddleCards[5] = "queen"; + } else if (cards[middleCard4].contains("king")) { + botAndMiddleCards[5] = "king"; + } + event.getChannel().sendMessage("The bot has " + botAndMiddleCards[0] + botAndMiddleCards[1] + + botAndMiddleCards[2] + botAndMiddleCards[3] + botAndMiddleCards[4]+botAndMiddleCards[5]); + } else { + balance += totalBet*2; + event.getChannel() + .sendMessage("The bot folded, you win " + totalBet*2 + ". Your balance is now " + balance); + } + // in the future maybe add a choice to add players + } + } + else if(content.contains("fold")) { + event.getChannel().sendMessage("You folded. Your balance is "+balance); + } + } + } + public int botAlgorithm(String [] botAndMiddleCards) { + highestCallChance = 0; + numberSameCards = 0; + for (int j = 0; j < botAndMiddleCards.length; j++) { + if (botAndMiddleCards[j] == "ace") { + numberSameCards += 1; + } + } + if (numberSameCards == 2) { + if (100 > highestCallChance) { + highestCallChance = 100; + } + } else if (numberSameCards == 3 || numberSameCards == 4) { + highestCallChance = 100; + } + + numberSameCards = 0; + for (int j = 0; j < botAndMiddleCards.length; j++) { + if (botAndMiddleCards[j] == "2") { + numberSameCards += 1; + } } + if (numberSameCards == 2) { + if (70 > highestCallChance) { + highestCallChance = 70; } + } else if (numberSameCards == 3 || numberSameCards == 4) { + highestCallChance = 100; } + numberSameCards = 0; + for (int j = 0; j < botAndMiddleCards.length; j++) { + if (botAndMiddleCards[j] == "3") { + numberSameCards += 1; + } + } + if (numberSameCards == 2) { + if (75 > highestCallChance) { + highestCallChance = 75; + } + } else if (numberSameCards == 3 || numberSameCards == 4) { + highestCallChance = 100; + } + numberSameCards = 0; + for (int j = 0; j < botAndMiddleCards.length; j++) { + if (botAndMiddleCards[j] == "4") { + numberSameCards += 1; + } + } + if (numberSameCards == 2) { + if (75 > highestCallChance) { + highestCallChance = 75; + } + } else if (numberSameCards == 3 || numberSameCards == 4) { + highestCallChance = 100; + } + numberSameCards = 0; + for (int j = 0; j < botAndMiddleCards.length; j++) { + if (botAndMiddleCards[j] == "5") { + numberSameCards += 1; + } + } + if (numberSameCards == 2) { + if (80 > highestCallChance) { + highestCallChance = 80; + } + } else if (numberSameCards == 3 || numberSameCards == 4) { + highestCallChance = 100; + } + + numberSameCards = 0; + for (int j = 0; j < botAndMiddleCards.length; j++) { + if (botAndMiddleCards[j] == "6") { + numberSameCards += 1; + } + } + if (numberSameCards == 2) { + if (80 > highestCallChance) { + highestCallChance = 80; + } + } else if (numberSameCards == 3 || numberSameCards == 4) { + highestCallChance = 100; + } + + numberSameCards = 0; + for (int j = 0; j < botAndMiddleCards.length; j++) { + if (botAndMiddleCards[j] == "7") { + numberSameCards += 1; + } + } + if (numberSameCards == 2) { + if (85 > highestCallChance) { + highestCallChance = 85; + } + } else if (numberSameCards == 3 || numberSameCards == 4) { + highestCallChance = 100; + } + + numberSameCards = 0; + for (int j = 0; j < botAndMiddleCards.length; j++) { + if (botAndMiddleCards[j] == "8") { + numberSameCards += 1; + } + } + if (numberSameCards == 2) { + if (85 > highestCallChance) { + highestCallChance = 85; + } + } else if (numberSameCards == 3 || numberSameCards == 4) { + highestCallChance = 100; + } + + numberSameCards = 0; + for (int j = 0; j < botAndMiddleCards.length; j++) { + if (botAndMiddleCards[j] == "9") { + numberSameCards += 1; + } + } + if (numberSameCards == 2) { + if (85 > highestCallChance) { + highestCallChance = 85; + } + } else if (numberSameCards == 3 || numberSameCards == 4) { + highestCallChance = 100; + } + + numberSameCards = 0; + for (int j = 0; j < botAndMiddleCards.length; j++) { + if (botAndMiddleCards[j] == "10") { + numberSameCards += 1; + } + } + if (numberSameCards == 2) { + if (90 > highestCallChance) { + highestCallChance = 90; + } + } else if (numberSameCards == 3 || numberSameCards == 4) { + highestCallChance = 100; + } + + numberSameCards = 0; + for (int j = 0; j < botAndMiddleCards.length; j++) { + if (botAndMiddleCards[j] == "jack") { + numberSameCards += 1; + } + } + if (numberSameCards == 2) { + if (90 > highestCallChance) { + highestCallChance = 90; + } + } else if (numberSameCards == 3 || numberSameCards == 4) { + highestCallChance = 100; + } + + numberSameCards = 0; + for (int j = 0; j < botAndMiddleCards.length; j++) { + if (botAndMiddleCards[j] == "queen") { + numberSameCards += 1; + } + } + if (numberSameCards == 2) { + if (95 > highestCallChance) { + highestCallChance = 95; + } + } else if (numberSameCards == 3 || numberSameCards == 4) { + highestCallChance = 100; + } + + numberSameCards = 0; + for (int j = 0; j < botAndMiddleCards.length; j++) { + if (botAndMiddleCards[j] == "king") { + numberSameCards += 1; + } + } + if (numberSameCards == 2) { + if (95 > highestCallChance) { + highestCallChance = 95; + } + } else if (numberSameCards == 3 || numberSameCards == 4) { + highestCallChance = 100; + } + return highestCallChance; + } +} From ff614e8fa41512f477bce49af858fc1adc05b39a Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 14 Mar 2021 11:32:11 -0700 Subject: [PATCH 06/22] token --- src/main/resources/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config.json b/src/main/resources/config.json index 287c3bb8..cf664003 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,4 +1,4 @@ { "channels": ["jake-m"], - "token": "ODA4MDQwODE4NzgyNjM0MDA0.YCAwpw.zvB3OJwFAFd82DjgJVEpScWNq3w" + "token": "token" } From 02aeec0fda7339ff3429bbf39624bf2b5111dfa5 Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 21 Mar 2021 11:42:02 -0700 Subject: [PATCH 07/22] poker is finished, only needs to check who is the winner --- .../java/org/jointheleague/modules/Poker.java | 906 ++++++++++++------ 1 file changed, 600 insertions(+), 306 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/Poker.java b/src/main/java/org/jointheleague/modules/Poker.java index 09dadc6f..c364701e 100644 --- a/src/main/java/org/jointheleague/modules/Poker.java +++ b/src/main/java/org/jointheleague/modules/Poker.java @@ -21,8 +21,9 @@ public Poker(String channelName) { int totalBet; Random randCards = new Random(); String[] cards = new String[52]; - String[] botAndMiddleCards = new String[8]; - int[] usedCards = new int[8]; + String[] botAndMiddleCards = new String[7]; + String[] playerAndMiddleCards=new String[7]; + int[] usedCards = new int[9]; int playerCard1; int playerCard2; int middleCard1; @@ -35,6 +36,9 @@ public Poker(String channelName) { int numberSameCards; boolean userCooporates = false; boolean isUsed = false; + boolean flop = true; + boolean turn = true; + boolean gameOver = true; int highestCallChance = 0; int botCallChance = 0; @@ -96,336 +100,623 @@ public void handle(MessageCreateEvent event) throws APIException { if (event.getMessageContent().contains(command)) { String content = event.getMessageContent().replaceAll(" ", "").replace("!gamble", ""); if (content.contains("poker")) { - totalBet=0; - content = content.replace("poker", ""); - try { - wager = Integer.parseInt(content); - } catch (Exception e) { - event.getChannel().sendMessage("Choose a number after the command to gamble"); - } - balance -= wager; - totalBet+=wager; - if (balance < 0) { - event.getChannel().sendMessage("You don't have enough money to wager that much."); - } else { - event.getChannel().sendMessage("Your balance is " + balance); - // send photos of cards in the middle, its only text currently - middleCard1 = randCards.nextInt(52); - usedCards[0] = middleCard1; - middleCard2 = randCards.nextInt(52); - for (int i = 0; i < usedCards.length; i++) { - if (usedCards[i] == middleCard2) { - isUsed = true; - + if (gameOver == true) { + gameOver = false; + totalBet = 0; + content = content.replace("poker", ""); + try { + wager = Integer.parseInt(content); + } catch (Exception e) { + event.getChannel().sendMessage("Choose a number after the command to gamble"); + } + balance -= wager; + totalBet += wager; + if (balance < 0) { + event.getChannel().sendMessage("You don't have enough money to wager that much."); + } else { + event.getChannel().sendMessage("Your balance is " + balance); + // send photos of cards in the middle, its only text currently + middleCard1 = randCards.nextInt(52); + usedCards[0] = middleCard1; + middleCard2 = randCards.nextInt(52); + for (int i = 0; i < usedCards.length; i++) { + if (usedCards[i] == middleCard2) { + isUsed = true; + + } + while (isUsed == true) { + middleCard2 = randCards.nextInt(52); + isUsed = false; + } } - while (isUsed == true) { - middleCard2 = randCards.nextInt(52); - isUsed = false; + usedCards[1] = middleCard2; + middleCard3 = randCards.nextInt(52); + for (int i = 0; i < usedCards.length; i++) { + if (usedCards[i] == middleCard3) { + isUsed = true; + + } + while (isUsed == true) { + middleCard3 = randCards.nextInt(52); + isUsed = false; + } } - } - usedCards[1] = middleCard2; - middleCard3 = randCards.nextInt(52); - for (int i = 0; i < usedCards.length; i++) { - if (usedCards[i] == middleCard3) { - isUsed = true; - + usedCards[2] = middleCard3; + event.getChannel().sendMessage("The middle cards are the " + cards[middleCard1] + ", the " + + cards[middleCard2] + " and the " + cards[middleCard3]); + + // send photo of player cards, its only text currently + playerCard1 = randCards.nextInt(52); + for (int i = 0; i < usedCards.length; i++) { + if (usedCards[i] == playerCard1) { + isUsed = true; + + } + while (isUsed == true) { + playerCard1 = randCards.nextInt(52); + isUsed = false; + } } - while (isUsed == true) { - middleCard3 = randCards.nextInt(52); - isUsed = false; + usedCards[3] = playerCard1; + playerCard2 = randCards.nextInt(52); + for (int i = 0; i < usedCards.length; i++) { + if (usedCards[i] == playerCard2) { + isUsed = true; + + } + while (isUsed == true) { + playerCard2 = randCards.nextInt(52); + isUsed = false; + } } - } - usedCards[2] = middleCard3; - event.getChannel().sendMessage("The middle cards are the " + cards[middleCard1] + ", the " - + cards[middleCard2] + " and the " + cards[middleCard3]); - - // send photo of player cards, its only text currently - playerCard1 = randCards.nextInt(52); - for (int i = 0; i < usedCards.length; i++) { - if (usedCards[i] == playerCard1) { - isUsed = true; - + usedCards[4] = playerCard2; + event.getChannel().sendMessage( + "Your cards are the " + cards[playerCard1] + " and the " + cards[playerCard2]); + + // bot logic + botCard1 = randCards.nextInt(52); + for (int i = 0; i < usedCards.length; i++) { + if (usedCards[i] == botCard1) { + isUsed = true; + + } + while (isUsed == true) { + botCard1 = randCards.nextInt(52); + isUsed = false; + } } - while (isUsed == true) { - playerCard1 = randCards.nextInt(52); - isUsed = false; + usedCards[5] = botCard1; + botCard2 = randCards.nextInt(52); + for (int i = 0; i < usedCards.length; i++) { + if (usedCards[i] == botCard2) { + isUsed = true; + + } + while (isUsed == true) { + botCard2 = randCards.nextInt(52); + isUsed = false; + } + } + usedCards[6] = botCard2; + + // shows bot's cards + event.getChannel().sendMessage( + "Temporary: Bot's cards are the " + cards[botCard1] + " and the " + cards[botCard2]); + + if (cards[middleCard1].contains("ace")) { + botAndMiddleCards[0] = "ace"; + } else if (cards[middleCard1].contains("2")) { + botAndMiddleCards[0] = "2"; + } else if (cards[middleCard1].contains("3")) { + botAndMiddleCards[0] = "3"; + } else if (cards[middleCard1].contains("4")) { + botAndMiddleCards[0] = "4"; + } else if (cards[middleCard1].contains("5")) { + botAndMiddleCards[0] = "5"; + } else if (cards[middleCard1].contains("6")) { + botAndMiddleCards[0] = "6"; + } else if (cards[middleCard1].contains("7")) { + botAndMiddleCards[0] = "7"; + } else if (cards[middleCard1].contains("8")) { + botAndMiddleCards[0] = "8"; + } else if (cards[middleCard1].contains("9")) { + botAndMiddleCards[0] = "9"; + } else if (cards[middleCard1].contains("10")) { + botAndMiddleCards[0] = "10"; + } else if (cards[middleCard1].contains("jack")) { + botAndMiddleCards[0] = "jack"; + } else if (cards[middleCard1].contains("queen")) { + botAndMiddleCards[0] = "queen"; + } else if (cards[middleCard1].contains("king")) { + botAndMiddleCards[0] = "king"; } - } - usedCards[3] = playerCard1; - playerCard2 = randCards.nextInt(52); - for (int i = 0; i < usedCards.length; i++) { - if (usedCards[i] == playerCard2) { - isUsed = true; + if (cards[middleCard2].contains("ace")) { + botAndMiddleCards[1] = "ace"; + } else if (cards[middleCard2].contains("2")) { + botAndMiddleCards[1] = "2"; + } else if (cards[middleCard2].contains("3")) { + botAndMiddleCards[1] = "3"; + } else if (cards[middleCard2].contains("4")) { + botAndMiddleCards[1] = "4"; + } else if (cards[middleCard2].contains("5")) { + botAndMiddleCards[1] = "5"; + } else if (cards[middleCard2].contains("6")) { + botAndMiddleCards[1] = "6"; + } else if (cards[middleCard2].contains("7")) { + botAndMiddleCards[1] = "7"; + } else if (cards[middleCard2].contains("8")) { + botAndMiddleCards[1] = "8"; + } else if (cards[middleCard2].contains("9")) { + botAndMiddleCards[1] = "9"; + } else if (cards[middleCard2].contains("10")) { + botAndMiddleCards[1] = "10"; + } else if (cards[middleCard2].contains("jack")) { + botAndMiddleCards[1] = "jack"; + } else if (cards[middleCard2].contains("queen")) { + botAndMiddleCards[1] = "queen"; + } else if (cards[middleCard2].contains("king")) { + botAndMiddleCards[1] = "king"; } - while (isUsed == true) { - playerCard2 = randCards.nextInt(52); - isUsed = false; + if (cards[middleCard3].contains("ace")) { + botAndMiddleCards[2] = "ace"; + } else if (cards[middleCard3].contains("2")) { + botAndMiddleCards[2] = "2"; + } else if (cards[middleCard3].contains("3")) { + botAndMiddleCards[2] = "3"; + } else if (cards[middleCard3].contains("4")) { + botAndMiddleCards[2] = "4"; + } else if (cards[middleCard3].contains("5")) { + botAndMiddleCards[2] = "5"; + } else if (cards[middleCard3].contains("6")) { + botAndMiddleCards[2] = "6"; + } else if (cards[middleCard3].contains("7")) { + botAndMiddleCards[2] = "7"; + } else if (cards[middleCard3].contains("8")) { + botAndMiddleCards[2] = "8"; + } else if (cards[middleCard3].contains("9")) { + botAndMiddleCards[2] = "9"; + } else if (cards[middleCard3].contains("10")) { + botAndMiddleCards[2] = "10"; + } else if (cards[middleCard3].contains("jack")) { + botAndMiddleCards[2] = "jack"; + } else if (cards[middleCard3].contains("queen")) { + botAndMiddleCards[2] = "queen"; + } else if (cards[middleCard3].contains("king")) { + botAndMiddleCards[2] = "king"; } - } - usedCards[4] = playerCard2; - event.getChannel() - .sendMessage("Your cards are the " + cards[playerCard1] + " and the " + cards[playerCard2]); - - // bot logic - botCard1 = randCards.nextInt(52); - for (int i = 0; i < usedCards.length; i++) { - if (usedCards[i] == botCard1) { - isUsed = true; + if (cards[botCard1].contains("ace")) { + botAndMiddleCards[3] = "ace"; + } else if (cards[botCard1].contains("2")) { + botAndMiddleCards[3] = "2"; + } else if (cards[botCard1].contains("3")) { + botAndMiddleCards[3] = "3"; + } else if (cards[botCard1].contains("4")) { + botAndMiddleCards[3] = "4"; + } else if (cards[botCard1].contains("5")) { + botAndMiddleCards[3] = "5"; + } else if (cards[botCard1].contains("6")) { + botAndMiddleCards[3] = "6"; + } else if (cards[botCard1].contains("7")) { + botAndMiddleCards[3] = "7"; + } else if (cards[botCard1].contains("8")) { + botAndMiddleCards[3] = "8"; + } else if (cards[botCard1].contains("9")) { + botAndMiddleCards[3] = "9"; + } else if (cards[botCard1].contains("10")) { + botAndMiddleCards[3] = "10"; + } else if (cards[botCard1].contains("jack")) { + botAndMiddleCards[3] = "jack"; + } else if (cards[botCard1].contains("queen")) { + botAndMiddleCards[3] = "queen"; + } else if (cards[botCard1].contains("king")) { + botAndMiddleCards[3] = "king"; } - while (isUsed == true) { - botCard1 = randCards.nextInt(52); - isUsed = false; + + if (cards[botCard2].contains("ace")) { + botAndMiddleCards[4] = "ace"; + } else if (cards[botCard2].contains("2")) { + botAndMiddleCards[4] = "2"; + } else if (cards[botCard2].contains("3")) { + botAndMiddleCards[4] = "3"; + } else if (cards[botCard2].contains("4")) { + botAndMiddleCards[4] = "4"; + } else if (cards[botCard2].contains("5")) { + botAndMiddleCards[4] = "5"; + } else if (cards[botCard2].contains("6")) { + botAndMiddleCards[4] = "6"; + } else if (cards[botCard2].contains("7")) { + botAndMiddleCards[4] = "7"; + } else if (cards[botCard2].contains("8")) { + botAndMiddleCards[4] = "8"; + } else if (cards[botCard2].contains("9")) { + botAndMiddleCards[4] = "9"; + } else if (cards[botCard2].contains("10")) { + botAndMiddleCards[4] = "10"; + } else if (cards[botCard2].contains("jack")) { + botAndMiddleCards[4] = "jack"; + } else if (cards[botCard2].contains("queen")) { + botAndMiddleCards[4] = "queen"; + } else if (cards[botCard2].contains("king")) { + botAndMiddleCards[4] = "king"; } + event.getChannel().sendMessage("The bot has " + botAndMiddleCards[0] + botAndMiddleCards[1] + + botAndMiddleCards[2] + botAndMiddleCards[3] + botAndMiddleCards[4]); + event.getChannel().sendMessage("How much would you like to bet"); + } + } + else { + event.getChannel().sendMessage("You already have a game running."); + } + } + else if (content.contains("bet") && flop) { + flop = false; + content = content.replace("bet", ""); + try { + wager = Integer.parseInt(content); + } catch (Exception e) { + event.getChannel().sendMessage("Choose a number after the command to gamble"); } - usedCards[5] = botCard1; - botCard2 = randCards.nextInt(52); - for (int i = 0; i < usedCards.length; i++) { - if (usedCards[i] == botCard2) { - isUsed = true; + balance -= wager; + totalBet += wager; + System.out.println(totalBet); + if (balance < 0) { + event.getChannel().sendMessage("You don't have enough money to wager that much."); + } else { + event.getChannel().sendMessage("Your balance is " + balance); + + highestCallChance = botAlgorithm(botAndMiddleCards); + // add more ways of having good hand here, in method + + if (50 > highestCallChance) { + highestCallChance = 50; } - while (isUsed == true) { - botCard2 = randCards.nextInt(52); - isUsed = false; + botCallChance = highestCallChance; + Random callRandom = new Random(); + int i = callRandom.nextInt(100); + if (botCallChance >= i) { + // bot calls + event.getChannel().sendMessage( + "Bot calls. Bot chance of calling was " + botCallChance + ". The random was " + i); + for (int k = 0; k < usedCards.length; k++) { + if (usedCards[k] == middleCard4) { + isUsed = true; + + } + while (isUsed == true) { + middleCard4 = randCards.nextInt(52); + isUsed = false; + } + } + usedCards[7] = middleCard4; + event.getChannel() + .sendMessage("The middle cards are now the " + cards[middleCard1] + ", the " + + cards[middleCard2] + ", the " + cards[middleCard3] + " and the " + + cards[middleCard4]); + + if (cards[middleCard4].contains("ace")) { + botAndMiddleCards[5] = "ace"; + } else if (cards[middleCard4].contains("2")) { + botAndMiddleCards[5] = "2"; + } else if (cards[middleCard4].contains("3")) { + botAndMiddleCards[5] = "3"; + } else if (cards[middleCard4].contains("4")) { + botAndMiddleCards[5] = "4"; + } else if (cards[middleCard4].contains("5")) { + botAndMiddleCards[5] = "5"; + } else if (cards[middleCard4].contains("6")) { + botAndMiddleCards[5] = "6"; + } else if (cards[middleCard4].contains("7")) { + botAndMiddleCards[5] = "7"; + } else if (cards[middleCard4].contains("8")) { + botAndMiddleCards[5] = "8"; + } else if (cards[middleCard4].contains("9")) { + botAndMiddleCards[5] = "9"; + } else if (cards[middleCard4].contains("10")) { + botAndMiddleCards[5] = "10"; + } else if (cards[middleCard4].contains("jack")) { + botAndMiddleCards[5] = "jack"; + } else if (cards[middleCard4].contains("queen")) { + botAndMiddleCards[5] = "queen"; + } else if (cards[middleCard4].contains("king")) { + botAndMiddleCards[5] = "king"; + } + event.getChannel() + .sendMessage("The bot has " + botAndMiddleCards[0] + botAndMiddleCards[1] + + botAndMiddleCards[2] + botAndMiddleCards[3] + botAndMiddleCards[4] + + botAndMiddleCards[5]); + event.getChannel().sendMessage("How much would you like to bet"); + } else { + balance += totalBet * 2; + event.getChannel().sendMessage( + "The bot folded, you win " + totalBet * 2 + ". Your balance is now " + balance); + gameOver = true; } - } - usedCards[6] = botCard2; - - // shows bot's cards - event.getChannel().sendMessage( - "Temporary: Bot's cards are the " + cards[botCard1] + " and the " + cards[botCard2]); - - if (cards[middleCard1].contains("ace")) { - botAndMiddleCards[0] = "ace"; - } else if (cards[middleCard1].contains("2")) { - botAndMiddleCards[0] = "2"; - } else if (cards[middleCard1].contains("3")) { - botAndMiddleCards[0] = "3"; - } else if (cards[middleCard1].contains("4")) { - botAndMiddleCards[0] = "4"; - } else if (cards[middleCard1].contains("5")) { - botAndMiddleCards[0] = "5"; - } else if (cards[middleCard1].contains("6")) { - botAndMiddleCards[0] = "6"; - } else if (cards[middleCard1].contains("7")) { - botAndMiddleCards[0] = "7"; - } else if (cards[middleCard1].contains("8")) { - botAndMiddleCards[0] = "8"; - } else if (cards[middleCard1].contains("9")) { - botAndMiddleCards[0] = "9"; - } else if (cards[middleCard1].contains("10")) { - botAndMiddleCards[0] = "10"; - } else if (cards[middleCard1].contains("jack")) { - botAndMiddleCards[0] = "jack"; - } else if (cards[middleCard1].contains("queen")) { - botAndMiddleCards[0] = "queen"; - } else if (cards[middleCard1].contains("king")) { - botAndMiddleCards[0] = "king"; - } - if (cards[middleCard2].contains("ace")) { - botAndMiddleCards[1] = "ace"; - } else if (cards[middleCard2].contains("2")) { - botAndMiddleCards[1] = "2"; - } else if (cards[middleCard2].contains("3")) { - botAndMiddleCards[1] = "3"; - } else if (cards[middleCard2].contains("4")) { - botAndMiddleCards[1] = "4"; - } else if (cards[middleCard2].contains("5")) { - botAndMiddleCards[1] = "5"; - } else if (cards[middleCard2].contains("6")) { - botAndMiddleCards[1] = "6"; - } else if (cards[middleCard2].contains("7")) { - botAndMiddleCards[1] = "7"; - } else if (cards[middleCard2].contains("8")) { - botAndMiddleCards[1] = "8"; - } else if (cards[middleCard2].contains("9")) { - botAndMiddleCards[1] = "9"; - } else if (cards[middleCard2].contains("10")) { - botAndMiddleCards[1] = "10"; - } else if (cards[middleCard2].contains("jack")) { - botAndMiddleCards[1] = "jack"; - } else if (cards[middleCard2].contains("queen")) { - botAndMiddleCards[1] = "queen"; - } else if (cards[middleCard2].contains("king")) { - botAndMiddleCards[1] = "king"; + // in the future maybe add a choice to add players } - if (cards[middleCard3].contains("ace")) { - botAndMiddleCards[2] = "ace"; - } else if (cards[middleCard3].contains("2")) { - botAndMiddleCards[2] = "2"; - } else if (cards[middleCard3].contains("3")) { - botAndMiddleCards[2] = "3"; - } else if (cards[middleCard3].contains("4")) { - botAndMiddleCards[2] = "4"; - } else if (cards[middleCard3].contains("5")) { - botAndMiddleCards[2] = "5"; - } else if (cards[middleCard3].contains("6")) { - botAndMiddleCards[2] = "6"; - } else if (cards[middleCard3].contains("7")) { - botAndMiddleCards[2] = "7"; - } else if (cards[middleCard3].contains("8")) { - botAndMiddleCards[2] = "8"; - } else if (cards[middleCard3].contains("9")) { - botAndMiddleCards[2] = "9"; - } else if (cards[middleCard3].contains("10")) { - botAndMiddleCards[2] = "10"; - } else if (cards[middleCard3].contains("jack")) { - botAndMiddleCards[2] = "jack"; - } else if (cards[middleCard3].contains("queen")) { - botAndMiddleCards[2] = "queen"; - } else if (cards[middleCard3].contains("king")) { - botAndMiddleCards[2] = "king"; + } else if (content.contains("bet") && turn) { + turn = false; + content = content.replace("bet", ""); + try { + wager = Integer.parseInt(content); + } catch (Exception e) { + event.getChannel().sendMessage("Choose a number after the command to gamble"); } + balance -= wager; + totalBet += wager; + System.out.println(totalBet); + if (balance < 0) { + event.getChannel().sendMessage("You don't have enough money to wager that much."); + } else { + event.getChannel().sendMessage("Your balance is " + balance); - if (cards[botCard1].contains("ace")) { - botAndMiddleCards[3] = "ace"; - } else if (cards[botCard1].contains("2")) { - botAndMiddleCards[3] = "2"; - } else if (cards[botCard1].contains("3")) { - botAndMiddleCards[3] = "3"; - } else if (cards[botCard1].contains("4")) { - botAndMiddleCards[3] = "4"; - } else if (cards[botCard1].contains("5")) { - botAndMiddleCards[3] = "5"; - } else if (cards[botCard1].contains("6")) { - botAndMiddleCards[3] = "6"; - } else if (cards[botCard1].contains("7")) { - botAndMiddleCards[3] = "7"; - } else if (cards[botCard1].contains("8")) { - botAndMiddleCards[3] = "8"; - } else if (cards[botCard1].contains("9")) { - botAndMiddleCards[3] = "9"; - } else if (cards[botCard1].contains("10")) { - botAndMiddleCards[3] = "10"; - } else if (cards[botCard1].contains("jack")) { - botAndMiddleCards[3] = "jack"; - } else if (cards[botCard1].contains("queen")) { - botAndMiddleCards[3] = "queen"; - } else if (cards[botCard1].contains("king")) { - botAndMiddleCards[3] = "king"; - } + highestCallChance = botAlgorithm(botAndMiddleCards); - if (cards[botCard2].contains("ace")) { - botAndMiddleCards[4] = "ace"; - } else if (cards[botCard2].contains("2")) { - botAndMiddleCards[4] = "2"; - } else if (cards[botCard2].contains("3")) { - botAndMiddleCards[4] = "3"; - } else if (cards[botCard2].contains("4")) { - botAndMiddleCards[4] = "4"; - } else if (cards[botCard2].contains("5")) { - botAndMiddleCards[4] = "5"; - } else if (cards[botCard2].contains("6")) { - botAndMiddleCards[4] = "6"; - } else if (cards[botCard2].contains("7")) { - botAndMiddleCards[4] = "7"; - } else if (cards[botCard2].contains("8")) { - botAndMiddleCards[4] = "8"; - } else if (cards[botCard2].contains("9")) { - botAndMiddleCards[4] = "9"; - } else if (cards[botCard2].contains("10")) { - botAndMiddleCards[4] = "10"; - } else if (cards[botCard2].contains("jack")) { - botAndMiddleCards[4] = "jack"; - } else if (cards[botCard2].contains("queen")) { - botAndMiddleCards[4] = "queen"; - } else if (cards[botCard2].contains("king")) { - botAndMiddleCards[4] = "king"; - } - event.getChannel().sendMessage("The bot has " + botAndMiddleCards[0] + botAndMiddleCards[1] - + botAndMiddleCards[2] + botAndMiddleCards[3] + botAndMiddleCards[4]); - event.getChannel().sendMessage("How much would you like to bet"); - } - } - else if(content.contains("bet")) { - content = content.replace("bet", ""); - try { - wager = Integer.parseInt(content); - } catch (Exception e) { - event.getChannel().sendMessage("Choose a number after the command to gamble"); - } - balance -= wager; - totalBet+=wager; - System.out.println(totalBet); - if (balance < 0) { - event.getChannel().sendMessage("You don't have enough money to wager that much."); - } else { - event.getChannel().sendMessage("Your balance is " + balance); - - highestCallChance=botAlgorithm(botAndMiddleCards); - - // add more ways of having good hand here - - if (50 > highestCallChance) { - highestCallChance = 50; - } - botCallChance = highestCallChance; - Random callRandom = new Random(); - int i = callRandom.nextInt(100); - if (botCallChance >= i) { - // bot calls - event.getChannel() - .sendMessage("Bot calls. Bot chance of calling was " + botCallChance + ". The random was " + i); - for (int k = 0; k < usedCards.length; k++) { - if (usedCards[k] == middleCard4) { - isUsed = true; + // add more ways of having good hand here, in method - } - while (isUsed == true) { - middleCard4 = randCards.nextInt(52); - isUsed = false; + if (50 > highestCallChance) { + highestCallChance = 50; + } + botCallChance = highestCallChance; + Random callRandom = new Random(); + int i = callRandom.nextInt(100); + if (botCallChance >= i) { + // bot calls + event.getChannel().sendMessage( + "Bot calls. Bot chance of calling was " + botCallChance + ". The random was " + i); + for (int k = 0; k < usedCards.length; k++) { + if (usedCards[k] == middleCard5) { + isUsed = true; + + } + while (isUsed == true) { + middleCard5 = randCards.nextInt(52); + isUsed = false; + } + } + usedCards[8] = middleCard5; + event.getChannel() + .sendMessage("The middle cards are now the " + cards[middleCard1] + ", the " + + cards[middleCard2] + ", the " + cards[middleCard3] + " , the " + + cards[middleCard4] + " and the " + cards[middleCard5]); + + if (cards[middleCard4].contains("ace")) { + botAndMiddleCards[6] = "ace"; + } else if (cards[middleCard4].contains("2")) { + botAndMiddleCards[6] = "2"; + } else if (cards[middleCard4].contains("3")) { + botAndMiddleCards[6] = "3"; + } else if (cards[middleCard4].contains("4")) { + botAndMiddleCards[6] = "4"; + } else if (cards[middleCard4].contains("5")) { + botAndMiddleCards[6] = "5"; + } else if (cards[middleCard4].contains("6")) { + botAndMiddleCards[6] = "6"; + } else if (cards[middleCard4].contains("7")) { + botAndMiddleCards[6] = "7"; + } else if (cards[middleCard4].contains("8")) { + botAndMiddleCards[6] = "8"; + } else if (cards[middleCard4].contains("9")) { + botAndMiddleCards[6] = "9"; + } else if (cards[middleCard4].contains("10")) { + botAndMiddleCards[6] = "10"; + } else if (cards[middleCard4].contains("jack")) { + botAndMiddleCards[6] = "jack"; + } else if (cards[middleCard4].contains("queen")) { + botAndMiddleCards[6] = "queen"; + } else if (cards[middleCard4].contains("king")) { + botAndMiddleCards[6] = "king"; + } + event.getChannel() + .sendMessage("The bot has " + botAndMiddleCards[0] + botAndMiddleCards[1] + + botAndMiddleCards[2] + botAndMiddleCards[3] + botAndMiddleCards[4] + + botAndMiddleCards[5] + botAndMiddleCards[6]); + } else { + balance += totalBet * 2; + event.getChannel().sendMessage( + "The bot folded, you win " + totalBet * 2 + ". Your balance is now " + balance); + gameOver = true; + + } + // check if won here + if (cards[middleCard1].contains("ace")) { + playerAndMiddleCards[0] = "ace"; + } else if (cards[middleCard1].contains("2")) { + playerAndMiddleCards[0] = "2"; + } else if (cards[middleCard1].contains("3")) { + playerAndMiddleCards[0] = "3"; + } else if (cards[middleCard1].contains("4")) { + playerAndMiddleCards[0] = "4"; + } else if (cards[middleCard1].contains("5")) { + playerAndMiddleCards[0] = "5"; + } else if (cards[middleCard1].contains("6")) { + playerAndMiddleCards[0] = "6"; + } else if (cards[middleCard1].contains("7")) { + playerAndMiddleCards[0] = "7"; + } else if (cards[middleCard1].contains("8")) { + playerAndMiddleCards[0] = "8"; + } else if (cards[middleCard1].contains("9")) { + playerAndMiddleCards[0] = "9"; + } else if (cards[middleCard1].contains("10")) { + playerAndMiddleCards[0] = "10"; + } else if (cards[middleCard1].contains("jack")) { + playerAndMiddleCards[0] = "jack"; + } else if (cards[middleCard1].contains("queen")) { + playerAndMiddleCards[0] = "queen"; + } else if (cards[middleCard1].contains("king")) { + playerAndMiddleCards[0] = "king"; + } + if (cards[middleCard2].contains("ace")) { + playerAndMiddleCards[1] = "ace"; + } else if (cards[middleCard2].contains("2")) { + playerAndMiddleCards[1] = "2"; + } else if (cards[middleCard2].contains("3")) { + playerAndMiddleCards[1] = "3"; + } else if (cards[middleCard2].contains("4")) { + playerAndMiddleCards[1] = "4"; + } else if (cards[middleCard2].contains("5")) { + playerAndMiddleCards[1] = "5"; + } else if (cards[middleCard2].contains("6")) { + playerAndMiddleCards[1] = "6"; + } else if (cards[middleCard2].contains("7")) { + playerAndMiddleCards[1] = "7"; + } else if (cards[middleCard2].contains("8")) { + playerAndMiddleCards[1] = "8"; + } else if (cards[middleCard2].contains("9")) { + playerAndMiddleCards[1] = "9"; + } else if (cards[middleCard2].contains("10")) { + playerAndMiddleCards[1] = "10"; + } else if (cards[middleCard2].contains("jack")) { + playerAndMiddleCards[1] = "jack"; + } else if (cards[middleCard2].contains("queen")) { + playerAndMiddleCards[1] = "queen"; + } else if (cards[middleCard2].contains("king")) { + playerAndMiddleCards[1] = "king"; + } + if (cards[middleCard3].contains("ace")) { + playerAndMiddleCards[2] = "ace"; + } else if (cards[middleCard3].contains("2")) { + playerAndMiddleCards[2] = "2"; + } else if (cards[middleCard3].contains("3")) { + playerAndMiddleCards[2] = "3"; + } else if (cards[middleCard3].contains("4")) { + playerAndMiddleCards[2] = "4"; + } else if (cards[middleCard3].contains("5")) { + playerAndMiddleCards[2] = "5"; + } else if (cards[middleCard3].contains("6")) { + playerAndMiddleCards[2] = "6"; + } else if (cards[middleCard3].contains("7")) { + playerAndMiddleCards[2] = "7"; + } else if (cards[middleCard3].contains("8")) { + playerAndMiddleCards[2] = "8"; + } else if (cards[middleCard3].contains("9")) { + playerAndMiddleCards[2] = "9"; + } else if (cards[middleCard3].contains("10")) { + playerAndMiddleCards[2] = "10"; + } else if (cards[middleCard3].contains("jack")) { + playerAndMiddleCards[2] = "jack"; + } else if (cards[middleCard3].contains("queen")) { + playerAndMiddleCards[2] = "queen"; + } else if (cards[middleCard3].contains("king")) { + playerAndMiddleCards[2] = "king"; + } + if (cards[playerCard1].contains("ace")) { + playerAndMiddleCards[3] = "ace"; + } else if (cards[playerCard1].contains("2")) { + playerAndMiddleCards[3] = "2"; + } else if (cards[playerCard1].contains("3")) { + playerAndMiddleCards[3] = "3"; + } else if (cards[playerCard1].contains("4")) { + playerAndMiddleCards[3] = "4"; + } else if (cards[playerCard1].contains("5")) { + playerAndMiddleCards[3] = "5"; + } else if (cards[playerCard1].contains("6")) { + playerAndMiddleCards[3] = "6"; + } else if (cards[playerCard1].contains("7")) { + playerAndMiddleCards[3] = "7"; + } else if (cards[playerCard1].contains("8")) { + playerAndMiddleCards[3] = "8"; + } else if (cards[playerCard1].contains("9")) { + playerAndMiddleCards[3] = "9"; + } else if (cards[playerCard1].contains("10")) { + playerAndMiddleCards[3] = "10"; + } else if (cards[playerCard1].contains("jack")) { + playerAndMiddleCards[3] = "jack"; + } else if (cards[playerCard1].contains("queen")) { + playerAndMiddleCards[3] = "queen"; + } else if (cards[playerCard1].contains("king")) { + playerAndMiddleCards[3] = "king"; + } + if (cards[playerCard2].contains("ace")) { + playerAndMiddleCards[4] = "ace"; + } else if (cards[playerCard2].contains("2")) { + playerAndMiddleCards[4] = "2"; + } else if (cards[playerCard2].contains("3")) { + playerAndMiddleCards[4] = "3"; + } else if (cards[playerCard2].contains("4")) { + playerAndMiddleCards[4] = "4"; + } else if (cards[playerCard2].contains("5")) { + playerAndMiddleCards[4] = "5"; + } else if (cards[playerCard2].contains("6")) { + playerAndMiddleCards[4] = "6"; + } else if (cards[playerCard2].contains("7")) { + playerAndMiddleCards[4] = "7"; + } else if (cards[playerCard2].contains("8")) { + playerAndMiddleCards[4] = "8"; + } else if (cards[playerCard2].contains("9")) { + playerAndMiddleCards[4] = "9"; + } else if (cards[playerCard2].contains("10")) { + playerAndMiddleCards[4] = "10"; + } else if (cards[playerCard2].contains("jack")) { + playerAndMiddleCards[4] = "jack"; + } else if (cards[playerCard2].contains("queen")) { + playerAndMiddleCards[4] = "queen"; + } else if (cards[playerCard2].contains("king")) { + playerAndMiddleCards[4] = "king"; + } + if (cards[middleCard4].contains("ace")) { + playerAndMiddleCards[5] = "ace"; + } else if (cards[middleCard4].contains("2")) { + playerAndMiddleCards[5] = "2"; + } else if (cards[middleCard4].contains("3")) { + playerAndMiddleCards[5] = "3"; + } else if (cards[middleCard4].contains("4")) { + playerAndMiddleCards[5] = "4"; + } else if (cards[middleCard4].contains("5")) { + playerAndMiddleCards[5] = "5"; + } else if (cards[middleCard4].contains("6")) { + playerAndMiddleCards[5] = "6"; + } else if (cards[middleCard4].contains("7")) { + playerAndMiddleCards[5] = "7"; + } else if (cards[middleCard4].contains("8")) { + playerAndMiddleCards[5] = "8"; + } else if (cards[middleCard4].contains("9")) { + playerAndMiddleCards[5] = "9"; + } else if (cards[middleCard4].contains("10")) { + playerAndMiddleCards[5] = "10"; + } else if (cards[middleCard4].contains("jack")) { + playerAndMiddleCards[5] = "jack"; + } else if (cards[middleCard4].contains("queen")) { + playerAndMiddleCards[5] = "queen"; + } else if (cards[middleCard4].contains("king")) { + playerAndMiddleCards[5] = "king"; + } + if (cards[middleCard5].contains("ace")) { + playerAndMiddleCards[6] = "ace"; + } else if (cards[middleCard5].contains("2")) { + playerAndMiddleCards[6] = "2"; + } else if (cards[middleCard5].contains("3")) { + playerAndMiddleCards[6] = "3"; + } else if (cards[middleCard5].contains("4")) { + playerAndMiddleCards[6] = "4"; + } else if (cards[middleCard5].contains("5")) { + playerAndMiddleCards[6] = "5"; + } else if (cards[middleCard5].contains("6")) { + playerAndMiddleCards[6] = "6"; + } else if (cards[middleCard5].contains("7")) { + playerAndMiddleCards[6] = "7"; + } else if (cards[middleCard5].contains("8")) { + playerAndMiddleCards[6] = "8"; + } else if (cards[middleCard5].contains("9")) { + playerAndMiddleCards[6] = "9"; + } else if (cards[middleCard5].contains("10")) { + playerAndMiddleCards[6] = "10"; + } else if (cards[middleCard5].contains("jack")) { + playerAndMiddleCards[6] = "jack"; + } else if (cards[middleCard5].contains("queen")) { + playerAndMiddleCards[6] = "queen"; + } else if (cards[middleCard5].contains("king")) { + playerAndMiddleCards[6] = "king"; + } } } - usedCards[7] = middleCard4; - event.getChannel().sendMessage("The middle cards are now the " + cards[middleCard1] + ", the " - + cards[middleCard2] + ", the " + cards[middleCard3]+" and the "+cards[middleCard4]); - - if (cards[middleCard4].contains("ace")) { - botAndMiddleCards[5] = "ace"; - } else if (cards[middleCard4].contains("2")) { - botAndMiddleCards[5] = "2"; - } else if (cards[middleCard4].contains("3")) { - botAndMiddleCards[5] = "3"; - } else if (cards[middleCard4].contains("4")) { - botAndMiddleCards[5] = "4"; - } else if (cards[middleCard4].contains("5")) { - botAndMiddleCards[5] = "5"; - } else if (cards[middleCard4].contains("6")) { - botAndMiddleCards[5] = "6"; - } else if (cards[middleCard4].contains("7")) { - botAndMiddleCards[5] = "7"; - } else if (cards[middleCard4].contains("8")) { - botAndMiddleCards[5] = "8"; - } else if (cards[middleCard4].contains("9")) { - botAndMiddleCards[5] = "9"; - } else if (cards[middleCard4].contains("10")) { - botAndMiddleCards[5] = "10"; - } else if (cards[middleCard4].contains("jack")) { - botAndMiddleCards[5] = "jack"; - } else if (cards[middleCard4].contains("queen")) { - botAndMiddleCards[5] = "queen"; - } else if (cards[middleCard4].contains("king")) { - botAndMiddleCards[5] = "king"; } - event.getChannel().sendMessage("The bot has " + botAndMiddleCards[0] + botAndMiddleCards[1] - + botAndMiddleCards[2] + botAndMiddleCards[3] + botAndMiddleCards[4]+botAndMiddleCards[5]); - } else { - balance += totalBet*2; - event.getChannel() - .sendMessage("The bot folded, you win " + totalBet*2 + ". Your balance is now " + balance); - } - // in the future maybe add a choice to add players - } - } - else if(content.contains("fold")) { - event.getChannel().sendMessage("You folded. Your balance is "+balance); - } - } } - public int botAlgorithm(String [] botAndMiddleCards) { + + public int botAlgorithm(String[] botAndMiddleCards) { highestCallChance = 0; numberSameCards = 0; for (int j = 0; j < botAndMiddleCards.length; j++) { @@ -610,4 +901,7 @@ public int botAlgorithm(String [] botAndMiddleCards) { } return highestCallChance; } + public boolean playerWins(String [] playerAndMiddleCards, String [] botAndPlayerCards) { + return (Boolean) null; //true if player wins, false otherwise + } } From 7827f35076c655a60045e471efc47f96f2b50e64 Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 28 Mar 2021 13:13:45 -0700 Subject: [PATCH 08/22] poker done, needs debugging --- .../java/org/jointheleague/modules/Poker.java | 196 ++++++++++++------ src/main/resources/config.json | 2 +- 2 files changed, 134 insertions(+), 64 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/Poker.java b/src/main/java/org/jointheleague/modules/Poker.java index c364701e..edf45c99 100644 --- a/src/main/java/org/jointheleague/modules/Poker.java +++ b/src/main/java/org/jointheleague/modules/Poker.java @@ -34,11 +34,15 @@ public Poker(String channelName) { int botCard1; int botCard2; int numberSameCards; + int playerScore; + int botScore; boolean userCooporates = false; boolean isUsed = false; boolean flop = true; boolean turn = true; boolean gameOver = true; + boolean playerWon; + boolean rewardGiven; int highestCallChance = 0; int botCallChance = 0; @@ -102,6 +106,9 @@ public void handle(MessageCreateEvent event) throws APIException { if (content.contains("poker")) { if (gameOver == true) { gameOver = false; + flop=true; + turn=true; + rewardGiven=false; totalBet = 0; content = content.replace("poker", ""); try { @@ -370,12 +377,12 @@ else if (content.contains("bet") && flop) { // add more ways of having good hand here, in method - if (50 > highestCallChance) { - highestCallChance = 50; + if (500 > highestCallChance) { + highestCallChance = 500; } botCallChance = highestCallChance; Random callRandom = new Random(); - int i = callRandom.nextInt(100); + int i = callRandom.nextInt(1000); if (botCallChance >= i) { // bot calls event.getChannel().sendMessage( @@ -431,8 +438,9 @@ else if (content.contains("bet") && flop) { } else { balance += totalBet * 2; event.getChannel().sendMessage( - "The bot folded, you win " + totalBet * 2 + ". Your balance is now " + balance); + "The bot folded, you win " + ((totalBet * 2)-wager) + ". Your balance is now " + balance); gameOver = true; + rewardGiven=true; } // in the future maybe add a choice to add players @@ -457,12 +465,12 @@ else if (content.contains("bet") && flop) { // add more ways of having good hand here, in method - if (50 > highestCallChance) { - highestCallChance = 50; + if (500 > highestCallChance) { + highestCallChance = 500; } botCallChance = highestCallChance; Random callRandom = new Random(); - int i = callRandom.nextInt(100); + int i = callRandom.nextInt(1000); if (botCallChance >= i) { // bot calls event.getChannel().sendMessage( @@ -517,11 +525,11 @@ else if (content.contains("bet") && flop) { } else { balance += totalBet * 2; event.getChannel().sendMessage( - "The bot folded, you win " + totalBet * 2 + ". Your balance is now " + balance); + "The bot folded, you win " + ((totalBet * 2)-wager) + ". Your balance is now " + balance); gameOver = true; + rewardGiven=true; } - // check if won here if (cards[middleCard1].contains("ace")) { playerAndMiddleCards[0] = "ace"; } else if (cards[middleCard1].contains("2")) { @@ -711,6 +719,21 @@ else if (content.contains("bet") && flop) { } else if (cards[middleCard5].contains("king")) { playerAndMiddleCards[6] = "king"; } + if(!rewardGiven) { + playerWon=playerWins(playerAndMiddleCards, botAndMiddleCards); + if(playerWon) { + balance += totalBet * 2; + event.getChannel().sendMessage( + "You have the better hand. You won " + ((totalBet * 2)-wager) + ". Your balance is now " + balance); + gameOver = true; + } + else if(!playerWon) { + event.getChannel().sendMessage("The bot has the better hand. You win nothing. Your balance is now "+balance); + } + else { + System.out.println("error"); + } + } } } } @@ -725,11 +748,14 @@ public int botAlgorithm(String[] botAndMiddleCards) { } } if (numberSameCards == 2) { - if (100 > highestCallChance) { - highestCallChance = 100; + if (950 > highestCallChance) { + highestCallChance = 950; } - } else if (numberSameCards == 3 || numberSameCards == 4) { - highestCallChance = 100; + } else if (numberSameCards == 3) { + highestCallChance = 970; + } + else if(numberSameCards == 4) { + highestCallChance=1000; } numberSameCards = 0; @@ -739,11 +765,14 @@ public int botAlgorithm(String[] botAndMiddleCards) { } } if (numberSameCards == 2) { - if (70 > highestCallChance) { - highestCallChance = 70; + if (700 > highestCallChance) { + highestCallChance = 700; } - } else if (numberSameCards == 3 || numberSameCards == 4) { - highestCallChance = 100; + } else if (numberSameCards == 3) { + highestCallChance = 951; + } + else if(numberSameCards == 4) { + highestCallChance=971; } numberSameCards = 0; @@ -753,11 +782,14 @@ public int botAlgorithm(String[] botAndMiddleCards) { } } if (numberSameCards == 2) { - if (75 > highestCallChance) { - highestCallChance = 75; + if (750 > highestCallChance) { + highestCallChance = 750; } - } else if (numberSameCards == 3 || numberSameCards == 4) { - highestCallChance = 100; + } else if (numberSameCards == 3) { + highestCallChance = 952; + } + else if(numberSameCards == 4) { + highestCallChance=972; } numberSameCards = 0; @@ -767,11 +799,14 @@ public int botAlgorithm(String[] botAndMiddleCards) { } } if (numberSameCards == 2) { - if (75 > highestCallChance) { - highestCallChance = 75; + if (751 > highestCallChance) { + highestCallChance = 751; } - } else if (numberSameCards == 3 || numberSameCards == 4) { - highestCallChance = 100; + } else if (numberSameCards == 3) { + highestCallChance = 953; + } + else if(numberSameCards == 4) { + highestCallChance=973; } numberSameCards = 0; @@ -781,11 +816,14 @@ public int botAlgorithm(String[] botAndMiddleCards) { } } if (numberSameCards == 2) { - if (80 > highestCallChance) { - highestCallChance = 80; + if (800 > highestCallChance) { + highestCallChance = 800; } - } else if (numberSameCards == 3 || numberSameCards == 4) { - highestCallChance = 100; + } else if (numberSameCards == 3) { + highestCallChance = 954; + } + else if(numberSameCards == 4) { + highestCallChance=974; } numberSameCards = 0; @@ -795,11 +833,14 @@ public int botAlgorithm(String[] botAndMiddleCards) { } } if (numberSameCards == 2) { - if (80 > highestCallChance) { - highestCallChance = 80; + if (801 > highestCallChance) { + highestCallChance = 801; } - } else if (numberSameCards == 3 || numberSameCards == 4) { - highestCallChance = 100; + } else if (numberSameCards == 3) { + highestCallChance = 955; + } + else if(numberSameCards == 4) { + highestCallChance=975; } numberSameCards = 0; @@ -809,11 +850,14 @@ public int botAlgorithm(String[] botAndMiddleCards) { } } if (numberSameCards == 2) { - if (85 > highestCallChance) { - highestCallChance = 85; + if (850 > highestCallChance) { + highestCallChance = 850; } - } else if (numberSameCards == 3 || numberSameCards == 4) { - highestCallChance = 100; + } else if (numberSameCards == 3) { + highestCallChance = 956; + } + else if(numberSameCards == 4) { + highestCallChance=976; } numberSameCards = 0; @@ -823,11 +867,14 @@ public int botAlgorithm(String[] botAndMiddleCards) { } } if (numberSameCards == 2) { - if (85 > highestCallChance) { - highestCallChance = 85; + if (851 > highestCallChance) { + highestCallChance = 851; } - } else if (numberSameCards == 3 || numberSameCards == 4) { - highestCallChance = 100; + } else if (numberSameCards == 3) { + highestCallChance = 957; + } + else if(numberSameCards == 4) { + highestCallChance=977; } numberSameCards = 0; @@ -837,11 +884,14 @@ public int botAlgorithm(String[] botAndMiddleCards) { } } if (numberSameCards == 2) { - if (85 > highestCallChance) { - highestCallChance = 85; + if (852 > highestCallChance) { + highestCallChance = 852; } - } else if (numberSameCards == 3 || numberSameCards == 4) { - highestCallChance = 100; + } else if (numberSameCards == 3) { + highestCallChance = 958; + } + else if(numberSameCards == 4) { + highestCallChance=958; } numberSameCards = 0; @@ -851,11 +901,14 @@ public int botAlgorithm(String[] botAndMiddleCards) { } } if (numberSameCards == 2) { - if (90 > highestCallChance) { - highestCallChance = 90; + if (900 > highestCallChance) { + highestCallChance = 900; } - } else if (numberSameCards == 3 || numberSameCards == 4) { - highestCallChance = 100; + } else if (numberSameCards == 3) { + highestCallChance = 959; + } + else if(numberSameCards == 4) { + highestCallChance=959; } numberSameCards = 0; @@ -865,11 +918,14 @@ public int botAlgorithm(String[] botAndMiddleCards) { } } if (numberSameCards == 2) { - if (90 > highestCallChance) { - highestCallChance = 90; + if (910 > highestCallChance) { + highestCallChance = 910; } - } else if (numberSameCards == 3 || numberSameCards == 4) { - highestCallChance = 100; + } else if (numberSameCards == 3) { + highestCallChance = 960; + } + else if(numberSameCards == 4) { + highestCallChance=980; } numberSameCards = 0; @@ -879,11 +935,14 @@ public int botAlgorithm(String[] botAndMiddleCards) { } } if (numberSameCards == 2) { - if (95 > highestCallChance) { - highestCallChance = 95; + if (920 > highestCallChance) { + highestCallChance = 920; } - } else if (numberSameCards == 3 || numberSameCards == 4) { - highestCallChance = 100; + } else if (numberSameCards == 3) { + highestCallChance = 961; + } + else if(numberSameCards == 4) { + highestCallChance=981; } numberSameCards = 0; @@ -893,15 +952,26 @@ public int botAlgorithm(String[] botAndMiddleCards) { } } if (numberSameCards == 2) { - if (95 > highestCallChance) { - highestCallChance = 95; + if (930 > highestCallChance) { + highestCallChance = 930; } - } else if (numberSameCards == 3 || numberSameCards == 4) { - highestCallChance = 100; + } else if (numberSameCards == 3) { + highestCallChance = 962; + } + else if(numberSameCards == 4) { + highestCallChance=982; } return highestCallChance; } - public boolean playerWins(String [] playerAndMiddleCards, String [] botAndPlayerCards) { - return (Boolean) null; //true if player wins, false otherwise + public boolean playerWins(String [] playerAndMiddleCards, String [] botAndMiddleCards) { + playerScore=botAlgorithm(playerAndMiddleCards); + botScore=botAlgorithm(botAndMiddleCards); + gameOver=true; + if(playerScore>botScore) { + return true; + } + else { + return false; + } } } diff --git a/src/main/resources/config.json b/src/main/resources/config.json index cf664003..ecde8103 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,4 +1,4 @@ { "channels": ["jake-m"], - "token": "token" + "token": "ODA4MDQwODE4NzgyNjM0MDA0.YCAwpw.3BoceDoMGYBeDJ3Bp9uPOsf0rog" } From 830214c15d02487eaab120c4db75c23d4fa6c8fa Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 28 Mar 2021 13:17:08 -0700 Subject: [PATCH 09/22] token change --- src/main/resources/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config.json b/src/main/resources/config.json index ecde8103..cf664003 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,4 +1,4 @@ { "channels": ["jake-m"], - "token": "ODA4MDQwODE4NzgyNjM0MDA0.YCAwpw.3BoceDoMGYBeDJ3Bp9uPOsf0rog" + "token": "token" } From 24e871e2105444add95b8a179aab7c07ef7d5cc4 Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 11 Apr 2021 11:30:28 -0700 Subject: [PATCH 10/22] Bot is done, needs to fix negative number glitch --- .../discord_bot_example/Bot.java | 6 +- .../java/org/jointheleague/modules/Poker.java | 67 ++++++++++++++----- src/main/resources/config.json | 2 +- 3 files changed, 56 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/jointheleague/discord_bot_example/Bot.java b/src/main/java/org/jointheleague/discord_bot_example/Bot.java index 4857c851..091cf08c 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -47,9 +47,9 @@ public void connect(boolean printInvite) { api.addMessageCreateListener(dl); helpListener.addHelpEmbed(dl.getHelpEmbed()); - CurrencyConverter cc = new CurrencyConverter(channelName); - api.addMessageCreateListener(cc); - helpListener.addHelpEmbed(cc.getHelpEmbed()); + //CurrencyConverter cc = new CurrencyConverter(channelName); + //api.addMessageCreateListener(cc); + //helpListener.addHelpEmbed(cc.getHelpEmbed()); ToDoList list = new ToDoList(channelName); api.addMessageCreateListener(list); diff --git a/src/main/java/org/jointheleague/modules/Poker.java b/src/main/java/org/jointheleague/modules/Poker.java index edf45c99..ac55d5bd 100644 --- a/src/main/java/org/jointheleague/modules/Poker.java +++ b/src/main/java/org/jointheleague/modules/Poker.java @@ -110,6 +110,32 @@ public void handle(MessageCreateEvent event) throws APIException { turn=true; rewardGiven=false; totalBet = 0; + highestCallChance=0; + botCallChance=0; + usedCards[0]=-1; + usedCards[1]=-1; + usedCards[2]=-1; + usedCards[3]=-1; + usedCards[4]=-1; + usedCards[5]=-1; + usedCards[6]=-1; + usedCards[7]=-1; + usedCards[8]=-1; + botAndMiddleCards[0]=""; + botAndMiddleCards[1]=""; + botAndMiddleCards[2]=""; + botAndMiddleCards[3]=""; + botAndMiddleCards[4]=""; + botAndMiddleCards[5]=""; + botAndMiddleCards[6]=""; + playerAndMiddleCards[0]=""; + playerAndMiddleCards[1]=""; + playerAndMiddleCards[2]=""; + playerAndMiddleCards[3]=""; + playerAndMiddleCards[4]=""; + playerAndMiddleCards[5]=""; + playerAndMiddleCards[6]=""; + content = content.replace("poker", ""); try { wager = Integer.parseInt(content); @@ -350,6 +376,7 @@ public void handle(MessageCreateEvent event) throws APIException { } event.getChannel().sendMessage("The bot has " + botAndMiddleCards[0] + botAndMiddleCards[1] + botAndMiddleCards[2] + botAndMiddleCards[3] + botAndMiddleCards[4]); + event.getChannel().sendMessage("Your hand is now the " +cards[playerCard1]+", "+cards[playerCard2]+", "+cards[middleCard1]+", "+cards[middleCard2]+", and "+cards[middleCard3]); event.getChannel().sendMessage("How much would you like to bet"); } } @@ -357,7 +384,11 @@ public void handle(MessageCreateEvent event) throws APIException { event.getChannel().sendMessage("You already have a game running."); } } - else if (content.contains("bet") && flop) { + else if(content.contains("fold") && !gameOver) { + event.getChannel().sendMessage("You folded. Your balance is now "+balance); + gameOver=true; + } + else if (content.contains("bet") && flop && !gameOver) { flop = false; content = content.replace("bet", ""); try { @@ -387,6 +418,7 @@ else if (content.contains("bet") && flop) { // bot calls event.getChannel().sendMessage( "Bot calls. Bot chance of calling was " + botCallChance + ". The random was " + i); + middleCard4 = randCards.nextInt(52); for (int k = 0; k < usedCards.length; k++) { if (usedCards[k] == middleCard4) { isUsed = true; @@ -402,6 +434,7 @@ else if (content.contains("bet") && flop) { .sendMessage("The middle cards are now the " + cards[middleCard1] + ", the " + cards[middleCard2] + ", the " + cards[middleCard3] + " and the " + cards[middleCard4]); + event.getChannel().sendMessage("Your hand is now the " +cards[playerCard1]+", "+cards[playerCard2]+", "+cards[middleCard1]+", "+cards[middleCard2]+", "+cards[middleCard3]+", and "+cards[middleCard4]); if (cards[middleCard4].contains("ace")) { botAndMiddleCards[5] = "ace"; @@ -445,7 +478,7 @@ else if (content.contains("bet") && flop) { // in the future maybe add a choice to add players } - } else if (content.contains("bet") && turn) { + } else if (content.contains("bet") && turn && !gameOver) { turn = false; content = content.replace("bet", ""); try { @@ -475,6 +508,7 @@ else if (content.contains("bet") && flop) { // bot calls event.getChannel().sendMessage( "Bot calls. Bot chance of calling was " + botCallChance + ". The random was " + i); + middleCard5 = randCards.nextInt(52); for (int k = 0; k < usedCards.length; k++) { if (usedCards[k] == middleCard5) { isUsed = true; @@ -491,37 +525,38 @@ else if (content.contains("bet") && flop) { + cards[middleCard2] + ", the " + cards[middleCard3] + " , the " + cards[middleCard4] + " and the " + cards[middleCard5]); - if (cards[middleCard4].contains("ace")) { + if (cards[middleCard5].contains("ace")) { botAndMiddleCards[6] = "ace"; - } else if (cards[middleCard4].contains("2")) { + } else if (cards[middleCard5].contains("2")) { botAndMiddleCards[6] = "2"; - } else if (cards[middleCard4].contains("3")) { + } else if (cards[middleCard5].contains("3")) { botAndMiddleCards[6] = "3"; - } else if (cards[middleCard4].contains("4")) { + } else if (cards[middleCard5].contains("4")) { botAndMiddleCards[6] = "4"; - } else if (cards[middleCard4].contains("5")) { + } else if (cards[middleCard5].contains("5")) { botAndMiddleCards[6] = "5"; - } else if (cards[middleCard4].contains("6")) { + } else if (cards[middleCard5].contains("6")) { botAndMiddleCards[6] = "6"; - } else if (cards[middleCard4].contains("7")) { + } else if (cards[middleCard5].contains("7")) { botAndMiddleCards[6] = "7"; - } else if (cards[middleCard4].contains("8")) { + } else if (cards[middleCard5].contains("8")) { botAndMiddleCards[6] = "8"; - } else if (cards[middleCard4].contains("9")) { + } else if (cards[middleCard5].contains("9")) { botAndMiddleCards[6] = "9"; - } else if (cards[middleCard4].contains("10")) { + } else if (cards[middleCard5].contains("10")) { botAndMiddleCards[6] = "10"; - } else if (cards[middleCard4].contains("jack")) { + } else if (cards[middleCard5].contains("jack")) { botAndMiddleCards[6] = "jack"; - } else if (cards[middleCard4].contains("queen")) { + } else if (cards[middleCard5].contains("queen")) { botAndMiddleCards[6] = "queen"; - } else if (cards[middleCard4].contains("king")) { + } else if (cards[middleCard5].contains("king")) { botAndMiddleCards[6] = "king"; } event.getChannel() .sendMessage("The bot has " + botAndMiddleCards[0] + botAndMiddleCards[1] + botAndMiddleCards[2] + botAndMiddleCards[3] + botAndMiddleCards[4] + botAndMiddleCards[5] + botAndMiddleCards[6]); + event.getChannel().sendMessage("Your hand is now the " +cards[playerCard1]+", "+cards[playerCard2]+", "+cards[middleCard1]+", "+cards[middleCard2]+", "+cards[middleCard3]+", "+cards[middleCard4]+", and "+cards[middleCard5]); } else { balance += totalBet * 2; event.getChannel().sendMessage( @@ -720,6 +755,8 @@ else if (content.contains("bet") && flop) { playerAndMiddleCards[6] = "king"; } if(!rewardGiven) { + event.getChannel().sendMessage("Your hand is now the " +cards[playerCard1]+", "+cards[playerCard2]+", "+cards[middleCard1]+", "+cards[middleCard2]+", "+cards[middleCard3]+", "+cards[middleCard4]+", and "+cards[middleCard5]); + event.getChannel().sendMessage("The bot's final hand has the "+cards[botCard1]+", "+cards[botCard2]+", "+cards[middleCard1]+", "+cards[middleCard2]+", "+cards[middleCard3]+", "+cards[middleCard4]+", and "+cards[middleCard5]); playerWon=playerWins(playerAndMiddleCards, botAndMiddleCards); if(playerWon) { balance += totalBet * 2; diff --git a/src/main/resources/config.json b/src/main/resources/config.json index cf664003..5c6fc4f8 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,4 +1,4 @@ { "channels": ["jake-m"], - "token": "token" + "token": "ODA4MDQwODE4NzgyNjM0MDA0.YCAwpw.5sQomdO4gwqQOQ8l_62jqGM_ylQ" } From acc4d062d3ece839edfe2a6e958536f196e117c7 Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 11 Apr 2021 11:31:24 -0700 Subject: [PATCH 11/22] token --- src/main/resources/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config.json b/src/main/resources/config.json index 5c6fc4f8..cf664003 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,4 +1,4 @@ { "channels": ["jake-m"], - "token": "ODA4MDQwODE4NzgyNjM0MDA0.YCAwpw.5sQomdO4gwqQOQ8l_62jqGM_ylQ" + "token": "token" } From bca86dcbd9eeb50bab8d99a10b9e025fe0f639ee Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 18 Apr 2021 11:47:35 -0700 Subject: [PATCH 12/22] added river betting, needs negative number bug to be fixed --- .../java/org/jointheleague/modules/Poker.java | 115 ++++++++++++------ src/main/resources/config.json | 2 +- 2 files changed, 81 insertions(+), 36 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/Poker.java b/src/main/java/org/jointheleague/modules/Poker.java index ac55d5bd..4b8b7ca4 100644 --- a/src/main/java/org/jointheleague/modules/Poker.java +++ b/src/main/java/org/jointheleague/modules/Poker.java @@ -36,10 +36,12 @@ public Poker(String channelName) { int numberSameCards; int playerScore; int botScore; + int numberPairs; boolean userCooporates = false; boolean isUsed = false; boolean flop = true; boolean turn = true; + boolean river=true; boolean gameOver = true; boolean playerWon; boolean rewardGiven; @@ -108,10 +110,12 @@ public void handle(MessageCreateEvent event) throws APIException { gameOver = false; flop=true; turn=true; + river=true; rewardGiven=false; totalBet = 0; highestCallChance=0; botCallChance=0; + numberPairs=0; usedCards[0]=-1; usedCards[1]=-1; usedCards[2]=-1; @@ -142,11 +146,14 @@ public void handle(MessageCreateEvent event) throws APIException { } catch (Exception e) { event.getChannel().sendMessage("Choose a number after the command to gamble"); } - balance -= wager; - totalBet += wager; if (balance < 0) { event.getChannel().sendMessage("You don't have enough money to wager that much."); - } else { + } else if (wager<0) { + event.getChannel().sendMessage("Choose a positive number"); + } + else { + balance -= wager; + totalBet += wager; event.getChannel().sendMessage("Your balance is " + balance); // send photos of cards in the middle, its only text currently middleCard1 = randCards.nextInt(52); @@ -206,7 +213,6 @@ public void handle(MessageCreateEvent event) throws APIException { event.getChannel().sendMessage( "Your cards are the " + cards[playerCard1] + " and the " + cards[playerCard2]); - // bot logic botCard1 = randCards.nextInt(52); for (int i = 0; i < usedCards.length; i++) { if (usedCards[i] == botCard1) { @@ -233,8 +239,7 @@ public void handle(MessageCreateEvent event) throws APIException { usedCards[6] = botCard2; // shows bot's cards - event.getChannel().sendMessage( - "Temporary: Bot's cards are the " + cards[botCard1] + " and the " + cards[botCard2]); + System.out.println("Temporary: Bot's cards are the " + cards[botCard1] + " and the " + cards[botCard2]); if (cards[middleCard1].contains("ace")) { botAndMiddleCards[0] = "ace"; @@ -374,8 +379,8 @@ public void handle(MessageCreateEvent event) throws APIException { } else if (cards[botCard2].contains("king")) { botAndMiddleCards[4] = "king"; } - event.getChannel().sendMessage("The bot has " + botAndMiddleCards[0] + botAndMiddleCards[1] - + botAndMiddleCards[2] + botAndMiddleCards[3] + botAndMiddleCards[4]); + System.out.println("The bot has " + botAndMiddleCards[0]+", "+botAndMiddleCards[1]+", " + +botAndMiddleCards[2]+", "+botAndMiddleCards[3]+", and "+botAndMiddleCards[4]); event.getChannel().sendMessage("Your hand is now the " +cards[playerCard1]+", "+cards[playerCard2]+", "+cards[middleCard1]+", "+cards[middleCard2]+", and "+cards[middleCard3]); event.getChannel().sendMessage("How much would you like to bet"); } @@ -389,24 +394,26 @@ else if(content.contains("fold") && !gameOver) { gameOver=true; } else if (content.contains("bet") && flop && !gameOver) { - flop = false; content = content.replace("bet", ""); try { wager = Integer.parseInt(content); } catch (Exception e) { event.getChannel().sendMessage("Choose a number after the command to gamble"); } - balance -= wager; - totalBet += wager; System.out.println(totalBet); if (balance < 0) { event.getChannel().sendMessage("You don't have enough money to wager that much."); - } else { + } else if(wager<0) { + event.getChannel().sendMessage("Choose a positive number"); + } + else { + flop = false; + balance -= wager; + totalBet += wager; event.getChannel().sendMessage("Your balance is " + balance); highestCallChance = botAlgorithm(botAndMiddleCards); - // add more ways of having good hand here, in method if (500 > highestCallChance) { highestCallChance = 500; @@ -416,9 +423,10 @@ else if (content.contains("bet") && flop && !gameOver) { int i = callRandom.nextInt(1000); if (botCallChance >= i) { // bot calls - event.getChannel().sendMessage( + System.out.println( "Bot calls. Bot chance of calling was " + botCallChance + ". The random was " + i); middleCard4 = randCards.nextInt(52); + event.getChannel().sendMessage("Bot calls."); for (int k = 0; k < usedCards.length; k++) { if (usedCards[k] == middleCard4) { isUsed = true; @@ -463,10 +471,9 @@ else if (content.contains("bet") && flop && !gameOver) { } else if (cards[middleCard4].contains("king")) { botAndMiddleCards[5] = "king"; } - event.getChannel() - .sendMessage("The bot has " + botAndMiddleCards[0] + botAndMiddleCards[1] - + botAndMiddleCards[2] + botAndMiddleCards[3] + botAndMiddleCards[4] - + botAndMiddleCards[5]); + System.out.println("The bot has "+botAndMiddleCards[0]+", "+botAndMiddleCards[1] + +", "+botAndMiddleCards[2]+", "+botAndMiddleCards[3]+", "+botAndMiddleCards[4] + +" and "+botAndMiddleCards[5]); event.getChannel().sendMessage("How much would you like to bet"); } else { balance += totalBet * 2; @@ -475,23 +482,24 @@ else if (content.contains("bet") && flop && !gameOver) { gameOver = true; rewardGiven=true; } - - // in the future maybe add a choice to add players } } else if (content.contains("bet") && turn && !gameOver) { - turn = false; content = content.replace("bet", ""); try { wager = Integer.parseInt(content); } catch (Exception e) { event.getChannel().sendMessage("Choose a number after the command to gamble"); } - balance -= wager; - totalBet += wager; System.out.println(totalBet); if (balance < 0) { event.getChannel().sendMessage("You don't have enough money to wager that much."); - } else { + } else if(wager<0) { + event.getChannel().sendMessage("Choose a positive number."); + } + else { + turn = false; + balance -= wager; + totalBet += wager; event.getChannel().sendMessage("Your balance is " + balance); highestCallChance = botAlgorithm(botAndMiddleCards); @@ -506,8 +514,8 @@ else if (content.contains("bet") && flop && !gameOver) { int i = callRandom.nextInt(1000); if (botCallChance >= i) { // bot calls - event.getChannel().sendMessage( - "Bot calls. Bot chance of calling was " + botCallChance + ". The random was " + i); + System.out.println("Bot calls. Bot chance of calling was " + botCallChance + ". The random was " + i); + event.getChannel().sendMessage("Bot calls."); middleCard5 = randCards.nextInt(52); for (int k = 0; k < usedCards.length; k++) { if (usedCards[k] == middleCard5) { @@ -552,19 +560,38 @@ else if (content.contains("bet") && flop && !gameOver) { } else if (cards[middleCard5].contains("king")) { botAndMiddleCards[6] = "king"; } - event.getChannel() - .sendMessage("The bot has " + botAndMiddleCards[0] + botAndMiddleCards[1] - + botAndMiddleCards[2] + botAndMiddleCards[3] + botAndMiddleCards[4] - + botAndMiddleCards[5] + botAndMiddleCards[6]); + System.out.println("The bot has "+botAndMiddleCards[0]+", "+botAndMiddleCards[1] + +", "+botAndMiddleCards[2]+", "+botAndMiddleCards[3]+", "+botAndMiddleCards[4] + +", "+botAndMiddleCards[5]+" and "+botAndMiddleCards[6]); event.getChannel().sendMessage("Your hand is now the " +cards[playerCard1]+", "+cards[playerCard2]+", "+cards[middleCard1]+", "+cards[middleCard2]+", "+cards[middleCard3]+", "+cards[middleCard4]+", and "+cards[middleCard5]); + event.getChannel().sendMessage("How much would you like to bet?"); } else { balance += totalBet * 2; event.getChannel().sendMessage( "The bot folded, you win " + ((totalBet * 2)-wager) + ". Your balance is now " + balance); gameOver = true; rewardGiven=true; - } + } + }else if (content.contains("bet") && river && !gameOver) { + content = content.replace("bet", ""); + try { + wager = Integer.parseInt(content); + } catch (Exception e) { + event.getChannel().sendMessage("Choose a number after the command to gamble"); + } + System.out.println(totalBet); + if (balance < 0) { + event.getChannel().sendMessage("You don't have enough money to wager that much."); + } else if(wager<0) { + event.getChannel().sendMessage("Choose a positive number."); + } + else { + river = false; + balance -= wager; + totalBet += wager; + event.getChannel().sendMessage("Your balance is " + balance); + } if (cards[middleCard1].contains("ace")) { playerAndMiddleCards[0] = "ace"; } else if (cards[middleCard1].contains("2")) { @@ -754,6 +781,7 @@ else if (content.contains("bet") && flop && !gameOver) { } else if (cards[middleCard5].contains("king")) { playerAndMiddleCards[6] = "king"; } + if(!rewardGiven) { event.getChannel().sendMessage("Your hand is now the " +cards[playerCard1]+", "+cards[playerCard2]+", "+cards[middleCard1]+", "+cards[middleCard2]+", "+cards[middleCard3]+", "+cards[middleCard4]+", and "+cards[middleCard5]); event.getChannel().sendMessage("The bot's final hand has the "+cards[botCard1]+", "+cards[botCard2]+", "+cards[middleCard1]+", "+cards[middleCard2]+", "+cards[middleCard3]+", "+cards[middleCard4]+", and "+cards[middleCard5]); @@ -774,11 +802,12 @@ else if(!playerWon) { } } } - } + public int botAlgorithm(String[] botAndMiddleCards) { highestCallChance = 0; numberSameCards = 0; + numberPairs=0; for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "ace") { numberSameCards += 1; @@ -787,9 +816,10 @@ public int botAlgorithm(String[] botAndMiddleCards) { if (numberSameCards == 2) { if (950 > highestCallChance) { highestCallChance = 950; + numberPairs+=1; } } else if (numberSameCards == 3) { - highestCallChance = 970; + highestCallChance = 963; } else if(numberSameCards == 4) { highestCallChance=1000; @@ -804,6 +834,7 @@ else if(numberSameCards == 4) { if (numberSameCards == 2) { if (700 > highestCallChance) { highestCallChance = 700; + numberPairs+=1; } } else if (numberSameCards == 3) { highestCallChance = 951; @@ -821,6 +852,7 @@ else if(numberSameCards == 4) { if (numberSameCards == 2) { if (750 > highestCallChance) { highestCallChance = 750; + numberPairs+=1; } } else if (numberSameCards == 3) { highestCallChance = 952; @@ -838,6 +870,7 @@ else if(numberSameCards == 4) { if (numberSameCards == 2) { if (751 > highestCallChance) { highestCallChance = 751; + numberPairs+=1; } } else if (numberSameCards == 3) { highestCallChance = 953; @@ -855,6 +888,7 @@ else if(numberSameCards == 4) { if (numberSameCards == 2) { if (800 > highestCallChance) { highestCallChance = 800; + numberPairs+=1; } } else if (numberSameCards == 3) { highestCallChance = 954; @@ -872,6 +906,7 @@ else if(numberSameCards == 4) { if (numberSameCards == 2) { if (801 > highestCallChance) { highestCallChance = 801; + numberPairs+=1; } } else if (numberSameCards == 3) { highestCallChance = 955; @@ -889,6 +924,7 @@ else if(numberSameCards == 4) { if (numberSameCards == 2) { if (850 > highestCallChance) { highestCallChance = 850; + numberPairs+=1; } } else if (numberSameCards == 3) { highestCallChance = 956; @@ -906,6 +942,7 @@ else if(numberSameCards == 4) { if (numberSameCards == 2) { if (851 > highestCallChance) { highestCallChance = 851; + numberPairs+=1; } } else if (numberSameCards == 3) { highestCallChance = 957; @@ -923,12 +960,13 @@ else if(numberSameCards == 4) { if (numberSameCards == 2) { if (852 > highestCallChance) { highestCallChance = 852; + numberPairs+=1; } } else if (numberSameCards == 3) { highestCallChance = 958; } else if(numberSameCards == 4) { - highestCallChance=958; + highestCallChance=978; } numberSameCards = 0; @@ -940,12 +978,13 @@ else if(numberSameCards == 4) { if (numberSameCards == 2) { if (900 > highestCallChance) { highestCallChance = 900; + numberPairs+=1; } } else if (numberSameCards == 3) { highestCallChance = 959; } else if(numberSameCards == 4) { - highestCallChance=959; + highestCallChance=979; } numberSameCards = 0; @@ -957,6 +996,7 @@ else if(numberSameCards == 4) { if (numberSameCards == 2) { if (910 > highestCallChance) { highestCallChance = 910; + numberPairs+=1; } } else if (numberSameCards == 3) { highestCallChance = 960; @@ -974,6 +1014,7 @@ else if(numberSameCards == 4) { if (numberSameCards == 2) { if (920 > highestCallChance) { highestCallChance = 920; + numberPairs+=1; } } else if (numberSameCards == 3) { highestCallChance = 961; @@ -991,6 +1032,7 @@ else if(numberSameCards == 4) { if (numberSameCards == 2) { if (930 > highestCallChance) { highestCallChance = 930; + numberPairs+=1; } } else if (numberSameCards == 3) { highestCallChance = 962; @@ -998,6 +1040,9 @@ else if(numberSameCards == 4) { else if(numberSameCards == 4) { highestCallChance=982; } + if(numberPairs==2) { + highestCallChance=964; + } return highestCallChance; } public boolean playerWins(String [] playerAndMiddleCards, String [] botAndMiddleCards) { diff --git a/src/main/resources/config.json b/src/main/resources/config.json index cf664003..6983b9ad 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,4 +1,4 @@ { - "channels": ["jake-m"], + "channels": ["channel"], "token": "token" } From 3ccce817c2afb4ba000260426b909cd7ef63ca47 Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 25 Apr 2021 11:31:17 -0700 Subject: [PATCH 13/22] added straight recognition needs scoring to be updated --- .../java/org/jointheleague/modules/Poker.java | 248 +++++++++++++++++- src/main/resources/config.json | 2 +- 2 files changed, 244 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/Poker.java b/src/main/java/org/jointheleague/modules/Poker.java index 4b8b7ca4..416c0e0b 100644 --- a/src/main/java/org/jointheleague/modules/Poker.java +++ b/src/main/java/org/jointheleague/modules/Poker.java @@ -45,8 +45,23 @@ public Poker(String channelName) { boolean gameOver = true; boolean playerWon; boolean rewardGiven; + boolean tie=false; + boolean straight; int highestCallChance = 0; int botCallChance = 0; + boolean ace; + boolean two; + boolean three; + boolean four; + boolean five; + boolean six; + boolean seven; + boolean eight; + boolean nine; + boolean ten; + boolean jack; + boolean queen; + boolean king; @Override public void handle(MessageCreateEvent event) throws APIException { @@ -150,6 +165,7 @@ public void handle(MessageCreateEvent event) throws APIException { event.getChannel().sendMessage("You don't have enough money to wager that much."); } else if (wager<0) { event.getChannel().sendMessage("Choose a positive number"); + gameOver=true; } else { balance -= wager; @@ -591,7 +607,7 @@ else if (content.contains("bet") && flop && !gameOver) { balance -= wager; totalBet += wager; event.getChannel().sendMessage("Your balance is " + balance); - } + if (cards[middleCard1].contains("ace")) { playerAndMiddleCards[0] = "ace"; } else if (cards[middleCard1].contains("2")) { @@ -789,12 +805,19 @@ else if (content.contains("bet") && flop && !gameOver) { if(playerWon) { balance += totalBet * 2; event.getChannel().sendMessage( - "You have the better hand. You won " + ((totalBet * 2)-wager) + ". Your balance is now " + balance); + "You have the better hand. You won " + ((totalBet * 2)) + ". Your balance is now " + balance); gameOver = true; } else if(!playerWon) { + if(tie) { + balance+=totalBet; + event.getChannel().sendMessage("It is a tie. You get back "+totalBet+". Your balance is now "+balance); + } + else { event.getChannel().sendMessage("The bot has the better hand. You win nothing. Your balance is now "+balance); } + } + } else { System.out.println("error"); } @@ -808,14 +831,188 @@ public int botAlgorithm(String[] botAndMiddleCards) { highestCallChance = 0; numberSameCards = 0; numberPairs=0; + straight=false; + ace=false; + two=false; + three=false; + four=false; + five=false; + six=false; + seven=false; + eight=false; + nine=false; + ten=false; + jack=false; + queen=false; + king=false; + for (int j = 0; j < botAndMiddleCards.length; j++) { + if(botAndMiddleCards[j]=="ace") { + ace=true; + } + else if(botAndMiddleCards[j]=="2") { + two=true; + } + else if(botAndMiddleCards[j]=="3") { + three=true; + } + else if(botAndMiddleCards[j]=="4") { + four=true; + } + else if(botAndMiddleCards[j]=="5") { + five=true; + } + else if(botAndMiddleCards[j]=="6") { + six=true; + } + else if(botAndMiddleCards[j]=="7") { + seven=true; + } + else if(botAndMiddleCards[j]=="8") { + eight=true; + } + else if(botAndMiddleCards[j]=="9") { + nine=true; + } + else if(botAndMiddleCards[j]=="10") { + ten=true; + } + else if(botAndMiddleCards[j]=="jack") { + jack=true; + } + else if(botAndMiddleCards[j]=="queen") { + queen=true; + } + else if(botAndMiddleCards[j]=="king") { + king=true; + } + if(ace) { + if(two) { + if(three) { + if(four) { + if(five) { + straight=true; + } + } + } + } + } + else if(two) { + if(three) { + if(four) { + if(five) { + if(six) { + straight=true; + } + } + } + } + } + else if(three) { + if(four) { + if(five) { + if(six) { + if(seven) { + straight=true; + } + } + } + } + } + else if(four) { + if(five) { + if(six) { + if(seven) { + if(eight) { + straight=true; + } + } + } + } + } + else if(five) { + if(six) { + if(seven) { + if(eight) { + if(nine) { + straight=true; + } + } + } + } + } + else if(six) { + if(seven) { + if(eight) { + if(nine) { + if(ten) { + straight=true; + } + } + } + } + } + else if(seven) { + if(eight) { + if(nine) { + if(ten) { + if(jack) { + straight=true; + } + } + } + } + } + else if(eight) { + if(nine) { + if(ten) { + if(jack) { + if(queen) { + straight=true; + } + } + } + } + } + else if(nine) { + if(ten) { + if(jack) { + if(queen) { + if(king) { + straight=true; + } + } + } + } + } + else if(ten) { + if(jack) { + if(queen) { + if(king) { + if(ace) { + straight=true; + } + } + } + } + } + } + + + + + + for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "ace") { numberSameCards += 1; + if(513>highestCallChance) { + highestCallChance=513; + } } } if (numberSameCards == 2) { - if (950 > highestCallChance) { - highestCallChance = 950; + if (949 > highestCallChance) { + highestCallChance = 949; numberPairs+=1; } } else if (numberSameCards == 3) { @@ -829,6 +1026,9 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "2") { numberSameCards += 1; + if(501>highestCallChance) { + highestCallChance=501; + } } } if (numberSameCards == 2) { @@ -847,6 +1047,9 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "3") { numberSameCards += 1; + if(502>highestCallChance) { + highestCallChance=502; + } } } if (numberSameCards == 2) { @@ -865,6 +1068,9 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "4") { numberSameCards += 1; + if(503>highestCallChance) { + highestCallChance=503; + } } } if (numberSameCards == 2) { @@ -883,6 +1089,9 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "5") { numberSameCards += 1; + if(504>highestCallChance) { + highestCallChance=504; + } } } if (numberSameCards == 2) { @@ -901,6 +1110,9 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "6") { numberSameCards += 1; + if(505>highestCallChance) { + highestCallChance=505; + } } } if (numberSameCards == 2) { @@ -919,6 +1131,9 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "7") { numberSameCards += 1; + if(506>highestCallChance) { + highestCallChance=506; + } } } if (numberSameCards == 2) { @@ -937,6 +1152,9 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "8") { numberSameCards += 1; + if(507>highestCallChance) { + highestCallChance=507; + } } } if (numberSameCards == 2) { @@ -955,6 +1173,9 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "9") { numberSameCards += 1; + if(508>highestCallChance) { + highestCallChance=508; + } } } if (numberSameCards == 2) { @@ -973,6 +1194,9 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "10") { numberSameCards += 1; + if(509>highestCallChance) { + highestCallChance=509; + } } } if (numberSameCards == 2) { @@ -991,6 +1215,9 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "jack") { numberSameCards += 1; + if(510>highestCallChance) { + highestCallChance=510; + } } } if (numberSameCards == 2) { @@ -1009,6 +1236,9 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "queen") { numberSameCards += 1; + if(511>highestCallChance) { + highestCallChance=511; + } } } if (numberSameCards == 2) { @@ -1027,6 +1257,9 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "king") { numberSameCards += 1; + if(512>highestCallChance) { + highestCallChance=512; + } } } if (numberSameCards == 2) { @@ -1041,7 +1274,7 @@ else if(numberSameCards == 4) { highestCallChance=982; } if(numberPairs==2) { - highestCallChance=964; + highestCallChance=950; } return highestCallChance; } @@ -1049,9 +1282,14 @@ public boolean playerWins(String [] playerAndMiddleCards, String [] botAndMiddle playerScore=botAlgorithm(playerAndMiddleCards); botScore=botAlgorithm(botAndMiddleCards); gameOver=true; + tie=false; if(playerScore>botScore) { return true; } + else if(playerScore==botScore) { + tie=true; + return false; + } else { return false; } diff --git a/src/main/resources/config.json b/src/main/resources/config.json index 6983b9ad..cf664003 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,4 +1,4 @@ { - "channels": ["channel"], + "channels": ["jake-m"], "token": "token" } From 3e598889501377b3ca26a7501b06eb0b5b1dc398 Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 2 May 2021 11:35:41 -0700 Subject: [PATCH 14/22] untested changed scoring with flushes now needs to change 4 of a kind scoring --- .../java/org/jointheleague/modules/Poker.java | 449 +++++++++++++++--- src/main/resources/config.json | 2 +- 2 files changed, 396 insertions(+), 55 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/Poker.java b/src/main/java/org/jointheleague/modules/Poker.java index 416c0e0b..b5866b10 100644 --- a/src/main/java/org/jointheleague/modules/Poker.java +++ b/src/main/java/org/jointheleague/modules/Poker.java @@ -37,6 +37,7 @@ public Poker(String channelName) { int playerScore; int botScore; int numberPairs; + int highestPairValue; boolean userCooporates = false; boolean isUsed = false; boolean flop = true; @@ -49,6 +50,16 @@ public Poker(String channelName) { boolean straight; int highestCallChance = 0; int botCallChance = 0; + int botSpades; + int botDiamonds; + int botHearts; + int botClubs; + int playerSpades; + int playerDiamonds; + int playerHearts; + int playerClubs; + int highestSuit; + int highCard; boolean ace; boolean two; boolean three; @@ -154,6 +165,14 @@ public void handle(MessageCreateEvent event) throws APIException { playerAndMiddleCards[4]=""; playerAndMiddleCards[5]=""; playerAndMiddleCards[6]=""; + botSpades=0; + botDiamonds=0; + botHearts=0; + botClubs=0; + playerSpades=0; + playerDiamonds=0; + playerHearts=0; + playerClubs=0; content = content.replace("poker", ""); try { @@ -284,6 +303,18 @@ public void handle(MessageCreateEvent event) throws APIException { } else if (cards[middleCard1].contains("king")) { botAndMiddleCards[0] = "king"; } + if (cards[middleCard1].contains("spades")) { + botSpades+=1; + } + else if(cards[middleCard1].contains("hearts")) { + botHearts+=1; + } + else if(cards[middleCard1].contains("diamonds")) { + botDiamonds+=1; + } + else if(cards[middleCard1].contains("clubs")) { + botClubs+=1; + } if (cards[middleCard2].contains("ace")) { botAndMiddleCards[1] = "ace"; @@ -312,6 +343,19 @@ public void handle(MessageCreateEvent event) throws APIException { } else if (cards[middleCard2].contains("king")) { botAndMiddleCards[1] = "king"; } + if (cards[middleCard2].contains("spades")) { + botSpades+=1; + } + else if(cards[middleCard2].contains("hearts")) { + botHearts+=1; + } + else if(cards[middleCard2].contains("diamonds")) { + botDiamonds+=1; + } + else if(cards[middleCard2].contains("clubs")) { + botClubs+=1; + } + if (cards[middleCard3].contains("ace")) { botAndMiddleCards[2] = "ace"; } else if (cards[middleCard3].contains("2")) { @@ -339,6 +383,18 @@ public void handle(MessageCreateEvent event) throws APIException { } else if (cards[middleCard3].contains("king")) { botAndMiddleCards[2] = "king"; } + if (cards[middleCard3].contains("spades")) { + botSpades+=1; + } + else if(cards[middleCard3].contains("hearts")) { + botHearts+=1; + } + else if(cards[middleCard3].contains("diamonds")) { + botDiamonds+=1; + } + else if(cards[middleCard3].contains("clubs")) { + botClubs+=1; + } if (cards[botCard1].contains("ace")) { botAndMiddleCards[3] = "ace"; @@ -367,6 +423,18 @@ public void handle(MessageCreateEvent event) throws APIException { } else if (cards[botCard1].contains("king")) { botAndMiddleCards[3] = "king"; } + if (cards[botCard1].contains("spades")) { + botSpades+=1; + } + else if(cards[botCard1].contains("hearts")) { + botHearts+=1; + } + else if(cards[botCard1].contains("diamonds")) { + botDiamonds+=1; + } + else if(cards[botCard1].contains("clubs")) { + botClubs+=1; + } if (cards[botCard2].contains("ace")) { botAndMiddleCards[4] = "ace"; @@ -395,6 +463,18 @@ public void handle(MessageCreateEvent event) throws APIException { } else if (cards[botCard2].contains("king")) { botAndMiddleCards[4] = "king"; } + if (cards[botCard2].contains("spades")) { + botSpades+=1; + } + else if(cards[botCard2].contains("hearts")) { + botHearts+=1; + } + else if(cards[botCard2].contains("diamonds")) { + botDiamonds+=1; + } + else if(cards[botCard2].contains("clubs")) { + botClubs+=1; + } System.out.println("The bot has " + botAndMiddleCards[0]+", "+botAndMiddleCards[1]+", " +botAndMiddleCards[2]+", "+botAndMiddleCards[3]+", and "+botAndMiddleCards[4]); event.getChannel().sendMessage("Your hand is now the " +cards[playerCard1]+", "+cards[playerCard2]+", "+cards[middleCard1]+", "+cards[middleCard2]+", and "+cards[middleCard3]); @@ -427,8 +507,19 @@ else if (content.contains("bet") && flop && !gameOver) { balance -= wager; totalBet += wager; event.getChannel().sendMessage("Your balance is " + balance); + highestSuit=0; + highestSuit=botSpades; + if(botDiamonds>highestSuit) { + highestSuit=botDiamonds; + } + if(botHearts>highestSuit) { + highestSuit=botHearts; + } + if(botSpades>highestSuit) { + highestSuit=botSpades; + } - highestCallChance = botAlgorithm(botAndMiddleCards); + highestCallChance = botAlgorithm(botAndMiddleCards, highestSuit); if (500 > highestCallChance) { @@ -487,6 +578,18 @@ else if (content.contains("bet") && flop && !gameOver) { } else if (cards[middleCard4].contains("king")) { botAndMiddleCards[5] = "king"; } + if (cards[middleCard4].contains("spades")) { + botSpades+=1; + } + else if(cards[middleCard4].contains("hearts")) { + botHearts+=1; + } + else if(cards[middleCard4].contains("diamonds")) { + botDiamonds+=1; + } + else if(cards[middleCard4].contains("clubs")) { + botClubs+=1; + } System.out.println("The bot has "+botAndMiddleCards[0]+", "+botAndMiddleCards[1] +", "+botAndMiddleCards[2]+", "+botAndMiddleCards[3]+", "+botAndMiddleCards[4] +" and "+botAndMiddleCards[5]); @@ -517,8 +620,19 @@ else if (content.contains("bet") && flop && !gameOver) { balance -= wager; totalBet += wager; event.getChannel().sendMessage("Your balance is " + balance); - - highestCallChance = botAlgorithm(botAndMiddleCards); + highestSuit=0; + highestSuit=botSpades; + if(botDiamonds>highestSuit) { + highestSuit=botDiamonds; + } + if(botHearts>highestSuit) { + highestSuit=botHearts; + } + if(botSpades>highestSuit) { + highestSuit=botSpades; + } + + highestCallChance = botAlgorithm(botAndMiddleCards, highestSuit); // add more ways of having good hand here, in method @@ -576,6 +690,19 @@ else if (content.contains("bet") && flop && !gameOver) { } else if (cards[middleCard5].contains("king")) { botAndMiddleCards[6] = "king"; } + if (cards[middleCard5].contains("spades")) { + botSpades+=1; + } + else if(cards[middleCard5].contains("hearts")) { + botHearts+=1; + } + else if(cards[middleCard5].contains("diamonds")) { + botDiamonds+=1; + } + else if(cards[middleCard5].contains("clubs")) { + botClubs+=1; + } + System.out.println("The bot has "+botAndMiddleCards[0]+", "+botAndMiddleCards[1] +", "+botAndMiddleCards[2]+", "+botAndMiddleCards[3]+", "+botAndMiddleCards[4] +", "+botAndMiddleCards[5]+" and "+botAndMiddleCards[6]); @@ -635,6 +762,19 @@ else if (content.contains("bet") && flop && !gameOver) { } else if (cards[middleCard1].contains("king")) { playerAndMiddleCards[0] = "king"; } + if (cards[middleCard1].contains("spades")) { + playerSpades+=1; + } + else if(cards[middleCard1].contains("hearts")) { + playerHearts+=1; + } + else if(cards[middleCard1].contains("diamonds")) { + playerDiamonds+=1; + } + else if(cards[middleCard1].contains("clubs")) { + playerClubs+=1; + } + if (cards[middleCard2].contains("ace")) { playerAndMiddleCards[1] = "ace"; } else if (cards[middleCard2].contains("2")) { @@ -662,6 +802,18 @@ else if (content.contains("bet") && flop && !gameOver) { } else if (cards[middleCard2].contains("king")) { playerAndMiddleCards[1] = "king"; } + if (cards[middleCard2].contains("spades")) { + playerSpades+=1; + } + else if(cards[middleCard2].contains("hearts")) { + playerHearts+=1; + } + else if(cards[middleCard2].contains("diamonds")) { + playerDiamonds+=1; + } + else if(cards[middleCard2].contains("clubs")) { + playerClubs+=1; + } if (cards[middleCard3].contains("ace")) { playerAndMiddleCards[2] = "ace"; } else if (cards[middleCard3].contains("2")) { @@ -689,6 +841,18 @@ else if (content.contains("bet") && flop && !gameOver) { } else if (cards[middleCard3].contains("king")) { playerAndMiddleCards[2] = "king"; } + if (cards[middleCard3].contains("spades")) { + playerSpades+=1; + } + else if(cards[middleCard3].contains("hearts")) { + playerHearts+=1; + } + else if(cards[middleCard3].contains("diamonds")) { + playerDiamonds+=1; + } + else if(cards[middleCard3].contains("clubs")) { + playerClubs+=1; + } if (cards[playerCard1].contains("ace")) { playerAndMiddleCards[3] = "ace"; } else if (cards[playerCard1].contains("2")) { @@ -716,6 +880,18 @@ else if (content.contains("bet") && flop && !gameOver) { } else if (cards[playerCard1].contains("king")) { playerAndMiddleCards[3] = "king"; } + if (cards[playerCard1].contains("spades")) { + playerSpades+=1; + } + else if(cards[playerCard1].contains("hearts")) { + playerHearts+=1; + } + else if(cards[playerCard1].contains("diamonds")) { + playerDiamonds+=1; + } + else if(cards[playerCard1].contains("clubs")) { + playerClubs+=1; + } if (cards[playerCard2].contains("ace")) { playerAndMiddleCards[4] = "ace"; } else if (cards[playerCard2].contains("2")) { @@ -743,6 +919,18 @@ else if (content.contains("bet") && flop && !gameOver) { } else if (cards[playerCard2].contains("king")) { playerAndMiddleCards[4] = "king"; } + if (cards[playerCard2].contains("spades")) { + playerSpades+=1; + } + else if(cards[playerCard2].contains("hearts")) { + playerHearts+=1; + } + else if(cards[playerCard2].contains("diamonds")) { + playerDiamonds+=1; + } + else if(cards[playerCard2].contains("clubs")) { + playerClubs+=1; + } if (cards[middleCard4].contains("ace")) { playerAndMiddleCards[5] = "ace"; } else if (cards[middleCard4].contains("2")) { @@ -770,6 +958,18 @@ else if (content.contains("bet") && flop && !gameOver) { } else if (cards[middleCard4].contains("king")) { playerAndMiddleCards[5] = "king"; } + if (cards[middleCard4].contains("spades")) { + playerSpades+=1; + } + else if(cards[middleCard4].contains("hearts")) { + playerHearts+=1; + } + else if(cards[middleCard4].contains("diamonds")) { + playerDiamonds+=1; + } + else if(cards[middleCard4].contains("clubs")) { + playerClubs+=1; + } if (cards[middleCard5].contains("ace")) { playerAndMiddleCards[6] = "ace"; } else if (cards[middleCard5].contains("2")) { @@ -797,6 +997,18 @@ else if (content.contains("bet") && flop && !gameOver) { } else if (cards[middleCard5].contains("king")) { playerAndMiddleCards[6] = "king"; } + if (cards[middleCard5].contains("spades")) { + playerSpades+=1; + } + else if(cards[middleCard5].contains("hearts")) { + playerHearts+=1; + } + else if(cards[middleCard5].contains("diamonds")) { + playerDiamonds+=1; + } + else if(cards[middleCard5].contains("clubs")) { + playerClubs+=1; + } if(!rewardGiven) { event.getChannel().sendMessage("Your hand is now the " +cards[playerCard1]+", "+cards[playerCard2]+", "+cards[middleCard1]+", "+cards[middleCard2]+", "+cards[middleCard3]+", "+cards[middleCard4]+", and "+cards[middleCard5]); @@ -827,10 +1039,12 @@ else if(!playerWon) { } - public int botAlgorithm(String[] botAndMiddleCards) { + public int botAlgorithm(String[] botAndMiddleCards, int suits) { highestCallChance = 0; numberSameCards = 0; numberPairs=0; + highestPairValue=0; + highCard=0; straight=false; ace=false; two=false; @@ -845,6 +1059,7 @@ public int botAlgorithm(String[] botAndMiddleCards) { jack=false; queen=false; king=false; + for (int j = 0; j < botAndMiddleCards.length; j++) { if(botAndMiddleCards[j]=="ace") { ace=true; @@ -890,7 +1105,9 @@ else if(botAndMiddleCards[j]=="king") { if(three) { if(four) { if(five) { - straight=true; + if(740>highestCallChance) { + highestCallChance=740; + } } } } @@ -901,7 +1118,9 @@ else if(two) { if(four) { if(five) { if(six) { - straight=true; + if(741>highestCallChance) { + highestCallChance=741; + } } } } @@ -912,7 +1131,9 @@ else if(three) { if(five) { if(six) { if(seven) { - straight=true; + if(742>highestCallChance) { + highestCallChance=742; + } } } } @@ -923,7 +1144,9 @@ else if(four) { if(six) { if(seven) { if(eight) { - straight=true; + if(743>highestCallChance) { + highestCallChance=743; + } } } } @@ -934,7 +1157,9 @@ else if(five) { if(seven) { if(eight) { if(nine) { - straight=true; + if(744>highestCallChance) { + highestCallChance=744; + } } } } @@ -945,7 +1170,9 @@ else if(six) { if(eight) { if(nine) { if(ten) { - straight=true; + if(745>highestCallChance) { + highestCallChance=745; + } } } } @@ -956,7 +1183,9 @@ else if(seven) { if(nine) { if(ten) { if(jack) { - straight=true; + if(746>highestCallChance) { + highestCallChance=746; + } } } } @@ -967,7 +1196,9 @@ else if(eight) { if(ten) { if(jack) { if(queen) { - straight=true; + if(747>highestCallChance) { + highestCallChance=747; + } } } } @@ -978,7 +1209,9 @@ else if(nine) { if(jack) { if(queen) { if(king) { - straight=true; + if(748>highestCallChance) { + highestCallChance=748; + } } } } @@ -989,7 +1222,9 @@ else if(ten) { if(queen) { if(king) { if(ace) { - straight=true; + if(749>highestCallChance) { + highestCallChance=749; + } } } } @@ -1005,18 +1240,24 @@ else if(ten) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "ace") { numberSameCards += 1; + if(13>highCard) { + highCard=13; + } if(513>highestCallChance) { highestCallChance=513; } } } if (numberSameCards == 2) { - if (949 > highestCallChance) { - highestCallChance = 949; + if (712 > highestCallChance) { + highestCallChance = 712; numberPairs+=1; + if(13>highestPairValue) { + highestPairValue=13; + } } } else if (numberSameCards == 3) { - highestCallChance = 963; + highestCallChance = 739; } else if(numberSameCards == 4) { highestCallChance=1000; @@ -1026,6 +1267,9 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "2") { numberSameCards += 1; + if(1>highCard) { + highCard=1; + } if(501>highestCallChance) { highestCallChance=501; } @@ -1035,9 +1279,12 @@ else if(numberSameCards == 4) { if (700 > highestCallChance) { highestCallChance = 700; numberPairs+=1; + if(1>highestPairValue) { + highestPairValue=1; + } } } else if (numberSameCards == 3) { - highestCallChance = 951; + highestCallChance = 727; } else if(numberSameCards == 4) { highestCallChance=971; @@ -1047,18 +1294,24 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "3") { numberSameCards += 1; + if(2>highCard) { + highCard=2; + } if(502>highestCallChance) { highestCallChance=502; } } } if (numberSameCards == 2) { - if (750 > highestCallChance) { - highestCallChance = 750; + if (701 > highestCallChance) { + highestCallChance = 701; numberPairs+=1; + if(2>highestPairValue) { + highestPairValue=2; + } } } else if (numberSameCards == 3) { - highestCallChance = 952; + highestCallChance = 728; } else if(numberSameCards == 4) { highestCallChance=972; @@ -1068,18 +1321,24 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "4") { numberSameCards += 1; + if(3>highCard) { + highCard=3; + } if(503>highestCallChance) { highestCallChance=503; } } } if (numberSameCards == 2) { - if (751 > highestCallChance) { - highestCallChance = 751; + if (702 > highestCallChance) { + highestCallChance = 702; numberPairs+=1; + if(3>highestPairValue) { + highestPairValue=3; + } } } else if (numberSameCards == 3) { - highestCallChance = 953; + highestCallChance = 729; } else if(numberSameCards == 4) { highestCallChance=973; @@ -1089,18 +1348,24 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "5") { numberSameCards += 1; + if(4>highCard) { + highCard=4; + } if(504>highestCallChance) { highestCallChance=504; } } } if (numberSameCards == 2) { - if (800 > highestCallChance) { - highestCallChance = 800; + if (703 > highestCallChance) { + highestCallChance = 703; numberPairs+=1; + if(4>highestPairValue) { + highestPairValue=4; + } } } else if (numberSameCards == 3) { - highestCallChance = 954; + highestCallChance = 730; } else if(numberSameCards == 4) { highestCallChance=974; @@ -1110,18 +1375,24 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "6") { numberSameCards += 1; + if(5>highCard) { + highCard=5; + } if(505>highestCallChance) { highestCallChance=505; } } } if (numberSameCards == 2) { - if (801 > highestCallChance) { - highestCallChance = 801; + if (704 > highestCallChance) { + highestCallChance = 704; numberPairs+=1; + if(5>highestPairValue) { + highestPairValue=5; + } } } else if (numberSameCards == 3) { - highestCallChance = 955; + highestCallChance = 731; } else if(numberSameCards == 4) { highestCallChance=975; @@ -1131,18 +1402,24 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "7") { numberSameCards += 1; + if(6>highCard) { + highCard=6; + } if(506>highestCallChance) { highestCallChance=506; } } } if (numberSameCards == 2) { - if (850 > highestCallChance) { - highestCallChance = 850; + if (705 > highestCallChance) { + highestCallChance = 705; numberPairs+=1; + if(6>highestPairValue) { + highestPairValue=6; + } } } else if (numberSameCards == 3) { - highestCallChance = 956; + highestCallChance = 732; } else if(numberSameCards == 4) { highestCallChance=976; @@ -1152,18 +1429,24 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "8") { numberSameCards += 1; + if(7>highCard) { + highCard=7; + } if(507>highestCallChance) { highestCallChance=507; } } } if (numberSameCards == 2) { - if (851 > highestCallChance) { - highestCallChance = 851; + if (706 > highestCallChance) { + highestCallChance = 706; numberPairs+=1; + if(7>highestPairValue) { + highestPairValue=7; + } } } else if (numberSameCards == 3) { - highestCallChance = 957; + highestCallChance = 733; } else if(numberSameCards == 4) { highestCallChance=977; @@ -1173,18 +1456,24 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "9") { numberSameCards += 1; + if(8>highCard) { + highCard=8; + } if(508>highestCallChance) { highestCallChance=508; } } } if (numberSameCards == 2) { - if (852 > highestCallChance) { - highestCallChance = 852; + if (707 > highestCallChance) { + highestCallChance = 707; numberPairs+=1; + if(8>highestPairValue) { + highestPairValue=8; + } } } else if (numberSameCards == 3) { - highestCallChance = 958; + highestCallChance = 734; } else if(numberSameCards == 4) { highestCallChance=978; @@ -1194,18 +1483,24 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "10") { numberSameCards += 1; + if(9>highCard) { + highCard=9; + } if(509>highestCallChance) { highestCallChance=509; } } } if (numberSameCards == 2) { - if (900 > highestCallChance) { - highestCallChance = 900; + if (708 > highestCallChance) { + highestCallChance = 708; numberPairs+=1; + if(9>highestPairValue) { + highestPairValue=9; + } } } else if (numberSameCards == 3) { - highestCallChance = 959; + highestCallChance = 735; } else if(numberSameCards == 4) { highestCallChance=979; @@ -1215,18 +1510,24 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "jack") { numberSameCards += 1; + if(10>highCard) { + highCard=10; + } if(510>highestCallChance) { highestCallChance=510; } } } if (numberSameCards == 2) { - if (910 > highestCallChance) { - highestCallChance = 910; + if (709 > highestCallChance) { + highestCallChance = 709; numberPairs+=1; + if(10>highestPairValue) { + highestPairValue=10; + } } } else if (numberSameCards == 3) { - highestCallChance = 960; + highestCallChance = 736; } else if(numberSameCards == 4) { highestCallChance=980; @@ -1236,18 +1537,24 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "queen") { numberSameCards += 1; + if(11>highCard) { + highCard=11; + } if(511>highestCallChance) { highestCallChance=511; } } } if (numberSameCards == 2) { - if (920 > highestCallChance) { - highestCallChance = 920; + if (710 > highestCallChance) { + highestCallChance = 710; numberPairs+=1; + if(11>highestPairValue) { + highestPairValue=11; + } } } else if (numberSameCards == 3) { - highestCallChance = 961; + highestCallChance = 737; } else if(numberSameCards == 4) { highestCallChance=981; @@ -1257,30 +1564,64 @@ else if(numberSameCards == 4) { for (int j = 0; j < botAndMiddleCards.length; j++) { if (botAndMiddleCards[j] == "king") { numberSameCards += 1; + if(12>highCard) { + highCard=12; + } if(512>highestCallChance) { highestCallChance=512; } } } if (numberSameCards == 2) { - if (930 > highestCallChance) { - highestCallChance = 930; + if (711 > highestCallChance) { + highestCallChance = 711; numberPairs+=1; + if(12>highestPairValue) { + highestPairValue=12; + } } } else if (numberSameCards == 3) { - highestCallChance = 962; + highestCallChance = 738; } else if(numberSameCards == 4) { highestCallChance=982; } if(numberPairs==2) { - highestCallChance=950; + highestCallChance=713+highestPairValue; + } + if(suits>=5) { + if((750+highCard)>highestCallChance) { + highestCallChance=750+highCard; + } } + return highestCallChance; } public boolean playerWins(String [] playerAndMiddleCards, String [] botAndMiddleCards) { - playerScore=botAlgorithm(playerAndMiddleCards); - botScore=botAlgorithm(botAndMiddleCards); + highestSuit=0; + highestSuit=playerSpades; + if(playerDiamonds>highestSuit) { + highestSuit=playerDiamonds; + } + if(playerHearts>highestSuit) { + highestSuit=playerHearts; + } + if(playerSpades>highestSuit) { + highestSuit=playerSpades; + } + playerScore=botAlgorithm(playerAndMiddleCards, highestSuit); + highestSuit=0; + highestSuit=botSpades; + if(botDiamonds>highestSuit) { + highestSuit=botDiamonds; + } + if(botHearts>highestSuit) { + highestSuit=botHearts; + } + if(botSpades>highestSuit) { + highestSuit=botSpades; + } + botScore=botAlgorithm(botAndMiddleCards, highestSuit); gameOver=true; tie=false; if(playerScore>botScore) { diff --git a/src/main/resources/config.json b/src/main/resources/config.json index cf664003..6138390f 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,4 +1,4 @@ { "channels": ["jake-m"], - "token": "token" + "token": "ODA4MDQwODE4NzgyNjM0MDA0.YCAwpw.QwEw2NHu_Nq1tkwcyZYtnCxL4GU" } From bacfcdf8167c919fc0cc75278694a1e87ac071fd Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 2 May 2021 11:36:30 -0700 Subject: [PATCH 15/22] token --- src/main/resources/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config.json b/src/main/resources/config.json index 6138390f..cf664003 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,4 +1,4 @@ { "channels": ["jake-m"], - "token": "ODA4MDQwODE4NzgyNjM0MDA0.YCAwpw.QwEw2NHu_Nq1tkwcyZYtnCxL4GU" + "token": "token" } From 00223fca2852aef5a3ada0a75db81623247b6408 Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 9 May 2021 11:39:12 -0700 Subject: [PATCH 16/22] full house done only needs straight flush and tie breaking high cards --- .../java/org/jointheleague/modules/Poker.java | 154 ++++++++++++++++-- 1 file changed, 139 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/Poker.java b/src/main/java/org/jointheleague/modules/Poker.java index b5866b10..1defaac6 100644 --- a/src/main/java/org/jointheleague/modules/Poker.java +++ b/src/main/java/org/jointheleague/modules/Poker.java @@ -38,6 +38,15 @@ public Poker(String channelName) { int botScore; int numberPairs; int highestPairValue; + int lowestPairValue; + int highestTripleValue; + int playerPairValue; + int botPairValue; + int playerLowPair; + int botLowPair; + int playerHighCard; + int botHighCard; + boolean triple; boolean userCooporates = false; boolean isUsed = false; boolean flop = true; @@ -142,6 +151,7 @@ public void handle(MessageCreateEvent event) throws APIException { highestCallChance=0; botCallChance=0; numberPairs=0; + triple=false; usedCards[0]=-1; usedCards[1]=-1; usedCards[2]=-1; @@ -527,7 +537,7 @@ else if (content.contains("bet") && flop && !gameOver) { } botCallChance = highestCallChance; Random callRandom = new Random(); - int i = callRandom.nextInt(1000); + int i = callRandom.nextInt(800); if (botCallChance >= i) { // bot calls System.out.println( @@ -641,7 +651,7 @@ else if(cards[middleCard4].contains("clubs")) { } botCallChance = highestCallChance; Random callRandom = new Random(); - int i = callRandom.nextInt(1000); + int i = callRandom.nextInt(800); if (botCallChance >= i) { // bot calls System.out.println("Bot calls. Bot chance of calling was " + botCallChance + ". The random was " + i); @@ -734,6 +744,7 @@ else if(cards[middleCard5].contains("clubs")) { balance -= wager; totalBet += wager; event.getChannel().sendMessage("Your balance is " + balance); + event.getChannel().sendMessage("Bot calls."); if (cards[middleCard1].contains("ace")) { playerAndMiddleCards[0] = "ace"; @@ -1044,7 +1055,15 @@ public int botAlgorithm(String[] botAndMiddleCards, int suits) { numberSameCards = 0; numberPairs=0; highestPairValue=0; + lowestPairValue=0; + highestTripleValue=0; + playerPairValue=0; + botPairValue=0; + playerLowPair=0; + botLowPair=0; highCard=0; + playerHighCard=0; + botHighCard=0; straight=false; ace=false; two=false; @@ -1255,12 +1274,17 @@ else if(ten) { if(13>highestPairValue) { highestPairValue=13; } + else { + lowestPairValue=13; + } } } else if (numberSameCards == 3) { highestCallChance = 739; + triple=true; + highestTripleValue=13; } else if(numberSameCards == 4) { - highestCallChance=1000; + highestCallChance=790; } numberSameCards = 0; @@ -1282,12 +1306,17 @@ else if(numberSameCards == 4) { if(1>highestPairValue) { highestPairValue=1; } + else { + lowestPairValue=1; + } } } else if (numberSameCards == 3) { highestCallChance = 727; + triple=true; + highestTripleValue=1; } else if(numberSameCards == 4) { - highestCallChance=971; + highestCallChance=778; } numberSameCards = 0; @@ -1309,12 +1338,17 @@ else if(numberSameCards == 4) { if(2>highestPairValue) { highestPairValue=2; } + else { + lowestPairValue=2; + } } } else if (numberSameCards == 3) { highestCallChance = 728; + triple=true; + highestTripleValue=2; } else if(numberSameCards == 4) { - highestCallChance=972; + highestCallChance=779; } numberSameCards = 0; @@ -1336,12 +1370,17 @@ else if(numberSameCards == 4) { if(3>highestPairValue) { highestPairValue=3; } + else { + lowestPairValue=3; + } } } else if (numberSameCards == 3) { highestCallChance = 729; + triple=true; + highestTripleValue=3; } else if(numberSameCards == 4) { - highestCallChance=973; + highestCallChance=780; } numberSameCards = 0; @@ -1363,12 +1402,17 @@ else if(numberSameCards == 4) { if(4>highestPairValue) { highestPairValue=4; } + else { + lowestPairValue=4; + } } } else if (numberSameCards == 3) { highestCallChance = 730; + triple=true; + highestTripleValue=4; } else if(numberSameCards == 4) { - highestCallChance=974; + highestCallChance=781; } numberSameCards = 0; @@ -1390,12 +1434,17 @@ else if(numberSameCards == 4) { if(5>highestPairValue) { highestPairValue=5; } + else { + lowestPairValue=5; + } } } else if (numberSameCards == 3) { highestCallChance = 731; + triple=true; + highestTripleValue=5; } else if(numberSameCards == 4) { - highestCallChance=975; + highestCallChance=782; } numberSameCards = 0; @@ -1416,13 +1465,17 @@ else if(numberSameCards == 4) { numberPairs+=1; if(6>highestPairValue) { highestPairValue=6; + }else { + lowestPairValue=6; } } } else if (numberSameCards == 3) { highestCallChance = 732; + triple=true; + highestTripleValue=6; } else if(numberSameCards == 4) { - highestCallChance=976; + highestCallChance=783; } numberSameCards = 0; @@ -1444,12 +1497,17 @@ else if(numberSameCards == 4) { if(7>highestPairValue) { highestPairValue=7; } + else { + lowestPairValue=7; + } } } else if (numberSameCards == 3) { highestCallChance = 733; + triple=true; + highestTripleValue=7; } else if(numberSameCards == 4) { - highestCallChance=977; + highestCallChance=784; } numberSameCards = 0; @@ -1471,12 +1529,17 @@ else if(numberSameCards == 4) { if(8>highestPairValue) { highestPairValue=8; } + else { + lowestPairValue=8; + } } } else if (numberSameCards == 3) { highestCallChance = 734; + triple=true; + highestTripleValue=8; } else if(numberSameCards == 4) { - highestCallChance=978; + highestCallChance=785; } numberSameCards = 0; @@ -1498,12 +1561,17 @@ else if(numberSameCards == 4) { if(9>highestPairValue) { highestPairValue=9; } + else { + lowestPairValue=9; + } } } else if (numberSameCards == 3) { highestCallChance = 735; + triple=true; + highestTripleValue=9; } else if(numberSameCards == 4) { - highestCallChance=979; + highestCallChance=786; } numberSameCards = 0; @@ -1525,12 +1593,17 @@ else if(numberSameCards == 4) { if(10>highestPairValue) { highestPairValue=10; } + else { + lowestPairValue=10; + } } } else if (numberSameCards == 3) { highestCallChance = 736; + triple=true; + highestTripleValue=10; } else if(numberSameCards == 4) { - highestCallChance=980; + highestCallChance=787; } numberSameCards = 0; @@ -1552,12 +1625,17 @@ else if(numberSameCards == 4) { if(11>highestPairValue) { highestPairValue=11; } + else { + lowestPairValue=11; + } } } else if (numberSameCards == 3) { highestCallChance = 737; + triple=true; + highestTripleValue=11; } else if(numberSameCards == 4) { - highestCallChance=981; + highestCallChance=788; } numberSameCards = 0; @@ -1579,12 +1657,17 @@ else if(numberSameCards == 4) { if(12>highestPairValue) { highestPairValue=12; } + else { + lowestPairValue=12; + } } } else if (numberSameCards == 3) { highestCallChance = 738; + triple=true; + highestTripleValue=12; } else if(numberSameCards == 4) { - highestCallChance=982; + highestCallChance=789; } if(numberPairs==2) { highestCallChance=713+highestPairValue; @@ -1594,6 +1677,11 @@ else if(numberSameCards == 4) { highestCallChance=750+highCard; } } + if(numberPairs==1 && triple) { + if(highestCallChance<764+highestTripleValue) { + highestCallChance=764+highestTripleValue; + } + } return highestCallChance; } @@ -1610,6 +1698,9 @@ public boolean playerWins(String [] playerAndMiddleCards, String [] botAndMiddle highestSuit=playerSpades; } playerScore=botAlgorithm(playerAndMiddleCards, highestSuit); + playerPairValue=highestPairValue; + playerLowPair=lowestPairValue; + playerHighCard=highCard; highestSuit=0; highestSuit=botSpades; if(botDiamonds>highestSuit) { @@ -1622,17 +1713,50 @@ public boolean playerWins(String [] playerAndMiddleCards, String [] botAndMiddle highestSuit=botSpades; } botScore=botAlgorithm(botAndMiddleCards, highestSuit); + botPairValue=highestPairValue; + botLowPair=lowestPairValue; + botHighCard=highCard; gameOver=true; tie=false; if(playerScore>botScore) { return true; } else if(playerScore==botScore) { + if(playerPairValue>=botPairValue) { + return true; + } + else if(playerPairValue<=botPairValue) { + return false; + } + else if(playerPairValue==botPairValue) { + if(playerLowPair>=botLowPair) { + return true; + } + else if(playerLowPair<=botLowPair) { + return false; + } + else if(playerLowPair==botLowPair) { + if(playerHighCard>=botHighCard) { + return true; + } + else if(playerHighCard<=botHighCard) { + return false; + } + else if(playerHighCard==botHighCard) { + //I got lazy and didn't want to add more checks for the highest to low cards + tie=true; + return false; + } + } + } + else { tie=true; return false; + } } else { return false; } + return false; } } From 4adcab45c0d6ba9cb59fce1009e4eb75beefd6d9 Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 16 May 2021 11:37:47 -0700 Subject: [PATCH 17/22] Everything done, in testing playerHighCard variable not working --- .../java/org/jointheleague/modules/Poker.java | 63 ++++++++++++++++--- 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/Poker.java b/src/main/java/org/jointheleague/modules/Poker.java index 1defaac6..4e6eebb1 100644 --- a/src/main/java/org/jointheleague/modules/Poker.java +++ b/src/main/java/org/jointheleague/modules/Poker.java @@ -69,6 +69,7 @@ public Poker(String channelName) { int playerClubs; int highestSuit; int highCard; + int highStraightCard; boolean ace; boolean two; boolean three; @@ -537,7 +538,7 @@ else if (content.contains("bet") && flop && !gameOver) { } botCallChance = highestCallChance; Random callRandom = new Random(); - int i = callRandom.nextInt(800); + int i = callRandom.nextInt(750); if (botCallChance >= i) { // bot calls System.out.println( @@ -600,6 +601,7 @@ else if(cards[middleCard4].contains("diamonds")) { else if(cards[middleCard4].contains("clubs")) { botClubs+=1; } + System.out.println("The bot has "+botAndMiddleCards[0]+", "+botAndMiddleCards[1] +", "+botAndMiddleCards[2]+", "+botAndMiddleCards[3]+", "+botAndMiddleCards[4] +" and "+botAndMiddleCards[5]); @@ -651,7 +653,7 @@ else if(cards[middleCard4].contains("clubs")) { } botCallChance = highestCallChance; Random callRandom = new Random(); - int i = callRandom.nextInt(800); + int i = callRandom.nextInt(750); if (botCallChance >= i) { // bot calls System.out.println("Bot calls. Bot chance of calling was " + botCallChance + ". The random was " + i); @@ -1021,6 +1023,25 @@ else if(cards[middleCard5].contains("clubs")) { playerClubs+=1; } + //test certain hands + botAndMiddleCards[0]="ace"; + botAndMiddleCards[1]="2"; + botAndMiddleCards[2]="3"; + botAndMiddleCards[3]="4"; + botAndMiddleCards[4]="6"; + botAndMiddleCards[5]="7"; + botAndMiddleCards[6]="8"; + + playerAndMiddleCards[0]="ace"; + playerAndMiddleCards[1]="2"; + playerAndMiddleCards[2]="3"; + playerAndMiddleCards[3]="4"; + playerAndMiddleCards[4]="6"; + playerAndMiddleCards[5]="7"; + playerAndMiddleCards[6]="8"; + + + if(!rewardGiven) { event.getChannel().sendMessage("Your hand is now the " +cards[playerCard1]+", "+cards[playerCard2]+", "+cards[middleCard1]+", "+cards[middleCard2]+", "+cards[middleCard3]+", "+cards[middleCard4]+", and "+cards[middleCard5]); event.getChannel().sendMessage("The bot's final hand has the "+cards[botCard1]+", "+cards[botCard2]+", "+cards[middleCard1]+", "+cards[middleCard2]+", "+cards[middleCard3]+", "+cards[middleCard4]+", and "+cards[middleCard5]); @@ -1062,6 +1083,7 @@ public int botAlgorithm(String[] botAndMiddleCards, int suits) { playerLowPair=0; botLowPair=0; highCard=0; + highStraightCard=0; playerHighCard=0; botHighCard=0; straight=false; @@ -1126,6 +1148,8 @@ else if(botAndMiddleCards[j]=="king") { if(five) { if(740>highestCallChance) { highestCallChance=740; + straight=true; + highStraightCard=1; } } } @@ -1139,6 +1163,8 @@ else if(two) { if(six) { if(741>highestCallChance) { highestCallChance=741; + straight=true; + highStraightCard=2; } } } @@ -1152,6 +1178,8 @@ else if(three) { if(seven) { if(742>highestCallChance) { highestCallChance=742; + straight=true; + highStraightCard=3; } } } @@ -1165,6 +1193,8 @@ else if(four) { if(eight) { if(743>highestCallChance) { highestCallChance=743; + straight=true; + highStraightCard=4; } } } @@ -1178,6 +1208,8 @@ else if(five) { if(nine) { if(744>highestCallChance) { highestCallChance=744; + straight=true; + highStraightCard=5; } } } @@ -1191,6 +1223,8 @@ else if(six) { if(ten) { if(745>highestCallChance) { highestCallChance=745; + straight=true; + highStraightCard=6; } } } @@ -1204,6 +1238,8 @@ else if(seven) { if(jack) { if(746>highestCallChance) { highestCallChance=746; + straight=true; + highStraightCard=7; } } } @@ -1217,6 +1253,8 @@ else if(eight) { if(queen) { if(747>highestCallChance) { highestCallChance=747; + straight=true; + highStraightCard=8; } } } @@ -1230,6 +1268,8 @@ else if(nine) { if(king) { if(748>highestCallChance) { highestCallChance=748; + straight=true; + highStraightCard=9; } } } @@ -1243,6 +1283,8 @@ else if(ten) { if(ace) { if(749>highestCallChance) { highestCallChance=749; + straight=true; + highStraightCard=10; } } } @@ -1673,7 +1715,10 @@ else if(numberSameCards == 4) { highestCallChance=713+highestPairValue; } if(suits>=5) { - if((750+highCard)>highestCallChance) { + if(straight && 791+highStraightCard>highestCallChance) { + highestCallChance=791+highStraightCard; + } + else if((750+highCard)>highestCallChance) { highestCallChance=750+highCard; } } @@ -1722,24 +1767,24 @@ public boolean playerWins(String [] playerAndMiddleCards, String [] botAndMiddle return true; } else if(playerScore==botScore) { - if(playerPairValue>=botPairValue) { + if(playerPairValue>botPairValue) { return true; } - else if(playerPairValue<=botPairValue) { + else if(playerPairValue=botLowPair) { + if(playerLowPair>botLowPair) { return true; } - else if(playerLowPair<=botLowPair) { + else if(playerLowPair=botHighCard) { + if(playerHighCard>botHighCard) { return true; } - else if(playerHighCard<=botHighCard) { + else if(playerHighCard Date: Sun, 23 May 2021 11:49:03 -0700 Subject: [PATCH 18/22] Working on debugging Variables at the start of the botAlgorithm method that are being set to 0 are messing up the checks in the playerWon method. --- .../java/org/jointheleague/modules/Poker.java | 279 ++++++++++++++++-- 1 file changed, 249 insertions(+), 30 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/Poker.java b/src/main/java/org/jointheleague/modules/Poker.java index 4e6eebb1..c27c08fe 100644 --- a/src/main/java/org/jointheleague/modules/Poker.java +++ b/src/main/java/org/jointheleague/modules/Poker.java @@ -45,7 +45,15 @@ public Poker(String channelName) { int playerLowPair; int botLowPair; int playerHighCard; + int playerSecondHighCard; + int playerThirdHighCard; + int playerFourthHighCard; + int playerFifthHighCard; int botHighCard; + int botSecondHighCard; + int botThirdHighCard; + int botFourthHighCard; + int botFifthHighCard; boolean triple; boolean userCooporates = false; boolean isUsed = false; @@ -57,6 +65,7 @@ public Poker(String channelName) { boolean rewardGiven; boolean tie=false; boolean straight; + boolean number; int highestCallChance = 0; int botCallChance = 0; int botSpades; @@ -69,6 +78,10 @@ public Poker(String channelName) { int playerClubs; int highestSuit; int highCard; + int secondHighCard; + int thirdHighCard; + int fourthHighCard; + int fifthHighCard; int highStraightCard; boolean ace; boolean two; @@ -142,6 +155,15 @@ public void handle(MessageCreateEvent event) throws APIException { if (event.getMessageContent().contains(command)) { String content = event.getMessageContent().replaceAll(" ", "").replace("!gamble", ""); if (content.contains("poker")) { + number=false; + content = content.replace("poker", ""); + try { + wager = Integer.parseInt(content); + number=true; + } catch (Exception e) { + event.getChannel().sendMessage("Choose a number after the command to gamble"); + return; + } if (gameOver == true) { gameOver = false; flop=true; @@ -185,12 +207,6 @@ public void handle(MessageCreateEvent event) throws APIException { playerHearts=0; playerClubs=0; - content = content.replace("poker", ""); - try { - wager = Integer.parseInt(content); - } catch (Exception e) { - event.getChannel().sendMessage("Choose a number after the command to gamble"); - } if (balance < 0) { event.getChannel().sendMessage("You don't have enough money to wager that much."); } else if (wager<0) { @@ -506,6 +522,7 @@ else if (content.contains("bet") && flop && !gameOver) { wager = Integer.parseInt(content); } catch (Exception e) { event.getChannel().sendMessage("Choose a number after the command to gamble"); + return; } System.out.println(totalBet); if (balance < 0) { @@ -620,6 +637,7 @@ else if(cards[middleCard4].contains("clubs")) { wager = Integer.parseInt(content); } catch (Exception e) { event.getChannel().sendMessage("Choose a number after the command to gamble"); + return; } System.out.println(totalBet); if (balance < 0) { @@ -734,6 +752,7 @@ else if(cards[middleCard5].contains("clubs")) { wager = Integer.parseInt(content); } catch (Exception e) { event.getChannel().sendMessage("Choose a number after the command to gamble"); + return; } System.out.println(totalBet); if (balance < 0) { @@ -1024,21 +1043,21 @@ else if(cards[middleCard5].contains("clubs")) { } //test certain hands - botAndMiddleCards[0]="ace"; - botAndMiddleCards[1]="2"; - botAndMiddleCards[2]="3"; - botAndMiddleCards[3]="4"; - botAndMiddleCards[4]="6"; - botAndMiddleCards[5]="7"; - botAndMiddleCards[6]="8"; + botAndMiddleCards[0]="6"; + botAndMiddleCards[1]="5"; + botAndMiddleCards[2]="10"; + botAndMiddleCards[3]="8"; + botAndMiddleCards[4]="5"; + botAndMiddleCards[5]="ace"; + botAndMiddleCards[6]="7"; - playerAndMiddleCards[0]="ace"; - playerAndMiddleCards[1]="2"; - playerAndMiddleCards[2]="3"; - playerAndMiddleCards[3]="4"; - playerAndMiddleCards[4]="6"; - playerAndMiddleCards[5]="7"; - playerAndMiddleCards[6]="8"; + playerAndMiddleCards[0]="queen"; + playerAndMiddleCards[1]="5"; + playerAndMiddleCards[2]="10"; + playerAndMiddleCards[3]="8"; + playerAndMiddleCards[4]="5"; + playerAndMiddleCards[5]="ace"; + playerAndMiddleCards[6]="7"; @@ -1072,6 +1091,7 @@ else if(!playerWon) { public int botAlgorithm(String[] botAndMiddleCards, int suits) { + //move these variables that are set to 0 because they are messing up the final check who wins checks highestCallChance = 0; numberSameCards = 0; numberPairs=0; @@ -1083,9 +1103,11 @@ public int botAlgorithm(String[] botAndMiddleCards, int suits) { playerLowPair=0; botLowPair=0; highCard=0; + secondHighCard=0; + thirdHighCard=0; + fourthHighCard=0; + fifthHighCard=0; highStraightCard=0; - playerHighCard=0; - botHighCard=0; straight=false; ace=false; two=false; @@ -1304,6 +1326,18 @@ else if(ten) { if(13>highCard) { highCard=13; } + else if(13>secondHighCard) { + secondHighCard=13; + } + else if(13>thirdHighCard) { + thirdHighCard=13; + } + else if(13>fourthHighCard) { + fourthHighCard=13; + } + else if (13>fifthHighCard) { + fifthHighCard=13; + } if(513>highestCallChance) { highestCallChance=513; } @@ -1336,6 +1370,18 @@ else if(numberSameCards == 4) { if(1>highCard) { highCard=1; } + else if(1>secondHighCard) { + secondHighCard=1; + } + else if(1>thirdHighCard) { + thirdHighCard=1; + } + else if(1>fourthHighCard) { + fourthHighCard=1; + } + else if (1>fifthHighCard) { + fifthHighCard=1; + } if(501>highestCallChance) { highestCallChance=501; } @@ -1368,6 +1414,18 @@ else if(numberSameCards == 4) { if(2>highCard) { highCard=2; } + else if(2>secondHighCard) { + secondHighCard=2; + } + else if(2>thirdHighCard) { + thirdHighCard=2; + } + else if(2>fourthHighCard) { + fourthHighCard=2; + } + else if (2>fifthHighCard) { + fifthHighCard=2; + } if(502>highestCallChance) { highestCallChance=502; } @@ -1400,6 +1458,18 @@ else if(numberSameCards == 4) { if(3>highCard) { highCard=3; } + else if(3>secondHighCard) { + secondHighCard=3; + } + else if(3>thirdHighCard) { + thirdHighCard=3; + } + else if(3>fourthHighCard) { + fourthHighCard=3; + } + else if (3>fifthHighCard) { + fifthHighCard=3; + } if(503>highestCallChance) { highestCallChance=503; } @@ -1432,6 +1502,18 @@ else if(numberSameCards == 4) { if(4>highCard) { highCard=4; } + else if(4>secondHighCard) { + secondHighCard=4; + } + else if(4>thirdHighCard) { + thirdHighCard=4; + } + else if(4>fourthHighCard) { + fourthHighCard=4; + } + else if (4>fifthHighCard) { + fifthHighCard=4; + } if(504>highestCallChance) { highestCallChance=504; } @@ -1464,6 +1546,18 @@ else if(numberSameCards == 4) { if(5>highCard) { highCard=5; } + else if(5>secondHighCard) { + secondHighCard=5; + } + else if(5>thirdHighCard) { + thirdHighCard=5; + } + else if(5>fourthHighCard) { + fourthHighCard=5; + } + else if (5>fifthHighCard) { + fifthHighCard=5; + } if(505>highestCallChance) { highestCallChance=505; } @@ -1496,6 +1590,18 @@ else if(numberSameCards == 4) { if(6>highCard) { highCard=6; } + else if(6>secondHighCard) { + secondHighCard=6; + } + else if(6>thirdHighCard) { + thirdHighCard=6; + } + else if(6>fourthHighCard) { + fourthHighCard=6; + } + else if (6>fifthHighCard) { + fifthHighCard=6; + } if(506>highestCallChance) { highestCallChance=506; } @@ -1527,6 +1633,18 @@ else if(numberSameCards == 4) { if(7>highCard) { highCard=7; } + else if(7>secondHighCard) { + secondHighCard=7; + } + else if(7>thirdHighCard) { + thirdHighCard=7; + } + else if(7>fourthHighCard) { + fourthHighCard=7; + } + else if (7>fifthHighCard) { + fifthHighCard=7; + } if(507>highestCallChance) { highestCallChance=507; } @@ -1559,6 +1677,18 @@ else if(numberSameCards == 4) { if(8>highCard) { highCard=8; } + else if(8>secondHighCard) { + secondHighCard=8; + } + else if(8>thirdHighCard) { + thirdHighCard=8; + } + else if(8>fourthHighCard) { + fourthHighCard=8; + } + else if (8>fifthHighCard) { + fifthHighCard=8; + } if(508>highestCallChance) { highestCallChance=508; } @@ -1591,6 +1721,18 @@ else if(numberSameCards == 4) { if(9>highCard) { highCard=9; } + else if(9>secondHighCard) { + secondHighCard=9; + } + else if(9>thirdHighCard) { + thirdHighCard=9; + } + else if(9>fourthHighCard) { + fourthHighCard=9; + } + else if (9>fifthHighCard) { + fifthHighCard=9; + } if(509>highestCallChance) { highestCallChance=509; } @@ -1623,6 +1765,18 @@ else if(numberSameCards == 4) { if(10>highCard) { highCard=10; } + else if(10>secondHighCard) { + secondHighCard=10; + } + else if(10>thirdHighCard) { + thirdHighCard=10; + } + else if(10>fourthHighCard) { + fourthHighCard=10; + } + else if (10>fifthHighCard) { + fifthHighCard=10; + } if(510>highestCallChance) { highestCallChance=510; } @@ -1655,6 +1809,18 @@ else if(numberSameCards == 4) { if(11>highCard) { highCard=11; } + else if(11>secondHighCard) { + secondHighCard=11; + } + else if(11>thirdHighCard) { + thirdHighCard=11; + } + else if(11>fourthHighCard) { + fourthHighCard=11; + } + else if (11>fifthHighCard) { + fifthHighCard=11; + } if(511>highestCallChance) { highestCallChance=511; } @@ -1687,6 +1853,18 @@ else if(numberSameCards == 4) { if(12>highCard) { highCard=12; } + else if(12>secondHighCard) { + secondHighCard=12; + } + else if(12>thirdHighCard) { + thirdHighCard=12; + } + else if(12>fourthHighCard) { + fourthHighCard=12; + } + else if (12>fifthHighCard) { + fifthHighCard=12; + } if(512>highestCallChance) { highestCallChance=512; } @@ -1742,10 +1920,17 @@ public boolean playerWins(String [] playerAndMiddleCards, String [] botAndMiddle if(playerSpades>highestSuit) { highestSuit=playerSpades; } + if(playerClubs>highestSuit) { + highestSuit=playerClubs; + } playerScore=botAlgorithm(playerAndMiddleCards, highestSuit); playerPairValue=highestPairValue; playerLowPair=lowestPairValue; playerHighCard=highCard; + playerSecondHighCard=secondHighCard; + playerThirdHighCard=thirdHighCard; + playerFourthHighCard=fourthHighCard; + playerFifthHighCard=fifthHighCard; highestSuit=0; highestSuit=botSpades; if(botDiamonds>highestSuit) { @@ -1757,10 +1942,17 @@ public boolean playerWins(String [] playerAndMiddleCards, String [] botAndMiddle if(botSpades>highestSuit) { highestSuit=botSpades; } + if(botClubs>highestSuit) { + highestSuit=botClubs; + } botScore=botAlgorithm(botAndMiddleCards, highestSuit); botPairValue=highestPairValue; botLowPair=lowestPairValue; botHighCard=highCard; + botSecondHighCard=secondHighCard; + botThirdHighCard=thirdHighCard; + botFourthHighCard=fourthHighCard; + botFifthHighCard=fifthHighCard; gameOver=true; tie=false; if(playerScore>botScore) { @@ -1788,20 +1980,47 @@ else if(playerHighCardbotSecondHighCard) { + return true; + } + else if(playerSecondHighCardbotThirdHighCard) { + return true; + } + else if(playerThirdHighCardbotFourthHighCard) { + return true; + } + else if(playerFourthHighCardbotFifthHighCard) { + return true; + } + else if(playerFifthHighCard Date: Sun, 30 May 2021 11:35:48 -0700 Subject: [PATCH 19/22] fixed bug that messed up scoring, needs testing --- .../java/org/jointheleague/modules/Poker.java | 586 +++++++++--------- src/main/resources/config.json | 2 +- 2 files changed, 296 insertions(+), 292 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/Poker.java b/src/main/java/org/jointheleague/modules/Poker.java index c27c08fe..cc18f762 100644 --- a/src/main/java/org/jointheleague/modules/Poker.java +++ b/src/main/java/org/jointheleague/modules/Poker.java @@ -1043,21 +1043,21 @@ else if(cards[middleCard5].contains("clubs")) { } //test certain hands - botAndMiddleCards[0]="6"; - botAndMiddleCards[1]="5"; - botAndMiddleCards[2]="10"; - botAndMiddleCards[3]="8"; - botAndMiddleCards[4]="5"; - botAndMiddleCards[5]="ace"; - botAndMiddleCards[6]="7"; + botAndMiddleCards[0]="7"; + botAndMiddleCards[1]="8"; + botAndMiddleCards[2]="9"; + botAndMiddleCards[3]="jack"; + botAndMiddleCards[4]="queen"; + botAndMiddleCards[5]="king"; + botAndMiddleCards[6]="ace"; - playerAndMiddleCards[0]="queen"; - playerAndMiddleCards[1]="5"; - playerAndMiddleCards[2]="10"; - playerAndMiddleCards[3]="8"; - playerAndMiddleCards[4]="5"; - playerAndMiddleCards[5]="ace"; - playerAndMiddleCards[6]="7"; + playerAndMiddleCards[0]="7"; + playerAndMiddleCards[1]="8"; + playerAndMiddleCards[2]="9"; + playerAndMiddleCards[3]="jack"; + playerAndMiddleCards[4]="queen"; + playerAndMiddleCards[5]="king"; + playerAndMiddleCards[6]="ace"; @@ -1091,17 +1091,12 @@ else if(!playerWon) { public int botAlgorithm(String[] botAndMiddleCards, int suits) { - //move these variables that are set to 0 because they are messing up the final check who wins checks highestCallChance = 0; numberSameCards = 0; numberPairs=0; highestPairValue=0; lowestPairValue=0; highestTripleValue=0; - playerPairValue=0; - botPairValue=0; - playerLowPair=0; - botLowPair=0; highCard=0; secondHighCard=0; thirdHighCard=0; @@ -1321,7 +1316,10 @@ else if(ten) { for (int j = 0; j < botAndMiddleCards.length; j++) { - if (botAndMiddleCards[j] == "ace") { + if(secondHighCard==12) { + System.out.println(""); + } + if (botAndMiddleCards[j].equals("ace")) { numberSameCards += 1; if(13>highCard) { highCard=13; @@ -1362,533 +1360,534 @@ else if (13>fifthHighCard) { else if(numberSameCards == 4) { highestCallChance=790; } - + numberSameCards = 0; for (int j = 0; j < botAndMiddleCards.length; j++) { - if (botAndMiddleCards[j] == "2") { + if (botAndMiddleCards[j].equals("king")) { numberSameCards += 1; - if(1>highCard) { - highCard=1; + if(12>highCard) { + highCard=12; } - else if(1>secondHighCard) { - secondHighCard=1; + else if(12>secondHighCard) { + secondHighCard=12; } - else if(1>thirdHighCard) { - thirdHighCard=1; + else if(12>thirdHighCard) { + thirdHighCard=12; } - else if(1>fourthHighCard) { - fourthHighCard=1; + else if(12>fourthHighCard) { + fourthHighCard=12; } - else if (1>fifthHighCard) { - fifthHighCard=1; + else if (12>fifthHighCard) { + fifthHighCard=12; } - if(501>highestCallChance) { - highestCallChance=501; + if(512>highestCallChance) { + highestCallChance=512; } } } if (numberSameCards == 2) { - if (700 > highestCallChance) { - highestCallChance = 700; + if (711 > highestCallChance) { + highestCallChance = 711; numberPairs+=1; - if(1>highestPairValue) { - highestPairValue=1; + if(12>highestPairValue) { + highestPairValue=12; } else { - lowestPairValue=1; + lowestPairValue=12; } } } else if (numberSameCards == 3) { - highestCallChance = 727; + highestCallChance = 738; triple=true; - highestTripleValue=1; + highestTripleValue=12; } else if(numberSameCards == 4) { - highestCallChance=778; + highestCallChance=789; } - + numberSameCards = 0; for (int j = 0; j < botAndMiddleCards.length; j++) { - if (botAndMiddleCards[j] == "3") { + if (botAndMiddleCards[j].equals("queen")) { numberSameCards += 1; - if(2>highCard) { - highCard=2; + if(11>highCard) { + highCard=11; } - else if(2>secondHighCard) { - secondHighCard=2; + else if(11>secondHighCard) { + secondHighCard=11; } - else if(2>thirdHighCard) { - thirdHighCard=2; + else if(11>thirdHighCard) { + thirdHighCard=11; } - else if(2>fourthHighCard) { - fourthHighCard=2; + else if(11>fourthHighCard) { + fourthHighCard=11; } - else if (2>fifthHighCard) { - fifthHighCard=2; + else if (11>fifthHighCard) { + fifthHighCard=11; } - if(502>highestCallChance) { - highestCallChance=502; + if(511>highestCallChance) { + highestCallChance=511; } } } if (numberSameCards == 2) { - if (701 > highestCallChance) { - highestCallChance = 701; + if (710 > highestCallChance) { + highestCallChance = 710; numberPairs+=1; - if(2>highestPairValue) { - highestPairValue=2; + if(11>highestPairValue) { + highestPairValue=11; } else { - lowestPairValue=2; + lowestPairValue=11; } } } else if (numberSameCards == 3) { - highestCallChance = 728; + highestCallChance = 737; triple=true; - highestTripleValue=2; + highestTripleValue=11; } else if(numberSameCards == 4) { - highestCallChance=779; + highestCallChance=788; } numberSameCards = 0; for (int j = 0; j < botAndMiddleCards.length; j++) { - if (botAndMiddleCards[j] == "4") { + if (botAndMiddleCards[j].equals("jack")) { numberSameCards += 1; - if(3>highCard) { - highCard=3; + if(10>highCard) { + highCard=10; } - else if(3>secondHighCard) { - secondHighCard=3; + else if(10>secondHighCard) { + secondHighCard=10; } - else if(3>thirdHighCard) { - thirdHighCard=3; + else if(10>thirdHighCard) { + thirdHighCard=10; } - else if(3>fourthHighCard) { - fourthHighCard=3; + else if(10>fourthHighCard) { + fourthHighCard=10; } - else if (3>fifthHighCard) { - fifthHighCard=3; + else if (10>fifthHighCard) { + fifthHighCard=10; } - if(503>highestCallChance) { - highestCallChance=503; + if(510>highestCallChance) { + highestCallChance=510; } } } if (numberSameCards == 2) { - if (702 > highestCallChance) { - highestCallChance = 702; + if (709 > highestCallChance) { + highestCallChance = 709; numberPairs+=1; - if(3>highestPairValue) { - highestPairValue=3; + if(10>highestPairValue) { + highestPairValue=10; } else { - lowestPairValue=3; + lowestPairValue=10; } } } else if (numberSameCards == 3) { - highestCallChance = 729; + highestCallChance = 736; triple=true; - highestTripleValue=3; + highestTripleValue=10; } else if(numberSameCards == 4) { - highestCallChance=780; + highestCallChance=787; } numberSameCards = 0; for (int j = 0; j < botAndMiddleCards.length; j++) { - if (botAndMiddleCards[j] == "5") { + if (botAndMiddleCards[j].equals("10")) { numberSameCards += 1; - if(4>highCard) { - highCard=4; - } - else if(4>secondHighCard) { - secondHighCard=4; - } - else if(4>thirdHighCard) { - thirdHighCard=4; - } - else if(4>fourthHighCard) { - fourthHighCard=4; - } - else if (4>fifthHighCard) { - fifthHighCard=4; + if(9>highCard) { + highCard=9; } - if(504>highestCallChance) { - highestCallChance=504; + else if(9>secondHighCard) { + secondHighCard=9; + } + else if(9>thirdHighCard) { + thirdHighCard=9; + } + else if(9>fourthHighCard) { + fourthHighCard=9; + } + else if (9>fifthHighCard) { + fifthHighCard=9; + } + if(509>highestCallChance) { + highestCallChance=509; } } } if (numberSameCards == 2) { - if (703 > highestCallChance) { - highestCallChance = 703; + if (708 > highestCallChance) { + highestCallChance = 708; numberPairs+=1; - if(4>highestPairValue) { - highestPairValue=4; + if(9>highestPairValue) { + highestPairValue=9; } else { - lowestPairValue=4; + lowestPairValue=9; } } } else if (numberSameCards == 3) { - highestCallChance = 730; + highestCallChance = 735; triple=true; - highestTripleValue=4; + highestTripleValue=9; } else if(numberSameCards == 4) { - highestCallChance=781; + highestCallChance=786; } - + numberSameCards = 0; for (int j = 0; j < botAndMiddleCards.length; j++) { - if (botAndMiddleCards[j] == "6") { + if (botAndMiddleCards[j].equals("9")) { numberSameCards += 1; - if(5>highCard) { - highCard=5; + if(8>highCard) { + highCard=8; } - else if(5>secondHighCard) { - secondHighCard=5; + else if(8>secondHighCard) { + secondHighCard=8; } - else if(5>thirdHighCard) { - thirdHighCard=5; + else if(8>thirdHighCard) { + thirdHighCard=8; } - else if(5>fourthHighCard) { - fourthHighCard=5; + else if(8>fourthHighCard) { + fourthHighCard=8; } - else if (5>fifthHighCard) { - fifthHighCard=5; + else if (8>fifthHighCard) { + fifthHighCard=8; } - if(505>highestCallChance) { - highestCallChance=505; + if(508>highestCallChance) { + highestCallChance=508; } } } if (numberSameCards == 2) { - if (704 > highestCallChance) { - highestCallChance = 704; + if (707 > highestCallChance) { + highestCallChance = 707; numberPairs+=1; - if(5>highestPairValue) { - highestPairValue=5; + if(8>highestPairValue) { + highestPairValue=8; } else { - lowestPairValue=5; + lowestPairValue=8; } } } else if (numberSameCards == 3) { - highestCallChance = 731; + highestCallChance = 734; triple=true; - highestTripleValue=5; + highestTripleValue=8; } else if(numberSameCards == 4) { - highestCallChance=782; + highestCallChance=785; } numberSameCards = 0; for (int j = 0; j < botAndMiddleCards.length; j++) { - if (botAndMiddleCards[j] == "7") { + if (botAndMiddleCards[j].equals("8")) { numberSameCards += 1; - if(6>highCard) { - highCard=6; + if(7>highCard) { + highCard=7; } - else if(6>secondHighCard) { - secondHighCard=6; + else if(7>secondHighCard) { + secondHighCard=7; } - else if(6>thirdHighCard) { - thirdHighCard=6; + else if(7>thirdHighCard) { + thirdHighCard=7; } - else if(6>fourthHighCard) { - fourthHighCard=6; + else if(7>fourthHighCard) { + fourthHighCard=7; } - else if (6>fifthHighCard) { - fifthHighCard=6; + else if (7>fifthHighCard) { + fifthHighCard=7; } - if(506>highestCallChance) { - highestCallChance=506; + if(507>highestCallChance) { + highestCallChance=507; } } } if (numberSameCards == 2) { - if (705 > highestCallChance) { - highestCallChance = 705; + if (706 > highestCallChance) { + highestCallChance = 706; numberPairs+=1; - if(6>highestPairValue) { - highestPairValue=6; - }else { - lowestPairValue=6; + if(7>highestPairValue) { + highestPairValue=7; + } + else { + lowestPairValue=7; } } } else if (numberSameCards == 3) { - highestCallChance = 732; + highestCallChance = 733; triple=true; - highestTripleValue=6; + highestTripleValue=7; } else if(numberSameCards == 4) { - highestCallChance=783; + highestCallChance=784; } numberSameCards = 0; for (int j = 0; j < botAndMiddleCards.length; j++) { - if (botAndMiddleCards[j] == "8") { + if (botAndMiddleCards[j].equals("7")) { numberSameCards += 1; - if(7>highCard) { - highCard=7; + if(6>highCard) { + highCard=6; } - else if(7>secondHighCard) { - secondHighCard=7; + else if(6>secondHighCard) { + secondHighCard=6; } - else if(7>thirdHighCard) { - thirdHighCard=7; + else if(6>thirdHighCard) { + thirdHighCard=6; } - else if(7>fourthHighCard) { - fourthHighCard=7; + else if(6>fourthHighCard) { + fourthHighCard=6; } - else if (7>fifthHighCard) { - fifthHighCard=7; + else if (6>fifthHighCard) { + fifthHighCard=6; } - if(507>highestCallChance) { - highestCallChance=507; + if(506>highestCallChance) { + highestCallChance=506; } } } if (numberSameCards == 2) { - if (706 > highestCallChance) { - highestCallChance = 706; + if (705 > highestCallChance) { + highestCallChance = 705; numberPairs+=1; - if(7>highestPairValue) { - highestPairValue=7; - } - else { - lowestPairValue=7; + if(6>highestPairValue) { + highestPairValue=6; + }else { + lowestPairValue=6; } } } else if (numberSameCards == 3) { - highestCallChance = 733; + highestCallChance = 732; triple=true; - highestTripleValue=7; + highestTripleValue=6; } else if(numberSameCards == 4) { - highestCallChance=784; + highestCallChance=783; } - + numberSameCards = 0; for (int j = 0; j < botAndMiddleCards.length; j++) { - if (botAndMiddleCards[j] == "9") { + if (botAndMiddleCards[j].equals("6")) { numberSameCards += 1; - if(8>highCard) { - highCard=8; + if(5>highCard) { + highCard=5; } - else if(8>secondHighCard) { - secondHighCard=8; + else if(5>secondHighCard) { + secondHighCard=5; } - else if(8>thirdHighCard) { - thirdHighCard=8; + else if(5>thirdHighCard) { + thirdHighCard=5; } - else if(8>fourthHighCard) { - fourthHighCard=8; + else if(5>fourthHighCard) { + fourthHighCard=5; } - else if (8>fifthHighCard) { - fifthHighCard=8; + else if (5>fifthHighCard) { + fifthHighCard=5; } - if(508>highestCallChance) { - highestCallChance=508; + if(505>highestCallChance) { + highestCallChance=505; } } } if (numberSameCards == 2) { - if (707 > highestCallChance) { - highestCallChance = 707; + if (704 > highestCallChance) { + highestCallChance = 704; numberPairs+=1; - if(8>highestPairValue) { - highestPairValue=8; + if(5>highestPairValue) { + highestPairValue=5; } else { - lowestPairValue=8; + lowestPairValue=5; } } } else if (numberSameCards == 3) { - highestCallChance = 734; + highestCallChance = 731; triple=true; - highestTripleValue=8; + highestTripleValue=5; } else if(numberSameCards == 4) { - highestCallChance=785; + highestCallChance=782; } - + numberSameCards = 0; for (int j = 0; j < botAndMiddleCards.length; j++) { - if (botAndMiddleCards[j] == "10") { + if (botAndMiddleCards[j].equals("5")) { numberSameCards += 1; - if(9>highCard) { - highCard=9; + if(4>highCard) { + highCard=4; } - else if(9>secondHighCard) { - secondHighCard=9; - } - else if(9>thirdHighCard) { - thirdHighCard=9; - } - else if(9>fourthHighCard) { - fourthHighCard=9; - } - else if (9>fifthHighCard) { - fifthHighCard=9; - } - if(509>highestCallChance) { - highestCallChance=509; + else if(4>secondHighCard) { + secondHighCard=4; + } + else if(4>thirdHighCard) { + thirdHighCard=4; + } + else if(4>fourthHighCard) { + fourthHighCard=4; + } + else if (4>fifthHighCard) { + fifthHighCard=4; + } + if(504>highestCallChance) { + highestCallChance=504; } } } if (numberSameCards == 2) { - if (708 > highestCallChance) { - highestCallChance = 708; + if (703 > highestCallChance) { + highestCallChance = 703; numberPairs+=1; - if(9>highestPairValue) { - highestPairValue=9; + if(4>highestPairValue) { + highestPairValue=4; } else { - lowestPairValue=9; + lowestPairValue=4; } } } else if (numberSameCards == 3) { - highestCallChance = 735; + highestCallChance = 730; triple=true; - highestTripleValue=9; + highestTripleValue=4; } else if(numberSameCards == 4) { - highestCallChance=786; + highestCallChance=781; } - + numberSameCards = 0; for (int j = 0; j < botAndMiddleCards.length; j++) { - if (botAndMiddleCards[j] == "jack") { + if (botAndMiddleCards[j].equals("4")) { numberSameCards += 1; - if(10>highCard) { - highCard=10; + if(3>highCard) { + highCard=3; } - else if(10>secondHighCard) { - secondHighCard=10; + else if(3>secondHighCard) { + secondHighCard=3; } - else if(10>thirdHighCard) { - thirdHighCard=10; + else if(3>thirdHighCard) { + thirdHighCard=3; } - else if(10>fourthHighCard) { - fourthHighCard=10; + else if(3>fourthHighCard) { + fourthHighCard=3; } - else if (10>fifthHighCard) { - fifthHighCard=10; + else if (3>fifthHighCard) { + fifthHighCard=3; } - if(510>highestCallChance) { - highestCallChance=510; + if(503>highestCallChance) { + highestCallChance=503; } } } if (numberSameCards == 2) { - if (709 > highestCallChance) { - highestCallChance = 709; + if (702 > highestCallChance) { + highestCallChance = 702; numberPairs+=1; - if(10>highestPairValue) { - highestPairValue=10; + if(3>highestPairValue) { + highestPairValue=3; } else { - lowestPairValue=10; + lowestPairValue=3; } } } else if (numberSameCards == 3) { - highestCallChance = 736; + highestCallChance = 729; triple=true; - highestTripleValue=10; + highestTripleValue=3; } else if(numberSameCards == 4) { - highestCallChance=787; + highestCallChance=780; } - + numberSameCards = 0; for (int j = 0; j < botAndMiddleCards.length; j++) { - if (botAndMiddleCards[j] == "queen") { + if (botAndMiddleCards[j].equals("3")) { numberSameCards += 1; - if(11>highCard) { - highCard=11; + if(2>highCard) { + highCard=2; } - else if(11>secondHighCard) { - secondHighCard=11; + else if(2>secondHighCard) { + secondHighCard=2; } - else if(11>thirdHighCard) { - thirdHighCard=11; + else if(2>thirdHighCard) { + thirdHighCard=2; } - else if(11>fourthHighCard) { - fourthHighCard=11; + else if(2>fourthHighCard) { + fourthHighCard=2; } - else if (11>fifthHighCard) { - fifthHighCard=11; + else if (2>fifthHighCard) { + fifthHighCard=2; } - if(511>highestCallChance) { - highestCallChance=511; + if(502>highestCallChance) { + highestCallChance=502; } } } if (numberSameCards == 2) { - if (710 > highestCallChance) { - highestCallChance = 710; + if (701 > highestCallChance) { + highestCallChance = 701; numberPairs+=1; - if(11>highestPairValue) { - highestPairValue=11; + if(2>highestPairValue) { + highestPairValue=2; } else { - lowestPairValue=11; + lowestPairValue=2; } } } else if (numberSameCards == 3) { - highestCallChance = 737; + highestCallChance = 728; triple=true; - highestTripleValue=11; + highestTripleValue=2; } else if(numberSameCards == 4) { - highestCallChance=788; + highestCallChance=779; } - + numberSameCards = 0; for (int j = 0; j < botAndMiddleCards.length; j++) { - if (botAndMiddleCards[j] == "king") { + if (botAndMiddleCards[j].equals("2")) { numberSameCards += 1; - if(12>highCard) { - highCard=12; + if(1>highCard) { + highCard=1; } - else if(12>secondHighCard) { - secondHighCard=12; + else if(1>secondHighCard) { + secondHighCard=1; } - else if(12>thirdHighCard) { - thirdHighCard=12; + else if(1>thirdHighCard) { + thirdHighCard=1; } - else if(12>fourthHighCard) { - fourthHighCard=12; + else if(1>fourthHighCard) { + fourthHighCard=1; } - else if (12>fifthHighCard) { - fifthHighCard=12; + else if (1>fifthHighCard) { + fifthHighCard=1; } - if(512>highestCallChance) { - highestCallChance=512; + if(501>highestCallChance) { + highestCallChance=501; } } } if (numberSameCards == 2) { - if (711 > highestCallChance) { - highestCallChance = 711; + if (700 > highestCallChance) { + highestCallChance = 700; numberPairs+=1; - if(12>highestPairValue) { - highestPairValue=12; + if(1>highestPairValue) { + highestPairValue=1; } else { - lowestPairValue=12; + lowestPairValue=1; } } } else if (numberSameCards == 3) { - highestCallChance = 738; + highestCallChance = 727; triple=true; - highestTripleValue=12; + highestTripleValue=1; } else if(numberSameCards == 4) { - highestCallChance=789; + highestCallChance=778; } + if(numberPairs==2) { highestCallChance=713+highestPairValue; } @@ -1910,6 +1909,10 @@ else if((750+highCard)>highestCallChance) { } public boolean playerWins(String [] playerAndMiddleCards, String [] botAndMiddleCards) { highestSuit=0; + playerPairValue=0; + botPairValue=0; + playerLowPair=0; + botLowPair=0; highestSuit=playerSpades; if(playerDiamonds>highestSuit) { highestSuit=playerDiamonds; @@ -1923,6 +1926,7 @@ public boolean playerWins(String [] playerAndMiddleCards, String [] botAndMiddle if(playerClubs>highestSuit) { highestSuit=playerClubs; } + playerScore=botAlgorithm(playerAndMiddleCards, highestSuit); playerPairValue=highestPairValue; playerLowPair=lowestPairValue; diff --git a/src/main/resources/config.json b/src/main/resources/config.json index cf664003..f110f286 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,4 +1,4 @@ { "channels": ["jake-m"], - "token": "token" + "token": "ODA4MDQwODE4NzgyNjM0MDA0.YCAwpw.AvGrwIptQJB7uFGPoKx2BLgsoF4" } From 6b9bb41bda2c7eaea57668698803acc26226f04e Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 30 May 2021 11:39:28 -0700 Subject: [PATCH 20/22] token --- src/main/resources/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config.json b/src/main/resources/config.json index f110f286..cf664003 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,4 +1,4 @@ { "channels": ["jake-m"], - "token": "ODA4MDQwODE4NzgyNjM0MDA0.YCAwpw.AvGrwIptQJB7uFGPoKx2BLgsoF4" + "token": "token" } From bcd76a8af0af73fab17d6af45dd1df6ef62bb6f8 Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 6 Jun 2021 11:22:16 -0700 Subject: [PATCH 21/22] Poker bot completed The !gamble poker command starts a new poker game. You add a number after this command as the starting wager. The command !gamble bet with a number after it is the next wager continues the game. You can fold by using !gamble fold. If you run out of money, you can use !gamble work with a number after it to gain money in your balance. --- .../java/org/jointheleague/modules/Poker.java | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/Poker.java b/src/main/java/org/jointheleague/modules/Poker.java index cc18f762..33cb46d4 100644 --- a/src/main/java/org/jointheleague/modules/Poker.java +++ b/src/main/java/org/jointheleague/modules/Poker.java @@ -5,6 +5,7 @@ import org.javacord.api.event.message.MessageCreateEvent; import org.javacord.api.listener.message.MessageCreateListener; +import org.jointheleague.modules.pojo.HelpEmbed; import net.aksingh.owmjapis.api.APIException; @@ -13,12 +14,14 @@ public class Poker extends CustomMessageCreateListener { public Poker(String channelName) { // TODO Auto-generated constructor stub super(channelName); + helpEmbed = new HelpEmbed("!gamble poker", "This command starts a new poker game. You add a number after this command as the starting wager. The command !gamble bet with a number after it as the next wager continues the game. You can fold by using !gamble fold. If you run out of money, you can use !gamble work with a number after it to gain money in your balance."); } private static final String command = "!gamble"; int balance = 50; int wager; int totalBet; + int payment; Random randCards = new Random(); String[] cards = new String[52]; String[] botAndMiddleCards = new String[7]; @@ -207,8 +210,9 @@ public void handle(MessageCreateEvent event) throws APIException { playerHearts=0; playerClubs=0; - if (balance < 0) { + if (balance-wager < 0) { event.getChannel().sendMessage("You don't have enough money to wager that much."); + gameOver=true; } else if (wager<0) { event.getChannel().sendMessage("Choose a positive number"); gameOver=true; @@ -525,8 +529,9 @@ else if (content.contains("bet") && flop && !gameOver) { return; } System.out.println(totalBet); - if (balance < 0) { + if (balance-wager < 0) { event.getChannel().sendMessage("You don't have enough money to wager that much."); + gameOver=true; } else if(wager<0) { event.getChannel().sendMessage("Choose a positive number"); } @@ -640,8 +645,9 @@ else if(cards[middleCard4].contains("clubs")) { return; } System.out.println(totalBet); - if (balance < 0) { + if (balance-wager < 0) { event.getChannel().sendMessage("You don't have enough money to wager that much."); + gameOver=true; } else if(wager<0) { event.getChannel().sendMessage("Choose a positive number."); } @@ -755,8 +761,9 @@ else if(cards[middleCard5].contains("clubs")) { return; } System.out.println(totalBet); - if (balance < 0) { + if (balance-wager < 0) { event.getChannel().sendMessage("You don't have enough money to wager that much."); + gameOver=true; } else if(wager<0) { event.getChannel().sendMessage("Choose a positive number."); } @@ -1043,7 +1050,7 @@ else if(cards[middleCard5].contains("clubs")) { } //test certain hands - botAndMiddleCards[0]="7"; + /*botAndMiddleCards[0]="7"; botAndMiddleCards[1]="8"; botAndMiddleCards[2]="9"; botAndMiddleCards[3]="jack"; @@ -1053,12 +1060,12 @@ else if(cards[middleCard5].contains("clubs")) { playerAndMiddleCards[0]="7"; playerAndMiddleCards[1]="8"; - playerAndMiddleCards[2]="9"; + playerAndMiddleCards[2]="10"; playerAndMiddleCards[3]="jack"; playerAndMiddleCards[4]="queen"; playerAndMiddleCards[5]="king"; playerAndMiddleCards[6]="ace"; - + */ if(!rewardGiven) { @@ -1086,9 +1093,20 @@ else if(!playerWon) { } } } + else if(event.getMessageContent().contains("work")) { + String work = event.getMessageContent().replaceAll(" ", "").replace("!gamble", "").replace("work", ""); + try { + payment=Integer.parseInt(work); + } + catch (Exception e){ + event.getChannel().sendMessage("Choose a number after the command to gamble"); + return; + } + balance+=payment; + event.getChannel().sendMessage("Your balance is now "+balance); } } - + } public int botAlgorithm(String[] botAndMiddleCards, int suits) { highestCallChance = 0; From 072ada17fcb5d60fbe02074270bc22a755656856 Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 6 Jun 2021 11:26:05 -0700 Subject: [PATCH 22/22] Poker bot completed This command starts a new poker game. You add a number after this command as the starting wager. The command !gamble bet with a number after it is the next wager continues the game. You can fold by using !gamble fold. If you run out of money, you can use !gamble work with a number after it to gain money in your balance. --- src/main/java/org/jointheleague/modules/Poker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jointheleague/modules/Poker.java b/src/main/java/org/jointheleague/modules/Poker.java index 33cb46d4..f2ff803c 100644 --- a/src/main/java/org/jointheleague/modules/Poker.java +++ b/src/main/java/org/jointheleague/modules/Poker.java @@ -14,7 +14,7 @@ public class Poker extends CustomMessageCreateListener { public Poker(String channelName) { // TODO Auto-generated constructor stub super(channelName); - helpEmbed = new HelpEmbed("!gamble poker", "This command starts a new poker game. You add a number after this command as the starting wager. The command !gamble bet with a number after it as the next wager continues the game. You can fold by using !gamble fold. If you run out of money, you can use !gamble work with a number after it to gain money in your balance."); + helpEmbed = new HelpEmbed("!gamble poker", "This command starts a new poker game. You add a number after this command as the starting wager. The command !gamble bet with a number after it is the next wager continues the game. You can fold by using !gamble fold. If you run out of money, you can use !gamble work with a number after it to gain money in your balance."); } private static final String command = "!gamble";