mirror of
https://github.com/correl/mage.git
synced 2025-01-11 11:05:23 +00:00
* Fixed that a player could wrongly not be chosen for not targeted effect, if the player had hexproof.
This commit is contained in:
parent
b76102b0cd
commit
17acc9f97d
4 changed files with 18 additions and 11 deletions
|
@ -221,18 +221,18 @@ public class HumanPlayer extends PlayerImpl {
|
|||
public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map<String, Serializable> options) {
|
||||
updateGameStatePriority("choose(5)", game);
|
||||
while (!abort) {
|
||||
Set<UUID> cards = target.possibleTargets(sourceId, playerId, game);
|
||||
if (cards == null || cards.isEmpty()) {
|
||||
Set<UUID> targetIds = target.possibleTargets(sourceId, playerId, game);
|
||||
if (targetIds == null || targetIds.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
boolean required = target.isRequired(sourceId, game);
|
||||
if (target.getTargets().size() >= target.getNumberOfTargets()) {
|
||||
required = false;
|
||||
}
|
||||
game.fireSelectTargetEvent(playerId, target.getMessage(), cards, required, options);
|
||||
game.fireSelectTargetEvent(playerId, target.getMessage(), targetIds, required, options);
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
if (!cards.contains(response.getUUID())) {
|
||||
if (!targetIds.contains(response.getUUID())) {
|
||||
continue;
|
||||
}
|
||||
if (target instanceof TargetPermanent) {
|
||||
|
|
|
@ -57,7 +57,11 @@ public class LeylineOfSanctity extends CardImpl {
|
|||
super(ownerId, 21, "Leyline of Sanctity", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}{W}");
|
||||
this.expansionSetCode = "M11";
|
||||
this.color.setWhite(true);
|
||||
|
||||
// If Leyline of Sanctity is in your opening hand, you may begin the game with it on the battlefield.
|
||||
this.addAbility(LeylineAbility.getInstance());
|
||||
|
||||
// You have hexproof. (You can't be the target of spells or abilities your opponents control.)
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControllerEffect(HexproofAbility.getInstance())));
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ import mage.target.common.TargetCreatureOrPlayer;
|
|||
*/
|
||||
public class GoblinGrenade extends CardImpl {
|
||||
|
||||
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("Goblin");
|
||||
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("a Goblin");
|
||||
|
||||
static {
|
||||
filter.add(new SubtypePredicate("Goblin"));
|
||||
|
|
|
@ -117,8 +117,9 @@ public class TargetPlayer extends TargetImpl {
|
|||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && !player.hasLeft() && filter.match(player, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets)
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -126,13 +127,14 @@ public class TargetPlayer extends TargetImpl {
|
|||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && !player.hasLeft() && filter.match(player, sourceId, sourceControllerId, game)) {
|
||||
if (player.canBeTargetedBy(targetSource, game))
|
||||
if (isNotTarget() || player.canBeTargetedBy(targetSource, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
|
@ -140,7 +142,7 @@ public class TargetPlayer extends TargetImpl {
|
|||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && !player.hasLeft() && filter.match(player, game)) {
|
||||
|
@ -154,8 +156,9 @@ public class TargetPlayer extends TargetImpl {
|
|||
public boolean isLegal(Ability source, Game game) {
|
||||
//20101001 - 608.2b
|
||||
for (UUID playerId: targets.keySet()) {
|
||||
if (canTarget(playerId, source, game))
|
||||
if (canTarget(playerId, source, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -174,7 +177,7 @@ public class TargetPlayer extends TargetImpl {
|
|||
Player player = game.getPlayer(id);
|
||||
if (player != null) {
|
||||
if (source != null) {
|
||||
return player.canBeTargetedBy(game.getObject(source.getSourceId()), game)
|
||||
return (isNotTarget() || player.canBeTargetedBy(game.getObject(source.getSourceId()), game))
|
||||
&& filter.match(player, source.getSourceId(), source.getControllerId(), game);
|
||||
} else {
|
||||
return filter.match(player, game);
|
||||
|
|
Loading…
Reference in a new issue