use of io.github.spugn.Sargo.Utilities.GitHubImage in project S-argo by Expugn.
the class Profile method init.
/**
* Initializes the EmbedMessage and variables.
*/
private void init() {
builder = new EmbedBuilder();
iUser = CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID));
user = new UserParser(DISCORD_ID);
userName = iUser.getName() + "#" + iUser.getDiscriminator();
goldCount = 0;
platinumCount = 0;
bannerType = new TreeMap<>();
builder.withAuthorName(userName + "'s Profile");
builder.withAuthorIcon(iUser.getAvatarURL());
builder.withColor(255, 86, 91);
builder.withThumbnail(new GitHubImage("images/System/Profile_Icon.png").getURL());
}
use of io.github.spugn.Sargo.Utilities.GitHubImage in project S-argo by Expugn.
the class CharacterScout method displayAndSave.
/**
* Displays the scout results to the channel where the command was
* requested and save the results to the user file afterwards. If
* the results fail to display for any reason then the user file
* is not saved.
*/
void displayAndSave() {
ScoutMasterParser smp = new ScoutMasterParser();
if (!SIMPLE_MESSAGE) {
scoutMenu.withAuthorName(SELECTED_BANNER.getBannerName());
setupScoutMenu();
if (!generateImage || IMAGE_DISABLED)
scoutMenu.appendField("- Scout Result -", characterString, false);
scoutMenu.withDesc(smp.getQuote());
scoutMenu.withAuthorIcon(new GitHubImage("images/System/Scout_Icon.png").getURL());
scoutMenu.withColor(244, 233, 167);
scoutMenu.withThumbnail(smp.getImage(highestRarity));
scoutMenu.withFooterIcon(new GitHubImage("images/System/Memory_Diamond_Icon.png").getURL());
scoutMenu.withFooterText((CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getName() + "#" + CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getDiscriminator()) + " | " + USER.getMemoryDiamonds() + " Memory Diamonds Left");
LOGGER.debug("Displaying Scout Result...");
IMessage display = null;
try {
if (generateImage && !IMAGE_DISABLED)
display = CHANNEL.sendFile(scoutMenu.build(), new File(tempUserDirectory + "/results.png"));
else
display = CHANNEL.sendMessage(scoutMenu.build());
} catch (FileNotFoundException e) {
CHANNEL.sendMessage(new WarningMessage("FAILED TO GENERATE IMAGE", "Unable to display scout result.").get().build());
display.delete();
deleteTempDirectory();
return;
} catch (RateLimitException e) {
EmbedBuilder rateLimited = new WarningMessage("RATE LIMIT EXCEPTION", "Slow down on the requests!").get();
try {
display.edit(rateLimited.build());
} catch (NullPointerException a) {
// DO SOMETHING
}
deleteTempDirectory();
return;
}
} else {
simpleMessage += "**" + SELECTED_BANNER.getBannerName() + "**" + "\n";
setupScoutMenu();
simpleMessage += smp.getQuote() + "\n";
if (!generateImage || IMAGE_DISABLED) {
simpleMessage += "**- Scout Result -**" + "\n";
simpleMessage += characterString;
}
simpleMessage += (CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getName() + "#" + CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getDiscriminator()) + " | " + USER.getMemoryDiamonds() + " Memory Diamonds Left";
LOGGER.debug("Displaying Scout Result...");
IMessage display = null;
try {
if (generateImage && !IMAGE_DISABLED) {
display = CHANNEL.sendFile(simpleMessage, new File(tempUserDirectory + "/results.png"));
} else {
display = CHANNEL.sendMessage(simpleMessage);
}
} catch (FileNotFoundException e) {
CHANNEL.sendMessage(new WarningMessage("FAILED TO GENERATE IMAGE", "Unable to display scout result.").get().build());
display.delete();
deleteTempDirectory();
return;
} catch (RateLimitException e) {
EmbedBuilder rateLimited = new WarningMessage("RATE LIMIT EXCEPTION", "Slow down on the requests!").get();
try {
display.edit(rateLimited.build());
} catch (NullPointerException a) {
// DO SOMETHING
}
deleteTempDirectory();
return;
}
}
LOGGER.debug("Saving User Data...");
USER.saveData();
deleteTempDirectory();
}
use of io.github.spugn.Sargo.Utilities.GitHubImage in project S-argo by Expugn.
the class TicketScout method displayAndSave.
/**
* Displays the scout results to the channel where the command
* was requested and save the results to the user file afterwards.
* If the results fail to display for any reason then the user file
* is not saved.
*/
void displayAndSave() {
if (!SIMPLE_MESSAGE) {
setupScoutMenu();
if (!generateImage || IMAGE_DISABLED)
scoutMenu.appendField("- Weapon Result -", itemString, false);
scoutMenu.withAuthorIcon(new GitHubImage("images/System/Scout_Icon.png").getURL());
scoutMenu.withColor(255, 255, 255);
scoutMenu.withFooterIcon(new GitHubImage("images/System/Memory_Diamond_Icon.png").getURL());
scoutMenu.withFooterText((CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getName() + "#" + CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getDiscriminator()) + " | " + userTotalScouts + " Total Ticket Scouts");
IMessage display = null;
try {
if (generateImage && !IMAGE_DISABLED)
display = CHANNEL.sendFile(scoutMenu.build(), new File(tempUserDirectory + "/results.png"));
else
display = CHANNEL.sendMessage(scoutMenu.build());
} catch (FileNotFoundException e) {
CHANNEL.sendMessage(new WarningMessage("FAILED TO GENERATE IMAGE", "Unable to display scout result.").get().build());
display.delete();
deleteTempDirectory();
return;
} catch (RateLimitException e) {
EmbedBuilder rateLimited = new WarningMessage("RATE LIMIT EXCEPTION", "Slow down on the requests!").get();
try {
display.edit(rateLimited.build());
} catch (NullPointerException a) {
// DO SOMETHING
}
deleteTempDirectory();
return;
}
} else {
setupScoutMenu();
if (!generateImage || IMAGE_DISABLED) {
simpleMessage += "**- Weapon Result -**" + "\n";
simpleMessage += itemString;
}
simpleMessage += (CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getName() + "#" + CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getDiscriminator()) + " | " + userTotalScouts + " Total Ticket Scouts";
IMessage display = null;
try {
if (generateImage && !IMAGE_DISABLED) {
display = CHANNEL.sendFile(simpleMessage, new File(tempUserDirectory + "/results.png"));
} else {
display = CHANNEL.sendMessage(simpleMessage);
}
} catch (FileNotFoundException e) {
CHANNEL.sendMessage(new WarningMessage("FAILED TO GENERATE IMAGE", "Unable to display scout result.").get().build());
display.delete();
deleteTempDirectory();
return;
} catch (RateLimitException e) {
EmbedBuilder rateLimited = new WarningMessage("RATE LIMIT EXCEPTION", "Slow down on the requests!").get();
try {
display.edit(rateLimited.build());
} catch (NullPointerException a) {
// DO SOMETHING
}
deleteTempDirectory();
return;
}
}
USER.upgradeExchangeSwords();
USER.saveData();
deleteTempDirectory();
}
use of io.github.spugn.Sargo.Utilities.GitHubImage in project S-argo by Expugn.
the class WeaponScout method displayAndSave.
/**
* Displays the scout results to the channel where the command was
* requested and save the results to the user file afterwards. If
* the results fail to display for any reason then the user file
* is not saved.
*/
void displayAndSave() {
if (!SIMPLE_MESSAGE) {
scoutMenu.withAuthorName(SELECTED_BANNER.getBannerName());
setupScoutMenu();
if (!generateImage || IMAGE_DISABLED)
scoutMenu.appendField("- Weapon Result -", weaponString, false);
scoutMenu.withAuthorIcon(new GitHubImage("images/System/Scout_Icon.png").getURL());
scoutMenu.withColor(139, 69, 19);
if (weapons.get(0).getRarity() == 2)
scoutMenu.withThumbnail(new GitHubImage("images/System/Brown_Chest.png").getURL());
else if (weapons.get(0).getRarity() == 3)
scoutMenu.withThumbnail(new GitHubImage("images/System/Blue_Chest.png").getURL());
else if (weapons.get(0).getRarity() == 4)
scoutMenu.withThumbnail(new GitHubImage("images/System/Red_Chest.png").getURL());
scoutMenu.withFooterIcon(new GitHubImage("images/System/Memory_Diamond_Icon.png").getURL());
scoutMenu.withFooterText((CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getName() + "#" + CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getDiscriminator()) + " | " + USER.getMemoryDiamonds() + " Memory Diamonds Left");
LOGGER.debug("Displaying Scout Result...");
IMessage display = null;
try {
if (generateImage && !IMAGE_DISABLED)
display = CHANNEL.sendFile(scoutMenu.build(), new File(tempUserDirectory + "/results.png"));
else
display = CHANNEL.sendMessage(scoutMenu.build());
} catch (FileNotFoundException e) {
CHANNEL.sendMessage(new WarningMessage("FAILED TO GENERATE IMAGE", "Unable to display scout result.").get().build());
display.delete();
deleteTempDirectory();
return;
} catch (RateLimitException e) {
EmbedBuilder rateLimited = new WarningMessage("RATE LIMIT EXCEPTION", "Slow down on the requests!").get();
try {
display.edit(rateLimited.build());
} catch (NullPointerException a) {
// DO SOMETHING
}
deleteTempDirectory();
return;
}
} else {
simpleMessage += "**" + SELECTED_BANNER.getBannerName() + "**" + "\n";
setupScoutMenu();
if (!generateImage || IMAGE_DISABLED) {
simpleMessage += "**- Weapon Result -**" + "\n";
simpleMessage += weaponString;
}
simpleMessage += (CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getName() + "#" + CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getDiscriminator()) + " | " + USER.getMemoryDiamonds() + " Memory Diamonds Left";
LOGGER.debug("Displaying Scout Result...");
IMessage display = null;
try {
if (generateImage && !IMAGE_DISABLED) {
display = CHANNEL.sendFile(simpleMessage, new File(tempUserDirectory + "/results.png"));
} else {
display = CHANNEL.sendMessage(simpleMessage);
}
} catch (FileNotFoundException e) {
CHANNEL.sendMessage(new WarningMessage("FAILED TO GENERATE IMAGE", "Unable to display scout result.").get().build());
display.delete();
deleteTempDirectory();
return;
} catch (RateLimitException e) {
EmbedBuilder rateLimited = new WarningMessage("RATE LIMIT EXCEPTION", "Slow down on the requests!").get();
try {
display.edit(rateLimited.build());
} catch (NullPointerException a) {
// DO SOMETHING
}
deleteTempDirectory();
return;
}
}
LOGGER.debug("Saving User Data...");
USER.saveData();
deleteTempDirectory();
}
use of io.github.spugn.Sargo.Utilities.GitHubImage in project S-argo by Expugn.
the class BannerInfo method getBannerInfo.
private void getBannerInfo() {
if (bannerID < BANNERS.size() && bannerID >= 0) {
Banner banner = BANNERS.get(bannerID);
BannerInfoMenu menu = new BannerInfoMenu();
Random rng = new Random();
int charIndex = rng.nextInt(banner.getCharacters().size());
menu.setBannerType(banner.bannerTypeToString());
menu.setBannerWepType(banner.getBannerWepType());
menu.setBannerName(banner.getBannerName());
menu.setCharacterAmount(banner.getCharacters().size());
menu.setBannerID(bannerID);
menu.setImageURL(new GitHubImage(banner.getCharacters().get(charIndex).getImagePath()).getURL());
/* CREATE CHARACTER LIST */
String charList = "";
for (Character c : banner.getCharacters()) {
charList += "\n" + c.toString();
}
menu.setCharacterList(charList);
/* IF THERE ARE WEAPONS, CREATE WEAPON LIST */
if (banner.getWeapons().size() > 0) {
String weapList = "";
for (Weapon w : banner.getWeapons()) {
weapList += "\n" + w.toString();
}
menu.setWeaponAmount(banner.getWeapons().size());
menu.setWeaponList(weapList);
}
/* CREATE RATE LIST */
List<Character> goldCharacters = new ArrayList<>();
List<Character> platinumCharacters = new ArrayList<>();
/* SORT GOLD AND PLATINUM CHARACTERS AND STORE THEM IN THEIR OWN ARRAYS */
for (Character character : banner.getCharacters()) {
if (character.getRarity() == 4) {
goldCharacters.add(character);
} else if (character.getRarity() == 5) {
platinumCharacters.add(character);
}
}
/* NO PLATINUM CHARACTER, ADJUST RATES */
if (platinumCharacters.size() <= 0) {
copper += platinum;
platinum = 0;
}
/* IF EVENT SCOUT, SET EVERYTHING BUT GOLD TO 0 */
if (banner.getBannerType() == 9) {
if (goldCharacters.size() > 0) {
copper = 0.0;
silver = 0.0;
gold = 100.0;
platinum = 0.0;
} else {
copper = 0.0;
silver = 0.0;
gold = 0.0;
platinum = 100.0;
}
}
/* IF RECORD CRYSTAL V4, INCREASE PLATINUM RATES BY 1.5 */
if (banner.getBannerType() == 11) {
copper = copper - ((platinum * 1.5) - platinum);
platinum = platinum * 1.5;
}
String ratesList = "";
if (platinum != 0)
ratesList += "[5 ★] " + platinum + "%\n";
ratesList += "[4 ★] " + gold + "%\n";
ratesList += "[3 ★] " + silver + "%\n";
ratesList += "[2 ★] " + copper + "%";
menu.setRatesList(ratesList);
/* BANNER IS STEP UP */
if (banner.getBannerType() == 1) {
double tC = copper - ((gold * 1.5) - gold);
double tS = silver;
double tG = gold * 1.5;
double tP = platinum;
String stepThreeRates = "";
if (tP != 0)
stepThreeRates += "[5 ★] " + tP + "%\n";
stepThreeRates += "[4 ★] " + tG + "%\n";
stepThreeRates += "[3 ★] " + tS + "%\n";
stepThreeRates += "[2 ★] " + tC + "%\n";
stepThreeRates += "**(4 ★ Scout Rates 1.5x)**";
menu.setStepThreeRatesList(stepThreeRates);
tC = copper - ((gold * 2.0) - gold);
tS = silver;
tG = gold * 2.0;
tP = platinum;
String stepFiveRates = "";
if (tP != 0)
stepFiveRates += "[5 ★] " + tP + "%\n";
stepFiveRates += "[4 ★] " + tG + "%\n";
stepFiveRates += "[3 ★] " + tS + "%\n";
stepFiveRates += "[2 ★] " + tC + "%\n";
stepFiveRates += "**(4 ★ Scout Rates 2.0x)**";
menu.setStepFiveRatesList(stepFiveRates);
} else /* BANNER IS STEP UP V2 */
if (banner.getBannerType() == 3 || banner.getBannerType() == 10) {
double tC = copper - ((platinum * 1.5) - platinum);
double tS = silver;
double tG = gold;
double tP = platinum * 1.5;
String stepThreeRates = "";
if (tP != 0)
stepThreeRates += "[5 ★] " + tP + "%\n";
stepThreeRates += "[4 ★] " + tG + "%\n";
stepThreeRates += "[3 ★] " + tS + "%\n";
stepThreeRates += "[2 ★] " + tC + "%\n";
stepThreeRates += "**(5 ★ Scout Rates 1.5x)**";
menu.setStepThreeRatesList(stepThreeRates);
tC = 0.0;
tS = 0.0;
tG = 0.0;
tP = 100.0;
String stepFiveRates = "";
stepFiveRates += "[5 ★] " + tP + "%\n";
stepFiveRates += "[4 ★] " + tG + "%\n";
stepFiveRates += "[3 ★] " + tS + "%\n";
stepFiveRates += "[2 ★] " + tC + "%\n";
stepFiveRates += "**(For One Character)**";
menu.setStepFiveRatesList(stepFiveRates);
tC = copper - ((platinum * 2.0) - platinum);
tS = silver;
tG = gold;
tP = platinum * 2.0;
String stepSixRates = "";
if (tP != 0)
stepSixRates += "[5 ★] " + tP + "%\n";
stepSixRates += "[4 ★] " + tG + "%\n";
stepSixRates += "[3 ★] " + tS + "%\n";
stepSixRates += "[2 ★] " + tC + "%\n";
stepSixRates += "**(5 ★ Scout Rates 2.0x)**";
menu.setStepSixRatesList(stepSixRates);
} else /* BANNER IS BIRTHDAY STEP UP */
if (banner.getBannerType() == 4) {
double tC = copper - (((platinum * 2.0) - platinum) + ((gold * 2.0) - gold));
double tS = silver;
double tG = gold * 2.0;
double tP = platinum * 2.0;
String stepThreeRates = "";
if (tP != 0)
stepThreeRates += "[5 ★] " + tP + "%\n";
stepThreeRates += "[4 ★] " + tG + "%\n";
stepThreeRates += "[3 ★] " + tS + "%\n";
stepThreeRates += "[2 ★] " + tC + "%\n";
stepThreeRates += "**(4+ ★ Scout Rates 2.0x)**";
menu.setStepThreeRatesList(stepThreeRates);
} else /* BANNER IS RECORD CRYSTAL */
if (banner.getBannerType() == 2 || banner.getBannerType() == 5 || banner.getBannerType() == 8 || banner.getBannerType() == 11) {
int counter = 0;
String recordCrystalRates = "";
DecimalFormat df = new DecimalFormat("0.0");
for (double d : recordCrystal) {
if (d != 0) {
recordCrystalRates += "[" + ++counter + " RC] " + df.format((d * 100)) + "%\n";
}
}
menu.setRecordCrystalRatesList(recordCrystalRates);
if (banner.getBannerType() == 8 || banner.getBannerType() == 11) {
int counter2 = 0;
String circluatingRecordCrystalRates = "";
if (banner.getBannerType() == 8) {
for (double d : circulatingRecordCrystal) {
if (d != 0) {
circluatingRecordCrystalRates += "[" + ++counter2 + " RC] " + df.format((d * 100)) + "%\n";
}
}
} else {
for (double d : recordCrystal) {
if (d != 0) {
circluatingRecordCrystalRates += "[" + ++counter2 + " RC] " + df.format((d * 100)) + "%\n";
}
}
}
menu.setCirculatingRecordCrystalRatesList(circluatingRecordCrystalRates);
}
} else /* BANNER IS STEP UP V3 */
if (banner.getBannerType() == 7) {
double tC = copper - ((platinum * 2.0) - platinum);
double tS = silver;
double tG = gold;
double tP = platinum * 2.0;
String stepThreeRates = "";
if (tP != 0)
stepThreeRates += "[5 ★] " + tP + "%\n";
stepThreeRates += "[4 ★] " + tG + "%\n";
stepThreeRates += "[3 ★] " + tS + "%\n";
stepThreeRates += "[2 ★] " + tC + "%\n";
stepThreeRates += "**(5 ★ Scout Rates 2.0x)**";
menu.setStepThreeRatesList(stepThreeRates);
}
/* WEAPON BANNER IS STEP UP */
if (banner.getBannerWepType() == 1) {
double tC = (copper + platinum) - ((gold * 2.0) - gold);
double tS = silver;
double tG = gold * 2.0;
String stepThreeRates = "";
stepThreeRates += "[4 ★] " + tG + "%\n";
stepThreeRates += "[3 ★] " + tS + "%\n";
stepThreeRates += "[2 ★] " + tC + "%\n";
stepThreeRates += "**(4 ★ Weapon Rates 2.0x)**";
menu.setStepThreeWeaponRatesList(stepThreeRates);
} else /* WEAPON BANNER IS STEP UP V2 */
if (banner.getBannerWepType() == 2) {
double tC = (copper + platinum) - ((gold * 1.5) - gold);
double tS = silver;
double tG = gold * 1.5;
String stepThreeRates = "";
stepThreeRates += "[4 ★] " + tG + "%\n";
stepThreeRates += "[3 ★] " + tS + "%\n";
stepThreeRates += "[2 ★] " + tC + "%\n";
stepThreeRates += "**(4 ★ Weapon Rates 1.5x)**";
menu.setStepThreeWeaponRatesList(stepThreeRates);
tC = 0.0;
tS = 0.0;
tG = 100.0;
String stepFiveRates = "";
stepFiveRates += "[4 ★] " + tG + "%\n";
stepFiveRates += "[3 ★] " + tS + "%\n";
stepFiveRates += "[2 ★] " + tC + "%\n";
stepFiveRates += "**(For One Weapon)**";
menu.setStepFiveWeaponRatesList(stepFiveRates);
tC = (copper + platinum) - ((gold * 2.0) - gold);
tS = silver;
tG = gold * 2.0;
String stepSixRates = "";
stepSixRates += "[4 ★] " + tG + "%\n";
stepSixRates += "[3 ★] " + tS + "%\n";
stepSixRates += "[2 ★] " + tC + "%\n";
stepSixRates += "**(4 ★ Weapon Rates 2.0x)**";
menu.setStepSixWeaponRatesList(stepSixRates);
}
CHANNEL.sendMessage(menu.get().build());
} else {
CHANNEL.sendMessage(new WarningMessage("UNKNOWN BANNER ID", "Use '" + CommandManager.getCommandPrefix() + "**scout**' for a list of banners.").get().build());
}
}
Aggregations