1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-12 17:00:08 -09:00

Updates to SacrificeEffect so that more than one target will actually be sacrificed

SOM cards.
This commit is contained in:
maurer.it 2011-01-08 12:24:16 -05:00
parent 55418f7ad9
commit e035e240f9
5 changed files with 460 additions and 7 deletions
Mage.Sets/src/mage/sets/scarsofmirrodin
Mage/src/mage/abilities/effects/common

View file

@ -0,0 +1,111 @@
/*
* 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.scarsofmirrodin;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.condition.common.Metalcraft;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.SacrificeEffect;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.target.TargetPlayer;
/**
*
* @author maurer.it_at_gmail.com
*/
public class DispenseJustice extends CardImpl<DispenseJustice> {
public DispenseJustice (UUID ownerId) {
super(ownerId, 5, "Dispense Justice", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{2}{W}");
this.expansionSetCode = "SOM";
this.color.setWhite(true);
this.getSpellAbility().addEffect(new DispenseJusticeEffect());
this.getSpellAbility().addTarget(new TargetPlayer());
}
public DispenseJustice (final DispenseJustice card) {
super(card);
}
@Override
public DispenseJustice copy() {
return new DispenseJustice(this);
}
}
class DispenseJusticeEffect extends OneShotEffect<DispenseJusticeEffect> {
private static final String effectText = "Target player sacrifices an attacking creature.\r\n\r\n"
+ "Metalcraft - That player sacrifices two attacking creatures instead if you control three or more artifacts";
private static final FilterCreaturePermanent filter;
static {
filter = new FilterCreaturePermanent();
filter.setUseAttacking(true);
filter.setAttacking(true);
}
DispenseJusticeEffect ( ) {
super(Outcome.Sacrifice);
}
DispenseJusticeEffect ( DispenseJusticeEffect effect ) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
if ( Metalcraft.getInstance().apply(game, source) ) {
return new SacrificeEffect(filter, 2, effectText).apply(game, source);
}
else {
return new SacrificeEffect(filter, 1, effectText).apply(game, source);
}
}
@Override
public DispenseJusticeEffect copy() {
return new DispenseJusticeEffect(this);
}
@Override
public String getText(Ability source) {
return effectText;
}
}

View file

@ -0,0 +1,143 @@
/*
* 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.scarsofmirrodin;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnFromExileEffect;
import mage.abilities.keyword.VigilanceAbility;
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.target.Target;
import mage.target.TargetPermanent;
/**
*
* @author maurer.it_at_gmail.com
*/
public class GlimmerpointStag extends CardImpl<GlimmerpointStag> {
public GlimmerpointStag(UUID ownerId) {
super(ownerId, 9, "Glimmerpoint Stag", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{2}{W}{W}");
this.expansionSetCode = "SOM";
this.subtype.add("Elk");
this.color.setWhite(true);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
this.addAbility(VigilanceAbility.getInstance());
Target etbTarget = new TargetPermanent();
etbTarget.setRequired(true);
Ability etbAbility = new EntersBattlefieldTriggeredAbility(new GlimmerpointStagEffect());
etbAbility.addTarget(etbTarget);
this.addAbility(etbAbility);
}
public GlimmerpointStag(final GlimmerpointStag card) {
super(card);
}
@Override
public GlimmerpointStag copy() {
return new GlimmerpointStag(this);
}
}
class GlimmerpointStagEffect extends OneShotEffect<GlimmerpointStagEffect> {
private static final String effectText = "exile another target permanent. Return that card to the battlefield under its owner's control at the beginning of the next end step";
GlimmerpointStagEffect ( ) {
super(Outcome.Benefit);
}
GlimmerpointStagEffect(GlimmerpointStagEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
if (permanent.moveToExile(source.getSourceId(), "Glimmerpoint Stag Exile", source.getId(), game)) {
//create delayed triggered ability
GlimmerpointStagDelayedTriggeredAbility delayedAbility = new GlimmerpointStagDelayedTriggeredAbility(source.getSourceId());
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
game.addDelayedTriggeredAbility(delayedAbility);
return true;
}
}
return false;
}
@Override
public GlimmerpointStagEffect copy() {
return new GlimmerpointStagEffect(this);
}
@Override
public String getText(Ability source) {
return effectText;
}
}
class GlimmerpointStagDelayedTriggeredAbility extends DelayedTriggeredAbility<GlimmerpointStagDelayedTriggeredAbility> {
GlimmerpointStagDelayedTriggeredAbility ( UUID exileId ) {
super(new ReturnFromExileEffect(exileId, Zone.BATTLEFIELD));
}
GlimmerpointStagDelayedTriggeredAbility(GlimmerpointStagDelayedTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == EventType.END_TURN_STEP_PRE) {
return true;
}
return false;
}
@Override
public GlimmerpointStagDelayedTriggeredAbility copy() {
return new GlimmerpointStagDelayedTriggeredAbility(this);
}
}

