mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Add Season of the Witch
This commit is contained in:
@@ -17,6 +17,7 @@ import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.CardPredicates.Presets;
|
||||
import forge.game.combat.AttackingBand;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.keyword.Keyword;
|
||||
import forge.game.mana.Mana;
|
||||
import forge.game.player.Player;
|
||||
@@ -1622,6 +1623,9 @@ public class CardProperty {
|
||||
if (band == null || !band.getAttackers().contains(card)) {
|
||||
return false;
|
||||
}
|
||||
} else if (property.equals("couldAttackButNotAttacking")) {
|
||||
if (!game.getPhaseHandler().isPlayerTurn(controller)) return false;
|
||||
return CombatUtil.couldAttackButNotAttacking(combat, card);
|
||||
} else if (property.startsWith("kicked")) {
|
||||
if (property.equals("kicked")) {
|
||||
if (card.getKickerMagnitude() == 0) {
|
||||
|
||||
@@ -45,6 +45,7 @@ import forge.util.collect.FCollectionView;
|
||||
import forge.util.maps.MapToAmount;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -82,6 +83,38 @@ public class CombatUtil {
|
||||
return myViolations <= bestAttack.getRight().intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if attacker could attack without violating any constraints.
|
||||
*/
|
||||
public static boolean couldAttackButNotAttacking(Combat combat, final Card attacker) {
|
||||
// If the player didn't declare attackers, combat here will be null
|
||||
if (combat == null) {
|
||||
combat = new Combat(attacker.getController());
|
||||
} else if (combat.isAttacking(attacker)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final AttackConstraints constraints = combat.getAttackConstraints();
|
||||
final Pair<Map<Card, GameEntity>, Integer> bestAttack = constraints.getLegalAttackers();
|
||||
final Map<Card, GameEntity> attackers = new HashMap<>(combat.getAttackersAndDefenders());
|
||||
final Game game = attacker.getGame();
|
||||
|
||||
return Iterables.any(getAllPossibleDefenders(attacker.getController()), new Predicate<GameEntity>() {
|
||||
@Override
|
||||
public boolean apply(final GameEntity defender) {
|
||||
if (!canAttack(attacker, defender) || getAttackCost(game, attacker, defender) != null) {
|
||||
return false;
|
||||
}
|
||||
attackers.put(attacker, defender);
|
||||
final int myViolations = constraints.countViolations(attackers);
|
||||
if (myViolations == -1) {
|
||||
return false;
|
||||
}
|
||||
return myViolations <= bestAttack.getRight().intValue();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Check whether a player should be given the chance to attack this combat.
|
||||
|
||||
Reference in New Issue
Block a user