Now AI would try to get removal spells (getting additional points for them).

This commit is contained in:
magenoxx 2011-08-18 11:07:21 +04:00
parent e7be3591d4
commit 02e09831ad
3 changed files with 46 additions and 4 deletions

View file

@ -1,7 +1,16 @@
package mage.player.ai.utils;
import mage.Constants;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.Card;
import mage.target.Target;
import mage.target.common.TargetCreatureOrPlayer;
import mage.target.common.TargetCreatureOrPlayerAmount;
import mage.target.common.TargetCreaturePermanent;
import org.apache.log4j.Logger;
import sun.rmi.runtime.Log;
import java.io.InputStream;
import java.util.*;
@ -23,6 +32,8 @@ public class RateCard {
*/
private static final int DEFAULT_NOT_RATED_CARD_RATING = 4;
private static final Logger log = Logger.getLogger(RateCard.class);
/**
* Hide constructor.
*/
@ -49,10 +60,40 @@ public class RateCard {
} else {
type = 6;
}
int score = 10 * getCardRating(card) + type + getManaCostScore(card, allowedColors);
int score = 10 * getCardRating(card) + 2 * type + getManaCostScore(card, allowedColors)
+ 40 * isRemoval(card);
return score;
}
private static int isRemoval(Card card) {
if (card.getSubtype().contains("Aura") || card.getCardType().contains(Constants.CardType.INSTANT)
|| card.getCardType().contains(Constants.CardType.SORCERY)) {
for (Ability ability : card.getAbilities()) {
for (Effect effect : ability.getEffects()) {
if (effect.getOutcome().equals(Constants.Outcome.Removal)) {
log.info("Found removal: " + card.getName());
return 1;
}
if (effect.getOutcome().equals(Constants.Outcome.Damage)) {
if (effect instanceof DamageTargetEffect) {
DamageTargetEffect damageEffect = (DamageTargetEffect) effect;
if (damageEffect.getAmount() > 1) {
for (Target target : ability.getTargets()) {
if (target instanceof TargetCreaturePermanent || target instanceof TargetCreatureOrPlayer) {
log.info("Found damage dealer: " + card.getName());
return 1;
}
}
}
}
}
}
}
}
return 0;
}
/**
* Return rating of the card.
*
@ -139,7 +180,7 @@ public class RateCard {
}
}
if (count == 0) {
return -30;
return -100;
}
Integer typeCount = singleCount.get(symbol);
if (typeCount == null) {

View file

@ -59,7 +59,7 @@ public class Pacifism extends CardImpl<Pacifism> {
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment));
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Removal));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PacifismEffect()));

View file

@ -328,7 +328,8 @@ public final class Constants {
Copy(true),
Benefit(true),
Detriment(false),
Neutral(true);
Neutral(true),
Removal(true);
private boolean good;