use of de.tectoast.emolga.utils.draft.Draft 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 de.tectoast.emolga.utils.draft.Draft 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 de.tectoast.emolga.utils.draft.Draft 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 de.tectoast.emolga.utils.draft.Draft in project Emolga by TecToast.
the class SwitchCommand method ndsdoc.
public static void ndsdoc(Tierlist tierlist, Draft d, long mem, DraftPokemon oldmon, DraftPokemon newmon) {
JSONObject league = getEmolgaJSON().getJSONObject("drafts").getJSONObject(d.name);
logger.info("oldmon = {}", oldmon);
logger.info("newmon = {}", newmon);
// 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 pokemon = newmon.getName();
String sdName = getSDName(pokemon);
JSONObject o = getDataJSON().getJSONObject(sdName);
int i = d.picks.get(mem).indexOf(newmon) + 15;
Coord tl = getTierlistLocation(pokemon, tierlist);
String oldmonName = oldmon.getName();
Coord tlold = getTierlistLocation(oldmonName, 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").addSingle("Tierliste!" + getAsXCoord(tlold.x() * 6 + 6) + (tlold.y() + 4), "-frei-");
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"));
b.addSingle(teamname + "!I" + i, tierlist.getPointsNeeded(pokemon));
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 - 2), numInRound * 5 + 1), "》》》》").addSingle("Draft!%s%d".formatted(getAsXCoord(d.round * 5 - 3), numInRound * 5 + 1), oldmonName).addSingle("Draft!%s%d".formatted(getAsXCoord(d.round * 5 - 4), numInRound * 5 + 1), getGen5Sprite(oldmonName)).addSingle("Draft!%s%d".formatted(getAsXCoord(d.round * 5 - 4), numInRound * 5 + 3), tierlist.prices.get(oldmon.getTier()));
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), tierlist.prices.get(newmon.getTier()));
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 de.tectoast.emolga.utils.draft.Draft in project Emolga by TecToast.
the class PickCommand method exec.
public static void exec(TextChannel tco, String msg, Member memberr, boolean isRandom) {
try {
long member = memberr.getIdLong();
if (msg.trim().equals("!pick")) {
if (isRandom) {
tco.sendMessage("Jedes Pokemon aus dem Tier mit dem Typen ist bereits weg!").queue();
} else {
tco.sendMessage("Willst du vielleicht noch ein Pokemon dahinter schreiben? xD").queue();
}
return;
}
Draft d = Draft.getDraftByMember(member, tco);
if (d == null) {
tco.sendMessage(memberr.getAsMention() + " Du bist in keinem Draft drin!").queue();
return;
}
if (!d.tc.getId().equals(tco.getId()))
return;
/*if (d.isSwitchDraft) {
tco.sendMessage("Dieser Draft ist ein Switch-Draft, daher wird !pick nicht unterstützt!").queue();
return;
}*/
if (d.isNotCurrent(member)) {
tco.sendMessage(d.getMention(member) + " Du bist nicht dran!").queue();
return;
}
long mem = d.current;
JSONObject league = getEmolgaJSON().getJSONObject("drafts").getJSONObject(d.name);
String[] split = msg.substring(6).split(" ");
String tier;
Translation t;
String pokemon;
Tierlist tierlist = d.getTierlist();
if (d.picks.get(mem).size() == 15) {
tco.sendMessage("Du hast bereits 15 Mons!").queue();
return;
}
if (split.length == 2 && !d.isPointBased) {
t = getDraftGerName(split[0]);
if (!t.isFromType(Translation.Type.POKEMON)) {
tco.sendMessage("Das ist kein Pokemon!").queue();
return;
}
pokemon = t.getTranslation();
tier = d.getTierlist().order.stream().filter(s -> split[1].equalsIgnoreCase(s)).findFirst().orElse("");
} else {
t = getDraftGerName(msg.substring(6));
if (!t.isFromType(Translation.Type.POKEMON)) {
tco.sendMessage("Das ist kein Pokemon!").queue();
return;
}
pokemon = t.getTranslation();
tier = tierlist.getTierOf(pokemon);
}
if (d.isPicked(pokemon)) {
// tco.sendMessage(member.getAsMention() + " Junge bist du scheiße oder was?! (Dieses Pokemon wurde bereits gepickt!)").queue();
tco.sendMessage(memberr.getAsMention() + " Dieses Pokemon wurde bereits gepickt!").queue();
return;
}
int needed = tierlist.getPointsNeeded(pokemon);
if (d.isPointBased) {
if (needed == -1) {
tco.sendMessage(memberr.getAsMention() + " Das Pokemon steht nicht in der Tierliste!").queue();
return;
}
} else {
String origtier = tierlist.getTierOf(pokemon);
if (origtier.equals("")) {
tco.sendMessage(memberr.getAsMention() + " Das ist kein Pokemon!").queue();
return;
}
if (tierlist.order.indexOf(origtier) < tierlist.order.indexOf(tier)) {
tco.sendMessage("Du kannst ein " + origtier + "-Mon nicht ins " + tier + " hochdraften!").queue();
return;
}
Map<String, Integer> map = d.getPossibleTiers(mem);
if (!map.containsKey(tier)) {
tco.sendMessage("Das Tier `" + tier + "` existiert nicht!").queue();
return;
}
if (map.get(tier) == 0) {
if (tierlist.prices.get(tier) == 0) {
tco.sendMessage("Ein Pokemon aus dem " + tier + "-Tier musst du in ein anderes Tier hochdraften!").queue();
return;
}
tco.sendMessage("Du kannst dir kein " + tier + "-Pokemon mehr picken!").queue();
return;
}
}
pokemon = tierlist.getNameOf(pokemon);
/*if (d.hasMega(mem) && pokemon.startsWith("M-")) {
tco.sendMessage(member.getAsMention() + " Du hast bereits ein Mega!").complete().getId();
return;
}
/*if (d.hasInAnotherForm(mem, pokemon)) {
tco.sendMessage(member.getAsMention() + " Damit würdest du gegen die Species Clause verstoßen!").queue();
return;
}*/
if (d.isPointBased && d.points.get(mem) - needed < 0) {
tco.sendMessage(memberr.getAsMention() + " Dafür hast du nicht genug Punkte!").queue();
return;
}
/*if (d.isPointBased && (d.getTierlist().rounds - d.round) * d.getTierlist().prices.get(d.getTierlist().order.get(d.getTierlist().order.size() - 1)) > (d.points.get(mem) - needed)) {
tco.sendMessage(memberr.getAsMention() + " Wenn du dir dieses Pokemon holen würdest, kann dein Kader nicht mehr vervollständigt werden!").queue();
return;
}*/
if (d.isPointBased)
d.points.put(mem, d.points.get(mem) - needed);
d.picks.get(mem).add(new DraftPokemon(pokemon, tier));
if (!league.has("picks"))
league.put("picks", new JSONObject());
league.getJSONObject("picks").put(mem, d.getTeamAsArray(mem));
// m.delete().queue();
d.update(mem);
if (isRandom) {
tco.sendMessage("**<@" + mem + ">** hat aus dem " + tier + "-Tier ein **" + pokemon + "** bekommen!").queue();
} else if (pokemon.equals("Emolga")) {
tco.sendMessage("<:Happy:701070356386938991> <:Happy:701070356386938991> <:Happy:701070356386938991> <:Happy:701070356386938991> <:Happy:701070356386938991>").queue();
}
// zbsdoc(tierlist, pokemon, d, mem, tier, d.members.size() - d.order.get(d.round).size(), d.round);
// fpldoc(tierlist, pokemon, d, mem, tier, d.members.size() - d.order.get(d.round).size(), d.round);
// woolooDoc(tierlist, pokemon, d, mem, tier, d.round);
// int rd = d.round == tierlist.rounds && d.picks.get(mem).size() < tierlist.rounds ? (int) league.getJSONObject("skippedturns").getJSONArrayL(mem).remove(0) : d.round;
// aslS10Doc(tierlist, pokemon, d, mem, tier, rd);
ndsdoc(tierlist, pokemon, d, mem, tier);
/*if (d.round == tierlist.rounds && d.picks.get(mem).size() < d.round) {
if (d.isPointBased)
//tco.sendMessage(getMention(current) + " (<@&" + asl.getLongList("roleids").get(getIndex(current.getIdLong())) + ">) ist dran! (" + points.get(current.getIdLong()) + " mögliche Punkte)").queue();
tco.sendMessage(d.getMention(mem) + " ist dran! (" + d.points.get(mem) + " mögliche Punkte)").queue();
else
tco.sendMessage(d.getMention(mem) + " ist dran! (Mögliche Tiers: " + d.getPossibleTiersAsString(mem) + ")").queue();
} else {*/
d.nextPlayer(tco, tierlist, league);
// }
// aslCoachDoc(tierlist, pokemon, d, mem, needed, round, toremove);
// ndsdoc(tierlist, pokemon, d, mem, tier, round);
} catch (Exception ex) {
tco.sendMessage("Es ist ein Fehler aufgetreten!").queue();
ex.printStackTrace();
}
}
Aggregations