use of org.jsolf.JSONObject in project Emolga by TecToast.
the class DexNumberCommand method process.
@Override
public void process(GuildCommandEvent e) {
JSONObject data = getDataJSON();
int num = e.getArguments().getInt("num");
for (String s : data.keySet()) {
JSONObject o = data.getJSONObject(s);
if (o.getInt("num") == num) {
e.reply(getGerNameNoCheck(o.getString("name")));
return;
}
}
}
use of org.jsolf.JSONObject in project Emolga by TecToast.
the class EmolgaChannelCommand method process.
@Override
public void process(GuildCommandEvent e) {
ArgumentManager args = e.getArguments();
String action = args.getText("action");
TextChannel tc = args.getChannel("channel");
JSONObject ec = getEmolgaJSON().getJSONObject("emolgachannel");
String gid = e.getGuild().getId();
long tid = tc.getIdLong();
if (!ec.has(gid))
ec.put(gid, new JSONArray());
JSONArray arr = ec.getJSONArray(gid);
List<Long> l = arr.toLongList();
long gidl = e.getGuild().getIdLong();
if (action.equals("add")) {
if (l.contains(tid)) {
e.reply(tc.getAsMention() + " wurde bereits als Channel eingestellt!");
return;
}
arr.put(tid);
if (!emolgaChannel.containsKey(gidl))
emolgaChannel.put(gidl, new ArrayList<>());
emolgaChannel.get(gidl).add(tid);
saveEmolgaJSON();
e.reply("Der Channel " + tc.getAsMention() + " wurde erfolgreich zu den erlaubten Channeln hinzugefügt!");
} else {
if (arr.length() == 0) {
e.reply("Auf diesem Server wurden noch keine Channel für mich eingestellt!");
return;
}
if (removeFromJSONArray(arr, tid)) {
e.reply(tc.getAsMention() + " wurde erfolgreich aus den erlaubten Channeln gelöscht!");
emolgaChannel.get(gidl).remove(tid);
saveEmolgaJSON();
return;
}
e.reply(tc.getAsMention() + " ist nicht in der Liste der erlaubten Channel!");
}
}
use of org.jsolf.JSONObject 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 org.jsolf.JSONObject in project Emolga by TecToast.
the class PickCommand method aslCoachDoc.
private static void aslCoachDoc(Tierlist tierlist, String pokemon, Draft d, Member mem, int needed, int round, @Nullable DraftPokemon removed) {
JSONObject asl = getEmolgaJSON().getJSONObject("drafts").getJSONObject("ASLS9");
JSONObject league = asl.getJSONObject(d.name);
String sid = asl.getString("sid");
int x = 1;
int y = 5;
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 = 5;
} else
y++;
}
RequestBuilder b = new RequestBuilder(sid);
if (found) {
b.addBGColorChange(league.getInt("tierlist"), x * 2, y, convertColor(0xff0000));
}
x = 1;
y = 5;
if (removed != null) {
for (String s : tierlist.tiercolumns) {
if (s.equalsIgnoreCase(removed.name)) {
break;
}
// logger.info(s + " " + y);
if (s.equals("NEXT")) {
x++;
y = 5;
} 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);*/
b.addBGColorChange(league.getInt("tierlist"), x * 2, y, convertColor(0x93c47d));
}
// logger.info(d.order.get(d.round).stream().map(Member::getEffectiveName).collect(Collectors.joining(", ")));
String team = asl.getStringList("teams").get(getIndex(mem.getIdLong()));
int yc = (Draft.getLevel(mem.getIdLong()) * 20 + d.picks.get(mem.getIdLong()).size());
List<Integer> list = new LinkedList<>();
for (int i = 0; i < 9; i++) {
list.add(i * 4 + 10);
}
b.addRow(team + "!B" + yc, Arrays.asList(getGen5Sprite(pokemon), pokemon, needed, "=" + list.stream().map(i -> getAsXCoord(i) + yc).collect(Collectors.joining(" + ")), "=" + list.stream().map(i -> getAsXCoord(i + 1) + yc).collect(Collectors.joining(" + ")), ("=E" + yc + " - F" + yc), getDataJSON().getJSONObject(getSDName(pokemon)).getJSONObject("baseStats").getInt("spe")));
b.execute();
}
use of org.jsolf.JSONObject 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();
}
Aggregations