use of com.janfic.games.computercombat.model.Card in project computercombat by janfic.
the class SQLAPI method getCardsInfo.
public List<Card> getCardsInfo(List<Integer> cardIDs, String optionalUID) {
List<Card> cards = new ArrayList<>();
try {
String sql = "SELECT * FROM card\n" + "JOIN ability ON card.ability_id = ability.id\n" + "JOIN join_components ON card.id = join_components.card\n" + "JOIN collection ON card.collection_id = collection.id ;";
Statement statement = connection.createStatement();
ResultSet set = statement.executeQuery(sql);
boolean areRowsLeft = set.next();
while (areRowsLeft) {
Card c = readCardFromSet(set, optionalUID);
if ((cardIDs == null || cardIDs.contains(c.getID())) && c.getID() != 0) {
cards.add(c);
}
areRowsLeft = set.next();
}
} catch (Exception e) {
e.printStackTrace();
return cards;
}
return cards;
}
use of com.janfic.games.computercombat.model.Card in project computercombat by janfic.
the class SQLAPI method getPlayerOwnedCards.
public Map<Card, Integer> getPlayerOwnedCards(String uid) {
System.out.println("[SERVER][MYSQL]: Querying for Player collection");
Map<Card, Integer> cards = new HashMap<>();
try {
// Get all player owned cards
String sql = "SELECT * FROM card \n" + "JOIN profile_owns_card ON card.id = profile_owns_card.card_id \n" + "JOIN profile ON profile.uid = profile_owns_card.profile_id \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 profile.uid = '" + uid + "' ORDER BY card.id;";
Statement statement = connection.createStatement();
ResultSet set = statement.executeQuery(sql);
boolean next = set.next();
while (next) {
int currentID = set.getInt("card.id");
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<>();
int id = set.getInt("card.id");
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");
int amount = set.getInt("profile_owns_card.amount");
String description = set.getString("card.description");
do {
components.add(set.getInt("components.id"));
next = set.next();
} while (next && currentID == set.getInt("card.id"));
int[] componentTypes = new int[components.size()];
for (int i = 0; i < components.size(); i++) {
componentTypes[i] = components.get(i);
}
Card s = new Card(id, uid, name, c, textureName, level, maxHealth, maxDefense, maxAttack, // magic
1, componentTypes, runRequirements, a, rarity, description);
cards.put(s, amount);
}
} catch (Exception e) {
e.printStackTrace();
}
return cards;
}
use of com.janfic.games.computercombat.model.Card in project computercombat by janfic.
the class CardToFrontAnimation method animate.
@Override
public List<List<Action>> animate(String currentPlayerUID, String playerUID, MatchScreen screen, float animationSpeed) {
List<List<Action>> animation = new ArrayList<>();
List<Action> toFrontActions = new ArrayList<>();
for (Card card : cards) {
SoftwareActor first = screen.getSoftwareActors().get(card.getOwnerUID()).get(0);
SoftwareActor actor = screen.getSoftwareActorByMatchID(card.getOwnerUID(), card.getMatchID());
screen.getSoftwareActors().get(card.getOwnerUID()).remove(actor);
screen.getSoftwareActors().get(card.getOwnerUID()).add(0, actor);
Action toFrontAction = Actions.sequence(Actions.moveTo(first.getX(), first.getY(), 1 * animationSpeed), Actions.run(() -> {
screen.buildPanels();
}));
toFrontAction.setActor(actor);
toFrontActions.add(toFrontAction);
}
animation.add(toFrontActions);
return animation;
}
use of com.janfic.games.computercombat.model.Card in project computercombat by janfic.
the class ChangeStatAnim method animate.
@Override
public List<List<Action>> animate(String currentPlayerUID, String playerUID, MatchScreen screen, float animationSpeed) {
List<List<Action>> animation = new ArrayList<>();
List<Action> actions = new ArrayList<>();
if (card instanceof Card) {
SoftwareActor softwareActor = screen.getSoftwareActorByMatchID(this.playerUID, card.getMatchID());
Action action = new ChangeStatAction(1 * animationSpeed, statChange, newAmount);
action.setActor(softwareActor);
actions.add(action);
}
animation.add(actions);
return animation;
}
use of com.janfic.games.computercombat.model.Card in project computercombat by janfic.
the class DestroyCardAnimation method animate.
@Override
public List<List<Action>> animate(String currentPlayerUID, String playerUID, MatchScreen screen, float animationSpeed) {
List<List<Action>> animation = new ArrayList<>();
List<Action> actions = new ArrayList<>();
for (Card card : destroyed) {
SoftwareActor actor = screen.getSoftwareActorByMatchID(this.playerUID, card.getMatchID());
Action action = Actions.sequence(Actions.fadeOut(1 * animationSpeed), Actions.removeActor(), Actions.run(new Runnable() {
@Override
public void run() {
screen.getSoftwareActors().get(DestroyCardAnimation.this.playerUID).remove(actor);
screen.buildPanels();
}
}));
action.setActor(actor);
actions.add(action);
}
animation.add(actions);
return animation;
}
Aggregations