mirror of
https://github.com/correl/mage.git
synced 2025-04-02 03:18:09 -09:00
Implemented Gauntlets of Chaos
This commit is contained in:
parent
58a829de0e
commit
2fdfaa9138
6 changed files with 235 additions and 0 deletions
Mage.Sets/src/mage
Mage/src/main/java/mage/abilities/effects/common/continuous
211
Mage.Sets/src/mage/cards/g/GauntletsOfChaos.java
Normal file
211
Mage.Sets/src/mage/cards/g/GauntletsOfChaos.java
Normal file
|
@ -0,0 +1,211 @@
|
|||
/*
|
||||
* 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.cards.g;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.common.continuous.ExchangeControlTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2 & L_J
|
||||
*/
|
||||
public class GauntletsOfChaos extends CardImpl {
|
||||
|
||||
public GauntletsOfChaos(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{5}");
|
||||
|
||||
// {5}, Sacrifice Gauntlets of Chaos: Exchange control of target artifact, creature, or land you control and target permanent an opponent controls that shares one of those types with it. If those permanents are exchanged this way, destroy all Auras attached to them.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExchangeControlTargetEffect(Duration.EndOfGame,
|
||||
"exchange control of target artifact, creature, or land you control and target permanent an opponent controls that shares one of those types with it."
|
||||
+ " If those permanents are exchanged this way, destroy all Auras attached to them", false, true, true),
|
||||
new ManaCostsImpl("{5}")
|
||||
);
|
||||
ability.addCost(new SacrificeSourceCost());
|
||||
ability.addTarget(new GauntletsOfChaosFirstTarget());
|
||||
ability.addTarget(new GauntletsOfChaosSecondTarget());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
public GauntletsOfChaos(final GauntletsOfChaos card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GauntletsOfChaos copy() {
|
||||
return new GauntletsOfChaos(this);
|
||||
}
|
||||
}
|
||||
|
||||
class GauntletsOfChaosFirstTarget extends TargetControlledPermanent {
|
||||
|
||||
public GauntletsOfChaosFirstTarget() {
|
||||
super();
|
||||
this.filter = this.filter.copy();
|
||||
filter.add(Predicates.or(
|
||||
new CardTypePredicate(CardType.ARTIFACT),
|
||||
new CardTypePredicate(CardType.CREATURE),
|
||||
new CardTypePredicate(CardType.LAND)));
|
||||
setTargetName("artifact, creature, or land you control");
|
||||
}
|
||||
|
||||
public GauntletsOfChaosFirstTarget(final GauntletsOfChaosFirstTarget target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
|
||||
if (super.canTarget(controllerId, id, source, game)) {
|
||||
Set<CardType> cardTypes = getOpponentPermanentCardTypes(source.getSourceId(), controllerId, game);
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
for (CardType type : permanent.getCardType()) {
|
||||
if (cardTypes.contains(type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
// get all cardtypes from opponents permanents
|
||||
Set<CardType> cardTypes = getOpponentPermanentCardTypes(sourceId, sourceControllerId, game);
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
for (CardType type : permanent.getCardType()) {
|
||||
if (cardTypes.contains(type)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GauntletsOfChaosFirstTarget copy() {
|
||||
return new GauntletsOfChaosFirstTarget(this);
|
||||
}
|
||||
|
||||
private EnumSet<CardType> getOpponentPermanentCardTypes(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Player controller = game.getPlayer(sourceControllerId);
|
||||
EnumSet<CardType> cardTypes =EnumSet.noneOf(CardType.class);
|
||||
if (controller != null) {
|
||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(sourceControllerId, game)) {
|
||||
if (controller.hasOpponent(permanent.getControllerId(), game)) {
|
||||
cardTypes.addAll(permanent.getCardType());
|
||||
}
|
||||
}
|
||||
}
|
||||
return cardTypes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class GauntletsOfChaosSecondTarget extends TargetPermanent {
|
||||
|
||||
private Permanent firstTarget = null;
|
||||
|
||||
public GauntletsOfChaosSecondTarget() {
|
||||
super();
|
||||
this.filter = this.filter.copy();
|
||||
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
||||
setTargetName("permanent an opponent controls that shares one of those types with it");
|
||||
}
|
||||
|
||||
public GauntletsOfChaosSecondTarget(final GauntletsOfChaosSecondTarget target) {
|
||||
super(target);
|
||||
this.firstTarget = target.firstTarget;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
if (super.canTarget(id, source, game)) {
|
||||
Permanent target1 = game.getPermanent(source.getFirstTarget());
|
||||
Permanent opponentPermanent = game.getPermanent(id);
|
||||
if (target1 != null && opponentPermanent != null) {
|
||||
return target1.shareTypes(opponentPermanent);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
if (firstTarget != null) {
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (permanent.shareTypes(firstTarget)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseTarget(Outcome outcome, UUID playerId, Ability source, Game game) {
|
||||
firstTarget = game.getPermanent(source.getFirstTarget());
|
||||
return super.chooseTarget(Outcome.Damage, playerId, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GauntletsOfChaosSecondTarget copy() {
|
||||
return new GauntletsOfChaosSecondTarget(this);
|
||||
}
|
||||
}
|
|
@ -95,6 +95,7 @@ public class Chronicles extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Flash Flood", 21, Rarity.COMMON, mage.cards.f.FlashFlood.class));
|
||||
cards.add(new SetCardInfo("Fountain of Youth", 78, Rarity.COMMON, mage.cards.f.FountainOfYouth.class));
|
||||
cards.add(new SetCardInfo("Gabriel Angelfire", 111, Rarity.RARE, mage.cards.g.GabrielAngelfire.class));
|
||||
cards.add(new SetCardInfo("Gauntlets of Chaos", 79, Rarity.RARE, mage.cards.g.GauntletsOfChaos.class));
|
||||
cards.add(new SetCardInfo("Ghazban Ogre", 37, Rarity.COMMON, mage.cards.g.GhazbanOgre.class));
|
||||
cards.add(new SetCardInfo("Goblin Artisans", 48, Rarity.UNCOMMON, mage.cards.g.GoblinArtisans.class));
|
||||
cards.add(new SetCardInfo("Goblin Digging Team", 49, Rarity.COMMON, mage.cards.g.GoblinDiggingTeam.class));
|
||||
|
|
|
@ -192,6 +192,7 @@ public class FifthEdition extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Fyndhorn Elder", 159, Rarity.UNCOMMON, mage.cards.f.FyndhornElder.class));
|
||||
cards.add(new SetCardInfo("Game of Chaos", 232, Rarity.RARE, mage.cards.g.GameOfChaos.class));
|
||||
cards.add(new SetCardInfo("Gaseous Form", 90, Rarity.COMMON, mage.cards.g.GaseousForm.class));
|
||||
cards.add(new SetCardInfo("Gauntlets of Chaos", 373, Rarity.RARE, mage.cards.g.GauntletsOfChaos.class));
|
||||
cards.add(new SetCardInfo("Ghazban Ogre", 160, Rarity.COMMON, mage.cards.g.GhazbanOgre.class));
|
||||
cards.add(new SetCardInfo("Giant Growth", 161, Rarity.COMMON, mage.cards.g.GiantGrowth.class));
|
||||
cards.add(new SetCardInfo("Giant Spider", 162, Rarity.COMMON, mage.cards.g.GiantSpider.class));
|
||||
|
|
|
@ -132,6 +132,7 @@ public class Legends extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Frost Giant", 146, Rarity.UNCOMMON, mage.cards.f.FrostGiant.class));
|
||||
cards.add(new SetCardInfo("Gabriel Angelfire", 266, Rarity.RARE, mage.cards.g.GabrielAngelfire.class));
|
||||
cards.add(new SetCardInfo("Gaseous Form", 59, Rarity.COMMON, mage.cards.g.GaseousForm.class));
|
||||
cards.add(new SetCardInfo("Gauntlets of Chaos", 222, Rarity.RARE, mage.cards.g.GauntletsOfChaos.class));
|
||||
cards.add(new SetCardInfo("Ghosts of the Damned", 12, Rarity.COMMON, mage.cards.g.GhostsOfTheDamned.class));
|
||||
cards.add(new SetCardInfo("Giant Strength", 147, Rarity.COMMON, mage.cards.g.GiantStrength.class));
|
||||
cards.add(new SetCardInfo("Giant Turtle", 102, Rarity.COMMON, mage.cards.g.GiantTurtle.class));
|
||||
|
|
|
@ -126,6 +126,7 @@ public class MastersEditionIII extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Frost Giant", 101, Rarity.UNCOMMON, mage.cards.f.FrostGiant.class));
|
||||
cards.add(new SetCardInfo("Gabriel Angelfire", 148, Rarity.RARE, mage.cards.g.GabrielAngelfire.class));
|
||||
cards.add(new SetCardInfo("Gaea's Touch", 120, Rarity.UNCOMMON, mage.cards.g.GaeasTouch.class));
|
||||
cards.add(new SetCardInfo("Gauntlets of Chaos", 196, Rarity.RARE, mage.cards.g.GauntletsOfChaos.class));
|
||||
cards.add(new SetCardInfo("Ghostly Visit", 67, Rarity.COMMON, mage.cards.g.GhostlyVisit.class));
|
||||
cards.add(new SetCardInfo("Ghosts of the Damned", 68, Rarity.COMMON, mage.cards.g.GhostsOfTheDamned.class));
|
||||
cards.add(new SetCardInfo("Giant Growth", 121, Rarity.COMMON, mage.cards.g.GiantGrowth.class));
|
||||
|
|
|
@ -39,6 +39,9 @@ import mage.constants.Duration;
|
|||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
|
@ -50,6 +53,7 @@ public class ExchangeControlTargetEffect extends ContinuousEffectImpl {
|
|||
private String rule;
|
||||
private boolean withSource;
|
||||
private boolean withSecondTarget;
|
||||
private boolean destroyAttachedAuras;
|
||||
private Map<UUID, Integer> zoneChangeCounter = new HashMap<>();
|
||||
private Map<UUID, UUID> lockedControllers = new HashMap<>();
|
||||
|
||||
|
@ -62,9 +66,14 @@ public class ExchangeControlTargetEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
public ExchangeControlTargetEffect(Duration duration, String rule, boolean withSource, boolean withSecondTarget) {
|
||||
this(duration, rule, withSource, withSecondTarget, false);
|
||||
}
|
||||
|
||||
public ExchangeControlTargetEffect(Duration duration, String rule, boolean withSource, boolean withSecondTarget, boolean destroyAttachedAuras) {
|
||||
super(duration, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
|
||||
this.withSource = withSource;
|
||||
this.withSecondTarget = withSecondTarget;
|
||||
this.destroyAttachedAuras = destroyAttachedAuras;
|
||||
this.rule = rule;
|
||||
}
|
||||
|
||||
|
@ -73,6 +82,7 @@ public class ExchangeControlTargetEffect extends ContinuousEffectImpl {
|
|||
this.rule = effect.rule;
|
||||
this.withSource = effect.withSource;
|
||||
this.withSecondTarget = effect.withSecondTarget;
|
||||
this.destroyAttachedAuras = effect.destroyAttachedAuras;
|
||||
this.lockedControllers = new HashMap<>(effect.lockedControllers);
|
||||
this.zoneChangeCounter = new HashMap<>(effect.zoneChangeCounter);
|
||||
}
|
||||
|
@ -141,6 +151,16 @@ public class ExchangeControlTargetEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
permanent.changeControllerId(lockedControllers.get(permanent.getId()), game);
|
||||
permanent.getAbilities().setControllerId(lockedControllers.get(permanent.getId()));
|
||||
if (destroyAttachedAuras) {
|
||||
FilterPermanent filter = new FilterPermanent();
|
||||
filter.add(new SubtypePredicate(SubType.AURA));
|
||||
for (UUID attachmentId : new HashSet<>(permanent.getAttachments())) {
|
||||
Permanent attachment = game.getPermanent(attachmentId);
|
||||
if (attachment != null && filter.match(attachment, game)) {
|
||||
attachment.destroy(source.getSourceId(), game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!toDelete.isEmpty()) {
|
||||
for (UUID uuid : toDelete) {
|
||||
|
|
Loading…
Add table
Reference in a new issue