use of com.janfic.games.computercombat.model.Collection in project computercombat by janfic.
the class SQLAPI method readCardFromSet.
private Card readCardFromSet(ResultSet set, String uid) {
try {
Ability a = (Ability) shell.evaluate(set.getString("ability.code"));
a.setInformation(set.getString("ability.description"), set.getString("ability.textureName"), set.getString("ability.name"), set.getString("ability.code"), set.getInt("ability.id"));
Collection collection = new Collection(set.getInt("collection.id"), set.getString("collection.name"), set.getString("collection.description"), set.getString("collection.textureName"), set.getString("collection.path"), set.getInt("collection.price"));
String name = set.getString("card.name");
String textureName = set.getString("card.textureName");
int level = set.getInt("card.level");
int id = set.getInt("card.id");
int maxHealth = set.getInt("card.maxHealth");
int maxDefense = set.getInt("card.maxDefense");
int maxAttack = set.getInt("card.maxAttack");
int runRequirements = set.getInt("card.runRequirements");
int rarity = set.getInt("card.rarity");
String description = set.getString("card.description");
String components = set.getString("components");
String[] c = components.split(",");
int[] componentTypes = new int[c.length];
for (int i = 0; i < c.length; i++) {
componentTypes[i] = Integer.parseInt(c[i]);
}
Card s = new Card(id, uid, name, collection, textureName, level, maxHealth, maxDefense, maxAttack, 1, componentTypes, runRequirements, a, rarity, description);
return s;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
use of com.janfic.games.computercombat.model.Collection in project computercombat by janfic.
the class SQLAPI method getCardById.
public Card getCardById(int id, String optionalUID) {
System.out.println("[SERVER][MYSQL]: Querying for Card Data");
try {
String sql = "SELECT * FROM card \n" + "JOIN ability ON card.ability_id = ability.id\n" + "JOIN run_requirements ON card.id = run_requirements.card_id\n" + "JOIN components ON components.id = run_requirements.component_id\n" + "JOIN collection ON card.collection_id = collection.id\n" + "WHERE card.id = '" + id + "';";
Statement statement = connection.createStatement();
ResultSet set = statement.executeQuery(sql);
set.next();
Ability a = (Ability) shell.evaluate(set.getString("ability.code"));
a.setInformation(set.getString("ability.description"), set.getString("ability.textureName"), set.getString("ability.name"), set.getString("ability.code"), set.getInt("ability.id"));
Collection c = new Collection(set.getInt("collection.id"), set.getString("collection.name"), set.getString("collection.description"), set.getString("collection.textureName"), set.getString("collection.path"), set.getInt("collection.price"));
List<Integer> components = new ArrayList<>();
String name = set.getString("card.name");
String textureName = set.getString("card.textureName");
int level = set.getInt("card.level");
int maxHealth = set.getInt("card.maxHealth");
int maxDefense = set.getInt("card.maxDefense");
int maxAttack = set.getInt("card.maxAttack");
int runRequirements = set.getInt("card.runRequirements");
int rarity = set.getInt("card.rarity");
String description = set.getString("card.description");
do {
components.add(set.getInt("components.id"));
} while (set.next());
int[] componentTypes = new int[components.size()];
for (int i = 0; i < components.size(); i++) {
componentTypes[i] = components.get(i);
}
Card s = new Card(id, optionalUID, name, c, textureName, level, maxHealth, maxDefense, maxAttack, 1, componentTypes, runRequirements, a, rarity, description);
return s;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
Aggregations