mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
- Code base cleanup.
This commit is contained in:
@@ -686,7 +686,7 @@ public class AiController {
|
||||
// will need actual logic that determines if the enchantment is able
|
||||
// to disable the permanent or it's still functional and a duplicate is unneeded.
|
||||
boolean disabledByEnemy = false;
|
||||
for (Card card2 : (card.getEnchantedBy(false))) {
|
||||
for (Card card2 : card.getEnchantedBy(false)) {
|
||||
if (card2.getOwner() != player) {
|
||||
disabledByEnemy = true;
|
||||
}
|
||||
|
||||
@@ -853,18 +853,11 @@ public class SpecialCardAi {
|
||||
|
||||
public static class PriceOfProgress {
|
||||
public static boolean consider(final Player ai, final SpellAbility sa) {
|
||||
int ailands = 0;
|
||||
int opplands = 0;
|
||||
int ailands = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), Predicates.and(CardPredicates.Presets.LANDS, Predicates.not(CardPredicates.Presets.BASIC_LANDS))).size();
|
||||
int opplands = CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Battlefield), Predicates.and(CardPredicates.Presets.LANDS, Predicates.not(CardPredicates.Presets.BASIC_LANDS))).size();
|
||||
|
||||
boolean hasbridge = false;
|
||||
for (Card cardInPlay : ai.getGame().getCardsIn(ZoneType.Battlefield)) {
|
||||
if ((cardInPlay.isLand()) && !cardInPlay.isBasicLand()) {
|
||||
if (cardInPlay.getController().equals(ai)) {
|
||||
ailands++;
|
||||
} else {
|
||||
opplands++;
|
||||
}
|
||||
}
|
||||
|
||||
// Do we have a card in play that makes us want to empty out hand?
|
||||
if ((cardInPlay.hasSVar("PreferredHandSize")) &&
|
||||
(cardInPlay.getController().equals(ai))) {
|
||||
@@ -878,11 +871,11 @@ public class SpecialCardAi {
|
||||
// TODO : predict actual damage instead of assuming it'll be 2*lands
|
||||
// Don't if we lose, unless we lose anyway to unblocked creatures next turn
|
||||
if ((ai.getLife() <= ailands * 2) &&
|
||||
(!(ComputerUtil.aiLifeInDanger(ai, true, 0)) && ((ai.getOpponents().get(0).getLife()) <= opplands * 2))) {
|
||||
(!(ComputerUtil.aiLifeInDanger(ai, true, 0)) && ((ai.getOpponentsSmallestLifeTotal()) <= opplands * 2))) {
|
||||
return false;
|
||||
}
|
||||
// Do if we can win
|
||||
if ((ai.getOpponents().get(0).getLife()) <= opplands * 2) {
|
||||
if ((ai.getOpponentsSmallestLifeTotal()) <= opplands * 2) {
|
||||
return true;
|
||||
}
|
||||
// Do if we need to lose cards to activate Ensnaring Bridge or Cursed Scroll
|
||||
@@ -893,8 +886,7 @@ public class SpecialCardAi {
|
||||
|
||||
// Don't if we'd lose a larger percentage of our remaining life than enemy
|
||||
if ((ailands / ((double) ai.getLife())) >
|
||||
(opplands / ((double) ai.getOpponents().get(0).getLife()))
|
||||
) {
|
||||
(opplands / ((double) ai.getOpponentsSmallestLifeTotal()))) {
|
||||
return false;
|
||||
}
|
||||
// Don't if no enemy nonbasic lands
|
||||
@@ -902,9 +894,8 @@ public class SpecialCardAi {
|
||||
return false;
|
||||
}
|
||||
// Don't if loss is equal in percentage but we lose more points
|
||||
if (((ailands / ((double) ai.getLife())) ==
|
||||
(opplands / ((double) ai.getOpponents().get(0).getLife()))
|
||||
) && (ailands > opplands)) {
|
||||
if (((ailands / ((double) ai.getLife())) == (opplands / ((double) ai.getOpponentsSmallestLifeTotal())))
|
||||
&& (ailands > opplands)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -474,54 +474,54 @@ public class AttachAi extends SpellAbilityAi {
|
||||
private static Card attachAICuriosityPreference(final SpellAbility sa, final List<Card> list, final boolean mandatory,
|
||||
final Card attachSource) {
|
||||
Card chosen = null;
|
||||
int prio = 0;
|
||||
int priority = 0;
|
||||
for (Card card : list) {
|
||||
int thisprio = 0;
|
||||
int cardPriority = 0;
|
||||
// Prefer Evasion
|
||||
if (card.hasKeyword("Trample")) {
|
||||
thisprio += 10;
|
||||
cardPriority += 10;
|
||||
}
|
||||
if (card.hasKeyword("Menace")) {
|
||||
thisprio += 10;
|
||||
cardPriority += 10;
|
||||
}
|
||||
// Avoid this for Sleepers Robe?
|
||||
if (card.hasKeyword("Fear")) {
|
||||
thisprio += 15;
|
||||
cardPriority += 15;
|
||||
}
|
||||
if (card.hasKeyword("Flying")) {
|
||||
thisprio += 20;
|
||||
cardPriority += 20;
|
||||
}
|
||||
if (card.hasKeyword("Shadow")) {
|
||||
thisprio += 30;
|
||||
cardPriority += 30;
|
||||
}
|
||||
if (card.hasKeyword("Horsemanship")) {
|
||||
thisprio += 40;
|
||||
cardPriority += 40;
|
||||
}
|
||||
if (card.hasKeyword("Unblockable")) {
|
||||
thisprio += 50;
|
||||
cardPriority += 50;
|
||||
}
|
||||
// Prefer "tap to deal damage"
|
||||
// TODO : Skip this one if triggers on combat damage only?
|
||||
for (SpellAbility sa2 : card.getSpellAbilities()) {
|
||||
if ((sa2.getApi().equals(ApiType.DealDamage))
|
||||
&& (sa2.getTargetRestrictions().canTgtPlayer())) {
|
||||
thisprio += 300;
|
||||
cardPriority += 300;
|
||||
}
|
||||
}
|
||||
// Prefer stronger creatures, avoid if can't attack
|
||||
thisprio += card.getCurrentToughness() * 2;
|
||||
thisprio += card.getCurrentPower();
|
||||
cardPriority += card.getCurrentToughness() * 2;
|
||||
cardPriority += card.getCurrentPower();
|
||||
if (card.getCurrentPower() <= 0) {
|
||||
thisprio = -100;
|
||||
cardPriority = -100;
|
||||
}
|
||||
if (card.hasKeyword("Defender")) {
|
||||
thisprio = -100;
|
||||
cardPriority = -100;
|
||||
}
|
||||
if (card.hasKeyword("Indestructible")) {
|
||||
thisprio += 15;
|
||||
cardPriority += 15;
|
||||
}
|
||||
if (thisprio > prio) {
|
||||
prio = thisprio;
|
||||
if (cardPriority > priority) {
|
||||
priority = cardPriority;
|
||||
chosen = card;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,10 +218,9 @@ public class CounterAi extends SpellAbilityAi {
|
||||
// discarding no cards, or is playing a deck where discarding is a benefit
|
||||
// as defined in SpecialCardAi.NullBrooch
|
||||
if (sa.hasParam("AILogic")) {
|
||||
if ("NullBooch".equals(sa.getParam("AILogic"))) {
|
||||
if ("NullBrooch".equals(sa.getParam("AILogic"))) {
|
||||
dontCounter = false;
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
if (dontCounter) {
|
||||
|
||||
@@ -129,8 +129,8 @@ public abstract class DamageAiBase extends SpellAbilityAi {
|
||||
// have a 100% chance to go for it, enemy hand will only lose cards over time!
|
||||
// But if 3 or less cards, use normal rules, just in case enemy starts holding card or plays a draw spell or we need mana for other instants.
|
||||
if (phase.isPlayerTurn(enemy)) {
|
||||
if (dmgByCardsInHand &&
|
||||
(phase.is(PhaseType.DRAW))
|
||||
if (dmgByCardsInHand
|
||||
&& (phase.is(PhaseType.DRAW))
|
||||
&& (enemy.getCardsIn(ZoneType.Hand).size() > 3)) {
|
||||
value = 1;
|
||||
} else if (phase.is(PhaseType.END_OF_TURN)
|
||||
|
||||
Reference in New Issue
Block a user