Search in sources :

Example 6 with Hero

use of cardgame1.Hero in project cardgame1 by joey101937.

the class FireBoltCard method castOnHero.

/**
 * deals damage to target hero
 * @param target
 * @return 1 if success, 0 if too expensive, -1 if null param
 */
@Override
public int castOnHero(Hero target) {
    if (target == null)
        return -1;
    // reutrn 0 if unaffordable
    if (!canAfford())
        return 0;
    Sticker impactEffect = new Sticker(SpriteHandler.blastEffectSmall, target, AI.AI.speed / 3);
    Main.wait(AI.AI.speed / 3);
    target.takeDamage(spellDamage);
    owner.resource -= cost;
    owner.hand.remove(this);
    TrapListener.onPlay(this);
    return 1;
}
Also used : Sticker(cardgame1.Sticker)

Example 7 with Hero

use of cardgame1.Hero in project cardgame1 by joey101937.

the class AI method tradeOnBoard.

/**
 * makes favorable trades on the board until there are no more favorable trades
 * @param should we wait between making plays so the player can see whats going on?
 * @param h
 */
private static void tradeOnBoard(Hero h, boolean instant) {
    int damagePotential = 0;
    Hero enemy;
    if (h == Board.topHero)
        enemy = Board.botHero;
    else
        enemy = Board.topHero;
    for (Minion m : h.minions.getStorage()) {
        if (m == null || !m.canAttack())
            continue;
        damagePotential += m.attack;
    }
    if (damagePotential >= enemy.health) {
        for (Minion m : h.minions.getStorage()) {
            if (m == null)
                continue;
            if (!instant)
                Main.wait(speed);
            m.attack(enemy);
        }
    }
    boolean doneTrading = false;
    while (!doneTrading) {
        doneTrading = true;
        for (Minion m : h.minions.getStorage()) {
            if (m == null)
                continue;
            if (AI.canFavorablyTrade(m) && m.canAttack() && m.attack > 0) {
                if (!instant)
                    Main.wait(speed);
                m.attack(AI.getBestTarget(m));
                doneTrading = false;
            }
        }
    }
    if (h == Board.topHero) {
        if (Board.botHero.minions.numOccupants() == 0) {
            for (Minion m : h.minions.getStorage()) {
                if (m == null || !m.canAttack())
                    continue;
                if (!instant)
                    Main.wait(speed);
                m.attack(Board.botHero);
            }
        }
    } else {
        // we are playing as bothero
        if (Board.topHero.minions.numOccupants() == 0) {
            for (Minion m : h.minions.getStorage()) {
                if (m == null || !m.canAttack())
                    continue;
                if (!instant)
                    Main.wait(speed);
                m.attack(Board.topHero);
            }
        }
    }
}
Also used : Minion(Minions.Minion) Hero(cardgame1.Hero)

Example 8 with Hero

use of cardgame1.Hero in project cardgame1 by joey101937.

the class LegacyGUI method playButtonActionPerformed.

// GEN-LAST:event_button720ActionPerformed
private void playButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_playButtonActionPerformed
    if (this.yourDeckCombo.getSelectedItem().equals(useCustomText)) {
        if (this.loadedCustomDeckPlayer == null)
            return;
    }
    if (this.AIDeckCombo.getSelectedItem().equals(useCustomText)) {
        if (this.loadedCustomDeckAI == null)
            return;
    }
    System.out.println("test for commit");
    this.assignDecks();
    int x = 0, y = 0;
    try {
        x = Integer.parseInt(this.resX.getText());
        y = Integer.parseInt(this.resY.getText());
    } catch (NumberFormatException nfe) {
        Main.display("Invalid dimensions. Must be numeric.");
        return;
    } catch (Exception e) {
        e.printStackTrace();
    }
    Hero enemy = new Hero("AI Hero", AIDeck, enemyHeroPortrait);
    enemy.setAIControlled(true);
    Hero player = new Hero("Player Hero", PlayerDeck, SpriteHandler.ashePortrait);
    if (x < 480 || y < 480) {
        Main.display("Warning, window too small");
        return;
    }
    if (x > 2560 || y > 2560) {
        Main.display("Warning, window too big");
        return;
    }
    Board b = new Board(enemy, player, new Dimension(x, y));
    this.dispose();
}
Also used : Board(cardgame1.Board) Hero(cardgame1.Hero) Dimension(java.awt.Dimension)

Example 9 with Hero

use of cardgame1.Hero in project cardgame1 by joey101937.

the class AI method takeTurn.

/**
 * core of the AI player, makes plays and casts cards the most efficient way possible and ends turn when done
 * @param h the AI will make plays on behalf on this hero
 */
public static void takeTurn(Hero h) {
    Hero enemy = null;
    if (h == Board.topHero)
        enemy = Board.botHero;
    else
        enemy = Board.topHero;
    tradeOnBoard(h, false);
    playOutHand(h);
    Main.wait(speed);
    tradeOnBoard(h, false);
    for (Minion m : h.minions.getStorage()) {
        if (!AI.isHeroVulnerable(h)) {
            if (m == null)
                continue;
            Main.wait(speed);
            m.attack(enemy);
        } else {
            if (m == null)
                continue;
            Main.wait(speed);
            // if we are vulnerable, attack on board as best as possible
            m.attack(AI.getBestTarget(m));
        }
    }
    Main.wait(speed);
    Board.controller.nextTurn();
/*
        for(Card c : h.hand){
            System.out.println(c + " == " + AI.getValueOfCard(c));
        }
        */
}
Also used : Minion(Minions.Minion) Hero(cardgame1.Hero)

Example 10 with Hero

use of cardgame1.Hero in project cardgame1 by joey101937.

the class PredationCard method castOnHero.

@Override
public int castOnHero(Hero target) {
    if (target == null || spellDamage < 1)
        return -1;
    // reutrn 0 if unaffordable
    if (!canAfford())
        return 0;
    target.takeDamage(spellDamage);
    Sticker impactEffect = new Sticker(SpriteHandler.bloodMedium, target, 300);
    owner.resource -= cost;
    owner.hand.remove(this);
    TrapListener.onPlay(this);
    return 1;
}
Also used : Sticker(cardgame1.Sticker)

Aggregations

Hero (cardgame1.Hero)6 Minion (Minions.Minion)5 Sticker (cardgame1.Sticker)4 Card (Cards.Card)1 Trap (Cards.CardPurpose.Trap)1 Trap (Traps.Trap)1 Board (cardgame1.Board)1 Dimension (java.awt.Dimension)1 ArrayList (java.util.ArrayList)1