use of org.jsolf.JSONObject in project Emolga by TecToast.
the class PickCommand method ndsdoc.
public static void ndsdoc(Tierlist tierlist, String pokemon, Draft d, long mem, String tier) {
JSONObject league = getEmolgaJSON().getJSONObject("drafts").getJSONObject(d.name);
// logger.info(d.order.get(d.round).stream().map(Member::getEffectiveName).collect(Collectors.joining(", ")));
RequestBuilder b = new RequestBuilder(league.getString("sid"));
String teamname = league.getJSONObject("teamnames").getString(mem);
String sdName = getSDName(pokemon);
JSONObject o = getDataJSON().getJSONObject(sdName);
int i = d.picks.get(mem).size() + 14;
Coord tl = getTierlistLocation(pokemon, tierlist);
String gen5Sprite = getGen5Sprite(o);
b.addSingle(teamname + "!B" + i, gen5Sprite).addSingle(teamname + "!D" + i, pokemon).addSingle("Tierliste!" + getAsXCoord(tl.x() * 6 + 6) + (tl.y() + 4), "='" + teamname + "'!B2");
List<Object> t = o.getStringList("types").stream().map(s -> getTypeIcons().getString(s)).collect(Collectors.toCollection(LinkedList::new));
if (t.size() == 1)
t.add("/");
b.addRow(teamname + "!F" + i, t);
b.addSingle(teamname + "!H" + i, o.getJSONObject("baseStats").getInt("spe"));
int pointsNeeded = tierlist.getPointsNeeded(pokemon);
b.addSingle(teamname + "!I" + i, pointsNeeded);
b.addSingle(teamname + "!J" + i, "2");
b.addRow(teamname + "!L" + i, Arrays.asList(canLearnNDS(sdName, "stealthrock"), canLearnNDS(sdName, "defog"), canLearnNDS(sdName, "rapidspin"), canLearnNDS(sdName, "voltswitch", "uturn", "flipturn", "batonpass", "teleport")));
int numInRound = d.originalOrder.get(d.round).indexOf(mem) + 1;
b.addSingle("Draft!%s%d".formatted(getAsXCoord(d.round * 5 - 3), numInRound * 5 + 2), "《《《《").addSingle("Draft!%s%d".formatted(getAsXCoord(d.round * 5 - 1), numInRound * 5 + 2), pokemon).addSingle("Draft!%s%d".formatted(getAsXCoord(d.round * 5), numInRound * 5 + 1), gen5Sprite).addSingle("Draft!%s%d".formatted(getAsXCoord(d.round * 5), numInRound * 5 + 3), pointsNeeded);
logger.info("d.members.size() = " + d.members.size());
logger.info("d.order.size() = " + d.order.get(d.round).size());
logger.info("d.members.size() - d.order.size() = " + numInRound);
// if (d.members.size() - d.order.get(d.round).size() != 1 && isEnabled)
b.execute();
}
use of org.jsolf.JSONObject in project Emolga by TecToast.
the class PickCommand method zbsdoc.
private static void zbsdoc(Tierlist tierlist, String pokemon, Draft d, Member mem, String tier, int num, int round) {
JSONObject league = getEmolgaJSON().getJSONObject("drafts").getJSONObject(d.name);
if (league.has("sid")) {
String doc = league.getString("sid");
int x = 1;
int y = 2;
for (String s : tierlist.tiercolumns) {
if (s.equalsIgnoreCase(pokemon))
break;
// logger.info(s + " " + y);
if (s.equals("NEXT")) {
x++;
y = 2;
} else
y++;
}
logger.info("num = " + num);
RequestBuilder b = new RequestBuilder(doc);
b.addStrikethroughChange(910228334, x * 2 + 1, y, true);
// logger.info(d.order.get(d.round).stream().map(Member::getEffectiveName).collect(Collectors.joining(", ")));
b.addStrikethroughChange(856868721, d.round + 2, num + 2, true);
int user = league.getLongList("table").indexOf(mem.getIdLong());
String range = "Liga 2!" + getAsXCoord((int) (tier.equals("S") ? (12 + d.picks.get(mem.getIdLong()).stream().filter(p -> p.tier.equals("S")).count()) : (tierlist.order.indexOf(tier) * 3 + 11 + d.picks.get(mem.getIdLong()).stream().filter(p -> p.tier.equals(tier)).count()))) + (user + 3);
logger.info("range = " + range);
b.addSingle(range, getGen5Sprite(pokemon));
logger.info("d.members.size() = " + d.members.size());
logger.info("d.order.size() = " + d.order.get(d.round).size());
logger.info("d.members.size() - d.order.size() = " + (d.members.size() - d.order.get(d.round).size()));
// if (d.members.size() - d.order.get(d.round).size() != 1 && isEnabled)
b.execute();
}
}
use of org.jsolf.JSONObject in project Emolga by TecToast.
the class ShowdownExportCommand method process.
@Override
public void process(GuildCommandEvent e) {
JSONObject league = getEmolgaJSON().getJSONObject("drafts").getJSONObject(e.getArguments().getText("draft"));
JSONObject picksObj = league.getJSONObject("picks");
StringBuilder b = new StringBuilder();
ArrayList<String> ids = new ArrayList<>(picksObj.keySet());
HashMap<String, String> names = new HashMap<>();
emolgajda.getGuildById(league.getString("guild")).retrieveMembersByIds(ids.toArray(new String[0])).get().forEach(mem -> names.put(mem.getId(), mem.getEffectiveName()));
for (String id : ids) {
JSONArray picksArr = picksObj.getJSONArray(id);
JSONArray oneUser = new JSONArray();
b.append("=== [gen8nationaldexag-box] ").append(e.getArg(0)).append("/").append(names.get(id)).append(" ===\n\n");
picksArr.toList().stream().map(o -> (String) ((HashMap<String, Object>) o).get("name")).sorted(Comparator.comparing(str -> getDataJSON().getJSONObject(getDataName((String) str)).getJSONObject("baseStats").getInt("spe")).reversed()).map(str -> {
if (sdex.containsKey(str)) {
return getEnglName(getFirst(str)) + getFirstAfterUppercase(sdex.get(str)) + " \nAbility: " + getDataJSON().getJSONObject(getDataName(str)).getJSONObject("abilities").getString("0");
}
if (str.startsWith("A-")) {
return getEnglName(str.substring(2)) + "-Alola \nAbility: " + getDataJSON().getJSONObject(getDataName(str)).getJSONObject("abilities").getString("0");
}
if (str.startsWith("G-")) {
return getEnglName(str.substring(2)) + "-Galar \nAbility: " + getDataJSON().getJSONObject(getDataName(str)).getJSONObject("abilities").getString("0");
}
if (str.startsWith("M-")) {
return getEnglName(str.substring(2)) + "-Mega \nAbility: " + getDataJSON().getJSONObject(getDataName(str)).getJSONObject("abilities").getString("0");
}
return getEnglName(str) + " \nAbility: " + getDataJSON().getJSONObject(getDataName(str)).getJSONObject("abilities").getString("0");
}).forEach(str -> b.append(str).append("\n\n"));
b.append("\n");
if (b.length() > 1500) {
e.reply(b.toString());
b.setLength(0);
}
}
e.reply(b.toString());
}
use of org.jsolf.JSONObject in project Emolga by TecToast.
the class SkipCommand method process.
@Override
public void process(GuildCommandEvent e) {
String msg = e.getMsg();
TextChannel tco = e.getChannel();
Member memberr = e.getMember();
long member = memberr.getIdLong();
Draft d = Draft.getDraftByMember(member, tco);
if (d == null) {
// tco.sendMessage(member.getAsMention() + " Du bist in keinem Draft drin!").queue();
return;
}
JSONObject league = getEmolgaJSON().getJSONObject("drafts").getJSONObject(d.name);
if (!d.tc.getId().equals(tco.getId()))
return;
if (!d.isSwitchDraft) {
e.reply("Dieser Draft ist kein Switch-Draft, daher wird !skip nicht unterstützt!");
return;
}
if (d.isNotCurrent(member)) {
tco.sendMessage(d.getMention(member) + " Du bist nicht dran!").queue();
return;
}
d.cooldown.cancel(false);
int round = d.round;
if (d.order.get(d.round).size() == 0) {
if (d.round == d.getTierlist().rounds) {
tco.sendMessage("Der Draft ist vorbei!").queue();
d.ended = true;
// wooloodoc(tierlist, pokemon, d, mem, needed, null, num, round);
if (d.afterDraft.size() > 0)
tco.sendMessage("Reihenfolge zum Nachdraften:\n" + d.afterDraft.stream().map(d::getMention).collect(Collectors.joining("\n"))).queue();
saveEmolgaJSON();
Draft.drafts.remove(d);
return;
}
d.round++;
d.tc.sendMessage("Runde " + d.round + "!").queue();
league.put("round", d.round);
}
logger.info("d.order = " + d.order);
logger.info("d.round = " + d.round);
d.current = d.order.get(d.round).remove(0);
league.put("current", d.current);
JSONObject asl = getEmolgaJSON().getJSONObject("drafts");
tco.sendMessage(d.getMention(d.current) + " ist dran! (" + d.points.get(d.current) + " mögliche Punkte)").queue();
d.cooldown.cancel(false);
long delay = calculateDraftTimer();
league.put("cooldown", System.currentTimeMillis() + delay);
d.cooldown = d.scheduler.schedule((Runnable) d::timer, delay, TimeUnit.MILLISECONDS);
saveEmolgaJSON();
}
use of org.jsolf.JSONObject in project Emolga by TecToast.
the class CounterButton method process.
@Override
public void process(ButtonClickEvent e, String name) {
String[] split = name.split(":");
String method = split[0];
Member mem = e.getMember();
JSONObject counter = shinycountjson.getJSONObject("counter");
String id = mem.getId().equals("893773494578470922") ? "598199247124299776" : mem.getId();
counter.getJSONObject(method).put(id, counter.getJSONObject(method).optInt(id, 0) + Integer.parseInt(split[1]));
Command.updateShinyCounts(e);
}
Aggregations