Skip to content

Commit

Permalink
update damage players batch triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
xenohedron committed Nov 17, 2024
1 parent 2d2d248 commit bc43b06
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 73 deletions.
30 changes: 18 additions & 12 deletions Mage.Sets/src/mage/cards/b/BreechesBrazenPlunderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.BatchTriggeredAbility;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.MenaceAbility;
Expand All @@ -10,7 +11,7 @@
import mage.constants.*;
import mage.game.Game;
import mage.game.events.DamagedBatchForPlayersEvent;
import mage.game.events.DamagedEvent;
import mage.game.events.DamagedPlayerEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
Expand Down Expand Up @@ -55,7 +56,7 @@ public BreechesBrazenPlunderer copy() {
}
}

class BreechesBrazenPlundererTriggeredAbility extends TriggeredAbilityImpl {
class BreechesBrazenPlundererTriggeredAbility extends TriggeredAbilityImpl implements BatchTriggeredAbility<DamagedPlayerEvent> {

BreechesBrazenPlundererTriggeredAbility() {
super(Zone.BATTLEFIELD, null);
Expand All @@ -70,19 +71,24 @@ public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DAMAGED_BATCH_FOR_PLAYERS;
}

@Override
public boolean checkEvent(DamagedPlayerEvent event, Game game) {
if (!game.getOpponents(getControllerId()).contains(event.getTargetId())) {
return false;
}
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
return permanent != null
&& permanent.isControlledBy(getControllerId())
&& permanent.hasSubtype(SubType.PIRATE, game);
}

@Override
public boolean checkTrigger(GameEvent event, Game game) {
Set<UUID> opponents = new HashSet<>();
for (DamagedEvent damagedEvent : ((DamagedBatchForPlayersEvent) event).getEvents()) {
Permanent permanent = game.getPermanent(damagedEvent.getSourceId());
if (permanent == null
|| !permanent.isControlledBy(getControllerId())
|| !permanent.hasSubtype(SubType.PIRATE, game)
|| !game.getOpponents(getControllerId()).contains(damagedEvent.getTargetId())) {
continue;
}
opponents.add(damagedEvent.getTargetId());
}
getFilteredEvents((DamagedBatchForPlayersEvent) event, game)
.stream()
.map(GameEvent::getTargetId)
.forEach(opponents::add);
if (opponents.isEmpty()) {
return false;
}
Expand Down
30 changes: 16 additions & 14 deletions Mage.Sets/src/mage/cards/c/ContaminantGrafter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.BatchTriggeredAbility;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.abilities.condition.common.CorruptedCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect;
import mage.abilities.effects.common.counter.ProliferateEffect;
import mage.abilities.keyword.ToxicAbility;
import mage.abilities.keyword.TrampleAbility;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AbilityWord;
Expand All @@ -19,8 +20,8 @@
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.events.DamagedEvent;
import mage.game.events.DamagedBatchForPlayersEvent;
import mage.game.events.DamagedPlayerEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;

Expand Down Expand Up @@ -69,7 +70,7 @@ public ContaminantGrafter copy() {
}
}

class ContaminantGrafterTriggeredAbility extends TriggeredAbilityImpl {
class ContaminantGrafterTriggeredAbility extends TriggeredAbilityImpl implements BatchTriggeredAbility<DamagedPlayerEvent> {

ContaminantGrafterTriggeredAbility() {
super(Zone.BATTLEFIELD, new ProliferateEffect(false), false);
Expand All @@ -86,18 +87,19 @@ public boolean checkEventType(GameEvent event, Game game) {
}

@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedBatchForPlayersEvent dEvent = (DamagedBatchForPlayersEvent) event;
for (DamagedEvent damagedEvent : dEvent.getEvents()) {
if (!damagedEvent.isCombatDamage()) {
continue;
}
Permanent permanent = game.getPermanent(damagedEvent.getSourceId());
if (permanent != null && permanent.isControlledBy(getControllerId())) {
return true;
}
public boolean checkEvent(DamagedPlayerEvent event, Game game) {
if (!event.isCombatDamage()) {
return false;
}
return false;
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
return permanent != null
&& permanent.isCreature(game)
&& permanent.isControlledBy(getControllerId());
}

@Override
public boolean checkTrigger(GameEvent event, Game game) {
return !getFilteredEvents((DamagedBatchForPlayersEvent) event, game).isEmpty();
}

@Override
Expand Down
33 changes: 17 additions & 16 deletions Mage.Sets/src/mage/cards/f/ForthEorlingas.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package mage.cards.f;

import java.util.UUID;

import mage.abilities.BatchTriggeredAbility;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.BecomesMonarchSourceEffect;
Expand All @@ -13,14 +12,15 @@
import mage.constants.CardType;
import mage.constants.Duration;
import mage.game.Game;
import mage.game.events.DamagedEvent;
import mage.game.events.DamagedBatchForPlayersEvent;
import mage.game.events.DamagedPlayerEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.HumanKnightToken;

import java.util.UUID;

/**
*
* @author Susucr
*/
public final class ForthEorlingas extends CardImpl {
Expand Down Expand Up @@ -50,7 +50,7 @@ public ForthEorlingas copy() {
}
}

class ForthEorlingasTriggeredAbility extends DelayedTriggeredAbility {
class ForthEorlingasTriggeredAbility extends DelayedTriggeredAbility implements BatchTriggeredAbility<DamagedPlayerEvent> {

public ForthEorlingasTriggeredAbility() {
super(new BecomesMonarchSourceEffect(), Duration.EndOfTurn, false);
Expand All @@ -68,18 +68,19 @@ public boolean checkEventType(GameEvent event, Game game) {
}

@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedBatchForPlayersEvent dEvent = (DamagedBatchForPlayersEvent) event;
for (DamagedEvent damagedEvent : dEvent.getEvents()) {
if (!damagedEvent.isCombatDamage()) {
continue;
}
Permanent permanent = game.getPermanent(damagedEvent.getSourceId());
if (permanent != null && permanent.isControlledBy(getControllerId())) {
return true;
}
public boolean checkEvent(DamagedPlayerEvent event, Game game) {
if (!event.isCombatDamage()) {
return false;
}
return false;
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
return permanent != null
&& permanent.isCreature(game)
&& permanent.isControlledBy(getControllerId());
}

@Override
public boolean checkTrigger(GameEvent event, Game game) {
return !getFilteredEvents((DamagedBatchForPlayersEvent) event, game).isEmpty();
}

@Override
Expand Down
36 changes: 19 additions & 17 deletions Mage.Sets/src/mage/cards/h/HordewingSkaab.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mage.cards.h;

import mage.MageInt;
import mage.abilities.BatchTriggeredAbility;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.DrawDiscardControllerEffect;
Expand All @@ -15,8 +16,8 @@
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.DamagedEvent;
import mage.game.events.DamagedBatchForPlayersEvent;
import mage.game.events.DamagedPlayerEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;

Expand Down Expand Up @@ -61,7 +62,7 @@ public HordewingSkaab copy() {
}
}

class HordewingSkaabTriggeredAbility extends TriggeredAbilityImpl {
class HordewingSkaabTriggeredAbility extends TriggeredAbilityImpl implements BatchTriggeredAbility<DamagedPlayerEvent> {

HordewingSkaabTriggeredAbility() {
super(Zone.BATTLEFIELD, null, true);
Expand All @@ -76,24 +77,25 @@ public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DAMAGED_BATCH_FOR_PLAYERS;
}

@Override
public boolean checkEvent(DamagedPlayerEvent event, Game game) {
if (!event.isCombatDamage() || !game.getOpponents(getControllerId()).contains(event.getTargetId())) {
return false;
}
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
return permanent != null
&& permanent.isControlledBy(getControllerId())
&& permanent.hasSubtype(SubType.ZOMBIE, game);
}

@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedBatchForPlayersEvent dEvent = (DamagedBatchForPlayersEvent) event;
Set<UUID> opponents = new HashSet<>();
for (DamagedEvent damagedEvent : dEvent.getEvents()) {
if (!damagedEvent.isCombatDamage()) {
continue;
}
Permanent permanent = game.getPermanent(damagedEvent.getSourceId());
if (permanent == null
|| !permanent.isControlledBy(getControllerId())
|| !permanent.hasSubtype(SubType.ZOMBIE, game)
|| !game.getOpponents(getControllerId()).contains(damagedEvent.getTargetId())) {
continue;
}
opponents.add(damagedEvent.getTargetId());
}
if (opponents.size() < 1) {
getFilteredEvents((DamagedBatchForPlayersEvent) event, game)
.stream()
.map(GameEvent::getTargetId)
.forEach(opponents::add);
if (opponents.isEmpty()) {
return false;
}
this.getEffects().clear();
Expand Down
33 changes: 19 additions & 14 deletions Mage.Sets/src/mage/cards/m/MalcolmKeenEyedNavigator.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mage.cards.m;

import mage.MageInt;
import mage.abilities.BatchTriggeredAbility;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.keyword.FlyingAbility;
Expand All @@ -12,8 +13,8 @@
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.DamagedEvent;
import mage.game.events.DamagedBatchForPlayersEvent;
import mage.game.events.DamagedPlayerEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.TreasureToken;
Expand Down Expand Up @@ -56,7 +57,7 @@ public MalcolmKeenEyedNavigator copy() {
}
}

class MalcolmKeenEyedNavigatorTriggeredAbility extends TriggeredAbilityImpl {
class MalcolmKeenEyedNavigatorTriggeredAbility extends TriggeredAbilityImpl implements BatchTriggeredAbility<DamagedPlayerEvent> {

MalcolmKeenEyedNavigatorTriggeredAbility() {
super(Zone.BATTLEFIELD, null);
Expand All @@ -71,21 +72,25 @@ public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DAMAGED_BATCH_FOR_PLAYERS;
}

@Override
public boolean checkEvent(DamagedPlayerEvent event, Game game) {
if (!game.getOpponents(getControllerId()).contains(event.getTargetId())) {
return false;
}
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
return permanent != null
&& permanent.isControlledBy(getControllerId())
&& permanent.hasSubtype(SubType.PIRATE, game);
}

@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedBatchForPlayersEvent dEvent = (DamagedBatchForPlayersEvent) event;
Set<UUID> opponents = new HashSet<>();
for (DamagedEvent damagedEvent : dEvent.getEvents()) {
Permanent permanent = game.getPermanent(damagedEvent.getSourceId());
if (permanent == null
|| !permanent.isControlledBy(getControllerId())
|| !permanent.hasSubtype(SubType.PIRATE, game)
|| !game.getOpponents(getControllerId()).contains(damagedEvent.getTargetId())) {
continue;
}
opponents.add(damagedEvent.getTargetId());
}
if (opponents.size() < 1) {
getFilteredEvents((DamagedBatchForPlayersEvent) event, game)
.stream()
.map(GameEvent::getTargetId)
.forEach(opponents::add);
if (opponents.isEmpty()) {
return false;
}
this.getEffects().clear();
Expand Down

0 comments on commit bc43b06

Please sign in to comment.