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) {
|
for (final Player p : tgtPlayers) {
|
||||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||||
GameEntity entity;
|
final String defender = sa.getParam("Defender");
|
||||||
if (sa.getParam("Defender").equals("Self")) {
|
final GameEntity entity;
|
||||||
|
if (defender.equals("Self")) {
|
||||||
entity = sa.getHostCard();
|
entity = sa.getHostCard();
|
||||||
|
} else if (defender.equals("You")) {
|
||||||
|
entity = sa.getActivatingPlayer();
|
||||||
} else {
|
} else {
|
||||||
entity = p.getOpponent();
|
throw new RuntimeException("Illegal defender " + defender + " for MustAttackEffect in card " + sa.getHostCard());
|
||||||
}
|
}
|
||||||
// System.out.println("Setting mustAttackEntity to: "+entity);
|
// System.out.println("Setting mustAttackEntity to: "+entity);
|
||||||
p.setMustAttackEntity(entity);
|
p.setMustAttackEntity(entity);
|
||||||
|
|||||||
@@ -734,6 +734,10 @@ public class CombatUtil {
|
|||||||
final int cntAttackers = combat.getAttackers().size();
|
final int cntAttackers = combat.getAttackers().size();
|
||||||
final Game game = c.getGame();
|
final Game game = c.getGame();
|
||||||
|
|
||||||
|
if (c.getController().getMustAttackEntity() != def) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (cntAttackers > 0) {
|
if (cntAttackers > 0) {
|
||||||
for (final Card card : game.getCardsIn(ZoneType.Battlefield)) {
|
for (final Card card : game.getCardsIn(ZoneType.Battlefield)) {
|
||||||
for (final String keyword : card.getKeyword()) {
|
for (final String keyword : card.getKeyword()) {
|
||||||
|
|||||||
@@ -75,15 +75,16 @@ public class InputAttack extends InputSyncronizedBase {
|
|||||||
|
|
||||||
List<Card> possibleAttackers = playerAttacks.getCardsIn(ZoneType.Battlefield);
|
List<Card> possibleAttackers = playerAttacks.getCardsIn(ZoneType.Battlefield);
|
||||||
for (Card c : Iterables.filter(possibleAttackers, CardPredicates.Presets.CREATURES)) {
|
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")) {
|
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 int i = c.getKeywordPosition("CARDNAME attacks specific player each combat if able");
|
||||||
final String defined = c.getKeyword().get(i).split(":")[1];
|
final String defined = c.getKeyword().get(i).split(":")[1];
|
||||||
final Player player = AbilityUtils.getDefinedPlayers(c, defined, null).get(0);
|
mustAttack = AbilityUtils.getDefinedPlayers(c, defined, null).get(0);
|
||||||
if (player != null && CombatUtil.canAttack(c, player, combat)) {
|
}
|
||||||
combat.addAttacker(c, player);
|
if (mustAttack != null && CombatUtil.canAttack(c, mustAttack, combat)) {
|
||||||
GuiBase.getInterface().fireEvent(new UiEventAttackerDeclared(c, player));
|
combat.addAttacker(c, mustAttack);
|
||||||
continue;
|
GuiBase.getInterface().fireEvent(new UiEventAttackerDeclared(c, mustAttack));
|
||||||
}
|
continue;
|
||||||
}
|
}
|
||||||
if (c.hasKeyword("CARDNAME attacks each combat if able.") ||
|
if (c.hasKeyword("CARDNAME attacks each combat if able.") ||
|
||||||
(c.hasKeyword("CARDNAME attacks each turn if able.") && !c.getDamageHistory().getCreatureAttackedThisTurn())) {
|
(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) {
|
private boolean canUndeclareAttacker(Card card) {
|
||||||
return !card.hasKeyword("CARDNAME attacks each turn if able.") &&
|
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) {
|
private boolean undeclareAttacker(Card card) {
|
||||||
|
|||||||
Reference in New Issue
Block a user