mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Fix effects that have a player attack a certain GameEntity (like Gideon Jura, Taunt).
This commit is contained in:
@@ -46,11 +46,14 @@ public class MustAttackEffect extends SpellAbilityEffect {
|
||||
|
||||
for (final Player p : tgtPlayers) {
|
||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||
GameEntity entity;
|
||||
if (sa.getParam("Defender").equals("Self")) {
|
||||
final String defender = sa.getParam("Defender");
|
||||
final GameEntity entity;
|
||||
if (defender.equals("Self")) {
|
||||
entity = sa.getHostCard();
|
||||
} else if (defender.equals("You")) {
|
||||
entity = sa.getActivatingPlayer();
|
||||
} else {
|
||||
entity = p.getOpponent();
|
||||
throw new RuntimeException("Illegal defender " + defender + " for MustAttackEffect in card " + sa.getHostCard());
|
||||
}
|
||||
// System.out.println("Setting mustAttackEntity to: "+entity);
|
||||
p.setMustAttackEntity(entity);
|
||||
|
||||
@@ -734,6 +734,10 @@ public class CombatUtil {
|
||||
final int cntAttackers = combat.getAttackers().size();
|
||||
final Game game = c.getGame();
|
||||
|
||||
if (c.getController().getMustAttackEntity() != def) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cntAttackers > 0) {
|
||||
for (final Card card : game.getCardsIn(ZoneType.Battlefield)) {
|
||||
for (final String keyword : card.getKeyword()) {
|
||||
|
||||
@@ -75,15 +75,16 @@ public class InputAttack extends InputSyncronizedBase {
|
||||
|
||||
List<Card> possibleAttackers = playerAttacks.getCardsIn(ZoneType.Battlefield);
|
||||
for (Card c : Iterables.filter(possibleAttackers, CardPredicates.Presets.CREATURES)) {
|
||||
GameEntity mustAttack = c.getController().getMustAttackEntity() ;
|
||||
if (c.hasStartOfKeyword("CARDNAME attacks specific player each combat if able")) {
|
||||
final int i = c.getKeywordPosition("CARDNAME attacks specific player each combat if able");
|
||||
final String defined = c.getKeyword().get(i).split(":")[1];
|
||||
final Player player = AbilityUtils.getDefinedPlayers(c, defined, null).get(0);
|
||||
if (player != null && CombatUtil.canAttack(c, player, combat)) {
|
||||
combat.addAttacker(c, player);
|
||||
GuiBase.getInterface().fireEvent(new UiEventAttackerDeclared(c, player));
|
||||
continue;
|
||||
mustAttack = AbilityUtils.getDefinedPlayers(c, defined, null).get(0);
|
||||
}
|
||||
if (mustAttack != null && CombatUtil.canAttack(c, mustAttack, combat)) {
|
||||
combat.addAttacker(c, mustAttack);
|
||||
GuiBase.getInterface().fireEvent(new UiEventAttackerDeclared(c, mustAttack));
|
||||
continue;
|
||||
}
|
||||
if (c.hasKeyword("CARDNAME attacks each combat if able.") ||
|
||||
(c.hasKeyword("CARDNAME attacks each turn if able.") && !c.getDamageHistory().getCreatureAttackedThisTurn())) {
|
||||
@@ -247,7 +248,8 @@ public class InputAttack extends InputSyncronizedBase {
|
||||
|
||||
private boolean canUndeclareAttacker(Card card) {
|
||||
return !card.hasKeyword("CARDNAME attacks each turn if able.") &&
|
||||
!card.hasStartOfKeyword("CARDNAME attacks specific player each combat if able");
|
||||
!card.hasStartOfKeyword("CARDNAME attacks specific player each combat if able") &&
|
||||
card.getController().getMustAttackEntity() == null;
|
||||
}
|
||||
|
||||
private boolean undeclareAttacker(Card card) {
|
||||
|
||||
Reference in New Issue
Block a user