[MOM] Implement Botanical Brawler

This commit is contained in:
theelk801 2023-04-17 20:14:47 -04:00
parent fbf874fdc5
commit ac611ae6e0
2 changed files with 134 additions and 0 deletions

View file

@ -0,0 +1,133 @@
package mage.cards.b;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.watchers.Watcher;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class BotanicalBrawler extends CardImpl {
public BotanicalBrawler(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{G}{W}");
this.subtype.add(SubType.ELEMENTAL);
this.subtype.add(SubType.WARRIOR);
this.power = new MageInt(0);
this.toughness = new MageInt(0);
// Trample
this.addAbility(TrampleAbility.getInstance());
// Botanical Brawler enters the battlefield with two +1/+1 counters on it.
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(
CounterType.P1P1.createInstance(2), true
), "with two +1/+1 counters on it"));
// Whenever one or more +1/+1 counters are put on another permanent you control, if it's the first time +1/+1 counters have been put on that permanent this turn, put a +1/+1 counter on Botanical Brawler.
this.addAbility(new BotanicalBrawlerTriggeredAbility());
}
private BotanicalBrawler(final BotanicalBrawler card) {
super(card);
}
@Override
public BotanicalBrawler copy() {
return new BotanicalBrawler(this);
}
}
class BotanicalBrawlerTriggeredAbility extends TriggeredAbilityImpl {
BotanicalBrawlerTriggeredAbility() {
super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance()));
this.addWatcher(new BotanicalBrawlerWatcher());
}
private BotanicalBrawlerTriggeredAbility(final BotanicalBrawlerTriggeredAbility ability) {
super(ability);
}
@Override
public BotanicalBrawlerTriggeredAbility copy() {
return new BotanicalBrawlerTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.COUNTERS_ADDED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
return permanent != null
&& !getSourceId().equals(event.getTargetId())
&& isControlledBy(permanent.getControllerId())
&& event.getData().equals(CounterType.P1P1.getName())
&& BotanicalBrawlerWatcher.checkEvent(event, permanent, game);
}
@Override
public String getRule() {
return "Whenever one or more +1/+1 counters are put on another permanent you control, " +
"if it's the first time +1/+1 counters have been put on that permanent this turn, " +
"put a +1/+1 counter on {this}.";
}
}
class BotanicalBrawlerWatcher extends Watcher {
private final Map<MageObjectReference, UUID> map = new HashMap<>();
BotanicalBrawlerWatcher() {
super(WatcherScope.GAME);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() != GameEvent.EventType.COUNTERS_ADDED) {
return;
}
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && event.getData().equals(CounterType.P1P1.getName())) {
map.putIfAbsent(new MageObjectReference(permanent, game), event.getId());
}
}
@Override
public void reset() {
super.reset();
map.clear();
}
static boolean checkEvent(GameEvent event, Permanent permanent, Game game) {
return event
.getId()
.equals(game
.getState()
.getWatcher(BotanicalBrawlerWatcher.class)
.map
.getOrDefault(new MageObjectReference(permanent, game), null));
}
}

View file

@ -63,6 +63,7 @@ public final class MarchOfTheMachine extends ExpansionSet {
cards.add(new SetCardInfo("Bonded Herdbeast", 178, Rarity.COMMON, mage.cards.b.BondedHerdbeast.class)); cards.add(new SetCardInfo("Bonded Herdbeast", 178, Rarity.COMMON, mage.cards.b.BondedHerdbeast.class));
cards.add(new SetCardInfo("Boon-Bringer Valkyrie", 9, Rarity.RARE, mage.cards.b.BoonBringerValkyrie.class)); cards.add(new SetCardInfo("Boon-Bringer Valkyrie", 9, Rarity.RARE, mage.cards.b.BoonBringerValkyrie.class));
cards.add(new SetCardInfo("Borborygmos and Fblthp", 219, Rarity.MYTHIC, mage.cards.b.BorborygmosAndFblthp.class)); cards.add(new SetCardInfo("Borborygmos and Fblthp", 219, Rarity.MYTHIC, mage.cards.b.BorborygmosAndFblthp.class));
cards.add(new SetCardInfo("Botanical Brawler", 220, Rarity.UNCOMMON, mage.cards.b.BotanicalBrawler.class));
cards.add(new SetCardInfo("Breach the Multiverse", 94, Rarity.RARE, mage.cards.b.BreachTheMultiverse.class)); cards.add(new SetCardInfo("Breach the Multiverse", 94, Rarity.RARE, mage.cards.b.BreachTheMultiverse.class));
cards.add(new SetCardInfo("Burning Sun's Fury", 133, Rarity.COMMON, mage.cards.b.BurningSunsFury.class)); cards.add(new SetCardInfo("Burning Sun's Fury", 133, Rarity.COMMON, mage.cards.b.BurningSunsFury.class));
cards.add(new SetCardInfo("Burnished Dunestomper", 43, Rarity.COMMON, mage.cards.b.BurnishedDunestomper.class)); cards.add(new SetCardInfo("Burnished Dunestomper", 43, Rarity.COMMON, mage.cards.b.BurnishedDunestomper.class));