Skip to content

Commit

Permalink
Implement Amzu, Swarm's Hunger
Browse files Browse the repository at this point in the history
  • Loading branch information
jimga150 committed Aug 19, 2024
1 parent 5d43904 commit c44e920
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 0 deletions.
117 changes: 117 additions & 0 deletions Mage.Sets/src/mage/cards/a/AmzuSwarmsHunger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package mage.cards.a;

import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.CardsLeaveGraveyardTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.cards.Card;
import mage.constants.*;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.MenaceAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.IzoniInsectToken;

/**
*
* @author jimga150
*/
public final class AmzuSwarmsHunger extends CardImpl {

private static final FilterPermanent filter = new FilterPermanent(SubType.INSECT, "Insects");

public AmzuSwarmsHunger(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}{G}");

this.supertype.add(SuperType.LEGENDARY);
this.subtype.add(SubType.INSECT);
this.subtype.add(SubType.SHAMAN);
this.power = new MageInt(3);
this.toughness = new MageInt(3);

// Flying
this.addAbility(FlyingAbility.getInstance());

// Menace
this.addAbility(new MenaceAbility());

// Other Insects you control have menace.
this.addAbility(new SimpleStaticAbility(new GainAbilityControlledEffect(
new MenaceAbility(false), Duration.WhileOnBattlefield,
filter, true
)));

// Whenever one or more cards leave your graveyard, you may create a 1/1 black and green Insect creature token,
// then put a number of +1/+1 counters on it equal to the greatest mana value among those cards.
// Do this only once each turn.
this.addAbility(new CardsLeaveGraveyardTriggeredAbility(new AmzuSwarmsHungerEffect(), true).setDoOnlyOnceEachTurn(true));
}

private AmzuSwarmsHunger(final AmzuSwarmsHunger card) {
super(card);
}

@Override
public AmzuSwarmsHunger copy() {
return new AmzuSwarmsHunger(this);
}
}

// Based on OutlawStitcherEffect
class AmzuSwarmsHungerEffect extends OneShotEffect {

AmzuSwarmsHungerEffect() {
super(Outcome.PutCreatureInPlay);
staticText = "create a 1/1 black and green Insect creature token, " +
"then put a number of +1/+1 counters on it equal to the greatest mana value among those cards.";
}

private AmzuSwarmsHungerEffect(final AmzuSwarmsHungerEffect effect) {
super(effect);
}

@Override
public AmzuSwarmsHungerEffect copy() {
return new AmzuSwarmsHungerEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
CreateTokenEffect effect = new CreateTokenEffect(new IzoniInsectToken());
boolean result = effect.apply(game, source);

Object cardsLeavingGraveyardObj = this.getValue("cardsLeavingGraveyard");
if (!(cardsLeavingGraveyardObj instanceof Set)) {
return false;
}
Set<Card> cardsLeavingGraveyard = (Set<Card>) cardsLeavingGraveyardObj;
int xvalue = cardsLeavingGraveyard
.stream()
.mapToInt(MageObject::getManaValue)
.max()
.orElse(0);

if (xvalue <= 0 || !result) {
return result;
}
for (UUID id : effect.getLastAddedTokenIds()) {
Permanent token = game.getPermanent(id);
if (token == null) {
continue;
}
token.addCounters(CounterType.P1P1.createInstance(xvalue), source.getControllerId(), source, game);
}
return true;
}

}
1 change: 1 addition & 0 deletions Mage.Sets/src/mage/sets/RavnicaClueEdition.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ private RavnicaClueEdition() {
cards.add(new SetCardInfo("Affectionate Indrik", 155, Rarity.UNCOMMON, mage.cards.a.AffectionateIndrik.class));
cards.add(new SetCardInfo("Afterlife Insurance", 23, Rarity.UNCOMMON, mage.cards.a.AfterlifeInsurance.class));
cards.add(new SetCardInfo("Ajani's Pridemate", 52, Rarity.UNCOMMON, mage.cards.a.AjanisPridemate.class));
cards.add(new SetCardInfo("Amzu, Swarm's Hunger", 24, Rarity.RARE, mage.cards.a.AmzuSwarmsHunger.class));
cards.add(new SetCardInfo("Angel of Vitality", 53, Rarity.UNCOMMON, mage.cards.a.AngelOfVitality.class));
cards.add(new SetCardInfo("Apothecary White", 1, Rarity.RARE, mage.cards.a.ApothecaryWhite.class));
cards.add(new SetCardInfo("Azorius Arrester", 54, Rarity.COMMON, mage.cards.a.AzoriusArrester.class));
Expand Down

0 comments on commit c44e920

Please sign in to comment.