mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Refactor: improved checks from 5c15400f02
This commit is contained in:
parent
ee74c7547c
commit
7998e31da6
3 changed files with 23 additions and 143 deletions
|
@ -1,27 +1,21 @@
|
|||
package mage.cards.s;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.abilities.keyword.HexproofAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.command.Emblem;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackAbility;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author noxx
|
||||
*/
|
||||
|
@ -76,45 +70,11 @@ class SigardaHostOfHeronsEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
UUID eventSourceControllerId = game.getControllerId(event.getSourceId());
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (controller != null
|
||||
&& permanent.getControllerId() == source.getControllerId()) {
|
||||
if (object instanceof PermanentCard) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((PermanentCard) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof Spell) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((Spell) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof Emblem) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((Emblem) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof Ability) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((Ability) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof SpellAbility) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((SpellAbility) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof StackAbility) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((StackAbility) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof Card) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((Card) object).getOwnerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (controller != null && permanent != null && permanent.getControllerId() == source.getControllerId()) {
|
||||
return game.getOpponents(source.getControllerId()).contains(eventSourceControllerId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,25 +1,19 @@
|
|||
package mage.cards.t;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.command.Emblem;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackAbility;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author noxx
|
||||
*/
|
||||
|
@ -76,46 +70,13 @@ class TajuruPreserverEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
UUID eventSourceControllerId = game.getControllerId(event.getSourceId());
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (controller != null
|
||||
&& permanent.getControllerId() == source.getControllerId()) {
|
||||
if (object instanceof PermanentCard) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((PermanentCard) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof Spell) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((Spell) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof Emblem) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((Emblem) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof Ability) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((Ability) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof SpellAbility) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((SpellAbility) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof StackAbility) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((StackAbility) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof Card) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((Card) object).getOwnerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (controller != null && permanent != null && permanent.getControllerId() == source.getControllerId()) {
|
||||
return game.getOpponents(source.getControllerId()).contains(eventSourceControllerId);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package mage.cards.t;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.LoyaltyAbility;
|
||||
import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility;
|
||||
|
@ -15,18 +14,13 @@ import mage.choices.ChoiceImpl;
|
|||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackAbility;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.SpellAbility;
|
||||
|
||||
import static mage.constants.Outcome.Benefit;
|
||||
import mage.game.command.Emblem;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
|
@ -88,51 +82,16 @@ class TamiyoCollectorOfTalesRuleEffect extends ContinuousRuleModifyingEffectImpl
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
Card cardInHand = game.getCard(event.getTargetId());
|
||||
if (controller != null) {
|
||||
if (permanent != null
|
||||
&& permanent.getControllerId() == source.getControllerId()
|
||||
|| cardInHand != null
|
||||
&& cardInHand.getOwnerId() == source.getControllerId()) {
|
||||
UUID eventSourceControllerId = game.getControllerId(event.getSourceId());
|
||||
|
||||
if (object instanceof PermanentCard) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((PermanentCard) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof Spell) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((Spell) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof Emblem) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((Emblem) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof Ability) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((Ability) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof SpellAbility) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((SpellAbility) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof StackAbility) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((StackAbility) object).getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (object instanceof Card) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(((Card) object).getOwnerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (controller != null && permanent != null && permanent.getControllerId() == source.getControllerId()) {
|
||||
return game.getOpponents(source.getControllerId()).contains(eventSourceControllerId);
|
||||
}
|
||||
|
||||
Card cardInHand = game.getCard(event.getTargetId());
|
||||
if (controller != null && cardInHand != null && cardInHand.getOwnerId() == source.getControllerId()) {
|
||||
return game.getOpponents(source.getControllerId()).contains(eventSourceControllerId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue