Merge branch 'master' into Attractions

This commit is contained in:
Jetz
2024-06-23 11:23:47 -04:00
426 changed files with 921 additions and 108 deletions

View File

@@ -22,10 +22,7 @@ package forge.game;
*/
public enum GlobalRuleChange {
attackerChoosesBlockers ("The attacking player chooses how each creature blocks 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.");
attackerChoosesBlockers ("The attacking player chooses how each creature blocks each combat.");
private final String ruleText;

View File

@@ -2133,6 +2133,9 @@ public class CardProperty {
List<String> nameList = Lists.newArrayList(names.split(";"));
return nameList.contains(card.getName());
} else if (property.equals("NotedGuessPhantasm")) {
String names = sourceController.getDraftNotes().get("Spire Phantasm");
return names != null && !names.isEmpty();
} else if (property.equals("NotedTypes")) {
// Should Paliano Vanguard be hardcoded here or part of the property?
String types = sourceController.getDraftNotes().get("Paliano Vanguard");

View File

@@ -24,7 +24,6 @@ import com.google.common.collect.Lists;
import forge.card.mana.ManaCost;
import forge.game.Game;
import forge.game.GameEntity;
import forge.game.GlobalRuleChange;
import forge.game.ability.AbilityKey;
import forge.game.card.*;
import forge.game.cost.Cost;
@@ -36,6 +35,7 @@ import forge.game.player.Player;
import forge.game.player.PlayerController.ManaPaymentPurpose;
import forge.game.spellability.SpellAbility;
import forge.game.staticability.StaticAbility;
import forge.game.staticability.StaticAbilityBlockRestrict;
import forge.game.staticability.StaticAbilityCantAttackBlock;
import forge.game.staticability.StaticAbilityMustBlock;
import forge.game.trigger.TriggerType;
@@ -457,21 +457,11 @@ public class CombatUtil {
if (!canBlockMoreCreatures(blocker, combat.getAttackersBlockedBy(blocker))) {
return false;
}
final Game game = blocker.getGame();
final int blockers = combat.getAllBlockers().size();
if (blockers > 1 && game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.onlyTwoBlockers)) {
return false;
}
if (blockers > 0 && game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.onlyOneBlocker)) {
return false;
}
CardCollection allOtherBlockers = combat.getAllBlockers();
allOtherBlockers.remove(blocker);
final int blockersFromOnePlayer = CardLists.count(allOtherBlockers, CardPredicates.isController(blocker.getController()));
if (blockersFromOnePlayer > 0 && game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.onlyOneBlockerPerOpponent)) {
if (blockersFromOnePlayer >= StaticAbilityBlockRestrict.blockRestrictNum(blocker.getController())) {
return false;
}

View File

@@ -2134,12 +2134,8 @@ public class Player extends GameEntity implements Comparable<Player> {
return lost;
}
public final boolean hasProwl(final Set<String> types) {
StringBuilder sb = new StringBuilder();
for (String type : types) {
sb.append("Card.YouCtrl+").append(type).append(",");
}
return !game.getDamageDoneThisTurn(true, true, sb.toString(), "Player", null, this, null).isEmpty();
public final boolean hasProwl(final SpellAbility sa) {
return !game.getDamageDoneThisTurn(true, true, "Card.YouCtrl+sharesCreatureTypeWith", "Player", sa.getHostCard(), this, sa).isEmpty();
}
public final boolean hasFreerunning() {

View File

@@ -440,7 +440,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
}
}
if (sa.isProwl()) {
if (!activator.hasProwl(c.getType().getCreatureTypes())) {
if (!activator.hasProwl(sa)) {
return false;
}
}

View File

@@ -0,0 +1,39 @@
package forge.game.staticability;
import forge.game.Game;
import forge.game.ability.AbilityUtils;
import forge.game.card.Card;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
public class StaticAbilityBlockRestrict {
static String MODE = "BlockRestrict";
static public int blockRestrictNum(Player defender) {
final Game game = defender.getGame();
int num = Integer.MAX_VALUE;
for (final Card ca : game.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) {
for (final StaticAbility stAb : ca.getStaticAbilities()) {
if (!stAb.checkConditions(MODE)) {
continue;
}
if (blockRestrict(stAb, defender)) {
int stNum = AbilityUtils.calculateAmount(stAb.getHostCard(),
stAb.getParamOrDefault("MaxBlockers", "1"), stAb);
if (stNum < num) {
num = stNum;
}
}
}
}
return num;
}
static public boolean blockRestrict(StaticAbility stAb, Player defender) {
if (!stAb.matchesValidParam("ValidDefender", defender)) {
return false;
}
return true;
}
}