mirror of
https://github.com/correl/mage.git
synced 2025-03-13 01:09:53 -09:00
Enhanced TargetSource class
This commit is contained in:
parent
92a9c10c16
commit
f3598fd4db
2 changed files with 43 additions and 7 deletions
Mage/src/mage
|
@ -28,16 +28,13 @@
|
|||
|
||||
package mage.game;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import mage.cards.Card;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.util.Copyable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -98,6 +95,14 @@ public class Exile implements Serializable, Copyable<Exile> {
|
|||
return null;
|
||||
}
|
||||
|
||||
public List<Card> getAllCards(Game game) {
|
||||
List<Card> cards = new ArrayList<Card>();
|
||||
for (ExileZone exile: exileZones.values()) {
|
||||
cards.addAll(exile.getCards(game));
|
||||
}
|
||||
return cards;
|
||||
}
|
||||
|
||||
public void removeCard(Card card, Game game) {
|
||||
for (ExileZone exile: exileZones.values()) {
|
||||
if (exile.contains(card.getId()))
|
||||
|
|
|
@ -31,10 +31,12 @@ package mage.target;
|
|||
import mage.Constants.Zone;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.filter.FilterObject;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -71,6 +73,7 @@ public class TargetSource extends TargetObject<TargetSource> {
|
|||
public TargetSource(final TargetSource target) {
|
||||
super(target);
|
||||
this.filter = target.filter.copy();
|
||||
setNotTarget(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -120,6 +123,22 @@ public class TargetSource extends TargetObject<TargetSource> {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
for (Player player : game.getPlayers().values()) {
|
||||
for (Card card : player.getGraveyard().getCards(game)) {
|
||||
if (filter.match(card, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Card card : game.getExile().getAllCards(game)) {
|
||||
if (filter.match(card, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -141,6 +160,18 @@ public class TargetSource extends TargetObject<TargetSource> {
|
|||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
for (Player player : game.getPlayers().values()) {
|
||||
for (Card card : player.getGraveyard().getCards(game)) {
|
||||
if (filter.match(card, game)) {
|
||||
possibleTargets.add(card.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Card card : game.getExile().getAllCards(game)) {
|
||||
if (filter.match(card, game)) {
|
||||
possibleTargets.add(card.getId());
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue