mirror of
https://github.com/correl/mage.git
synced 2025-01-12 11:08:01 +00:00
Reworked Hate condition.
This commit is contained in:
parent
9cf9d69c55
commit
c703ebaa9d
16 changed files with 47 additions and 57 deletions
|
@ -44,7 +44,7 @@ import mage.constants.CardType;
|
|||
import mage.constants.Duration;
|
||||
import mage.constants.Rarity;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.watchers.common.NonCombatDamageWatcher;
|
||||
import mage.watchers.common.LifeLossOtherFromCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -76,7 +76,7 @@ public class AsajjVentress extends CardImpl {
|
|||
HateCondition.getInstance(),
|
||||
"<i>Hate</i> — Whenever Asajj Ventress attacks, if an opponent lost life from a source other than combat damage this turn, target creature blocks this turn if able");
|
||||
ability.addTarget(new TargetCreaturePermanent());
|
||||
this.addAbility(ability, new NonCombatDamageWatcher());
|
||||
this.addAbility(ability, new LifeLossOtherFromCombatWatcher());
|
||||
}
|
||||
|
||||
public AsajjVentress(final AsajjVentress card) {
|
||||
|
|
|
@ -35,7 +35,7 @@ import mage.abilities.effects.common.GainLifeEffect;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.watchers.common.NonCombatDamageWatcher;
|
||||
import mage.watchers.common.LifeLossOtherFromCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -59,7 +59,7 @@ public class BatheInBacta extends CardImpl {
|
|||
HateCondition.getInstance(),
|
||||
"If you lost life from a source other than combat damage this turn, you gain 9 life instead"));
|
||||
|
||||
this.getSpellAbility().addWatcher(new NonCombatDamageWatcher());
|
||||
this.getSpellAbility().addWatcher(new LifeLossOtherFromCombatWatcher());
|
||||
}
|
||||
|
||||
public BatheInBacta(final BatheInBacta card) {
|
||||
|
|
|
@ -38,7 +38,7 @@ import mage.constants.CardType;
|
|||
import mage.constants.Rarity;
|
||||
import mage.constants.TargetController;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.watchers.common.NonCombatDamageWatcher;
|
||||
import mage.watchers.common.LifeLossOtherFromCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -56,7 +56,7 @@ public class DarkApprenticeship extends CardImpl {
|
|||
HateCondition.getInstance(),
|
||||
"<i>Hate</i> — At the beggining of each end step, if an opponent lost life from source other than combat damage this turn, Dark Apprenticeship deals 2 damage to target player.");
|
||||
ability.addTarget(new TargetPlayer());
|
||||
this.addAbility(ability, new NonCombatDamageWatcher());
|
||||
this.addAbility(ability, new LifeLossOtherFromCombatWatcher());
|
||||
}
|
||||
|
||||
public DarkApprenticeship(final DarkApprenticeship card) {
|
||||
|
|
|
@ -41,7 +41,7 @@ import mage.constants.CardType;
|
|||
import mage.constants.Duration;
|
||||
import mage.constants.Rarity;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.watchers.common.NonCombatDamageWatcher;
|
||||
import mage.watchers.common.LifeLossOtherFromCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -70,7 +70,7 @@ public class DarthMaul extends CardImpl {
|
|||
HateCondition.getInstance(),
|
||||
"<i>Hate</i> — Whenever Darth Maul attacks, if an opponent loses life from a source other than combat damage this turn, target creature can't block this turn.");
|
||||
ability.addTarget(new TargetCreaturePermanent());
|
||||
this.addAbility(ability, new NonCombatDamageWatcher());
|
||||
this.addAbility(ability, new LifeLossOtherFromCombatWatcher());
|
||||
}
|
||||
|
||||
public DarthMaul(final DarthMaul card) {
|
||||
|
|
|
@ -39,7 +39,7 @@ import mage.cards.CardImpl;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.target.TargetSpell;
|
||||
import mage.watchers.common.NonCombatDamageWatcher;
|
||||
import mage.watchers.common.LifeLossOtherFromCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -63,7 +63,7 @@ public class ForceDenial extends CardImpl {
|
|||
HateCondition.getInstance(),
|
||||
"<br><i>Hate</i> - If an opponent lost life from a source other than combat damage this turn, counter that spell instead."));
|
||||
this.getSpellAbility().addTarget(new TargetSpell());
|
||||
this.getSpellAbility().addWatcher(new NonCombatDamageWatcher());
|
||||
this.getSpellAbility().addWatcher(new LifeLossOtherFromCombatWatcher());
|
||||
|
||||
// Scry 1
|
||||
this.getSpellAbility().addEffect(new ScryEffect(1));
|
||||
|
|
|
@ -41,7 +41,7 @@ import mage.constants.CardType;
|
|||
import mage.constants.Rarity;
|
||||
import mage.constants.TargetController;
|
||||
import mage.game.permanent.token.Token;
|
||||
import mage.watchers.common.NonCombatDamageWatcher;
|
||||
import mage.watchers.common.LifeLossOtherFromCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -60,7 +60,7 @@ public class IronFistOfTheEmpire extends CardImpl {
|
|||
triggeredAbility,
|
||||
HateCondition.getInstance(),
|
||||
"<i>Hate</i> — At the beggining of each end step, if opponent lost life from a source other than combat damage this turn, you gain 1 life and create a 2/2 red Soldier creature token with first strike named Royal Guard.");
|
||||
this.addAbility(ability, new NonCombatDamageWatcher());
|
||||
this.addAbility(ability, new LifeLossOtherFromCombatWatcher());
|
||||
}
|
||||
|
||||
public IronFistOfTheEmpire(final IronFistOfTheEmpire card) {
|
||||
|
|
|
@ -42,7 +42,7 @@ import mage.filter.common.FilterCreaturePermanent;
|
|||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.watchers.common.NonCombatDamageWatcher;
|
||||
import mage.watchers.common.LifeLossOtherFromCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -70,7 +70,7 @@ public class SithAssassin extends CardImpl {
|
|||
HateCondition.getInstance(),
|
||||
"<i>Hate</i> - When {this} enters the battlefield, if an opponent lost life from a source other than combat damage this turn, destroy target nonblack creature.");
|
||||
ability.addTarget(new TargetCreaturePermanent(filter));
|
||||
this.addAbility(ability, new NonCombatDamageWatcher());
|
||||
this.addAbility(ability, new LifeLossOtherFromCombatWatcher());
|
||||
}
|
||||
|
||||
public SithAssassin(final SithAssassin card) {
|
||||
|
|
|
@ -38,7 +38,7 @@ import mage.cards.CardImpl;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.target.common.TargetOpponent;
|
||||
import mage.watchers.common.NonCombatDamageWatcher;
|
||||
import mage.watchers.common.LifeLossOtherFromCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -60,7 +60,7 @@ public class SithInquisitor extends CardImpl {
|
|||
HateCondition.getInstance(),
|
||||
"<i>Hate</i> — When {this} enters the battlefield, if an opponent lost life from a source other then combat damage this turn, target player discard a card at random.");
|
||||
ability.addTarget(new TargetOpponent());
|
||||
this.addAbility(ability, new NonCombatDamageWatcher());
|
||||
this.addAbility(ability, new LifeLossOtherFromCombatWatcher());
|
||||
}
|
||||
|
||||
public SithInquisitor(final SithInquisitor card) {
|
||||
|
|
|
@ -58,7 +58,7 @@ import mage.game.permanent.Permanent;
|
|||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInGraveyard;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.watchers.common.NonCombatDamageWatcher;
|
||||
import mage.watchers.common.LifeLossOtherFromCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -78,7 +78,7 @@ public class SithMagic extends CardImpl {
|
|||
HateCondition.getInstance(),
|
||||
"<i>Hate</i> — At the beggining of each combat, if opponent lost life from a source other than combat damage this turn, you may return target card from a graveyard to the battlefield under your control. It gains lifelink and haste. Exile it at the beginning of the next end step or if it would leave the battlefield.");
|
||||
ability.addTarget(new TargetCardInGraveyard(new FilterCreatureCard()));
|
||||
this.addAbility(ability, new NonCombatDamageWatcher());
|
||||
this.addAbility(ability, new LifeLossOtherFromCombatWatcher());
|
||||
}
|
||||
|
||||
public SithMagic(final SithMagic card) {
|
||||
|
|
|
@ -40,7 +40,7 @@ import mage.cards.CardImpl;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.watchers.common.NonCombatDamageWatcher;
|
||||
import mage.watchers.common.LifeLossOtherFromCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -62,7 +62,7 @@ public class SithManipulator extends CardImpl {
|
|||
new InvertCondition(HateCondition.getInstance()),
|
||||
"When Sith Manipulator enters the battlefield, return target creature to its owner's hand");
|
||||
ability.addTarget(new TargetCreaturePermanent());
|
||||
this.addAbility(ability, new NonCombatDamageWatcher());
|
||||
this.addAbility(ability, new LifeLossOtherFromCombatWatcher());
|
||||
|
||||
// <i>Hate</i> — If opponent lost life from source other than combat damage this turn, put that card on top of its owner's library instead.
|
||||
ability = new ConditionalTriggeredAbility(
|
||||
|
@ -70,7 +70,7 @@ public class SithManipulator extends CardImpl {
|
|||
HateCondition.getInstance(),
|
||||
"<i>Hate</i> — If opponent lost life from source other than combat damage this turn, put that card on top of its owner's library instead");
|
||||
ability.addTarget(new TargetCreaturePermanent());
|
||||
this.addAbility(ability, new NonCombatDamageWatcher());
|
||||
this.addAbility(ability, new LifeLossOtherFromCombatWatcher());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ import mage.cards.CardImpl;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
import mage.watchers.common.NonCombatDamageWatcher;
|
||||
import mage.watchers.common.LifeLossOtherFromCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -60,7 +60,7 @@ public class SithMarauder extends CardImpl {
|
|||
HateCondition.getInstance(),
|
||||
"<i>Hate</i> — When {this} enters the battlefield, if an opponent lost life from a source other than combat damage this turn, {this} deals 3 damage to target creature or player");
|
||||
ability.addTarget(new TargetCreatureOrPlayer());
|
||||
this.addAbility(ability, new NonCombatDamageWatcher());
|
||||
this.addAbility(ability, new LifeLossOtherFromCombatWatcher());
|
||||
}
|
||||
|
||||
public SithMarauder(final SithMarauder card) {
|
||||
|
|
|
@ -40,7 +40,7 @@ import mage.constants.CardType;
|
|||
import mage.constants.Duration;
|
||||
import mage.constants.Rarity;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.watchers.common.NonCombatDamageWatcher;
|
||||
import mage.watchers.common.LifeLossOtherFromCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -62,7 +62,7 @@ public class SithMindseer extends CardImpl {
|
|||
HateCondition.getInstance(),
|
||||
"<i>Hate</i> — When Sith Mindseer enters the battlefield, if an opponent loses life from a source other than combat damage, gain control of target creature for as long as Sith Mindseer remains on the battlefield.");
|
||||
ability.addTarget(new TargetCreaturePermanent());
|
||||
this.addAbility(ability, new NonCombatDamageWatcher());
|
||||
this.addAbility(ability, new LifeLossOtherFromCombatWatcher());
|
||||
}
|
||||
|
||||
public SithMindseer(final SithMindseer card) {
|
||||
|
|
|
@ -38,7 +38,7 @@ import mage.abilities.effects.keyword.ScryEffect;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.watchers.common.NonCombatDamageWatcher;
|
||||
import mage.watchers.common.LifeLossOtherFromCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -62,7 +62,7 @@ public class SithSorcerer extends CardImpl {
|
|||
new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1)),
|
||||
HateCondition.getInstance(),
|
||||
"<i>Hate</i> — When {this} enters the battlefield, if an opponent lost life from a source other than combat damage this turn, draw a card.");
|
||||
this.addAbility(ability, new NonCombatDamageWatcher());
|
||||
this.addAbility(ability, new LifeLossOtherFromCombatWatcher());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ import mage.filter.common.FilterControlledPermanent;
|
|||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.watchers.common.NonCombatDamageWatcher;
|
||||
import mage.watchers.common.LifeLossOtherFromCombatWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -60,7 +60,7 @@ public class Terentatek extends CardImpl {
|
|||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new Terentatek1RestrictionEffect()));
|
||||
|
||||
// <i>Hate</i> — If an opponent lost life from source other than combat damage this turn, Terentatek may attack as though you controlled a Sith.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new Terentatek2RestrictionEffect()), new NonCombatDamageWatcher());
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new Terentatek2RestrictionEffect()), new LifeLossOtherFromCombatWatcher());
|
||||
|
||||
}
|
||||
|
||||
|
@ -142,8 +142,8 @@ class Terentatek2RestrictionEffect extends RestrictionEffect {
|
|||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
if (permanent.getId().equals(source.getSourceId())) {
|
||||
NonCombatDamageWatcher watcher = (NonCombatDamageWatcher) game.getState().getWatchers().get("NonCombatDamageWatcher");
|
||||
return watcher != null && watcher.opponentsBeenDealtNonCombatDamage(source.getControllerId());
|
||||
LifeLossOtherFromCombatWatcher watcher = (LifeLossOtherFromCombatWatcher) game.getState().getWatchers().get("NonCombatDamageWatcher");
|
||||
return watcher != null && watcher.opponentLostLifeOtherFromCombat(source.getControllerId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ package mage.abilities.condition.common;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.game.Game;
|
||||
import mage.watchers.common.NonCombatDamageWatcher;
|
||||
import mage.watchers.common.LifeLossOtherFromCombatWatcher;
|
||||
|
||||
/**
|
||||
* Describes condition when an opponent has been dealt any amount of non-combat
|
||||
|
@ -54,8 +54,8 @@ public class HateCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
NonCombatDamageWatcher watcher = (NonCombatDamageWatcher) game.getState().getWatchers().get("NonCombatDamageWatcher");
|
||||
return watcher != null && watcher.opponentsBeenDealtNonCombatDamage(source.getControllerId());
|
||||
LifeLossOtherFromCombatWatcher watcher = (LifeLossOtherFromCombatWatcher) game.getState().getWatchers().get(LifeLossOtherFromCombatWatcher.class.getName());
|
||||
return watcher != null && watcher.opponentLostLifeOtherFromCombat(source.getControllerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,58 +32,48 @@ import java.util.Set;
|
|||
import java.util.UUID;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamagedPlayerEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
/*
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class NonCombatDamageWatcher extends Watcher {
|
||||
public class LifeLossOtherFromCombatWatcher extends Watcher {
|
||||
|
||||
private final Set<UUID> playersBeenDealtNonCombatDamage = new HashSet<>();
|
||||
private final Set<UUID> players = new HashSet<>();
|
||||
|
||||
public NonCombatDamageWatcher() {
|
||||
super("NonCombatDamageWatcher", WatcherScope.GAME);
|
||||
public LifeLossOtherFromCombatWatcher() {
|
||||
super(LifeLossOtherFromCombatWatcher.class.getName(), WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public NonCombatDamageWatcher(final NonCombatDamageWatcher watcher) {
|
||||
public LifeLossOtherFromCombatWatcher(final LifeLossOtherFromCombatWatcher watcher) {
|
||||
super(watcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.LOST_LIFE) {
|
||||
if (event.getType() == GameEvent.EventType.LOST_LIFE && !event.getFlag()) {
|
||||
UUID playerId = event.getPlayerId();
|
||||
if (playerId != null) {
|
||||
playersBeenDealtNonCombatDamage.add(playerId);
|
||||
players.add(playerId);
|
||||
}
|
||||
} else if (event.getType() == EventType.DAMAGED_PLAYER) {
|
||||
DamagedPlayerEvent dEvent = (DamagedPlayerEvent) event;
|
||||
if (!dEvent.isCombatDamage()) {
|
||||
UUID playerId = event.getPlayerId();
|
||||
if (playerId != null) {
|
||||
playersBeenDealtNonCombatDamage.add(playerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean opponentsBeenDealtNonCombatDamage(UUID playerId) {
|
||||
return (!playersBeenDealtNonCombatDamage.contains(playerId) && playersBeenDealtNonCombatDamage.size() > 0)
|
||||
|| (playersBeenDealtNonCombatDamage.contains(playerId) && playersBeenDealtNonCombatDamage.size() > 1);
|
||||
public boolean opponentLostLifeOtherFromCombat(UUID playerId) {
|
||||
return (!players.contains(playerId) && players.size() > 0)
|
||||
|| (players.contains(playerId) && players.size() > 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
playersBeenDealtNonCombatDamage.clear();
|
||||
players.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonCombatDamageWatcher copy() {
|
||||
return new NonCombatDamageWatcher(this);
|
||||
public LifeLossOtherFromCombatWatcher copy() {
|
||||
return new LifeLossOtherFromCombatWatcher(this);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue