use of de.tectoast.emolga.utils.draft.DraftPokemon in project Emolga by TecToast.
the class PickCommand method aslS10Doc.
private static void aslS10Doc(Tierlist tierlist, String pokemon, Draft d, long mem, String tier, int effectiveRound) {
JSONObject league = getEmolgaJSON().getJSONObject("drafts").getJSONObject(d.name);
String sid = league.getString("sid");
RequestBuilder b = new RequestBuilder(sid);
Coord c = getTierlistLocation(pokemon, tierlist);
logger.info("c.toString() = {}", c);
logger.info("c.valid() = {}", c.valid());
if (c.valid())
b.addBGColorChange(league.getInt("tierlist"), c.x() * 2 + 2, c.y() + 5, convertColor(0xFF0000));
Coord cengl = getTierlistLocation(pokemon, tierlist.tiercolumnsEngl);
if (cengl.valid())
b.addBGColorChange(league.getInt("tierlistengl"), cengl.x() * 2 + 2, cengl.y() + 5, convertColor(0xFF0000));
Integer points = tierlist.prices.get(tier);
Comparator<DraftPokemon> comparator = Comparator.comparing(p -> tierlist.order.indexOf(p.getTier()));
Comparator<DraftPokemon> finalComp = comparator.thenComparing(p -> p.name);
b.addAll("Teamseite HR!B%d".formatted(league.getLongList("table").indexOf(mem) * 15 + 4), d.picks.get(mem).stream().sorted(finalComp).map(mon -> new ArrayList<Object>(Arrays.asList(mon.getTier(), mon.getName(), getDataJSON().getJSONObject(getSDName(mon.getName())).getJSONObject("baseStats").getInt("spe")))).collect(Collectors.toList()));
int rr = effectiveRound - 1;
logger.info("d.originalOrder = {}", d.originalOrder);
logger.info("effectiveRound = {}", effectiveRound);
logger.info("mem = {}", mem);
int index = d.originalOrder.get(effectiveRound).indexOf(mem);
logger.info("index = {}", index);
b.addRow("Draft!%s%d".formatted(getAsXCoord((rr % 6) * 4 + 3), (rr / 6) * 10 + 4 + index), Arrays.asList(pokemon, points));
b.execute();
}
use of de.tectoast.emolga.utils.draft.DraftPokemon in project Emolga by TecToast.
the class PickCommand method woolooolddoc.
/*public void doc(Tierlist tierlist, String pokemon, Draft d, Member mem, String tier, JSONObject league, int pk) {
zbsdoc(tierlist, pokemon, d, mem, tier, num);
//aslnocoachdoc(tierlist, pokemon, d, mem, tier, league, pk);
}*/
private static void woolooolddoc(Tierlist tierlist, String pokemon, Draft d, Member mem, int needed, @Nullable DraftPokemon removed, int num, int round) {
JSONObject league = getEmolgaJSON().getJSONObject("drafts").getJSONObject(d.name);
String sid = league.getString("sid");
int x = 1;
int y = 2;
boolean found = false;
for (String s : tierlist.tiercolumns) {
if (s.equalsIgnoreCase(pokemon)) {
found = true;
break;
}
// logger.info(s + " " + y);
if (s.equals("NEXT")) {
x++;
y = 2;
} else
y++;
}
RequestBuilder b = new RequestBuilder(sid);
if (found) {
Request request = new Request();
request.setUpdateCells(new UpdateCellsRequest().setRows(Collections.singletonList(new RowData().setValues(Collections.singletonList(new CellData().setUserEnteredFormat(new CellFormat().setBackgroundColor(new Color().setRed(1f))))))).setFields("userEnteredFormat.backgroundColor").setRange(new GridRange().setSheetId(league.getInt("tierlist")).setStartRowIndex(y).setEndRowIndex(y + 1).setStartColumnIndex(x * 2 - 1).setEndColumnIndex(x * 2)));
b.addBatch(request);
}
x = 1;
y = 2;
if (removed != null) {
for (String s : tierlist.tiercolumns) {
if (s.equalsIgnoreCase(removed.name)) {
break;
}
// logger.info(s + " " + y);
if (s.equals("NEXT")) {
x++;
y = 2;
} else
y++;
}
Request request = new Request();
request.setUpdateCells(new UpdateCellsRequest().setRows(Collections.singletonList(new RowData().setValues(Collections.singletonList(new CellData().setUserEnteredFormat(new CellFormat().setBackgroundColor(new Color().setRed((float) 0.5764706).setGreen((float) 0.76862746).setBlue((float) 0.49019608))))))).setFields("userEnteredFormat.backgroundColor").setRange(new GridRange().setSheetId(league.getInt("tierlist")).setStartRowIndex(y).setEndRowIndex(y + 1).setStartColumnIndex(x * 2 - 1).setEndColumnIndex(x * 2)));
b.addBatch(request);
}
Request req = new Request();
// logger.info(d.order.get(d.round).stream().map(Member::getEffectiveName).collect(Collectors.joining(", ")));
req.setUpdateCells(new UpdateCellsRequest().setRows(Collections.singletonList(new RowData().setValues(Collections.singletonList(new CellData().setUserEnteredFormat(new CellFormat().setTextFormat(new TextFormat().setStrikethrough(true))))))).setFields("userEnteredFormat.textFormat.strikethrough").setRange(new GridRange().setSheetId(1316641169).setStartRowIndex(num + 1).setEndRowIndex(num + 2).setStartColumnIndex(round).setEndColumnIndex(round + 1)));
// logger.info(d.order.get(d.round).stream().map(Member::getEffectiveName).collect(Collectors.joining(", ")));
b.addBatch(req);
int user = Arrays.asList(league.getString("table").split(",")).indexOf(mem.getId());
List<DraftPokemon> picks = d.picks.get(mem.getIdLong());
for (int i = 0; i < 13; i++) {
List<Object> list = new ArrayList<>();
if (i < picks.size()) {
DraftPokemon mon = picks.get(i);
list.add(tierlist.prices.get(mon.tier));
list.add(mon.name);
} else {
list.add("");
list.add("");
}
b.addRow("Teamübersicht!" + getAsXCoord((user > 3 ? user - 4 : user) * 6 + 2) + ((user > 3 ? 25 : 7) + i), list);
}
b.execute();
}
use of de.tectoast.emolga.utils.draft.DraftPokemon 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.DraftPokemon 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();
}
}
use of de.tectoast.emolga.utils.draft.DraftPokemon in project Emolga by TecToast.
the class PickCommand method aslnocoachdoc.
private static void aslnocoachdoc(Tierlist tierlist, String pokemon, Draft d, Member mem, int needed, @Nullable DraftPokemon removed) {
JSONObject league = getEmolgaJSON().getJSONObject("drafts").getJSONObject(d.name);
String sid = league.getString("sid");
int x = 1;
int y = 2;
boolean found = false;
for (String s : tierlist.tiercolumns) {
if (s.equalsIgnoreCase(pokemon)) {
found = true;
break;
}
// logger.info(s + " " + y);
if (s.equals("NEXT")) {
x++;
y = 2;
} else
y++;
}
RequestBuilder b = new RequestBuilder(sid);
if (found) {
Request request = new Request();
request.setUpdateCells(new UpdateCellsRequest().setRows(Collections.singletonList(new RowData().setValues(Collections.singletonList(new CellData().setUserEnteredFormat(new CellFormat().setBackgroundColor(new Color().setRed(1f))))))).setFields("userEnteredFormat.backgroundColor").setRange(new GridRange().setSheetId(league.getInt("tierlist")).setStartRowIndex(y).setEndRowIndex(y + 1).setStartColumnIndex(x * 2 - 1).setEndColumnIndex(x * 2)));
b.addBatch(request);
}
x = 1;
y = 2;
if (removed != null) {
for (String s : tierlist.tiercolumns) {
if (s.equalsIgnoreCase(removed.name)) {
break;
}
// logger.info(s + " " + y);
if (s.equals("NEXT")) {
x++;
y = 2;
} else
y++;
}
Request request = new Request();
request.setUpdateCells(new UpdateCellsRequest().setRows(Collections.singletonList(new RowData().setValues(Collections.singletonList(new CellData().setUserEnteredFormat(new CellFormat().setBackgroundColor(new Color().setRed((float) 0.5764706).setGreen((float) 0.76862746).setBlue((float) 0.49019608))))))).setFields("userEnteredFormat.backgroundColor").setRange(new GridRange().setSheetId(league.getInt("tierlist")).setStartRowIndex(y).setEndRowIndex(y + 1).setStartColumnIndex(x * 2 - 1).setEndColumnIndex(x * 2)));
b.addBatch(request);
}
// logger.info(d.order.get(d.round).stream().map(Member::getEffectiveName).collect(Collectors.joining(", ")));
int user = Arrays.asList(league.getString("table").split(",")).indexOf(mem.getId());
List<DraftPokemon> picks = d.picks.get(mem.getIdLong());
for (int i = 0; i < 12; i++) {
List<Object> list = new ArrayList<>();
if (i < picks.size()) {
DraftPokemon mon = picks.get(i);
list.add(mon.name);
list.add(String.valueOf(tierlist.getPointsNeeded(mon.name)));
} else {
list.add("");
list.add("");
}
b.addRow("Teams!" + getAsXCoord((user > 3 ? user - 4 : user) * 5 + 1) + ((user > 3 ? 24 : 7) + i), list);
}
b.execute();
}
Aggregations