mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 04:42:07 -08:00
* Landfall - Fixed that it also works for Instant and Soceries copied from opponents. Corrected tooltip text formating.
This commit is contained in:
parent
fa2f7e2055
commit
f8f21bd8ce
12 changed files with 156 additions and 73 deletions
|
|
@ -34,7 +34,6 @@ import mage.abilities.TriggeredAbilityImpl;
|
|||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
|
|
@ -44,10 +43,10 @@ import mage.game.permanent.Permanent;
|
|||
public class LandfallAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public LandfallAbility(Effect effect, boolean optional) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
this(Zone.BATTLEFIELD, effect, optional);
|
||||
}
|
||||
|
||||
public LandfallAbility ( Zone zone, Effect effect, Boolean optional ) {
|
||||
public LandfallAbility (Zone zone, Effect effect, Boolean optional ) {
|
||||
super(zone, effect, optional);
|
||||
}
|
||||
|
||||
|
|
@ -63,15 +62,12 @@ public class LandfallAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null && permanent.getCardType().contains(CardType.LAND) && permanent.getControllerId().equals(this.controllerId)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return permanent != null && permanent.getCardType().contains(CardType.LAND) && permanent.getControllerId().equals(this.controllerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Landfall - Whenever a land enters the battlefield under your control, " + super.getRule();
|
||||
return "<i>Landfall</i> — Whenever a land enters the battlefield under your control, " + super.getRule();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ package mage.abilities.condition.common;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.game.Game;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.common.LandfallWatcher;
|
||||
|
||||
/**
|
||||
* @author Loki
|
||||
*/
|
||||
public class LandfallCondition implements Condition {
|
||||
private static LandfallCondition instance = new LandfallCondition();
|
||||
private final static LandfallCondition instance = new LandfallCondition();
|
||||
|
||||
public static LandfallCondition getInstance() {
|
||||
return instance;
|
||||
|
|
@ -20,7 +20,7 @@ public class LandfallCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Watcher watcher = game.getState().getWatchers().get("LandPlayed", source.getControllerId());
|
||||
return watcher.conditionMet();
|
||||
LandfallWatcher watcher = (LandfallWatcher) game.getState().getWatchers().get("LandPlayed");
|
||||
return watcher != null && watcher.landPlayed(source.getControllerId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public abstract class Watcher implements Serializable {
|
|||
public boolean conditionMet() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
|
||||
public void reset() {
|
||||
condition = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package mage.watchers.common;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
|
|
@ -13,12 +16,15 @@ import mage.watchers.Watcher;
|
|||
*/
|
||||
public class LandfallWatcher extends Watcher {
|
||||
|
||||
Set<UUID> playerPlayedLand = new HashSet<>();
|
||||
|
||||
public LandfallWatcher() {
|
||||
super("LandPlayed", WatcherScope.PLAYER);
|
||||
super("LandPlayed", WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public LandfallWatcher(final LandfallWatcher watcher) {
|
||||
super(watcher);
|
||||
playerPlayedLand.addAll(playerPlayedLand);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -28,15 +34,21 @@ public class LandfallWatcher extends Watcher {
|
|||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (condition == true) { //no need to check - condition has already occured
|
||||
return;
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent.getCardType().contains(CardType.LAND) && permanent.getControllerId().equals(this.controllerId)) {
|
||||
condition = true;
|
||||
if (permanent.getCardType().contains(CardType.LAND) && !playerPlayedLand.contains(event.getPlayerId())) {
|
||||
playerPlayedLand.add(event.getPlayerId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
playerPlayedLand.clear();
|
||||
super.reset();
|
||||
}
|
||||
|
||||
public boolean landPlayed(UUID playerId) {
|
||||
return playerPlayedLand.contains(playerId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue