Splice: do a total rewrite to make it better for the player and more rules conform

This commit is contained in:
Hanmac
2016-12-21 18:32:50 +00:00
parent 77437bdb50
commit 94681b6675
10 changed files with 118 additions and 74 deletions

View File

@@ -84,7 +84,7 @@ import forge.util.collect.FCollection;
* @version $Id$
*/
public class ComputerUtil {
public static boolean handlePlayingSpellAbility(final Player ai, final SpellAbility sa, final Game game) {
public static boolean handlePlayingSpellAbility(final Player ai, SpellAbility sa, final Game game) {
game.getStack().freezeStack();
final Card source = sa.getHostCard();
@@ -99,6 +99,10 @@ public class ComputerUtil {
CharmEffect.makeChoices(sa);
}
if (source.getType().hasStringType("Arcane") && !source.isCopiedSpell()) {
sa = AbilityUtils.addSpliceEffects(sa);
}
if (sa.hasParam("Bestow")) {
sa.getHostCard().animateBestow();
}

View File

@@ -12,6 +12,7 @@ import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import forge.LobbyPlayer;
@@ -898,4 +899,25 @@ public class PlayerControllerAi extends PlayerController {
}
return SpellApiToAi.Converter.get(api).chooseCardName(player, sa, faces);
}
@Override
public List<Card> chooseCardsForSplice(SpellAbility sa, List<Card> cards) {
// sort from best to worst
CardLists.sortByCmcDesc(cards);
List<Card> result = Lists.newArrayList();
SpellAbility oldSA = sa;
// TODO maybe add some more Logic into it
for (final Card c : cards) {
SpellAbility newSA = oldSA.copy();
AbilityUtils.addSpliceEffect(newSA, c);
// check if AI still wants or can play the card with spliced effect
if (AiPlayDecision.WillPlay == getAi().canPlayFromEffectAI((Spell) newSA, false, false)) {
oldSA = newSA;
result.add(c);
}
}
return result;
}
}