[CMM] Implement Rukarumel, Biologist (#10703)

This commit is contained in:
Susucre 2023-07-31 01:26:11 +02:00 committed by GitHub
parent ac609c3714
commit 53b270fc36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 284 additions and 108 deletions

View file

@ -0,0 +1,121 @@
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
import mage.cards.Card;
import mage.constants.*;
import mage.filter.common.*;
import mage.game.Game;
import mage.game.command.CommandObject;
import mage.game.command.Commander;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
import java.util.List;
import java.util.UUID;
/**
* @author TheElk801, Susucr
*/
public class AddCreatureSubTypeAllMultiZoneEffect extends ContinuousEffectImpl {
private final FilterControlledCreaturePermanent filterPermanent;
private final FilterControlledCreatureSpell filterSpell;
private final FilterOwnedCreatureCard filterCard;
public AddCreatureSubTypeAllMultiZoneEffect(
FilterControlledCreaturePermanent filterPermanent,
FilterControlledCreatureSpell filterSpell,
FilterOwnedCreatureCard filterCard
) {
super(Duration.WhileOnBattlefield, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
this.filterPermanent = filterPermanent;
this.filterSpell = filterSpell;
this.filterCard = filterCard;
staticText = filterPermanent.getMessage() + " are the chosen type in addition to their other types. "
+ "The same is true for " + filterSpell.getMessage()
+ " and " + filterCard.getMessage() + " that aren't on the battlefield";
}
private AddCreatureSubTypeAllMultiZoneEffect(final AddCreatureSubTypeAllMultiZoneEffect effect) {
super(effect);
this.filterPermanent = effect.filterPermanent;
this.filterSpell = effect.filterSpell;
this.filterCard = effect.filterCard;
}
@Override
public AddCreatureSubTypeAllMultiZoneEffect copy() {
return new AddCreatureSubTypeAllMultiZoneEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
UUID controllerId = source.getControllerId();
Player controller = game.getPlayer(controllerId);
SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
if (controller == null || subType == null) {
return false;
}
// creatures cards you own that aren't on the battlefield
// in graveyard
for (UUID cardId : controller.getGraveyard()) {
Card card = game.getCard(cardId);
if (filterCard.match(card, controllerId, source, game) && !card.hasSubtype(subType, game)) {
game.getState().getCreateMageObjectAttribute(card, game).getSubtype().add(subType);
}
}
// on Hand
for (UUID cardId : controller.getHand()) {
Card card = game.getCard(cardId);
if (filterCard.match(card, controllerId, source, game) && !card.hasSubtype(subType, game)) {
game.getState().getCreateMageObjectAttribute(card, game).getSubtype().add(subType);
}
}
// in Exile
for (Card card : game.getState().getExile().getAllCards(game, controllerId)) {
if (filterCard.match(card, controllerId, source, game) && !card.hasSubtype(subType, game)) {
game.getState().getCreateMageObjectAttribute(card, game).getSubtype().add(subType);
}
}
// in Library (e.g. for Mystical Teachings)
for (Card card : controller.getLibrary().getCards(game)) {
if (filterCard.match(card, controllerId, source, game) && !card.hasSubtype(subType, game)) {
game.getState().getCreateMageObjectAttribute(card, game).getSubtype().add(subType);
}
}
// commander in command zone
for (CommandObject commandObject : game.getState().getCommand()) {
if (commandObject instanceof Commander) {
Card card = game.getCard((commandObject).getId());
if (filterCard.match(card, controllerId, source, game) && !card.hasSubtype(subType, game)) {
game.getState().getCreateMageObjectAttribute(card, game).getSubtype().add(subType);
}
}
}
// creature spells you control
for (StackObject stackObject : game.getStack()) {
if (stackObject instanceof Spell
&& filterSpell.match(stackObject, controllerId, source, game)
&& !stackObject.hasSubtype(subType, game)) {
Card card = ((Spell) stackObject).getCard();
game.getState().getCreateMageObjectAttribute(card, game).getSubtype().add(subType);
}
}
// creatures you control
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(
filterPermanent, controllerId, game);
for (Permanent creature : creatures) {
if (creature != null) {
creature.addSubType(game, subType);
}
}
return true;
}
}

View file

@ -0,0 +1,31 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mage.filter.common;
import mage.constants.TargetController;
/**
* @author LevelX2
*/
public class FilterControlledCreatureSpell extends FilterCreatureSpell {
public FilterControlledCreatureSpell() {
this("creature spell");
}
public FilterControlledCreatureSpell(String name) {
super(name);
this.add(TargetController.YOU.getControllerPredicate());
}
public FilterControlledCreatureSpell(final FilterControlledCreatureSpell filter) {
super(filter);
}
@Override
public FilterControlledCreatureSpell copy() {
return new FilterControlledCreatureSpell(this);
}
}

View file

@ -22,4 +22,12 @@ public class FilterCreatureSpell extends FilterSpell {
this.add(CardType.CREATURE.getPredicate());
}
public FilterCreatureSpell(final FilterCreatureSpell filter) {
super(filter);
}
@Override
public FilterCreatureSpell copy() {
return new FilterCreatureSpell(this);
}
}

View file

@ -0,0 +1,30 @@
package mage.filter.common;
import mage.constants.CardType;
/**
* @author Susucr
*/
public class FilterOwnedCreatureCard extends FilterOwnedCard {
public FilterOwnedCreatureCard() {
this("creature card");
}
public FilterOwnedCreatureCard(String name) {
super(name);
this.add(CardType.CREATURE.getPredicate());
}
public FilterOwnedCreatureCard(final FilterOwnedCreatureCard filter) {
super(filter);
}
@Override
public FilterOwnedCreatureCard copy() {
return new FilterOwnedCreatureCard(this);
}
}