mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
AnimateAi: replace copyCard with LKI copy
This commit is contained in:
@@ -30,8 +30,8 @@ import forge.game.ability.ApiType;
|
||||
import forge.game.ability.effects.ProtectEffect;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardCollectionView;
|
||||
import forge.game.card.CardFactory;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardUtil;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.combat.CombatUtil;
|
||||
@@ -125,7 +125,7 @@ public class AiAttackController {
|
||||
if (sa.getApi() == ApiType.Animate) {
|
||||
if (ComputerUtilCost.canPayCost(sa, defender)
|
||||
&& sa.getRestrictions().checkOtherRestrictions(c, sa, defender)) {
|
||||
Card animatedCopy = CardFactory.copyCard(c, true);
|
||||
Card animatedCopy = CardUtil.getLKICopy(c);
|
||||
AnimateAi.becomeAnimated(animatedCopy, c.hasSickness(), sa);
|
||||
defenders.add(animatedCopy);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,10 @@ import forge.ai.ability.AnimateAi;
|
||||
import forge.card.ColorSet;
|
||||
import forge.game.GameActionUtil;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
import forge.game.card.CardFactory;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardUtil;
|
||||
import forge.game.card.CardPredicates.Presets;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.combat.Combat;
|
||||
@@ -315,11 +314,10 @@ public class ComputerUtilCost {
|
||||
* the source
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static boolean checkTapTypeCost(final Player ai, final Cost cost, final Card source) {
|
||||
public static boolean checkTapTypeCost(final Player ai, final Cost cost, final Card source, final SpellAbility sa) {
|
||||
if (cost == null) {
|
||||
return true;
|
||||
}
|
||||
boolean isVehicle = source.hasStartOfKeyword("Crew");
|
||||
for (final CostPart part : cost.getCostParts()) {
|
||||
if (part instanceof CostTapType) {
|
||||
/*
|
||||
@@ -329,28 +327,25 @@ public class ComputerUtilCost {
|
||||
* - block against evasive (flyers, intimidate, etc.)
|
||||
* - break board stall by racing with evasive vehicle
|
||||
*/
|
||||
if (isVehicle) {
|
||||
for (SpellAbility sa : source.getSpellAbilities()) {
|
||||
if (sa.getApi() == ApiType.Animate) {
|
||||
Card vehicle = CardFactory.copyCard(sa.getHostCard(), false);
|
||||
AnimateAi.becomeAnimated(vehicle, sa.getHostCard().hasSickness(), sa);
|
||||
final int vehicleValue = ComputerUtilCard.evaluateCreature(vehicle);
|
||||
String type = part.getType();
|
||||
String totalP = type.split("withTotalPowerGE")[1];
|
||||
type = type.replace("+withTotalPowerGE" + totalP, "");
|
||||
CardCollection exclude = CardLists.getValidCards(
|
||||
new CardCollection(ai.getCardsIn(ZoneType.Battlefield)), type.split(";"),
|
||||
source.getController(), source, sa);
|
||||
exclude = CardLists.filter(exclude, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return ComputerUtilCard.evaluateCreature(c) >= vehicleValue;
|
||||
}
|
||||
}); // exclude creatures >= vehicle
|
||||
return ComputerUtil.chooseTapTypeAccumulatePower(ai, type, sa, true,
|
||||
Integer.parseInt(totalP), exclude) != null;
|
||||
if (sa.hasParam("Crew")) {
|
||||
//Card vehicle = CardFactory.copyCard(sa.getHostCard(), true);
|
||||
Card vehicle = CardUtil.getLKICopy(source);
|
||||
AnimateAi.becomeAnimated(vehicle, source.hasSickness(), sa);
|
||||
final int vehicleValue = ComputerUtilCard.evaluateCreature(vehicle);
|
||||
String type = part.getType();
|
||||
String totalP = type.split("withTotalPowerGE")[1];
|
||||
type = type.replace("+withTotalPowerGE" + totalP, "");
|
||||
CardCollection exclude = CardLists.getValidCards(
|
||||
new CardCollection(ai.getCardsIn(ZoneType.Battlefield)), type.split(";"),
|
||||
source.getController(), source, sa);
|
||||
exclude = CardLists.filter(exclude, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return ComputerUtilCard.evaluateCreature(c) >= vehicleValue;
|
||||
}
|
||||
}
|
||||
}); // exclude creatures >= vehicle
|
||||
return ComputerUtil.chooseTapTypeAccumulatePower(ai, type, sa, true,
|
||||
Integer.parseInt(totalP), exclude) != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import forge.game.ability.ApiType;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
import forge.game.card.CardCollectionView;
|
||||
import forge.game.card.CardFactory;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.card.CardUtil;
|
||||
@@ -88,7 +87,7 @@ public class AnimateAi extends SpellAbilityAi {
|
||||
list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(topStack));
|
||||
ComputerUtilCard.sortByEvaluateCreature(list);
|
||||
if (!list.isEmpty() && list.size() == nToSac && ComputerUtilCost.canPayCost(sa, ai)) {
|
||||
Card animatedCopy = CardFactory.copyCard(source, true);
|
||||
Card animatedCopy = CardUtil.getLKICopy(source);//CardFactory.copyCard(source, false);
|
||||
becomeAnimated(animatedCopy, source.hasSickness(), sa);
|
||||
list.add(animatedCopy);
|
||||
list = CardLists.getValidCards(list, valid.split(","), ai.getOpponent(), topStack.getHostCard(),
|
||||
@@ -139,7 +138,7 @@ public class AnimateAi extends SpellAbilityAi {
|
||||
if (!game.getStack().isEmpty() && game.getStack().peekAbility().getApi() == ApiType.Sacrifice) {
|
||||
return true; // interrupt sacrifice
|
||||
}
|
||||
if (!ComputerUtilCost.checkTapTypeCost(aiPlayer, sa.getPayCosts(), source)) {
|
||||
if (!ComputerUtilCost.checkTapTypeCost(aiPlayer, sa.getPayCosts(), source, sa)) {
|
||||
return false; // prevent crewing with equal or better creatures
|
||||
}
|
||||
if (null == tgt) {
|
||||
@@ -174,7 +173,7 @@ public class AnimateAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (!SpellAbilityAi.isSorcerySpeed(sa) && !sa.hasParam("Permanent")) {
|
||||
Card animatedCopy = CardFactory.getCard(c.getPaperCard(), aiPlayer, c.getGame());
|
||||
Card animatedCopy = CardUtil.getLKICopy(c);
|
||||
AnimateAi.becomeAnimated(animatedCopy, c.hasSickness(), sa);
|
||||
if (ph.isPlayerTurn(aiPlayer)
|
||||
&& !ComputerUtilCard.doesSpecifiedCreatureAttackAI(aiPlayer, animatedCopy)) {
|
||||
|
||||
Reference in New Issue
Block a user