mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
Emblem Refactor
This commit is contained in:
parent
6d52ec5a59
commit
71fad444c1
2 changed files with 6 additions and 146 deletions
|
@ -27,12 +27,8 @@
|
|||
*/
|
||||
package mage.cards.d;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.LoyaltyAbility;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DrawCardTargetEffect;
|
||||
import mage.abilities.effects.common.GetEmblemEffect;
|
||||
|
@ -41,20 +37,9 @@ import mage.abilities.effects.common.discard.DiscardTargetEffect;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.command.Emblem;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.game.command.emblems.DackFaydenEmblem;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.target.common.TargetArtifactPermanent;
|
||||
import mage.target.targetpointer.FixedTargets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -100,120 +85,3 @@ public class DackFayden extends CardImpl {
|
|||
return new DackFayden(this);
|
||||
}
|
||||
}
|
||||
|
||||
class DackFaydenEmblem extends Emblem {
|
||||
|
||||
DackFaydenEmblem() {
|
||||
this.setName("Emblem Dack");
|
||||
this.getAbilities().add(new DackFaydenEmblemTriggeredAbility());
|
||||
}
|
||||
}
|
||||
|
||||
class DackFaydenEmblemTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
DackFaydenEmblemTriggeredAbility() {
|
||||
super(Zone.COMMAND, new DackFaydenEmblemEffect(), false);
|
||||
}
|
||||
|
||||
DackFaydenEmblemTriggeredAbility(final DackFaydenEmblemTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DackFaydenEmblemTriggeredAbility copy() {
|
||||
return new DackFaydenEmblemTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.SPELL_CAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
boolean returnValue = false;
|
||||
List<UUID> targetedPermanentIds = new ArrayList<>(0);
|
||||
Player player = game.getPlayer(this.getControllerId());
|
||||
if (player != null) {
|
||||
if (event.getPlayerId().equals(this.getControllerId())) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null) {
|
||||
SpellAbility spellAbility = spell.getSpellAbility();
|
||||
for (Target target : spellAbility.getTargets()) {
|
||||
if (!target.isNotTarget()) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
if (game.getBattlefield().containsPermanent(targetId)) {
|
||||
returnValue = true;
|
||||
targetedPermanentIds.add(targetId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Effect effect : spellAbility.getEffects()) {
|
||||
for (UUID targetId : effect.getTargetPointer().getTargets(game, spellAbility)) {
|
||||
if (game.getBattlefield().containsPermanent(targetId)) {
|
||||
returnValue = true;
|
||||
targetedPermanentIds.add(targetId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Effect effect : this.getEffects()) {
|
||||
if (effect instanceof DackFaydenEmblemEffect) {
|
||||
DackFaydenEmblemEffect dackEffect = (DackFaydenEmblemEffect) effect;
|
||||
List<Permanent> permanents = new ArrayList<>();
|
||||
for(UUID permanentId : targetedPermanentIds) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
if(permanent != null) {
|
||||
permanents.add(permanent);
|
||||
}
|
||||
}
|
||||
|
||||
dackEffect.setTargets(permanents, game);
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever you cast a spell that targets one or more permanents, gain control of those permanents.";
|
||||
}
|
||||
}
|
||||
|
||||
class DackFaydenEmblemEffect extends ContinuousEffectImpl {
|
||||
|
||||
protected FixedTargets fixedTargets;
|
||||
|
||||
DackFaydenEmblemEffect() {
|
||||
super(Duration.EndOfGame, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
|
||||
this.staticText = "gain control of those permanents";
|
||||
}
|
||||
|
||||
DackFaydenEmblemEffect(final DackFaydenEmblemEffect effect) {
|
||||
super(effect);
|
||||
this.fixedTargets = effect.fixedTargets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DackFaydenEmblemEffect copy() {
|
||||
return new DackFaydenEmblemEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID permanentId : fixedTargets.getTargets(game, source)) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
if (permanent != null) {
|
||||
permanent.changeControllerId(source.getControllerId(), game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setTargets(List<Permanent> targetedPermanents, Game game) {
|
||||
this.fixedTargets = new FixedTargets(targetedPermanents, game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,12 +28,11 @@
|
|||
package mage.cards.g;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.MageInt;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.LoyaltyAbility;
|
||||
import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.GetEmblemEffect;
|
||||
|
@ -47,8 +46,8 @@ import mage.constants.*;
|
|||
import mage.filter.common.FilterPlaneswalkerPermanent;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.command.Emblem;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.command.emblems.GideonOfTheTrialsEmblem;
|
||||
import mage.game.permanent.token.Token;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
|
@ -119,8 +118,8 @@ class GideonOfTheTrialsCantLoseEffect extends ContinuousRuleModifyingEffectImpl
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if ((event.getType() == GameEvent.EventType.WINS && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) ||
|
||||
(event.getType() == GameEvent.EventType.LOSES && event.getPlayerId().equals(source.getControllerId()))) {
|
||||
if ((event.getType() == GameEvent.EventType.WINS && game.getOpponents(source.getControllerId()).contains(event.getPlayerId()))
|
||||
|| (event.getType() == GameEvent.EventType.LOSES && event.getPlayerId().equals(source.getControllerId()))) {
|
||||
if (game.getBattlefield().contains(filter, source.getControllerId(), 1, game)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -134,15 +133,8 @@ class GideonOfTheTrialsCantLoseEffect extends ContinuousRuleModifyingEffectImpl
|
|||
}
|
||||
}
|
||||
|
||||
class GideonOfTheTrialsEmblem extends Emblem {
|
||||
public GideonOfTheTrialsEmblem() {
|
||||
this.setName("Emblem - Gideon of the Trials");
|
||||
Ability ability = new SimpleStaticAbility(Zone.COMMAND, new GideonOfTheTrialsCantLoseEffect());
|
||||
this.getAbilities().add(ability);
|
||||
}
|
||||
}
|
||||
|
||||
class GideonOfTheTrialsToken extends Token {
|
||||
|
||||
public GideonOfTheTrialsToken() {
|
||||
super("", "a 4/4 Human Soldier creature with indestructible");
|
||||
cardType.add(CardType.CREATURE);
|
||||
|
|
Loading…
Reference in a new issue