View file

@ -0,0 +1,127 @@
/*
* 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.scarsofmirrodin;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
/**
*
* @author maurer.it_at_gmail.com
*/
public class GlintHawk extends CardImpl<GlintHawk> {
public GlintHawk(UUID ownerId) {
super(ownerId, 10, "Glint Hawk", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{W}");
this.expansionSetCode = "SOM";
this.subtype.add("Bird");
this.color.setWhite(true);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
this.addAbility(FlyingAbility.getInstance());
this.addAbility(new EntersBattlefieldTriggeredAbility(new GlintHawkEffect()));
}
public GlintHawk(final GlintHawk card) {
super(card);
}
@Override
public GlintHawk copy() {
return new GlintHawk(this);
}
}
class GlintHawkEffect extends OneShotEffect<GlintHawkEffect> {
private static final FilterControlledPermanent filter;
private static final String effectText = "When Glint Hawk enters the battlefield, sacrifice it unless you return an artifact you control to its owner's hand";
static {
filter = new FilterControlledPermanent();
filter.getCardType().add(CardType.ARTIFACT);
}
GlintHawkEffect ( ) {
super(Outcome.Sacrifice);
}
GlintHawkEffect ( GlintHawkEffect effect ) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
boolean targetChosen = false;
Player player = game.getPlayer(source.getControllerId());
TargetPermanent target = new TargetPermanent(1, 1, filter, false);
if (target.canChoose(player.getId(), game)) {
player.choose(Outcome.Sacrifice, target, game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if ( permanent != null ) {
targetChosen = true;
permanent.moveToZone(Zone.HAND, this.getId(), game, false);
}
}
if ( !targetChosen ) {
new SacrificeSourceEffect().apply(game, source);
}
return false;
}
@Override
public GlintHawkEffect copy() {
return new GlintHawkEffect(this);
}
@Override
public String getText(Ability source) {
return effectText;
}
}

View file

@ -0,0 +1,70 @@
/*
* 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.scarsofmirrodin;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
/**
* TODO: Javadoc me
*
* @author maurer.it_at_gmail.com
*/
public class KembasSkyguard extends CardImpl<KembasSkyguard> {
public KembasSkyguard(UUID ownerId) {
super(ownerId, 13, "Kemba's Skyguard", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{W}{W}");
this.expansionSetCode = "SOM";
this.subtype.add("Cat");
this.subtype.add("Knight");
this.color.setWhite(true);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
this.addAbility(FlyingAbility.getInstance());
this.addAbility(new EntersBattlefieldTriggeredAbility(new GainLifeEffect(2)));
}
public KembasSkyguard(final KembasSkyguard card) {
super(card);
}
@Override
public KembasSkyguard copy() {
return new KembasSkyguard(this);
}
}

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.effects.common;
import java.util.UUID;
import mage.Constants.Outcome;
import mage.Constants.TargetController;
import mage.abilities.Ability;
@ -60,10 +61,6 @@ public class SacrificeEffect extends OneShotEffect<SacrificeEffect>{
this.count = effect.count;
this.preText = effect.preText;
}
public void setCount ( int count ) {
this.count = count;
}
@Override
public boolean apply(Game game, Ability source) {
@ -74,15 +71,20 @@ public class SacrificeEffect extends OneShotEffect<SacrificeEffect>{
//A spell or ability could have removed the only legal target this player
//had, if thats the case this ability should fizzle.
if (target.canChoose(player.getId(), game)) {
boolean abilityApplied = false;
while (!target.isChosen()) {
player.choose(Outcome.Sacrifice, target, game);
}
Permanent permanent = game.getPermanent(target.getFirstTarget());
for ( int idx = 0; idx < target.getTargets().size(); idx++) {
Permanent permanent = game.getPermanent((UUID)target.getTargets().get(idx));
if ( permanent != null ) {
return permanent.sacrifice(source.getId(), game);
if ( permanent != null ) {
abilityApplied |= permanent.sacrifice(source.getId(), game);
}
}
return abilityApplied;
}
return false;
}