mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Fixes and refactoring.
This commit is contained in:
parent
a38e441e08
commit
005c1a1954
9 changed files with 125 additions and 142 deletions
|
@ -31,23 +31,21 @@ package mage.sets.magic2011;
|
|||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Duration;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.WatcherImpl;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author North
|
||||
*/
|
||||
public class BloodcrazedGoblin extends CardImpl<BloodcrazedGoblin> {
|
||||
|
||||
|
@ -74,40 +72,33 @@ public class BloodcrazedGoblin extends CardImpl<BloodcrazedGoblin> {
|
|||
|
||||
}
|
||||
|
||||
class BloodcrazedGoblinEffect extends ReplacementEffectImpl<BloodcrazedGoblinEffect> {
|
||||
class BloodcrazedGoblinEffect extends RestrictionEffect<BloodcrazedGoblinEffect> {
|
||||
|
||||
public BloodcrazedGoblinEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||
staticText = "{this} can't attack unless an opponent has been dealt damage this turn";
|
||||
}
|
||||
public BloodcrazedGoblinEffect() {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
staticText = "{this} can't attack unless an opponent has been dealt damage this turn";
|
||||
}
|
||||
|
||||
public BloodcrazedGoblinEffect(final BloodcrazedGoblinEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
public BloodcrazedGoblinEffect(final BloodcrazedGoblinEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BloodcrazedGoblinEffect copy() {
|
||||
return new BloodcrazedGoblinEffect(this);
|
||||
}
|
||||
@Override
|
||||
public BloodcrazedGoblinEffect copy() {
|
||||
return new BloodcrazedGoblinEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.DECLARE_ATTACKER && source.getSourceId().equals(event.getSourceId())) {
|
||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "DamagedOpponents");
|
||||
if (watcher != null)
|
||||
return !watcher.conditionMet();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canAttack(Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "DamagedOpponents");
|
||||
if (watcher != null) {
|
||||
return !watcher.conditionMet();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,98 +25,81 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.sets.magic2011;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Duration;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.abilities.keyword.IslandwalkAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.Filter.ComparisonScope;
|
||||
import mage.filter.common.FilterLandPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author North
|
||||
*/
|
||||
public class HarborSerpent extends CardImpl<HarborSerpent> {
|
||||
|
||||
public HarborSerpent(UUID ownerId) {
|
||||
super(ownerId, 56, "Harbor Serpent", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{4}{U}{U}");
|
||||
this.expansionSetCode = "M11";
|
||||
this.subtype.add("Serpent");
|
||||
this.color.setBlue(true);
|
||||
this.power = new MageInt(5);
|
||||
this.toughness = new MageInt(5);
|
||||
public HarborSerpent(UUID ownerId) {
|
||||
super(ownerId, 56, "Harbor Serpent", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{4}{U}{U}");
|
||||
this.expansionSetCode = "M11";
|
||||
this.subtype.add("Serpent");
|
||||
this.color.setBlue(true);
|
||||
this.power = new MageInt(5);
|
||||
this.toughness = new MageInt(5);
|
||||
|
||||
this.addAbility(new IslandwalkAbility());
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new HarborSerpentEffect()));
|
||||
}
|
||||
this.addAbility(new IslandwalkAbility());
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new HarborSerpentEffect()));
|
||||
}
|
||||
|
||||
public HarborSerpent(final HarborSerpent card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HarborSerpent copy() {
|
||||
return new HarborSerpent(this);
|
||||
}
|
||||
public HarborSerpent(final HarborSerpent card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HarborSerpent copy() {
|
||||
return new HarborSerpent(this);
|
||||
}
|
||||
}
|
||||
|
||||
class HarborSerpentEffect extends ReplacementEffectImpl<HarborSerpentEffect> {
|
||||
class HarborSerpentEffect extends RestrictionEffect<HarborSerpentEffect> {
|
||||
|
||||
private static final FilterLandPermanent filter = new FilterLandPermanent("Island");
|
||||
private final FilterLandPermanent filter = new FilterLandPermanent("Island");
|
||||
|
||||
static {
|
||||
filter.getSubtype().add("Island");
|
||||
filter.setScopeSubtype(ComparisonScope.Any);
|
||||
}
|
||||
public HarborSerpentEffect() {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
filter.getSubtype().add("Island");
|
||||
staticText = "{this} can't attack unless there are five or more Islands on the battlefield";
|
||||
}
|
||||
|
||||
public HarborSerpentEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||
staticText = "{this} can't attack unless there are five or more Islands on the battlefield";
|
||||
}
|
||||
public HarborSerpentEffect(final HarborSerpentEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
public HarborSerpentEffect(final HarborSerpentEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HarborSerpentEffect copy() {
|
||||
return new HarborSerpentEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.DECLARE_ATTACKER && source.getSourceId().equals(event.getSourceId())) {
|
||||
int count = game.getBattlefield().countAll(filter);
|
||||
if (count < 5)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public HarborSerpentEffect copy() {
|
||||
return new HarborSerpentEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAttack(Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
if (game.getBattlefield().countAll(filter) < 5) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import mage.abilities.effects.common.DrawCardControllerEffect;
|
|||
import mage.abilities.effects.common.continious.GainAbilityTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamagedEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
|
@ -86,7 +87,7 @@ class HuntersInsightTriggeredAbility extends TriggeredAbilityImpl<HuntersInsight
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if ((event.getType() == EventType.DAMAGED_PLAYER || event.getType() == EventType.DAMAGED_PLANESWALKER)
|
||||
&& event.getSourceId().equals(this.sourceId)) {
|
||||
&& event.getSourceId().equals(this.sourceId) && ((DamagedEvent) event).isCombatDamage()) {
|
||||
this.addEffect(new DrawCardControllerEffect(event.getAmount()));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import mage.abilities.keyword.DeathtouchAbility;
|
|||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamagedEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
@ -93,10 +94,11 @@ class VengefulPharaohTriggeredAbility extends TriggeredAbilityImpl<VengefulPhara
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if ((event.getType() == EventType.DAMAGED_PLAYER && event.getTargetId().equals(this.getControllerId()))) {
|
||||
if ((event.getType() == EventType.DAMAGED_PLAYER && event.getTargetId().equals(this.getControllerId()))
|
||||
&& ((DamagedEvent) event).isCombatDamage()) {
|
||||
return true;
|
||||
}
|
||||
if (event.getType() == EventType.DAMAGED_PLANESWALKER) {
|
||||
if (event.getType() == EventType.DAMAGED_PLANESWALKER && ((DamagedEvent) event).isCombatDamage()) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null && permanent.getControllerId().equals(this.getControllerId())) {
|
||||
return true;
|
||||
|
|
|
@ -33,13 +33,16 @@ import mage.Constants.Rarity;
|
|||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.abilities.keyword.TrampleAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamagedPlayerEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.token.EldraziSpawnToken;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -88,7 +91,8 @@ class RapaciousOneTriggeredAbility extends TriggeredAbilityImpl<RapaciousOneTrig
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.DAMAGED_PLAYER && event.getSourceId().equals(this.sourceId)) {
|
||||
if (event.getType() == EventType.DAMAGED_PLAYER && event.getSourceId().equals(this.sourceId)
|
||||
&& ((DamagedPlayerEvent) event).isCombatDamage()) {
|
||||
this.addEffect(new CreateTokenEffect(new EldraziSpawnToken(), event.getAmount()));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,9 @@ import java.util.UUID;
|
|||
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SpellCastTriggeredAbility;
|
||||
|
@ -39,27 +41,24 @@ import mage.abilities.costs.common.RemoveCountersSourceCost;
|
|||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.sets.alarareborn.FiligreeAngel;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Loki
|
||||
* @author Loki, North
|
||||
*/
|
||||
public class QuestForTheHolyRelic extends CardImpl<QuestForTheHolyRelic> {
|
||||
|
||||
|
||||
public QuestForTheHolyRelic(UUID ownerId) {
|
||||
super(ownerId, 33, "Quest for the Holy Relic", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{W}");
|
||||
this.expansionSetCode = "ZEN";
|
||||
|
@ -84,46 +83,48 @@ public class QuestForTheHolyRelic extends CardImpl<QuestForTheHolyRelic> {
|
|||
}
|
||||
}
|
||||
|
||||
class QuestForTheHolyRelicEffect extends SearchLibraryPutInPlayEffect {
|
||||
private static final FilterCard filter = new FilterCard("Equipment");
|
||||
class QuestForTheHolyRelicEffect extends OneShotEffect<QuestForTheHolyRelicEffect> {
|
||||
|
||||
static {
|
||||
filter.getSubtype().add("Equipment");
|
||||
filter.setScopeSubtype(Filter.ComparisonScope.Any);
|
||||
public QuestForTheHolyRelicEffect() {
|
||||
super(Outcome.PutCardInPlay);
|
||||
this.staticText = "Search your library for an Equipment card, put it onto the battlefield, and attach it to a creature you control. Then shuffle your library";
|
||||
}
|
||||
|
||||
QuestForTheHolyRelicEffect() {
|
||||
super(new TargetCardInLibrary(filter));
|
||||
staticText = "Search your library for an Equipment card, put it onto the battlefield, and attach it to a creature you control. Then shuffle your library";
|
||||
}
|
||||
|
||||
QuestForTheHolyRelicEffect(final QuestForTheHolyRelicEffect effect) {
|
||||
public QuestForTheHolyRelicEffect(final QuestForTheHolyRelicEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null && super.apply(game, source)) {
|
||||
Target target = new TargetControlledCreaturePermanent();
|
||||
if (player.choose(Constants.Outcome.Benefit, target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
Permanent permanent = game.getPermanent(target.getTargets().get(0));
|
||||
Permanent sourceEquipment = null;
|
||||
if (super.getTargets().size() > 0) {
|
||||
sourceEquipment = game.getPermanent(super.getTargets().get(0));
|
||||
}
|
||||
if (permanent != null && sourceEquipment != null) {
|
||||
return permanent.addAttachment(sourceEquipment.getId(), game);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuestForTheHolyRelicEffect copy() {
|
||||
return new QuestForTheHolyRelicEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FilterCard filter = new FilterCard("Equipment");
|
||||
filter.getSubtype().add("Equipment");
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(filter);
|
||||
if (player.searchLibrary(target, game)) {
|
||||
Card card = player.getLibrary().remove(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
card.putOntoBattlefield(game, Zone.LIBRARY, source.getId(), source.getControllerId());
|
||||
Permanent equipment = game.getPermanent(card.getId());
|
||||
|
||||
Target targetCreature = new TargetControlledCreaturePermanent();
|
||||
if (equipment != null && player.choose(Outcome.BoostCreature, targetCreature, game)) {
|
||||
Permanent permanent = game.getPermanent(targetCreature.getFirstTarget());
|
||||
permanent.addAttachment(equipment.getId(), game);
|
||||
}
|
||||
|
||||
player.shuffleLibrary(game);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import mage.Constants.Zone;
|
|||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamagedPlayerEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
@ -64,7 +65,8 @@ public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.DAMAGED_PLAYER && event.getSourceId().equals(this.sourceId)) {
|
||||
if (event.getType() == EventType.DAMAGED_PLAYER && event.getSourceId().equals(this.sourceId)
|
||||
&& ((DamagedPlayerEvent) event).isCombatDamage()) {
|
||||
if (setTargetPointer) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
|
|
|
@ -42,7 +42,7 @@ import mage.game.permanent.Permanent;
|
|||
public class MustBlockSourceTargetEffect extends RequirementEffect<MustBlockSourceTargetEffect> {
|
||||
|
||||
public MustBlockSourceTargetEffect() {
|
||||
this(Duration.WhileOnBattlefield);
|
||||
this(Duration.EndOfTurn);
|
||||
}
|
||||
|
||||
public MustBlockSourceTargetEffect(Duration duration) {
|
||||
|
|
|
@ -32,7 +32,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.TargetController;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
|
|
Loading…
Reference in a new issue