Various fixed. +3 tests passed.

This commit is contained in:
magenoxx 2012-05-24 00:24:01 +04:00
parent c761c62a3e
commit a47b8c25df
17 changed files with 156 additions and 96 deletions

View file

@ -396,16 +396,18 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
targets = threats(opponentId, source.getSourceId(), ((FilterCreatureOrPlayer)t.getFilter()).getCreatureFilter(), game, target.getTargets());
}
if (outcome.isGood()) {
if (target.canTarget(playerId, source, game)) {
target.addTarget(playerId, source, game);
return true;
if (targets.isEmpty()) {
if (outcome.isGood()) {
if (target.canTarget(playerId, source, game)) {
target.addTarget(playerId, source, game);
return true;
}
}
}
else {
if (target.canTarget(opponentId, source, game)) {
target.addTarget(opponentId, source, game);
return true;
else {
if (target.canTarget(opponentId, source, game)) {
target.addTarget(opponentId, source, game);
return true;
}
}
}
@ -422,6 +424,19 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
}
}
if (outcome.isGood()) {
if (target.canTarget(playerId, source, game)) {
target.addTarget(playerId, source, game);
return true;
}
}
else {
if (target.canTarget(opponentId, source, game)) {
target.addTarget(opponentId, source, game);
return true;
}
}
if (!target.isRequired())
return false;
}
@ -1501,12 +1516,12 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
protected List<Permanent> threats(UUID playerId, UUID sourceId, FilterPermanent filter, Game game, List<UUID> targets) {
List<Permanent> threats = playerId == null ?
game.getBattlefield().getAllActivePermanents(filter) :
game.getBattlefield().getAllActivePermanents(filter, playerId);
game.getBattlefield().getActivePermanents(filter, playerId, sourceId, game);
Iterator<Permanent> it = threats.iterator();
while (it.hasNext()) { // remove permanents already targeted
Permanent test = it.next();
if (targets.contains(test.getId()))
if (targets.contains(test.getId()) || (playerId != null && !test.getControllerId().equals(playerId)))
it.remove();
}
Collections.sort(threats, new PermanentComparator(game));

View file

@ -1,19 +1,72 @@
NAME:RB Aggro
4 [ALA:156] Blightning
2 [ZEN:245] Mountain
2 [ZEN:244] Mountain
2 [ZEN:243] Mountain
2 [ZEN:242] Mountain
4 [ZEN:223] Scalding Tarn
4 [M10:146] Lightning Bolt
4 [WWK:139] Lavaclaw Reaches
3 [M10:134] Earthquake
4 [ZEN:126] Goblin Guide
4 [CON:65] Hellspark Elemental
4 [M10:125] Ball Lightning
4 [ALA:103] Hell's Thunder
2 [CON:70] Quenchable Fire
3 [ZEN:119] Burst Lightning
4 [ZEN:211] Arid Mesa
4 [M10:223] Dragonskull Summit
4 [WWK:90] Searing Blaze
NAME:RB Aggro
1 [GUR:3] Mountain
1 [SHM:296] Mountain
1 [AVR:240] Mountain
1 [SHM:295] Mountain
1 [SHM:294] Mountain
1 [TSP:295] Mountain
1 [TSP:294] Mountain
1 [10E:379] Mountain
1 [SOM:245] Mountain
1 [ZEN:262] Mountain
1 [ZEN:245] Mountain
1 [10E:378] Mountain
1 [SOM:244] Mountain
1 [SOM:243] Mountain
1 [ZEN:244] Mountain
1 [SOM:242] Mountain
1 [ZEN:243] Mountain
1 [ZEN:242] Mountain
1 [ALA:243] Mountain
1 [ALA:242] Mountain
1 [M12:245] Mountain
1 [CHK:299] Mountain
1 [M12:243] Mountain
1 [M12:244] Mountain
1 [CHK:300] Mountain
1 [CHK:301] Mountain
1 [M12:242] Mountain
1 [CHK:302] Mountain
1 [10E:376] Mountain
1 [M11:243] Mountain
1 [M11:242] Mountain
1 [M11:245] Mountain
1 [M11:244] Mountain
1 [MBS:152] Mountain
1 [ALA:244] Mountain
1 [ALA:245] Mountain
1 [ZEN:263] Mountain
1 [ZEN:264] Mountain
1 [RAV:301] Mountain
1 [RAV:300] Mountain
1 [RAV:299] Mountain
1 [USG:345] Mountain
1 [USG:346] Mountain
1 [M10:242] Mountain
1 [RAV:302] Mountain
1 [USG:343] Mountain
1 [USG:344] Mountain
1 [ISD:259] Mountain
1 [ROE:244] Mountain
1 [ISD:261] Mountain
1 [ISD:260] Mountain
1 [ROE:241] Mountain
1 [ROE:242] Mountain
1 [ROE:243] Mountain
1 [MRD:301] Mountain
1 [MRD:300] Mountain
1 [MRD:299] Mountain
1 [M10:244] Mountain
1 [M10:243] Mountain
1 [M10:245] Mountain
1 [LRW:294] Mountain
1 [TMP:319] Mountain
1 [LRW:295] Mountain
1 [LRW:296] Mountain
1 [LRW:297] Mountain
1 [TMP:322] Mountain
1 [MRD:302] Mountain
1 [TMP:320] Mountain
1 [TMP:321] Mountain
1 [INV:345] Mountain
1 [INV:344] Mountain

View file

@ -350,6 +350,7 @@ public class SoulbondKeywordTest extends CardTestPlayerBase {
assertAbilities(playerA, "Elite Vanguard", abilities);
}
@Test
public void testExileAndReturnBack() {
//TODO: Soulbond + Soulshift
Assert.assertTrue(false);

View file

@ -26,7 +26,7 @@ public class ArchangelsLightTest extends CardTestPlayerBase {
assertLife(playerB, 20);
assertGraveyardCount(playerA, 1);
assertGraveyardCount(playerA, "Archangel's Light", 1);
Assert.assertEquals(currentGame.getPlayer(playerA.getId()).getLibrary().size(), 66);
Assert.assertEquals(currentGame.getPlayer(playerA.getId()).getLibrary().size(), 77);
}

View file

@ -61,10 +61,10 @@ public class SorinLordOfInnistradTest extends CardTestPlayerBase {
assertLife(playerA, 23);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Sorin, Lord of Innistrad", 0);
assertPermanentCount(playerA, "Craw Wurm", 1);
assertPermanentCount(playerB, "Craw Wurm", 0);
assertPermanentCount(playerA, "Angel of Mercy", 1);
assertPermanentCount(playerB, "Angel of Mercy", 0);
assertPermanentCount(playerA, "Craw Wurm", 1);
assertPermanentCount(playerA, "Angel of Mercy", 1);
}
}

View file

@ -42,8 +42,9 @@ public class CondemnTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Sejiri Merfolk", 0);
assertLife(playerB, 20);
assertLife(playerA, 21);
// check was put on top
Assert.assertEquals(currentGame.getPlayer(playerA.getId()).getLibrary().size(), 61);
Assert.assertEquals(72, currentGame.getPlayer(playerA.getId()).getLibrary().size());
}
}

