forked from External/mage
rewrote enum comparisons, iterator to removeIf, added some stream and filters
This commit is contained in:
parent
05e5ca3c78
commit
3a152ab3d6
41 changed files with 178 additions and 239 deletions
|
|
@ -33,6 +33,7 @@ import java.util.Collections;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.abilities.common.ZoneChangeTriggeredAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.keyword.ProtectionAbility;
|
||||
|
|
@ -44,9 +45,8 @@ import mage.util.ThreadLocalStringBuilder;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @param <T>
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Abilities<T> {
|
||||
|
||||
|
|
@ -171,7 +171,7 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
|||
public Abilities<Ability> getManaAbilities(Zone zone) {
|
||||
Abilities<Ability> abilities = new AbilitiesImpl<>();
|
||||
for (T ability : this) {
|
||||
if (ability.getAbilityType().equals(AbilityType.MANA) && ability.getZone().match(zone)) {
|
||||
if (ability.getAbilityType() == AbilityType.MANA && ability.getZone().match(zone)) {
|
||||
abilities.add(ability);
|
||||
}
|
||||
}
|
||||
|
|
@ -257,7 +257,7 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
|||
|
||||
@Override
|
||||
public boolean contains(T ability) {
|
||||
for (Iterator<T> iterator = this.iterator(); iterator.hasNext();) { // simple loop can cause java.util.ConcurrentModificationException
|
||||
for (Iterator<T> iterator = this.iterator(); iterator.hasNext(); ) { // simple loop can cause java.util.ConcurrentModificationException
|
||||
T test = iterator.next();
|
||||
// Checking also by getRule() without other restrictions is a problem when a triggered ability will be copied to a permanent that had the same ability
|
||||
// already before the copy. Because then it keeps the triggered ability twice and it triggers twice.
|
||||
|
|
@ -287,6 +287,7 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
|||
|
||||
@Override
|
||||
public boolean containsAll(Abilities<T> abilities) {
|
||||
|
||||
if (this.size() < abilities.size()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ import mage.game.events.GameEvent;
|
|||
if (this.size() > 0) {
|
||||
for (Iterator<DelayedTriggeredAbility> it = this.iterator();it.hasNext();) {
|
||||
DelayedTriggeredAbility ability = it.next();
|
||||
if (ability.getDuration().equals(Duration.Custom)){
|
||||
if (ability.getDuration()== Duration.Custom){
|
||||
if (ability.isInactive(game)) {
|
||||
it.remove();
|
||||
continue;
|
||||
|
|
@ -74,21 +74,11 @@ import mage.game.events.GameEvent;
|
|||
}
|
||||
|
||||
public void removeEndOfTurnAbilities() {
|
||||
for (Iterator<DelayedTriggeredAbility> it = this.iterator();it.hasNext();) {
|
||||
DelayedTriggeredAbility ability = it.next();
|
||||
if (ability.getDuration() == Duration.EndOfTurn) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
this.removeIf(ability -> ability.getDuration() == Duration.EndOfTurn);
|
||||
}
|
||||
|
||||
public void removeEndOfCombatAbilities() {
|
||||
for (Iterator<DelayedTriggeredAbility> it = this.iterator();it.hasNext();) {
|
||||
DelayedTriggeredAbility ability = it.next();
|
||||
if (ability.getDuration() == Duration.EndOfCombat) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
this.removeIf(ability -> ability.getDuration() == Duration.EndOfCombat);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -67,11 +67,6 @@ public class SpecialActions extends AbilitiesImpl<SpecialAction> {
|
|||
}
|
||||
|
||||
public void removeManaActions() {
|
||||
for (Iterator<SpecialAction> iterator = this.iterator(); iterator.hasNext();) {
|
||||
SpecialAction next = iterator.next();
|
||||
if (next.isManaAction()) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
this.removeIf(SpecialAction::isManaAction);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,22 +27,18 @@
|
|||
*/
|
||||
package mage.abilities;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.keyword.FlashAbility;
|
||||
import mage.cards.SplitCard;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.TimingRule;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class SpellAbility extends ActivatedAbilityImpl {
|
||||
|
|
@ -90,7 +86,7 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
|||
public boolean canActivate(UUID playerId, Game game) {
|
||||
if (game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.CAST_AS_INSTANT, this, playerId, game) // check this first to allow Offering in main phase
|
||||
|| this.spellCanBeActivatedRegularlyNow(playerId, game)) {
|
||||
if (spellAbilityType.equals(SpellAbilityType.SPLIT)) {
|
||||
if (spellAbilityType == SpellAbilityType.SPLIT) {
|
||||
return false;
|
||||
}
|
||||
// fix for Gitaxian Probe and casting opponent's spells
|
||||
|
|
@ -106,7 +102,7 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
|||
}
|
||||
}
|
||||
// Alternate spell abilities (Flashback, Overload) can't be cast with no mana to pay option
|
||||
if (getSpellAbilityType().equals(SpellAbilityType.BASE_ALTERNATE)) {
|
||||
if (getSpellAbilityType()== SpellAbilityType.BASE_ALTERNATE) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && getSourceId().equals(player.getCastSourceIdWithAlternateMana())) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public abstract class StaticAbility extends AbilityImpl {
|
|||
if (game.getShortLivingLKI(getSourceId(), zone)) {
|
||||
return true; // maybe this can be a problem if effects removed the ability from the object
|
||||
}
|
||||
if (game.getPermanentEntering(getSourceId()) != null && zone.equals(Zone.BATTLEFIELD)) {
|
||||
if (game.getPermanentEntering(getSourceId()) != null && zone == Zone.BATTLEFIELD) {
|
||||
return true; // abilities of permanents entering battlefield are countes as on battlefield
|
||||
}
|
||||
return super.isInUseableZone(game, source, event);
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
|
|||
case ZONE_CHANGE:
|
||||
case DESTROYED_PERMANENT:
|
||||
if (isLeavesTheBattlefieldTrigger()) {
|
||||
if (event.getType().equals(EventType.DESTROYED_PERMANENT)) {
|
||||
if (event.getType() == EventType.DESTROYED_PERMANENT) {
|
||||
source = game.getLastKnownInformation(getSourceId(), Zone.BATTLEFIELD);
|
||||
} else if (((ZoneChangeEvent) event).getTarget() != null) {
|
||||
source = ((ZoneChangeEvent) event).getTarget();
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class AttackedByCreatureTriggeredAbility extends TriggeredAbilityImpl {
|
|||
UUID playerId = game.getCombat().getDefendingPlayerId(event.getSourceId(), game);
|
||||
Permanent attackingCreature = game.getPermanent(event.getSourceId());
|
||||
if (getControllerId().equals(playerId) && attackingCreature != null) {
|
||||
if (!setTargetPointer.equals(SetTargetPointer.NONE)) {
|
||||
if (setTargetPointer != SetTargetPointer.NONE) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
switch (setTargetPointer) {
|
||||
case PERMANENT:
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class BeginningOfCombatTriggeredAbility extends TriggeredAbilityImpl {
|
|||
boolean yours = event.getPlayerId().equals(this.controllerId);
|
||||
if (yours && setTargetPointer) {
|
||||
if (getTargets().isEmpty()) {
|
||||
this.getEffects().stream().forEach((effect) -> {
|
||||
this.getEffects().forEach(effect -> {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
});
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ public class BeginningOfCombatTriggeredAbility extends TriggeredAbilityImpl {
|
|||
case OPPONENT:
|
||||
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
|
||||
if (setTargetPointer) {
|
||||
this.getEffects().stream().forEach((effect) -> {
|
||||
this.getEffects().forEach(effect -> {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
});
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ public class BeginningOfCombatTriggeredAbility extends TriggeredAbilityImpl {
|
|||
break;
|
||||
case ANY:
|
||||
if (setTargetPointer) {
|
||||
this.getEffects().stream().forEach((effect) -> {
|
||||
this.getEffects().forEach(effect -> {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class CycleAllTriggeredAbility extends TriggeredAbilityImpl {
|
|||
}
|
||||
StackObject item = game.getState().getStack().getFirst();
|
||||
if (item instanceof StackAbility
|
||||
&& ((StackAbility) item).getStackAbility() instanceof CyclingAbility) {
|
||||
&& item.getStackAbility() instanceof CyclingAbility) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public class DealsCombatDamageTriggeredAbility extends TriggeredAbilityImpl {
|
|||
return true;
|
||||
|
||||
}
|
||||
if (event.getType().equals(GameEvent.EventType.COMBAT_DAMAGE_STEP_PRE)) {
|
||||
if (event.getType()== GameEvent.EventType.COMBAT_DAMAGE_STEP_PRE) {
|
||||
usedInPhase = false;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -13,20 +13,19 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class DealsDamageAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
|
||||
public DealsDamageAttachedTriggeredAbility(Zone zone, Effect effect, boolean optional) {
|
||||
super(zone, effect, optional);
|
||||
}
|
||||
|
||||
|
||||
public DealsDamageAttachedTriggeredAbility(final DealsDamageAttachedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DealsDamageAttachedTriggeredAbility copy() {
|
||||
return new DealsDamageAttachedTriggeredAbility(this);
|
||||
|
|
@ -34,11 +33,11 @@ public class DealsDamageAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType().equals(GameEvent.EventType.DAMAGED_CREATURE)
|
||||
|| event.getType().equals(GameEvent.EventType.DAMAGED_PLAYER)
|
||||
|| event.getType().equals(GameEvent.EventType.DAMAGED_PLANESWALKER);
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_CREATURE
|
||||
|| event.getType() == GameEvent.EventType.DAMAGED_PLAYER
|
||||
|| event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent enchantment = game.getPermanent(this.getSourceId());
|
||||
|
|
@ -54,7 +53,7 @@ public class DealsDamageAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever enchanted creature deals damage, " + super.getRule();
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ import mage.game.permanent.Permanent;
|
|||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX
|
||||
*/
|
||||
public class DealsDamageToACreatureAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
|
@ -54,15 +53,15 @@ public class DealsDamageToACreatureAttachedTriggeredAbility extends TriggeredAbi
|
|||
}
|
||||
|
||||
public DealsDamageToACreatureAttachedTriggeredAbility(final DealsDamageToACreatureAttachedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
this.combatOnly = ability.combatOnly;
|
||||
this.attachedDescription = ability.attachedDescription;
|
||||
super(ability);
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
this.combatOnly = ability.combatOnly;
|
||||
this.attachedDescription = ability.attachedDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DealsDamageToACreatureAttachedTriggeredAbility copy() {
|
||||
return new DealsDamageToACreatureAttachedTriggeredAbility(this);
|
||||
return new DealsDamageToACreatureAttachedTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -74,18 +73,17 @@ public class DealsDamageToACreatureAttachedTriggeredAbility extends TriggeredAbi
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (!combatOnly || ((DamagedCreatureEvent) event).isCombatDamage()) {
|
||||
Permanent attachment = game.getPermanent(this.getSourceId());
|
||||
if (attachment != null
|
||||
&& attachment.getAttachedTo() != null
|
||||
&& event.getSourceId().equals(attachment.getAttachedTo())
|
||||
) {
|
||||
if (setTargetPointer) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
|
||||
effect.setValue("damage", event.getAmount());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (attachment != null
|
||||
&& attachment.getAttachedTo() != null
|
||||
&& event.getSourceId().equals(attachment.getAttachedTo())) {
|
||||
if (setTargetPointer) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
|
||||
effect.setValue("damage", event.getAmount());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
|
|
@ -93,11 +91,11 @@ public class DealsDamageToACreatureAttachedTriggeredAbility extends TriggeredAbi
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return new StringBuilder("Whenever ").append(attachedDescription)
|
||||
.append(" deals ")
|
||||
.append(combatOnly ? "combat ":"")
|
||||
.append("damage to a creature, ")
|
||||
.append(super.getRule()).toString();
|
||||
return new StringBuilder("Whenever ").append(attachedDescription)
|
||||
.append(" deals ")
|
||||
.append(combatOnly ? "combat " : "")
|
||||
.append("damage to a creature, ")
|
||||
.append(super.getRule()).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class DealsDamageToOneOrMoreCreaturesTriggeredAbility extends DealsDamageToACreatureTriggeredAbility {
|
||||
|
|
@ -28,7 +27,8 @@ public class DealsDamageToOneOrMoreCreaturesTriggeredAbility extends DealsDamage
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (super.checkTrigger(event, game)) {
|
||||
// check that combat damage does only once trigger also if multiple creatures were damaged because they block or were blocked by source
|
||||
if (game.getTurn().getStepType().equals(PhaseStep.COMBAT_DAMAGE) || game.getTurn().getStepType().equals(PhaseStep.FIRST_COMBAT_DAMAGE)) {
|
||||
if (game.getTurn().getStepType() == PhaseStep.COMBAT_DAMAGE
|
||||
|| game.getTurn().getStepType() == PhaseStep.FIRST_COMBAT_DAMAGE) {
|
||||
String stepHash = (String) game.getState().getValue("damageStep" + getOriginalId());
|
||||
String newStepHash = game.getStep().getType().toString() + game.getTurnNum();
|
||||
if (stepHash == null || !newStepHash.equals(stepHash)) {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class DiesCreatureTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.getFromZone().equals(Zone.BATTLEFIELD) && zEvent.getToZone().equals(Zone.GRAVEYARD)) {
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD) {
|
||||
if (filter.match(zEvent.getTarget(), sourceId, controllerId, game)) {
|
||||
if (setTargetPointer) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class LandfallAbility extends TriggeredAbilityImpl {
|
|||
&& permanent.getCardType().contains(CardType.LAND)
|
||||
&& permanent.getControllerId().equals(this.controllerId)) {
|
||||
triggeringLand = permanent;
|
||||
if (setTargetPointer.equals(SetTargetPointer.PERMANENT)) {
|
||||
if (setTargetPointer == SetTargetPointer.PERMANENT) {
|
||||
for (Effect effect : getAllEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(permanent, game));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ public class SpellCastAllTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null && filter.match(spell, getSourceId(), getControllerId(), game)) {
|
||||
if (!setTargetPointer.equals(SetTargetPointer.NONE)) {
|
||||
if (setTargetPointer != SetTargetPointer.NONE) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
switch (setTargetPointer) {
|
||||
case SPELL:
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ import mage.game.stack.Spell;
|
|||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class SpellCastOpponentTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
|
@ -60,7 +59,6 @@ public class SpellCastOpponentTriggeredAbility extends TriggeredAbilityImpl {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param zone
|
||||
* @param effect
|
||||
* @param filter
|
||||
|
|
@ -89,8 +87,8 @@ public class SpellCastOpponentTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (game.getPlayer(this.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null && filter.match(spell, game)) {
|
||||
if (!setTargetPointer.equals(SetTargetPointer.NONE)) {
|
||||
for (Effect effect: this.getEffects()) {
|
||||
if (setTargetPointer != SetTargetPointer.NONE) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
switch (setTargetPointer) {
|
||||
case SPELL:
|
||||
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
|
||||
|
|
@ -101,7 +99,7 @@ public class SpellCastOpponentTriggeredAbility extends TriggeredAbilityImpl {
|
|||
default:
|
||||
throw new UnsupportedOperationException("Value of SetTargetPointer not supported!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class SpellCounteredControllerTriggeredAbility extends TriggeredAbilityIm
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
StackObject stackObjectThatCountered = (StackObject) game.getStack().getStackObject(event.getSourceId());
|
||||
StackObject stackObjectThatCountered = game.getStack().getStackObject(event.getSourceId());
|
||||
if (stackObjectThatCountered == null) {
|
||||
stackObjectThatCountered = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ import mage.game.events.GameEvent.EventType;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class AtTheBeginOfMainPhaseDelayedTriggeredAbility extends DelayedTriggeredAbility {
|
||||
|
|
@ -93,8 +92,8 @@ public class AtTheBeginOfMainPhaseDelayedTriggeredAbility extends DelayedTrigger
|
|||
case ANY:
|
||||
return true;
|
||||
case YOU:
|
||||
boolean yours = event.getPlayerId().equals(this.controllerId);
|
||||
return yours;
|
||||
return event.getPlayerId().equals(this.controllerId);
|
||||
|
||||
case OPPONENT:
|
||||
if (game.getPlayer(this.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
|
||||
return true;
|
||||
|
|
@ -117,11 +116,11 @@ public class AtTheBeginOfMainPhaseDelayedTriggeredAbility extends DelayedTrigger
|
|||
switch (phaseSelection) {
|
||||
case NEXT_MAIN:
|
||||
case NEXT_MAIN_THIS_TURN:
|
||||
return EventType.PRECOMBAT_MAIN_PHASE_PRE.equals(eventType) || EventType.POSTCOMBAT_MAIN_PHASE_PRE.equals(eventType);
|
||||
return EventType.PRECOMBAT_MAIN_PHASE_PRE == eventType || EventType.POSTCOMBAT_MAIN_PHASE_PRE == eventType;
|
||||
case NEXT_POSTCOMAT_MAIN:
|
||||
return EventType.POSTCOMBAT_MAIN_PHASE_PRE.equals(eventType);
|
||||
return EventType.POSTCOMBAT_MAIN_PHASE_PRE == eventType;
|
||||
case NEXT_PRECOMBAT_MAIN:
|
||||
return EventType.PRECOMBAT_MAIN_PHASE_PRE.equals(eventType);
|
||||
return EventType.PRECOMBAT_MAIN_PHASE_PRE == eventType;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ public class AtTheBeginOfNextEndStepDelayedTriggeredAbility extends DelayedTrigg
|
|||
case ANY:
|
||||
return true;
|
||||
case YOU:
|
||||
boolean yours = event.getPlayerId().equals(this.controllerId);
|
||||
return yours;
|
||||
return event.getPlayerId().equals(this.controllerId);
|
||||
|
||||
case OPPONENT:
|
||||
if (game.getPlayer(this.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import mage.constants.PhaseStep;
|
|||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class AfterUpkeepStepCondtion implements Condition {
|
||||
|
|
@ -24,8 +23,8 @@ public class AfterUpkeepStepCondtion implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return !(game.getStep().getType().equals(PhaseStep.UNTAP)
|
||||
|| game.getStep().getType().equals(PhaseStep.UPKEEP));
|
||||
return !(game.getStep().getType() == PhaseStep.UNTAP
|
||||
|| game.getStep().getType() == PhaseStep.UPKEEP);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ import mage.util.CardUtil;
|
|||
*/
|
||||
public class CardsInHandCondition implements Condition {
|
||||
|
||||
public static enum CountType {
|
||||
public enum CountType {
|
||||
MORE_THAN, FEWER_THAN, EQUAL_TO
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class IsStepCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return phaseStep.equals(game.getStep().getType()) && (!onlyDuringYourSteps || game.getActivePlayerId().equals(source.getControllerId()));
|
||||
return phaseStep == game.getStep().getType() && (!onlyDuringYourSteps || game.getActivePlayerId().equals(source.getControllerId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -166,12 +166,7 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter
|
|||
if (alternativeCostsToCheck.canPay(ability, ability.getSourceId(), ability.getControllerId(), game)
|
||||
&& player.chooseUse(Outcome.Benefit, costChoiceText, this, game)) {
|
||||
if (ability instanceof SpellAbility) {
|
||||
for (Iterator<ManaCost> iterator = ability.getManaCostsToPay().iterator(); iterator.hasNext();) {
|
||||
ManaCost manaCost = iterator.next();
|
||||
if (manaCost instanceof VariableCost) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
ability.getManaCostsToPay().removeIf(manaCost -> manaCost instanceof VariableCost);
|
||||
CardUtil.reduceCost((SpellAbility) ability, ability.getManaCosts());
|
||||
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class OptionalAdditionalCostImpl<T extends OptionalAdditionalCostImpl> ex
|
|||
this.delimiter = delimiter;
|
||||
this.reminderText = "<i>(" + reminderText + ")</i>";
|
||||
this.activatedCounter = 0;
|
||||
this.add((Cost) cost);
|
||||
this.add(cost);
|
||||
}
|
||||
|
||||
public OptionalAdditionalCostImpl(final OptionalAdditionalCostImpl cost) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue