use of Minions.Minion in project cardgame1 by joey101937.
the class AI method isHeroVulnerable.
/**
* returns true if the given hero would be killed by an attack from each of the opponents minions
* @param h hero to evaluate
* @return result
*/
public static boolean isHeroVulnerable(Hero h) {
Hero enemy = null;
if (h == Board.topHero) {
enemy = Board.botHero;
} else {
enemy = Board.topHero;
}
int damagePotential = 0;
for (Minion m : enemy.minions.getStorage()) {
if (m == null)
continue;
damagePotential += m.attack;
}
return damagePotential >= h.health;
}
use of Minions.Minion in project cardgame1 by joey101937.
the class MockBattlefield method getBestTarget.
// AI METHODS
/**
* returns the best minoin target for the given minion
* sometimes there is no good trade, and this method will return the "least bad" trade.
* @param attacker minion that will be attacking
* @return Best target
*/
public Minion getBestTarget(Minion attacker) {
int bestValue = -99999999;
Minion bestTarget = null;
if (friendlies.contains(attacker)) {
// is a friendly minion
for (Minion target : enemies) {
int value = AI.getTradeValue(attacker, target);
if (value > bestValue) {
bestValue = value;
bestTarget = target;
}
}
return bestTarget;
} else if (enemies.contains(attacker)) {
// is an enemy minion
for (Minion target : friendlies) {
int value = AI.getTradeValue(attacker, target);
if (value > bestValue) {
bestValue = value;
bestTarget = target;
}
}
return bestTarget;
}
System.out.println("error finding best target for " + attacker);
return null;
}
use of Minions.Minion in project cardgame1 by joey101937.
the class FireSpearCard method tick.
@Override
public void tick() {
intrinsicValue = -4;
int potential = 0;
for (Minion m : owner.opponent.minions.getOccupants()) {
if (m.attack >= 5 && AI.AI.getWorth(m) > potential) {
potential = AI.AI.getWorth(m);
}
}
intrinsicValue += potential;
}
use of Minions.Minion in project cardgame1 by joey101937.
the class ZombieBiteSpell method smartCast.
/**
* plays the card the best way possible
*/
@Override
public void smartCast() {
int valueOnEnemy = 0;
Minion bestTargetEnemy = null;
for (Minion m : owner.opponent.minions.getOccupants()) {
if (m.attack + m.health > (attack + health)) {
int potentialValue = m.attack + m.health - (attack + health);
if (potentialValue > valueOnEnemy) {
valueOnEnemy = potentialValue;
bestTargetEnemy = m;
}
}
}
if (valueOnEnemy > 1 && AI.isVulnerable(new SimulatedMinion(attack, health, owner.opponent))) {
valueOnEnemy += 2;
}
int valueOnSelf = 0;
Minion bestTargetSelf = null;
for (Minion m : owner.minions.getOccupants()) {
if (m.attack + m.health < (attack + health)) {
int potentialValue = (attack + health) - m.attack - m.health;
if ((!AI.canFavorablyTrade(m) || !m.canAttack()) && AI.canFavorablyTrade(new SimulatedMinion(4, 2, owner))) {
potentialValue = AI.getWorth(AI.getBestTarget(new SimulatedMinion(4, 2, owner)));
}
if (potentialValue > valueOnSelf) {
valueOnSelf = potentialValue;
bestTargetSelf = m;
}
}
}
if (valueOnEnemy > valueOnSelf) {
// better to cast on an enemy
this.cast(bestTargetEnemy);
return;
} else {
// better to cast on self
this.cast(bestTargetSelf);
return;
}
}
use of Minions.Minion in project cardgame1 by joey101937.
the class ZombieBiteSpell method tick.
/**
* constantly updates value of the card for AI
*/
@Override
public void tick() {
if (owner.minions.numOccupants() == 0 && owner.opponent.minions.numOccupants() == 0) {
intrinsicValue = -2;
return;
}
intrinsicValue = -2;
int valueOnEnemy = 0;
Minion bestTargetEnemy = null;
for (Minion m : owner.opponent.minions.getOccupants()) {
if (m.attack + m.health > (attack + health)) {
int potentialValue = m.attack + m.health - (attack + health);
if (potentialValue > valueOnEnemy) {
valueOnEnemy = potentialValue;
bestTargetEnemy = m;
}
}
}
if (valueOnEnemy > 1 && AI.isVulnerable(new SimulatedMinion(attack, health, owner.opponent))) {
valueOnEnemy += 2;
}
int valueOnSelf = 0;
Minion bestTargetSelf = null;
for (Minion m : owner.minions.getOccupants()) {
if (m.attack + m.health < (attack + health)) {
int potentialValue = (attack + health) - m.attack - m.health;
if (AI.isVulnerable(m) && !AI.isVulnerable(new SimulatedMinion(attack, health, owner))) {
potentialValue = AI.getWorth(m);
}
if (potentialValue > valueOnSelf) {
valueOnSelf = potentialValue;
bestTargetSelf = m;
}
}
}
if (valueOnEnemy > valueOnSelf) {
intrinsicValue += valueOnEnemy;
} else {
intrinsicValue += valueOnSelf;
}
}
Aggregations