mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
ROE cards and AnnihilatorAbility
This commit is contained in:
parent
9aca4b0284
commit
1d52177968
4 changed files with 415 additions and 0 deletions
|
@ -14,6 +14,7 @@ Mage.Server.Plugins/Mage.Game.TwoPlayerDuel/target
|
|||
Mage.Server.Plugins/Mage.Player.AI/target
|
||||
Mage.Server.Plugins/Mage.Player.AIMinimax/target
|
||||
Mage.Server.Plugins/Mage.Player.Human/target
|
||||
Mage.Server.Plugins/Mage.Draft.8PlayerBooster/target
|
||||
Mage.Server/target
|
||||
Mage.Sets/target
|
||||
Mage.Tests/target
|
||||
|
|
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
* 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.riseoftheeldrazi;
|
||||
|
||||
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.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.ZoneChangeTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||
import mage.abilities.keyword.AnnihilatorAbility;
|
||||
import mage.abilities.keyword.IndestructibleAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author maurer.it_at_gmail.com
|
||||
*/
|
||||
public class UlamogtheInfiniteGyre extends CardImpl<UlamogtheInfiniteGyre> {
|
||||
|
||||
private static final String effectText = "When Ulamog is put into a graveyard from anywhere, its owner shuffles his or her graveyard into his or her library";
|
||||
|
||||
public UlamogtheInfiniteGyre(UUID ownerId) {
|
||||
super(ownerId, 12, "Ulamog, the Infinite Gyre", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{11}");
|
||||
this.expansionSetCode = "ROE";
|
||||
this.supertype.add("Legendary");
|
||||
this.subtype.add("Eldrazi");
|
||||
|
||||
this.power = new MageInt(10);
|
||||
this.toughness = new MageInt(10);
|
||||
|
||||
this.addAbility(new UlamogtheInfiniteGyreDestroyOnCastAbility());
|
||||
this.addAbility(new AnnihilatorAbility(4));
|
||||
this.addAbility(IndestructibleAbility.getInstance());
|
||||
this.addAbility(new ZoneChangeTriggeredAbility(Zone.GRAVEYARD, new UlamogtheInfiniteGyreEnterGraveyardEffect(), effectText, false));
|
||||
}
|
||||
|
||||
public UlamogtheInfiniteGyre(final UlamogtheInfiniteGyre card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UlamogtheInfiniteGyre copy() {
|
||||
return new UlamogtheInfiniteGyre(this);
|
||||
}
|
||||
}
|
||||
|
||||
class UlamogtheInfiniteGyreDestroyOnCastAbility extends TriggeredAbilityImpl<UlamogtheInfiniteGyreDestroyOnCastAbility> {
|
||||
|
||||
private static final String abilityText = "When you cast Ulamog, the Infinite Gyre, destroy target permanent";
|
||||
|
||||
UlamogtheInfiniteGyreDestroyOnCastAbility ( ) {
|
||||
super(Zone.STACK, new DestroyTargetEffect());
|
||||
this.addTarget(new TargetPermanent());
|
||||
}
|
||||
|
||||
UlamogtheInfiniteGyreDestroyOnCastAbility(UlamogtheInfiniteGyreDestroyOnCastAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if ( event.getType() == EventType.SPELL_CAST ) {
|
||||
Spell spell = (Spell)game.getObject(event.getTargetId());
|
||||
if ( this.getSourceId().equals(spell.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UlamogtheInfiniteGyreDestroyOnCastAbility copy() {
|
||||
return new UlamogtheInfiniteGyreDestroyOnCastAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return abilityText;
|
||||
}
|
||||
}
|
||||
|
||||
class UlamogtheInfiniteGyreEnterGraveyardEffect extends OneShotEffect<UlamogtheInfiniteGyreEnterGraveyardEffect> {
|
||||
|
||||
UlamogtheInfiniteGyreEnterGraveyardEffect ( ) {
|
||||
super(Outcome.Benefit);
|
||||
}
|
||||
|
||||
UlamogtheInfiniteGyreEnterGraveyardEffect(UlamogtheInfiniteGyreEnterGraveyardEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
/*Card permanent = (Card)game.getObject(source.getSourceId());*/
|
||||
if (player != null /* && permanent != null */) {
|
||||
/*permanent.moveToZone(Zone.LIBRARY, source.getId(), game, true);*/
|
||||
player.getLibrary().addAll(player.getGraveyard().getCards(game), game);
|
||||
player.getGraveyard().clear();
|
||||
player.getLibrary().shuffle();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UlamogtheInfiniteGyreEnterGraveyardEffect copy() {
|
||||
return new UlamogtheInfiniteGyreEnterGraveyardEffect(this);
|
||||
}
|
||||
}
|
127
Mage.Sets/src/mage/sets/worldwake/EyeofUgin.java
Normal file
127
Mage.Sets/src/mage/sets/worldwake/EyeofUgin.java
Normal 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.worldwake;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.common.SearchLibraryRevealPutInHandEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
/**
|
||||
* TODO: Implement this better.
|
||||
*
|
||||
* @author maurer.it_at_gmail.com
|
||||
*/
|
||||
public class EyeofUgin extends CardImpl<EyeofUgin> {
|
||||
|
||||
private static final FilterCreatureCard filter;
|
||||
|
||||
static {
|
||||
filter = new FilterCreatureCard();
|
||||
filter.setColorless(true);
|
||||
filter.setUseColorless(true);
|
||||
}
|
||||
|
||||
public EyeofUgin (UUID ownerId) {
|
||||
super(ownerId, 136, "Eye of Ugin", Rarity.MYTHIC, new CardType[]{CardType.LAND}, null);
|
||||
this.expansionSetCode = "WWK";
|
||||
this.supertype.add("Legendary");
|
||||
this.subtype.add("Land");
|
||||
|
||||
this.addAbility(new EyeofUginCostReductionAbility());
|
||||
Ability searchAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SearchLibraryRevealPutInHandEffect(new TargetCardInLibrary(filter)), new TapSourceCost());
|
||||
searchAbility.addCost(new ManaCostsImpl("{7}"));
|
||||
this.addAbility(searchAbility);
|
||||
}
|
||||
|
||||
public EyeofUgin (final EyeofUgin card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EyeofUgin copy() {
|
||||
return new EyeofUgin(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implemented as a {@link TriggeredAbilityImpl} for now as there currently is
|
||||
* no other way of interacting with a cards casting cost from an external object.
|
||||
* This ability has no effect as of right now until a better way of implementing
|
||||
* this form of object interaction is designed and implemented.
|
||||
*
|
||||
* @author maurer.it_at_gmail.com
|
||||
*/
|
||||
class EyeofUginCostReductionAbility extends TriggeredAbilityImpl<EyeofUginCostReductionAbility> {
|
||||
|
||||
EyeofUginCostReductionAbility() {
|
||||
super(Zone.BATTLEFIELD, null);
|
||||
}
|
||||
|
||||
EyeofUginCostReductionAbility ( EyeofUginCostReductionAbility effect ) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if ( event.getType() == EventType.ZONE_CHANGE &&
|
||||
event.getPlayerId().equals(this.getControllerId()) &&
|
||||
((ZoneChangeEvent)event).getToZone() == Zone.STACK )
|
||||
{
|
||||
Card card = (Card)game.getObject(event.getTargetId());
|
||||
Spell spell = (Spell)game.getObject(event.getSourceId());
|
||||
if ( card.getSubtype().contains("Eldrazi") ) {
|
||||
ManaCosts costs = spell.getSpellAbility().getManaCosts();
|
||||
costs.load("{" + (card.getManaCost().convertedManaCost() - 2) + "}");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EyeofUginCostReductionAbility copy() {
|
||||
return new EyeofUginCostReductionAbility(this);
|
||||
}
|
||||
}
|
139
Mage/src/mage/abilities/keyword/AnnihilatorAbility.java
Normal file
139
Mage/src/mage/abilities/keyword/AnnihilatorAbility.java
Normal file
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
* 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.abilities.keyword;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.TargetController;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
/**
|
||||
* TODO: Javadoc me
|
||||
*
|
||||
* @author maurer.it_at_gmail.com
|
||||
*/
|
||||
public class AnnihilatorAbility extends TriggeredAbilityImpl<AnnihilatorAbility> {
|
||||
|
||||
int count;
|
||||
|
||||
public AnnihilatorAbility ( int count ) {
|
||||
super(Zone.BATTLEFIELD, new AnnihilatorEffect(count), false);
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public AnnihilatorAbility ( final AnnihilatorAbility ability ) {
|
||||
super(ability);
|
||||
this.count = ability.count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger ( GameEvent event, Game game ) {
|
||||
if ( event.getType() == EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId()) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule ( ) {
|
||||
return "Annihilator " + count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnihilatorAbility copy ( ) {
|
||||
return new AnnihilatorAbility(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class AnnihilatorEffect extends OneShotEffect<AnnihilatorEffect> {
|
||||
|
||||
private final int count;
|
||||
private static final FilterControlledPermanent filter;
|
||||
|
||||
static {
|
||||
filter = new FilterControlledPermanent();
|
||||
}
|
||||
|
||||
AnnihilatorEffect ( int count ) {
|
||||
super(Outcome.Sacrifice);
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
AnnihilatorEffect(AnnihilatorEffect effect) {
|
||||
super(effect);
|
||||
this.count = effect.count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
UUID defenderId = game.getCombat().getDefendingPlayer(source.getSourceId());
|
||||
Player player = game.getPlayer(defenderId);
|
||||
|
||||
filter.setTargetController(TargetController.YOU);
|
||||
Target target = new TargetControlledPermanent(1, count, filter, false);
|
||||
|
||||
//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() && target.canChoose(player.getId(), game)) {
|
||||
player.choose(Outcome.Sacrifice, target, game);
|
||||
}
|
||||
|
||||
for ( int idx = 0; idx < target.getTargets().size(); idx++) {
|
||||
Permanent permanent = game.getPermanent((UUID)target.getTargets().get(idx));
|
||||
|
||||
if ( permanent != null ) {
|
||||
abilityApplied |= permanent.sacrifice(source.getId(), game);
|
||||
}
|
||||
}
|
||||
|
||||
return abilityApplied;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnihilatorEffect copy() {
|
||||
return new AnnihilatorEffect(this);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue