forked from TCGdex/java-sdk
Rename package and cleanup
This commit is contained in:
parent
5295ec2b3b
commit
bee1b6d71e
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.github.maxopoly</groupId>
|
||||
<groupId>com.github.tcgdex</groupId>
|
||||
|
||||
<artifactId>tcgdex</artifactId>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.github.maxopoly.tcgdex;
|
||||
package com.github.tcgdex;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -29,16 +29,17 @@ public class Ability {
|
||||
private final String name;
|
||||
private final String effect;
|
||||
|
||||
Ability(JSONObject json) {
|
||||
this(json.getString("type"), json.getString("name"), json.getString("effect"));
|
||||
}
|
||||
|
||||
Ability(String type, String name, String effect) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.effect = effect;
|
||||
}
|
||||
|
||||
Ability(JSONObject json) {
|
||||
this(json.getString("type"), json.getString("name"), json.getString("effect"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof Ability)) {
|
||||
return false;
|
||||
@ -48,24 +49,6 @@ public class Ability {
|
||||
new Object[] { other.type, other.name, other.effect });
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.type, this.name, this.effect);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Type of the ability, for example 'Poke-POWER'
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Name of the ability
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Description/Effect of the ability
|
||||
@ -74,4 +57,23 @@ public class Ability {
|
||||
return effect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Name of the ability
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Type of the ability, for example 'Poke-POWER'
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.type, this.name, this.effect);
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.github.maxopoly.tcgdex;
|
||||
package com.github.tcgdex;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -30,6 +30,11 @@ public class Attack {
|
||||
private final String effect;
|
||||
private final String damage;
|
||||
|
||||
Attack(JSONObject json) {
|
||||
this(Types.parse(json.getJSONArray("cost")), json.getString("name"), json.optString("effect"),
|
||||
json.optString("damage"));
|
||||
}
|
||||
|
||||
Attack(List<Types> cost, String name, String effect, String damage) {
|
||||
super();
|
||||
this.cost = cost;
|
||||
@ -38,11 +43,7 @@ public class Attack {
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
Attack(JSONObject json) {
|
||||
this(Types.parse(json.getJSONArray("cost")), json.getString("name"), json.optString("effect"),
|
||||
json.optString("damage"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof Attack)) {
|
||||
return false;
|
||||
@ -52,10 +53,6 @@ public class Attack {
|
||||
new Object[] { other.cost, other.name, other.effect, other.damage });
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.cost, this.name, this.effect, this.damage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Cost of the attack in the same order as listed on the card
|
||||
*/
|
||||
@ -63,20 +60,6 @@ public class Attack {
|
||||
return cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Name of the attack
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Effect/Description of the attack, may be null for attacks without text
|
||||
*/
|
||||
public String getEffect() {
|
||||
return effect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Damage the attack deals. May just be a number like '30', but can also
|
||||
* be a multiplier like 'x20'
|
||||
@ -85,4 +68,23 @@ public class Attack {
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Effect/Description of the attack, may be null for attacks without text
|
||||
*/
|
||||
public String getEffect() {
|
||||
return effect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Name of the attack
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.cost, this.name, this.effect, this.damage);
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.github.maxopoly.tcgdex;
|
||||
package com.github.tcgdex;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -34,35 +34,6 @@ public class CardInfo extends CardResume {
|
||||
private final Integer retreat;
|
||||
private final String regulationMark;
|
||||
|
||||
public CardInfo(String id, String localId, String name, String image, String illustrator, Rarities rarity,
|
||||
Categories category, boolean hasNormalVariant, boolean hasReverseVariant, boolean hasHolo,
|
||||
boolean hasFirstEditionPic, SetResume set, List<Integer> dexIDs, Integer hp, List<Types> types,
|
||||
String evolveFrom, String description, String level, String stage, String suffix, List<Attack> attacks,
|
||||
List<Weakness> weakness, List<Ability> abilities, Integer retreat, String regulationMark) {
|
||||
super(id, localId, name, image);
|
||||
this.illustrator = illustrator;
|
||||
this.rarity = rarity;
|
||||
this.category = category;
|
||||
this.hasNormalVariant = hasNormalVariant;
|
||||
this.hasReverseVariant = hasReverseVariant;
|
||||
this.hasHolo = hasHolo;
|
||||
this.hasFirstEditionPic = hasFirstEditionPic;
|
||||
this.set = set;
|
||||
this.dexIDs = dexIDs;
|
||||
this.hp = hp;
|
||||
this.types = types;
|
||||
this.evolveFrom = evolveFrom;
|
||||
this.description = description;
|
||||
this.level = level;
|
||||
this.stage = stage;
|
||||
this.suffix = suffix;
|
||||
this.attacks = attacks;
|
||||
this.weakness = weakness;
|
||||
this.abilities = abilities;
|
||||
this.retreat = retreat;
|
||||
this.regulationMark = regulationMark;
|
||||
}
|
||||
|
||||
CardInfo(JSONObject json) {
|
||||
super(json);
|
||||
this.illustrator = json.getString("illustrator");
|
||||
@ -95,6 +66,35 @@ public class CardInfo extends CardResume {
|
||||
this.abilities = Ability.parse(json.optJSONArray("abilities"));
|
||||
}
|
||||
|
||||
public CardInfo(String id, String localId, String name, String image, String illustrator, Rarities rarity,
|
||||
Categories category, boolean hasNormalVariant, boolean hasReverseVariant, boolean hasHolo,
|
||||
boolean hasFirstEditionPic, SetResume set, List<Integer> dexIDs, Integer hp, List<Types> types,
|
||||
String evolveFrom, String description, String level, String stage, String suffix, List<Attack> attacks,
|
||||
List<Weakness> weakness, List<Ability> abilities, Integer retreat, String regulationMark) {
|
||||
super(id, localId, name, image);
|
||||
this.illustrator = illustrator;
|
||||
this.rarity = rarity;
|
||||
this.category = category;
|
||||
this.hasNormalVariant = hasNormalVariant;
|
||||
this.hasReverseVariant = hasReverseVariant;
|
||||
this.hasHolo = hasHolo;
|
||||
this.hasFirstEditionPic = hasFirstEditionPic;
|
||||
this.set = set;
|
||||
this.dexIDs = dexIDs;
|
||||
this.hp = hp;
|
||||
this.types = types;
|
||||
this.evolveFrom = evolveFrom;
|
||||
this.description = description;
|
||||
this.level = level;
|
||||
this.stage = stage;
|
||||
this.suffix = suffix;
|
||||
this.attacks = attacks;
|
||||
this.weakness = weakness;
|
||||
this.abilities = abilities;
|
||||
this.retreat = retreat;
|
||||
this.regulationMark = regulationMark;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Pokemon's abilities. May be empty if it doesn't have any, but never
|
||||
* null
|
||||
@ -103,14 +103,6 @@ public class CardInfo extends CardResume {
|
||||
return abilities;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Card's regulation mark. May be null if unknown or doesn't exist
|
||||
*/
|
||||
public String getRegulationMark() {
|
||||
return regulationMark;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attacks the pokemon has. Empty for cards without attacks
|
||||
*/
|
||||
@ -119,17 +111,43 @@ public class CardInfo extends CardResume {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Weaknesses the pokemon has. Empty for cards without attacks
|
||||
*
|
||||
* @return Card category
|
||||
*/
|
||||
public List<Weakness> getWeakness() {
|
||||
return weakness;
|
||||
public Categories getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Card's retreat. Will be null for cards without retreat
|
||||
*
|
||||
* @return List of the national pokedex IDs of the pokemon on the card (may be
|
||||
* multiple)
|
||||
*/
|
||||
public Integer getRetreat() {
|
||||
return retreat;
|
||||
public List<Integer> getDexIDs() {
|
||||
return dexIDs;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Card effect/description, may be null
|
||||
*/
|
||||
public String getEffect() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Name of the pokemon this one evolves from
|
||||
*/
|
||||
public String getEvolveFrom() {
|
||||
return evolveFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HP of the pokemon, will be null if the card is not a pokemon
|
||||
*/
|
||||
public Integer getHp() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -140,6 +158,14 @@ public class CardInfo extends CardResume {
|
||||
return illustrator;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Pokemon level, may be 'X', hence not an integer
|
||||
*/
|
||||
public String getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Card rarity
|
||||
@ -150,10 +176,68 @@ public class CardInfo extends CardResume {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Card category
|
||||
* @return Card's regulation mark. May be null if unknown or doesn't exist
|
||||
*/
|
||||
public Categories getCategory() {
|
||||
return category;
|
||||
public String getRegulationMark() {
|
||||
return regulationMark;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Card's retreat. Will be null for cards without retreat
|
||||
*/
|
||||
public Integer getRetreat() {
|
||||
return retreat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Resume of the set the card belongs to
|
||||
*/
|
||||
public SetResume getSet() {
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Pokemon's stage, like 'Basic'
|
||||
*/
|
||||
public String getStage() {
|
||||
return stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Suffix, like 'V', may be null
|
||||
*/
|
||||
public String getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Types of the pokemon
|
||||
*/
|
||||
public List<Types> getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Weaknesses the pokemon has. Empty for cards without attacks
|
||||
*/
|
||||
public List<Weakness> getWeakness() {
|
||||
return weakness;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Does the card have a small first edition in the middle left
|
||||
*/
|
||||
public boolean hasFirstEditionPic() {
|
||||
return hasFirstEditionPic;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Does the card have a holo variant (picture is shining)
|
||||
*/
|
||||
public boolean hasHoloVariant() {
|
||||
return hasHolo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -172,88 +256,4 @@ public class CardInfo extends CardResume {
|
||||
return hasReverseVariant;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Does the card have a holo variant (picture is shining)
|
||||
*/
|
||||
public boolean hasHoloVariant() {
|
||||
return hasHolo;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Does the card have a small first edition in the middle left
|
||||
*/
|
||||
public boolean hasFirstEditionPic() {
|
||||
return hasFirstEditionPic;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Resume of the set the card belongs to
|
||||
*/
|
||||
public SetResume getSet() {
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return List of the national pokedex IDs of the pokemon on the card (may be
|
||||
* multiple)
|
||||
*/
|
||||
public List<Integer> getDexIDs() {
|
||||
return dexIDs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HP of the pokemon, will be null if the card is not a pokemon
|
||||
*/
|
||||
public Integer getHp() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Types of the pokemon
|
||||
*/
|
||||
public List<Types> getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Name of the pokemon this one evolves from
|
||||
*/
|
||||
public String getEvolveFrom() {
|
||||
return evolveFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Card effect/description, may be null
|
||||
*/
|
||||
public String getEffect() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Pokemon level, may be 'X', hence not an integer
|
||||
*/
|
||||
public String getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Pokemon's stage, like 'Basic'
|
||||
*/
|
||||
public String getStage() {
|
||||
return stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Suffix, like 'V', may be null
|
||||
*/
|
||||
public String getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.github.maxopoly.tcgdex;
|
||||
package com.github.tcgdex;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -29,6 +29,10 @@ public class CardResume {
|
||||
private final String name;
|
||||
private final String image;
|
||||
|
||||
CardResume(JSONObject json) {
|
||||
this(json.getString("id"), json.getString("localId"), json.getString("name"), json.optString("image"));
|
||||
}
|
||||
|
||||
CardResume(String id, String localId, String name, String image) {
|
||||
this.id = id;
|
||||
this.localId = localId;
|
||||
@ -36,10 +40,6 @@ public class CardResume {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
CardResume(JSONObject json) {
|
||||
this(json.getString("id"), json.getString("localId"), json.getString("name"), json.optString("image"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Globally unique card ID based on the set ID and the cards ID within the set
|
||||
*/
|
||||
@ -47,6 +47,14 @@ public class CardResume {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Card image, can be null
|
||||
*/
|
||||
public String getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ID indexing this card within its set, usually just its number
|
||||
*/
|
||||
@ -61,12 +69,4 @@ public class CardResume {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Card image, can be null
|
||||
*/
|
||||
public String getImage() {
|
||||
return image;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.github.maxopoly.tcgdex;
|
||||
package com.github.tcgdex;
|
||||
|
||||
public enum Categories {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.github.maxopoly.tcgdex;
|
||||
package com.github.tcgdex;
|
||||
|
||||
public enum Rarities {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.github.maxopoly.tcgdex;
|
||||
package com.github.tcgdex;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -12,16 +12,16 @@ public class SeriesInfo extends SeriesResume {
|
||||
|
||||
private final List<SetResume> sets;
|
||||
|
||||
SeriesInfo(String id, String name, List<SetResume> sets) {
|
||||
super(id, name);
|
||||
this.sets = sets;
|
||||
}
|
||||
|
||||
SeriesInfo(JSONObject json) {
|
||||
super(json);
|
||||
this.sets = SetResume.parse(json.optJSONArray("sets"));
|
||||
}
|
||||
|
||||
SeriesInfo(String id, String name, List<SetResume> sets) {
|
||||
super(id, name);
|
||||
this.sets = sets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Resumes of the sets part of this series
|
||||
*/
|
@ -1,4 +1,4 @@
|
||||
package com.github.maxopoly.tcgdex;
|
||||
package com.github.tcgdex;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
@ -11,15 +11,15 @@ public class SeriesResume {
|
||||
private final String id;
|
||||
private final String name;
|
||||
|
||||
SeriesResume(JSONObject json) {
|
||||
this(json.getString("id"), json.getString("name"));
|
||||
}
|
||||
|
||||
SeriesResume(String id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
SeriesResume(JSONObject json) {
|
||||
this(json.getString("id"), json.getString("name"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Serie unique ID
|
||||
*/
|
@ -1,4 +1,4 @@
|
||||
package com.github.maxopoly.tcgdex;
|
||||
package com.github.tcgdex;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@ -58,6 +58,20 @@ public class SetInfo extends SetResume {
|
||||
this.cards = cards;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return All cards part of the set
|
||||
*/
|
||||
public List<CardResume> getCards() {
|
||||
return cards;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Amount of first edition cards the set has
|
||||
*/
|
||||
public int getFirstEdCardCount() {
|
||||
return firstEd;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Amount of holo cards the set has
|
||||
*/
|
||||
@ -73,10 +87,10 @@ public class SetInfo extends SetResume {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Amount of first edition cards the set has
|
||||
* @return When the set was released
|
||||
*/
|
||||
public int getFirstEdCardCount() {
|
||||
return firstEd;
|
||||
public LocalDate getReleaseDate() {
|
||||
return releaseDate;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,10 +115,10 @@ public class SetInfo extends SetResume {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return When the set was released
|
||||
* @return Ability to use this set in Expanded competitions
|
||||
*/
|
||||
public LocalDate getReleaseDate() {
|
||||
return releaseDate;
|
||||
public boolean isLegalInExpanded() {
|
||||
return legalInExpanded;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -113,18 +127,4 @@ public class SetInfo extends SetResume {
|
||||
public boolean isLegalInStandard() {
|
||||
return legalInStandard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Ability to use this set in Expanded competitions
|
||||
*/
|
||||
public boolean isLegalInExpanded() {
|
||||
return legalInExpanded;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return All cards part of the set
|
||||
*/
|
||||
public List<CardResume> getCards() {
|
||||
return cards;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.github.maxopoly.tcgdex;
|
||||
package com.github.tcgdex;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -31,6 +31,11 @@ public class SetResume {
|
||||
private final int officialCardCount;
|
||||
private final int totalCardCount;
|
||||
|
||||
public SetResume(JSONObject json) {
|
||||
this(json.getString("id"), json.getString("name"), json.optString("logo"), json.optString("symbol"),
|
||||
json.getJSONObject("cardCount").getInt("total"), json.getJSONObject("cardCount").getInt("official"));
|
||||
}
|
||||
|
||||
SetResume(String id, String name, String logo, String symbol, int officialCardCount, int totalCardCount) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
@ -40,11 +45,6 @@ public class SetResume {
|
||||
this.totalCardCount = totalCardCount;
|
||||
}
|
||||
|
||||
public SetResume(JSONObject json) {
|
||||
this(json.getString("id"), json.getString("name"), json.optString("logo"), json.optString("symbol"),
|
||||
json.getJSONObject("cardCount").getInt("total"), json.getJSONObject("cardCount").getInt("official"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Set unique ID
|
||||
*/
|
||||
@ -52,13 +52,6 @@ public class SetResume {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Set name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Set logo URL, may be null
|
||||
*/
|
||||
@ -67,10 +60,10 @@ public class SetResume {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Set symbol URL, may be null
|
||||
* @return Set name
|
||||
*/
|
||||
public String getSymbol() {
|
||||
return symbol;
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,6 +73,13 @@ public class SetResume {
|
||||
return officialCardCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Set symbol URL, may be null
|
||||
*/
|
||||
public String getSymbol() {
|
||||
return symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Total amount of cards in this set
|
||||
*/
|
@ -1,4 +1,4 @@
|
||||
package com.github.maxopoly.tcgdex;
|
||||
package com.github.tcgdex;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -32,6 +32,16 @@ public class TCGDexAPI {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
private String buildURL(String path, String... optional) {
|
||||
String result = String.format(API_URL, this.language.getAPIID(), path);
|
||||
// not gonna do a string builder here, because we intend this array to be of
|
||||
// length 1 in almost all cases
|
||||
for (String opt : optional) {
|
||||
result += "/" + opt;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list containing the core information for every core
|
||||
*
|
||||
@ -44,43 +54,23 @@ public class TCGDexAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets detailed information of a card based on a sets identifier and the
|
||||
* identifier/index of a card within this set. Note that for example 'base4-1'
|
||||
* is already a combined identifier, here the correct setID would be 'base4' and
|
||||
* the cardID '1'
|
||||
* Gets a list of all known card illustrators
|
||||
*
|
||||
* @param setID Unique ID of the set
|
||||
* @param cardID ID/index describing the card within the set
|
||||
* @return Card info obtained
|
||||
* @return List of all illustrators
|
||||
* @throws IOException Thrown in response to any kind of networking error
|
||||
*/
|
||||
public CardInfo getCardInfo(String setID, String cardID) throws IOException {
|
||||
String data = Utils.doGet(buildURL("sets", setID, cardID));
|
||||
return new CardInfo(new JSONObject(data));
|
||||
public List<String> getAllIllustrators() throws IOException {
|
||||
return loadStringArrayFrom("illustrators");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets detailed information of a card based on its globally unique identifier,
|
||||
* for example 'base4-1'
|
||||
*
|
||||
* @param globalCardID Globally unique ID of the card
|
||||
* @return Card info obtained
|
||||
* @throws IOException Thrown in response to any kind of networking error
|
||||
*/
|
||||
public CardInfo getCardInfo(String globalCardID) throws IOException {
|
||||
String data = Utils.doGet(buildURL("cards", globalCardID));
|
||||
return new CardInfo(new JSONObject(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets detailed information of a card based on its resume
|
||||
*
|
||||
* @param card Card to get info for
|
||||
* @return Card info obtained
|
||||
* @throws IOException Thrown in response to any kind of networking error
|
||||
*/
|
||||
public CardInfo getCardInfo(CardResume card) throws IOException {
|
||||
return getCardInfo(card.getId());
|
||||
public List<Integer> getAllPossibleHPValues() throws IOException {
|
||||
String data = Utils.doGet(buildURL("hp"));
|
||||
JSONArray json = new JSONArray(data);
|
||||
List<Integer> result = new ArrayList<>();
|
||||
for (int i = 0; i < json.length(); i++) {
|
||||
result.add(json.getInt(i));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,15 +101,43 @@ public class TCGDexAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets detailed information of a series based on its ID
|
||||
* Gets detailed information of a card based on its resume
|
||||
*
|
||||
* @param seriesID ID of the series
|
||||
* @return Detailed information of the series
|
||||
* @param card Card to get info for
|
||||
* @return Card info obtained
|
||||
* @throws IOException Thrown in response to any kind of networking error
|
||||
*/
|
||||
public SeriesInfo getSeriesInfo(String seriesID) throws IOException {
|
||||
String data = Utils.doGet(buildURL("series", seriesID));
|
||||
return new SeriesInfo(new JSONObject(data));
|
||||
public CardInfo getCardInfo(CardResume card) throws IOException {
|
||||
return getCardInfo(card.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets detailed information of a card based on its globally unique identifier,
|
||||
* for example 'base4-1'
|
||||
*
|
||||
* @param globalCardID Globally unique ID of the card
|
||||
* @return Card info obtained
|
||||
* @throws IOException Thrown in response to any kind of networking error
|
||||
*/
|
||||
public CardInfo getCardInfo(String globalCardID) throws IOException {
|
||||
String data = Utils.doGet(buildURL("cards", globalCardID));
|
||||
return new CardInfo(new JSONObject(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets detailed information of a card based on a sets identifier and the
|
||||
* identifier/index of a card within this set. Note that for example 'base4-1'
|
||||
* is already a combined identifier, here the correct setID would be 'base4' and
|
||||
* the cardID '1'
|
||||
*
|
||||
* @param setID Unique ID of the set
|
||||
* @param cardID ID/index describing the card within the set
|
||||
* @return Card info obtained
|
||||
* @throws IOException Thrown in response to any kind of networking error
|
||||
*/
|
||||
public CardInfo getCardInfo(String setID, String cardID) throws IOException {
|
||||
String data = Utils.doGet(buildURL("sets", setID, cardID));
|
||||
return new CardInfo(new JSONObject(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,17 +153,17 @@ public class TCGDexAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets detailed information of a set based on its ID
|
||||
* Gets detailed information of a series based on its ID
|
||||
*
|
||||
* @param setID ID of the set
|
||||
* @return Detailed information of the set
|
||||
* @param seriesID ID of the series
|
||||
* @return Detailed information of the series
|
||||
* @throws IOException Thrown in response to any kind of networking error
|
||||
*/
|
||||
public SetInfo getSetInfo(String setID) throws IOException {
|
||||
String data = Utils.doGet(buildURL("sets", setID));
|
||||
return new SetInfo(new JSONObject(data));
|
||||
public SeriesInfo getSeriesInfo(String seriesID) throws IOException {
|
||||
String data = Utils.doGet(buildURL("series", seriesID));
|
||||
return new SeriesInfo(new JSONObject(data));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets detailed information of a set based on a card belonging to it
|
||||
*
|
||||
@ -159,36 +177,24 @@ public class TCGDexAPI {
|
||||
return new SetInfo(new JSONObject(data));
|
||||
}
|
||||
|
||||
List<String> loadRarities() throws IOException {
|
||||
return loadStringArrayFrom("rarities");
|
||||
/**
|
||||
* Gets detailed information of a set based on its ID
|
||||
*
|
||||
* @param setID ID of the set
|
||||
* @return Detailed information of the set
|
||||
* @throws IOException Thrown in response to any kind of networking error
|
||||
*/
|
||||
public SetInfo getSetInfo(String setID) throws IOException {
|
||||
String data = Utils.doGet(buildURL("sets", setID));
|
||||
return new SetInfo(new JSONObject(data));
|
||||
}
|
||||
|
||||
List<String> loadCategories() throws IOException {
|
||||
return loadStringArrayFrom("categories");
|
||||
}
|
||||
|
||||
List<String> loadTypes() throws IOException {
|
||||
return loadStringArrayFrom("types");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of all known card illustrators
|
||||
*
|
||||
* @return List of all illustrators
|
||||
* @throws IOException Thrown in response to any kind of networking error
|
||||
*/
|
||||
public List<String> getAllIllustrators() throws IOException {
|
||||
return loadStringArrayFrom("illustrators");
|
||||
}
|
||||
|
||||
public List<Integer> getAllPossibleHPValues() throws IOException {
|
||||
String data = Utils.doGet(buildURL("hp"));
|
||||
JSONArray json = new JSONArray(data);
|
||||
List<Integer> result = new ArrayList<>();
|
||||
for (int i = 0; i < json.length(); i++) {
|
||||
result.add(json.getInt(i));
|
||||
}
|
||||
return result;
|
||||
List<String> loadRarities() throws IOException {
|
||||
return loadStringArrayFrom("rarities");
|
||||
}
|
||||
|
||||
private List<String> loadStringArrayFrom(String path) throws IOException {
|
||||
@ -201,14 +207,8 @@ public class TCGDexAPI {
|
||||
return result;
|
||||
}
|
||||
|
||||
private String buildURL(String path, String... optional) {
|
||||
String result = String.format(API_URL, this.language.getAPIID(), path);
|
||||
// not gonna do a string builder here, because we intend this array to be of
|
||||
// length 1 in almost all cases
|
||||
for (String opt : optional) {
|
||||
result += "/" + opt;
|
||||
}
|
||||
return result;
|
||||
List<String> loadTypes() throws IOException {
|
||||
return loadStringArrayFrom("types");
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.github.maxopoly.tcgdex;
|
||||
package com.github.tcgdex;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
@ -1,4 +1,4 @@
|
||||
package com.github.maxopoly.tcgdex;
|
||||
package com.github.tcgdex;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
@ -1,4 +1,4 @@
|
||||
package com.github.maxopoly.tcgdex;
|
||||
package com.github.tcgdex;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -29,15 +29,16 @@ public class Weakness {
|
||||
private final String value;
|
||||
|
||||
|
||||
Weakness(JSONObject json) {
|
||||
this(Types.parse(json.getString("type")), json.getString("value"));
|
||||
}
|
||||
|
||||
Weakness(Types type, String value) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
Weakness(JSONObject json) {
|
||||
this(Types.parse(json.getString("type")), json.getString("value"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof Weakness)) {
|
||||
return false;
|
||||
@ -47,14 +48,6 @@ public class Weakness {
|
||||
new Object[] { other.type, other.value});
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.type, this.value);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return String.format("%s %s", this.type, this.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Type the weakness is to
|
||||
*/
|
||||
@ -69,6 +62,16 @@ public class Weakness {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.type, this.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s %s", this.type, this.value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,8 +1,19 @@
|
||||
package com.github.maxopoly.tcgdex;
|
||||
package com.github.tcgdex;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.github.maxopoly.tcgdex.TCGDexAPI.Language;
|
||||
import com.github.tcgdex.Ability;
|
||||
import com.github.tcgdex.Attack;
|
||||
import com.github.tcgdex.CardInfo;
|
||||
import com.github.tcgdex.Categories;
|
||||
import com.github.tcgdex.Rarities;
|
||||
import com.github.tcgdex.SeriesInfo;
|
||||
import com.github.tcgdex.SetInfo;
|
||||
import com.github.tcgdex.SetResume;
|
||||
import com.github.tcgdex.TCGDexAPI;
|
||||
import com.github.tcgdex.Types;
|
||||
import com.github.tcgdex.Weakness;
|
||||
import com.github.tcgdex.TCGDexAPI.Language;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
Loading…
x
Reference in New Issue
Block a user