Skip to content

Commit

Permalink
Team name showing as Red, Blue, Yellow
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryptically committed Aug 9, 2016
1 parent 19c1f89 commit 39a01d3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
15 changes: 15 additions & 0 deletions src/me/corriekay/pokegoutil/utils/Utilities.java
Expand Up @@ -24,6 +24,10 @@
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.UIManager; import javax.swing.UIManager;


import org.apache.commons.lang3.StringUtils;

import com.pokegoapi.api.player.Team;

public abstract class Utilities { public abstract class Utilities {
private static final Random random = new Random(System.currentTimeMillis()); private static final Random random = new Random(System.currentTimeMillis());


Expand Down Expand Up @@ -258,4 +262,15 @@ public static void sleep(int sleep) {
e.printStackTrace(); e.printStackTrace();
} }
} }

public static String convertTeamColorToName(int teamValue){
Team[] teams = Team.values();

for(Team team : teams){
if(team.getValue() == teamValue){
return StringUtils.capitalize(team.toString().toLowerCase().replaceAll("team_", ""));
}
}
return "UNKNOWN_TEAM";
}
} }
3 changes: 2 additions & 1 deletion src/me/corriekay/pokegoutil/windows/MenuBar.java
Expand Up @@ -7,6 +7,7 @@


import javax.swing.*; import javax.swing.*;
import me.corriekay.pokegoutil.controllers.AccountController; import me.corriekay.pokegoutil.controllers.AccountController;
import me.corriekay.pokegoutil.utils.Utilities;


@SuppressWarnings("serial") @SuppressWarnings("serial")
public class MenuBar extends JMenuBar { public class MenuBar extends JMenuBar {
Expand Down Expand Up @@ -67,7 +68,7 @@ private void displayTrainerStats() throws Exception {
PlayerProfile pp = go.getPlayerProfile(); PlayerProfile pp = go.getPlayerProfile();
Object[] tstats = { Object[] tstats = {
"Trainer Name: " + pp.getPlayerData().getUsername(), "Trainer Name: " + pp.getPlayerData().getUsername(),
"Team: " + pp.getPlayerData().getTeam().toString(), "Team: " + Utilities.convertTeamColorToName(pp.getPlayerData().getTeamValue()),
"Level: " + pp.getStats().getLevel(), "Level: " + pp.getStats().getLevel(),
"XP: " + pp.getStats().getExperience() + " (" + go.getPlayerProfile().getStats().getNextLevelXp() + " to next level)", "XP: " + pp.getStats().getExperience() + " (" + go.getPlayerProfile().getStats().getNextLevelXp() + " to next level)",
"Stardust: " + pp.getCurrency(Currency.STARDUST) "Stardust: " + pp.getCurrency(Currency.STARDUST)
Expand Down
21 changes: 10 additions & 11 deletions src/me/corriekay/pokegoutil/windows/PokemonGoMainWindow.java
Expand Up @@ -10,8 +10,6 @@
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JTabbedPane; import javax.swing.JTabbedPane;


import org.apache.commons.lang3.StringUtils;

import com.pokegoapi.api.PokemonGo; import com.pokegoapi.api.PokemonGo;
import com.pokegoapi.api.player.PlayerProfile; import com.pokegoapi.api.player.PlayerProfile;
import com.pokegoapi.exceptions.InvalidCurrencyException; import com.pokegoapi.exceptions.InvalidCurrencyException;
Expand All @@ -26,7 +24,7 @@
public class PokemonGoMainWindow extends JFrame { public class PokemonGoMainWindow extends JFrame {


private final PokemonGo go; private final PokemonGo go;
private final PlayerProfile p; private final PlayerProfile pp;
public static PokemonGoMainWindow window = null; public static PokemonGoMainWindow window = null;
private Config config = Config.getConfig(); private Config config = Config.getConfig();


Expand All @@ -36,15 +34,16 @@ public class PokemonGoMainWindow extends JFrame {


public PokemonGoMainWindow(PokemonGo pkmngo, Console console){ public PokemonGoMainWindow(PokemonGo pkmngo, Console console){
go = pkmngo; go = pkmngo;
p = go.getPlayerProfile(); pp = go.getPlayerProfile();


console.clearAllLines(); console.clearAllLines();
try { try {
System.out.println("Successfully logged in. Welcome, " + p.getPlayerData().getUsername() + ".");
System.out.println("Stats: Lvl " + p.getStats().getLevel() + " " + StringUtils.capitalize( System.out.println("Successfully logged in. Welcome, " + pp.getPlayerData().getUsername() + ".");
p.getPlayerData().getTeam().toString().toLowerCase().replaceAll("team_", "") + " player.")); System.out.println("Stats: Lvl " + pp.getStats().getLevel() + " "
System.out.println("Pokédex - Types Caught: " + p.getStats().getUniquePokedexEntries() + Utilities.convertTeamColorToName(pp.getPlayerData().getTeamValue()) + " player.");
+ ", Total Pokémon Caught: " + p.getStats().getPokemonsCaptured() + ", Total Current Pokémon: " System.out.println("Pokédex - Types Caught: " + pp.getStats().getUniquePokedexEntries()
+ ", Total Pokémon Caught: " + pp.getStats().getPokemonsCaptured() + ", Total Current Pokémon: "
+ go.getInventories().getPokebank().getPokemons().size()); + go.getInventories().getPokebank().getPokemons().size());
} catch (RemoteServerException | LoginFailedException e) { } catch (RemoteServerException | LoginFailedException e) {
System.out.println("Unable to login!"); System.out.println("Unable to login!");
Expand Down Expand Up @@ -91,8 +90,8 @@ public void componentMoved(ComponentEvent e) {
public void refreshTitle() { public void refreshTitle() {
try { try {
NumberFormat f = NumberFormat.getInstance(); NumberFormat f = NumberFormat.getInstance();
setTitle(String.format("%s - Stardust: %s - Blossom's Pokémon Go Manager", p.getPlayerData().getUsername(), setTitle(String.format("%s - Stardust: %s - Blossom's Pokémon Go Manager", pp.getPlayerData().getUsername(),
f.format(p.getCurrency(PlayerProfile.Currency.STARDUST)))); f.format(pp.getCurrency(PlayerProfile.Currency.STARDUST))));
} catch (InvalidCurrencyException | LoginFailedException | RemoteServerException e) { } catch (InvalidCurrencyException | LoginFailedException | RemoteServerException e) {
setTitle("Blossom's Pokémon Go Manager"); setTitle("Blossom's Pokémon Go Manager");
} }
Expand Down

0 comments on commit 39a01d3

Please sign in to comment.