mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
* Fixed a problem if some of multiple targets can't be targeted during resolution (e.g. target got hexproof meanwhile) it was still targeted (e.g. it happens for INto the void).
This commit is contained in:
parent
8cf788e9cc
commit
80fc87a7f7
3 changed files with 96 additions and 15 deletions
|
@ -61,23 +61,27 @@
|
|||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.16</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<finalName>mage-tests</finalName>
|
||||
</build>
|
||||
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package org.mage.test.cards.abilities.keywords;
|
||||
|
||||
import mage.abilities.keyword.HexproofAbility;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class HexproofTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* Tests one target gets hexproof
|
||||
*/
|
||||
@Test
|
||||
public void testOneTargetOneGainingHexproof() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Elder of Laurels");
|
||||
addCard(Zone.HAND, playerA, "Ranger's Guile");
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Island", 4);
|
||||
addCard(Zone.HAND, playerB, "Into the Void");
|
||||
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Into the Void", "Elder of Laurels");
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, "Ranger's Guile", "Elder of Laurels");
|
||||
|
||||
setStopAt(2, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
// because of hexproof the Elder should be onto the battlefield
|
||||
assertPermanentCount(playerA, "Elder of Laurels", 1);
|
||||
assertPowerToughness(playerA, "Elder of Laurels", 3, 4);
|
||||
assertAbility(playerA, "Elder of Laurels", HexproofAbility.getInstance(), true);
|
||||
}
|
||||
/**
|
||||
* Tests one target gets hexproof
|
||||
*/
|
||||
@Test
|
||||
public void testTwoTargetsOneGainingHexproof() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Elder of Laurels");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Arbor Elf");
|
||||
addCard(Zone.HAND, playerA, "Ranger's Guile");
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Island", 4);
|
||||
addCard(Zone.HAND, playerB, "Into the Void");
|
||||
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Into the Void", "Elder of Laurels^Arbor Elf");
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, "Ranger's Guile", "Elder of Laurels");
|
||||
|
||||
setStopAt(2, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
// because of hexproof the Elder should be onto the battlefield
|
||||
assertPermanentCount(playerA, "Elder of Laurels", 1);
|
||||
assertPowerToughness(playerA, "Elder of Laurels", 3, 4);
|
||||
assertAbility(playerA, "Elder of Laurels", HexproofAbility.getInstance(), true);
|
||||
assertPermanentCount(playerA, "Arbor Elf", 0);
|
||||
}
|
||||
}
|
|
@ -1,10 +1,14 @@
|
|||
package mage.target.targetpointer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.*;
|
||||
import mage.target.Target;
|
||||
|
||||
public class FirstTargetPointer implements TargetPointer {
|
||||
|
||||
|
@ -40,12 +44,16 @@ public class FirstTargetPointer implements TargetPointer {
|
|||
public List<UUID> getTargets(Game game, Ability source) {
|
||||
ArrayList<UUID> target = new ArrayList<UUID>();
|
||||
if (source.getTargets().size() > 0) {
|
||||
Target currentTarget = source.getTargets().get(0);
|
||||
for (UUID targetId : source.getTargets().get(0).getTargets()) {
|
||||
Card card = game.getCard(targetId);
|
||||
if (card != null && zoneChangeCounter.containsKey(targetId)
|
||||
&& card.getZoneChangeCounter() != zoneChangeCounter.get(targetId)) {
|
||||
continue;
|
||||
}
|
||||
if (!currentTarget.canTarget(targetId, source, game)) {
|
||||
continue;
|
||||
}
|
||||
target.add(targetId);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue