Skip to content

Commit

Permalink
Changes from review.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidorovich77 committed Aug 13, 2024
1 parent a24c739 commit a62b366
Showing 1 changed file with 19 additions and 92 deletions.
111 changes: 19 additions & 92 deletions Mage.Sets/src/mage/cards/v/VrestinMenoptraLeader.java
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
package mage.cards.v;

import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.AttacksWithCreaturesTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect;
import mage.abilities.effects.common.counter.AddCountersAllEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.filter.common.FilterAttackingCreature;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.permanent.token.AlienInsectToken;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

/**
* @author Sidorovich77
*/
public final class VrestinMenoptraLeader extends CardImpl {


private static final FilterAttackingCreature filter = new FilterAttackingCreature();

static {
filter.add(SubType.INSECT.getPredicate());
}

public VrestinMenoptraLeader(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{X}{G}{G}{W}");

Expand All @@ -54,7 +57,10 @@ public VrestinMenoptraLeader(UUID ownerId, CardSetInfo setInfo) {
));

// Whenever you attack with one or more Insects, put a +1/+1 counter on each of them.
this.addAbility(new VrestinMenoptraLeaderTriggeredAbility());
this.addAbility(new AttacksWithCreaturesTriggeredAbility((new AddCountersAllEffect(CounterType.P1P1.createInstance(),
filter).setText("put a +1/+1 counter on each of them.")), 1,
new FilterCreaturePermanent(SubType.INSECT, "Insects")).setTriggerPhrase("Whenever you attack with one or more Insects, "));

}

private VrestinMenoptraLeader(final VrestinMenoptraLeader card) {
Expand All @@ -65,83 +71,4 @@ private VrestinMenoptraLeader(final VrestinMenoptraLeader card) {
public VrestinMenoptraLeader copy() {
return new VrestinMenoptraLeader(this);
}
class VrestinMenoptraLeaderTriggeredAbility extends TriggeredAbilityImpl {

VrestinMenoptraLeaderTriggeredAbility() {
super(Zone.BATTLEFIELD, null);
}

private VrestinMenoptraLeaderTriggeredAbility(final VrestinMenoptraLeaderTriggeredAbility ability) {
super(ability);
}

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

@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS;
}

@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (game.getCombat().getAttackingPlayerId().equals(getControllerId())) {
int attackerCount = 0;
Set<MageObjectReference> attackers = new HashSet();
for (UUID attackerId : game.getCombat().getAttackers()) {
Permanent permanent = game.getPermanent(attackerId);
if (permanent.isCreature(game) && permanent.hasSubtype(SubType.INSECT, game))
{
attackerCount++;
attackers.add(new MageObjectReference(permanent, game));
}
}
if (attackerCount >= 1) {
this.getEffects().clear();
this.addEffect(new VrestinMenoptraLeaderEffect(attackers));
return true;
}
}
return false;
}

@Override
public String getRule() {
return "Whenever you attack with one or more Insects, put a +1/+1 counter on each of them.";
}
}

class VrestinMenoptraLeaderEffect extends OneShotEffect {

private final Set<MageObjectReference> attackers;

VrestinMenoptraLeaderEffect(Set<MageObjectReference> attackers) {
super(Outcome.Benefit);
this.attackers = attackers;
}

private VrestinMenoptraLeaderEffect(final VrestinMenoptraLeaderEffect effect) {
super(effect);
this.attackers = effect.attackers;
}

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

@Override
public boolean apply(Game game, Ability source) {
for (MageObjectReference mor : attackers) {
Permanent permanent = mor.getPermanent(game);
if (permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
}
}
return true;
}
}

}
}

0 comments on commit a62b366

Please sign in to comment.