mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-12 08:48:39 +00:00
Fix for Dewdrop Spy
This commit is contained in:
@@ -16,6 +16,7 @@ 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.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
@@ -30,27 +31,29 @@ public class RearrangeTopOfLibraryAi extends SpellAbilityAi {
|
||||
final PhaseHandler ph = aiPlayer.getGame().getPhaseHandler();
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
if (source.isPermanent() && !sa.getRestrictions().isSorcerySpeed()
|
||||
&& (sa.getPayCosts().hasTapCost() || sa.getPayCosts().hasManaCost())) {
|
||||
// If it has an associated cost, try to only do this before own turn
|
||||
if (!(ph.is(PhaseType.END_OF_TURN) && ph.getNextTurn() == aiPlayer)) {
|
||||
if (!sa.isTrigger()) {
|
||||
if (source.isPermanent() && !sa.getRestrictions().isSorcerySpeed()
|
||||
&& (sa.getPayCosts().hasTapCost() || sa.getPayCosts().hasManaCost())) {
|
||||
// If it has an associated cost, try to only do this before own turn
|
||||
if (!(ph.is(PhaseType.END_OF_TURN) && ph.getNextTurn() == aiPlayer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Do it once per turn, generally (may be improved later)
|
||||
if (AiCardMemory.isRememberedCardByName(aiPlayer, source.getName(), AiCardMemory.MemorySet.ACTIVATED_THIS_TURN)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Do it once per turn, generally (may be improved later)
|
||||
if (!sa.isTrigger()
|
||||
&& AiCardMemory.isRememberedCardByName(aiPlayer, source.getName(), AiCardMemory.MemorySet.ACTIVATED_THIS_TURN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sa.usesTargeting()) {
|
||||
// ability is targeted
|
||||
sa.resetTargets();
|
||||
|
||||
Player opp = aiPlayer.getWeakestOpponent();
|
||||
PlayerCollection targetableOpps = aiPlayer.getOpponents().filter(PlayerPredicates.isTargetableBy(sa));
|
||||
Player opp = targetableOpps.min(PlayerPredicates.compareByLife());
|
||||
final boolean canTgtAI = sa.canTarget(aiPlayer);
|
||||
final boolean canTgtHuman = sa.canTarget(opp);
|
||||
final boolean canTgtHuman = opp != null && sa.canTarget(opp);
|
||||
|
||||
if (canTgtHuman && canTgtAI) {
|
||||
// TODO: maybe some other consideration rather than random?
|
||||
|
||||
@@ -41,7 +41,6 @@ public class Aggregates {
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
public static final <T> T itemWithMax(final Iterable<T> source, final Function<T, Integer> valueAccessor) {
|
||||
if (source == null) { return null; }
|
||||
int max = Integer.MIN_VALUE;
|
||||
@@ -188,7 +187,6 @@ public class Aggregates {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static <TItem, TField> TItem firstFieldEquals(List<TItem> source, Function<TItem, TField> valueAccessor, TField valueEquals) {
|
||||
if (source == null) { return null; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user