mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
ONE: The Eternal Wanderer + support + tidy related cards
This commit is contained in:
@@ -26,8 +26,6 @@ public enum GlobalRuleChange {
|
||||
attackerChoosesBlockers ("The attacking player chooses how each creature blocks each combat."),
|
||||
manaBurn ("A player losing unspent mana causes that player to lose that much life."),
|
||||
noNight ("It can't become night."),
|
||||
/* onlyOneAttackerATurn ("No more than one creature can attack each turn."), */
|
||||
onlyOneAttackerACombat ("No more than one creature can attack each combat."),
|
||||
onlyOneBlocker ("No more than one creature can block each combat."),
|
||||
onlyOneBlockerPerOpponent ("Each opponent can't block with more than one creature."),
|
||||
onlyTwoBlockers ("No more than two creatures can block each combat."),
|
||||
|
||||
@@ -7,10 +7,9 @@ import com.google.common.primitives.Ints;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.GlobalRuleChange;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.game.staticability.StaticAbilityAttackRestrict;
|
||||
import forge.util.collect.FCollectionView;
|
||||
import forge.util.maps.LinkedHashMapToAmount;
|
||||
import forge.util.maps.MapToAmount;
|
||||
@@ -107,33 +106,13 @@ public class GlobalAttackRestrictions {
|
||||
* @return a {@link GlobalAttackRestrictions} object.
|
||||
*/
|
||||
public static GlobalAttackRestrictions getGlobalRestrictions(final Player attackingPlayer, final FCollectionView<GameEntity> possibleDefenders) {
|
||||
int max = -1;
|
||||
final MapToAmount<GameEntity> defenderMax = new LinkedHashMapToAmount<>(possibleDefenders.size());
|
||||
final Game game = attackingPlayer.getGame();
|
||||
|
||||
/* if (game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.onlyOneAttackerATurn)) {
|
||||
if (!attackingPlayer.getAttackedWithCreatureThisTurn().isEmpty()) {
|
||||
max = 0;
|
||||
} else {
|
||||
max = 1;
|
||||
}
|
||||
} */
|
||||
|
||||
if (max == -1 && game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.onlyOneAttackerACombat)) {
|
||||
max = 1;
|
||||
}
|
||||
|
||||
if (max == -1) {
|
||||
for (final Card card : game.getCardsIn(ZoneType.Battlefield)) {
|
||||
if (card.hasKeyword("No more than two creatures can attack each combat.")) {
|
||||
max = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
int max = StaticAbilityAttackRestrict.globalAttackRestrict(game);
|
||||
|
||||
for (final GameEntity defender : possibleDefenders) {
|
||||
final int defMax = getMaxAttackTo(defender);
|
||||
final int defMax = StaticAbilityAttackRestrict.attackRestrictNum(defender);
|
||||
if (defMax != -1) {
|
||||
defenderMax.add(defender, defMax);
|
||||
}
|
||||
@@ -145,27 +124,4 @@ public class GlobalAttackRestrictions {
|
||||
|
||||
return new GlobalAttackRestrictions(max, defenderMax);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Get the maximum number of creatures allowed to attack a certain defender.
|
||||
* </p>
|
||||
*
|
||||
* @param defender
|
||||
* the defending {@link GameEntity}.
|
||||
* @return the maximum number of creatures, or -1 if it is unlimited.
|
||||
*/
|
||||
private static int getMaxAttackTo(final GameEntity defender) {
|
||||
if (defender instanceof Player) {
|
||||
for (final Card card : ((Player) defender).getCardsIn(ZoneType.Battlefield)) {
|
||||
if (card.hasKeyword("No more than one creature can attack you each combat.")) {
|
||||
return 1;
|
||||
} else if (card.hasKeyword("No more than two creatures can attack you each combat.")) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package forge.game.staticability;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
public class StaticAbilityAttackRestrict {
|
||||
|
||||
static String MODE = "AttackRestrict";
|
||||
|
||||
static public int globalAttackRestrict(Game game) {
|
||||
int max = Integer.MAX_VALUE;
|
||||
for (final Card ca : game.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) {
|
||||
for (final StaticAbility stAb : ca.getStaticAbilities()) {
|
||||
if (!stAb.getParam("Mode").equals(MODE) || stAb.isSuppressed() || !stAb.checkConditions()
|
||||
|| stAb.hasParam("ValidDefender")) {
|
||||
continue;
|
||||
}
|
||||
int stMax = AbilityUtils.calculateAmount(stAb.getHostCard(),
|
||||
stAb.getParamOrDefault("MaxAttackers", "1"), stAb);
|
||||
if (stMax < max) {
|
||||
max = stMax;
|
||||
}
|
||||
}
|
||||
}
|
||||
return max < Integer.MAX_VALUE ? max : -1;
|
||||
}
|
||||
|
||||
static public int attackRestrictNum(GameEntity defender) {
|
||||
final Game game = defender.getGame();
|
||||
for (final Card ca : game.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) {
|
||||
for (final StaticAbility stAb : ca.getStaticAbilities()) {
|
||||
if (!stAb.getParam("Mode").equals(MODE) || stAb.isSuppressed() || !stAb.checkConditions()) {
|
||||
continue;
|
||||
}
|
||||
if (attackRestrict(stAb, defender)) {
|
||||
return AbilityUtils.calculateAmount(stAb.getHostCard(),
|
||||
stAb.getParamOrDefault("MaxAttackers", "1"), stAb);
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static public boolean attackRestrict(StaticAbility stAb, GameEntity defender) {
|
||||
if (!stAb.matchesValidParam("ValidDefender", defender)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user