View file

@ -13,7 +13,7 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
public class BloodArtistTest extends CardTestPlayerBase {
/**
* Tests that whenever Blood Artist goes to graveyard, it would trigget its ability.
* Tests that whenever Blood Artist goes to graveyard, it would trigger its ability.
* Tests that after Blood Artist went to graveyard, his ability doesn't work anymore.
*/
@Test
@ -26,9 +26,9 @@ public class BloodArtistTest extends CardTestPlayerBase {
addCard(Constants.Zone.BATTLEFIELD, playerB, "Bloodflow Connoisseur", 1);
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Blood Artist");
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Bloodflow Connoisseur");
castSpell(1, Constants.PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", "Bloodflow Connoisseur");
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
setStopAt(1, Constants.PhaseStep.END_TURN);
execute();
assertLife(playerA, 23);

View file

@ -230,7 +230,9 @@ public class TestPlayer extends ComputerPlayer<TestPlayer> {
for (UUID id: ability.getTargets().get(0).possibleTargets(ability.getSourceId(), ability.getControllerId(), game)) {
MageObject object = game.getObject(id);
if (object != null && object.getName().equals(t)) {
ability.getTargets().get(0).clearChosen();
if (ability.getTargets().get(0).getNumberOfTargets() == 1) {
ability.getTargets().get(0).clearChosen();
}
ability.getTargets().get(0).addTarget(id, ability, game);
break;
}

View file

@ -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);
}

View file

@ -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

View file

@ -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());

View file

@ -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

View file

@ -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);
}

View file

@ -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);

View file

@ -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

View file

@ -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.");
}
}