Skip to content

Commit

Permalink
Merge pull request #31 from Mazawrath/weebStock
Browse files Browse the repository at this point in the history
Added WEEB
  • Loading branch information
Mazawrath authored Dec 5, 2018
2 parents f45d83c + 9b86bd6 commit cc8e011
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public BeanInvestCommand(Points points, StockMarket stockMarket) {
@Command(
aliases = {"beanInvest", "coinInvest"},
description = "Lets you invest in companies from the Bean Market.",
usage = "beanInvest [[buy/sell] [symbol]]",
usage = "beanInvest [[buy/sell/check] [symbol]]",
privateMessages = false
)

Expand All @@ -33,7 +33,8 @@ public void onCommand(String[] args, ServerTextChannel serverTextChannel, User a
serverTextChannel.sendMessage("No arguments for this command are currently not supported. In the future this will be a way to look at your portfolio and all the shares you have invested in.\n" +
"Instructions for `.beaninvest`.\n" +
"\t- `.beaninvest buy [symbol] [amount]` - Buys shares from that symbol.\n" +
"\t- `.beaninvest sell [symbol]` - Sells all shares bought from that symbol.");
"\t- `.beaninvest sell [symbol]` - Sells all shares bought from that symbol." +
"\t- `.beaninvest check [symbol]` - Checks how many shares are bought from that symbol.");
} else if (args[0].equals("buy")) {
EmbedBuilder embed = new EmbedBuilder()
.setTitle("Bean Market Investment")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ public void onCommand(String command, String id, DiscordApi api, ServerTextChann

private String getRecentChangeLog() {
return "**New beanBOT update released.**\n" +
"Detailed changelog can be found on https://github.com/Mazawrath/beanBOT/compare/v2.6.0...v2.6.1\n" +
"Release can be found on https://github.com/Mazawrath/beanBOT/releases/tag/v2.6.2\n" +
"Detailed changelog can be found on https://github.com/Mazawrath/beanBOT/compare/v2.6.1...v2.6.2\n" +
"\n" +
"**v2.6.1**\n" +
"**v2.6.2**\n" +
"**New**\n" +
"\t- Bean Market\n" +
"\t\t- Added `BEAB` (Blissful Beans).\n" +
//"**Changes**\n" +
//"\t- Changed chances of winning `.beanbet` from 35% to 45%.\n" +
"\t\t- Added `WEEB` (MicroWeeb).\n" +
"**Changes**\n" +
"\t- Added extra info when using `.beaninvest` without any arguments.\n" +
"**Bug Fixes**\n" +
"\t- Fixed an issue with selling shares.";
"\t- Fixed an issue with selling or checking stocks you never bought.";
}
}
16 changes: 15 additions & 1 deletion src/main/java/com/mazawrath/beanbot/utilities/StockMarket.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

public class StockMarket {
private static final RethinkDB r = new RethinkDB();
public static final String[] COMPANIES = {"BEAN", "FBI", "SHTEB", "BEZFF", "ABD", "BNTC", "BETHS", "BEAB"};
public static final String[] COMPANIES = {"BEAN", "FBI", "SHTEB", "BEZFF", "ABD", "BNTC", "BETHS", "BEAB", "WEEB"};
private static final String DB_VALUE_PREFIX = "P_";
Connection conn;

Expand Down Expand Up @@ -145,6 +145,12 @@ public static JSONObject getCompanyInfo(String symbol) {
companyInfo.put("Symbol", symbol);
symbol = getSymbol(symbol);
break;
case "WEEB":
companyInfo.put("Name", "MicroWeeb");
companyInfo.put("Logo", "https://cdn.discordapp.com/attachments/480959729330290688/519694521144049674/Untitled.png");
companyInfo.put("Symbol", symbol);
symbol = getSymbol(symbol);
break;
default:
return null;
}
Expand Down Expand Up @@ -183,6 +189,8 @@ public String getCompanyName(String beanSymbol) {
return "Papa BEETHS";
case "BEAB":
return "Blissful Beans";
case "WEEB":
return "MicroWeeb";
default:
return null;
}
Expand All @@ -206,6 +214,8 @@ public static String getSymbol(String beanSymbol) {
return "PZZA";
case "BEAB":
return "SBUX";
case "WEEB":
return "MSFT";
default:
return null;
}
Expand All @@ -225,10 +235,14 @@ public BigDecimal getStockPrice(String symbol, boolean beanSymbol) {
}

public BigDecimal getShareInvested(String userID, String serverID, String symbol) {
checkUser(userID, serverID);
checkCompany(userID, serverID, symbol);
return new BigDecimal(parseValueFromDB(r.db("beanBotStock").table(serverID).get(userID).getField(symbol + " shares bought").run(conn))).setScale(Points.SCALE, Points.ROUNDING_MODE);
}

public BigDecimal getBeanCoinSpent(String userID, String serverID, String symbol) {
checkUser(userID, serverID);
checkCompany(userID, serverID, symbol);
return new BigDecimal(parseValueFromDB(r.db("beanBotStock").table(serverID).get(userID).getField(symbol + " beanCoin spent").run(conn))).setScale(Points.SCALE, Points.ROUNDING_MODE);
}

Expand Down

0 comments on commit cc8e011

Please sign in to comment.