mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
Various fixed. +3 tests passed.
This commit is contained in:
parent
c761c62a3e
commit
a47b8c25df
17 changed files with 156 additions and 96 deletions
|
|
@ -28,9 +28,6 @@
|
|||
|
||||
package mage.abilities;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.AbilityType;
|
||||
import mage.Constants.EffectType;
|
||||
import mage.Constants.Zone;
|
||||
|
|
@ -47,6 +44,10 @@ import mage.game.Game;
|
|||
import mage.target.Target;
|
||||
import mage.target.Targets;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Practically everything in the game is started from an Ability. This
|
||||
* interface describes what an Ability is composed of at the highest level.
|
||||
|
|
@ -356,8 +357,9 @@ public interface Ability extends Serializable {
|
|||
* Returns true if this abilities source is in the zone for the ability
|
||||
*
|
||||
* @param game
|
||||
* @param checkLKI
|
||||
* @return
|
||||
*/
|
||||
public boolean isInUseableZone(Game game);
|
||||
public boolean isInUseableZone(Game game, boolean checkLKI);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -458,12 +458,14 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isInUseableZone(Game game) {
|
||||
public boolean isInUseableZone(Game game, boolean checkLKI) {
|
||||
// try LKI first
|
||||
|
||||
MageObject lkiTest = game.getLastKnownInformation(getSourceId(), zone);
|
||||
if (lkiTest != null) {
|
||||
return true;
|
||||
if (checkLKI) {
|
||||
MageObject lkiTest = game.getLastKnownInformation(getSourceId(), zone);
|
||||
if (lkiTest != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// check against current state
|
||||
|
|
|
|||
|
|
@ -28,13 +28,14 @@
|
|||
|
||||
package mage.abilities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -51,7 +52,7 @@ public class TriggeredAbilities extends HashMap<UUID, TriggeredAbility> {
|
|||
|
||||
public void checkTriggers(GameEvent event, Game game) {
|
||||
for (TriggeredAbility ability: this.values()) {
|
||||
if (ability.isInUseableZone(game)) {
|
||||
if (ability.isInUseableZone(game, true)) {
|
||||
MageObject object = game.getLastKnownInformation(ability.getSourceId(), event.getZone());
|
||||
if (object == null) {
|
||||
object = game.getObject(ability.getSourceId());
|
||||
|
|
|
|||
|
|
@ -28,15 +28,11 @@
|
|||
|
||||
package mage.abilities.common;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -59,7 +55,7 @@ public class DiesTriggeredAbility extends ZoneChangeTriggeredAbility<DiesTrigger
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isInUseableZone(Game game) {
|
||||
public boolean isInUseableZone(Game game, boolean checkLKI) {
|
||||
// check it was previously on battlefield
|
||||
MageObject before = game.getLastKnownInformation(sourceId, Constants.Zone.BATTLEFIELD);
|
||||
// check now it is in graveyard
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ public class ContinuousEffects implements Serializable {
|
|||
case WhileOnStack:
|
||||
case WhileInGraveyard:
|
||||
Ability ability = layeredEffects.getAbility(effect.getId());
|
||||
if (ability.isInUseableZone(game))
|
||||
if (ability.isInUseableZone(game, false))
|
||||
layerEffects.add(effect);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -163,7 +163,7 @@ public class ContinuousEffects implements Serializable {
|
|||
List<RequirementEffect> effects = new ArrayList<RequirementEffect>();
|
||||
for (RequirementEffect effect: requirementEffects) {
|
||||
Ability ability = requirementEffects.getAbility(effect.getId());
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game)) {
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, false)) {
|
||||
if (effect.applies(permanent, ability, game))
|
||||
effects.add(effect);
|
||||
}
|
||||
|
|
@ -175,7 +175,7 @@ public class ContinuousEffects implements Serializable {
|
|||
List<RestrictionEffect> effects = new ArrayList<RestrictionEffect>();
|
||||
for (RestrictionEffect effect: restrictionEffects) {
|
||||
Ability ability = restrictionEffects.getAbility(effect.getId());
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game)) {
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, false)) {
|
||||
if (effect.applies(permanent, ability, game))
|
||||
effects.add(effect);
|
||||
}
|
||||
|
|
@ -198,7 +198,7 @@ public class ContinuousEffects implements Serializable {
|
|||
//get all applicable transient Replacement effects
|
||||
for (ReplacementEffect effect: replacementEffects) {
|
||||
Ability ability = replacementEffects.getAbility(effect.getId());
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game)) {
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, false)) {
|
||||
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
|
||||
if (effect.applies(event, ability, game)) {
|
||||
replaceEffects.add(effect);
|
||||
|
|
@ -208,7 +208,7 @@ public class ContinuousEffects implements Serializable {
|
|||
}
|
||||
for (PreventionEffect effect: preventionEffects) {
|
||||
Ability ability = preventionEffects.getAbility(effect.getId());
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game)) {
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, false)) {
|
||||
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
|
||||
if (effect.applies(event, ability, game)) {
|
||||
replaceEffects.add(effect);
|
||||
|
|
@ -230,7 +230,7 @@ public class ContinuousEffects implements Serializable {
|
|||
|
||||
for (CostModificationEffect effect: costModificationEffects) {
|
||||
Ability ability = costModificationEffects.getAbility(effect.getId());
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game)) {
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, false)) {
|
||||
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
|
||||
costEffects.add(effect);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -640,7 +640,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
if (checkStateAndTriggered()) {
|
||||
applyEffects();
|
||||
}
|
||||
resetLKI();
|
||||
//resetLKI();
|
||||
applyEffects();
|
||||
if (isPaused() || isGameOver()) return;
|
||||
// resetPassed should be called if player performs any action
|
||||
|
|
@ -660,7 +660,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
state.getPlayers().resetPassed();
|
||||
fireUpdatePlayersEvent();
|
||||
state.getRevealed().reset();
|
||||
resetLKI();
|
||||
//resetLKI();
|
||||
break;
|
||||
} else {
|
||||
//removeBookmark(bookmark);
|
||||
|
|
|
|||
|
|
@ -28,16 +28,6 @@
|
|||
|
||||
package mage.game;
|
||||
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.SpellStack;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.*;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
|
|
@ -48,11 +38,10 @@ import mage.choices.Choice;
|
|||
import mage.game.combat.Combat;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.command.Command;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Battlefield;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.stack.SpellStack;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.game.turn.Turn;
|
||||
import mage.game.turn.TurnMods;
|
||||
|
|
@ -64,6 +53,9 @@ import mage.util.Copyable;
|
|||
import mage.watchers.Watcher;
|
||||
import mage.watchers.Watchers;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
|
|||
|
|
@ -28,37 +28,32 @@
|
|||
|
||||
package mage.game.stack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import mage.Constants.AbilityType;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.Modes;
|
||||
import mage.abilities.costs.AlternativeCost;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.Costs;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.Choices;
|
||||
import mage.game.*;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.EffectType;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.abilities.AbilitiesImpl;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.StateTriggeredAbility;
|
||||
import mage.abilities.*;
|
||||
import mage.abilities.costs.AlternativeCost;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.Costs;
|
||||
import mage.abilities.costs.CostsImpl;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.Choices;
|
||||
import mage.game.Game;
|
||||
import mage.target.Target;
|
||||
import mage.target.Targets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -329,7 +324,7 @@ public class StackAbility implements StackObject, Ability {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isInUseableZone(Game game) {
|
||||
public boolean isInUseableZone(Game game, boolean checkLKI) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue