Search in sources :

Example 6 with Character

use of io.github.spugn.Sargo.Objects.Character in project S-argo by Expugn.

the class CharacterScout method init.

/**
 * Initializes all the variables needed for scouts.
 */
private void init() {
    /* FILES */
    // SETTINGS = new SettingsParser();
    BANNERS = BannerParser.getBanners();
    USER = new UserParser(DISCORD_ID);
    /* SETTINGS */
    IS_RARITY_STARS = SettingsParser.isRarityStars();
    COPPER = (int) (SettingsParser.getCopperRates() * 100);
    SILVER = (int) (SettingsParser.getSilverRates() * 100);
    GOLD = (int) (SettingsParser.getGoldRates() * 100);
    PLATINUM = (int) (SettingsParser.getPlatinumRates() * 100);
    RECORD_CRYSTAL_RATES = SettingsParser.getRecordCrystalRates();
    CIRCULATING_RECORD_CRYSTAL_RATES = SettingsParser.getCirculatingRecordCrystalRates();
    GOLD_BANNERS = SettingsParser.getGoldBanners();
    GOLD_BANNERS_V2 = SettingsParser.getGoldBannersv2();
    IMAGE_DISABLED = SettingsParser.isDisableImages();
    SIMPLE_MESSAGE = SettingsParser.isSimpleMessage();
    /* USER */
    userMemoryDiamonds = USER.getMemoryDiamonds();
    userHackingCrystals = USER.getHackingCrystals();
    userRecordCrystals = 0;
    /* VARIABLES */
    RNG = new Random(System.currentTimeMillis());
    imageStrings = new String[11];
    characters = new ArrayList<>();
    guaranteeOnePlatinum = false;
    guaranteedScout = false;
    characterString = "";
    tempUserDirectory = new File("images/temp_" + DISCORD_ID);
    scoutMenu = new EmbedBuilder();
    simpleMessage = "";
    /* MEMORY DIAMOND PRICES */
    singleScoutPrice = 25;
    multiScoutPrice = 250;
    /* BANNER */
    if (BANNER_ID < BANNERS.size() && BANNER_ID >= 0) {
        SELECTED_BANNER = BANNERS.get(BANNER_ID);
        BANNER_CHARACTERS = SELECTED_BANNER.getCharacters();
        bannerType = SELECTED_BANNER.getBannerType();
        bannerTypeData = USER.getBannerData(SELECTED_BANNER.getBannerName());
        goldCharacters = new ArrayList<>();
        platinumCharacters = new ArrayList<>();
        if (USER.isBannerInfoExists(SELECTED_BANNER.getBannerName()) == -1) {
            initBannerInfo();
        }
        for (Character character : BANNER_CHARACTERS) {
            if (character.getRarity() == 4) {
                goldCharacters.add(character);
            } else if (character.getRarity() == 5) {
                platinumCharacters.add(character);
            }
        }
        if (platinumCharacters.size() <= 0) {
            COPPER += PLATINUM;
            PLATINUM = 0;
        }
        modifyScoutData();
        LOGGER.debug("\n- Scout Data -\n" + "Single Price " + singleScoutPrice + "\n" + "Multi Price: " + multiScoutPrice + "\n" + "COPPER: " + COPPER + "%\n" + "SILVER: " + SILVER + "%\n" + "GOLD: " + GOLD + "%\n" + "PLATINUM: " + PLATINUM + "%");
    }
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder) Random(java.util.Random) Character(io.github.spugn.Sargo.Objects.Character) UserParser(io.github.spugn.Sargo.XMLParsers.UserParser) File(java.io.File)

Example 7 with Character

use of io.github.spugn.Sargo.Objects.Character in project S-argo by Expugn.

the class CharacterScout method doMultiPull.

/**
 * Generates eleven characters and the scout result image.
 */
void doMultiPull() {
    if (generateImage && !IMAGE_DISABLED) {
        tempUserDirectory.mkdir();
    }
    for (int i = 0; i < 11; i++) {
        characters.add(getCharacter(scout()));
    }
    Character tempCharacter;
    for (int a = 0; a < 12; a++) {
        for (int b = 1; b < 11; b++) {
            if (characters.get(b - 1).getRarity() <= characters.get(b).getRarity()) {
                tempCharacter = characters.get(b - 1);
                characters.set(b - 1, characters.get(b));
                characters.set(b, tempCharacter);
            }
        }
    }
    highestRarity = characters.get(0).getRarity();
    generateImageStrings();
    if (generateImage && !IMAGE_DISABLED)
        new ImageEditor().drawMultiScout(imageStrings, true, tempUserDirectory + "/results.png");
}
Also used : ImageEditor(io.github.spugn.Sargo.Utilities.ImageEditor) Character(io.github.spugn.Sargo.Objects.Character)

Example 8 with Character

use of io.github.spugn.Sargo.Objects.Character in project S-argo by Expugn.

the class CharacterScout method generateImageString.

/**
 * Checks the user's character box for duplicate characters,
 * grant Hacking Crystals, and generates the character images.
 */
private void generateImageString() {
    if (!USER.getCharacterBox().isEmpty()) {
        for (Character userCharacter : USER.getCharacterBox()) {
            if (userCharacter.getPrefix().equals(characters.get(0).getPrefix()) && userCharacter.getRarity() == characters.get(0).getRarity() && userCharacter.getName().equals(characters.get(0).getName())) {
                giveHackingCrystals(characters.get(0));
                characterString += "~~" + characters.get(0).toString() + "~~" + "\n";
                if (generateImage && !IMAGE_DISABLED)
                    new ImageEditor().drawCharacterImage(characters.get(0).getImagePath(), characters.get(0).getRarity(), true, IS_RARITY_STARS, tempUserDirectory + "/temp_" + 0 + ".png");
                imageString = tempUserDirectory + "/temp_" + 0 + ".png";
                return;
            }
        }
    }
    USER.addCharacter(characters.get(0));
    characterString += "**" + characters.get(0).toString() + "**\n";
    if (generateImage && !IMAGE_DISABLED)
        new ImageEditor().drawCharacterImage(characters.get(0).getImagePath(), characters.get(0).getRarity(), false, IS_RARITY_STARS, tempUserDirectory + "/temp_" + 0 + ".png");
    imageString = tempUserDirectory + "/temp_" + 0 + ".png";
}
Also used : ImageEditor(io.github.spugn.Sargo.Utilities.ImageEditor) Character(io.github.spugn.Sargo.Objects.Character)

Example 9 with Character

use of io.github.spugn.Sargo.Objects.Character in project S-argo by Expugn.

the class Memorial method randGoldCharacter.

@Override
protected Character randGoldCharacter() {
    int randIndex = GOLD_BANNERS_V2.get(RNG.nextInt(GOLD_BANNERS_V2.size()));
    Banner randBanner = BANNERS.get(randIndex - 1);
    List<Character> randCharacters = randBanner.getCharacters();
    return randCharacters.get(RNG.nextInt(randCharacters.size()));
}
Also used : Character(io.github.spugn.Sargo.Objects.Character) Banner(io.github.spugn.Sargo.Objects.Banner)

Example 10 with Character

use of io.github.spugn.Sargo.Objects.Character in project S-argo by Expugn.

the class Normal method randGoldCharacter.

@Override
protected Character randGoldCharacter() {
    int randIndex = GOLD_BANNERS.get(RNG.nextInt(GOLD_BANNERS.size()));
    Banner randBanner = BANNERS.get(randIndex - 1);
    List<Character> randCharacters = randBanner.getCharacters();
    return randCharacters.get(RNG.nextInt(randCharacters.size()));
}
Also used : Character(io.github.spugn.Sargo.Objects.Character) Banner(io.github.spugn.Sargo.Objects.Banner)

Aggregations

Character (io.github.spugn.Sargo.Objects.Character)25 Banner (io.github.spugn.Sargo.Objects.Banner)13 ImageEditor (io.github.spugn.Sargo.Utilities.ImageEditor)3 Weapon (io.github.spugn.Sargo.Objects.Weapon)2 UserParser (io.github.spugn.Sargo.XMLParsers.UserParser)2 FailedToReadBannerFileException (io.github.spugn.Sargo.Exceptions.FailedToReadBannerFileException)1 GitHubImage (io.github.spugn.Sargo.Utilities.GitHubImage)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 DecimalFormat (java.text.DecimalFormat)1 Random (java.util.Random)1 XMLEventReader (javax.xml.stream.XMLEventReader)1 XMLInputFactory (javax.xml.stream.XMLInputFactory)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 Attribute (javax.xml.stream.events.Attribute)1 EndElement (javax.xml.stream.events.EndElement)1 StartElement (javax.xml.stream.events.StartElement)1