mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Implemented Role Reversal
This commit is contained in:
parent
b22443f422
commit
0b703b1be0
4 changed files with 112 additions and 12 deletions
94
Mage.Sets/src/mage/cards/r/RoleReversal.java
Normal file
94
Mage.Sets/src/mage/cards/r/RoleReversal.java
Normal file
|
@ -0,0 +1,94 @@
|
|||
package mage.cards.r;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
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.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class RoleReversal extends CardImpl {
|
||||
|
||||
public RoleReversal(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{U}{U}{R}");
|
||||
|
||||
// Exchange control of two target permanents that share a permanent type.
|
||||
this.getSpellAbility().addEffect(new ExchangeControlTargetEffect(
|
||||
Duration.EndOfGame, "Exchange control of two target permanents that share a permanent type."
|
||||
));
|
||||
this.getSpellAbility().addTarget(new TargetPermanentsThatShareCardType());
|
||||
}
|
||||
|
||||
private RoleReversal(final RoleReversal card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleReversal copy() {
|
||||
return new RoleReversal(this);
|
||||
}
|
||||
}
|
||||
|
||||
class TargetPermanentsThatShareCardType extends TargetPermanent {
|
||||
|
||||
TargetPermanentsThatShareCardType() {
|
||||
super(2, 2, StaticFilters.FILTER_PERMANENT, false);
|
||||
targetName = "permanents that share a permanent type";
|
||||
}
|
||||
|
||||
private TargetPermanentsThatShareCardType(final TargetPermanentsThatShareCardType target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
|
||||
if (super.canTarget(controllerId, id, source, game)) {
|
||||
if (!getTargets().isEmpty()) {
|
||||
Permanent targetOne = game.getPermanent(getTargets().get(0));
|
||||
Permanent targetTwo = game.getPermanent(id);
|
||||
if (targetOne == null || targetTwo == null) {
|
||||
return false;
|
||||
}
|
||||
return targetOne.shareTypes(targetTwo);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<CardType> cardTypes = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
if (targetSource != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
for (CardType cardType : permanent.getCardType()) {
|
||||
if (cardTypes.contains(cardType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
cardTypes.addAll(permanent.getCardType());
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetPermanentsThatShareCardType copy() {
|
||||
return new TargetPermanentsThatShareCardType(this);
|
||||
}
|
||||
}
|
|
@ -1,9 +1,6 @@
|
|||
|
||||
package mage.cards.s;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.common.continuous.ExchangeControlTargetEffect;
|
||||
|
@ -11,19 +8,22 @@ import mage.cards.CardImpl;
|
|||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class ShiftingLoyalties extends CardImpl {
|
||||
|
||||
public ShiftingLoyalties(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{5}{U}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{5}{U}");
|
||||
|
||||
// Exchange control of two target permanents that share a card type. <i>(Artifact, creature, enchantment, land, and planeswalker are card types.)</i>
|
||||
this.getSpellAbility().addEffect(new ExchangeControlTargetEffect(Duration.EndOfGame, "Exchange control of two target permanents that share a card type. <i>(Artifact, creature, enchantment, land, and planeswalker are card types.)</i>"));
|
||||
|
@ -31,7 +31,7 @@ public final class ShiftingLoyalties extends CardImpl {
|
|||
|
||||
}
|
||||
|
||||
public ShiftingLoyalties(final ShiftingLoyalties card) {
|
||||
private ShiftingLoyalties(final ShiftingLoyalties card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
|
@ -43,12 +43,12 @@ public final class ShiftingLoyalties extends CardImpl {
|
|||
|
||||
class TargetPermanentsThatShareCardType extends TargetPermanent {
|
||||
|
||||
public TargetPermanentsThatShareCardType() {
|
||||
super(2, 2, new FilterPermanent(), false);
|
||||
TargetPermanentsThatShareCardType() {
|
||||
super(2, 2, StaticFilters.FILTER_PERMANENT, false);
|
||||
targetName = "permanents that share a card type";
|
||||
}
|
||||
|
||||
public TargetPermanentsThatShareCardType(final TargetPermanentsThatShareCardType target) {
|
||||
private TargetPermanentsThatShareCardType(final TargetPermanentsThatShareCardType target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ class TargetPermanentsThatShareCardType extends TargetPermanent {
|
|||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<CardType> cardTypes = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
if(targetSource != null) {
|
||||
if (targetSource != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
for (CardType cardType : permanent.getCardType()) {
|
||||
|
|
|
@ -93,6 +93,7 @@ public final class WarOfTheSpark extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Ravnica at War", 28, Rarity.RARE, mage.cards.r.RavnicaAtWar.class));
|
||||
cards.add(new SetCardInfo("Relentless Advance", 64, Rarity.COMMON, mage.cards.r.RelentlessAdvance.class));
|
||||
cards.add(new SetCardInfo("Rising Populace", 29, Rarity.COMMON, mage.cards.r.RisingPopulace.class));
|
||||
cards.add(new SetCardInfo("Role Reversal", 214, Rarity.RARE, mage.cards.r.RoleReversal.class));
|
||||
cards.add(new SetCardInfo("Samut's Sprint", 142, Rarity.COMMON, mage.cards.s.SamutsSprint.class));
|
||||
cards.add(new SetCardInfo("Samut, Tyrant Smasher", 235, Rarity.UNCOMMON, mage.cards.s.SamutTyrantSmasher.class));
|
||||
cards.add(new SetCardInfo("Sorin's Thirst", 104, Rarity.COMMON, mage.cards.s.SorinsThirst.class));
|
||||
|
|
|
@ -153,13 +153,18 @@ public interface MageObject extends MageItem, Serializable {
|
|||
* @return
|
||||
*/
|
||||
default boolean shareTypes(Card otherCard) {
|
||||
return this.shareTypes(otherCard, false);
|
||||
}
|
||||
|
||||
default boolean shareTypes(Card otherCard, boolean permanentOnly) {
|
||||
|
||||
if (otherCard == null) {
|
||||
throw new IllegalArgumentException("Params can't be null");
|
||||
}
|
||||
|
||||
for (CardType type : getCardType()) {
|
||||
if (otherCard.getCardType().contains(type)) {
|
||||
if (otherCard.getCardType().contains(type)
|
||||
&& (!permanentOnly || type.isPermanentType())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue