use of cardgame1.Sticker 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);
}
use of cardgame1.Sticker in project cardgame1 by joey101937.
the class ArcherCard method cast.
@Override
public int cast(Minion target) {
int outcome = defaultMinionSummon();
if (outcome == 1) {
Sticker s = new Sticker(SpriteHandler.slashEffect, target, AI.AI.speed / 3);
Main.wait(AI.AI.speed / 3);
target.takeDamage(summonDamage);
}
return outcome;
}
use of cardgame1.Sticker in project cardgame1 by joey101937.
the class ArcherCard method castOnHero.
@Override
public int castOnHero(Hero target) {
int outcome = defaultMinionSummon();
if (outcome == 1) {
Sticker s = new Sticker(SpriteHandler.slashEffect, target, AI.AI.speed / 3);
Main.wait(AI.AI.speed / 3);
target.takeDamage(summonDamage);
}
return outcome;
}
use of cardgame1.Sticker in project cardgame1 by joey101937.
the class FireBoltCard method cast.
/**
* deals damage to target minion.
* @param target
* @return 1 if success, 0 if too expensive, -1 if null param
*/
@Override
public int cast(Minion 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;
}
use of cardgame1.Sticker 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;
}
Aggregations