mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
fixed Ongoing Investigation trigger (#4052)
This commit is contained in:
parent
70c50656dd
commit
954ebd1652
2 changed files with 20 additions and 32 deletions
|
@ -27,15 +27,14 @@
|
|||
*/
|
||||
package mage.cards.o;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.ExileFromGraveCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.GainLifeEffect;
|
||||
import mage.abilities.effects.keyword.InvestigateEffect;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -46,7 +45,6 @@ import mage.filter.common.FilterCreatureCard;
|
|||
import mage.game.Game;
|
||||
import mage.game.events.DamagedPlayerEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
|
||||
|
@ -81,8 +79,7 @@ public class OngoingInvestigation extends CardImpl {
|
|||
|
||||
class OngoingInvestigationTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private boolean madeDamage = false;
|
||||
private Set<UUID> damagedPlayers = new HashSet<>();
|
||||
List<UUID> damagedPlayerIds = new ArrayList<>();
|
||||
|
||||
public OngoingInvestigationTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new InvestigateEffect(), false);
|
||||
|
@ -90,9 +87,6 @@ class OngoingInvestigationTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
public OngoingInvestigationTriggeredAbility(final OngoingInvestigationTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.madeDamage = ability.madeDamage;
|
||||
this.damagedPlayers = new HashSet<>();
|
||||
this.damagedPlayers.addAll(ability.damagedPlayers);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -102,36 +96,30 @@ class OngoingInvestigationTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.DAMAGED_PLAYER || event.getType() == EventType.COMBAT_DAMAGE_STEP_POST;
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER
|
||||
|| event.getType() == GameEvent.EventType.END_COMBAT_STEP_POST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.DAMAGED_PLAYER) {
|
||||
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
|
||||
Permanent p = game.getPermanent(event.getSourceId());
|
||||
if (damageEvent.isCombatDamage() && p != null && p.getControllerId().equals(this.getControllerId())) {
|
||||
madeDamage = true;
|
||||
damagedPlayers.add(event.getPlayerId());
|
||||
}
|
||||
}
|
||||
if (event.getType() == EventType.COMBAT_DAMAGE_STEP_POST) {
|
||||
if (madeDamage) {
|
||||
Set<UUID> damagedPlayersCopy = new HashSet<>();
|
||||
damagedPlayersCopy.addAll(damagedPlayers);
|
||||
for(Effect effect: this.getEffects()) {
|
||||
effect.setValue("damagedPlayers", damagedPlayersCopy);
|
||||
}
|
||||
damagedPlayers.clear();
|
||||
madeDamage = false;
|
||||
if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER) {
|
||||
if (((DamagedPlayerEvent) event).isCombatDamage()) {
|
||||
Permanent creature = game.getPermanent(event.getSourceId());
|
||||
if (creature != null && creature.getControllerId().equals(controllerId)
|
||||
&& !damagedPlayerIds.contains(event.getTargetId())) {
|
||||
damagedPlayerIds.add(event.getTargetId());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.END_COMBAT_STEP_POST) {
|
||||
damagedPlayerIds.clear();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever one or more creatures you control deal combat damage to a player, " + super.getRule();
|
||||
return "Whenever one or more creatures you control deal combat damage to a player, investigate";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,6 +149,6 @@ class ThopterSpyNetworkDamageTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever one or more artifact creatures you control deals combat damage to a player, draw a card";
|
||||
return "Whenever one or more artifact creatures you control deal combat damage to a player, draw a card";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue