* Norn's Annex - Fixed that the effect did not work if a planeswalker of the controller was attacked.

This commit is contained in:
LevelX2 2015-05-11 15:00:54 +02:00 committed by Luna Skyrise
parent d42901d052
commit ef1ee0adbf
3 changed files with 24 additions and 20 deletions

View file

@ -52,7 +52,9 @@ public class NornsAnnex extends CardImpl {
public NornsAnnex(UUID ownerId) {
super(ownerId, 17, "Norn's Annex", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{3}{WP}{WP}");
this.expansionSetCode = "NPH";
this.color.setWhite(true);
// {WP} ({WP} can be paid with either or 2 life.)
// Creatures can't attack you or a planeswalker you control unless their controller pays for each of those creatures.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new NornsAnnexReplacementEffect()));
}
@ -87,29 +89,24 @@ class NornsAnnexReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.DECLARE_ATTACKER) {
if (event.getTargetId().equals(source.getControllerId()) ) {
return true;
}
// planeswalker
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && permanent.getControllerId().equals(source.getControllerId())
&& permanent.getCardType().contains(CardType.PLANESWALKER)) {
return true;
}
if (event.getTargetId().equals(source.getControllerId()) ) {
return true;
}
return false;
// planeswalker
Permanent permanent = game.getPermanent(event.getTargetId());
return permanent != null && permanent.getControllerId().equals(source.getControllerId())
&& permanent.getCardType().contains(CardType.PLANESWALKER);
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player player = game.getPlayer(event.getPlayerId());
if (player != null && event.getTargetId().equals(source.getControllerId())) {
if (player != null) {
ManaCostsImpl propagandaTax = new ManaCostsImpl("{WP}");
if (propagandaTax.canPay(source, source.getSourceId(), event.getPlayerId(), game) &&
player.chooseUse(Outcome.Benefit, "Pay {WP} to declare attacker?", game)) {
if (propagandaTax.payOrRollback(source, game, this.getId(), event.getPlayerId())) {
if (propagandaTax.payOrRollback(source, game, source.getSourceId(), event.getPlayerId())) {
return false;
}
}
@ -125,5 +122,3 @@ class NornsAnnexReplacementEffect extends ReplacementEffectImpl {
}
}

View file

@ -139,12 +139,12 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
* @param ability
* @param game
* @param sourceId
* @param controllerId
* @param payingPlayerId
* @return true if the cost was paid
*/
public boolean payOrRollback(Ability ability, Game game, UUID sourceId, UUID controllerId) {
public boolean payOrRollback(Ability ability, Game game, UUID sourceId, UUID payingPlayerId) {
int bookmark = game.bookmarkState();
if (pay(ability, game, sourceId, controllerId, false)) {
if (pay(ability, game, sourceId, payingPlayerId, false)) {
game.removeBookmark(bookmark);
return true;
}

View file

@ -148,7 +148,16 @@ public class GameEvent implements Serializable {
COUNTER,
COUNTERED,
DECLARING_ATTACKERS, DECLARED_ATTACKERS,
DECLARE_ATTACKER, ATTACKER_DECLARED,
DECLARE_ATTACKER,
/* ATTACKER_DECLARED
targetId id of the defending player or planeswalker attacked
sourceId id of the attacking creature
playerId player defining the attacking creatures
amount not used for this event
flag not used for this event
*/
ATTACKER_DECLARED,
/* DECLARING_BLOCKERS
targetId attackerId