mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- Improved TapAllAI.
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
Name:Thoughtweft Gambit
|
||||
ManaCost:4 WU WU
|
||||
Types:Instant
|
||||
#Switched order of abilities since DB$UntapAll doesn't exist yet
|
||||
A:SP$ UntapAll | Cost$ 4 WU WU | ValidCards$ Creature.YouCtrl | SubAbility$ DBTap | SpellDescription$ Tap all creatures your opponents control and untap all creatures you control.
|
||||
SVar:DBTap:DB$ TapAll | ValidCards$ Creature.OppCtrl
|
||||
A:SP$ TapAll | Cost$ 4 WU WU | ValidCards$ Creature.OppCtrl | SubAbility$ DBUnTap | SpellDescription$ Tap all creatures your opponents control and untap all creatures you control.
|
||||
SVar:DBUnTap:DB$ UntapAll | ValidCards$ Creature.YouCtrl
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/thoughtweft_gambit.jpg
|
||||
Oracle:Tap all creatures your opponents control and untap all creatures you control.
|
||||
SetInfo:SHM Uncommon
|
||||
@@ -13,6 +13,7 @@ import forge.Singletons;
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.game.phase.CombatUtil;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.AIPlayer;
|
||||
import forge.game.player.Player;
|
||||
@@ -56,12 +57,14 @@ public class TapAllAi extends SpellAbilityAi {
|
||||
validTappables = CardLists.filter(validTappables, Presets.UNTAPPED);
|
||||
|
||||
final Random r = MyRandom.getRandom();
|
||||
boolean rr = false;
|
||||
if (r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn())) {
|
||||
rr = true;
|
||||
if (r.nextFloat() > Math.pow(.6667, sa.getActivationsThisTurn())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (validTappables.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (validTappables.size() > 0) {
|
||||
final List<Card> human = CardLists.filter(validTappables, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
@@ -74,12 +77,24 @@ public class TapAllAi extends SpellAbilityAi {
|
||||
return c.getController().equals(ai);
|
||||
}
|
||||
});
|
||||
if (human.size() > compy.size()) {
|
||||
return rr;
|
||||
}
|
||||
}
|
||||
if (human.size() <= compy.size()) {
|
||||
return false;
|
||||
}
|
||||
// in AI's turn, check if there are possible attackers, before tapping blockers
|
||||
if (Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(ai) && !SpellAbilityAi.isSorcerySpeed(sa)) {
|
||||
validTappables = ai.getCardsIn(ZoneType.Battlefield);
|
||||
final boolean any = Iterables.any(validTappables, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return CombatUtil.canAttack(c) && CombatUtil.canAttackNextTurn(c);
|
||||
}
|
||||
});
|
||||
if(!any) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
||||
@@ -807,13 +807,17 @@ public class CombatUtil {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean canAttack(final Card c, final GameEntity defender) {
|
||||
return canAttack(c) && canAttackNextTurn(c, defender);
|
||||
}
|
||||
|
||||
public static boolean canAttack(final Card c) {
|
||||
if (c.isTapped() || c.isPhasedOut()
|
||||
|| (c.hasSickness() && !c.hasKeyword("CARDNAME can attack as though it had haste."))
|
||||
|| Singletons.getModel().getGame().getPhaseHandler().getPhase()
|
||||
.isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
return false;
|
||||
}
|
||||
return CombatUtil.canAttackNextTurn(c, defender);
|
||||
return true;
|
||||
}
|
||||
|
||||
// can a creature attack if untapped and without summoning sickness?
|
||||
|
||||
Reference in New Issue
Block a user