use of de.tectoast.emolga.commands.GuildCommandEvent in project Emolga by TecToast.
the class RandomizeKillsCommand method process.
@Override
public void process(GuildCommandEvent e) {
List<Integer> l = new LinkedList<>();
Random r = new Random();
for (int i = 0; i < 6; i++) {
int rand = r.nextInt(6) + 1;
int sum = l.stream().mapToInt(x -> x).sum();
if (sum + rand > 6)
rand = 6 - sum;
l.add(rand);
}
Collections.shuffle(l);
StringBuilder b = new StringBuilder();
for (int i = 0; i < l.size(); i++) {
b.append("Pokemon ").append(i + 1).append(": ").append(l.get(i)).append("\n");
}
e.reply(b.toString());
}
use of de.tectoast.emolga.commands.GuildCommandEvent in project Emolga by TecToast.
the class NaturalGiftCommand method process.
@Override
public void process(GuildCommandEvent e) {
Translation t = e.getArguments().getTranslation("stuff");
String translation = t.getTranslation();
if (t.isFromType(Translation.Type.ITEM)) {
NGData ngData = DBManagers.NATURAL_GIFT.fromName(translation);
e.reply(new EmbedBuilder().setTitle(translation).addField("Typ", ngData.type(), false).addField("Basepower", String.valueOf(ngData.bp()), false).setColor(Color.CYAN).build());
} else {
List<NGData> ngData = DBManagers.NATURAL_GIFT.fromType(translation);
e.reply(new EmbedBuilder().setTitle(translation).setDescription(ngData.stream().sorted(Comparator.comparing(NGData::bp)).map(d -> d.name() + "/" + getEnglName(d.name()) + ": " + d.bp()).collect(Collectors.joining("\n"))).setColor(Color.CYAN).build());
}
}
use of de.tectoast.emolga.commands.GuildCommandEvent 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 de.tectoast.emolga.commands.GuildCommandEvent in project Emolga by TecToast.
the class AllowCommand method process.
@Override
public void process(GuildCommandEvent e) {
JSONObject drafts = getEmolgaJSON().getJSONObject("drafts");
Member member = e.getMember();
Optional<JSONObject> op = drafts.keySet().stream().map(drafts::getJSONObject).filter(o -> o.has("guild")).filter(o -> o.getString("guild").equals(e.getGuild().getId())).filter(o -> o.has("table")).filter(o -> o.getLongList("table").contains(member.getIdLong())).findFirst();
if (op.isPresent()) {
Member mem = e.getArguments().getMember("user");
long user = mem.getIdLong();
JSONObject league = op.get();
if (!league.has("allowed"))
league.put("allowed", new JSONObject());
JSONObject allowed = league.getJSONObject("allowed");
if (allowed.has(user)) {
e.reply("%s pickt bereits für `%s`!".formatted(mem.getEffectiveName(), e.getGuild().retrieveMemberById(allowed.getLongL(user)).complete().getEffectiveName()));
return;
}
allowed.put(user, member.getIdLong());
e.reply("Du hast %s erlaubt, für dich zu picken!".formatted(mem.getEffectiveName()));
saveEmolgaJSON();
} else {
e.reply("Du nimmst nicht an einer Liga auf diesem Server teil!");
}
}
use of de.tectoast.emolga.commands.GuildCommandEvent in project Emolga by TecToast.
the class PokeFansExportCommand method process.
@Override
public void process(GuildCommandEvent e) {
JSONObject league = Draft.getLeagueStatic(e.getArguments().getText("draft"));
JSONObject picksObj = league.getJSONObject("picks");
JSONArray tosend = new JSONArray();
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();
oneUser.put(names.get(id).replaceAll("[^A-Za-z\\s]", ""));
oneUser.put(e.getArg(0));
JSONArray mons = new JSONArray();
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 -> str.replace("Boreos-T", "Boreos Tiergeistform").replace("Voltolos-T", "Voltolos Tiergeistform").replace("Demeteros-T", "Demeteros Tiergeistform").replace("Boreos-I", "Boreos Inkarnationsform").replace("Voltolos-I", "Voltolos Inkarnationsform").replace("Demeteros-I", "Demeteros Inkarnationsform").replace("Wolwerock-Tag", "Wolwerock Tagform").replace("Wolwerock-Nacht", "Wolwerock Nachtform").replace("Wolwerock-Zw", "Wolwerock Zwielichtform").replace("Shaymin", "Shaymin Landform").replace("Durengard", "Durengard Schildform").replace("Pumpdjinn", "Pumpdjinn XL").replace("M-", "Mega-").replace("A-", "Alola-").replace("G-", "Galar-")).forEach(mons::put);
oneUser.put(mons);
tosend.put(oneUser);
if (tosend.toString().length() > 1500) {
e.reply(tosend.toString());
tosend.clear();
}
}
e.reply(tosend.toString());
}
Aggregations