mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
Add AI for Rousing Refrain
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -25,6 +26,7 @@ public class CharmAi extends SpellAbilityAi {
|
||||
protected boolean checkApiLogic(Player ai, SpellAbility sa) {
|
||||
final Card source = sa.getHostCard();
|
||||
List<AbilitySub> choices = CharmEffect.makePossibleOptions(sa);
|
||||
Collections.shuffle(choices);
|
||||
|
||||
final int num;
|
||||
final int min;
|
||||
|
||||
@@ -114,7 +114,7 @@ public class ManaEffectAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Dark Ritual and other similar instants/sorceries that add mana to mana pool
|
||||
private boolean doManaRitualLogic(Player ai, SpellAbility sa) {
|
||||
public static boolean doManaRitualLogic(Player ai, SpellAbility sa) {
|
||||
final Card host = sa.getHostCard();
|
||||
final String logic = sa.getParamOrDefault("AILogic", "");
|
||||
|
||||
@@ -123,7 +123,7 @@ public class ManaEffectAi extends SpellAbilityAi {
|
||||
int manaReceived = sa.hasParam("Amount") ? AbilityUtils.calculateAmount(host, sa.getParam("Amount"), sa) : 1;
|
||||
manaReceived *= sa.getParam("Produced").split(" ").length;
|
||||
|
||||
int selfCost = sa.getPayCosts().getCostMana() != null ? sa.getPayCosts().getCostMana().getMana().getCMC() : 0;
|
||||
int selfCost = sa.getRootAbility().getPayCosts().getCostMana() != null ? sa.getRootAbility().getPayCosts().getCostMana().getMana().getCMC() : 0;
|
||||
|
||||
String produced = sa.getParam("Produced");
|
||||
byte producedColor = produced.equals("Any") ? MagicColor.ALL_COLORS : MagicColor.fromName(produced);
|
||||
|
||||
@@ -34,6 +34,8 @@ import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.player.PlayerCollection;
|
||||
import forge.game.player.PlayerPredicates;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.staticability.StaticAbility;
|
||||
@@ -510,6 +512,15 @@ public class PumpAi extends PumpAiBase {
|
||||
}
|
||||
|
||||
return false;
|
||||
} else if ("ManaRitual".equals(sa.getParam("AILogic"))) {
|
||||
PlayerCollection targetableOpps = ai.getOpponents().filter(PlayerPredicates.isTargetableBy(sa));
|
||||
if (targetableOpps.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
Player mostCards = targetableOpps.max(PlayerPredicates.compareByZoneSize(ZoneType.Hand));
|
||||
sa.resetTargets();
|
||||
sa.getTargets().add(mostCards);
|
||||
return mandatory || ManaEffectAi.doManaRitualLogic(ai, sa.getSubAbility());
|
||||
}
|
||||
|
||||
if (isFight) {
|
||||
|
||||
Reference in New Issue
Block a user