mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
Sheoldred, Whispering One and refactoring and make more generic BeginningOfCntrolledUpkeepTriggeredAbility
This commit is contained in:
parent
61ce0ffb6b
commit
b9f4f7abf4
9 changed files with 152 additions and 55 deletions
|
@ -29,19 +29,18 @@
|
|||
package mage.sets.conflux;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Duration;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfControllerUpkeepTriggeredAbility;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.effects.common.ReturnToHandTargetEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
/**
|
||||
|
@ -64,7 +63,7 @@ public class Esperzoa extends CardImpl<Esperzoa> {
|
|||
this.power = new MageInt(4);
|
||||
this.toughness = new MageInt(3);
|
||||
this.addAbility(FlyingAbility.getInstance());
|
||||
Ability ability = new BeginningOfControllerUpkeepTriggeredAbility(new ReturnToHandTargetEffect(), false);
|
||||
Ability ability = new BeginningOfUpkeepTriggeredAbility(new ReturnToHandTargetEffect(), Constants.TargetController.YOU, false);
|
||||
TargetControlledPermanent t = new TargetControlledPermanent(filter);
|
||||
t.setRequired(true);
|
||||
ability.addTarget(t);
|
||||
|
|
|
@ -29,11 +29,13 @@
|
|||
package mage.sets.mirrodinbesieged;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfControllerUpkeepTriggeredAbility;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.counters.CounterType;
|
||||
|
@ -53,7 +55,7 @@ public class VedalkenInfuser extends CardImpl<VedalkenInfuser> {
|
|||
this.color.setBlue(true);
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(4);
|
||||
Ability ability = new BeginningOfControllerUpkeepTriggeredAbility(new AddCountersTargetEffect(CounterType.CHARGE.createInstance()), true);
|
||||
Ability ability = new BeginningOfUpkeepTriggeredAbility(new AddCountersTargetEffect(CounterType.CHARGE.createInstance()), Constants.TargetController.YOU, true);
|
||||
ability.addTarget(new TargetArtifactPermanent());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.sets.newphyrexia;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
|
||||
import mage.abilities.effects.common.SacrificeEffect;
|
||||
import mage.abilities.keyword.SwampwalkAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Loki
|
||||
*/
|
||||
public class SheoldredWhisperingOne extends CardImpl<SheoldredWhisperingOne> {
|
||||
|
||||
public SheoldredWhisperingOne (UUID ownerId) {
|
||||
super(ownerId, 73, "Sheoldred, Whispering One", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{5}{B}{B}");
|
||||
this.expansionSetCode = "NPH";
|
||||
this.supertype.add("Legendary");
|
||||
this.subtype.add("Praetor");
|
||||
this.color.setBlack(true);
|
||||
this.power = new MageInt(6);
|
||||
this.toughness = new MageInt(6);
|
||||
this.addAbility(new SwampwalkAbility());
|
||||
Ability ability = new BeginningOfUpkeepTriggeredAbility(new ReturnFromGraveyardToBattlefieldTargetEffect(false), Constants.TargetController.YOU, false);
|
||||
ability.addTarget(new TargetCardInYourGraveyard(new FilterCreatureCard()));
|
||||
this.addAbility(ability);
|
||||
ability = new BeginningOfUpkeepTriggeredAbility(new SacrificeEffect(new FilterCreaturePermanent(), 1, ""), Constants.TargetController.OPPONENT, false);
|
||||
ability.addTarget(new TargetPlayer());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
public SheoldredWhisperingOne (final SheoldredWhisperingOne card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheoldredWhisperingOne copy() {
|
||||
return new SheoldredWhisperingOne(this);
|
||||
}
|
||||
|
||||
}
|
|
@ -34,7 +34,7 @@ import mage.Constants;
|
|||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfControllerUpkeepTriggeredAbility;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.SacrificeTargetEffect;
|
||||
|
@ -63,7 +63,7 @@ public class DemonicAppetite extends CardImpl<DemonicAppetite> {
|
|||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||
this.addAbility(ability);
|
||||
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new BoostEnchantedEffect(3, 3, Constants.Duration.WhileOnBattlefield)));
|
||||
ability = new BeginningOfControllerUpkeepTriggeredAbility(new SacrificeTargetEffect(), false);
|
||||
ability = new BeginningOfUpkeepTriggeredAbility(new SacrificeTargetEffect(), Constants.TargetController.YOU, false);
|
||||
ability.addTarget(new TargetControlledCreaturePermanent());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ import mage.Constants.CardType;
|
|||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfControllerUpkeepTriggeredAbility;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
|
@ -56,7 +56,7 @@ public class GoldenUrn extends CardImpl<GoldenUrn> {
|
|||
public GoldenUrn (UUID ownerId) {
|
||||
super(ownerId, 158, "Golden Urn", Rarity.COMMON, new CardType[]{CardType.ARTIFACT}, "{1}");
|
||||
this.expansionSetCode = "SOM";
|
||||
this.addAbility(new BeginningOfControllerUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), true));
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), Constants.TargetController.YOU, true));
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GoldenUrnEffect(), new TapSourceCost());
|
||||
ability.addCost(new SacrificeSourceCost());
|
||||
this.addAbility(ability);
|
||||
|
|
|
@ -33,16 +33,13 @@ import java.util.UUID;
|
|||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.BeginningOfControllerUpkeepTriggeredAbility;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.token.Token;
|
||||
|
||||
|
@ -61,7 +58,7 @@ public class KembaKhaRegent extends CardImpl<KembaKhaRegent> {
|
|||
this.color.setWhite(true);
|
||||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(4);
|
||||
this.addAbility(new BeginningOfControllerUpkeepTriggeredAbility(new KembaKhaRegentEffect(), false));
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new KembaKhaRegentEffect(), Constants.TargetController.YOU, false));
|
||||
}
|
||||
|
||||
public KembaKhaRegent (final KembaKhaRegent card) {
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
*/
|
||||
package mage.sets.zendikar;
|
||||
|
||||
import mage.abilities.common.BeginningOfControllerUpkeepTriggeredAbility;
|
||||
import mage.Constants;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
|
@ -55,11 +56,11 @@ public class VampireLacerator extends CardImpl<VampireLacerator> {
|
|||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(2);
|
||||
|
||||
this.addAbility(new BeginningOfControllerUpkeepTriggeredAbility(
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
|
||||
new ConditionalOneShotEffect(
|
||||
new LoseLifeSourceEffect(1),
|
||||
new Unless( new TenOrLessLife(AN_OPPONENT) ),
|
||||
"you lose 1 life unless an opponent has 10 or less life"), false));
|
||||
"you lose 1 life unless an opponent has 10 or less life"), Constants.TargetController.YOU, false));
|
||||
}
|
||||
|
||||
public VampireLacerator(final VampireLacerator card) {
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
public class BeginningOfControllerUpkeepTriggeredAbility extends TriggeredAbilityImpl<BeginningOfControllerUpkeepTriggeredAbility> {
|
||||
|
||||
public BeginningOfControllerUpkeepTriggeredAbility(Effect effect, boolean isOptional) {
|
||||
super(Constants.Zone.BATTLEFIELD, effect, isOptional);
|
||||
}
|
||||
|
||||
public BeginningOfControllerUpkeepTriggeredAbility(final BeginningOfControllerUpkeepTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeginningOfControllerUpkeepTriggeredAbility copy() {
|
||||
return new BeginningOfControllerUpkeepTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE && event.getPlayerId().equals(this.controllerId)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "At the beginning of your upkeep, " + effects.getText(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import com.sun.org.apache.bcel.internal.generic.CASTORE;
|
||||
import mage.Constants;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
public class BeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl<BeginningOfUpkeepTriggeredAbility> {
|
||||
private Constants.TargetController targetController;
|
||||
|
||||
public BeginningOfUpkeepTriggeredAbility(Effect effect, Constants.TargetController targetController, boolean isOptional) {
|
||||
super(Constants.Zone.BATTLEFIELD, effect, isOptional);
|
||||
this.targetController = targetController;
|
||||
}
|
||||
|
||||
public BeginningOfUpkeepTriggeredAbility(final BeginningOfUpkeepTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.targetController = ability.targetController;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeginningOfUpkeepTriggeredAbility copy() {
|
||||
return new BeginningOfUpkeepTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE) {
|
||||
switch (targetController) {
|
||||
case YOU:
|
||||
return event.getPlayerId().equals(this.controllerId);
|
||||
case OPPONENT:
|
||||
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
|
||||
this.getTargets().get(0).add(event.getPlayerId(), game); //TODO add target pushing checking to constructor
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
switch (targetController) {
|
||||
case YOU:
|
||||
return "At the beginning of your upkeep, " + effects.getText(this);
|
||||
case OPPONENT:
|
||||
return "At the beginning of each opponent's upkeep, " + effects.getText(this);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue