From 88c92f69a7b42ff014fdfac0a3a8e39fd030a302 Mon Sep 17 00:00:00 2001 From: codeavenger1 Date: Mon, 21 Dec 2020 17:01:07 -0800 Subject: [PATCH 01/55] created new feature --- .../discord_bot_example/Bot.java | 6 +++++- .../modules/FilmRecommendations.java | 19 +++++++++++++++++++ src/main/resources/config.json | 4 ++-- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 src/main/java/org/jointheleague/modules/FilmRecommendations.java 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 75aff545..9dd8d8cf 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -109,6 +109,10 @@ public void connect(boolean printInvite) { api.addMessageCreateListener(rps); helpListener.addHelpEmbed(rps.getHelpEmbed()); + FilmRecommendations f = new FilmRecommendations(channelName); + api.addMessageCreateListener(f); + helpListener.addHelpEmbed(f.getHelpEmbed()); + //old way to add listeners api.addMessageCreateListener(helpListener); api.addMessageCreateListener(new MomBot(channelName)); @@ -153,6 +157,6 @@ public void connect(boolean printInvite) { api.addMessageCreateListener(new RandomCase(channelName)); api.addMessageCreateListener(new GetTime(channelName)); api.addMessageCreateListener(new ScreenCapture(channelName)); - + } } diff --git a/src/main/java/org/jointheleague/modules/FilmRecommendations.java b/src/main/java/org/jointheleague/modules/FilmRecommendations.java new file mode 100644 index 00000000..06d0a96f --- /dev/null +++ b/src/main/java/org/jointheleague/modules/FilmRecommendations.java @@ -0,0 +1,19 @@ +package org.jointheleague.modules; + +import org.javacord.api.event.message.MessageCreateEvent; + +import net.aksingh.owmjapis.api.APIException; + +public class FilmRecommendations extends CustomMessageCreateListener { + + public FilmRecommendations(String channelName) { + super(channelName); + + } + + @Override + public void handle(MessageCreateEvent event) throws APIException { + + } + +} diff --git a/src/main/resources/config.json b/src/main/resources/config.json index eaac8cdf..df3437be 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,7 +1,7 @@ { - "channels": ["channel"], - "token": "token" + "channels": [""], + "token": "" } From f7b24a71081b5df68b05b3f70928d44be75e3881 Mon Sep 17 00:00:00 2001 From: adrianolguin <33267387+adrianolguin@users.noreply.github.com> Date: Wed, 23 Dec 2020 18:30:31 -0800 Subject: [PATCH 02/55] Discord Bot --- src/main/resources/config.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/resources/config.json b/src/main/resources/config.json index eaac8cdf..f96a1c44 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,7 +1,7 @@ - -{ - - "channels": ["channel"], - "token": "token" - -} + +{ + + "channels": ["bot-lab"], + "token": "NzkxNDg5MzY4MDgxNTYzNjg4.X-P56g.AW0ZMmrtS8td7FFC-qjBIoc7urQ" + +} From c5866c2d48669f7949f11114051f65f114552207 Mon Sep 17 00:00:00 2001 From: adrianolguin <33267387+adrianolguin@users.noreply.github.com> Date: Wed, 30 Dec 2020 18:23:20 -0800 Subject: [PATCH 03/55] bot --- .../discord_bot_example/Bot.java | 318 +++++++++--------- .../java/org/jointheleague/modules/Hello.java | 24 ++ 2 files changed, 184 insertions(+), 158 deletions(-) create mode 100644 src/main/java/org/jointheleague/modules/Hello.java 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 75aff545..e06a83f3 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -1,158 +1,160 @@ -package org.jointheleague.discord_bot_example; - -import org.javacord.api.DiscordApi; - -import org.javacord.api.DiscordApiBuilder; - -/** - * Launches all of the listeners for one channel. - * @author keithgroves and https://tinystripz.com - * - */ -import org.jointheleague.modules.*; - - - -public class Bot { - - // The string to show the custom :vomiting_robot: emoji - public static String emoji = "<:vomiting_robot:642414033290657803>"; - - private String token; - private String channelName; - DiscordApi api; - _HelpListener helpListener; - - public Bot(String token, String channelName) { - this.token = token; - this.channelName = channelName; - helpListener = new _HelpListener(channelName); - } - - public void connect(boolean printInvite) { - - api = new DiscordApiBuilder().setToken(token).login().join(); - - // Print the URL to invite the bot - if (printInvite) { - System.out.println("You can invite the bot by using the following url: " + api.createBotInvite()); - } - - api.getServerTextChannelsByName(channelName).forEach(e -> e.sendMessage("Bot Connected")); - - //add Listeners - - ToDoList list = new ToDoList(channelName); - api.addMessageCreateListener(list); - helpListener.addHelpEmbed(list.getHelpEmbed()); - - HeadlineListener head = new HeadlineListener(channelName); - api.addMessageCreateListener(head); - helpListener.addHelpEmbed(head.getHelpEmbed()); - - RandomNumber randomNumber = new RandomNumber(channelName); //replace with feature class later - api.addMessageCreateListener(randomNumber); - helpListener.addHelpEmbed(randomNumber.getHelpEmbed()); - - HypeMachine hypeMachine = new HypeMachine(channelName); - api.addMessageCreateListener(hypeMachine); - helpListener.addHelpEmbed(hypeMachine.getHelpEmbed()); - - TextStyler textStyler = new TextStyler(channelName); - api.addMessageCreateListener(textStyler); - helpListener.addHelpEmbed(textStyler.getHelpEmbed()); - - Tomagachi tomagachi = new Tomagachi(channelName); - api.addMessageCreateListener(tomagachi); - helpListener.addHelpEmbed(tomagachi.getHelpEmbed()); - - SetProfilePic setPFP = new SetProfilePic(channelName); - api.addMessageCreateListener(setPFP); - helpListener.addHelpEmbed(setPFP.getHelpEmbed()); - - ToGif toGif = new ToGif(channelName); - api.addMessageCreateListener(toGif); - helpListener.addHelpEmbed(toGif.getHelpEmbed()); - - RandomCase randomCase = new RandomCase(channelName); - api.addMessageCreateListener(randomCase); - helpListener.addHelpEmbed(randomCase.getHelpEmbed()); - - _ApiExampleListener apiExampleListener = new _ApiExampleListener(channelName); - api.addMessageCreateListener(apiExampleListener); - helpListener.addHelpEmbed(apiExampleListener.getHelpEmbed()); - - NewWeather newWeather = new NewWeather(channelName); - api.addMessageCreateListener(newWeather); - helpListener.addHelpEmbed(newWeather.getHelpEmbed()); - - CoinFlip cp = new CoinFlip(channelName); - api.addMessageCreateListener(cp); - - RandomString randomString = new RandomString(channelName); - api.addMessageCreateListener(randomString); - helpListener.addHelpEmbed(randomString.getHelpEmbed()); - - Greeter g = new Greeter(channelName); - api.addMessageCreateListener(g); - helpListener.addHelpEmbed(g.getHelpEmbed()); - - ListMakerMessageListener LM = new ListMakerMessageListener(channelName); - api.addMessageCreateListener(LM); - helpListener.addHelpEmbed(LM.getHelpEmbed()); - - Dice d = new Dice(channelName); - api.addMessageCreateListener(d); - helpListener.addHelpEmbed(d.getHelpEmbed()); - - UnbeatableRockPaperScissors rps = new UnbeatableRockPaperScissors(channelName); - api.addMessageCreateListener(rps); - helpListener.addHelpEmbed(rps.getHelpEmbed()); - - //old way to add listeners - api.addMessageCreateListener(helpListener); - api.addMessageCreateListener(new MomBot(channelName)); - api.addMessageCreateListener(new DadJokes(channelName)); - api.addMessageCreateListener(new ClockMessageListener(channelName)); - api.addMessageCreateListener(new CalculatorMessageListener(channelName)); - api.addMessageCreateListener(new ComicMessageListener(channelName)); - api.addMessageCreateListener(new ElmoMessageListener(channelName)); - api.addMessageCreateListener(new FactMessageListener(channelName)); - api.addMessageCreateListener(new CasinoGameListener(channelName)); - api.addMessageCreateListener(new HighLowListener(channelName)); - api.addMessageCreateListener(new Ryland(channelName)); - api.addMessageCreateListener(new RockPaperScissorsListener(channelName)); - api.addMessageCreateListener(new leetMessageListener(channelName)); - api.addMessageCreateListener(new ConnectFour(channelName)); - api.addMessageCreateListener(new FlagMessageListener(channelName)); - api.addMessageCreateListener(new EightBall(channelName)); - api.addMessageCreateListener(new Reddit(channelName)); - api.addMessageCreateListener(new DeepFrier(channelName)); - api.addMessageCreateListener(new PictureOf(channelName)); - api.addMessageCreateListener(new GetPicture(channelName)); - api.addMessageCreateListener(new CuteAnimal(channelName)); - api.addMessageCreateListener(new Weather(channelName)); - api.addMessageCreateListener(new FashionAdvisor(channelName)); - api.addMessageCreateListener(new LatexRender(channelName)); - api.addMessageCreateListener(new MinesweeperListener(channelName)); - api.addMessageCreateListener(new Bot1Listener(channelName)); - api.addMessageCreateListener(new PingMessageListener(channelName)); - api.addMessageCreateListener(new CoinFlipMessageListener(channelName)); - api.addMessageCreateListener(new PlayRPSMessageListener(channelName)); - api.addMessageCreateListener(new KickMessageListener(channelName)); - api.addMessageCreateListener(new AssignRoleMessageListener(channelName)); - api.addMessageCreateListener(new NicknameListener(channelName)); - api.addMessageCreateListener(new SolveQuadraticListener(channelName)); - api.addMessageCreateListener(new RollDiceMessageListener(channelName)); - api.addMessageCreateListener(new MorseTranslator(channelName)); - api.addMessageCreateListener(new HangmanListener(channelName)); - api.addMessageCreateListener(new BogoSorterListener(channelName)); - api.addMessageCreateListener(new ComplimentListener(channelName)); - api.addMessageCreateListener(new CrazyEights(channelName)); - api.addMessageCreateListener(new Blackjack(channelName)); - api.addMessageCreateListener(new RandomCase(channelName)); - api.addMessageCreateListener(new GetTime(channelName)); - api.addMessageCreateListener(new ScreenCapture(channelName)); - - } -} +package org.jointheleague.discord_bot_example; + +import org.javacord.api.DiscordApi; + +import org.javacord.api.DiscordApiBuilder; + +/** + * Launches all of the listeners for one channel. + * @author keithgroves and https://tinystripz.com + * + */ +import org.jointheleague.modules.*; + + + +public class Bot { + + // The string to show the custom :vomiting_robot: emoji + public static String emoji = "<:vomiting_robot:642414033290657803>"; + + private String token; + private String channelName; + DiscordApi api; + _HelpListener helpListener; + + public Bot(String token, String channelName) { + this.token = token; + this.channelName = channelName; + helpListener = new _HelpListener(channelName); + } + + public void connect(boolean printInvite) { + + api = new DiscordApiBuilder().setToken(token).login().join(); + + // Print the URL to invite the bot + if (printInvite) { + System.out.println("You can invite the bot by using the following url: " + api.createBotInvite()); + } + + api.getServerTextChannelsByName(channelName).forEach(e -> e.sendMessage("Bot Connected")); + + //add Listeners + + ToDoList list = new ToDoList(channelName); + api.addMessageCreateListener(list); + helpListener.addHelpEmbed(list.getHelpEmbed()); + + HeadlineListener head = new HeadlineListener(channelName); + api.addMessageCreateListener(head); + helpListener.addHelpEmbed(head.getHelpEmbed()); + + RandomNumber randomNumber = new RandomNumber(channelName); //replace with feature class later + api.addMessageCreateListener(randomNumber); + helpListener.addHelpEmbed(randomNumber.getHelpEmbed()); + + HypeMachine hypeMachine = new HypeMachine(channelName); + api.addMessageCreateListener(hypeMachine); + helpListener.addHelpEmbed(hypeMachine.getHelpEmbed()); + + TextStyler textStyler = new TextStyler(channelName); + api.addMessageCreateListener(textStyler); + helpListener.addHelpEmbed(textStyler.getHelpEmbed()); + + Tomagachi tomagachi = new Tomagachi(channelName); + api.addMessageCreateListener(tomagachi); + helpListener.addHelpEmbed(tomagachi.getHelpEmbed()); + + SetProfilePic setPFP = new SetProfilePic(channelName); + api.addMessageCreateListener(setPFP); + helpListener.addHelpEmbed(setPFP.getHelpEmbed()); + + ToGif toGif = new ToGif(channelName); + api.addMessageCreateListener(toGif); + helpListener.addHelpEmbed(toGif.getHelpEmbed()); + + RandomCase randomCase = new RandomCase(channelName); + api.addMessageCreateListener(randomCase); + helpListener.addHelpEmbed(randomCase.getHelpEmbed()); + + _ApiExampleListener apiExampleListener = new _ApiExampleListener(channelName); + api.addMessageCreateListener(apiExampleListener); + helpListener.addHelpEmbed(apiExampleListener.getHelpEmbed()); + + NewWeather newWeather = new NewWeather(channelName); + api.addMessageCreateListener(newWeather); + helpListener.addHelpEmbed(newWeather.getHelpEmbed()); + + CoinFlip cp = new CoinFlip(channelName); + api.addMessageCreateListener(cp); + + RandomString randomString = new RandomString(channelName); + api.addMessageCreateListener(randomString); + helpListener.addHelpEmbed(randomString.getHelpEmbed()); + + Greeter g = new Greeter(channelName); + api.addMessageCreateListener(g); + helpListener.addHelpEmbed(g.getHelpEmbed()); + + ListMakerMessageListener LM = new ListMakerMessageListener(channelName); + api.addMessageCreateListener(LM); + helpListener.addHelpEmbed(LM.getHelpEmbed()); + + Dice d = new Dice(channelName); + api.addMessageCreateListener(d); + helpListener.addHelpEmbed(d.getHelpEmbed()); + + UnbeatableRockPaperScissors rps = new UnbeatableRockPaperScissors(channelName); + api.addMessageCreateListener(rps); + helpListener.addHelpEmbed(rps.getHelpEmbed()); + + //old way to add listeners + api.addMessageCreateListener(helpListener); + api.addMessageCreateListener(new MomBot(channelName)); + api.addMessageCreateListener(new DadJokes(channelName)); + api.addMessageCreateListener(new ClockMessageListener(channelName)); + api.addMessageCreateListener(new CalculatorMessageListener(channelName)); + api.addMessageCreateListener(new ComicMessageListener(channelName)); + api.addMessageCreateListener(new ElmoMessageListener(channelName)); + api.addMessageCreateListener(new FactMessageListener(channelName)); + api.addMessageCreateListener(new CasinoGameListener(channelName)); + api.addMessageCreateListener(new HighLowListener(channelName)); + api.addMessageCreateListener(new Ryland(channelName)); + api.addMessageCreateListener(new RockPaperScissorsListener(channelName)); + api.addMessageCreateListener(new leetMessageListener(channelName)); + api.addMessageCreateListener(new ConnectFour(channelName)); + api.addMessageCreateListener(new FlagMessageListener(channelName)); + api.addMessageCreateListener(new EightBall(channelName)); + api.addMessageCreateListener(new Reddit(channelName)); + api.addMessageCreateListener(new DeepFrier(channelName)); + api.addMessageCreateListener(new PictureOf(channelName)); + api.addMessageCreateListener(new GetPicture(channelName)); + api.addMessageCreateListener(new CuteAnimal(channelName)); + api.addMessageCreateListener(new Weather(channelName)); + api.addMessageCreateListener(new FashionAdvisor(channelName)); + api.addMessageCreateListener(new LatexRender(channelName)); + api.addMessageCreateListener(new MinesweeperListener(channelName)); + api.addMessageCreateListener(new Bot1Listener(channelName)); + api.addMessageCreateListener(new PingMessageListener(channelName)); + api.addMessageCreateListener(new CoinFlipMessageListener(channelName)); + api.addMessageCreateListener(new PlayRPSMessageListener(channelName)); + api.addMessageCreateListener(new KickMessageListener(channelName)); + api.addMessageCreateListener(new AssignRoleMessageListener(channelName)); + api.addMessageCreateListener(new NicknameListener(channelName)); + api.addMessageCreateListener(new SolveQuadraticListener(channelName)); + api.addMessageCreateListener(new RollDiceMessageListener(channelName)); + api.addMessageCreateListener(new MorseTranslator(channelName)); + api.addMessageCreateListener(new HangmanListener(channelName)); + api.addMessageCreateListener(new BogoSorterListener(channelName)); + api.addMessageCreateListener(new ComplimentListener(channelName)); + api.addMessageCreateListener(new CrazyEights(channelName)); + api.addMessageCreateListener(new Blackjack(channelName)); + api.addMessageCreateListener(new RandomCase(channelName)); + api.addMessageCreateListener(new GetTime(channelName)); + api.addMessageCreateListener(new ScreenCapture(channelName)); + + api.addMessageCreateListener(new Hello(channelName)); + + } +} diff --git a/src/main/java/org/jointheleague/modules/Hello.java b/src/main/java/org/jointheleague/modules/Hello.java new file mode 100644 index 00000000..f601a0b0 --- /dev/null +++ b/src/main/java/org/jointheleague/modules/Hello.java @@ -0,0 +1,24 @@ +package org.jointheleague.modules; + +import org.javacord.api.event.message.MessageCreateEvent; + +import net.aksingh.owmjapis.api.APIException; + +public class Hello extends CustomMessageCreateListener { + + private static final String COMMAND = "!Hello"; + + public Hello(String channelName) { + super(channelName); + } + + @Override + public void handle(MessageCreateEvent event) throws APIException { + if (event.getMessageContent().contains(COMMAND)) { + String user = event.getMessageAuthor().getDisplayName().toString(); + event.getChannel().sendMessage("Hello! " + user); + + } + } + +} From 1918f772cbf78408e5b7f34a9a980c96d8763a09 Mon Sep 17 00:00:00 2001 From: codeavenger1 Date: Mon, 4 Jan 2021 16:59:14 -0800 Subject: [PATCH 04/55] got api keys --- .../modules/FilmRecommendations.java | 92 ++++++++++++++++++- src/main/resources/config.json | 4 +- 2 files changed, 91 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/FilmRecommendations.java b/src/main/java/org/jointheleague/modules/FilmRecommendations.java index 06d0a96f..d7d3b5c3 100644 --- a/src/main/java/org/jointheleague/modules/FilmRecommendations.java +++ b/src/main/java/org/jointheleague/modules/FilmRecommendations.java @@ -1,19 +1,105 @@ package org.jointheleague.modules; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.ProtocolException; +import java.net.URL; + +import javax.json.Json; +import javax.json.JsonObject; +import javax.json.JsonReader; + import org.javacord.api.event.message.MessageCreateEvent; +import org.jointheleague.modules.pojo.HelpEmbed; +import org.jointheleague.modules.pojo.apiExample.ApiExampleWrapper; +import org.jointheleague.modules.pojo.apiExample.Article; + +import com.google.gson.Gson; import net.aksingh.owmjapis.api.APIException; public class FilmRecommendations extends CustomMessageCreateListener { + private final String apiKey = "74590d2a04d94185bb36d38a39d6238e"; + private static final String COMMAND = "!newsAPI"; + private final Gson gson = new Gson(); + public FilmRecommendations(String channelName) { super(channelName); - + helpEmbed = new HelpEmbed(COMMAND, "Example of using an API to get information from another service"); } - + @Override public void handle(MessageCreateEvent event) throws APIException { - + if(event.getMessageContent().contains(COMMAND)) { + + //remove the command so we are only left with the search term + String msg = event.getMessageContent().replaceAll(" ", "").replace(COMMAND, ""); + + if (msg.equals("")) { + event.getChannel().sendMessage("Please put a word after the command"); + } else { + String definition = getNewsStoryByTopic(msg); + event.getChannel().sendMessage(definition); + } + + } } + public String getNewsStoryByTopic(String topic) { + + //create the request URL (can be found in the documentation) + String requestURL = "http://newsapi.org/v2/everything?" + + "q="+topic+"&" + + "sortBy=popularity&" + + "apiKey="+apiKey; + + try { + + //the following code will probably be the same for your feature + URL url = new URL(requestURL); + HttpURLConnection con = (HttpURLConnection) url.openConnection(); + con.setRequestMethod("GET"); + JsonReader repoReader = Json.createReader(con.getInputStream()); + JsonObject userJSON = ((JsonObject) repoReader.read()); + con.disconnect(); + + //turn the json response into a java object + //you will need to create a java class that represents the response in org.jointheleague.modules.pojo + //you can use a tools like Postman and jsonschema2pojo.com to help with that + + //you can use postman to make the request and receive a response, then take that and put it right into jsonschema2pojo.com + //If using jsonschema2pojo.com, select Target Langue = java, Source Type = JSON, Annotation Style = Gson + ApiExampleWrapper apiExampleWrapper = gson.fromJson(userJSON.toString(), ApiExampleWrapper.class); + + //get the first article (these are just java objects now) + Article article = apiExampleWrapper.getArticles().get(0); + + //get the title of the article + String articleTitle = article.getTitle(); + + //get the content of the article + String articleContent = article.getContent(); + + //create the message + String message = articleTitle + " - " + articleContent; + + //send the message + return message; + + + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (ProtocolException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return "No news story found for the keyword: " + topic; + } + + } + + diff --git a/src/main/resources/config.json b/src/main/resources/config.json index df3437be..cdc93765 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,7 +1,7 @@ { - "channels": [""], - "token": "" + "channels": ["shiva"], + "token": "NzU3NzM5OTMxODgyODgxMjI1.X2kyTQ.Ikyhjt7EV6PPcla9mQy6gqV6Oes" } From b7673d6b173ed2f490164834cde58b94bd54e692 Mon Sep 17 00:00:00 2001 From: adrianolguin <33267387+adrianolguin@users.noreply.github.com> Date: Wed, 6 Jan 2021 18:28:11 -0800 Subject: [PATCH 05/55] Started working on reminder feature, going well --- .../discord_bot_example/Bot.java | 1 + .../org/jointheleague/modules/Reminder.java | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 src/main/java/org/jointheleague/modules/Reminder.java 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 e06a83f3..28dd9437 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -155,6 +155,7 @@ public void connect(boolean printInvite) { api.addMessageCreateListener(new ScreenCapture(channelName)); api.addMessageCreateListener(new Hello(channelName)); + api.addMessageCreateListener(new Reminder(channelName)); } } diff --git a/src/main/java/org/jointheleague/modules/Reminder.java b/src/main/java/org/jointheleague/modules/Reminder.java new file mode 100644 index 00000000..57663e44 --- /dev/null +++ b/src/main/java/org/jointheleague/modules/Reminder.java @@ -0,0 +1,58 @@ +package org.jointheleague.modules; + +import java.time.LocalTime; + +import org.javacord.api.event.message.MessageCreateEvent; +import org.javacord.api.listener.message.MessageCreateListener; + +import net.aksingh.owmjapis.api.APIException; + +public class Reminder extends CustomMessageCreateListener { + + public static final String COMMAND = "!setReminder"; + + public static String reminderTime = ""; + + public Reminder(String channelName) { + super(channelName); + + } + + @Override + public void handle(MessageCreateEvent event) throws APIException { + if (event.getMessageContent().contains(COMMAND)) { + String cmd = event.getMessageContent().replaceAll(" ", "").replace(COMMAND, ""); + + if (cmd.equals("")) { + event.getChannel().sendMessage("Invalid Input"); + + } + + System.out.println(cmd); + + String timeParameter = cmd.substring(0, cmd.indexOf(',')); + System.out.println(timeParameter); + + int count = timeParameter.length() - timeParameter.replaceAll(":", "").length(); + if (count == 1) { + timeParameter += ":00"; + } + + System.out.println("Fixed time parameter: " + timeParameter); + + LocalTime time = LocalTime.parse(timeParameter); + System.out.println("Time: " + time); + + cmd = cmd.substring(cmd.indexOf(',') + 1, cmd.length()); + System.out.println(cmd); + + String messageParameter = cmd.substring(0, cmd.length()); + System.out.println(messageParameter); + + } + + + + } + +} From 2049be53f09ca5668cdd5b85ff229bb60553efdf Mon Sep 17 00:00:00 2001 From: codeavenger1 Date: Mon, 11 Jan 2021 16:56:31 -0800 Subject: [PATCH 06/55] got api key --- .../org/jointheleague/modules/FilmRecommendations.java | 9 +++------ src/main/resources/config.json | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/FilmRecommendations.java b/src/main/java/org/jointheleague/modules/FilmRecommendations.java index d7d3b5c3..aeb14eb2 100644 --- a/src/main/java/org/jointheleague/modules/FilmRecommendations.java +++ b/src/main/java/org/jointheleague/modules/FilmRecommendations.java @@ -21,8 +21,8 @@ public class FilmRecommendations extends CustomMessageCreateListener { - private final String apiKey = "74590d2a04d94185bb36d38a39d6238e"; - private static final String COMMAND = "!newsAPI"; + private final String apiKey = "AIzaSyDNMPIR-dNHFahbddV_T2XrMlMiT_y89MY"; + private static final String COMMAND = "!moviesAPI"; private final Gson gson = new Gson(); public FilmRecommendations(String channelName) { @@ -99,7 +99,4 @@ public String getNewsStoryByTopic(String topic) { return "No news story found for the keyword: " + topic; } - -} - - +} \ No newline at end of file diff --git a/src/main/resources/config.json b/src/main/resources/config.json index cdc93765..df3437be 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,7 +1,7 @@ { - "channels": ["shiva"], - "token": "NzU3NzM5OTMxODgyODgxMjI1.X2kyTQ.Ikyhjt7EV6PPcla9mQy6gqV6Oes" + "channels": [""], + "token": "" } From ba785b4b7318e2a048c9eaa1606ffd16941e2e45 Mon Sep 17 00:00:00 2001 From: adrianolguin <33267387+adrianolguin@users.noreply.github.com> Date: Wed, 13 Jan 2021 17:13:50 -0800 Subject: [PATCH 07/55] Adrian's 2nd Feature --- .../org/jointheleague/modules/Reminder.java | 108 +++++++++++++++--- 1 file changed, 90 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/Reminder.java b/src/main/java/org/jointheleague/modules/Reminder.java index 57663e44..a2674b91 100644 --- a/src/main/java/org/jointheleague/modules/Reminder.java +++ b/src/main/java/org/jointheleague/modules/Reminder.java @@ -1,17 +1,29 @@ package org.jointheleague.modules; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.time.LocalTime; +import java.time.temporal.ChronoField; +import java.util.ArrayList; +import javax.swing.Timer; +import org.javacord.api.entity.channel.TextChannel; +import org.javacord.api.entity.message.MessageBuilder; +import org.javacord.api.entity.message.embed.EmbedBuilder; import org.javacord.api.event.message.MessageCreateEvent; import org.javacord.api.listener.message.MessageCreateListener; import net.aksingh.owmjapis.api.APIException; -public class Reminder extends CustomMessageCreateListener { +public class Reminder extends CustomMessageCreateListener implements ActionListener { - public static final String COMMAND = "!setReminder"; + ArrayList userNames = new ArrayList(); + ArrayList messages = new ArrayList(); + ArrayList channelNames = new ArrayList(); + ArrayList timers = new ArrayList(); - public static String reminderTime = ""; + public static final String REMIND_COMMAND = "!setReminder"; + public static final String HELP_COMMAND = "!setReminderHelp"; public Reminder(String channelName) { super(channelName); @@ -20,39 +32,99 @@ public Reminder(String channelName) { @Override public void handle(MessageCreateEvent event) throws APIException { - if (event.getMessageContent().contains(COMMAND)) { - String cmd = event.getMessageContent().replaceAll(" ", "").replace(COMMAND, ""); - if (cmd.equals("")) { + if (event.getMessageContent().contains(HELP_COMMAND)) { + + new MessageBuilder().setEmbed(new EmbedBuilder().setTitle( + "To use this command first type the '!setReminder' command, followed by the time you want to be reminded (In Military Time), a comma, then your remind message") + .setDescription("P.S. Make sure when you input your time use a colon between the hours and minutes").setFooter("")).send(event.getChannel()); + + } else if (event.getMessageContent().contains(REMIND_COMMAND)) { + + // add use to the arraylist + String user = event.getMessageAuthor().getIdAsString(); + userNames.add(user); + + // add the channel to the arraylist + TextChannel txtChannel = event.getChannel(); + channelNames.add(txtChannel); + + String parameters = event.getMessageContent().replace(REMIND_COMMAND, ""); + + if (parameters.equals("")) { event.getChannel().sendMessage("Invalid Input"); + } + + String timeParameter = ""; + + try { + // get the raw timeParameter, fix it later + timeParameter = parameters.substring(0, parameters.indexOf(',')); + + parameters = parameters.substring(parameters.indexOf(',') + 1, parameters.length()); + } catch (StringIndexOutOfBoundsException e) { + timeParameter = parameters.substring(0, parameters.length()); + + parameters = ""; } - System.out.println(cmd); + // get the raw messageParameter, no need to fix it and I add it to the arrayList + // immediately + String messageParameter = parameters.substring(0, parameters.length()); + messages.add(messageParameter); - String timeParameter = cmd.substring(0, cmd.indexOf(',')); - System.out.println(timeParameter); + // all this is fixing the raw timeParameter so I can parse it to the LocalTime + // class and compare in to the current time + timeParameter = timeParameter.replaceAll(" ", ""); int count = timeParameter.length() - timeParameter.replaceAll(":", "").length(); if (count == 1) { timeParameter += ":00"; } - System.out.println("Fixed time parameter: " + timeParameter); - + // parse fixed timeParameter to LocalTime class and get the current local time LocalTime time = LocalTime.parse(timeParameter); - System.out.println("Time: " + time); + LocalTime currentTime = LocalTime.now(); - cmd = cmd.substring(cmd.indexOf(',') + 1, cmd.length()); - System.out.println(cmd); + // using LocalTime class functions, find the time until the user needs to be + // reminded, in seconds + // what the heck is a chronofield + int timeUntil = (int) (time.getLong(ChronoField.SECOND_OF_DAY) + - currentTime.getLong(ChronoField.SECOND_OF_DAY)); - String messageParameter = cmd.substring(0, cmd.length()); - System.out.println(messageParameter); + // Using the calculated time in seconds to create a timer that goes off after + // that time, add to ArrayList + timers.add(new Timer(timeUntil * 1000, this)); + timers.get(timers.size() - 1).start(); } - - } + @Override + public void actionPerformed(ActionEvent e) { + + for (int i = 0; i < timers.size(); i++) { + + // Check which timer the ActionEvent belongs to, to find which index to be using + if (e.getSource().equals(timers.get(i))) { + channelNames.get(i).sendMessage("<@" + userNames.get(i) + ">"); + + new MessageBuilder() + .setEmbed(new EmbedBuilder().setTitle(messages.get(i)).setDescription("").setFooter("")) + .send(channelNames.get(i)); + + timers.get(i).stop(); + + // removing the information from the ArrayLists + userNames.remove(i); + channelNames.remove(i); + timers.remove(i); + messages.remove(i); + + } + } + } + } From 5389d87264a3c35fd2b3d89a63ca101faa4007ed Mon Sep 17 00:00:00 2001 From: codeavenger1 Date: Mon, 18 Jan 2021 17:00:57 -0800 Subject: [PATCH 08/55] test next class --- .../modules/FilmRecommendations.java | 42 ++- .../pojo/movieRecs/com/example/Genre.java | 32 ++ .../pojo/movieRecs/com/example/Movie.java | 286 ++++++++++++++++++ .../com/example/ProductionCompany.java | 54 ++++ .../com/example/ProductionCountry.java | 32 ++ .../movieRecs/com/example/SpokenLanguage.java | 43 +++ 6 files changed, 473 insertions(+), 16 deletions(-) create mode 100644 src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Genre.java create mode 100644 src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Movie.java create mode 100644 src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/ProductionCompany.java create mode 100644 src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/ProductionCountry.java create mode 100644 src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/SpokenLanguage.java diff --git a/src/main/java/org/jointheleague/modules/FilmRecommendations.java b/src/main/java/org/jointheleague/modules/FilmRecommendations.java index aeb14eb2..e70dac71 100644 --- a/src/main/java/org/jointheleague/modules/FilmRecommendations.java +++ b/src/main/java/org/jointheleague/modules/FilmRecommendations.java @@ -5,6 +5,7 @@ import java.net.MalformedURLException; import java.net.ProtocolException; import java.net.URL; +import java.util.List; import javax.json.Json; import javax.json.JsonObject; @@ -14,6 +15,8 @@ import org.jointheleague.modules.pojo.HelpEmbed; import org.jointheleague.modules.pojo.apiExample.ApiExampleWrapper; import org.jointheleague.modules.pojo.apiExample.Article; +import org.jointheleague.modules.pojo.movieRecs.com.example.Genre; +import org.jointheleague.modules.pojo.movieRecs.com.example.Movie; import com.google.gson.Gson; @@ -21,7 +24,7 @@ public class FilmRecommendations extends CustomMessageCreateListener { - private final String apiKey = "AIzaSyDNMPIR-dNHFahbddV_T2XrMlMiT_y89MY"; + private final String apiKey = "fa92f432901a636644b602c85e08eb4a"; private static final String COMMAND = "!moviesAPI"; private final Gson gson = new Gson(); @@ -40,19 +43,21 @@ public void handle(MessageCreateEvent event) throws APIException { if (msg.equals("")) { event.getChannel().sendMessage("Please put a word after the command"); } else { - String definition = getNewsStoryByTopic(msg); + String definition = getMovie(msg); event.getChannel().sendMessage(definition); } } } - public String getNewsStoryByTopic(String topic) { + public String getMovie(String topic) { //create the request URL (can be found in the documentation) - String requestURL = "http://newsapi.org/v2/everything?" + - "q="+topic+"&" + - "sortBy=popularity&" + - "apiKey="+apiKey; +// String requestURL = "http://newsapi.org/v2/everything?" + +// "q="+topic+"&" + +// "sortBy=popularity&" + +// "apiKey="+apiKey; + + String requestURL = "https://api.themoviedb.org/3/movie/550?api_key=fa92f432901a636644b602c85e08eb4a"; try { @@ -70,19 +75,24 @@ public String getNewsStoryByTopic(String topic) { //you can use postman to make the request and receive a response, then take that and put it right into jsonschema2pojo.com //If using jsonschema2pojo.com, select Target Langue = java, Source Type = JSON, Annotation Style = Gson - ApiExampleWrapper apiExampleWrapper = gson.fromJson(userJSON.toString(), ApiExampleWrapper.class); + Movie movie = gson.fromJson(userJSON.toString(), Movie.class); + - //get the first article (these are just java objects now) - Article article = apiExampleWrapper.getArticles().get(0); + //get the genre of movie (these are just java objects now) + List genreList = movie.getGenres(); + for (int i = 0; i < genreList.size(); i++) { + Genre g = genreList.get(i); + g.getName(); + } - //get the title of the article - String articleTitle = article.getTitle(); + //get the title of the movie + String title = movie.getOriginalTitle(); - //get the content of the article - String articleContent = article.getContent(); + //get the overview of the movie + String overview = movie.getOverview(); //create the message - String message = articleTitle + " - " + articleContent; + String message = "'" + title + "' is a " + genreList + ". Here is the overview: " + overview; //send the message return message; @@ -96,7 +106,7 @@ public String getNewsStoryByTopic(String topic) { e.printStackTrace(); } - return "No news story found for the keyword: " + topic; + return "No information found for: " + topic; } } \ No newline at end of file diff --git a/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Genre.java b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Genre.java new file mode 100644 index 00000000..893b73c0 --- /dev/null +++ b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Genre.java @@ -0,0 +1,32 @@ + +package org.jointheleague.modules.pojo.movieRecs.com.example; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Genre { + + @SerializedName("id") + @Expose + private Integer id; + @SerializedName("name") + @Expose + private String name; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Movie.java b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Movie.java new file mode 100644 index 00000000..b6cbc101 --- /dev/null +++ b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Movie.java @@ -0,0 +1,286 @@ + +package org.jointheleague.modules.pojo.movieRecs.com.example; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Movie { + + @SerializedName("adult") + @Expose + private Boolean adult; + @SerializedName("backdrop_path") + @Expose + private String backdropPath; + @SerializedName("belongs_to_collection") + @Expose + private Object belongsToCollection; + @SerializedName("budget") + @Expose + private Integer budget; + @SerializedName("genres") + @Expose + private List genres = null; + @SerializedName("homepage") + @Expose + private String homepage; + @SerializedName("id") + @Expose + private Integer id; + @SerializedName("imdb_id") + @Expose + private String imdbId; + @SerializedName("original_language") + @Expose + private String originalLanguage; + @SerializedName("original_title") + @Expose + private String originalTitle; + @SerializedName("overview") + @Expose + private String overview; + @SerializedName("popularity") + @Expose + private Double popularity; + @SerializedName("poster_path") + @Expose + private String posterPath; + @SerializedName("production_companies") + @Expose + private List productionCompanies = null; + @SerializedName("production_countries") + @Expose + private List productionCountries = null; + @SerializedName("release_date") + @Expose + private String releaseDate; + @SerializedName("revenue") + @Expose + private Integer revenue; + @SerializedName("runtime") + @Expose + private Integer runtime; + @SerializedName("spoken_languages") + @Expose + private List spokenLanguages = null; + @SerializedName("status") + @Expose + private String status; + @SerializedName("tagline") + @Expose + private String tagline; + @SerializedName("title") + @Expose + private String title; + @SerializedName("video") + @Expose + private Boolean video; + @SerializedName("vote_average") + @Expose + private Double voteAverage; + @SerializedName("vote_count") + @Expose + private Integer voteCount; + + public Boolean getAdult() { + return adult; + } + + public void setAdult(Boolean adult) { + this.adult = adult; + } + + public String getBackdropPath() { + return backdropPath; + } + + public void setBackdropPath(String backdropPath) { + this.backdropPath = backdropPath; + } + + public Object getBelongsToCollection() { + return belongsToCollection; + } + + public void setBelongsToCollection(Object belongsToCollection) { + this.belongsToCollection = belongsToCollection; + } + + public Integer getBudget() { + return budget; + } + + public void setBudget(Integer budget) { + this.budget = budget; + } + + public List getGenres() { + return genres; + } + + public void setGenres(List genres) { + this.genres = genres; + } + + public String getHomepage() { + return homepage; + } + + public void setHomepage(String homepage) { + this.homepage = homepage; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getImdbId() { + return imdbId; + } + + public void setImdbId(String imdbId) { + this.imdbId = imdbId; + } + + public String getOriginalLanguage() { + return originalLanguage; + } + + public void setOriginalLanguage(String originalLanguage) { + this.originalLanguage = originalLanguage; + } + + public String getOriginalTitle() { + return originalTitle; + } + + public void setOriginalTitle(String originalTitle) { + this.originalTitle = originalTitle; + } + + public String getOverview() { + return overview; + } + + public void setOverview(String overview) { + this.overview = overview; + } + + public Double getPopularity() { + return popularity; + } + + public void setPopularity(Double popularity) { + this.popularity = popularity; + } + + public String getPosterPath() { + return posterPath; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + + public List getProductionCompanies() { + return productionCompanies; + } + + public void setProductionCompanies(List productionCompanies) { + this.productionCompanies = productionCompanies; + } + + public List getProductionCountries() { + return productionCountries; + } + + public void setProductionCountries(List productionCountries) { + this.productionCountries = productionCountries; + } + + public String getReleaseDate() { + return releaseDate; + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + + public Integer getRevenue() { + return revenue; + } + + public void setRevenue(Integer revenue) { + this.revenue = revenue; + } + + public Integer getRuntime() { + return runtime; + } + + public void setRuntime(Integer runtime) { + this.runtime = runtime; + } + + public List getSpokenLanguages() { + return spokenLanguages; + } + + public void setSpokenLanguages(List spokenLanguages) { + this.spokenLanguages = spokenLanguages; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getTagline() { + return tagline; + } + + public void setTagline(String tagline) { + this.tagline = tagline; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Boolean getVideo() { + return video; + } + + public void setVideo(Boolean video) { + this.video = video; + } + + public Double getVoteAverage() { + return voteAverage; + } + + public void setVoteAverage(Double voteAverage) { + this.voteAverage = voteAverage; + } + + public Integer getVoteCount() { + return voteCount; + } + + public void setVoteCount(Integer voteCount) { + this.voteCount = voteCount; + } + +} diff --git a/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/ProductionCompany.java b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/ProductionCompany.java new file mode 100644 index 00000000..ee28757d --- /dev/null +++ b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/ProductionCompany.java @@ -0,0 +1,54 @@ + +package org.jointheleague.modules.pojo.movieRecs.com.example; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class ProductionCompany { + + @SerializedName("id") + @Expose + private Integer id; + @SerializedName("logo_path") + @Expose + private String logoPath; + @SerializedName("name") + @Expose + private String name; + @SerializedName("origin_country") + @Expose + private String originCountry; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getLogoPath() { + return logoPath; + } + + public void setLogoPath(String logoPath) { + this.logoPath = logoPath; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getOriginCountry() { + return originCountry; + } + + public void setOriginCountry(String originCountry) { + this.originCountry = originCountry; + } + +} diff --git a/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/ProductionCountry.java b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/ProductionCountry.java new file mode 100644 index 00000000..0e40fc53 --- /dev/null +++ b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/ProductionCountry.java @@ -0,0 +1,32 @@ + +package org.jointheleague.modules.pojo.movieRecs.com.example; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class ProductionCountry { + + @SerializedName("iso_3166_1") + @Expose + private String iso31661; + @SerializedName("name") + @Expose + private String name; + + public String getIso31661() { + return iso31661; + } + + public void setIso31661(String iso31661) { + this.iso31661 = iso31661; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/SpokenLanguage.java b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/SpokenLanguage.java new file mode 100644 index 00000000..dc1dc35c --- /dev/null +++ b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/SpokenLanguage.java @@ -0,0 +1,43 @@ + +package org.jointheleague.modules.pojo.movieRecs.com.example; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class SpokenLanguage { + + @SerializedName("english_name") + @Expose + private String englishName; + @SerializedName("iso_639_1") + @Expose + private String iso6391; + @SerializedName("name") + @Expose + private String name; + + public String getEnglishName() { + return englishName; + } + + public void setEnglishName(String englishName) { + this.englishName = englishName; + } + + public String getIso6391() { + return iso6391; + } + + public void setIso6391(String iso6391) { + this.iso6391 = iso6391; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} From 27cfe0e4fae0003ca088c6ca624dd84e444a9ab6 Mon Sep 17 00:00:00 2001 From: adrianolguin <33267387+adrianolguin@users.noreply.github.com> Date: Wed, 27 Jan 2021 18:30:41 -0800 Subject: [PATCH 09/55] Third bot function --- .../discord_bot_example/Bot.java | 5 +- .../java/org/jointheleague/modules/Poll.java | 76 +++++++++++++++++++ .../org/jointheleague/modules/Reminder.java | 14 +++- 3 files changed, 87 insertions(+), 8 deletions(-) create mode 100644 src/main/java/org/jointheleague/modules/Poll.java 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 01a88425..8499b987 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -103,10 +103,6 @@ public void connect(boolean printInvite) { MaxTicTacToe mttt = new MaxTicTacToe(channelName); api.addMessageCreateListener(mttt); helpListener.addHelpEmbed(mttt.getHelpEmbed()); - - Greeter g = new Greeter(channelName); - api.addMessageCreateListener(g); - helpListener.addHelpEmbed(g.getHelpEmbed()); pythagcalc pythagCalc = new pythagcalc(channelName); api.addMessageCreateListener(pythagCalc); @@ -179,5 +175,6 @@ public void connect(boolean printInvite) { api.addMessageCreateListener(new Hello(channelName)); api.addMessageCreateListener(new Reminder(channelName)); + api.addMessageCreateListener(new Poll(channelName)); } } diff --git a/src/main/java/org/jointheleague/modules/Poll.java b/src/main/java/org/jointheleague/modules/Poll.java new file mode 100644 index 00000000..feb8a232 --- /dev/null +++ b/src/main/java/org/jointheleague/modules/Poll.java @@ -0,0 +1,76 @@ +package org.jointheleague.modules; + +import java.util.ArrayList; +import java.util.Iterator; + +import org.javacord.api.entity.message.MessageBuilder; +import org.javacord.api.entity.message.embed.EmbedBuilder; +import org.javacord.api.event.message.MessageCreateEvent; + +import net.aksingh.owmjapis.api.APIException; + +public class Poll extends CustomMessageCreateListener { + + + ArrayList options; + + public static String pollOptionContent = ""; + + public static final String COMMAND = "!createPoll"; + + public Poll(String channelName) { + super(channelName); + } + + @Override + public void handle(MessageCreateEvent event) throws APIException { + if (event.getMessageContent().contains(COMMAND)) { + + String parameters = event.getMessageContent().replace(COMMAND, ""); + + System.out.println(parameters); + + String timeParameter = parameters.substring(0, parameters.indexOf(',')); + parameters = parameters.substring(parameters.indexOf(',') + 1, parameters.length()); + + System.out.println(timeParameter); + + String pollTitle = parameters.substring(0, parameters.indexOf(',')); + parameters = parameters.substring(parameters.indexOf(',') + 1, parameters.length()); + + ArrayList optionInputs = new ArrayList(); + + while (parameters != "") { + try { + optionInputs.add(parameters.substring(0, parameters.indexOf(','))); + + parameters = parameters.substring(parameters.indexOf(',') + 1, parameters.length()); + + } catch (StringIndexOutOfBoundsException e) { + optionInputs.add(parameters.substring(0, parameters.length())); + + parameters = ""; + + } + } + + System.out.println("List of options"); + + for (String s : optionInputs) { + pollOptionContent += s + "\n"; + } + +// for(int i = 0; i < optionInputs.size(); i++) { +// pollOptionContent += optionInputs.get(i); +// } + + new MessageBuilder() + .setEmbed(new EmbedBuilder().setTitle(pollTitle).setDescription(pollOptionContent) + .setFooter("The poll will only be up for about ___ minutes/seconds")) + .send(event.getChannel()); + + } + + } + +} diff --git a/src/main/java/org/jointheleague/modules/Reminder.java b/src/main/java/org/jointheleague/modules/Reminder.java index a2674b91..62dd1e6a 100644 --- a/src/main/java/org/jointheleague/modules/Reminder.java +++ b/src/main/java/org/jointheleague/modules/Reminder.java @@ -1,11 +1,9 @@ package org.jointheleague.modules; - import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.time.LocalTime; import java.time.temporal.ChronoField; import java.util.ArrayList; - import javax.swing.Timer; import org.javacord.api.entity.channel.TextChannel; import org.javacord.api.entity.message.MessageBuilder; @@ -32,12 +30,15 @@ public Reminder(String channelName) { @Override public void handle(MessageCreateEvent event) throws APIException { - + if (event.getMessageContent().contains(HELP_COMMAND)) { + //event.get + new MessageBuilder().setEmbed(new EmbedBuilder().setTitle( "To use this command first type the '!setReminder' command, followed by the time you want to be reminded (In Military Time), a comma, then your remind message") - .setDescription("P.S. Make sure when you input your time use a colon between the hours and minutes").setFooter("")).send(event.getChannel()); + .setDescription("P.S. Make sure when you input your time use a colon between the hours and minutes") + .setFooter("")).send(event.getChannel()); } else if (event.getMessageContent().contains(REMIND_COMMAND)) { @@ -63,6 +64,9 @@ public void handle(MessageCreateEvent event) throws APIException { parameters = parameters.substring(parameters.indexOf(',') + 1, parameters.length()); } catch (StringIndexOutOfBoundsException e) { + // This catches if there is no comma, which probably means there is no message + // so I set that to an empty string + timeParameter = parameters.substring(0, parameters.length()); parameters = ""; @@ -98,6 +102,8 @@ public void handle(MessageCreateEvent event) throws APIException { timers.add(new Timer(timeUntil * 1000, this)); timers.get(timers.size() - 1).start(); + event.getChannel().sendMessage("Successfully created a reminder for " + time.toString()); + } } From f1a9ed74dd4ffa173dd49e78a088e005fd18762c Mon Sep 17 00:00:00 2001 From: adrianolguin <33267387+adrianolguin@users.noreply.github.com> Date: Wed, 27 Jan 2021 18:31:16 -0800 Subject: [PATCH 10/55] reminder --- src/main/java/org/jointheleague/modules/Reminder.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/jointheleague/modules/Reminder.java b/src/main/java/org/jointheleague/modules/Reminder.java index 62dd1e6a..a0cb2081 100644 --- a/src/main/java/org/jointheleague/modules/Reminder.java +++ b/src/main/java/org/jointheleague/modules/Reminder.java @@ -105,7 +105,6 @@ public void handle(MessageCreateEvent event) throws APIException { event.getChannel().sendMessage("Successfully created a reminder for " + time.toString()); } - } @Override From 1a879faadcd536db91659222d0e3a9f327c64337 Mon Sep 17 00:00:00 2001 From: codeavenger1 Date: Mon, 8 Feb 2021 17:31:18 -0800 Subject: [PATCH 11/55] done --- .../modules/FilmRecommendations.java | 121 ++++++++++++---- .../modules/UnbeatableRockPaperScissors.java | 2 +- .../pojo/movieRecs/com/example/Genre.java | 32 ----- .../pojo/movieRecs/com/example/Movie2.java | 55 +++++++ .../com/example/ProductionCompany.java | 54 ------- .../com/example/ProductionCountry.java | 32 ----- .../com/example/{Movie.java => Result.java} | 135 +----------------- .../movieRecs/com/example/SpokenLanguage.java | 43 ------ 8 files changed, 156 insertions(+), 318 deletions(-) delete mode 100644 src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Genre.java create mode 100644 src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Movie2.java delete mode 100644 src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/ProductionCompany.java delete mode 100644 src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/ProductionCountry.java rename src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/{Movie.java => Result.java} (51%) delete mode 100644 src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/SpokenLanguage.java diff --git a/src/main/java/org/jointheleague/modules/FilmRecommendations.java b/src/main/java/org/jointheleague/modules/FilmRecommendations.java index e70dac71..e8e25660 100644 --- a/src/main/java/org/jointheleague/modules/FilmRecommendations.java +++ b/src/main/java/org/jointheleague/modules/FilmRecommendations.java @@ -5,6 +5,7 @@ import java.net.MalformedURLException; import java.net.ProtocolException; import java.net.URL; +import java.util.HashMap; import java.util.List; import javax.json.Json; @@ -15,8 +16,8 @@ import org.jointheleague.modules.pojo.HelpEmbed; import org.jointheleague.modules.pojo.apiExample.ApiExampleWrapper; import org.jointheleague.modules.pojo.apiExample.Article; -import org.jointheleague.modules.pojo.movieRecs.com.example.Genre; -import org.jointheleague.modules.pojo.movieRecs.com.example.Movie; +import org.jointheleague.modules.pojo.movieRecs.com.example.Movie2; +import org.jointheleague.modules.pojo.movieRecs.com.example.Result; import com.google.gson.Gson; @@ -27,29 +28,77 @@ public class FilmRecommendations extends CustomMessageCreateListener { private final String apiKey = "fa92f432901a636644b602c85e08eb4a"; private static final String COMMAND = "!moviesAPI"; private final Gson gson = new Gson(); + HashMap genreMap = new HashMap(); public FilmRecommendations(String channelName) { super(channelName); - helpEmbed = new HelpEmbed(COMMAND, "Example of using an API to get information from another service"); + helpEmbed = new HelpEmbed(COMMAND, "Please type '!moviesAPI' and the name of a movie you want information for."); + genreMap.put(28, "Action"); + genreMap.put(12, "Adventure"); + genreMap.put(16, "Animation"); + genreMap.put(35, "Comedy"); + genreMap.put(80, "Crime"); + genreMap.put(99, "Documentary"); + genreMap.put(18, "Drama"); + genreMap.put(10751, "Family"); + genreMap.put(14, "Fantasy"); + genreMap.put(36, "History"); + genreMap.put(27, "Horror"); + genreMap.put(10402, "Music"); + genreMap.put(9648, "Mystery"); + genreMap.put(10749, "Romance"); + genreMap.put(878, "Science Fiction"); + genreMap.put(10770, "TV Movie"); + genreMap.put(53, "Thriller"); + genreMap.put(10752, "War"); + genreMap.put(37, "Western"); } + + @Override public void handle(MessageCreateEvent event) throws APIException { + if(event.getMessageContent().contains(COMMAND)) { - //remove the command so we are only left with the search term - String msg = event.getMessageContent().replaceAll(" ", "").replace(COMMAND, ""); + //String msg = event.getMessageContent(); - if (msg.equals("")) { - event.getChannel().sendMessage("Please put a word after the command"); - } else { - String definition = getMovie(msg); - event.getChannel().sendMessage(definition); - } + String [] msg = event.getMessageContent().split(" "); + if (msg[0].equals("!moviesAPI")) { + //event.getChannel().sendMessage("Please give me a movie"); + String userOutput = ""; + + for(int i = 1; i < msg.length; i++) { + userOutput += msg[i]; + + if(i < msg.length-1) { + userOutput += "%20"; + } + } + + System.out.println(userOutput); + + + String movieInfo = getMovie(userOutput); + System.out.println(movieInfo); + event.getChannel().sendMessage(movieInfo); + //event.getChannel().sendMessage("Please put a word after the command"); + } + else { + event.getChannel().sendMessage("Please enter a movie."); + String userOutput = ""; + for(int i = 1; i < msg.length; i++) { + userOutput += msg[i]; + + if(i < msg.length-1) { + userOutput += "%20"; + } + } + } } } - public String getMovie(String topic) { + public String getMovie(String movieName) { //create the request URL (can be found in the documentation) // String requestURL = "http://newsapi.org/v2/everything?" + @@ -57,7 +106,8 @@ public String getMovie(String topic) { // "sortBy=popularity&" + // "apiKey="+apiKey; - String requestURL = "https://api.themoviedb.org/3/movie/550?api_key=fa92f432901a636644b602c85e08eb4a"; + //String requestURL = "https://api.themoviedb.org/3/movie/550?api_key=fa92f432901a636644b602c85e08eb4a"; + String requestURL = "https://api.themoviedb.org/3/search/movie?api_key=" + apiKey + "&language=en-US&query=" + movieName + "&page=1&include_adult=false"; try { @@ -75,24 +125,38 @@ public String getMovie(String topic) { //you can use postman to make the request and receive a response, then take that and put it right into jsonschema2pojo.com //If using jsonschema2pojo.com, select Target Langue = java, Source Type = JSON, Annotation Style = Gson - Movie movie = gson.fromJson(userJSON.toString(), Movie.class); + Movie2 movie = gson.fromJson(userJSON.toString(), Movie2.class); + String getTitleStr = ""; + String getOverviewStr = ""; + List getGenreStr = null; + Double getVoteNum = null; + List resultList = movie.getResults(); + for(int i = 0; i < resultList.size(); i++) { + Result r = resultList.get(i); + getTitleStr = r.getTitle(); + getOverviewStr = r.getOverview(); + getGenreStr = r.getGenreIds(); + getVoteNum = r.getVoteAverage(); + } //get the genre of movie (these are just java objects now) - List genreList = movie.getGenres(); - for (int i = 0; i < genreList.size(); i++) { - Genre g = genreList.get(i); - g.getName(); - } - - //get the title of the movie - String title = movie.getOriginalTitle(); - - //get the overview of the movie - String overview = movie.getOverview(); +// String getGenreName = ""; +// List genreList = movie.getGenres(); +// for (int i = 0; i < genreList.size(); i++) { +// Genre g = genreList.get(i); +// getGenreName = g.getName(); +// } +// +// //get the title of the movie +// String title = movie.getTitle(); +// +// //get the overview of the movie +// String overview = movie.getOverview(); //create the message - String message = "'" + title + "' is a " + genreList + ". Here is the overview: " + overview; + String message = "'" + getTitleStr + "' is in the genre " + genreMap.get(getGenreStr.get(0)) + ". " + + "Here is an overview of the movie: " + getOverviewStr + " " + " This movie got an average of " + getVoteNum + " votes."; //send the message return message; @@ -105,8 +169,9 @@ public String getMovie(String topic) { } catch (IOException e) { e.printStackTrace(); } - - return "No information found for: " + topic; + + //fix catch statement + return "No information found for: " + movieName; } } \ No newline at end of file diff --git a/src/main/java/org/jointheleague/modules/UnbeatableRockPaperScissors.java b/src/main/java/org/jointheleague/modules/UnbeatableRockPaperScissors.java index 0c80f0ca..f285296c 100644 --- a/src/main/java/org/jointheleague/modules/UnbeatableRockPaperScissors.java +++ b/src/main/java/org/jointheleague/modules/UnbeatableRockPaperScissors.java @@ -28,7 +28,7 @@ else if(cmd.equalsIgnoreCase("paper")) { else if(cmd.equalsIgnoreCase("scissors")) { event.getChannel().sendMessage("Rock"); }else { - event.getChannel().sendMessage("Invalid Command"); + //event.getChannel().sendMessage("Invalid Command"); } } diff --git a/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Genre.java b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Genre.java deleted file mode 100644 index 893b73c0..00000000 --- a/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Genre.java +++ /dev/null @@ -1,32 +0,0 @@ - -package org.jointheleague.modules.pojo.movieRecs.com.example; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Genre { - - @SerializedName("id") - @Expose - private Integer id; - @SerializedName("name") - @Expose - private String name; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - -} diff --git a/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Movie2.java b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Movie2.java new file mode 100644 index 00000000..47f5500c --- /dev/null +++ b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Movie2.java @@ -0,0 +1,55 @@ + +package org.jointheleague.modules.pojo.movieRecs.com.example; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Movie2 { + + @SerializedName("page") + @Expose + private Integer page; + @SerializedName("results") + @Expose + private List results = null; + @SerializedName("total_pages") + @Expose + private Integer totalPages; + @SerializedName("total_results") + @Expose + private Integer totalResults; + + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + this.page = page; + } + + public List getResults() { + return results; + } + + public void setResults(List results) { + this.results = results; + } + + public Integer getTotalPages() { + return totalPages; + } + + public void setTotalPages(Integer totalPages) { + this.totalPages = totalPages; + } + + public Integer getTotalResults() { + return totalResults; + } + + public void setTotalResults(Integer totalResults) { + this.totalResults = totalResults; + } + +} diff --git a/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/ProductionCompany.java b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/ProductionCompany.java deleted file mode 100644 index ee28757d..00000000 --- a/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/ProductionCompany.java +++ /dev/null @@ -1,54 +0,0 @@ - -package org.jointheleague.modules.pojo.movieRecs.com.example; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class ProductionCompany { - - @SerializedName("id") - @Expose - private Integer id; - @SerializedName("logo_path") - @Expose - private String logoPath; - @SerializedName("name") - @Expose - private String name; - @SerializedName("origin_country") - @Expose - private String originCountry; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getLogoPath() { - return logoPath; - } - - public void setLogoPath(String logoPath) { - this.logoPath = logoPath; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getOriginCountry() { - return originCountry; - } - - public void setOriginCountry(String originCountry) { - this.originCountry = originCountry; - } - -} diff --git a/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/ProductionCountry.java b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/ProductionCountry.java deleted file mode 100644 index 0e40fc53..00000000 --- a/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/ProductionCountry.java +++ /dev/null @@ -1,32 +0,0 @@ - -package org.jointheleague.modules.pojo.movieRecs.com.example; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class ProductionCountry { - - @SerializedName("iso_3166_1") - @Expose - private String iso31661; - @SerializedName("name") - @Expose - private String name; - - public String getIso31661() { - return iso31661; - } - - public void setIso31661(String iso31661) { - this.iso31661 = iso31661; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - -} diff --git a/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Movie.java b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Result.java similarity index 51% rename from src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Movie.java rename to src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Result.java index b6cbc101..6b2de8da 100644 --- a/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Movie.java +++ b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/Result.java @@ -5,7 +5,7 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; -public class Movie { +public class Result { @SerializedName("adult") @Expose @@ -13,24 +13,12 @@ public class Movie { @SerializedName("backdrop_path") @Expose private String backdropPath; - @SerializedName("belongs_to_collection") + @SerializedName("genre_ids") @Expose - private Object belongsToCollection; - @SerializedName("budget") - @Expose - private Integer budget; - @SerializedName("genres") - @Expose - private List genres = null; - @SerializedName("homepage") - @Expose - private String homepage; + private List genreIds = null; @SerializedName("id") @Expose private Integer id; - @SerializedName("imdb_id") - @Expose - private String imdbId; @SerializedName("original_language") @Expose private String originalLanguage; @@ -46,30 +34,9 @@ public class Movie { @SerializedName("poster_path") @Expose private String posterPath; - @SerializedName("production_companies") - @Expose - private List productionCompanies = null; - @SerializedName("production_countries") - @Expose - private List productionCountries = null; @SerializedName("release_date") @Expose private String releaseDate; - @SerializedName("revenue") - @Expose - private Integer revenue; - @SerializedName("runtime") - @Expose - private Integer runtime; - @SerializedName("spoken_languages") - @Expose - private List spokenLanguages = null; - @SerializedName("status") - @Expose - private String status; - @SerializedName("tagline") - @Expose - private String tagline; @SerializedName("title") @Expose private String title; @@ -99,36 +66,12 @@ public void setBackdropPath(String backdropPath) { this.backdropPath = backdropPath; } - public Object getBelongsToCollection() { - return belongsToCollection; - } - - public void setBelongsToCollection(Object belongsToCollection) { - this.belongsToCollection = belongsToCollection; - } - - public Integer getBudget() { - return budget; - } - - public void setBudget(Integer budget) { - this.budget = budget; - } - - public List getGenres() { - return genres; - } - - public void setGenres(List genres) { - this.genres = genres; + public List getGenreIds() { + return genreIds; } - public String getHomepage() { - return homepage; - } - - public void setHomepage(String homepage) { - this.homepage = homepage; + public void setGenreIds(List genreIds) { + this.genreIds = genreIds; } public Integer getId() { @@ -139,14 +82,6 @@ public void setId(Integer id) { this.id = id; } - public String getImdbId() { - return imdbId; - } - - public void setImdbId(String imdbId) { - this.imdbId = imdbId; - } - public String getOriginalLanguage() { return originalLanguage; } @@ -187,22 +122,6 @@ public void setPosterPath(String posterPath) { this.posterPath = posterPath; } - public List getProductionCompanies() { - return productionCompanies; - } - - public void setProductionCompanies(List productionCompanies) { - this.productionCompanies = productionCompanies; - } - - public List getProductionCountries() { - return productionCountries; - } - - public void setProductionCountries(List productionCountries) { - this.productionCountries = productionCountries; - } - public String getReleaseDate() { return releaseDate; } @@ -211,46 +130,6 @@ public void setReleaseDate(String releaseDate) { this.releaseDate = releaseDate; } - public Integer getRevenue() { - return revenue; - } - - public void setRevenue(Integer revenue) { - this.revenue = revenue; - } - - public Integer getRuntime() { - return runtime; - } - - public void setRuntime(Integer runtime) { - this.runtime = runtime; - } - - public List getSpokenLanguages() { - return spokenLanguages; - } - - public void setSpokenLanguages(List spokenLanguages) { - this.spokenLanguages = spokenLanguages; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getTagline() { - return tagline; - } - - public void setTagline(String tagline) { - this.tagline = tagline; - } - public String getTitle() { return title; } diff --git a/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/SpokenLanguage.java b/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/SpokenLanguage.java deleted file mode 100644 index dc1dc35c..00000000 --- a/src/main/java/org/jointheleague/modules/pojo/movieRecs/com/example/SpokenLanguage.java +++ /dev/null @@ -1,43 +0,0 @@ - -package org.jointheleague.modules.pojo.movieRecs.com.example; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class SpokenLanguage { - - @SerializedName("english_name") - @Expose - private String englishName; - @SerializedName("iso_639_1") - @Expose - private String iso6391; - @SerializedName("name") - @Expose - private String name; - - public String getEnglishName() { - return englishName; - } - - public void setEnglishName(String englishName) { - this.englishName = englishName; - } - - public String getIso6391() { - return iso6391; - } - - public void setIso6391(String iso6391) { - this.iso6391 = iso6391; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - -} From 4b4463b8cdc899309b11673dd4246c8a648bbd55 Mon Sep 17 00:00:00 2001 From: codeavenger1 Date: Mon, 15 Feb 2021 16:11:52 -0800 Subject: [PATCH 12/55] done --- .../modules/FilmRecommendations.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/FilmRecommendations.java b/src/main/java/org/jointheleague/modules/FilmRecommendations.java index e8e25660..a31f0178 100644 --- a/src/main/java/org/jointheleague/modules/FilmRecommendations.java +++ b/src/main/java/org/jointheleague/modules/FilmRecommendations.java @@ -132,12 +132,15 @@ public String getMovie(String movieName) { List getGenreStr = null; Double getVoteNum = null; List resultList = movie.getResults(); - for(int i = 0; i < resultList.size(); i++) { - Result r = resultList.get(i); + + if(resultList.size() > 0) { + Result r = resultList.get(0); getTitleStr = r.getTitle(); getOverviewStr = r.getOverview(); getGenreStr = r.getGenreIds(); getVoteNum = r.getVoteAverage(); + } else { + return "Please enter a movie."; } //get the genre of movie (these are just java objects now) @@ -155,7 +158,12 @@ public String getMovie(String movieName) { // String overview = movie.getOverview(); //create the message - String message = "'" + getTitleStr + "' is in the genre " + genreMap.get(getGenreStr.get(0)) + ". " + String genre = "*not found*"; + if(getGenreStr.size() > 0) { + genre = genreMap.get(getGenreStr.get(0)); + } + + String message = "'" + getTitleStr + "' is in the genre " + genre + ". " + "Here is an overview of the movie: " + getOverviewStr + " " + " This movie got an average of " + getVoteNum + " votes."; //send the message @@ -168,10 +176,10 @@ public String getMovie(String movieName) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); - } - + } //fix catch statement - return "No information found for: " + movieName; + return "No information found. Enter a different movie."; + } } \ No newline at end of file From 20dee6af20322ab026559682595ee7a4c6da1fad Mon Sep 17 00:00:00 2001 From: adrianolguin <33267387+adrianolguin@users.noreply.github.com> Date: Wed, 17 Feb 2021 18:27:17 -0800 Subject: [PATCH 13/55] Refactoring yay --- .../java/org/jointheleague/modules/Poll.java | 113 +++++++++++++----- 1 file changed, 81 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/Poll.java b/src/main/java/org/jointheleague/modules/Poll.java index feb8a232..f9fd78c1 100644 --- a/src/main/java/org/jointheleague/modules/Poll.java +++ b/src/main/java/org/jointheleague/modules/Poll.java @@ -1,20 +1,34 @@ package org.jointheleague.modules; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.time.LocalTime; +import java.time.temporal.ChronoField; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.ExecutionException; +import javax.swing.Timer; + +import org.javacord.api.entity.channel.TextChannel; +import org.javacord.api.entity.message.Message; import org.javacord.api.entity.message.MessageBuilder; +import org.javacord.api.entity.message.Reaction; import org.javacord.api.entity.message.embed.EmbedBuilder; import org.javacord.api.event.message.MessageCreateEvent; +import org.javacord.api.event.message.reaction.ReactionAddEvent; +import org.javacord.api.event.message.reaction.ReactionRemoveEvent; +import org.javacord.api.listener.message.reaction.ReactionAddListener; +import org.javacord.api.listener.message.reaction.ReactionRemoveListener; import net.aksingh.owmjapis.api.APIException; public class Poll extends CustomMessageCreateListener { - - ArrayList options; - - public static String pollOptionContent = ""; + public static String[] emoji = { "1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟" }; public static final String COMMAND = "!createPoll"; @@ -24,53 +38,88 @@ public Poll(String channelName) { @Override public void handle(MessageCreateEvent event) throws APIException { + if (event.getMessageContent().contains(COMMAND)) { - String parameters = event.getMessageContent().replace(COMMAND, ""); + String messageContent = event.getMessageContent().replace(COMMAND, ""); - System.out.println(parameters); + ArrayList parameters = getParameters(messageContent); - String timeParameter = parameters.substring(0, parameters.indexOf(',')); - parameters = parameters.substring(parameters.indexOf(',') + 1, parameters.length()); + String time = parameters.get(0); + parameters.remove(0); - System.out.println(timeParameter); + String title = parameters.get(0); + parameters.remove(0); + + String[] options = new String[parameters.size()]; + for (int i = 0; i < options.length; i++) { + options[i] = parameters.get(i); + } - String pollTitle = parameters.substring(0, parameters.indexOf(',')); - parameters = parameters.substring(parameters.indexOf(',') + 1, parameters.length()); + buildEmbed(title, options, event.getChannel()); - ArrayList optionInputs = new ArrayList(); + } - while (parameters != "") { - try { - optionInputs.add(parameters.substring(0, parameters.indexOf(','))); + } - parameters = parameters.substring(parameters.indexOf(',') + 1, parameters.length()); + private void buildEmbed(String title, String[] options, TextChannel channel) { + MessageBuilder mb = new MessageBuilder(); + EmbedBuilder eb = new EmbedBuilder(); - } catch (StringIndexOutOfBoundsException e) { - optionInputs.add(parameters.substring(0, parameters.length())); + eb.setTitle(title); - parameters = ""; + String optionString = ""; + for (String s : options) { + optionString += " " + s; + } - } - } + eb.setDescription(optionString); - System.out.println("List of options"); + mb.setEmbed(eb); - for (String s : optionInputs) { - pollOptionContent += s + "\n"; - } + mb.send(channel); + } + + private ArrayList getParameters(String message) { + String messageContent = message; + System.out.println("Message: " + messageContent); + + ArrayList group = new ArrayList(); + + String time = messageContent.substring(0, messageContent.indexOf(',') + 1); + messageContent = messageContent.replace(time, ""); + time = time.replace(",", "").trim(); + + String title = messageContent.substring(0, messageContent.indexOf(',') + 1); + messageContent = messageContent.replace(title, ""); + title = title.replace(",", "").trim(); -// for(int i = 0; i < optionInputs.size(); i++) { -// pollOptionContent += optionInputs.get(i); -// } + ArrayList options = new ArrayList(); - new MessageBuilder() - .setEmbed(new EmbedBuilder().setTitle(pollTitle).setDescription(pollOptionContent) - .setFooter("The poll will only be up for about ___ minutes/seconds")) - .send(event.getChannel()); + group.add(time); + group.add(title); + while (messageContent != "") { + String option = messageContent.substring(0, messageContent.indexOf(',') + 1); + messageContent = messageContent.replace(option, ""); + option = option.replace(",", "").trim(); + options.add(option); + + } + + for (String s : options) { + group.add(s); } + return group; + +// System.out.println("time: " + time); +// System.out.println("title: " + title); +// for (String s : options) { +// System.out.println("option: " + s); +// } +// System.out.println("final: " + messageContent); + } } From dd485674d90d1306a1607eab47659e1cdff673bc Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 21 Feb 2021 11:35:21 -0800 Subject: [PATCH 14/55] 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 15/55] 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 99c07d84a658448b3ae0d1a01e71ed364c075883 Mon Sep 17 00:00:00 2001 From: adrianolguin <33267387+adrianolguin@users.noreply.github.com> Date: Wed, 24 Feb 2021 18:29:10 -0800 Subject: [PATCH 16/55] Poll, percentages --- .../java/org/jointheleague/modules/Poll.java | 132 +++++++++++++----- 1 file changed, 96 insertions(+), 36 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/Poll.java b/src/main/java/org/jointheleague/modules/Poll.java index f9fd78c1..ef9fadd0 100644 --- a/src/main/java/org/jointheleague/modules/Poll.java +++ b/src/main/java/org/jointheleague/modules/Poll.java @@ -26,12 +26,14 @@ import net.aksingh.owmjapis.api.APIException; -public class Poll extends CustomMessageCreateListener { +public class Poll extends CustomMessageCreateListener implements ReactionAddListener { public static String[] emoji = { "1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟" }; public static final String COMMAND = "!createPoll"; - + + ArrayList votePercentages = new ArrayList(); + public Poll(String channelName) { super(channelName); } @@ -42,50 +44,72 @@ public void handle(MessageCreateEvent event) throws APIException { if (event.getMessageContent().contains(COMMAND)) { String messageContent = event.getMessageContent().replace(COMMAND, ""); + Parameters parameters = getParameters(messageContent); - ArrayList parameters = getParameters(messageContent); - - String time = parameters.get(0); - parameters.remove(0); + String time = parameters.time; + String title = parameters.title; + String[] options = parameters.options; - String title = parameters.get(0); - parameters.remove(0); + OptionContent[] oc = initializeOptions(options); - String[] options = new String[parameters.size()]; - for (int i = 0; i < options.length; i++) { - options[i] = parameters.get(i); - } + Message m = buildEmbed(title, oc, event.getChannel()); + handleReactions(m, options.length); + + } - buildEmbed(title, options, event.getChannel()); + } + private void handleReactions(Message m, int amount) { + for (int i = 0; i < amount; i++) { + m.addReaction(emoji[i]); } + + try { + Thread.sleep(6000); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + + m.addReactionRemoveListener(e -> calcVotePercentages(m, amount)); + m.addReactionAddListener(e -> calcVotePercentages(m, amount)); + } + private OptionContent[] initializeOptions(String[] options) { + OptionContent[] oc = new OptionContent[options.length]; + + for (int i = 0; i < options.length; i++) { + oc[i] = new OptionContent(emoji[i], options[i], "0%"); + } + return oc; } - private void buildEmbed(String title, String[] options, TextChannel channel) { + private Message buildEmbed(String title, OptionContent[] options, TextChannel channel) { MessageBuilder mb = new MessageBuilder(); EmbedBuilder eb = new EmbedBuilder(); eb.setTitle(title); + eb.setFooter("Testing what this does"); - String optionString = ""; - for (String s : options) { - optionString += " " + s; + String descriptionContent = ""; + for (OptionContent oc : options) { + descriptionContent += oc.toString() + "\n"; } - - eb.setDescription(optionString); + eb.setDescription(descriptionContent); mb.setEmbed(eb); - - mb.send(channel); + Message m = null; + try { + m = mb.send(channel).get(); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + return m; } - private ArrayList getParameters(String message) { + private Parameters getParameters(String message) { String messageContent = message; System.out.println("Message: " + messageContent); - ArrayList group = new ArrayList(); - String time = messageContent.substring(0, messageContent.indexOf(',') + 1); messageContent = messageContent.replace(time, ""); time = time.replace(",", "").trim(); @@ -96,9 +120,6 @@ private ArrayList getParameters(String message) { ArrayList options = new ArrayList(); - group.add(time); - group.add(title); - while (messageContent != "") { String option = messageContent.substring(0, messageContent.indexOf(',') + 1); messageContent = messageContent.replace(option, ""); @@ -107,19 +128,58 @@ private ArrayList getParameters(String message) { } - for (String s : options) { - group.add(s); + Parameters p = new Parameters(time, title, options.toArray(new String[options.size()])); + + return p; + } + + @Override + public void onReactionAdd(ReactionAddEvent event) { + + } + + private void calcVotePercentages(Message m, int amount) { + List l = m.getReactions(); + int totalVotes = 0; + + for (int i = 0; i < amount; i++) { + totalVotes += l.get(i).getCount() - 1; } + for (int i = 0; i < amount; i++) { + int percentage = 100 * (l.get(i).getCount() - 1) / totalVotes; + votePercentages.add(percentage); + } + } - return group; +} -// System.out.println("time: " + time); -// System.out.println("title: " + title); -// for (String s : options) { -// System.out.println("option: " + s); -// } -// System.out.println("final: " + messageContent); +class Parameters { + String time; + String title; + String[] options; + Parameters(String time, String title, String[] options) { + this.time = time; + this.title = title; + this.options = options; + } + +} + +class OptionContent { + String emoji; + String option; + String percentage; + + OptionContent(String emoji, String option, String percentage) { + this.emoji = emoji; + this.option = option; + this.percentage = percentage; + } + + @Override + public String toString() { + return emoji + " " + option + " " + percentage; } } From f657d78dfe05d784a469e2fd47a3f2ad84ecdbbb Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sat, 27 Feb 2021 11:58:57 -0800 Subject: [PATCH 17/55] 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: Wed, 10 Mar 2021 17:14:47 -0800 Subject: [PATCH 18/55] poll finished --- .../java/org/jointheleague/modules/Poll.java | 130 ++++++++++++++---- 1 file changed, 101 insertions(+), 29 deletions(-) diff --git a/src/main/java/org/jointheleague/modules/Poll.java b/src/main/java/org/jointheleague/modules/Poll.java index ef9fadd0..531b360a 100644 --- a/src/main/java/org/jointheleague/modules/Poll.java +++ b/src/main/java/org/jointheleague/modules/Poll.java @@ -12,11 +12,13 @@ import java.util.concurrent.ExecutionException; import javax.swing.Timer; +import javax.swing.plaf.metal.OceanTheme; import org.javacord.api.entity.channel.TextChannel; import org.javacord.api.entity.message.Message; import org.javacord.api.entity.message.MessageBuilder; import org.javacord.api.entity.message.Reaction; +import org.javacord.api.entity.message.embed.Embed; import org.javacord.api.entity.message.embed.EmbedBuilder; import org.javacord.api.event.message.MessageCreateEvent; import org.javacord.api.event.message.reaction.ReactionAddEvent; @@ -24,6 +26,7 @@ import org.javacord.api.listener.message.reaction.ReactionAddListener; import org.javacord.api.listener.message.reaction.ReactionRemoveListener; +import javassist.compiler.MemberCodeGen; import net.aksingh.owmjapis.api.APIException; public class Poll extends CustomMessageCreateListener implements ReactionAddListener { @@ -31,9 +34,9 @@ public class Poll extends CustomMessageCreateListener implements ReactionAddList public static String[] emoji = { "1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟" }; public static final String COMMAND = "!createPoll"; - - ArrayList votePercentages = new ArrayList(); - + + boolean pollUp = false; + public Poll(String channelName) { super(channelName); } @@ -50,35 +53,116 @@ public void handle(MessageCreateEvent event) throws APIException { String title = parameters.title; String[] options = parameters.options; - OptionContent[] oc = initializeOptions(options); + OptionContent[] oc = initializeOptions(options, null); Message m = buildEmbed(title, oc, event.getChannel()); handleReactions(m, options.length); - + + createTimer(time, m); + + try { + Thread.sleep(6000); + } catch (Exception e) { + e.printStackTrace(); + } + + m.addReactionRemoveListener(e -> votePercentages(m, options)); + m.addReactionAddListener(e -> votePercentages(m, options)); + + pollUp = true; + + } + + } + + private void createTimer(String timeParameter, Message m) { + + String measure = timeParameter.substring(timeParameter.indexOf(' ') + 1, timeParameter.length()); + String amount = timeParameter.substring(0, timeParameter.indexOf(' ')); + + int duration = 0; + + if (measure.equals("hours") || measure.equals("hour")) { + duration = Integer.parseInt(amount) * 60 * 60; + + } else if (measure.equals("minutes") || measure.equals("minute")) { + duration = Integer.parseInt(amount) * 60; + + } else if (measure.equals("seconds") || measure.equals("second")) { + duration = Integer.parseInt(amount); + } + Timer timer = new Timer(duration * 1000, e -> { + pollUp = false; + + String title = m.getEmbeds().get(0).getTitle().get(); + String footer = m.getEmbeds().get(0).getFooter().get().getText().get() + "\n(POLL HAS ENDED)\n"; + String description = m.getEmbeds().get(0).getDescription().get(); + + EmbedBuilder eb = new EmbedBuilder().setTitle(title).setDescription(description).setFooter(footer); + + m.edit(eb); + }); + + timer.setRepeats(false); + timer.start(); + } + + private void votePercentages(Message m, String[] options) { + if (pollUp) { + List reactionList = m.getReactions(); + + int[] percentages = new int[options.length]; + + int totalVotes = 0; + + for (int i = 0; i < options.length; i++) { + totalVotes += reactionList.get(i).getCount() - 1; + } + + for (int i = 0; i < options.length; i++) { + int percentage = 0; + try { + percentage = (reactionList.get(i).getCount() - 1) * (100 / totalVotes); + } catch (Exception e) { + e.getStackTrace(); + } + percentages[i] = percentage; + } + + OptionContent[] oc = initializeOptions(options, percentages); + + String descriptionContent = ""; + + for (OptionContent c : oc) { + descriptionContent += c.toString() + "\n"; + } + + String title = m.getEmbeds().get(0).getTitle().get(); + String footer = m.getEmbeds().get(0).getFooter().get().getText().get(); + + m.edit(new EmbedBuilder().setTitle(title).setDescription(descriptionContent).setFooter(footer)); + } } private void handleReactions(Message m, int amount) { for (int i = 0; i < amount; i++) { m.addReaction(emoji[i]); } - - try { - Thread.sleep(6000); - } catch (InterruptedException e1) { - e1.printStackTrace(); - } - - m.addReactionRemoveListener(e -> calcVotePercentages(m, amount)); - m.addReactionAddListener(e -> calcVotePercentages(m, amount)); } - private OptionContent[] initializeOptions(String[] options) { + private OptionContent[] initializeOptions(String[] options, int[] percentages) { OptionContent[] oc = new OptionContent[options.length]; + String percent = " 0%"; + for (int i = 0; i < options.length; i++) { - oc[i] = new OptionContent(emoji[i], options[i], "0%"); + if (percentages != null) { + percent = " " + percentages[i] + "%"; + } + + oc[i] = new OptionContent(emoji[i], options[i], percent); } return oc; } @@ -98,6 +182,7 @@ private Message buildEmbed(String title, OptionContent[] options, TextChannel ch mb.setEmbed(eb); Message m = null; + try { m = mb.send(channel).get(); } catch (InterruptedException | ExecutionException e) { @@ -138,19 +223,6 @@ public void onReactionAdd(ReactionAddEvent event) { } - private void calcVotePercentages(Message m, int amount) { - List l = m.getReactions(); - int totalVotes = 0; - - for (int i = 0; i < amount; i++) { - totalVotes += l.get(i).getCount() - 1; - } - for (int i = 0; i < amount; i++) { - int percentage = 100 * (l.get(i).getCount() - 1) / totalVotes; - votePercentages.add(percentage); - } - } - } class Parameters { From ec631a36aa1a2b061ed0e6f87ea81e7051bbacdf Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sat, 13 Mar 2021 11:58:26 -0800 Subject: [PATCH 19/55] 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 20/55] 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 21/55] 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 2425f324b42f0cd1d63d91e9b3b9a3436a39f42e Mon Sep 17 00:00:00 2001 From: adrianolguin <33267387+adrianolguin@users.noreply.github.com> Date: Wed, 17 Mar 2021 18:01:01 -0700 Subject: [PATCH 22/55] Fixing my branches :p --- .../discord_bot_example/Bot.java | 355 +++++++++--------- .../java/org/jointheleague/modules/Poll.java | 257 ------------- .../org/jointheleague/modules/Reminder.java | 135 ------- 3 files changed, 175 insertions(+), 572 deletions(-) delete mode 100644 src/main/java/org/jointheleague/modules/Poll.java delete mode 100644 src/main/java/org/jointheleague/modules/Reminder.java 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 8499b987..28e20348 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -1,180 +1,175 @@ -package org.jointheleague.discord_bot_example; - -import org.javacord.api.DiscordApi; - -import org.javacord.api.DiscordApiBuilder; - -/** - * Launches all of the listeners for one channel. - * @author keithgroves and https://tinystripz.com - * - */ -import org.jointheleague.modules.*; - - - -public class Bot { - - // The string to show the custom :vomiting_robot: emoji - public static String emoji = "<:vomiting_robot:642414033290657803>"; - - private String token; - private String channelName; - DiscordApi api; - _HelpListener helpListener; - - public Bot(String token, String channelName) { - this.token = token; - this.channelName = channelName; - helpListener = new _HelpListener(channelName); - } - - public void connect(boolean printInvite) { - - api = new DiscordApiBuilder().setToken(token).login().join(); - - // Print the URL to invite the bot - if (printInvite) { - System.out.println("You can invite the bot by using the following url: " + api.createBotInvite()); - } - - api.getServerTextChannelsByName(channelName).forEach(e -> e.sendMessage("Bot Connected")); - - //add Listeners - DiscordLibrary dl = new DiscordLibrary(channelName); - api.addMessageCreateListener(dl); - helpListener.addHelpEmbed(dl.getHelpEmbed()); - - CurrencyConverter cc = new CurrencyConverter(channelName); - api.addMessageCreateListener(cc); - helpListener.addHelpEmbed(cc.getHelpEmbed()); - - ToDoList list = new ToDoList(channelName); - api.addMessageCreateListener(list); - helpListener.addHelpEmbed(list.getHelpEmbed()); - - HeadlineListener head = new HeadlineListener(channelName); - api.addMessageCreateListener(head); - helpListener.addHelpEmbed(head.getHelpEmbed()); - - RandomNumber randomNumber = new RandomNumber(channelName); //replace with feature class later - api.addMessageCreateListener(randomNumber); - helpListener.addHelpEmbed(randomNumber.getHelpEmbed()); - - HypeMachine hypeMachine = new HypeMachine(channelName); - api.addMessageCreateListener(hypeMachine); - helpListener.addHelpEmbed(hypeMachine.getHelpEmbed()); - - TextStyler textStyler = new TextStyler(channelName); - api.addMessageCreateListener(textStyler); - helpListener.addHelpEmbed(textStyler.getHelpEmbed()); - - Tomagachi tomagachi = new Tomagachi(channelName); - api.addMessageCreateListener(tomagachi); - helpListener.addHelpEmbed(tomagachi.getHelpEmbed()); - - SetProfilePic setPFP = new SetProfilePic(channelName); - api.addMessageCreateListener(setPFP); - helpListener.addHelpEmbed(setPFP.getHelpEmbed()); - - ToGif toGif = new ToGif(channelName); - api.addMessageCreateListener(toGif); - helpListener.addHelpEmbed(toGif.getHelpEmbed()); - - RandomCase randomCase = new RandomCase(channelName); - api.addMessageCreateListener(randomCase); - helpListener.addHelpEmbed(randomCase.getHelpEmbed()); - - _ApiExampleListener apiExampleListener = new _ApiExampleListener(channelName); - api.addMessageCreateListener(apiExampleListener); - helpListener.addHelpEmbed(apiExampleListener.getHelpEmbed()); - - NewWeather newWeather = new NewWeather(channelName); - api.addMessageCreateListener(newWeather); - helpListener.addHelpEmbed(newWeather.getHelpEmbed()); - - CoinFlip cp = new CoinFlip(channelName); - api.addMessageCreateListener(cp); - - RollDie rollDie = new RollDie(channelName); - api.addMessageCreateListener(rollDie); - - - MaxTicTacToe mttt = new MaxTicTacToe(channelName); - api.addMessageCreateListener(mttt); - helpListener.addHelpEmbed(mttt.getHelpEmbed()); - - pythagcalc pythagCalc = new pythagcalc(channelName); - api.addMessageCreateListener(pythagCalc); - helpListener.addHelpEmbed(pythagCalc.getHelpEmbed()); - - //Greeter g = new Greeter(channelName); - //api.addMessageCreateListener(g); - //helpListener.addHelpEmbed(g.getHelpEmbed()); - - CovidCaseGetter covid = new CovidCaseGetter(channelName); - api.addMessageCreateListener(covid); - helpListener.addHelpEmbed(covid.getHelpEmbed()); - - ListMakerMessageListener LM = new ListMakerMessageListener(channelName); - api.addMessageCreateListener(LM); - helpListener.addHelpEmbed(LM.getHelpEmbed()); - - Dice d = new Dice(channelName); - api.addMessageCreateListener(d); - helpListener.addHelpEmbed(d.getHelpEmbed()); - - UnbeatableRockPaperScissors rps = new UnbeatableRockPaperScissors(channelName); - api.addMessageCreateListener(rps); - helpListener.addHelpEmbed(rps.getHelpEmbed()); - - //old way to add listeners - api.addMessageCreateListener(helpListener); - api.addMessageCreateListener(new MomBot(channelName)); - api.addMessageCreateListener(new DadJokes(channelName)); - api.addMessageCreateListener(new ClockMessageListener(channelName)); - api.addMessageCreateListener(new CalculatorMessageListener(channelName)); - api.addMessageCreateListener(new ComicMessageListener(channelName)); - api.addMessageCreateListener(new ElmoMessageListener(channelName)); - api.addMessageCreateListener(new FactMessageListener(channelName)); - api.addMessageCreateListener(new CasinoGameListener(channelName)); - api.addMessageCreateListener(new HighLowListener(channelName)); - api.addMessageCreateListener(new Ryland(channelName)); - api.addMessageCreateListener(new RockPaperScissorsListener(channelName)); - api.addMessageCreateListener(new leetMessageListener(channelName)); - api.addMessageCreateListener(new ConnectFour(channelName)); - api.addMessageCreateListener(new FlagMessageListener(channelName)); - api.addMessageCreateListener(new EightBall(channelName)); - api.addMessageCreateListener(new Reddit(channelName)); - api.addMessageCreateListener(new DeepFrier(channelName)); - api.addMessageCreateListener(new PictureOf(channelName)); - api.addMessageCreateListener(new GetPicture(channelName)); - api.addMessageCreateListener(new CuteAnimal(channelName)); - api.addMessageCreateListener(new Weather(channelName)); - api.addMessageCreateListener(new FashionAdvisor(channelName)); - api.addMessageCreateListener(new LatexRender(channelName)); - api.addMessageCreateListener(new MinesweeperListener(channelName)); - api.addMessageCreateListener(new Bot1Listener(channelName)); - api.addMessageCreateListener(new PingMessageListener(channelName)); - api.addMessageCreateListener(new CoinFlipMessageListener(channelName)); - api.addMessageCreateListener(new PlayRPSMessageListener(channelName)); - api.addMessageCreateListener(new KickMessageListener(channelName)); - api.addMessageCreateListener(new AssignRoleMessageListener(channelName)); - api.addMessageCreateListener(new NicknameListener(channelName)); - api.addMessageCreateListener(new SolveQuadraticListener(channelName)); - api.addMessageCreateListener(new RollDiceMessageListener(channelName)); - api.addMessageCreateListener(new MorseTranslator(channelName)); - api.addMessageCreateListener(new HangmanListener(channelName)); - api.addMessageCreateListener(new BogoSorterListener(channelName)); - api.addMessageCreateListener(new ComplimentListener(channelName)); - api.addMessageCreateListener(new CrazyEights(channelName)); - api.addMessageCreateListener(new Blackjack(channelName)); - api.addMessageCreateListener(new RandomCase(channelName)); - api.addMessageCreateListener(new GetTime(channelName)); - api.addMessageCreateListener(new ScreenCapture(channelName)); - - api.addMessageCreateListener(new Hello(channelName)); - api.addMessageCreateListener(new Reminder(channelName)); - api.addMessageCreateListener(new Poll(channelName)); - } -} +package org.jointheleague.discord_bot_example; + +import org.javacord.api.DiscordApi; + +import org.javacord.api.DiscordApiBuilder; + +/** + * Launches all of the listeners for one channel. + * @author keithgroves and https://tinystripz.com + * + */ +import org.jointheleague.modules.*; + +public class Bot { + + // The string to show the custom :vomiting_robot: emoji + public static String emoji = "<:vomiting_robot:642414033290657803>"; + + private String token; + private String channelName; + DiscordApi api; + _HelpListener helpListener; + + public Bot(String token, String channelName) { + this.token = token; + this.channelName = channelName; + helpListener = new _HelpListener(channelName); + } + + public void connect(boolean printInvite) { + + api = new DiscordApiBuilder().setToken(token).login().join(); + + // Print the URL to invite the bot + if (printInvite) { + System.out.println("You can invite the bot by using the following url: " + api.createBotInvite()); + } + + api.getServerTextChannelsByName(channelName).forEach(e -> e.sendMessage("Bot Connected")); + + // add Listeners + DiscordLibrary dl = new DiscordLibrary(channelName); + api.addMessageCreateListener(dl); + helpListener.addHelpEmbed(dl.getHelpEmbed()); + + CurrencyConverter cc = new CurrencyConverter(channelName); + api.addMessageCreateListener(cc); + helpListener.addHelpEmbed(cc.getHelpEmbed()); + + ToDoList list = new ToDoList(channelName); + api.addMessageCreateListener(list); + helpListener.addHelpEmbed(list.getHelpEmbed()); + + HeadlineListener head = new HeadlineListener(channelName); + api.addMessageCreateListener(head); + helpListener.addHelpEmbed(head.getHelpEmbed()); + + RandomNumber randomNumber = new RandomNumber(channelName); // replace with feature class later + api.addMessageCreateListener(randomNumber); + helpListener.addHelpEmbed(randomNumber.getHelpEmbed()); + + HypeMachine hypeMachine = new HypeMachine(channelName); + api.addMessageCreateListener(hypeMachine); + helpListener.addHelpEmbed(hypeMachine.getHelpEmbed()); + + TextStyler textStyler = new TextStyler(channelName); + api.addMessageCreateListener(textStyler); + helpListener.addHelpEmbed(textStyler.getHelpEmbed()); + + Tomagachi tomagachi = new Tomagachi(channelName); + api.addMessageCreateListener(tomagachi); + helpListener.addHelpEmbed(tomagachi.getHelpEmbed()); + + SetProfilePic setPFP = new SetProfilePic(channelName); + api.addMessageCreateListener(setPFP); + helpListener.addHelpEmbed(setPFP.getHelpEmbed()); + + ToGif toGif = new ToGif(channelName); + api.addMessageCreateListener(toGif); + helpListener.addHelpEmbed(toGif.getHelpEmbed()); + + RandomCase randomCase = new RandomCase(channelName); + api.addMessageCreateListener(randomCase); + helpListener.addHelpEmbed(randomCase.getHelpEmbed()); + + _ApiExampleListener apiExampleListener = new _ApiExampleListener(channelName); + api.addMessageCreateListener(apiExampleListener); + helpListener.addHelpEmbed(apiExampleListener.getHelpEmbed()); + + NewWeather newWeather = new NewWeather(channelName); + api.addMessageCreateListener(newWeather); + helpListener.addHelpEmbed(newWeather.getHelpEmbed()); + + CoinFlip cp = new CoinFlip(channelName); + api.addMessageCreateListener(cp); + + RollDie rollDie = new RollDie(channelName); + api.addMessageCreateListener(rollDie); + + MaxTicTacToe mttt = new MaxTicTacToe(channelName); + api.addMessageCreateListener(mttt); + helpListener.addHelpEmbed(mttt.getHelpEmbed()); + + pythagcalc pythagCalc = new pythagcalc(channelName); + api.addMessageCreateListener(pythagCalc); + helpListener.addHelpEmbed(pythagCalc.getHelpEmbed()); + + // Greeter g = new Greeter(channelName); + // api.addMessageCreateListener(g); + // helpListener.addHelpEmbed(g.getHelpEmbed()); + + CovidCaseGetter covid = new CovidCaseGetter(channelName); + api.addMessageCreateListener(covid); + helpListener.addHelpEmbed(covid.getHelpEmbed()); + + ListMakerMessageListener LM = new ListMakerMessageListener(channelName); + api.addMessageCreateListener(LM); + helpListener.addHelpEmbed(LM.getHelpEmbed()); + + Dice d = new Dice(channelName); + api.addMessageCreateListener(d); + helpListener.addHelpEmbed(d.getHelpEmbed()); + + UnbeatableRockPaperScissors rps = new UnbeatableRockPaperScissors(channelName); + api.addMessageCreateListener(rps); + helpListener.addHelpEmbed(rps.getHelpEmbed()); + + // old way to add listeners + api.addMessageCreateListener(helpListener); + api.addMessageCreateListener(new MomBot(channelName)); + api.addMessageCreateListener(new DadJokes(channelName)); + api.addMessageCreateListener(new ClockMessageListener(channelName)); + api.addMessageCreateListener(new CalculatorMessageListener(channelName)); + api.addMessageCreateListener(new ComicMessageListener(channelName)); + api.addMessageCreateListener(new ElmoMessageListener(channelName)); + api.addMessageCreateListener(new FactMessageListener(channelName)); + api.addMessageCreateListener(new CasinoGameListener(channelName)); + api.addMessageCreateListener(new HighLowListener(channelName)); + api.addMessageCreateListener(new Ryland(channelName)); + api.addMessageCreateListener(new RockPaperScissorsListener(channelName)); + api.addMessageCreateListener(new leetMessageListener(channelName)); + api.addMessageCreateListener(new ConnectFour(channelName)); + api.addMessageCreateListener(new FlagMessageListener(channelName)); + api.addMessageCreateListener(new EightBall(channelName)); + api.addMessageCreateListener(new Reddit(channelName)); + api.addMessageCreateListener(new DeepFrier(channelName)); + api.addMessageCreateListener(new PictureOf(channelName)); + api.addMessageCreateListener(new GetPicture(channelName)); + api.addMessageCreateListener(new CuteAnimal(channelName)); + api.addMessageCreateListener(new Weather(channelName)); + api.addMessageCreateListener(new FashionAdvisor(channelName)); + api.addMessageCreateListener(new LatexRender(channelName)); + api.addMessageCreateListener(new MinesweeperListener(channelName)); + api.addMessageCreateListener(new Bot1Listener(channelName)); + api.addMessageCreateListener(new PingMessageListener(channelName)); + api.addMessageCreateListener(new CoinFlipMessageListener(channelName)); + api.addMessageCreateListener(new PlayRPSMessageListener(channelName)); + api.addMessageCreateListener(new KickMessageListener(channelName)); + api.addMessageCreateListener(new AssignRoleMessageListener(channelName)); + api.addMessageCreateListener(new NicknameListener(channelName)); + api.addMessageCreateListener(new SolveQuadraticListener(channelName)); + api.addMessageCreateListener(new RollDiceMessageListener(channelName)); + api.addMessageCreateListener(new MorseTranslator(channelName)); + api.addMessageCreateListener(new HangmanListener(channelName)); + api.addMessageCreateListener(new BogoSorterListener(channelName)); + api.addMessageCreateListener(new ComplimentListener(channelName)); + api.addMessageCreateListener(new CrazyEights(channelName)); + api.addMessageCreateListener(new Blackjack(channelName)); + api.addMessageCreateListener(new RandomCase(channelName)); + api.addMessageCreateListener(new GetTime(channelName)); + api.addMessageCreateListener(new ScreenCapture(channelName)); + + api.addMessageCreateListener(new Hello(channelName)); + } +} diff --git a/src/main/java/org/jointheleague/modules/Poll.java b/src/main/java/org/jointheleague/modules/Poll.java deleted file mode 100644 index 531b360a..00000000 --- a/src/main/java/org/jointheleague/modules/Poll.java +++ /dev/null @@ -1,257 +0,0 @@ -package org.jointheleague.modules; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.time.LocalTime; -import java.time.temporal.ChronoField; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.ExecutionException; - -import javax.swing.Timer; -import javax.swing.plaf.metal.OceanTheme; - -import org.javacord.api.entity.channel.TextChannel; -import org.javacord.api.entity.message.Message; -import org.javacord.api.entity.message.MessageBuilder; -import org.javacord.api.entity.message.Reaction; -import org.javacord.api.entity.message.embed.Embed; -import org.javacord.api.entity.message.embed.EmbedBuilder; -import org.javacord.api.event.message.MessageCreateEvent; -import org.javacord.api.event.message.reaction.ReactionAddEvent; -import org.javacord.api.event.message.reaction.ReactionRemoveEvent; -import org.javacord.api.listener.message.reaction.ReactionAddListener; -import org.javacord.api.listener.message.reaction.ReactionRemoveListener; - -import javassist.compiler.MemberCodeGen; -import net.aksingh.owmjapis.api.APIException; - -public class Poll extends CustomMessageCreateListener implements ReactionAddListener { - - public static String[] emoji = { "1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟" }; - - public static final String COMMAND = "!createPoll"; - - boolean pollUp = false; - - public Poll(String channelName) { - super(channelName); - } - - @Override - public void handle(MessageCreateEvent event) throws APIException { - - if (event.getMessageContent().contains(COMMAND)) { - - String messageContent = event.getMessageContent().replace(COMMAND, ""); - Parameters parameters = getParameters(messageContent); - - String time = parameters.time; - String title = parameters.title; - String[] options = parameters.options; - - OptionContent[] oc = initializeOptions(options, null); - - Message m = buildEmbed(title, oc, event.getChannel()); - handleReactions(m, options.length); - - createTimer(time, m); - - try { - Thread.sleep(6000); - } catch (Exception e) { - e.printStackTrace(); - } - - m.addReactionRemoveListener(e -> votePercentages(m, options)); - m.addReactionAddListener(e -> votePercentages(m, options)); - - pollUp = true; - - } - - } - - private void createTimer(String timeParameter, Message m) { - - String measure = timeParameter.substring(timeParameter.indexOf(' ') + 1, timeParameter.length()); - String amount = timeParameter.substring(0, timeParameter.indexOf(' ')); - - int duration = 0; - - if (measure.equals("hours") || measure.equals("hour")) { - duration = Integer.parseInt(amount) * 60 * 60; - - } else if (measure.equals("minutes") || measure.equals("minute")) { - duration = Integer.parseInt(amount) * 60; - - } else if (measure.equals("seconds") || measure.equals("second")) { - duration = Integer.parseInt(amount); - - } - - Timer timer = new Timer(duration * 1000, e -> { - pollUp = false; - - String title = m.getEmbeds().get(0).getTitle().get(); - String footer = m.getEmbeds().get(0).getFooter().get().getText().get() + "\n(POLL HAS ENDED)\n"; - String description = m.getEmbeds().get(0).getDescription().get(); - - EmbedBuilder eb = new EmbedBuilder().setTitle(title).setDescription(description).setFooter(footer); - - m.edit(eb); - }); - - timer.setRepeats(false); - timer.start(); - } - - private void votePercentages(Message m, String[] options) { - if (pollUp) { - List reactionList = m.getReactions(); - - int[] percentages = new int[options.length]; - - int totalVotes = 0; - - for (int i = 0; i < options.length; i++) { - totalVotes += reactionList.get(i).getCount() - 1; - } - - for (int i = 0; i < options.length; i++) { - int percentage = 0; - try { - percentage = (reactionList.get(i).getCount() - 1) * (100 / totalVotes); - } catch (Exception e) { - e.getStackTrace(); - } - percentages[i] = percentage; - } - - OptionContent[] oc = initializeOptions(options, percentages); - - String descriptionContent = ""; - - for (OptionContent c : oc) { - descriptionContent += c.toString() + "\n"; - } - - String title = m.getEmbeds().get(0).getTitle().get(); - String footer = m.getEmbeds().get(0).getFooter().get().getText().get(); - - m.edit(new EmbedBuilder().setTitle(title).setDescription(descriptionContent).setFooter(footer)); - } - } - - private void handleReactions(Message m, int amount) { - for (int i = 0; i < amount; i++) { - m.addReaction(emoji[i]); - } - } - - private OptionContent[] initializeOptions(String[] options, int[] percentages) { - OptionContent[] oc = new OptionContent[options.length]; - - String percent = " 0%"; - - for (int i = 0; i < options.length; i++) { - if (percentages != null) { - percent = " " + percentages[i] + "%"; - } - - oc[i] = new OptionContent(emoji[i], options[i], percent); - } - return oc; - } - - private Message buildEmbed(String title, OptionContent[] options, TextChannel channel) { - MessageBuilder mb = new MessageBuilder(); - EmbedBuilder eb = new EmbedBuilder(); - - eb.setTitle(title); - eb.setFooter("Testing what this does"); - - String descriptionContent = ""; - for (OptionContent oc : options) { - descriptionContent += oc.toString() + "\n"; - } - eb.setDescription(descriptionContent); - - mb.setEmbed(eb); - Message m = null; - - try { - m = mb.send(channel).get(); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - return m; - } - - private Parameters getParameters(String message) { - String messageContent = message; - System.out.println("Message: " + messageContent); - - String time = messageContent.substring(0, messageContent.indexOf(',') + 1); - messageContent = messageContent.replace(time, ""); - time = time.replace(",", "").trim(); - - String title = messageContent.substring(0, messageContent.indexOf(',') + 1); - messageContent = messageContent.replace(title, ""); - title = title.replace(",", "").trim(); - - ArrayList options = new ArrayList(); - - while (messageContent != "") { - String option = messageContent.substring(0, messageContent.indexOf(',') + 1); - messageContent = messageContent.replace(option, ""); - option = option.replace(",", "").trim(); - options.add(option); - - } - - Parameters p = new Parameters(time, title, options.toArray(new String[options.size()])); - - return p; - } - - @Override - public void onReactionAdd(ReactionAddEvent event) { - - } - -} - -class Parameters { - String time; - String title; - String[] options; - - Parameters(String time, String title, String[] options) { - this.time = time; - this.title = title; - this.options = options; - } - -} - -class OptionContent { - String emoji; - String option; - String percentage; - - OptionContent(String emoji, String option, String percentage) { - this.emoji = emoji; - this.option = option; - this.percentage = percentage; - } - - @Override - public String toString() { - return emoji + " " + option + " " + percentage; - } - -} diff --git a/src/main/java/org/jointheleague/modules/Reminder.java b/src/main/java/org/jointheleague/modules/Reminder.java deleted file mode 100644 index a0cb2081..00000000 --- a/src/main/java/org/jointheleague/modules/Reminder.java +++ /dev/null @@ -1,135 +0,0 @@ -package org.jointheleague.modules; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.time.LocalTime; -import java.time.temporal.ChronoField; -import java.util.ArrayList; -import javax.swing.Timer; -import org.javacord.api.entity.channel.TextChannel; -import org.javacord.api.entity.message.MessageBuilder; -import org.javacord.api.entity.message.embed.EmbedBuilder; -import org.javacord.api.event.message.MessageCreateEvent; -import org.javacord.api.listener.message.MessageCreateListener; - -import net.aksingh.owmjapis.api.APIException; - -public class Reminder extends CustomMessageCreateListener implements ActionListener { - - ArrayList userNames = new ArrayList(); - ArrayList messages = new ArrayList(); - ArrayList channelNames = new ArrayList(); - ArrayList timers = new ArrayList(); - - public static final String REMIND_COMMAND = "!setReminder"; - public static final String HELP_COMMAND = "!setReminderHelp"; - - public Reminder(String channelName) { - super(channelName); - - } - - @Override - public void handle(MessageCreateEvent event) throws APIException { - - if (event.getMessageContent().contains(HELP_COMMAND)) { - - //event.get - - new MessageBuilder().setEmbed(new EmbedBuilder().setTitle( - "To use this command first type the '!setReminder' command, followed by the time you want to be reminded (In Military Time), a comma, then your remind message") - .setDescription("P.S. Make sure when you input your time use a colon between the hours and minutes") - .setFooter("")).send(event.getChannel()); - - } else if (event.getMessageContent().contains(REMIND_COMMAND)) { - - // add use to the arraylist - String user = event.getMessageAuthor().getIdAsString(); - userNames.add(user); - - // add the channel to the arraylist - TextChannel txtChannel = event.getChannel(); - channelNames.add(txtChannel); - - String parameters = event.getMessageContent().replace(REMIND_COMMAND, ""); - - if (parameters.equals("")) { - event.getChannel().sendMessage("Invalid Input"); - } - - String timeParameter = ""; - - try { - // get the raw timeParameter, fix it later - timeParameter = parameters.substring(0, parameters.indexOf(',')); - - parameters = parameters.substring(parameters.indexOf(',') + 1, parameters.length()); - } catch (StringIndexOutOfBoundsException e) { - // This catches if there is no comma, which probably means there is no message - // so I set that to an empty string - - timeParameter = parameters.substring(0, parameters.length()); - - parameters = ""; - - } - - // get the raw messageParameter, no need to fix it and I add it to the arrayList - // immediately - String messageParameter = parameters.substring(0, parameters.length()); - messages.add(messageParameter); - - // all this is fixing the raw timeParameter so I can parse it to the LocalTime - // class and compare in to the current time - timeParameter = timeParameter.replaceAll(" ", ""); - - int count = timeParameter.length() - timeParameter.replaceAll(":", "").length(); - if (count == 1) { - timeParameter += ":00"; - } - - // parse fixed timeParameter to LocalTime class and get the current local time - LocalTime time = LocalTime.parse(timeParameter); - LocalTime currentTime = LocalTime.now(); - - // using LocalTime class functions, find the time until the user needs to be - // reminded, in seconds - // what the heck is a chronofield - int timeUntil = (int) (time.getLong(ChronoField.SECOND_OF_DAY) - - currentTime.getLong(ChronoField.SECOND_OF_DAY)); - - // Using the calculated time in seconds to create a timer that goes off after - // that time, add to ArrayList - timers.add(new Timer(timeUntil * 1000, this)); - timers.get(timers.size() - 1).start(); - - event.getChannel().sendMessage("Successfully created a reminder for " + time.toString()); - - } - } - - @Override - public void actionPerformed(ActionEvent e) { - - for (int i = 0; i < timers.size(); i++) { - - // Check which timer the ActionEvent belongs to, to find which index to be using - if (e.getSource().equals(timers.get(i))) { - channelNames.get(i).sendMessage("<@" + userNames.get(i) + ">"); - - new MessageBuilder() - .setEmbed(new EmbedBuilder().setTitle(messages.get(i)).setDescription("").setFooter("")) - .send(channelNames.get(i)); - - timers.get(i).stop(); - - // removing the information from the ArrayLists - userNames.remove(i); - channelNames.remove(i); - timers.remove(i); - messages.remove(i); - - } - } - } - -} From 4314942ade46c065d5f3d18e4fad25fba3b480d9 Mon Sep 17 00:00:00 2001 From: adrianolguin <33267387+adrianolguin@users.noreply.github.com> Date: Wed, 17 Mar 2021 18:04:09 -0700 Subject: [PATCH 23/55] Fixing my branches --- .../discord_bot_example/Bot.java | 355 +++++++++--------- .../java/org/jointheleague/modules/Hello.java | 24 -- .../java/org/jointheleague/modules/Poll.java | 257 ------------- 3 files changed, 175 insertions(+), 461 deletions(-) delete mode 100644 src/main/java/org/jointheleague/modules/Hello.java delete mode 100644 src/main/java/org/jointheleague/modules/Poll.java 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 8499b987..c07c7114 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -1,180 +1,175 @@ -package org.jointheleague.discord_bot_example; - -import org.javacord.api.DiscordApi; - -import org.javacord.api.DiscordApiBuilder; - -/** - * Launches all of the listeners for one channel. - * @author keithgroves and https://tinystripz.com - * - */ -import org.jointheleague.modules.*; - - - -public class Bot { - - // The string to show the custom :vomiting_robot: emoji - public static String emoji = "<:vomiting_robot:642414033290657803>"; - - private String token; - private String channelName; - DiscordApi api; - _HelpListener helpListener; - - public Bot(String token, String channelName) { - this.token = token; - this.channelName = channelName; - helpListener = new _HelpListener(channelName); - } - - public void connect(boolean printInvite) { - - api = new DiscordApiBuilder().setToken(token).login().join(); - - // Print the URL to invite the bot - if (printInvite) { - System.out.println("You can invite the bot by using the following url: " + api.createBotInvite()); - } - - api.getServerTextChannelsByName(channelName).forEach(e -> e.sendMessage("Bot Connected")); - - //add Listeners - DiscordLibrary dl = new DiscordLibrary(channelName); - api.addMessageCreateListener(dl); - helpListener.addHelpEmbed(dl.getHelpEmbed()); - - CurrencyConverter cc = new CurrencyConverter(channelName); - api.addMessageCreateListener(cc); - helpListener.addHelpEmbed(cc.getHelpEmbed()); - - ToDoList list = new ToDoList(channelName); - api.addMessageCreateListener(list); - helpListener.addHelpEmbed(list.getHelpEmbed()); - - HeadlineListener head = new HeadlineListener(channelName); - api.addMessageCreateListener(head); - helpListener.addHelpEmbed(head.getHelpEmbed()); - - RandomNumber randomNumber = new RandomNumber(channelName); //replace with feature class later - api.addMessageCreateListener(randomNumber); - helpListener.addHelpEmbed(randomNumber.getHelpEmbed()); - - HypeMachine hypeMachine = new HypeMachine(channelName); - api.addMessageCreateListener(hypeMachine); - helpListener.addHelpEmbed(hypeMachine.getHelpEmbed()); - - TextStyler textStyler = new TextStyler(channelName); - api.addMessageCreateListener(textStyler); - helpListener.addHelpEmbed(textStyler.getHelpEmbed()); - - Tomagachi tomagachi = new Tomagachi(channelName); - api.addMessageCreateListener(tomagachi); - helpListener.addHelpEmbed(tomagachi.getHelpEmbed()); - - SetProfilePic setPFP = new SetProfilePic(channelName); - api.addMessageCreateListener(setPFP); - helpListener.addHelpEmbed(setPFP.getHelpEmbed()); - - ToGif toGif = new ToGif(channelName); - api.addMessageCreateListener(toGif); - helpListener.addHelpEmbed(toGif.getHelpEmbed()); - - RandomCase randomCase = new RandomCase(channelName); - api.addMessageCreateListener(randomCase); - helpListener.addHelpEmbed(randomCase.getHelpEmbed()); - - _ApiExampleListener apiExampleListener = new _ApiExampleListener(channelName); - api.addMessageCreateListener(apiExampleListener); - helpListener.addHelpEmbed(apiExampleListener.getHelpEmbed()); - - NewWeather newWeather = new NewWeather(channelName); - api.addMessageCreateListener(newWeather); - helpListener.addHelpEmbed(newWeather.getHelpEmbed()); - - CoinFlip cp = new CoinFlip(channelName); - api.addMessageCreateListener(cp); - - RollDie rollDie = new RollDie(channelName); - api.addMessageCreateListener(rollDie); - - - MaxTicTacToe mttt = new MaxTicTacToe(channelName); - api.addMessageCreateListener(mttt); - helpListener.addHelpEmbed(mttt.getHelpEmbed()); - - pythagcalc pythagCalc = new pythagcalc(channelName); - api.addMessageCreateListener(pythagCalc); - helpListener.addHelpEmbed(pythagCalc.getHelpEmbed()); - - //Greeter g = new Greeter(channelName); - //api.addMessageCreateListener(g); - //helpListener.addHelpEmbed(g.getHelpEmbed()); - - CovidCaseGetter covid = new CovidCaseGetter(channelName); - api.addMessageCreateListener(covid); - helpListener.addHelpEmbed(covid.getHelpEmbed()); - - ListMakerMessageListener LM = new ListMakerMessageListener(channelName); - api.addMessageCreateListener(LM); - helpListener.addHelpEmbed(LM.getHelpEmbed()); - - Dice d = new Dice(channelName); - api.addMessageCreateListener(d); - helpListener.addHelpEmbed(d.getHelpEmbed()); - - UnbeatableRockPaperScissors rps = new UnbeatableRockPaperScissors(channelName); - api.addMessageCreateListener(rps); - helpListener.addHelpEmbed(rps.getHelpEmbed()); - - //old way to add listeners - api.addMessageCreateListener(helpListener); - api.addMessageCreateListener(new MomBot(channelName)); - api.addMessageCreateListener(new DadJokes(channelName)); - api.addMessageCreateListener(new ClockMessageListener(channelName)); - api.addMessageCreateListener(new CalculatorMessageListener(channelName)); - api.addMessageCreateListener(new ComicMessageListener(channelName)); - api.addMessageCreateListener(new ElmoMessageListener(channelName)); - api.addMessageCreateListener(new FactMessageListener(channelName)); - api.addMessageCreateListener(new CasinoGameListener(channelName)); - api.addMessageCreateListener(new HighLowListener(channelName)); - api.addMessageCreateListener(new Ryland(channelName)); - api.addMessageCreateListener(new RockPaperScissorsListener(channelName)); - api.addMessageCreateListener(new leetMessageListener(channelName)); - api.addMessageCreateListener(new ConnectFour(channelName)); - api.addMessageCreateListener(new FlagMessageListener(channelName)); - api.addMessageCreateListener(new EightBall(channelName)); - api.addMessageCreateListener(new Reddit(channelName)); - api.addMessageCreateListener(new DeepFrier(channelName)); - api.addMessageCreateListener(new PictureOf(channelName)); - api.addMessageCreateListener(new GetPicture(channelName)); - api.addMessageCreateListener(new CuteAnimal(channelName)); - api.addMessageCreateListener(new Weather(channelName)); - api.addMessageCreateListener(new FashionAdvisor(channelName)); - api.addMessageCreateListener(new LatexRender(channelName)); - api.addMessageCreateListener(new MinesweeperListener(channelName)); - api.addMessageCreateListener(new Bot1Listener(channelName)); - api.addMessageCreateListener(new PingMessageListener(channelName)); - api.addMessageCreateListener(new CoinFlipMessageListener(channelName)); - api.addMessageCreateListener(new PlayRPSMessageListener(channelName)); - api.addMessageCreateListener(new KickMessageListener(channelName)); - api.addMessageCreateListener(new AssignRoleMessageListener(channelName)); - api.addMessageCreateListener(new NicknameListener(channelName)); - api.addMessageCreateListener(new SolveQuadraticListener(channelName)); - api.addMessageCreateListener(new RollDiceMessageListener(channelName)); - api.addMessageCreateListener(new MorseTranslator(channelName)); - api.addMessageCreateListener(new HangmanListener(channelName)); - api.addMessageCreateListener(new BogoSorterListener(channelName)); - api.addMessageCreateListener(new ComplimentListener(channelName)); - api.addMessageCreateListener(new CrazyEights(channelName)); - api.addMessageCreateListener(new Blackjack(channelName)); - api.addMessageCreateListener(new RandomCase(channelName)); - api.addMessageCreateListener(new GetTime(channelName)); - api.addMessageCreateListener(new ScreenCapture(channelName)); - - api.addMessageCreateListener(new Hello(channelName)); - api.addMessageCreateListener(new Reminder(channelName)); - api.addMessageCreateListener(new Poll(channelName)); - } -} +package org.jointheleague.discord_bot_example; + +import org.javacord.api.DiscordApi; + +import org.javacord.api.DiscordApiBuilder; + +/** + * Launches all of the listeners for one channel. + * @author keithgroves and https://tinystripz.com + * + */ +import org.jointheleague.modules.*; + +public class Bot { + + // The string to show the custom :vomiting_robot: emoji + public static String emoji = "<:vomiting_robot:642414033290657803>"; + + private String token; + private String channelName; + DiscordApi api; + _HelpListener helpListener; + + public Bot(String token, String channelName) { + this.token = token; + this.channelName = channelName; + helpListener = new _HelpListener(channelName); + } + + public void connect(boolean printInvite) { + + api = new DiscordApiBuilder().setToken(token).login().join(); + + // Print the URL to invite the bot + if (printInvite) { + System.out.println("You can invite the bot by using the following url: " + api.createBotInvite()); + } + + api.getServerTextChannelsByName(channelName).forEach(e -> e.sendMessage("Bot Connected")); + + // add Listeners + DiscordLibrary dl = new DiscordLibrary(channelName); + api.addMessageCreateListener(dl); + helpListener.addHelpEmbed(dl.getHelpEmbed()); + + CurrencyConverter cc = new CurrencyConverter(channelName); + api.addMessageCreateListener(cc); + helpListener.addHelpEmbed(cc.getHelpEmbed()); + + ToDoList list = new ToDoList(channelName); + api.addMessageCreateListener(list); + helpListener.addHelpEmbed(list.getHelpEmbed()); + + HeadlineListener head = new HeadlineListener(channelName); + api.addMessageCreateListener(head); + helpListener.addHelpEmbed(head.getHelpEmbed()); + + RandomNumber randomNumber = new RandomNumber(channelName); // replace with feature class later + api.addMessageCreateListener(randomNumber); + helpListener.addHelpEmbed(randomNumber.getHelpEmbed()); + + HypeMachine hypeMachine = new HypeMachine(channelName); + api.addMessageCreateListener(hypeMachine); + helpListener.addHelpEmbed(hypeMachine.getHelpEmbed()); + + TextStyler textStyler = new TextStyler(channelName); + api.addMessageCreateListener(textStyler); + helpListener.addHelpEmbed(textStyler.getHelpEmbed()); + + Tomagachi tomagachi = new Tomagachi(channelName); + api.addMessageCreateListener(tomagachi); + helpListener.addHelpEmbed(tomagachi.getHelpEmbed()); + + SetProfilePic setPFP = new SetProfilePic(channelName); + api.addMessageCreateListener(setPFP); + helpListener.addHelpEmbed(setPFP.getHelpEmbed()); + + ToGif toGif = new ToGif(channelName); + api.addMessageCreateListener(toGif); + helpListener.addHelpEmbed(toGif.getHelpEmbed()); + + RandomCase randomCase = new RandomCase(channelName); + api.addMessageCreateListener(randomCase); + helpListener.addHelpEmbed(randomCase.getHelpEmbed()); + + _ApiExampleListener apiExampleListener = new _ApiExampleListener(channelName); + api.addMessageCreateListener(apiExampleListener); + helpListener.addHelpEmbed(apiExampleListener.getHelpEmbed()); + + NewWeather newWeather = new NewWeather(channelName); + api.addMessageCreateListener(newWeather); + helpListener.addHelpEmbed(newWeather.getHelpEmbed()); + + CoinFlip cp = new CoinFlip(channelName); + api.addMessageCreateListener(cp); + + RollDie rollDie = new RollDie(channelName); + api.addMessageCreateListener(rollDie); + + MaxTicTacToe mttt = new MaxTicTacToe(channelName); + api.addMessageCreateListener(mttt); + helpListener.addHelpEmbed(mttt.getHelpEmbed()); + + pythagcalc pythagCalc = new pythagcalc(channelName); + api.addMessageCreateListener(pythagCalc); + helpListener.addHelpEmbed(pythagCalc.getHelpEmbed()); + + // Greeter g = new Greeter(channelName); + // api.addMessageCreateListener(g); + // helpListener.addHelpEmbed(g.getHelpEmbed()); + + CovidCaseGetter covid = new CovidCaseGetter(channelName); + api.addMessageCreateListener(covid); + helpListener.addHelpEmbed(covid.getHelpEmbed()); + + ListMakerMessageListener LM = new ListMakerMessageListener(channelName); + api.addMessageCreateListener(LM); + helpListener.addHelpEmbed(LM.getHelpEmbed()); + + Dice d = new Dice(channelName); + api.addMessageCreateListener(d); + helpListener.addHelpEmbed(d.getHelpEmbed()); + + UnbeatableRockPaperScissors rps = new UnbeatableRockPaperScissors(channelName); + api.addMessageCreateListener(rps); + helpListener.addHelpEmbed(rps.getHelpEmbed()); + + // old way to add listeners + api.addMessageCreateListener(helpListener); + api.addMessageCreateListener(new MomBot(channelName)); + api.addMessageCreateListener(new DadJokes(channelName)); + api.addMessageCreateListener(new ClockMessageListener(channelName)); + api.addMessageCreateListener(new CalculatorMessageListener(channelName)); + api.addMessageCreateListener(new ComicMessageListener(channelName)); + api.addMessageCreateListener(new ElmoMessageListener(channelName)); + api.addMessageCreateListener(new FactMessageListener(channelName)); + api.addMessageCreateListener(new CasinoGameListener(channelName)); + api.addMessageCreateListener(new HighLowListener(channelName)); + api.addMessageCreateListener(new Ryland(channelName)); + api.addMessageCreateListener(new RockPaperScissorsListener(channelName)); + api.addMessageCreateListener(new leetMessageListener(channelName)); + api.addMessageCreateListener(new ConnectFour(channelName)); + api.addMessageCreateListener(new FlagMessageListener(channelName)); + api.addMessageCreateListener(new EightBall(channelName)); + api.addMessageCreateListener(new Reddit(channelName)); + api.addMessageCreateListener(new DeepFrier(channelName)); + api.addMessageCreateListener(new PictureOf(channelName)); + api.addMessageCreateListener(new GetPicture(channelName)); + api.addMessageCreateListener(new CuteAnimal(channelName)); + api.addMessageCreateListener(new Weather(channelName)); + api.addMessageCreateListener(new FashionAdvisor(channelName)); + api.addMessageCreateListener(new LatexRender(channelName)); + api.addMessageCreateListener(new MinesweeperListener(channelName)); + api.addMessageCreateListener(new Bot1Listener(channelName)); + api.addMessageCreateListener(new PingMessageListener(channelName)); + api.addMessageCreateListener(new CoinFlipMessageListener(channelName)); + api.addMessageCreateListener(new PlayRPSMessageListener(channelName)); + api.addMessageCreateListener(new KickMessageListener(channelName)); + api.addMessageCreateListener(new AssignRoleMessageListener(channelName)); + api.addMessageCreateListener(new NicknameListener(channelName)); + api.addMessageCreateListener(new SolveQuadraticListener(channelName)); + api.addMessageCreateListener(new RollDiceMessageListener(channelName)); + api.addMessageCreateListener(new MorseTranslator(channelName)); + api.addMessageCreateListener(new HangmanListener(channelName)); + api.addMessageCreateListener(new BogoSorterListener(channelName)); + api.addMessageCreateListener(new ComplimentListener(channelName)); + api.addMessageCreateListener(new CrazyEights(channelName)); + api.addMessageCreateListener(new Blackjack(channelName)); + api.addMessageCreateListener(new RandomCase(channelName)); + api.addMessageCreateListener(new GetTime(channelName)); + api.addMessageCreateListener(new ScreenCapture(channelName)); + + api.addMessageCreateListener(new Reminder(channelName)); + } +} diff --git a/src/main/java/org/jointheleague/modules/Hello.java b/src/main/java/org/jointheleague/modules/Hello.java deleted file mode 100644 index f601a0b0..00000000 --- a/src/main/java/org/jointheleague/modules/Hello.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.jointheleague.modules; - -import org.javacord.api.event.message.MessageCreateEvent; - -import net.aksingh.owmjapis.api.APIException; - -public class Hello extends CustomMessageCreateListener { - - private static final String COMMAND = "!Hello"; - - public Hello(String channelName) { - super(channelName); - } - - @Override - public void handle(MessageCreateEvent event) throws APIException { - if (event.getMessageContent().contains(COMMAND)) { - String user = event.getMessageAuthor().getDisplayName().toString(); - event.getChannel().sendMessage("Hello! " + user); - - } - } - -} diff --git a/src/main/java/org/jointheleague/modules/Poll.java b/src/main/java/org/jointheleague/modules/Poll.java deleted file mode 100644 index 531b360a..00000000 --- a/src/main/java/org/jointheleague/modules/Poll.java +++ /dev/null @@ -1,257 +0,0 @@ -package org.jointheleague.modules; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.time.LocalTime; -import java.time.temporal.ChronoField; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.ExecutionException; - -import javax.swing.Timer; -import javax.swing.plaf.metal.OceanTheme; - -import org.javacord.api.entity.channel.TextChannel; -import org.javacord.api.entity.message.Message; -import org.javacord.api.entity.message.MessageBuilder; -import org.javacord.api.entity.message.Reaction; -import org.javacord.api.entity.message.embed.Embed; -import org.javacord.api.entity.message.embed.EmbedBuilder; -import org.javacord.api.event.message.MessageCreateEvent; -import org.javacord.api.event.message.reaction.ReactionAddEvent; -import org.javacord.api.event.message.reaction.ReactionRemoveEvent; -import org.javacord.api.listener.message.reaction.ReactionAddListener; -import org.javacord.api.listener.message.reaction.ReactionRemoveListener; - -import javassist.compiler.MemberCodeGen; -import net.aksingh.owmjapis.api.APIException; - -public class Poll extends CustomMessageCreateListener implements ReactionAddListener { - - public static String[] emoji = { "1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟" }; - - public static final String COMMAND = "!createPoll"; - - boolean pollUp = false; - - public Poll(String channelName) { - super(channelName); - } - - @Override - public void handle(MessageCreateEvent event) throws APIException { - - if (event.getMessageContent().contains(COMMAND)) { - - String messageContent = event.getMessageContent().replace(COMMAND, ""); - Parameters parameters = getParameters(messageContent); - - String time = parameters.time; - String title = parameters.title; - String[] options = parameters.options; - - OptionContent[] oc = initializeOptions(options, null); - - Message m = buildEmbed(title, oc, event.getChannel()); - handleReactions(m, options.length); - - createTimer(time, m); - - try { - Thread.sleep(6000); - } catch (Exception e) { - e.printStackTrace(); - } - - m.addReactionRemoveListener(e -> votePercentages(m, options)); - m.addReactionAddListener(e -> votePercentages(m, options)); - - pollUp = true; - - } - - } - - private void createTimer(String timeParameter, Message m) { - - String measure = timeParameter.substring(timeParameter.indexOf(' ') + 1, timeParameter.length()); - String amount = timeParameter.substring(0, timeParameter.indexOf(' ')); - - int duration = 0; - - if (measure.equals("hours") || measure.equals("hour")) { - duration = Integer.parseInt(amount) * 60 * 60; - - } else if (measure.equals("minutes") || measure.equals("minute")) { - duration = Integer.parseInt(amount) * 60; - - } else if (measure.equals("seconds") || measure.equals("second")) { - duration = Integer.parseInt(amount); - - } - - Timer timer = new Timer(duration * 1000, e -> { - pollUp = false; - - String title = m.getEmbeds().get(0).getTitle().get(); - String footer = m.getEmbeds().get(0).getFooter().get().getText().get() + "\n(POLL HAS ENDED)\n"; - String description = m.getEmbeds().get(0).getDescription().get(); - - EmbedBuilder eb = new EmbedBuilder().setTitle(title).setDescription(description).setFooter(footer); - - m.edit(eb); - }); - - timer.setRepeats(false); - timer.start(); - } - - private void votePercentages(Message m, String[] options) { - if (pollUp) { - List reactionList = m.getReactions(); - - int[] percentages = new int[options.length]; - - int totalVotes = 0; - - for (int i = 0; i < options.length; i++) { - totalVotes += reactionList.get(i).getCount() - 1; - } - - for (int i = 0; i < options.length; i++) { - int percentage = 0; - try { - percentage = (reactionList.get(i).getCount() - 1) * (100 / totalVotes); - } catch (Exception e) { - e.getStackTrace(); - } - percentages[i] = percentage; - } - - OptionContent[] oc = initializeOptions(options, percentages); - - String descriptionContent = ""; - - for (OptionContent c : oc) { - descriptionContent += c.toString() + "\n"; - } - - String title = m.getEmbeds().get(0).getTitle().get(); - String footer = m.getEmbeds().get(0).getFooter().get().getText().get(); - - m.edit(new EmbedBuilder().setTitle(title).setDescription(descriptionContent).setFooter(footer)); - } - } - - private void handleReactions(Message m, int amount) { - for (int i = 0; i < amount; i++) { - m.addReaction(emoji[i]); - } - } - - private OptionContent[] initializeOptions(String[] options, int[] percentages) { - OptionContent[] oc = new OptionContent[options.length]; - - String percent = " 0%"; - - for (int i = 0; i < options.length; i++) { - if (percentages != null) { - percent = " " + percentages[i] + "%"; - } - - oc[i] = new OptionContent(emoji[i], options[i], percent); - } - return oc; - } - - private Message buildEmbed(String title, OptionContent[] options, TextChannel channel) { - MessageBuilder mb = new MessageBuilder(); - EmbedBuilder eb = new EmbedBuilder(); - - eb.setTitle(title); - eb.setFooter("Testing what this does"); - - String descriptionContent = ""; - for (OptionContent oc : options) { - descriptionContent += oc.toString() + "\n"; - } - eb.setDescription(descriptionContent); - - mb.setEmbed(eb); - Message m = null; - - try { - m = mb.send(channel).get(); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - return m; - } - - private Parameters getParameters(String message) { - String messageContent = message; - System.out.println("Message: " + messageContent); - - String time = messageContent.substring(0, messageContent.indexOf(',') + 1); - messageContent = messageContent.replace(time, ""); - time = time.replace(",", "").trim(); - - String title = messageContent.substring(0, messageContent.indexOf(',') + 1); - messageContent = messageContent.replace(title, ""); - title = title.replace(",", "").trim(); - - ArrayList options = new ArrayList(); - - while (messageContent != "") { - String option = messageContent.substring(0, messageContent.indexOf(',') + 1); - messageContent = messageContent.replace(option, ""); - option = option.replace(",", "").trim(); - options.add(option); - - } - - Parameters p = new Parameters(time, title, options.toArray(new String[options.size()])); - - return p; - } - - @Override - public void onReactionAdd(ReactionAddEvent event) { - - } - -} - -class Parameters { - String time; - String title; - String[] options; - - Parameters(String time, String title, String[] options) { - this.time = time; - this.title = title; - this.options = options; - } - -} - -class OptionContent { - String emoji; - String option; - String percentage; - - OptionContent(String emoji, String option, String percentage) { - this.emoji = emoji; - this.option = option; - this.percentage = percentage; - } - - @Override - public String toString() { - return emoji + " " + option + " " + percentage; - } - -} From 0d41f8b54b1f41ff5211bc4059eb9c45ea87f15b Mon Sep 17 00:00:00 2001 From: adrianolguin <33267387+adrianolguin@users.noreply.github.com> Date: Wed, 17 Mar 2021 18:07:09 -0700 Subject: [PATCH 24/55] Fixing my branches --- .../discord_bot_example/Bot.java | 358 +++++++++--------- .../java/org/jointheleague/modules/Hello.java | 24 -- .../org/jointheleague/modules/Reminder.java | 135 ------- 3 files changed, 178 insertions(+), 339 deletions(-) delete mode 100644 src/main/java/org/jointheleague/modules/Hello.java delete mode 100644 src/main/java/org/jointheleague/modules/Reminder.java 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 8499b987..8a5c0d9d 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -1,180 +1,178 @@ -package org.jointheleague.discord_bot_example; - -import org.javacord.api.DiscordApi; - -import org.javacord.api.DiscordApiBuilder; - -/** - * Launches all of the listeners for one channel. - * @author keithgroves and https://tinystripz.com - * - */ -import org.jointheleague.modules.*; - - - -public class Bot { - - // The string to show the custom :vomiting_robot: emoji - public static String emoji = "<:vomiting_robot:642414033290657803>"; - - private String token; - private String channelName; - DiscordApi api; - _HelpListener helpListener; - - public Bot(String token, String channelName) { - this.token = token; - this.channelName = channelName; - helpListener = new _HelpListener(channelName); - } - - public void connect(boolean printInvite) { - - api = new DiscordApiBuilder().setToken(token).login().join(); - - // Print the URL to invite the bot - if (printInvite) { - System.out.println("You can invite the bot by using the following url: " + api.createBotInvite()); - } - - api.getServerTextChannelsByName(channelName).forEach(e -> e.sendMessage("Bot Connected")); - - //add Listeners - DiscordLibrary dl = new DiscordLibrary(channelName); - api.addMessageCreateListener(dl); - helpListener.addHelpEmbed(dl.getHelpEmbed()); - - CurrencyConverter cc = new CurrencyConverter(channelName); - api.addMessageCreateListener(cc); - helpListener.addHelpEmbed(cc.getHelpEmbed()); - - ToDoList list = new ToDoList(channelName); - api.addMessageCreateListener(list); - helpListener.addHelpEmbed(list.getHelpEmbed()); - - HeadlineListener head = new HeadlineListener(channelName); - api.addMessageCreateListener(head); - helpListener.addHelpEmbed(head.getHelpEmbed()); - - RandomNumber randomNumber = new RandomNumber(channelName); //replace with feature class later - api.addMessageCreateListener(randomNumber); - helpListener.addHelpEmbed(randomNumber.getHelpEmbed()); - - HypeMachine hypeMachine = new HypeMachine(channelName); - api.addMessageCreateListener(hypeMachine); - helpListener.addHelpEmbed(hypeMachine.getHelpEmbed()); - - TextStyler textStyler = new TextStyler(channelName); - api.addMessageCreateListener(textStyler); - helpListener.addHelpEmbed(textStyler.getHelpEmbed()); - - Tomagachi tomagachi = new Tomagachi(channelName); - api.addMessageCreateListener(tomagachi); - helpListener.addHelpEmbed(tomagachi.getHelpEmbed()); - - SetProfilePic setPFP = new SetProfilePic(channelName); - api.addMessageCreateListener(setPFP); - helpListener.addHelpEmbed(setPFP.getHelpEmbed()); - - ToGif toGif = new ToGif(channelName); - api.addMessageCreateListener(toGif); - helpListener.addHelpEmbed(toGif.getHelpEmbed()); - - RandomCase randomCase = new RandomCase(channelName); - api.addMessageCreateListener(randomCase); - helpListener.addHelpEmbed(randomCase.getHelpEmbed()); - - _ApiExampleListener apiExampleListener = new _ApiExampleListener(channelName); - api.addMessageCreateListener(apiExampleListener); - helpListener.addHelpEmbed(apiExampleListener.getHelpEmbed()); - - NewWeather newWeather = new NewWeather(channelName); - api.addMessageCreateListener(newWeather); - helpListener.addHelpEmbed(newWeather.getHelpEmbed()); - - CoinFlip cp = new CoinFlip(channelName); - api.addMessageCreateListener(cp); - - RollDie rollDie = new RollDie(channelName); - api.addMessageCreateListener(rollDie); - - - MaxTicTacToe mttt = new MaxTicTacToe(channelName); - api.addMessageCreateListener(mttt); - helpListener.addHelpEmbed(mttt.getHelpEmbed()); - - pythagcalc pythagCalc = new pythagcalc(channelName); - api.addMessageCreateListener(pythagCalc); - helpListener.addHelpEmbed(pythagCalc.getHelpEmbed()); - - //Greeter g = new Greeter(channelName); - //api.addMessageCreateListener(g); - //helpListener.addHelpEmbed(g.getHelpEmbed()); - - CovidCaseGetter covid = new CovidCaseGetter(channelName); - api.addMessageCreateListener(covid); - helpListener.addHelpEmbed(covid.getHelpEmbed()); - - ListMakerMessageListener LM = new ListMakerMessageListener(channelName); - api.addMessageCreateListener(LM); - helpListener.addHelpEmbed(LM.getHelpEmbed()); - - Dice d = new Dice(channelName); - api.addMessageCreateListener(d); - helpListener.addHelpEmbed(d.getHelpEmbed()); - - UnbeatableRockPaperScissors rps = new UnbeatableRockPaperScissors(channelName); - api.addMessageCreateListener(rps); - helpListener.addHelpEmbed(rps.getHelpEmbed()); - - //old way to add listeners - api.addMessageCreateListener(helpListener); - api.addMessageCreateListener(new MomBot(channelName)); - api.addMessageCreateListener(new DadJokes(channelName)); - api.addMessageCreateListener(new ClockMessageListener(channelName)); - api.addMessageCreateListener(new CalculatorMessageListener(channelName)); - api.addMessageCreateListener(new ComicMessageListener(channelName)); - api.addMessageCreateListener(new ElmoMessageListener(channelName)); - api.addMessageCreateListener(new FactMessageListener(channelName)); - api.addMessageCreateListener(new CasinoGameListener(channelName)); - api.addMessageCreateListener(new HighLowListener(channelName)); - api.addMessageCreateListener(new Ryland(channelName)); - api.addMessageCreateListener(new RockPaperScissorsListener(channelName)); - api.addMessageCreateListener(new leetMessageListener(channelName)); - api.addMessageCreateListener(new ConnectFour(channelName)); - api.addMessageCreateListener(new FlagMessageListener(channelName)); - api.addMessageCreateListener(new EightBall(channelName)); - api.addMessageCreateListener(new Reddit(channelName)); - api.addMessageCreateListener(new DeepFrier(channelName)); - api.addMessageCreateListener(new PictureOf(channelName)); - api.addMessageCreateListener(new GetPicture(channelName)); - api.addMessageCreateListener(new CuteAnimal(channelName)); - api.addMessageCreateListener(new Weather(channelName)); - api.addMessageCreateListener(new FashionAdvisor(channelName)); - api.addMessageCreateListener(new LatexRender(channelName)); - api.addMessageCreateListener(new MinesweeperListener(channelName)); - api.addMessageCreateListener(new Bot1Listener(channelName)); - api.addMessageCreateListener(new PingMessageListener(channelName)); - api.addMessageCreateListener(new CoinFlipMessageListener(channelName)); - api.addMessageCreateListener(new PlayRPSMessageListener(channelName)); - api.addMessageCreateListener(new KickMessageListener(channelName)); - api.addMessageCreateListener(new AssignRoleMessageListener(channelName)); - api.addMessageCreateListener(new NicknameListener(channelName)); - api.addMessageCreateListener(new SolveQuadraticListener(channelName)); - api.addMessageCreateListener(new RollDiceMessageListener(channelName)); - api.addMessageCreateListener(new MorseTranslator(channelName)); - api.addMessageCreateListener(new HangmanListener(channelName)); - api.addMessageCreateListener(new BogoSorterListener(channelName)); - api.addMessageCreateListener(new ComplimentListener(channelName)); - api.addMessageCreateListener(new CrazyEights(channelName)); - api.addMessageCreateListener(new Blackjack(channelName)); - api.addMessageCreateListener(new RandomCase(channelName)); - api.addMessageCreateListener(new GetTime(channelName)); - api.addMessageCreateListener(new ScreenCapture(channelName)); - - api.addMessageCreateListener(new Hello(channelName)); - api.addMessageCreateListener(new Reminder(channelName)); - api.addMessageCreateListener(new Poll(channelName)); - } -} +package org.jointheleague.discord_bot_example; + +import org.javacord.api.DiscordApi; + +import org.javacord.api.DiscordApiBuilder; + +/** + * Launches all of the listeners for one channel. + * @author keithgroves and https://tinystripz.com + * + */ +import org.jointheleague.modules.*; + + + +public class Bot { + + // The string to show the custom :vomiting_robot: emoji + public static String emoji = "<:vomiting_robot:642414033290657803>"; + + private String token; + private String channelName; + DiscordApi api; + _HelpListener helpListener; + + public Bot(String token, String channelName) { + this.token = token; + this.channelName = channelName; + helpListener = new _HelpListener(channelName); + } + + public void connect(boolean printInvite) { + + api = new DiscordApiBuilder().setToken(token).login().join(); + + // Print the URL to invite the bot + if (printInvite) { + System.out.println("You can invite the bot by using the following url: " + api.createBotInvite()); + } + + api.getServerTextChannelsByName(channelName).forEach(e -> e.sendMessage("Bot Connected")); + + //add Listeners + DiscordLibrary dl = new DiscordLibrary(channelName); + api.addMessageCreateListener(dl); + helpListener.addHelpEmbed(dl.getHelpEmbed()); + + CurrencyConverter cc = new CurrencyConverter(channelName); + api.addMessageCreateListener(cc); + helpListener.addHelpEmbed(cc.getHelpEmbed()); + + ToDoList list = new ToDoList(channelName); + api.addMessageCreateListener(list); + helpListener.addHelpEmbed(list.getHelpEmbed()); + + HeadlineListener head = new HeadlineListener(channelName); + api.addMessageCreateListener(head); + helpListener.addHelpEmbed(head.getHelpEmbed()); + + RandomNumber randomNumber = new RandomNumber(channelName); //replace with feature class later + api.addMessageCreateListener(randomNumber); + helpListener.addHelpEmbed(randomNumber.getHelpEmbed()); + + HypeMachine hypeMachine = new HypeMachine(channelName); + api.addMessageCreateListener(hypeMachine); + helpListener.addHelpEmbed(hypeMachine.getHelpEmbed()); + + TextStyler textStyler = new TextStyler(channelName); + api.addMessageCreateListener(textStyler); + helpListener.addHelpEmbed(textStyler.getHelpEmbed()); + + Tomagachi tomagachi = new Tomagachi(channelName); + api.addMessageCreateListener(tomagachi); + helpListener.addHelpEmbed(tomagachi.getHelpEmbed()); + + SetProfilePic setPFP = new SetProfilePic(channelName); + api.addMessageCreateListener(setPFP); + helpListener.addHelpEmbed(setPFP.getHelpEmbed()); + + ToGif toGif = new ToGif(channelName); + api.addMessageCreateListener(toGif); + helpListener.addHelpEmbed(toGif.getHelpEmbed()); + + RandomCase randomCase = new RandomCase(channelName); + api.addMessageCreateListener(randomCase); + helpListener.addHelpEmbed(randomCase.getHelpEmbed()); + + _ApiExampleListener apiExampleListener = new _ApiExampleListener(channelName); + api.addMessageCreateListener(apiExampleListener); + helpListener.addHelpEmbed(apiExampleListener.getHelpEmbed()); + + NewWeather newWeather = new NewWeather(channelName); + api.addMessageCreateListener(newWeather); + helpListener.addHelpEmbed(newWeather.getHelpEmbed()); + + CoinFlip cp = new CoinFlip(channelName); + api.addMessageCreateListener(cp); + + RollDie rollDie = new RollDie(channelName); + api.addMessageCreateListener(rollDie); + + + MaxTicTacToe mttt = new MaxTicTacToe(channelName); + api.addMessageCreateListener(mttt); + helpListener.addHelpEmbed(mttt.getHelpEmbed()); + + pythagcalc pythagCalc = new pythagcalc(channelName); + api.addMessageCreateListener(pythagCalc); + helpListener.addHelpEmbed(pythagCalc.getHelpEmbed()); + + //Greeter g = new Greeter(channelName); + //api.addMessageCreateListener(g); + //helpListener.addHelpEmbed(g.getHelpEmbed()); + + CovidCaseGetter covid = new CovidCaseGetter(channelName); + api.addMessageCreateListener(covid); + helpListener.addHelpEmbed(covid.getHelpEmbed()); + + ListMakerMessageListener LM = new ListMakerMessageListener(channelName); + api.addMessageCreateListener(LM); + helpListener.addHelpEmbed(LM.getHelpEmbed()); + + Dice d = new Dice(channelName); + api.addMessageCreateListener(d); + helpListener.addHelpEmbed(d.getHelpEmbed()); + + UnbeatableRockPaperScissors rps = new UnbeatableRockPaperScissors(channelName); + api.addMessageCreateListener(rps); + helpListener.addHelpEmbed(rps.getHelpEmbed()); + + //old way to add listeners + api.addMessageCreateListener(helpListener); + api.addMessageCreateListener(new MomBot(channelName)); + api.addMessageCreateListener(new DadJokes(channelName)); + api.addMessageCreateListener(new ClockMessageListener(channelName)); + api.addMessageCreateListener(new CalculatorMessageListener(channelName)); + api.addMessageCreateListener(new ComicMessageListener(channelName)); + api.addMessageCreateListener(new ElmoMessageListener(channelName)); + api.addMessageCreateListener(new FactMessageListener(channelName)); + api.addMessageCreateListener(new CasinoGameListener(channelName)); + api.addMessageCreateListener(new HighLowListener(channelName)); + api.addMessageCreateListener(new Ryland(channelName)); + api.addMessageCreateListener(new RockPaperScissorsListener(channelName)); + api.addMessageCreateListener(new leetMessageListener(channelName)); + api.addMessageCreateListener(new ConnectFour(channelName)); + api.addMessageCreateListener(new FlagMessageListener(channelName)); + api.addMessageCreateListener(new EightBall(channelName)); + api.addMessageCreateListener(new Reddit(channelName)); + api.addMessageCreateListener(new DeepFrier(channelName)); + api.addMessageCreateListener(new PictureOf(channelName)); + api.addMessageCreateListener(new GetPicture(channelName)); + api.addMessageCreateListener(new CuteAnimal(channelName)); + api.addMessageCreateListener(new Weather(channelName)); + api.addMessageCreateListener(new FashionAdvisor(channelName)); + api.addMessageCreateListener(new LatexRender(channelName)); + api.addMessageCreateListener(new MinesweeperListener(channelName)); + api.addMessageCreateListener(new Bot1Listener(channelName)); + api.addMessageCreateListener(new PingMessageListener(channelName)); + api.addMessageCreateListener(new CoinFlipMessageListener(channelName)); + api.addMessageCreateListener(new PlayRPSMessageListener(channelName)); + api.addMessageCreateListener(new KickMessageListener(channelName)); + api.addMessageCreateListener(new AssignRoleMessageListener(channelName)); + api.addMessageCreateListener(new NicknameListener(channelName)); + api.addMessageCreateListener(new SolveQuadraticListener(channelName)); + api.addMessageCreateListener(new RollDiceMessageListener(channelName)); + api.addMessageCreateListener(new MorseTranslator(channelName)); + api.addMessageCreateListener(new HangmanListener(channelName)); + api.addMessageCreateListener(new BogoSorterListener(channelName)); + api.addMessageCreateListener(new ComplimentListener(channelName)); + api.addMessageCreateListener(new CrazyEights(channelName)); + api.addMessageCreateListener(new Blackjack(channelName)); + api.addMessageCreateListener(new RandomCase(channelName)); + api.addMessageCreateListener(new GetTime(channelName)); + api.addMessageCreateListener(new ScreenCapture(channelName)); + + api.addMessageCreateListener(new Poll(channelName)); + } +} diff --git a/src/main/java/org/jointheleague/modules/Hello.java b/src/main/java/org/jointheleague/modules/Hello.java deleted file mode 100644 index f601a0b0..00000000 --- a/src/main/java/org/jointheleague/modules/Hello.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.jointheleague.modules; - -import org.javacord.api.event.message.MessageCreateEvent; - -import net.aksingh.owmjapis.api.APIException; - -public class Hello extends CustomMessageCreateListener { - - private static final String COMMAND = "!Hello"; - - public Hello(String channelName) { - super(channelName); - } - - @Override - public void handle(MessageCreateEvent event) throws APIException { - if (event.getMessageContent().contains(COMMAND)) { - String user = event.getMessageAuthor().getDisplayName().toString(); - event.getChannel().sendMessage("Hello! " + user); - - } - } - -} diff --git a/src/main/java/org/jointheleague/modules/Reminder.java b/src/main/java/org/jointheleague/modules/Reminder.java deleted file mode 100644 index a0cb2081..00000000 --- a/src/main/java/org/jointheleague/modules/Reminder.java +++ /dev/null @@ -1,135 +0,0 @@ -package org.jointheleague.modules; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.time.LocalTime; -import java.time.temporal.ChronoField; -import java.util.ArrayList; -import javax.swing.Timer; -import org.javacord.api.entity.channel.TextChannel; -import org.javacord.api.entity.message.MessageBuilder; -import org.javacord.api.entity.message.embed.EmbedBuilder; -import org.javacord.api.event.message.MessageCreateEvent; -import org.javacord.api.listener.message.MessageCreateListener; - -import net.aksingh.owmjapis.api.APIException; - -public class Reminder extends CustomMessageCreateListener implements ActionListener { - - ArrayList userNames = new ArrayList(); - ArrayList messages = new ArrayList(); - ArrayList channelNames = new ArrayList(); - ArrayList timers = new ArrayList(); - - public static final String REMIND_COMMAND = "!setReminder"; - public static final String HELP_COMMAND = "!setReminderHelp"; - - public Reminder(String channelName) { - super(channelName); - - } - - @Override - public void handle(MessageCreateEvent event) throws APIException { - - if (event.getMessageContent().contains(HELP_COMMAND)) { - - //event.get - - new MessageBuilder().setEmbed(new EmbedBuilder().setTitle( - "To use this command first type the '!setReminder' command, followed by the time you want to be reminded (In Military Time), a comma, then your remind message") - .setDescription("P.S. Make sure when you input your time use a colon between the hours and minutes") - .setFooter("")).send(event.getChannel()); - - } else if (event.getMessageContent().contains(REMIND_COMMAND)) { - - // add use to the arraylist - String user = event.getMessageAuthor().getIdAsString(); - userNames.add(user); - - // add the channel to the arraylist - TextChannel txtChannel = event.getChannel(); - channelNames.add(txtChannel); - - String parameters = event.getMessageContent().replace(REMIND_COMMAND, ""); - - if (parameters.equals("")) { - event.getChannel().sendMessage("Invalid Input"); - } - - String timeParameter = ""; - - try { - // get the raw timeParameter, fix it later - timeParameter = parameters.substring(0, parameters.indexOf(',')); - - parameters = parameters.substring(parameters.indexOf(',') + 1, parameters.length()); - } catch (StringIndexOutOfBoundsException e) { - // This catches if there is no comma, which probably means there is no message - // so I set that to an empty string - - timeParameter = parameters.substring(0, parameters.length()); - - parameters = ""; - - } - - // get the raw messageParameter, no need to fix it and I add it to the arrayList - // immediately - String messageParameter = parameters.substring(0, parameters.length()); - messages.add(messageParameter); - - // all this is fixing the raw timeParameter so I can parse it to the LocalTime - // class and compare in to the current time - timeParameter = timeParameter.replaceAll(" ", ""); - - int count = timeParameter.length() - timeParameter.replaceAll(":", "").length(); - if (count == 1) { - timeParameter += ":00"; - } - - // parse fixed timeParameter to LocalTime class and get the current local time - LocalTime time = LocalTime.parse(timeParameter); - LocalTime currentTime = LocalTime.now(); - - // using LocalTime class functions, find the time until the user needs to be - // reminded, in seconds - // what the heck is a chronofield - int timeUntil = (int) (time.getLong(ChronoField.SECOND_OF_DAY) - - currentTime.getLong(ChronoField.SECOND_OF_DAY)); - - // Using the calculated time in seconds to create a timer that goes off after - // that time, add to ArrayList - timers.add(new Timer(timeUntil * 1000, this)); - timers.get(timers.size() - 1).start(); - - event.getChannel().sendMessage("Successfully created a reminder for " + time.toString()); - - } - } - - @Override - public void actionPerformed(ActionEvent e) { - - for (int i = 0; i < timers.size(); i++) { - - // Check which timer the ActionEvent belongs to, to find which index to be using - if (e.getSource().equals(timers.get(i))) { - channelNames.get(i).sendMessage("<@" + userNames.get(i) + ">"); - - new MessageBuilder() - .setEmbed(new EmbedBuilder().setTitle(messages.get(i)).setDescription("").setFooter("")) - .send(channelNames.get(i)); - - timers.get(i).stop(); - - // removing the information from the ArrayLists - userNames.remove(i); - channelNames.remove(i); - timers.remove(i); - messages.remove(i); - - } - } - } - -} From 9234a6c0840530fb5968ab6649fc211c2c3c22b2 Mon Sep 17 00:00:00 2001 From: adrianolguin <33267387+adrianolguin@users.noreply.github.com> Date: Wed, 17 Mar 2021 18:28:11 -0700 Subject: [PATCH 25/55] Adding help embed to my feature --- .../java/org/jointheleague/discord_bot_example/Bot.java | 7 +++++-- src/main/java/org/jointheleague/modules/Hello.java | 2 ++ 2 files changed, 7 insertions(+), 2 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 28e20348..73402a08 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -109,6 +109,10 @@ public void connect(boolean printInvite) { // api.addMessageCreateListener(g); // helpListener.addHelpEmbed(g.getHelpEmbed()); + Hello hello = new Hello(channelName); + api.addMessageCreateListener(hello); + helpListener.addHelpEmbed(hello.getHelpEmbed()); + CovidCaseGetter covid = new CovidCaseGetter(channelName); api.addMessageCreateListener(covid); helpListener.addHelpEmbed(covid.getHelpEmbed()); @@ -126,7 +130,7 @@ public void connect(boolean printInvite) { helpListener.addHelpEmbed(rps.getHelpEmbed()); // old way to add listeners - api.addMessageCreateListener(helpListener); + //api.addMessageCreateListener(helpListener); api.addMessageCreateListener(new MomBot(channelName)); api.addMessageCreateListener(new DadJokes(channelName)); api.addMessageCreateListener(new ClockMessageListener(channelName)); @@ -170,6 +174,5 @@ public void connect(boolean printInvite) { api.addMessageCreateListener(new GetTime(channelName)); api.addMessageCreateListener(new ScreenCapture(channelName)); - api.addMessageCreateListener(new Hello(channelName)); } } diff --git a/src/main/java/org/jointheleague/modules/Hello.java b/src/main/java/org/jointheleague/modules/Hello.java index f601a0b0..3d216b85 100644 --- a/src/main/java/org/jointheleague/modules/Hello.java +++ b/src/main/java/org/jointheleague/modules/Hello.java @@ -1,6 +1,7 @@ package org.jointheleague.modules; import org.javacord.api.event.message.MessageCreateEvent; +import org.jointheleague.modules.pojo.HelpEmbed; import net.aksingh.owmjapis.api.APIException; @@ -10,6 +11,7 @@ public class Hello extends CustomMessageCreateListener { public Hello(String channelName) { super(channelName); + helpEmbed = new HelpEmbed(COMMAND, "This is a simple command that gives you a friendly Hello! To use it just type \\\"!Hello\\\""); } @Override From a345c270a2b9a547f4a6b4c4e9e3e65cab891680 Mon Sep 17 00:00:00 2001 From: adrianolguin <33267387+adrianolguin@users.noreply.github.com> Date: Wed, 17 Mar 2021 18:28:29 -0700 Subject: [PATCH 26/55] oops --- src/main/java/org/jointheleague/discord_bot_example/Bot.java | 2 +- 1 file changed, 1 insertion(+), 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 73402a08..3cc94c2d 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -130,7 +130,7 @@ public void connect(boolean printInvite) { helpListener.addHelpEmbed(rps.getHelpEmbed()); // old way to add listeners - //api.addMessageCreateListener(helpListener); + api.addMessageCreateListener(helpListener); api.addMessageCreateListener(new MomBot(channelName)); api.addMessageCreateListener(new DadJokes(channelName)); api.addMessageCreateListener(new ClockMessageListener(channelName)); From 5d3cb0b7517f70d29742dced4082559e39c25369 Mon Sep 17 00:00:00 2001 From: adrianolguin <33267387+adrianolguin@users.noreply.github.com> Date: Sat, 20 Mar 2021 19:44:52 -0700 Subject: [PATCH 27/55] Adding Help Embed --- .../discord_bot_example/Bot.java | 6 ++++-- .../org/jointheleague/modules/Reminder.java | 19 ++++++------------- 2 files changed, 10 insertions(+), 15 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 c07c7114..3ce0ee81 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -109,6 +109,10 @@ public void connect(boolean printInvite) { // api.addMessageCreateListener(g); // helpListener.addHelpEmbed(g.getHelpEmbed()); + Reminder reminder = new Reminder(channelName); + api.addMessageCreateListener(reminder); + helpListener.addHelpEmbed(reminder.getHelpEmbed()); + CovidCaseGetter covid = new CovidCaseGetter(channelName); api.addMessageCreateListener(covid); helpListener.addHelpEmbed(covid.getHelpEmbed()); @@ -169,7 +173,5 @@ public void connect(boolean printInvite) { api.addMessageCreateListener(new RandomCase(channelName)); api.addMessageCreateListener(new GetTime(channelName)); api.addMessageCreateListener(new ScreenCapture(channelName)); - - api.addMessageCreateListener(new Reminder(channelName)); } } diff --git a/src/main/java/org/jointheleague/modules/Reminder.java b/src/main/java/org/jointheleague/modules/Reminder.java index a0cb2081..4dd71ad7 100644 --- a/src/main/java/org/jointheleague/modules/Reminder.java +++ b/src/main/java/org/jointheleague/modules/Reminder.java @@ -1,4 +1,5 @@ package org.jointheleague.modules; + import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.time.LocalTime; @@ -10,6 +11,7 @@ import org.javacord.api.entity.message.embed.EmbedBuilder; 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; @@ -21,26 +23,17 @@ public class Reminder extends CustomMessageCreateListener implements ActionListe ArrayList timers = new ArrayList(); public static final String REMIND_COMMAND = "!setReminder"; - public static final String HELP_COMMAND = "!setReminderHelp"; public Reminder(String channelName) { super(channelName); - + helpEmbed = new HelpEmbed(REMIND_COMMAND, + "To use this command first type the '!setReminder' command, followed by the time you want to be reminded (In Military Time), a comma, then your remind message \nP.S. Make sure when you input your time use a colon between the hours and minutes"); } @Override public void handle(MessageCreateEvent event) throws APIException { - - if (event.getMessageContent().contains(HELP_COMMAND)) { - //event.get - - new MessageBuilder().setEmbed(new EmbedBuilder().setTitle( - "To use this command first type the '!setReminder' command, followed by the time you want to be reminded (In Military Time), a comma, then your remind message") - .setDescription("P.S. Make sure when you input your time use a colon between the hours and minutes") - .setFooter("")).send(event.getChannel()); - - } else if (event.getMessageContent().contains(REMIND_COMMAND)) { + if (event.getMessageContent().contains(REMIND_COMMAND)) { // add use to the arraylist String user = event.getMessageAuthor().getIdAsString(); @@ -103,7 +96,7 @@ public void handle(MessageCreateEvent event) throws APIException { timers.get(timers.size() - 1).start(); event.getChannel().sendMessage("Successfully created a reminder for " + time.toString()); - + } } From 02aeec0fda7339ff3429bbf39624bf2b5111dfa5 Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 21 Mar 2021 11:42:02 -0700 Subject: [PATCH 28/55] 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 5b5b85f6bbfa4d1438084385f3762d839dccff2f Mon Sep 17 00:00:00 2001 From: adrianolguin <33267387+adrianolguin@users.noreply.github.com> Date: Wed, 24 Mar 2021 17:38:10 -0700 Subject: [PATCH 29/55] Finishing touches, finally done --- .../discord_bot_example/Bot.java | 58 +++++++++---------- .../java/org/jointheleague/modules/Poll.java | 27 +++++++-- 2 files changed, 52 insertions(+), 33 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 8a5c0d9d..790e132a 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -11,10 +11,8 @@ */ import org.jointheleague.modules.*; +public class Bot { - -public class Bot { - // The string to show the custom :vomiting_robot: emoji public static String emoji = "<:vomiting_robot:642414033290657803>"; @@ -30,7 +28,7 @@ public Bot(String token, String channelName) { } public void connect(boolean printInvite) { - + api = new DiscordApiBuilder().setToken(token).login().join(); // Print the URL to invite the bot @@ -39,16 +37,16 @@ public void connect(boolean printInvite) { } api.getServerTextChannelsByName(channelName).forEach(e -> e.sendMessage("Bot Connected")); - - //add Listeners + + // add Listeners DiscordLibrary dl = new DiscordLibrary(channelName); api.addMessageCreateListener(dl); helpListener.addHelpEmbed(dl.getHelpEmbed()); - + CurrencyConverter cc = new CurrencyConverter(channelName); api.addMessageCreateListener(cc); helpListener.addHelpEmbed(cc.getHelpEmbed()); - + ToDoList list = new ToDoList(channelName); api.addMessageCreateListener(list); helpListener.addHelpEmbed(list.getHelpEmbed()); @@ -57,49 +55,48 @@ public void connect(boolean printInvite) { api.addMessageCreateListener(head); helpListener.addHelpEmbed(head.getHelpEmbed()); - RandomNumber randomNumber = new RandomNumber(channelName); //replace with feature class later + RandomNumber randomNumber = new RandomNumber(channelName); // replace with feature class later api.addMessageCreateListener(randomNumber); helpListener.addHelpEmbed(randomNumber.getHelpEmbed()); - + HypeMachine hypeMachine = new HypeMachine(channelName); api.addMessageCreateListener(hypeMachine); helpListener.addHelpEmbed(hypeMachine.getHelpEmbed()); - + TextStyler textStyler = new TextStyler(channelName); api.addMessageCreateListener(textStyler); helpListener.addHelpEmbed(textStyler.getHelpEmbed()); - + Tomagachi tomagachi = new Tomagachi(channelName); api.addMessageCreateListener(tomagachi); helpListener.addHelpEmbed(tomagachi.getHelpEmbed()); - + SetProfilePic setPFP = new SetProfilePic(channelName); api.addMessageCreateListener(setPFP); helpListener.addHelpEmbed(setPFP.getHelpEmbed()); - + ToGif toGif = new ToGif(channelName); api.addMessageCreateListener(toGif); helpListener.addHelpEmbed(toGif.getHelpEmbed()); - + RandomCase randomCase = new RandomCase(channelName); api.addMessageCreateListener(randomCase); helpListener.addHelpEmbed(randomCase.getHelpEmbed()); - + _ApiExampleListener apiExampleListener = new _ApiExampleListener(channelName); api.addMessageCreateListener(apiExampleListener); helpListener.addHelpEmbed(apiExampleListener.getHelpEmbed()); - + NewWeather newWeather = new NewWeather(channelName); api.addMessageCreateListener(newWeather); helpListener.addHelpEmbed(newWeather.getHelpEmbed()); - + CoinFlip cp = new CoinFlip(channelName); api.addMessageCreateListener(cp); - + RollDie rollDie = new RollDie(channelName); api.addMessageCreateListener(rollDie); - MaxTicTacToe mttt = new MaxTicTacToe(channelName); api.addMessageCreateListener(mttt); helpListener.addHelpEmbed(mttt.getHelpEmbed()); @@ -108,10 +105,14 @@ public void connect(boolean printInvite) { api.addMessageCreateListener(pythagCalc); helpListener.addHelpEmbed(pythagCalc.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()); + + Poll poll = new Poll(channelName); + api.addMessageCreateListener(poll); + helpListener.addHelpEmbed(poll.getHelpEmbed()); + CovidCaseGetter covid = new CovidCaseGetter(channelName); api.addMessageCreateListener(covid); helpListener.addHelpEmbed(covid.getHelpEmbed()); @@ -119,7 +120,7 @@ public void connect(boolean printInvite) { ListMakerMessageListener LM = new ListMakerMessageListener(channelName); api.addMessageCreateListener(LM); helpListener.addHelpEmbed(LM.getHelpEmbed()); - + Dice d = new Dice(channelName); api.addMessageCreateListener(d); helpListener.addHelpEmbed(d.getHelpEmbed()); @@ -127,8 +128,8 @@ public void connect(boolean printInvite) { UnbeatableRockPaperScissors rps = new UnbeatableRockPaperScissors(channelName); api.addMessageCreateListener(rps); helpListener.addHelpEmbed(rps.getHelpEmbed()); - - //old way to add listeners + + // old way to add listeners api.addMessageCreateListener(helpListener); api.addMessageCreateListener(new MomBot(channelName)); api.addMessageCreateListener(new DadJokes(channelName)); @@ -155,7 +156,7 @@ public void connect(boolean printInvite) { api.addMessageCreateListener(new LatexRender(channelName)); api.addMessageCreateListener(new MinesweeperListener(channelName)); api.addMessageCreateListener(new Bot1Listener(channelName)); - api.addMessageCreateListener(new PingMessageListener(channelName)); + api.addMessageCreateListener(new PingMessageListener(channelName)); api.addMessageCreateListener(new CoinFlipMessageListener(channelName)); api.addMessageCreateListener(new PlayRPSMessageListener(channelName)); api.addMessageCreateListener(new KickMessageListener(channelName)); @@ -173,6 +174,5 @@ public void connect(boolean printInvite) { api.addMessageCreateListener(new GetTime(channelName)); api.addMessageCreateListener(new ScreenCapture(channelName)); - api.addMessageCreateListener(new Poll(channelName)); } } diff --git a/src/main/java/org/jointheleague/modules/Poll.java b/src/main/java/org/jointheleague/modules/Poll.java index 531b360a..bc8b261d 100644 --- a/src/main/java/org/jointheleague/modules/Poll.java +++ b/src/main/java/org/jointheleague/modules/Poll.java @@ -25,6 +25,7 @@ import org.javacord.api.event.message.reaction.ReactionRemoveEvent; import org.javacord.api.listener.message.reaction.ReactionAddListener; import org.javacord.api.listener.message.reaction.ReactionRemoveListener; +import org.jointheleague.modules.pojo.HelpEmbed; import javassist.compiler.MemberCodeGen; import net.aksingh.owmjapis.api.APIException; @@ -39,6 +40,10 @@ public class Poll extends CustomMessageCreateListener implements ReactionAddList public Poll(String channelName) { super(channelName); + helpEmbed = new HelpEmbed(COMMAND, + "You can create polls where people can vote for options using emojis. In order to create a poll first type the command " + + COMMAND + + " and then enter how long you want the poll to be up, its name, and then list the options in the poll. Everything should be separated by a comma \n Ex. !createPoll 5 minutes, Cats vs Dogs, Cats, Dogs, Neither"); } @Override @@ -56,6 +61,7 @@ public void handle(MessageCreateEvent event) throws APIException { OptionContent[] oc = initializeOptions(options, null); Message m = buildEmbed(title, oc, event.getChannel()); + System.out.println(m.getContent()); handleReactions(m, options.length); createTimer(time, m); @@ -187,6 +193,7 @@ private Message buildEmbed(String title, OptionContent[] options, TextChannel ch m = mb.send(channel).get(); } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); + System.out.println("exception"); } return m; } @@ -206,10 +213,22 @@ private Parameters getParameters(String message) { ArrayList options = new ArrayList(); while (messageContent != "") { - String option = messageContent.substring(0, messageContent.indexOf(',') + 1); - messageContent = messageContent.replace(option, ""); - option = option.replace(",", "").trim(); - options.add(option); + String option = ""; + + if(messageContent.contains(",")) { + option = messageContent.substring(0, messageContent.indexOf(',') + 1); + messageContent = messageContent.replace(option, ""); + option = option.replace(",", "").trim(); + options.add(option); + } else { + option = messageContent.substring(0, messageContent.length()); + messageContent = messageContent.replace(option, ""); + option.trim(); + options.add(option); + } + + + } From c8cb4673233bfbe4c2e2faf3135ca5692479da4a Mon Sep 17 00:00:00 2001 From: adrianolguin <33267387+adrianolguin@users.noreply.github.com> Date: Wed, 24 Mar 2021 17:38:32 -0700 Subject: [PATCH 30/55] done --- src/main/java/org/jointheleague/modules/Poll.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/jointheleague/modules/Poll.java b/src/main/java/org/jointheleague/modules/Poll.java index bc8b261d..c1aef0d2 100644 --- a/src/main/java/org/jointheleague/modules/Poll.java +++ b/src/main/java/org/jointheleague/modules/Poll.java @@ -200,7 +200,6 @@ private Message buildEmbed(String title, OptionContent[] options, TextChannel ch private Parameters getParameters(String message) { String messageContent = message; - System.out.println("Message: " + messageContent); String time = messageContent.substring(0, messageContent.indexOf(',') + 1); messageContent = messageContent.replace(time, ""); From 5c5e4502fc2c8205aa113846472f2e1596168d8f Mon Sep 17 00:00:00 2001 From: adrianolguin <33267387+adrianolguin@users.noreply.github.com> Date: Wed, 24 Mar 2021 17:45:42 -0700 Subject: [PATCH 31/55] Done --- src/main/java/org/jointheleague/modules/Reminder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jointheleague/modules/Reminder.java b/src/main/java/org/jointheleague/modules/Reminder.java index 4dd71ad7..e0fc0118 100644 --- a/src/main/java/org/jointheleague/modules/Reminder.java +++ b/src/main/java/org/jointheleague/modules/Reminder.java @@ -27,7 +27,7 @@ public class Reminder extends CustomMessageCreateListener implements ActionListe public Reminder(String channelName) { super(channelName); helpEmbed = new HelpEmbed(REMIND_COMMAND, - "To use this command first type the '!setReminder' command, followed by the time you want to be reminded (In Military Time), a comma, then your remind message \nP.S. Make sure when you input your time use a colon between the hours and minutes"); + "To use this command first type the '!setReminder' command, followed by the time you want to be reminded (In Military Time, in PST), a comma, then your remind message \nP.S. Make sure when you input your time use a colon between the hours and minutes"); } @Override From 7827f35076c655a60045e471efc47f96f2b50e64 Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 28 Mar 2021 13:13:45 -0700 Subject: [PATCH 32/55] 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 33/55] 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 34/55] 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 35/55] 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 36/55] 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 ebcc36a5461e253500f68c644dda5ce12d329bd4 Mon Sep 17 00:00:00 2001 From: Dexter H Date: Mon, 19 Apr 2021 18:25:31 -0700 Subject: [PATCH 37/55] Finished the marsImage feature. --- .../discord_bot_example/Bot.java | 10 +- .../jointheleague/modules/MarsPictures.java | 125 ++++++++++++++++++ .../modules/pojo/MarsImage/Camera.java | 56 ++++++++ .../pojo/MarsImage/MarsImageWrapper.java | 24 ++++ .../modules/pojo/MarsImage/Photo.java | 78 +++++++++++ .../modules/pojo/MarsImage/Rover.java | 74 +++++++++++ .../modules/pojo/MarsRover/Camera.java | 34 +++++ .../modules/pojo/MarsRover/ManifestRover.java | 112 ++++++++++++++++ .../pojo/MarsRover/MarsRoverWrapper.java | 23 ++++ src/main/resources/config.json | 4 +- 10 files changed, 535 insertions(+), 5 deletions(-) create mode 100644 src/main/java/org/jointheleague/modules/MarsPictures.java create mode 100644 src/main/java/org/jointheleague/modules/pojo/MarsImage/Camera.java create mode 100644 src/main/java/org/jointheleague/modules/pojo/MarsImage/MarsImageWrapper.java create mode 100644 src/main/java/org/jointheleague/modules/pojo/MarsImage/Photo.java create mode 100644 src/main/java/org/jointheleague/modules/pojo/MarsImage/Rover.java create mode 100644 src/main/java/org/jointheleague/modules/pojo/MarsRover/Camera.java create mode 100644 src/main/java/org/jointheleague/modules/pojo/MarsRover/ManifestRover.java create mode 100644 src/main/java/org/jointheleague/modules/pojo/MarsRover/MarsRoverWrapper.java 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 06e330bf..4e3ede22 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); @@ -59,6 +59,10 @@ public void connect(boolean printInvite) { api.addMessageCreateListener(maze); helpListener.addHelpEmbed(maze.getHelpEmbed()); + MarsPictures marsPictures = new MarsPictures(channelName); + api.addMessageCreateListener(marsPictures); + helpListener.addHelpEmbed(marsPictures.getHelpEmbed()); + HeadlineListener head = new HeadlineListener(channelName); api.addMessageCreateListener(head); helpListener.addHelpEmbed(head.getHelpEmbed()); diff --git a/src/main/java/org/jointheleague/modules/MarsPictures.java b/src/main/java/org/jointheleague/modules/MarsPictures.java new file mode 100644 index 00000000..86c1b715 --- /dev/null +++ b/src/main/java/org/jointheleague/modules/MarsPictures.java @@ -0,0 +1,125 @@ +package org.jointheleague.modules; + +import java.net.HttpURLConnection; +import java.net.URL; + +import javax.json.Json; +import javax.json.JsonObject; +import javax.json.JsonReader; + +import org.javacord.api.event.message.MessageCreateEvent; +import org.jointheleague.modules.pojo.HelpEmbed; +import org.jointheleague.modules.pojo.MarsImage.MarsImageWrapper; +import org.jointheleague.modules.pojo.MarsRover.ManifestRover; +import org.jointheleague.modules.pojo.MarsRover.MarsRoverWrapper; + +import com.google.gson.Gson; + +public class MarsPictures extends CustomMessageCreateListener{ + + private final String apiKey = "aY1trRHtbf5TdONEoOJcngI3SCjgeZbAPRPf7ccx"; + private static final String COMMAND = "!marsImage"; + private final Gson gson = new Gson(); + + public MarsPictures(String channelName) { + super(channelName); + helpEmbed = new HelpEmbed(COMMAND, "This command will return an image taken by a mars rover (either Curiosity, Opportunity, or Spirit). " + + "This command will require you to input the rover you want to get pictures from and the martian sol (day) that you want to get images from. " + + "You are also optionally able to input a specific camera to get images from. The parameters should be in the order . " + + "Use \"!marsImage cameras\" to see what cameras are supported by what rovers. Use \"!marsImage manifest \" to see the mission manifest " + + "of the rover."); + } + + @Override + public void handle(MessageCreateEvent event) { + if(!event.getMessageAuthor().isBotUser() && event.getMessageContent().startsWith(COMMAND)) { + //remove the command so we are only left with the search term + String msg = event.getMessageContent().replace(COMMAND + " ", ""); + String[] parameterList = msg.split(" "); + + for (int i = 0; i < parameterList.length; i++) { + System.out.println(parameterList[i]); + } + + if(parameterList[0].equalsIgnoreCase(COMMAND) || parameterList[0].equalsIgnoreCase("help")) { + event.getChannel().sendMessage(helpEmbed.getDescription()); + } else if(parameterList[0].equalsIgnoreCase("cameras")) { + event.getChannel().sendMessage("```" + + "Abbreviation: | Camera: | Rovers:\n" + + "FHAZ | Front Hazard Avoidance Camera | Curiosity, Opportunity, Spirit\n" + + "RHAZ | Rear Hazard Avoidance Camera | Curiosity, Opportunity, Spirit\n" + + "MAST | Mast Camera | Curiosity\n" + + "CHEMCAM | Chemistry and Camera Complex | Curiosity\n" + + "MAHLI | Mars Hand Lens Imager | Curiosity\n" + + "MARDI | Mars descent Imager | Curiosity\n" + + "NAVCAM | Navigation Camera | Curiosity, Opportunity, Spirit\n" + + "PANCAM | Panoramic Camera | Opportunity, Spirit\n" + + "MINITES | Miniature Thermal Emission Spectrometer | Opportunity, Spirit\n" + + "```"); + } else if(parameterList[0].equalsIgnoreCase("manifest") && parameterList.length > 1){ + event.getChannel().sendMessage(getMarsRoverManifest(parameterList[1])); + } else { + if (parameterList.length < 2) { + event.getChannel().sendMessage("You didn't enter enough parameters. Use the \"help\" parameter for more information."); + } else if (parameterList.length == 2){ + event.getChannel().sendMessage(getMarsImageURL(parameterList[0], parameterList[1])); + } else { + event.getChannel().sendMessage(getMarsImageURL(parameterList[0], parameterList[2], parameterList[1])); + } + } + } + } + + public String getMarsImageURL(String rover, String sol) { + return getMarsImageURL(rover, "", sol); + } + + public String getMarsImageURL(String rover, String camera, String sol) { + + String requestURL; + + if(camera.equals("")) { + requestURL = "https://api.nasa.gov/mars-photos/api/v1/rovers/" + rover.toLowerCase() + "/photos?" + "sol=" + sol + "&api_key=" + apiKey; + }else { + requestURL = "https://api.nasa.gov/mars-photos/api/v1/rovers/" + rover.toLowerCase() + "/photos?" + "sol=" + sol + "&camera=" + camera.toUpperCase() + "&api_key=" + apiKey; + } + + try { + URL url = new URL(requestURL); + HttpURLConnection con = (HttpURLConnection) url.openConnection(); + con.setRequestMethod("GET"); + JsonReader repoReader = Json.createReader(con.getInputStream()); + JsonObject userJSON = ((JsonObject) repoReader.read()); + con.disconnect(); + + MarsImageWrapper marsImageWrapper = gson.fromJson(userJSON.toString(), MarsImageWrapper.class); + + return marsImageWrapper.getPhotos().get(0).getImgSrc(); + + } catch (Exception e) { + return "A parameter was invalid or unavailable."; + } + } + + public String getMarsRoverManifest(String rover) { + String requestURL = "https://api.nasa.gov/mars-photos/api/v1/rovers/" + rover.toLowerCase() + "/?api_key=" + apiKey; + + try { + URL url = new URL(requestURL); + HttpURLConnection con = (HttpURLConnection) url.openConnection(); + con.setRequestMethod("GET"); + JsonReader repoReader = Json.createReader(con.getInputStream()); + JsonObject userJSON = ((JsonObject) repoReader.read()); + con.disconnect(); + + MarsRoverWrapper manifestRover = gson.fromJson(userJSON.toString(), MarsRoverWrapper .class); + ManifestRover manifest = manifestRover.getRover(); + + return "Name: " + manifest.getName() + ", Status: " + manifest.getStatus() + ", Launch Date: " + + manifest.getLaunchDate() + ", Landing Date: " + manifest.getLandingDate() + ", Max Sol: " + manifest.getMaxSol(); + + } catch (Exception e) { + return "A parameter was invalid."; + } + } +} diff --git a/src/main/java/org/jointheleague/modules/pojo/MarsImage/Camera.java b/src/main/java/org/jointheleague/modules/pojo/MarsImage/Camera.java new file mode 100644 index 00000000..e59e0bc7 --- /dev/null +++ b/src/main/java/org/jointheleague/modules/pojo/MarsImage/Camera.java @@ -0,0 +1,56 @@ + +package org.jointheleague.modules.pojo.MarsImage; + +import javax.annotation.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +@Generated("jsonschema2pojo") +public class Camera { + + @SerializedName("id") + @Expose + private Integer id; + @SerializedName("name") + @Expose + private String name; + @SerializedName("rover_id") + @Expose + private Integer roverId; + @SerializedName("full_name") + @Expose + private String fullName; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getRoverId() { + return roverId; + } + + public void setRoverId(Integer roverId) { + this.roverId = roverId; + } + + public String getFullName() { + return fullName; + } + + public void setFullName(String fullName) { + this.fullName = fullName; + } + +} diff --git a/src/main/java/org/jointheleague/modules/pojo/MarsImage/MarsImageWrapper.java b/src/main/java/org/jointheleague/modules/pojo/MarsImage/MarsImageWrapper.java new file mode 100644 index 00000000..6647ff30 --- /dev/null +++ b/src/main/java/org/jointheleague/modules/pojo/MarsImage/MarsImageWrapper.java @@ -0,0 +1,24 @@ + +package org.jointheleague.modules.pojo.MarsImage; + +import java.util.List; +import javax.annotation.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +@Generated("jsonschema2pojo") +public class MarsImageWrapper { + + @SerializedName("photos") + @Expose + private List photos = null; + + public List getPhotos() { + return photos; + } + + public void setPhotos(List photos) { + this.photos = photos; + } + +} diff --git a/src/main/java/org/jointheleague/modules/pojo/MarsImage/Photo.java b/src/main/java/org/jointheleague/modules/pojo/MarsImage/Photo.java new file mode 100644 index 00000000..7f9c1016 --- /dev/null +++ b/src/main/java/org/jointheleague/modules/pojo/MarsImage/Photo.java @@ -0,0 +1,78 @@ + +package org.jointheleague.modules.pojo.MarsImage; + +import javax.annotation.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +@Generated("jsonschema2pojo") +public class Photo { + + @SerializedName("id") + @Expose + private Integer id; + @SerializedName("sol") + @Expose + private Integer sol; + @SerializedName("camera") + @Expose + private Camera camera; + @SerializedName("img_src") + @Expose + private String imgSrc; + @SerializedName("earth_date") + @Expose + private String earthDate; + @SerializedName("rover") + @Expose + private Rover rover; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getSol() { + return sol; + } + + public void setSol(Integer sol) { + this.sol = sol; + } + + public Camera getCamera() { + return camera; + } + + public void setCamera(Camera camera) { + this.camera = camera; + } + + public String getImgSrc() { + return imgSrc; + } + + public void setImgSrc(String imgSrc) { + this.imgSrc = imgSrc; + } + + public String getEarthDate() { + return earthDate; + } + + public void setEarthDate(String earthDate) { + this.earthDate = earthDate; + } + + public Rover getRover() { + return rover; + } + + public void setRover(Rover rover) { + this.rover = rover; + } + +} diff --git a/src/main/java/org/jointheleague/modules/pojo/MarsImage/Rover.java b/src/main/java/org/jointheleague/modules/pojo/MarsImage/Rover.java new file mode 100644 index 00000000..014619f2 --- /dev/null +++ b/src/main/java/org/jointheleague/modules/pojo/MarsImage/Rover.java @@ -0,0 +1,74 @@ + +package org.jointheleague.modules.pojo.MarsImage; + +import javax.annotation.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +@Generated("jsonschema2pojo") +public class Rover { + + @SerializedName("id") + @Expose + private Integer id; + @SerializedName("name") + @Expose + private String name; + @SerializedName("landing_date") + @Expose + private String landingDate; + @SerializedName("launch_date") + @Expose + private String launchDate; + @SerializedName("status") + @Expose + private String status; + @SerializedName("max_sol") + @Expose + private int maxSol; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLandingDate() { + return landingDate; + } + + public void setLandingDate(String landingDate) { + this.landingDate = landingDate; + } + + public String getLaunchDate() { + return launchDate; + } + + public void setLaunchDate(String launchDate) { + this.launchDate = launchDate; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public int getMaxSol() { + return maxSol; + } + +} diff --git a/src/main/java/org/jointheleague/modules/pojo/MarsRover/Camera.java b/src/main/java/org/jointheleague/modules/pojo/MarsRover/Camera.java new file mode 100644 index 00000000..ac1a8c62 --- /dev/null +++ b/src/main/java/org/jointheleague/modules/pojo/MarsRover/Camera.java @@ -0,0 +1,34 @@ + +package org.jointheleague.modules.pojo.MarsRover; + +import javax.annotation.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +@Generated("jsonschema2pojo") +public class Camera { + + @SerializedName("name") + @Expose + private String name; + @SerializedName("full_name") + @Expose + private String fullName; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getFullName() { + return fullName; + } + + public void setFullName(String fullName) { + this.fullName = fullName; + } + +} diff --git a/src/main/java/org/jointheleague/modules/pojo/MarsRover/ManifestRover.java b/src/main/java/org/jointheleague/modules/pojo/MarsRover/ManifestRover.java new file mode 100644 index 00000000..2232de5c --- /dev/null +++ b/src/main/java/org/jointheleague/modules/pojo/MarsRover/ManifestRover.java @@ -0,0 +1,112 @@ + +package org.jointheleague.modules.pojo.MarsRover; + +import java.util.List; +import javax.annotation.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +@Generated("jsonschema2pojo") +public class ManifestRover { + + @SerializedName("id") + @Expose + private Integer id; + @SerializedName("name") + @Expose + private String name; + @SerializedName("landing_date") + @Expose + private String landingDate; + @SerializedName("launch_date") + @Expose + private String launchDate; + @SerializedName("status") + @Expose + private String status; + @SerializedName("max_sol") + @Expose + private Integer maxSol; + @SerializedName("max_date") + @Expose + private String maxDate; + @SerializedName("total_photos") + @Expose + private Integer totalPhotos; + @SerializedName("cameras") + @Expose + private List cameras = null; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLandingDate() { + return landingDate; + } + + public void setLandingDate(String landingDate) { + this.landingDate = landingDate; + } + + public String getLaunchDate() { + return launchDate; + } + + public void setLaunchDate(String launchDate) { + this.launchDate = launchDate; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Integer getMaxSol() { + return maxSol; + } + + public void setMaxSol(Integer maxSol) { + this.maxSol = maxSol; + } + + public String getMaxDate() { + return maxDate; + } + + public void setMaxDate(String maxDate) { + this.maxDate = maxDate; + } + + public Integer getTotalPhotos() { + return totalPhotos; + } + + public void setTotalPhotos(Integer totalPhotos) { + this.totalPhotos = totalPhotos; + } + + public List getCameras() { + return cameras; + } + + public void setCameras(List cameras) { + this.cameras = cameras; + } + +} diff --git a/src/main/java/org/jointheleague/modules/pojo/MarsRover/MarsRoverWrapper.java b/src/main/java/org/jointheleague/modules/pojo/MarsRover/MarsRoverWrapper.java new file mode 100644 index 00000000..b1a2686d --- /dev/null +++ b/src/main/java/org/jointheleague/modules/pojo/MarsRover/MarsRoverWrapper.java @@ -0,0 +1,23 @@ + +package org.jointheleague.modules.pojo.MarsRover; + +import javax.annotation.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +@Generated("jsonschema2pojo") +public class MarsRoverWrapper { + + @SerializedName("rover") + @Expose + private ManifestRover rover; + + public ManifestRover getRover() { + return rover; + } + + public void setRover(ManifestRover rover) { + this.rover = rover; + } + +} diff --git a/src/main/resources/config.json b/src/main/resources/config.json index 0b58c8d9..4dd58050 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,4 +1,4 @@ { - "channels": ["channelName"], - "token": "discordToken" + "channels": [""], + "token": "" } From 3ccce817c2afb4ba000260426b909cd7ef63ca47 Mon Sep 17 00:00:00 2001 From: cheetah676 Date: Sun, 25 Apr 2021 11:31:17 -0700 Subject: [PATCH 38/55] 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 39/55] 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 40/55] 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 41/55] 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 42/55] 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 43/55] 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 44/55] 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 45/55] 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 46/55] 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 47/55] 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"; From 4d0ed9c0f2f4b58165ddcf6ef1f840236b5b7acf Mon Sep 17 00:00:00 2001 From: sen <87282133+surroundedxd@users.noreply.github.com> Date: Mon, 10 Jan 2022 18:05:42 -0800 Subject: [PATCH 48/55] commit --- .gitignore | 2 + .idea/.gitignore | 3 + .idea/compiler.xml | 13 + .idea/encodings.xml | 7 + .idea/jarRepositories.xml | 20 + .idea/misc.xml | 12 + .idea/uiDesigner.xml | 124 ++++++ .idea/vcs.xml | 6 + .../discord_bot_example/Bot.java | 381 +++++++++--------- .../org/jointheleague/modules/MazeGame.java | 2 +- .../org/jointheleague/modules/PingPong.java | 24 ++ src/main/resources/WolframAlpha-1.1.jar | Bin 74513 -> 0 bytes src/main/resources/config.json | 4 - 13 files changed, 400 insertions(+), 198 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml create mode 100644 src/main/java/org/jointheleague/modules/PingPong.java delete mode 100644 src/main/resources/WolframAlpha-1.1.jar delete mode 100644 src/main/resources/config.json diff --git a/.gitignore b/.gitignore index 330a9173..aece16ef 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,5 @@ target/ src/main/resources/config.json src/main/resources/config.json +src/main/resources/config.json +src/main/resources/config.json diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 00000000..5b2e27ba --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 00000000..aa00ffab --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 00000000..712ab9d9 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..6c4f88c6 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 00000000..e96534fb --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file 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 0dac01fb..8a9a7778 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -1,212 +1,207 @@ package org.jointheleague.discord_bot_example; import org.javacord.api.DiscordApi; - import org.javacord.api.DiscordApiBuilder; - -/** - * Launches all of the listeners for one channel. - * @author keithgroves and https://tinystripz.com - * - */ import org.jointheleague.modules.*; public class Bot { - // The string to show the custom :vomiting_robot: emoji - public static String emoji = "<:vomiting_robot:642414033290657803>"; - - private String token; - private String channelName; - DiscordApi api; - _HelpListener helpListener; + // The string to show the custom :vomiting_robot: emoji + public static String emoji = "<:vomiting_robot:642414033290657803>"; - public Bot(String token, String channelName) { - this.token = token; - this.channelName = channelName; - helpListener = new _HelpListener(channelName); - } + private final String token; + private final String channelName; + DiscordApi api; + _HelpListener helpListener; - public void connect(boolean printInvite) { + public Bot(String token, String channelName) { + this.token = token; + this.channelName = channelName; + helpListener = new _HelpListener(channelName); + } - api = new DiscordApiBuilder().setToken(token).login().join(); + public void connect(boolean printInvite) { + api = new DiscordApiBuilder().setToken(token).login().join(); - // Print the URL to invite the bot - if (printInvite) { - System.out.println("You can invite the bot by using the following url: " + api.createBotInvite()); - } + // Print the URL to invite the bot + if (printInvite) { + System.out.println("You can invite the bot by using the following url: " + api.createBotInvite()); + } - api.getServerTextChannelsByName(channelName).forEach(e -> e.sendMessage("Bot Connected")); + api.getServerTextChannelsByName(channelName).forEach(e -> e.sendMessage("Bot Connected")); - // add Listeners - DiscordLibrary dl = new DiscordLibrary(channelName); - api.addMessageCreateListener(dl); - helpListener.addHelpEmbed(dl.getHelpEmbed()); + // add Listeners + DiscordLibrary dl = new DiscordLibrary(channelName); + api.addMessageCreateListener(dl); + helpListener.addHelpEmbed(dl.getHelpEmbed()); // CurrencyConverter cc = new CurrencyConverter(channelName); // api.addMessageCreateListener(cc); // helpListener.addHelpEmbed(cc.getHelpEmbed()); - - ToDoList list = new ToDoList(channelName); - api.addMessageCreateListener(list); - helpListener.addHelpEmbed(list.getHelpEmbed()); - - MazeGame maze = new MazeGame(channelName); - api.addMessageCreateListener(maze); - helpListener.addHelpEmbed(maze.getHelpEmbed()); - - MarsPictures marsPictures = new MarsPictures(channelName); - api.addMessageCreateListener(marsPictures); - helpListener.addHelpEmbed(marsPictures.getHelpEmbed()); - - HeadlineListener head = new HeadlineListener(channelName); - api.addMessageCreateListener(head); - helpListener.addHelpEmbed(head.getHelpEmbed()); - - RandomNumber randomNumber = new RandomNumber(channelName); // replace with feature class later - api.addMessageCreateListener(randomNumber); - helpListener.addHelpEmbed(randomNumber.getHelpEmbed()); - - HypeMachine hypeMachine = new HypeMachine(channelName); - api.addMessageCreateListener(hypeMachine); - helpListener.addHelpEmbed(hypeMachine.getHelpEmbed()); - - TextStyler textStyler = new TextStyler(channelName); - api.addMessageCreateListener(textStyler); - helpListener.addHelpEmbed(textStyler.getHelpEmbed()); - - Tomagachi tomagachi = new Tomagachi(channelName); - api.addMessageCreateListener(tomagachi); - helpListener.addHelpEmbed(tomagachi.getHelpEmbed()); - - SetProfilePic setPFP = new SetProfilePic(channelName); - api.addMessageCreateListener(setPFP); - helpListener.addHelpEmbed(setPFP.getHelpEmbed()); - - ToGif toGif = new ToGif(channelName); - api.addMessageCreateListener(toGif); - helpListener.addHelpEmbed(toGif.getHelpEmbed()); - - RandomCase randomCase = new RandomCase(channelName); - api.addMessageCreateListener(randomCase); - helpListener.addHelpEmbed(randomCase.getHelpEmbed()); - - _ApiExampleListener apiExampleListener = new _ApiExampleListener(channelName); - api.addMessageCreateListener(apiExampleListener); - helpListener.addHelpEmbed(apiExampleListener.getHelpEmbed()); - - NewWeather newWeather = new NewWeather(channelName); - api.addMessageCreateListener(newWeather); - helpListener.addHelpEmbed(newWeather.getHelpEmbed()); - - CoinFlip cp = new CoinFlip(channelName); - api.addMessageCreateListener(cp); - - RollDie rollDie = new RollDie(channelName); - api.addMessageCreateListener(rollDie); - - MaxTicTacToe mttt = new MaxTicTacToe(channelName); - api.addMessageCreateListener(mttt); - helpListener.addHelpEmbed(mttt.getHelpEmbed()); - - pythagcalc pythagCalc = new pythagcalc(channelName); - api.addMessageCreateListener(pythagCalc); - helpListener.addHelpEmbed(pythagCalc.getHelpEmbed()); - - Reminder reminder = new Reminder(channelName); - api.addMessageCreateListener(reminder); - helpListener.addHelpEmbed(reminder.getHelpEmbed()); - - Hello hello = new Hello(channelName); - api.addMessageCreateListener(hello); - helpListener.addHelpEmbed(hello.getHelpEmbed()); - - Poll poll = new Poll(channelName); - api.addMessageCreateListener(poll); - helpListener.addHelpEmbed(poll.getHelpEmbed()); - - //Greeter g = new Greeter(channelName); - //api.addMessageCreateListener(g); - //helpListener.addHelpEmbed(g.getHelpEmbed()); - DiscordZoomAccess dza = new DiscordZoomAccess(channelName); - api.addMessageCreateListener(dza); - helpListener.addHelpEmbed(dza.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()); - - ListMakerMessageListener LM = new ListMakerMessageListener(channelName); - api.addMessageCreateListener(LM); - helpListener.addHelpEmbed(LM.getHelpEmbed()); - - Dice d = new Dice(channelName); - api.addMessageCreateListener(d); - helpListener.addHelpEmbed(d.getHelpEmbed()); - - UnbeatableRockPaperScissors rps = new UnbeatableRockPaperScissors(channelName); - api.addMessageCreateListener(rps); - helpListener.addHelpEmbed(rps.getHelpEmbed()); - - FilmRecommendations f = new FilmRecommendations(channelName); - api.addMessageCreateListener(f); - helpListener.addHelpEmbed(f.getHelpEmbed()); - - Depression depress = new Depression(channelName); - api.addMessageCreateListener(depress); - helpListener.addHelpEmbed(depress.getHelpEmbed()); - - Depression depress = new Depression(channelName); - api.addMessageCreateListener(depress); - helpListener.addHelpEmbed(depress.getHelpEmbed()); - - // old way to add listeners - api.addMessageCreateListener(helpListener); - api.addMessageCreateListener(new MomBot(channelName)); - api.addMessageCreateListener(new DadJokes(channelName)); - api.addMessageCreateListener(new ClockMessageListener(channelName)); - api.addMessageCreateListener(new CalculatorMessageListener(channelName)); - api.addMessageCreateListener(new ComicMessageListener(channelName)); - api.addMessageCreateListener(new ElmoMessageListener(channelName)); - api.addMessageCreateListener(new FactMessageListener(channelName)); - api.addMessageCreateListener(new CasinoGameListener(channelName)); - api.addMessageCreateListener(new HighLowListener(channelName)); - api.addMessageCreateListener(new Ryland(channelName)); - api.addMessageCreateListener(new RockPaperScissorsListener(channelName)); - api.addMessageCreateListener(new leetMessageListener(channelName)); - api.addMessageCreateListener(new ConnectFour(channelName)); - api.addMessageCreateListener(new FlagMessageListener(channelName)); - api.addMessageCreateListener(new EightBall(channelName)); - api.addMessageCreateListener(new Reddit(channelName)); - api.addMessageCreateListener(new DeepFrier(channelName)); - api.addMessageCreateListener(new PictureOf(channelName)); - api.addMessageCreateListener(new GetPicture(channelName)); - api.addMessageCreateListener(new CuteAnimal(channelName)); - api.addMessageCreateListener(new Weather(channelName)); - api.addMessageCreateListener(new FashionAdvisor(channelName)); - api.addMessageCreateListener(new LatexRender(channelName)); - api.addMessageCreateListener(new MinesweeperListener(channelName)); - api.addMessageCreateListener(new Bot1Listener(channelName)); - api.addMessageCreateListener(new PingMessageListener(channelName)); - api.addMessageCreateListener(new CoinFlipMessageListener(channelName)); - api.addMessageCreateListener(new PlayRPSMessageListener(channelName)); - api.addMessageCreateListener(new KickMessageListener(channelName)); - api.addMessageCreateListener(new AssignRoleMessageListener(channelName)); - api.addMessageCreateListener(new NicknameListener(channelName)); - api.addMessageCreateListener(new SolveQuadraticListener(channelName)); - api.addMessageCreateListener(new RollDiceMessageListener(channelName)); - api.addMessageCreateListener(new MorseTranslator(channelName)); - api.addMessageCreateListener(new HangmanListener(channelName)); - api.addMessageCreateListener(new BogoSorterListener(channelName)); - api.addMessageCreateListener(new ComplimentListener(channelName)); - api.addMessageCreateListener(new CrazyEights(channelName)); - api.addMessageCreateListener(new Blackjack(channelName)); - api.addMessageCreateListener(new RandomCase(channelName)); - api.addMessageCreateListener(new GetTime(channelName)); - api.addMessageCreateListener(new ScreenCapture(channelName)); - } + + ToDoList list = new ToDoList(channelName); + api.addMessageCreateListener(list); + helpListener.addHelpEmbed(list.getHelpEmbed()); + + MazeGame maze = new MazeGame(channelName); + api.addMessageCreateListener(maze); + helpListener.addHelpEmbed(maze.getHelpEmbed()); + + MarsPictures marsPictures = new MarsPictures(channelName); + api.addMessageCreateListener(marsPictures); + helpListener.addHelpEmbed(marsPictures.getHelpEmbed()); + + HeadlineListener head = new HeadlineListener(channelName); + api.addMessageCreateListener(head); + helpListener.addHelpEmbed(head.getHelpEmbed()); + + RandomNumber randomNumber = new RandomNumber(channelName); // replace with feature class later + api.addMessageCreateListener(randomNumber); + helpListener.addHelpEmbed(randomNumber.getHelpEmbed()); + + HypeMachine hypeMachine = new HypeMachine(channelName); + api.addMessageCreateListener(hypeMachine); + helpListener.addHelpEmbed(hypeMachine.getHelpEmbed()); + + TextStyler textStyler = new TextStyler(channelName); + api.addMessageCreateListener(textStyler); + helpListener.addHelpEmbed(textStyler.getHelpEmbed()); + + Tomagachi tomagachi = new Tomagachi(channelName); + api.addMessageCreateListener(tomagachi); + helpListener.addHelpEmbed(tomagachi.getHelpEmbed()); + + SetProfilePic setPFP = new SetProfilePic(channelName); + api.addMessageCreateListener(setPFP); + helpListener.addHelpEmbed(setPFP.getHelpEmbed()); + + ToGif toGif = new ToGif(channelName); + api.addMessageCreateListener(toGif); + helpListener.addHelpEmbed(toGif.getHelpEmbed()); + + RandomCase randomCase = new RandomCase(channelName); + api.addMessageCreateListener(randomCase); + helpListener.addHelpEmbed(randomCase.getHelpEmbed()); + + _ApiExampleListener apiExampleListener = new _ApiExampleListener(channelName); + api.addMessageCreateListener(apiExampleListener); + helpListener.addHelpEmbed(apiExampleListener.getHelpEmbed()); + + NewWeather newWeather = new NewWeather(channelName); + api.addMessageCreateListener(newWeather); + helpListener.addHelpEmbed(newWeather.getHelpEmbed()); + + CoinFlip cp = new CoinFlip(channelName); + api.addMessageCreateListener(cp); + + RollDie rollDie = new RollDie(channelName); + api.addMessageCreateListener(rollDie); + + MaxTicTacToe mttt = new MaxTicTacToe(channelName); + api.addMessageCreateListener(mttt); + helpListener.addHelpEmbed(mttt.getHelpEmbed()); + + pythagcalc pythagCalc = new pythagcalc(channelName); + api.addMessageCreateListener(pythagCalc); + helpListener.addHelpEmbed(pythagCalc.getHelpEmbed()); + + Reminder reminder = new Reminder(channelName); + api.addMessageCreateListener(reminder); + helpListener.addHelpEmbed(reminder.getHelpEmbed()); + + Hello hello = new Hello(channelName); + api.addMessageCreateListener(hello); + helpListener.addHelpEmbed(hello.getHelpEmbed()); + + Poll poll = new Poll(channelName); + api.addMessageCreateListener(poll); + helpListener.addHelpEmbed(poll.getHelpEmbed()); + + //Greeter g = new Greeter(channelName); + //api.addMessageCreateListener(g); + //helpListener.addHelpEmbed(g.getHelpEmbed()); + DiscordZoomAccess dza = new DiscordZoomAccess(channelName); + api.addMessageCreateListener(dza); + helpListener.addHelpEmbed(dza.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()); + + ListMakerMessageListener LM = new ListMakerMessageListener(channelName); + api.addMessageCreateListener(LM); + helpListener.addHelpEmbed(LM.getHelpEmbed()); + + Dice d = new Dice(channelName); + api.addMessageCreateListener(d); + helpListener.addHelpEmbed(d.getHelpEmbed()); + + UnbeatableRockPaperScissors rps = new UnbeatableRockPaperScissors(channelName); + api.addMessageCreateListener(rps); + helpListener.addHelpEmbed(rps.getHelpEmbed()); + + FilmRecommendations f = new FilmRecommendations(channelName); + api.addMessageCreateListener(f); + helpListener.addHelpEmbed(f.getHelpEmbed()); + + Depression depress = new Depression(channelName); + api.addMessageCreateListener(depress); + helpListener.addHelpEmbed(depress.getHelpEmbed()); + + PingPong pingPong = new PingPong(channelName); + api.addMessageCreateListener(pingPong); + +// Depression depress = new Depression(channelName); +// api.addMessageCreateListener(depress); +// helpListener.addHelpEmbed(depress.getHelpEmbed()); + + // old way to add listeners + api.addMessageCreateListener(helpListener); + api.addMessageCreateListener(new MomBot(channelName)); + api.addMessageCreateListener(new DadJokes(channelName)); + api.addMessageCreateListener(new ClockMessageListener(channelName)); + api.addMessageCreateListener(new CalculatorMessageListener(channelName)); + api.addMessageCreateListener(new ComicMessageListener(channelName)); + api.addMessageCreateListener(new ElmoMessageListener(channelName)); + api.addMessageCreateListener(new FactMessageListener(channelName)); + api.addMessageCreateListener(new CasinoGameListener(channelName)); + api.addMessageCreateListener(new HighLowListener(channelName)); + api.addMessageCreateListener(new Ryland(channelName)); + api.addMessageCreateListener(new RockPaperScissorsListener(channelName)); + api.addMessageCreateListener(new leetMessageListener(channelName)); + api.addMessageCreateListener(new ConnectFour(channelName)); + api.addMessageCreateListener(new FlagMessageListener(channelName)); + api.addMessageCreateListener(new EightBall(channelName)); + api.addMessageCreateListener(new Reddit(channelName)); + api.addMessageCreateListener(new DeepFrier(channelName)); + api.addMessageCreateListener(new PictureOf(channelName)); + api.addMessageCreateListener(new GetPicture(channelName)); + api.addMessageCreateListener(new CuteAnimal(channelName)); + api.addMessageCreateListener(new Weather(channelName)); + api.addMessageCreateListener(new FashionAdvisor(channelName)); + api.addMessageCreateListener(new LatexRender(channelName)); + api.addMessageCreateListener(new MinesweeperListener(channelName)); + api.addMessageCreateListener(new Bot1Listener(channelName)); + api.addMessageCreateListener(new PingMessageListener(channelName)); + api.addMessageCreateListener(new CoinFlipMessageListener(channelName)); + api.addMessageCreateListener(new PlayRPSMessageListener(channelName)); + api.addMessageCreateListener(new KickMessageListener(channelName)); + api.addMessageCreateListener(new AssignRoleMessageListener(channelName)); + api.addMessageCreateListener(new NicknameListener(channelName)); + api.addMessageCreateListener(new SolveQuadraticListener(channelName)); + api.addMessageCreateListener(new RollDiceMessageListener(channelName)); + api.addMessageCreateListener(new MorseTranslator(channelName)); + api.addMessageCreateListener(new HangmanListener(channelName)); + api.addMessageCreateListener(new BogoSorterListener(channelName)); + api.addMessageCreateListener(new ComplimentListener(channelName)); + api.addMessageCreateListener(new CrazyEights(channelName)); + api.addMessageCreateListener(new Blackjack(channelName)); + api.addMessageCreateListener(new RandomCase(channelName)); + api.addMessageCreateListener(new GetTime(channelName)); + api.addMessageCreateListener(new ScreenCapture(channelName)); + } } \ No newline at end of file diff --git a/src/main/java/org/jointheleague/modules/MazeGame.java b/src/main/java/org/jointheleague/modules/MazeGame.java index 76e1f77c..b972c5c0 100644 --- a/src/main/java/org/jointheleague/modules/MazeGame.java +++ b/src/main/java/org/jointheleague/modules/MazeGame.java @@ -30,7 +30,7 @@ public void handle(MessageCreateEvent event) throws APIException { System.out.println("Heard message: " + event.getMessageContent()); if (event.getMessageContent().contains(COMMAND) && !event.getMessageAuthor().isBotUser()) { if (event.getMessageContent().contains("start") || event.getMessageContent().contains("load")) { - String target = event.getMessageContent().substring(11).strip(); + String target = event.getMessageContent().substring(11); try { if(!target.equalsIgnoreCase("upload")) { diff --git a/src/main/java/org/jointheleague/modules/PingPong.java b/src/main/java/org/jointheleague/modules/PingPong.java new file mode 100644 index 00000000..0a92b47a --- /dev/null +++ b/src/main/java/org/jointheleague/modules/PingPong.java @@ -0,0 +1,24 @@ +package org.jointheleague.modules; + +import net.aksingh.owmjapis.api.APIException; +import org.javacord.api.event.message.MessageCreateEvent; +import org.jointheleague.modules.pojo.HelpEmbed; + +public class PingPong extends CustomMessageCreateListener { + private static final String prefix = "!ping"; + + public PingPong(String channelName) { + super(channelName); + this.helpEmbed = new HelpEmbed(prefix, "Pong!!!!"); + } + + @Override + public void handle(MessageCreateEvent event) throws APIException { + String content = event.getMessageContent(); + + if (content.isEmpty()) return; + if (content.toLowerCase().contentEquals(prefix)) { + event.getChannel().sendMessage("Pong!"); + } + } +} \ No newline at end of file diff --git a/src/main/resources/WolframAlpha-1.1.jar b/src/main/resources/WolframAlpha-1.1.jar deleted file mode 100644 index 9b98a5060a2dce2484f539fd9148fd0d54085d60..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 74513 zcmafabzEH8vNge_2_D?t-7Q$-?(XgqT!On>2=4Cg?(Xg$JUBrRxoFo`HEXZ%KEImfP-#`5E2L=QjL|Q~ifL2@vNdGzl0wVXvRA`X& z_o;921S!MsQ=LA5fS|r#|2!WqNqeC4fKi`FX>@G1m63$_0phOSsPbaTy975i`8#AcQ9Y$nuG$;_JnGP4-;7xhx%e_*XqdJB5O!OYB6Ml z2bMdD0Zvk{--n|6DL4VlN7gcsNfKNq*!W@|-!Lhk((D@qr4?gT3eh#uK7I*P);1Vf zE+8w0C1va@F)9^A>wZCLIdFkKa0RLr`3o(2($|&M+L%Nwv{!b2=gE%W-`eh9mRdwJ zXWGu?mIzDEa}{&$az1=fO@DBqHD&)F)BmrRz~4WvZ$|&G^Uba8to~uqr~kUh#@Oi}*5Ll_8htx`Lo?%lSc?6(OaDK=^Y0g0 zFggCyfBf%WaWZ!NCkwIu>(6vHcQkjhb@;b=(7%(U-!Xbi3Je6q7!m}8vRE9|^WMky_+Ng)R-&0#SDzaK}+i8jCe!_Hy^ zK)f1W8bxEQqClt{iS7x)huW))PLtlY^1?g###wi#>+^O+jP7fdV-A3?mBN_n%}IV`Z1lFPt=>OO}C zFSROXy_mWLtFE0DrL{NC>2m-D zSw|khW|>?(wOipD&#vI*w5P8bB>IIH zzn4=KHZYx);Y%;V9MEKCI9eMa94J0IRn@<16E|_Lq3CoSFpaj%qs*&_tA06#vCc8N zEAw5DpRvU)Y14^?dXDfiVR|79z55tOG}gbjb|b_OgqC{NZ~D<+sCJlRq7PXYnmzpx z4k;7WK53_4xjG-QEvy1L-E7>^>TK)sSbc^24gIqb!Y5{4%J4R%BG_%NE;L&fodFRo z7@NIcRA1{BZz#RLZtMfBtL{$emL+m0YzN&H{FHR4E?6hs740Q9awm+ptKZp;-74N0oPIT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ibf9^ZTN`eDc U Date: Mon, 10 Jan 2022 18:06:52 -0800 Subject: [PATCH 49/55] Update PingPong.java --- src/main/java/org/jointheleague/modules/PingPong.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jointheleague/modules/PingPong.java b/src/main/java/org/jointheleague/modules/PingPong.java index 0a92b47a..c7c781ea 100644 --- a/src/main/java/org/jointheleague/modules/PingPong.java +++ b/src/main/java/org/jointheleague/modules/PingPong.java @@ -5,7 +5,7 @@ import org.jointheleague.modules.pojo.HelpEmbed; public class PingPong extends CustomMessageCreateListener { - private static final String prefix = "!ping"; + private static final String prefix = "!pingpong"; public PingPong(String channelName) { super(channelName); From 46403af79d2d392a811b73923f5a260245b67c6e Mon Sep 17 00:00:00 2001 From: Roshan Sood Date: Mon, 10 Jan 2022 18:26:08 -0800 Subject: [PATCH 50/55] Created Random Number Feature --- .idea/.gitignore | 3 + .idea/jarRepositories.xml | 20 +++ .idea/misc.xml | 12 ++ .idea/uiDesigner.xml | 124 ++++++++++++++++++ .idea/vcs.xml | 6 + .../discord_bot_example/Bot.java | 11 +- .../org/jointheleague/modules/MazeGame.java | 2 +- .../jointheleague/modules/NumberRandom.java | 23 ++++ src/main/resources/config.json | 4 +- 9 files changed, 199 insertions(+), 6 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml create mode 100644 src/main/java/org/jointheleague/modules/NumberRandom.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 00000000..712ab9d9 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..93c3f204 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 00000000..e96534fb --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file 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 0dac01fb..35e3d0cb 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -39,6 +39,11 @@ public void connect(boolean printInvite) { api.getServerTextChannelsByName(channelName).forEach(e -> e.sendMessage("Bot Connected")); // add Listeners + + NumberRandom rn = new NumberRandom(channelName); + api.addMessageCreateListener(rn); + helpListener.addHelpEmbed(rn.getHelpEmbed()); + DiscordLibrary dl = new DiscordLibrary(channelName); api.addMessageCreateListener(dl); helpListener.addHelpEmbed(dl.getHelpEmbed()); @@ -160,9 +165,9 @@ public void connect(boolean printInvite) { api.addMessageCreateListener(depress); helpListener.addHelpEmbed(depress.getHelpEmbed()); - Depression depress = new Depression(channelName); - api.addMessageCreateListener(depress); - helpListener.addHelpEmbed(depress.getHelpEmbed()); + //Depression depress = new Depression(channelName); +// api.addMessageCreateListener(depress); +// helpListener.addHelpEmbed(depress.getHelpEmbed()); // old way to add listeners api.addMessageCreateListener(helpListener); diff --git a/src/main/java/org/jointheleague/modules/MazeGame.java b/src/main/java/org/jointheleague/modules/MazeGame.java index 76e1f77c..b972c5c0 100644 --- a/src/main/java/org/jointheleague/modules/MazeGame.java +++ b/src/main/java/org/jointheleague/modules/MazeGame.java @@ -30,7 +30,7 @@ public void handle(MessageCreateEvent event) throws APIException { System.out.println("Heard message: " + event.getMessageContent()); if (event.getMessageContent().contains(COMMAND) && !event.getMessageAuthor().isBotUser()) { if (event.getMessageContent().contains("start") || event.getMessageContent().contains("load")) { - String target = event.getMessageContent().substring(11).strip(); + String target = event.getMessageContent().substring(11); try { if(!target.equalsIgnoreCase("upload")) { diff --git a/src/main/java/org/jointheleague/modules/NumberRandom.java b/src/main/java/org/jointheleague/modules/NumberRandom.java new file mode 100644 index 00000000..dd162711 --- /dev/null +++ b/src/main/java/org/jointheleague/modules/NumberRandom.java @@ -0,0 +1,23 @@ +package org.jointheleague.modules; + +import net.aksingh.owmjapis.api.APIException; +import org.javacord.api.event.message.MessageCreateEvent; + + +import java.util.Random; + +public class NumberRandom extends CustomMessageCreateListener{ + public NumberRandom(String channelName) { + super(channelName); + } + + @Override + public void handle(MessageCreateEvent event) throws APIException { + String COMMAND = "!random"; + String messageContent = event.getMessageContent(); + if (messageContent.startsWith(COMMAND)) { + Random r = new Random(); + event.getChannel().sendMessage("Your random number is " + r.nextInt(1001)); + } + } +} diff --git a/src/main/resources/config.json b/src/main/resources/config.json index 4dd58050..efdb0d97 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,4 +1,4 @@ { - "channels": [""], - "token": "" + "channels": ["general"], + "token": "OTMwMjc1ODk3ODUwODg4MjQy.Ydzg8Q.5QOH7l8ALT_RgNtcRUC3gzkzA58" } From 83ef7b75887a9871cab93b1dc5d9cc5c42e40ee7 Mon Sep 17 00:00:00 2001 From: Roshan Sood Date: Mon, 17 Jan 2022 17:11:28 -0800 Subject: [PATCH 51/55] Updated the first feature --- .../org/jointheleague/modules/NumberRandom.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jointheleague/modules/NumberRandom.java b/src/main/java/org/jointheleague/modules/NumberRandom.java index dd162711..f3d03de7 100644 --- a/src/main/java/org/jointheleague/modules/NumberRandom.java +++ b/src/main/java/org/jointheleague/modules/NumberRandom.java @@ -6,7 +6,7 @@ import java.util.Random; -public class NumberRandom extends CustomMessageCreateListener{ +public class NumberRandom extends CustomMessageCreateListener { public NumberRandom(String channelName) { super(channelName); } @@ -19,5 +19,17 @@ public void handle(MessageCreateEvent event) throws APIException { Random r = new Random(); event.getChannel().sendMessage("Your random number is " + r.nextInt(1001)); } + + String input = "!game"; + String input2 = "higher"; + String input3 = "lower"; + String messageContent2 = event.getMessageContent(); + if (messageContent2.startsWith(input)) { + Random r2 = new Random(); + int ran = r2.nextInt(1001); + event.getChannel().sendMessage("Welcome to higher or lower. Your guess: " + ran); + + + } } } From 0de745b20aaaf955e3349dd7b8027c09e8dfa5e6 Mon Sep 17 00:00:00 2001 From: sen <87282133+surroundedxd@users.noreply.github.com> Date: Mon, 17 Jan 2022 17:27:05 -0800 Subject: [PATCH 52/55] Update config.json --- src/main/resources/config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/config.json b/src/main/resources/config.json index efdb0d97..4dd58050 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,4 +1,4 @@ { - "channels": ["general"], - "token": "OTMwMjc1ODk3ODUwODg4MjQy.Ydzg8Q.5QOH7l8ALT_RgNtcRUC3gzkzA58" + "channels": [""], + "token": "" } From 82a3413d19ebcb67b8a140bc0f5bb94d8c3c32c6 Mon Sep 17 00:00:00 2001 From: Roshan Sood Date: Mon, 17 Jan 2022 18:25:51 -0800 Subject: [PATCH 53/55] Finished Second Feature --- .../discord_bot_example/Bot.java | 7 ++-- .../modules/CustomMessageCreateListener.java | 4 +-- .../jointheleague/modules/NumberRandom.java | 34 +++++++++++++++---- 3 files changed, 34 insertions(+), 11 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 35e3d0cb..65347446 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -11,6 +11,7 @@ */ import org.jointheleague.modules.*; + public class Bot { // The string to show the custom :vomiting_robot: emoji @@ -68,9 +69,9 @@ public void connect(boolean printInvite) { api.addMessageCreateListener(head); helpListener.addHelpEmbed(head.getHelpEmbed()); - RandomNumber randomNumber = new RandomNumber(channelName); // replace with feature class later - api.addMessageCreateListener(randomNumber); - helpListener.addHelpEmbed(randomNumber.getHelpEmbed()); +// RandomNumber randomNumber = new RandomNumber(channelName); // replace with feature class later +// api.addMessageCreateListener(randomNumber); +// helpListener.addHelpEmbed(randomNumber.getHelpEmbed()); HypeMachine hypeMachine = new HypeMachine(channelName); api.addMessageCreateListener(hypeMachine); diff --git a/src/main/java/org/jointheleague/modules/CustomMessageCreateListener.java b/src/main/java/org/jointheleague/modules/CustomMessageCreateListener.java index 699aee68..61f2d5d9 100644 --- a/src/main/java/org/jointheleague/modules/CustomMessageCreateListener.java +++ b/src/main/java/org/jointheleague/modules/CustomMessageCreateListener.java @@ -22,7 +22,7 @@ public void onMessageCreate(MessageCreateEvent event) { if (e.getName().equals(channelName)) { try { handle(event); - } catch (APIException e1) { + } catch (APIException | InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } @@ -34,5 +34,5 @@ public HelpEmbed getHelpEmbed() { return this.helpEmbed; } - public abstract void handle(MessageCreateEvent event) throws APIException; + public abstract void handle(MessageCreateEvent event) throws APIException, InterruptedException; } \ No newline at end of file diff --git a/src/main/java/org/jointheleague/modules/NumberRandom.java b/src/main/java/org/jointheleague/modules/NumberRandom.java index f3d03de7..254106f4 100644 --- a/src/main/java/org/jointheleague/modules/NumberRandom.java +++ b/src/main/java/org/jointheleague/modules/NumberRandom.java @@ -12,7 +12,7 @@ public NumberRandom(String channelName) { } @Override - public void handle(MessageCreateEvent event) throws APIException { + public void handle(MessageCreateEvent event) throws APIException, InterruptedException { String COMMAND = "!random"; String messageContent = event.getMessageContent(); if (messageContent.startsWith(COMMAND)) { @@ -21,14 +21,36 @@ public void handle(MessageCreateEvent event) throws APIException { } String input = "!game"; - String input2 = "higher"; - String input3 = "lower"; + String random = ""; String messageContent2 = event.getMessageContent(); + String messageContent3 = event.getMessageContent(); if (messageContent2.startsWith(input)) { Random r2 = new Random(); - int ran = r2.nextInt(1001); - event.getChannel().sendMessage("Welcome to higher or lower. Your guess: " + ran); - + int ran = r2.nextInt(3); + event.getChannel().sendMessage("Welcome to Guess The Number from 0-3. Your guess: " + ran); + if (ran == 0){ + input += "0"; + } + if (ran == 1){ + input += "1"; + } + if (ran == 2){ + input += "2"; + } +// event.getChannel().sendMessage(random); +// event.getChannel().sendMessage(event.getMessageContent()); + +// int guess = Integer.parseInt(messageContent3); +// System.out.println(guess); + if (messageContent3.startsWith(random)){ + event.getChannel().sendMessage("Correct"); + } +// else if (guess < ran){ +// event.getChannel().sendMessage("Higher!"); +// } + else { + event.getChannel().sendMessage("Nope! "); + } } } From 1836a2e4d6c9d9fa3694d1464cf7d7268cfa5a4c Mon Sep 17 00:00:00 2001 From: Roshan Sood Date: Mon, 24 Jan 2022 17:04:39 -0800 Subject: [PATCH 54/55] Finished Second Feature --- .../discord_bot_example/Bot.java | 4 ++ .../jointheleague/modules/NumberGuesser.java | 38 +++++++++++++++++++ .../jointheleague/modules/NumberRandom.java | 38 +++++++------------ 3 files changed, 55 insertions(+), 25 deletions(-) create mode 100644 src/main/java/org/jointheleague/modules/NumberGuesser.java 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 65347446..d1da67ad 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -45,6 +45,10 @@ public void connect(boolean printInvite) { api.addMessageCreateListener(rn); helpListener.addHelpEmbed(rn.getHelpEmbed()); + NumberGuesser ng = new NumberGuesser(channelName); + api.addMessageCreateListener(ng); + helpListener.addHelpEmbed(ng.getHelpEmbed()); + DiscordLibrary dl = new DiscordLibrary(channelName); api.addMessageCreateListener(dl); helpListener.addHelpEmbed(dl.getHelpEmbed()); diff --git a/src/main/java/org/jointheleague/modules/NumberGuesser.java b/src/main/java/org/jointheleague/modules/NumberGuesser.java new file mode 100644 index 00000000..77b74f8a --- /dev/null +++ b/src/main/java/org/jointheleague/modules/NumberGuesser.java @@ -0,0 +1,38 @@ +package org.jointheleague.modules; + +import net.aksingh.owmjapis.api.APIException; +import org.javacord.api.event.message.MessageCreateEvent; + + +import java.util.Random; + +public class NumberGuesser extends CustomMessageCreateListener { + public NumberGuesser(String channelName) { + super(channelName); + } + + @Override + public void handle(MessageCreateEvent event) throws APIException, InterruptedException { + String zero = "0"; + String one = "1"; + String two = "2"; + String three = "3"; + Random r2 = new Random(); + int ran = r2.nextInt(3); + + String messageContent2 = event.getMessageContent(); + String messageContent3 = event.getMessageContent(); + if (messageContent2.startsWith(zero) || messageContent2.startsWith(one) || messageContent2.startsWith(two) || messageContent2.startsWith(three)) { + event.getChannel().sendMessage("Answer: " + ran); + + if (messageContent3.startsWith("" + ran)){ + event.getChannel().sendMessage("Correct" + " Now resetting..."); + } + + else { + event.getChannel().sendMessage("Nope!" + " Now resetting..."); + } + + } + } +} diff --git a/src/main/java/org/jointheleague/modules/NumberRandom.java b/src/main/java/org/jointheleague/modules/NumberRandom.java index 254106f4..28d0174e 100644 --- a/src/main/java/org/jointheleague/modules/NumberRandom.java +++ b/src/main/java/org/jointheleague/modules/NumberRandom.java @@ -20,36 +20,24 @@ public void handle(MessageCreateEvent event) throws APIException, InterruptedExc event.getChannel().sendMessage("Your random number is " + r.nextInt(1001)); } - String input = "!game"; - String random = ""; + String zero = "0"; + String one = "1"; + String two = "2"; + String three = "3"; + Random r2 = new Random(); + int ran = r2.nextInt(3); + String messageContent2 = event.getMessageContent(); String messageContent3 = event.getMessageContent(); - if (messageContent2.startsWith(input)) { - Random r2 = new Random(); - int ran = r2.nextInt(3); - event.getChannel().sendMessage("Welcome to Guess The Number from 0-3. Your guess: " + ran); - if (ran == 0){ - input += "0"; - } - if (ran == 1){ - input += "1"; - } - if (ran == 2){ - input += "2"; - } -// event.getChannel().sendMessage(random); -// event.getChannel().sendMessage(event.getMessageContent()); + if (messageContent2.startsWith(zero) || messageContent2.startsWith(one) || messageContent2.startsWith(two) || messageContent2.startsWith(three)) { + event.getChannel().sendMessage("Answer: " + ran); -// int guess = Integer.parseInt(messageContent3); -// System.out.println(guess); - if (messageContent3.startsWith(random)){ - event.getChannel().sendMessage("Correct"); + if (messageContent3.startsWith("" + ran)){ + event.getChannel().sendMessage("Correct" + " Now resetting..."); } -// else if (guess < ran){ -// event.getChannel().sendMessage("Higher!"); -// } + else { - event.getChannel().sendMessage("Nope! "); + event.getChannel().sendMessage("Nope!" + " Now resetting..."); } } From f4ce6b6b5621615e3d53fc47b5a5c2d32bf6977c Mon Sep 17 00:00:00 2001 From: Roshan Sood Date: Mon, 24 Jan 2022 18:24:33 -0800 Subject: [PATCH 55/55] Finished Final Feature on the Discord Bot --- .../discord_bot_example/Bot.java | 8 +++ .../org/jointheleague/modules/BotKick.java | 63 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 src/main/java/org/jointheleague/modules/BotKick.java 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 d1da67ad..19a12719 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -45,10 +45,18 @@ public void connect(boolean printInvite) { api.addMessageCreateListener(rn); helpListener.addHelpEmbed(rn.getHelpEmbed()); + RollDie rd = new RollDie(channelName); + api.addMessageCreateListener(rd); + helpListener.addHelpEmbed(rd.getHelpEmbed()); + NumberGuesser ng = new NumberGuesser(channelName); api.addMessageCreateListener(ng); helpListener.addHelpEmbed(ng.getHelpEmbed()); + BotKick bk = new BotKick(channelName); + api.addMessageCreateListener(bk); + helpListener.addHelpEmbed(bk.getHelpEmbed()); + DiscordLibrary dl = new DiscordLibrary(channelName); api.addMessageCreateListener(dl); helpListener.addHelpEmbed(dl.getHelpEmbed()); diff --git a/src/main/java/org/jointheleague/modules/BotKick.java b/src/main/java/org/jointheleague/modules/BotKick.java new file mode 100644 index 00000000..d753cc93 --- /dev/null +++ b/src/main/java/org/jointheleague/modules/BotKick.java @@ -0,0 +1,63 @@ +package org.jointheleague.modules; + +import net.aksingh.owmjapis.api.APIException; +import org.javacord.api.event.message.MessageCreateEvent; + +import java.util.Random; + + +public class BotKick extends CustomMessageCreateListener { + public BotKick(String channelName) { + super(channelName); + } + + @Override + public void handle(MessageCreateEvent event) throws APIException, InterruptedException { + + String messageContent2 = event.getMessageContent(); + String rock = "rock"; + String paper = "paper"; + String scissors = "scissors"; + String botChoice = ""; + Random ran = new Random(); + int Random = ran.nextInt(3); + if (Random == 0){ + botChoice = scissors; + } + if (Random == 1){ + botChoice = rock; + } + if (Random == 2){ + botChoice = paper; + } + if(messageContent2.contains(rock)){ + event.getChannel().sendMessage("Computer chose: " + botChoice); + if (botChoice.equals(scissors)){ + event.getChannel().sendMessage("You win"); + } + else if (botChoice.equals(paper)){ + event.getChannel().sendMessage("You lose"); + } + } + else if(messageContent2.contains(scissors)) { + event.getChannel().sendMessage("Computer chose: " + botChoice); + if (botChoice.equals(paper)) { + event.getChannel().sendMessage("You win"); + } else if (botChoice.equals(rock)) { + event.getChannel().sendMessage("You lose"); + } + } + else if(messageContent2.contains(paper)) { + event.getChannel().sendMessage("Computer chose: " + botChoice); + if (botChoice.equals(rock)) { + event.getChannel().sendMessage("You win"); + } else if (botChoice.equals(scissors)) { + event.getChannel().sendMessage("You lose"); + } + } + + + + } +} +