- Stopped AI from crewing vehicles with stronger or equal (ie. crew vehicle with another copy of crewed vehicle) creatures

This commit is contained in:
excessum
2016-10-06 02:25:15 +00:00
parent d3faa45ab1
commit b962bc9ca6

View File

@@ -32,6 +32,7 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import forge.ai.ability.AnimateAi;
import forge.ai.ability.ProtectAi;
import forge.card.CardType;
import forge.card.MagicColor;
@@ -44,6 +45,7 @@ import forge.game.ability.effects.CharmEffect;
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.CardPredicates.Presets;
@@ -497,10 +499,12 @@ public class ComputerUtil {
return tapList;
}
public static CardCollection chooseTapTypeAccumulatePower(final Player ai, final String type, final SpellAbility sa, final boolean tap, final int amount, final CardCollectionView exclude) {
public static CardCollection chooseTapTypeAccumulatePower(final Player ai, final String type, final SpellAbility sa,
final boolean tap, final int amount, final CardCollectionView exclude) {
// Used for Crewing vehicles, ideally we sort by useless creatures. Can't Attack/Defender
int totalPower = 0;
final Card activate = sa.getHostCard();
int vehicleValue = 0;
CardCollection all = new CardCollection(ai.getCardsIn(ZoneType.Battlefield));
all.removeAll(exclude);
@@ -509,6 +513,9 @@ public class ComputerUtil {
if (sa.hasParam("Crew")) {
typeList = CardLists.getNotKeyword(typeList, "CARDNAME can't crew Vehicles.");
Card vehicle = CardFactory.copyCard(sa.getHostCard(), true);
AnimateAi.becomeAnimated(vehicle, false, sa);
vehicleValue = ComputerUtilCard.evaluateCreature(vehicle);
}
// is this needed?
@@ -524,7 +531,7 @@ public class ComputerUtil {
// Very very rudimentary
for (Card next : typeList) {
int pow = next.getNetPower();
if (pow <= 0) {
if (pow <= 0 || ComputerUtilCard.evaluateCreature(next) > vehicleValue) {
continue;
}
totalPower += pow;