Search in sources :

Example 1 with Card

use of Cards.Card in project cardgame1 by joey101937.

the class InputHandler method mouseClicked.

@Override
public void mouseClicked(MouseEvent e) {
    double x = e.getX() / Board.xScale;
    double y = e.getY() / Board.yScale;
    System.out.println(e.getX() / Board.xScale + ", " + e.getY() / Board.yScale);
    // if its not our turn, ignore it
    if (!Board.playerHero.turn || !enabled)
        return;
    Card clickedCard = InputHandler.getCardAt(e.getX() / Board.xScale, e.getY() / Board.yScale);
    if (clickedCard != null && clickedCard.isTargeted == false) {
        // cast with null param becuase there is no target
        clickedCard.cast(null);
    }
    if (x < 35 && y < 35) {
        // options gear is in top left, 0,0 and is 35x35
        LegacyGUI.settings = new SettingsPane();
    }
    if (x > 400 + Board.playerHero.picture.getWidth() && x < 400 + Board.playerHero.picture.getWidth() + SpriteHandler.leftArrow.getWidth()) {
        if (Board.playerHero == Board.botHero) {
            if (y > 850 && y < 850 + SpriteHandler.leftArrow.getHeight()) {
                onEndTurn();
            }
        } else {
            // player is tophero
            if (y < SpriteHandler.leftArrow.getHeight()) {
                onEndTurn();
            }
        }
    }
}
Also used : SettingsPane(GUI.SettingsPane) Card(Cards.Card)

Example 2 with Card

use of Cards.Card in project cardgame1 by joey101937.

the class VisualEffectHandler method drawLineC.

/**
 * draws a line from the selected card to the location of the mouse
 * @param g
 */
public void drawLineC(Graphics2D g) {
    Card selected = InputHandler.selectedCard;
    if (selected == null)
        return;
    // return if card is untargeted or too expensive
    if (!selected.isTargeted || !selected.canAfford())
        return;
    g.setColor(Color.yellow);
    g.drawLine(selected.getXCoordinate() + Card.WIDTH / 2, selected.getYCoordinate() + Card.HEIGHT / 2, Board.mouseX, Board.mouseY);
}
Also used : Card(Cards.Card)

Example 3 with Card

use of Cards.Card in project cardgame1 by joey101937.

the class SeaWitchMinion method onSummon.

@Override
public void onSummon() {
    ArrayList<Card> options = new ArrayList<>();
    // possible draw options
    options.add(new FrenzyCard());
    options.add(new PredationCard());
    options.add(new SwollowCard());
    options.add(new SeaSerpentTrapCard());
    options.add(new ThrasherCard());
    options.add(new JellyfishCard());
    options.add(new CarnifishCard());
    options.add(new BaitfishCard());
    options.add(new SeaWitchCard());
    options.add(new KelpieCard());
    options.add(new PirranahCard());
    // 
    this.proc();
    Main.wait(AI.AI.speed / 3);
    owner.draw(options.get((int) (Math.random() * options.size())));
}
Also used : ArrayList(java.util.ArrayList) KelpieCard(Cards.Base.KelpieCard) Card(Cards.Card) KelpieCard(Cards.Base.KelpieCard)

Example 4 with Card

use of Cards.Card in project cardgame1 by joey101937.

the class AI method getWorth.

/**
 * calculates the worth of a minion for purposes of making plays
 * @param m minion to evaluate
 * @return how much a minion is worth, higher is better
 */
public static int getWorth(Minion m) {
    int sumStats = m.health + m.attack;
    sumStats += m.intrinsicValue;
    // low attack is slightly worse than high atk
    if (m.attack < m.health)
        sumStats--;
    if (m.health <= 0) {
        // worthless if dead
        return 0;
    }
    if (m.owner.minions.isFull()) {
        for (Minion min : m.owner.minions.getStorage()) {
            if (m == null)
                continue;
            if (sumStats > min.attack + min.health) {
                return sumStats;
            }
        }
        // this is the smallest minion on a full field
        for (Card c : m.owner.hand) {
            if (c.canAfford() && c.cardType == CardType.Minion && (c.summon.attack + c.summon.health + c.intrinsicValue) > sumStats) {
                // the minion is taking a slot that a largert minion should have
                return 0;
            }
        }
    }
    return sumStats;
}
Also used : Minion(Minions.Minion) Card(Cards.Card)

Example 5 with Card

use of Cards.Card in project cardgame1 by joey101937.

the class AI method playOutHand.

/**
 * plays all cards we can in the best way possible, recursively
 */
public static void playOutHand(Hero h) {
    Board.getMainBoard().tick();
    boolean playOver = true;
    for (Card c : h.hand) {
        // there is something we want to play
        if (c.canAfford() && AI.getValueOfCard(c) > 0)
            playOver = false;
    }
    if (playOver)
        return;
    ArrayList<Card> playable = new ArrayList<>();
    for (Card c : h.hand) {
        if (c.canAfford() && getValueOfCard(c) > 0)
            playable.add(c);
    }
    // orders the cards using their comparable interface, ordering based on value rather than worth (value accounts for cost, worth does not)
    playable.sort(null);
    if (playable.get(playable.size() - 1).cardPurpose == CardPurpose.Trap) {
        // let user know we are playing a trap card
        Sticker s = new Sticker(SpriteHandler.trapPlaceholder, 1700, 200, speed * 3);
    } else {
        // let user know what non-trap card we are playing
        Sticker s = new Sticker(playable.get(playable.size() - 1), 1700, 200, speed * 3);
    }
    Main.wait(speed * 3);
    System.out.println("attempting to play: " + playable.get(playable.size() - 1));
    AI.playCard(playable.get(playable.size() - 1));
    playOutHand(h);
}
Also used : Sticker(cardgame1.Sticker) ArrayList(java.util.ArrayList) Card(Cards.Card)

Aggregations

Card (Cards.Card)12 ArrayList (java.util.ArrayList)3 ImageIcon (javax.swing.ImageIcon)3 JLabel (javax.swing.JLabel)3 File (java.io.File)2 IOException (java.io.IOException)2 KelpieCard (Cards.Base.KelpieCard)1 CorruptFileException (CustomDecks.CorruptFileException)1 CustomDeck (CustomDecks.CustomDeck)1 SettingsPane (GUI.SettingsPane)1 Minion (Minions.Minion)1 TrapCard (Traps.TrapCard)1 Sticker (cardgame1.Sticker)1 Dimension (java.awt.Dimension)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 MouseEvent (java.awt.event.MouseEvent)1 MouseListener (java.awt.event.MouseListener)1 BufferedWriter (java.io.BufferedWriter)1 FileNotFoundException (java.io.FileNotFoundException)1