Search in sources :

Example 16 with Minion

use of Minions.Minion in project cardgame1 by joey101937.

the class VolcanoCard method cast.

/**
 * deals damage to target minion.
 * @param target
 * @return 1 if success, 0 if too expensive, -1 if opponent has no minions
 */
@Override
public int cast(Minion t) {
    if (owner.opponent.minions.numOccupants() == 0)
        return -1;
    // reutrn 0 if unaffordable
    if (!canAfford())
        return 0;
    for (Minion target : owner.opponent.minions.getOccupants()) {
        Sticker impactEffect = new Sticker(SpriteHandler.blastEffectSmall, target, AI.AI.speed / 3);
    }
    // first put the fire sticker on all targets, then apply damage. easier to follow this way.
    Main.wait(AI.AI.speed / 3);
    for (Minion target : owner.opponent.minions.getOccupants()) {
        target.takeDamage(spellDamage);
    }
    owner.resource -= cost;
    owner.hand.remove(this);
    TrapListener.onPlay(this);
    return 1;
}
Also used : Sticker(cardgame1.Sticker) Minion(Minions.Minion)

Example 17 with Minion

use of Minions.Minion in project cardgame1 by joey101937.

the class FrostDragonMinion method onSummon.

@Override
public void onSummon() {
    Sticker s = new Sticker(SpriteHandler.snowflakeLarge, this.getXCordinate() + Minion.WIDTH / 2, this.getYcoordinate() + Minion.HEIGHT / 2, AI.AI.speed);
    Main.wait(AI.AI.speed);
    for (Minion m : owner.opponent.minions.getOccupants()) {
        m.freeze();
    }
}
Also used : Sticker(cardgame1.Sticker) Minion(Minions.Minion)

Example 18 with Minion

use of Minions.Minion in project cardgame1 by joey101937.

the class PirranahMinion method onTurnEnd.

@Override
public void onTurnEnd() {
    if (isSilenced)
        return;
    if (isFrozen || owner.opponent.minions.numOccupants() == 0) {
        // do not attack if frozen
        isFrozen = false;
        return;
    }
    Sticker s = new Sticker(SpriteHandler.bloodMedium, this, AI.AI.speed / 2);
    Main.wait(AI.AI.speed / 2);
    int roll = (int) (Math.random() * (owner.opponent.minions.numOccupants()));
    Minion target = owner.opponent.minions.getOccupants().get(roll);
    this.refresh();
    this.attack(target);
    Main.wait(AI.AI.speed / 2);
}
Also used : Sticker(cardgame1.Sticker) Minion(Minions.Minion)

Example 19 with Minion

use of Minions.Minion in project cardgame1 by joey101937.

the class BaitfishMinion method onDeath.

@Override
public void onDeath() {
    Sticker s = new Sticker(SpriteHandler.skullMedium, this, 600);
    if (isSilenced)
        return;
    ArrayList<Minion> targets = new ArrayList<>();
    for (Minion m : owner.minions.getOccupants()) {
        if (m.tribe == Tribe.Fish && m != this)
            targets.add(m);
    }
    if (targets.isEmpty()) {
        System.out.println("no targets for baitfish death effect");
        owner.draw(new BaitfishCard());
        return;
    }
    Minion target = targets.get(Main.generateRandom(0, targets.size()));
    target.attack += 1;
    target.health += 1;
    target.proc();
    owner.draw(new BaitfishCard());
}
Also used : Sticker(cardgame1.Sticker) BaitfishCard(Cards.Fish.BaitfishCard) Minion(Minions.Minion) ArrayList(java.util.ArrayList)

Example 20 with Minion

use of Minions.Minion 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)

Aggregations

Minion (Minions.Minion)28 Sticker (cardgame1.Sticker)7 Hero (cardgame1.Hero)5 ArrayList (java.util.ArrayList)3 ConcurrentModificationException (java.util.ConcurrentModificationException)2 SimulatedMinion (AI.SimulatedMinion)1 Card (Cards.Card)1 Trap (Cards.CardPurpose.Trap)1 BaitfishCard (Cards.Fish.BaitfishCard)1 SkeletonMinion (Minions.Undead.SkeletonMinion)1 Trap (Traps.Trap)1