mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-13 01:08:06 +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.Player;
|
||||||
import forge.game.player.PlayerActionConfirmMode;
|
import forge.game.player.PlayerActionConfirmMode;
|
||||||
import forge.game.player.PlayerCollection;
|
import forge.game.player.PlayerCollection;
|
||||||
|
import forge.game.player.PlayerPredicates;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
@@ -30,28 +31,30 @@ public class RearrangeTopOfLibraryAi extends SpellAbilityAi {
|
|||||||
final PhaseHandler ph = aiPlayer.getGame().getPhaseHandler();
|
final PhaseHandler ph = aiPlayer.getGame().getPhaseHandler();
|
||||||
final Card source = sa.getHostCard();
|
final Card source = sa.getHostCard();
|
||||||
|
|
||||||
if (source.isPermanent() && !sa.getRestrictions().isSorcerySpeed()
|
if (!sa.isTrigger()) {
|
||||||
&& (sa.getPayCosts().hasTapCost() || sa.getPayCosts().hasManaCost())) {
|
if (source.isPermanent() && !sa.getRestrictions().isSorcerySpeed()
|
||||||
// If it has an associated cost, try to only do this before own turn
|
&& (sa.getPayCosts().hasTapCost() || sa.getPayCosts().hasManaCost())) {
|
||||||
if (!(ph.is(PhaseType.END_OF_TURN) && ph.getNextTurn() == aiPlayer)) {
|
// 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;
|
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()) {
|
if (sa.usesTargeting()) {
|
||||||
// ability is targeted
|
// ability is targeted
|
||||||
sa.resetTargets();
|
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 canTgtAI = sa.canTarget(aiPlayer);
|
||||||
final boolean canTgtHuman = sa.canTarget(opp);
|
final boolean canTgtHuman = opp != null && sa.canTarget(opp);
|
||||||
|
|
||||||
if (canTgtHuman && canTgtAI) {
|
if (canTgtHuman && canTgtAI) {
|
||||||
// TODO: maybe some other consideration rather than random?
|
// TODO: maybe some other consideration rather than random?
|
||||||
Player preferredTarget = MyRandom.percentTrue(50) ? aiPlayer : opp;
|
Player preferredTarget = MyRandom.percentTrue(50) ? aiPlayer : opp;
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ public class Aggregates {
|
|||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static final <T> T itemWithMax(final Iterable<T> source, final Function<T, Integer> valueAccessor) {
|
public static final <T> T itemWithMax(final Iterable<T> source, final Function<T, Integer> valueAccessor) {
|
||||||
if (source == null) { return null; }
|
if (source == null) { return null; }
|
||||||
int max = Integer.MIN_VALUE;
|
int max = Integer.MIN_VALUE;
|
||||||
@@ -188,7 +187,6 @@ public class Aggregates {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static <TItem, TField> TItem firstFieldEquals(List<TItem> source, Function<TItem, TField> valueAccessor, TField valueEquals) {
|
public static <TItem, TField> TItem firstFieldEquals(List<TItem> source, Function<TItem, TField> valueAccessor, TField valueEquals) {
|
||||||
if (source == null) { return null; }
|
if (source == null) { return null; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user