mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Fixed Standardize, was implemented as target creature instead of each creature
This commit is contained in:
parent
bebe5631e7
commit
aaf800d9b9
2 changed files with 178 additions and 3 deletions
|
@ -27,13 +27,26 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.onslaught;
|
package mage.sets.onslaught;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.effects.ContinuousEffect;
|
||||||
|
import mage.abilities.effects.Effect;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.continuous.BecomesChosenNonWallCreatureTypeTargetEffect;
|
import mage.abilities.effects.common.continuous.BecomesChosenNonWallCreatureTypeTargetEffect;
|
||||||
|
import mage.abilities.effects.common.continuous.BecomesSubtypeAllEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.repository.CardRepository;
|
||||||
|
import mage.choices.Choice;
|
||||||
|
import mage.choices.ChoiceImpl;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.players.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -46,7 +59,7 @@ public class Standardize extends CardImpl {
|
||||||
this.expansionSetCode = "ONS";
|
this.expansionSetCode = "ONS";
|
||||||
|
|
||||||
// Choose a creature type other than Wall. Each creature becomes that type until end of turn.
|
// Choose a creature type other than Wall. Each creature becomes that type until end of turn.
|
||||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
|
||||||
this.getSpellAbility().addEffect(new BecomesChosenNonWallCreatureTypeTargetEffect());
|
this.getSpellAbility().addEffect(new BecomesChosenNonWallCreatureTypeTargetEffect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,4 +71,54 @@ public class Standardize extends CardImpl {
|
||||||
public Standardize copy() {
|
public Standardize copy() {
|
||||||
return new Standardize(this);
|
return new Standardize(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class StandardizeEffect extends OneShotEffect {
|
||||||
|
|
||||||
|
public StandardizeEffect() {
|
||||||
|
super(Outcome.BoostCreature);
|
||||||
|
staticText = "choose a creature type other than wall, each creature's type becomes that type until end of turn";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public StandardizeEffect(final StandardizeEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
|
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||||
|
String chosenType = "";
|
||||||
|
if (player != null && permanent != null) {
|
||||||
|
Choice typeChoice = new ChoiceImpl(true);
|
||||||
|
typeChoice.setMessage("Choose creature type other than Wall");
|
||||||
|
Set<String> types = CardRepository.instance.getCreatureTypes();
|
||||||
|
types.remove("Wall");
|
||||||
|
typeChoice.setChoices(types);
|
||||||
|
while (!player.choose(Outcome.BoostCreature, typeChoice, game)) {
|
||||||
|
if (!player.isInGame()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice());
|
||||||
|
chosenType = typeChoice.getChoice();
|
||||||
|
if (chosenType != null && !chosenType.isEmpty()) {
|
||||||
|
// ADD TYPE TO TARGET
|
||||||
|
ContinuousEffect effect = new BecomesSubtypeAllEffect(Duration.EndOfTurn, chosenType);
|
||||||
|
game.addEffect(effect, source);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Effect copy() {
|
||||||
|
return new StandardizeEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,112 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package mage.abilities.effects.common.continuous;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.Layer;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.SubLayer;
|
||||||
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
public class BecomesSubtypeAllEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
|
protected ArrayList<String> subtypes = new ArrayList();
|
||||||
|
protected boolean loseOther; // loses other subtypes
|
||||||
|
|
||||||
|
public BecomesSubtypeAllEffect(Duration duration, String subtype) {
|
||||||
|
this(duration, createArrayList(subtype));
|
||||||
|
}
|
||||||
|
|
||||||
|
public BecomesSubtypeAllEffect(Duration duration, ArrayList<String> subtypes) {
|
||||||
|
this(duration, subtypes, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BecomesSubtypeAllEffect(Duration duration,
|
||||||
|
ArrayList<String> subtypes, boolean loseOther) {
|
||||||
|
super(duration, Outcome.Detriment);
|
||||||
|
this.subtypes = subtypes;
|
||||||
|
this.staticText = setText();
|
||||||
|
this.loseOther = loseOther;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ArrayList<String> createArrayList(String subtype) {
|
||||||
|
ArrayList<String> subtypes = new ArrayList<>();
|
||||||
|
subtypes.add(subtype);
|
||||||
|
return subtypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BecomesSubtypeAllEffect(final BecomesSubtypeAllEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
this.subtypes.addAll(effect.subtypes);
|
||||||
|
this.loseOther = effect.loseOther;
|
||||||
|
this.loseOther = effect.loseOther;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BecomesSubtypeAllEffect copy() {
|
||||||
|
return new BecomesSubtypeAllEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Layer layer, SubLayer sublayer, Ability source,
|
||||||
|
Game game) {
|
||||||
|
|
||||||
|
for (Permanent permanent : game.getBattlefield()
|
||||||
|
.getAllActivePermanents(new FilterCreaturePermanent(), game)) {
|
||||||
|
if (permanent != null) {
|
||||||
|
switch (layer) {
|
||||||
|
case TypeChangingEffects_4:
|
||||||
|
if (loseOther) {
|
||||||
|
permanent.getSubtype().clear();
|
||||||
|
permanent.getSubtype().addAll(subtypes);
|
||||||
|
} else {
|
||||||
|
for (String subtype : subtypes) {
|
||||||
|
if (!permanent.getSubtype().contains(subtype)) {
|
||||||
|
permanent.getSubtype().add(subtype);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (duration.equals(Duration.Custom)) {
|
||||||
|
discard();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasLayer(Layer layer) {
|
||||||
|
return layer == Layer.TypeChangingEffects_4;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String setText() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Target creature becomes that type");
|
||||||
|
if (!duration.toString().isEmpty()
|
||||||
|
&& !duration.equals(Duration.EndOfGame)) {
|
||||||
|
sb.append(" ").append(duration.toString());
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue