mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Card: add IsEquippedBy like isEnchantedBy from GameEntity
CardPredicates: use isEquippedBy and isEnchantedBy for Predicate<Card>
This commit is contained in:
@@ -473,12 +473,8 @@ public class ComputerUtilCombat {
|
||||
public static int totalDamageOfBlockers(final Card attacker, final List<Card> defenders) {
|
||||
int damage = 0;
|
||||
|
||||
if (attacker.isEquipped()) {
|
||||
for (Card equipment : attacker.getEquippedBy(false)) {
|
||||
if (equipment.getName().equals("Godsend") && !defenders.isEmpty()) {
|
||||
defenders.remove(0);
|
||||
}
|
||||
}
|
||||
if (attacker.isEquippedBy("Godsend") && !defenders.isEmpty()) {
|
||||
defenders.remove(0);
|
||||
}
|
||||
|
||||
for (final Card defender : defenders) {
|
||||
@@ -495,10 +491,8 @@ public class ComputerUtilCombat {
|
||||
public static int totalFirstStrikeDamageOfBlockers(final Card attacker, final List<Card> defenders) {
|
||||
int damage = 0;
|
||||
|
||||
for (Card equipment : attacker.getEquippedBy(false)) {
|
||||
if (equipment.getName().equals("Godsend") && !defenders.isEmpty()) {
|
||||
defenders.remove(0);
|
||||
}
|
||||
if (attacker.isEquippedBy("Godsend") && !defenders.isEmpty()) {
|
||||
defenders.remove(0);
|
||||
}
|
||||
|
||||
for (final Card defender : defenders) {
|
||||
@@ -1527,12 +1521,8 @@ public class ComputerUtilCombat {
|
||||
// check whether the attacker will be destroyed by triggered abilities before First Strike damage
|
||||
public static boolean canDestroyAttackerBeforeFirstStrike(final Card attacker, final Card blocker, final Combat combat,
|
||||
final boolean withoutAbilities) {
|
||||
if (blocker.isEquipped()) {
|
||||
for (Card equipment : blocker.getEquippedBy(false)) {
|
||||
if (equipment.getName().equals("Godsend")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (blocker.isEquippedBy("Godsend")) {
|
||||
return true;
|
||||
}
|
||||
if (attacker.hasKeyword("Indestructible") || ComputerUtil.canRegenerate(attacker.getController(), attacker)) {
|
||||
return false;
|
||||
@@ -1747,12 +1737,8 @@ public class ComputerUtilCombat {
|
||||
|
||||
public static boolean canDestroyBlockerBeforeFirstStrike(final Card blocker, final Card attacker, final boolean withoutAbilities) {
|
||||
|
||||
if (attacker.isEquipped()) {
|
||||
for (Card equipment : attacker.getEquippedBy(false)) {
|
||||
if (equipment.getName().equals("Godsend")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (attacker.isEquippedBy("Godsend")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (attacker.getName().equals("Elven Warhounds")) {
|
||||
|
||||
@@ -664,17 +664,9 @@ public class AttachAi extends SpellAbilityAi {
|
||||
|
||||
//some auras aren't useful in multiples
|
||||
if (attachSource.hasSVar("NonStackingAttachEffect")) {
|
||||
prefList = CardLists.filter(prefList, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
for (Card aura : c.getEnchantedBy(false)) {
|
||||
if (aura.getName().equals(attachSource.getName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
prefList = CardLists.filter(prefList,
|
||||
Predicates.not(CardPredicates.isEnchantedBy(attachSource.getName()))
|
||||
);
|
||||
}
|
||||
|
||||
c = ComputerUtilCard.getBestAI(prefList);
|
||||
@@ -723,12 +715,8 @@ public class AttachAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
// don't equip creatures that don't gain anything
|
||||
if (card.hasSVar("NonStackingAttachEffect")) {
|
||||
for (Card equipment : newTarget.getEquippedBy(false)) {
|
||||
if (equipment.getName().equals(card.getName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (card.hasSVar("NonStackingAttachEffect") && newTarget.isEquippedBy(equipment.getName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -958,26 +946,10 @@ public class AttachAi extends SpellAbilityAi {
|
||||
|
||||
//some auras/equipments aren't useful in multiples
|
||||
if (attachSource.hasSVar("NonStackingAttachEffect")) {
|
||||
prefList = CardLists.filter(prefList, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (c.isEquipped()) {
|
||||
for (Card equipment : c.getEquippedBy(false)) {
|
||||
if (equipment.getName().equals(attachSource.getName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (c.isEnchanted()) {
|
||||
for (Card aura : c.getEnchantedBy(false)) {
|
||||
if (aura.getName().equals(attachSource.getName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
prefList = CardLists.filter(prefList, Predicates.not(Predicates.or(
|
||||
CardPredicates.isEquippedBy(attachSource.getName()),
|
||||
CardPredicates.isEnchantedBy(attachSource.getName())
|
||||
)));
|
||||
}
|
||||
|
||||
// Don't pump cards that will die.
|
||||
|
||||
Reference in New Issue
Block a user