Search in sources :

Example 1 with BlackCard

use of com.gianlu.pyxreborn.Models.BlackCard in project PretendYoureXyzzyReborn by devgianlu.

the class CardsDB method loadBlackCards.

/**
 * Loads all the black cards.
 */
private Map<Integer, BlackCard> loadBlackCards(Statement statement) throws SQLException {
    Map<Integer, BlackCard> blackCards = new HashMap<>();
    try (ResultSet result = statement.executeQuery("SELECT * FROM black_cards")) {
        while (result.next()) {
            BlackCard card = new BlackCard(result.getInt("id"), result.getString("text"), result.getString("watermark"), result.getInt("draw"), result.getInt("pick"));
            blackCards.put(card.id, card);
        }
    }
    return blackCards;
}
Also used : HashMap(java.util.HashMap) BlackCard(com.gianlu.pyxreborn.Models.BlackCard)

Example 2 with BlackCard

use of com.gianlu.pyxreborn.Models.BlackCard in project PretendYoureXyzzyReborn by devgianlu.

the class PyxCard method initialize.

@FXML
public void initialize() {
    this.text.setText(card.text);
    this.watermark.setText(card.watermark);
    if (card instanceof BlackCard) {
        // Black card
        setBackground(new Background(new BackgroundFill(Color.BLACK, new CornerRadii(8), Insets.EMPTY)));
        this.text.setTextFill(Color.WHITE);
        this.watermark.setTextFill(Color.WHITE);
    } else {
        // White card
        setBackground(new Background(new BackgroundFill(Color.WHITE, new CornerRadii(8), Insets.EMPTY)));
        this.text.setTextFill(Color.BLACK);
        this.watermark.setTextFill(Color.BLACK);
    }
}
Also used : Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) BlackCard(com.gianlu.pyxreborn.Models.BlackCard) CornerRadii(javafx.scene.layout.CornerRadii) FXML(javafx.fxml.FXML)

Example 3 with BlackCard

use of com.gianlu.pyxreborn.Models.BlackCard in project PretendYoureXyzzyReborn by devgianlu.

the class CardsDB method loadCardSets.

/**
 * Loads all the card sets in the database.
 */
public CardSets loadCardSets() throws SQLException {
    CardSets sets = new CardSets();
    try (Statement statement = db.createStatement()) {
        try (ResultSet result = statement.executeQuery("SELECT * FROM card_set")) {
            while (result.next()) {
                sets.add(new CardSet(result.getInt("id"), result.getInt("active") == 1, result.getString("name"), result.getInt("base_deck") == 1, result.getString("description"), result.getInt("weight")));
            }
        }
        Map<Integer, WhiteCard> whiteCards = loadWhiteCards(statement);
        for (CardSet set : sets) {
            try (ResultSet result = statement.executeQuery("SELECT white_card_id FROM card_set_white_card WHERE card_set_id=" + set.id)) {
                while (result.next()) {
                    set.whiteCards.add(whiteCards.get(result.getInt("white_card_id")));
                }
            }
        }
        Map<Integer, BlackCard> blackCards = loadBlackCards(statement);
        for (CardSet set : sets) {
            try (ResultSet result = statement.executeQuery("SELECT black_card_id FROM card_set_black_card WHERE card_set_id=" + set.id)) {
                while (result.next()) {
                    set.blackCards.add(blackCards.get(result.getInt("black_card_id")));
                }
            }
        }
    }
    sets.sort(new CardSets.WeightComparator());
    return sets;
}
Also used : WhiteCard(com.gianlu.pyxreborn.Models.WhiteCard) BlackCard(com.gianlu.pyxreborn.Models.BlackCard) CardSets(com.gianlu.pyxreborn.server.Lists.CardSets) CardSet(com.gianlu.pyxreborn.Models.CardSet)

Aggregations

BlackCard (com.gianlu.pyxreborn.Models.BlackCard)3 CardSet (com.gianlu.pyxreborn.Models.CardSet)1 WhiteCard (com.gianlu.pyxreborn.Models.WhiteCard)1 CardSets (com.gianlu.pyxreborn.server.Lists.CardSets)1 HashMap (java.util.HashMap)1 FXML (javafx.fxml.FXML)1 Background (javafx.scene.layout.Background)1 BackgroundFill (javafx.scene.layout.BackgroundFill)1 CornerRadii (javafx.scene.layout.CornerRadii)1