Skip to content

Commit

Permalink
Spell "effect" fields now are List<List<Double>> instead of
Browse files Browse the repository at this point in the history
List<List<Integer>>.
  • Loading branch information
Rob Rua committed Jul 8, 2014
1 parent d011da2 commit c83be8f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
8 changes: 6 additions & 2 deletions src/lib/orianna/api/JSONConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ private static LocalDateTime getDateTime(final JSONObject object, final String k
return LocalDateTime.ofEpochSecond(epoch / 1000, 0, timeZone);
}

private static List<Double> getDoubleList(final JSONArray list) {
return getList(list, d -> (Double)d);
}

private static List<Double> getDoubleList(final JSONObject object, final String key) {
return getList(object, key, d -> (Double)d);
}
Expand Down Expand Up @@ -734,7 +738,7 @@ public ChampionSpell getChampionSpellFromJSON(final JSONObject championSpellInfo
final LevelTip levelTip = getLevelTipFromJSON((JSONObject)championSpellInfo.get("leveltip"));
final List<Image> altImages = getList(championSpellInfo, "altimages", i -> getImageFromJSON((JSONObject)i));
final List<SpellVariables> vars = getList(championSpellInfo, "vars", v -> getSpellVariablesFromJSON((JSONObject)v));
final List<List<Integer>> effect = getList(championSpellInfo, "effect", l -> getIntegerList((JSONArray)l));
final List<List<Double>> effect = getList(championSpellInfo, "effect", l -> getDoubleList((JSONArray)l));

List<Integer> range;
final Object val = championSpellInfo.get("range");
Expand Down Expand Up @@ -1478,7 +1482,7 @@ public SummonerSpell getSummonerSpellFromJSON(final JSONObject summonerSpellInfo
final String sanitizedTooltip = (String)summonerSpellInfo.get("sanitizedTooltip");
final String tooltip = (String)summonerSpellInfo.get("tooltip");
final List<Integer> cost = getIntegerList(summonerSpellInfo, "cost");
final List<List<Integer>> effect = getList(summonerSpellInfo, "effect", l -> getIntegerList((JSONArray)l));
final List<List<Double>> effect = getList(summonerSpellInfo, "effect", l -> getDoubleList((JSONArray)l));
final List<String> effectBurn = getStringList(summonerSpellInfo, "effectBurn");
final List<String> modes = getStringList(summonerSpellInfo, "modes");
final Integer ID = getInteger(summonerSpellInfo, "id");
Expand Down
20 changes: 4 additions & 16 deletions src/lib/orianna/api/RiotAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,11 @@ private class Cache {
private final static JSONParser parser = new JSONParser();

private static List<Long> getIDsFromSummoners(final List<Summoner> summoners) {
final List<Long> summonerIDs = new ArrayList<Long>();
for(final Summoner summoner : summoners) {
summonerIDs.add(summoner.ID);
}
return summonerIDs;
return summoners.parallelStream().map((summoner) -> summoner.ID).collect(Collectors.toList());
}

private static List<String> getIDsFromTeams(final List<Team> teams) {
final List<String> teamIDs = new ArrayList<String>();
for(final Team team : teams) {
teamIDs.add(team.ID);
}
return teamIDs;
return teams.parallelStream().map((team) -> team.ID).collect(Collectors.toList());
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -144,17 +136,13 @@ private static <T> List<List<T>> splitIDList(final List<T> IDs) {

private static <T> Map<Summoner, T> summonerMapFromID(final List<Summoner> summoners, final Map<Long, T> IDMap) {
final Map<Summoner, T> map = new HashMap<Summoner, T>();
for(final Summoner summoner : summoners) {
map.put(summoner, IDMap.get(summoner.ID));
}
summoners.forEach((summoner) -> map.put(summoner, IDMap.get(summoner.ID)));
return Collections.unmodifiableMap(map);
}

private static <T> Map<Team, T> teamMapFromID(final List<Team> teams, final Map<String, T> IDMap) {
final Map<Team, T> map = new HashMap<Team, T>();
for(final Team team : teams) {
map.put(team, IDMap.get(team.ID));
}
teams.forEach((team) -> map.put(team, IDMap.get(team.ID)));
return Collections.unmodifiableMap(map);
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/orianna/type/staticdata/ChampionSpell.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ChampionSpell implements Serializable {
public final List<Double> cooldown;
public final String cooldownBurn, costBurn, costType, description, key, name, rangeBurn, resource, sanitizedDescription, sanitizedTooltip, tooltip;
public final List<Integer> cost, range;
public final List<List<Integer>> effect;
public final List<List<Double>> effect;
public final List<String> effectBurn;
public final Image image;
public final LevelTip levelTip;
Expand All @@ -18,7 +18,7 @@ public class ChampionSpell implements Serializable {

public ChampionSpell(final List<Image> altImages, final List<Double> cooldown, final String cooldownBurn, final String costBurn, final String costType,
final String description, final String key, final String name, final String rangeBurn, final String resource, final String sanitizedDescription,
final String sanitizedTooltip, final String tooltip, final List<Integer> cost, final List<Integer> range, final List<List<Integer>> effect,
final String sanitizedTooltip, final String tooltip, final List<Integer> cost, final List<Integer> range, final List<List<Double>> effect,
final List<String> effectBurn, final Image image, final LevelTip levelTip, final Integer maxRank, final List<SpellVariables> vars) {
this.altImages = altImages;
this.cooldown = cooldown;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/orianna/type/staticdata/SummonerSpell.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class SummonerSpell implements Serializable {
public final List<Double> cooldown;
public final String cooldownBurn, costBurn, costType, description, key, name, rangeBurn, resource, sanitizedDescription, sanitizedTooltip, tooltip;
public final List<Integer> cost, range;
public final List<List<Integer>> effect;
public final List<List<Double>> effect;
public final List<String> effectBurn, modes;
public final Integer ID, maxRank, summonerLevel;
public final Image image;
Expand All @@ -17,7 +17,7 @@ public class SummonerSpell implements Serializable {

public SummonerSpell(final String cooldownBurn, final String costBurn, final String costType, final String description, final String key,
final String name, final String rangeBurn, final String resource, final String sanitizedDescription, final String sanitizedTooltip,
final String tooltip, final List<Double> cooldown, final List<Integer> cost, final List<Integer> range, final List<List<Integer>> effect,
final String tooltip, final List<Double> cooldown, final List<Integer> cost, final List<Integer> range, final List<List<Double>> effect,
final List<String> effectBurn, final List<String> modes, final Integer ID, final Integer maxRank, final Integer summonerLevel, final Image image,
final LevelTip levelTip, final List<SpellVariables> vars) {
this.cooldownBurn = cooldownBurn;
Expand Down

0 comments on commit c83be8f

Please sign in to comment.