[refactor] removed generic parameter from Target

This commit is contained in:
North 2014-06-02 15:49:14 +03:00
parent 7af040e70b
commit 82a45cee88
57 changed files with 70 additions and 73 deletions

View file

@ -76,7 +76,7 @@ public class Outwit extends CardImpl<Outwit> {
return new Outwit(this);
}
private class CustomTargetSpell extends TargetObject<CustomTargetSpell> {
private class CustomTargetSpell extends TargetObject {
protected FilterSpell filter;

View file

@ -113,7 +113,7 @@ class StreamOfConsciousnessEffect extends OneShotEffect {
}
}
class StreamOfConsciousnessTarget extends TargetCard<StreamOfConsciousnessTarget> {
class StreamOfConsciousnessTarget extends TargetCard {
public StreamOfConsciousnessTarget() {
super(0, 4, Zone.GRAVEYARD, new FilterCard("cards from target player's graveyard"));

View file

@ -68,7 +68,7 @@ public class Reciprocate extends CardImpl<Reciprocate> {
}
class ReciprocateTarget extends TargetPermanent<ReciprocateTarget> {
class ReciprocateTarget extends TargetPermanent {
public ReciprocateTarget() {
super(1, 1, new FilterCreaturePermanent(), false);

View file

@ -75,7 +75,7 @@ public class Squelch extends CardImpl<Squelch> {
}
}
class ActivatedAbilityTarget extends TargetObject<ActivatedAbilityTarget> {
class ActivatedAbilityTarget extends TargetObject {
public ActivatedAbilityTarget() {
this.minNumberOfTargets = 1;

View file

@ -87,7 +87,7 @@ public class GiltspireAvenger extends CardImpl<GiltspireAvenger> {
}
}
class GiltspireAvengerTarget extends TargetPermanent<GiltspireAvengerTarget> {
class GiltspireAvengerTarget extends TargetPermanent {
public GiltspireAvengerTarget() {
super(1, 1, new FilterCreaturePermanent(), false);

View file

@ -206,7 +206,7 @@ class RavagerOfTheFellsEffect extends OneShotEffect {
}
class RavagerOfTheFellsTarget extends TargetPermanent<RavagerOfTheFellsTarget> {
class RavagerOfTheFellsTarget extends TargetPermanent {
public RavagerOfTheFellsTarget() {
super(0, 1, new FilterCreaturePermanent(), false);

View file

@ -110,7 +110,7 @@ class LoamingShamanEffect extends OneShotEffect {
}
}
class LoamingShamanTargetCardsInGraveyard extends TargetCard<LoamingShamanTargetCardsInGraveyard> {
class LoamingShamanTargetCardsInGraveyard extends TargetCard {
public LoamingShamanTargetCardsInGraveyard(int minNumTargets, int maxNumTargets, FilterCard filter) {
super(minNumTargets, maxNumTargets, Zone.GRAVEYARD, filter);

View file

@ -165,7 +165,7 @@ class BaneAlleyBrokerDrawExileEffect extends OneShotEffect {
}
}
class TargetCardInBaneAlleyBrokerExile extends TargetCard<TargetCardInBaneAlleyBrokerExile> {
class TargetCardInBaneAlleyBrokerExile extends TargetCard {
public TargetCardInBaneAlleyBrokerExile(UUID CardId) {
super(1, 1, Zone.EXILED, new FilterCard("card exiled with Bane Alley Broker"));

View file

@ -73,7 +73,7 @@ public class ExecutionersSwing extends CardImpl<ExecutionersSwing> {
}
}
class TargetCreaturePermanentThatDealtDamageThisTurn extends TargetPermanent<TargetCreaturePermanentThatDealtDamageThisTurn> {
class TargetCreaturePermanentThatDealtDamageThisTurn extends TargetPermanent {
public TargetCreaturePermanentThatDealtDamageThisTurn() {
super(1, 1, new FilterCreaturePermanent(), false);

View file

@ -117,7 +117,7 @@ class MemorysJourneyEffect extends OneShotEffect {
}
}
class MemorysJourneyTarget extends TargetCard<MemorysJourneyTarget> {
class MemorysJourneyTarget extends TargetCard {
public MemorysJourneyTarget() {
super(0, 3, Zone.GRAVEYARD, new FilterCard());

View file

@ -151,7 +151,7 @@ class TargetControlledPermanentSharingOpponentPermanentCardType extends TargetCo
}
class DaringThiefSecondTarget extends TargetPermanent<DaringThiefSecondTarget> {
class DaringThiefSecondTarget extends TargetPermanent {
private Permanent firstTarget = null;

View file

@ -146,7 +146,7 @@ class FaceUpPredicate implements Predicate<Card> {
}
}
class MirrorOfFateTarget extends TargetCard<MirrorOfFateTarget> {
class MirrorOfFateTarget extends TargetCard {
public MirrorOfFateTarget() {
super(0, 7, Zone.EXILED, new FilterCard());

View file

@ -139,7 +139,7 @@ class ChandraPyromasterEffect1 extends OneShotEffect {
}
}
class ChandraPyromasterTarget extends TargetPermanent<ChandraPyromasterTarget> {
class ChandraPyromasterTarget extends TargetPermanent {
public ChandraPyromasterTarget() {
super(0, 1, new FilterCreaturePermanent("creature that the targeted player controls"), false);

View file

@ -130,7 +130,7 @@ class StrionicResonatorEffect extends OneShotEffect {
}
}
class TargetTriggeredAbility extends TargetObject<TargetTriggeredAbility> {
class TargetTriggeredAbility extends TargetObject {
public TargetTriggeredAbility() {
this.minNumberOfTargets = 1;

View file

@ -94,7 +94,7 @@ public class AEtherBurst extends CardImpl<AEtherBurst> {
}
}
class DynamicTargetCreaturePermanent extends TargetPermanent<DynamicTargetCreaturePermanent> {
class DynamicTargetCreaturePermanent extends TargetPermanent {
private static final FilterCreaturePermanent filterCreature = new FilterCreaturePermanent("creatures");

View file

@ -116,7 +116,7 @@ class DiaochanArtfulBeautyDestroyEffect extends OneShotEffect {
}
}
class TargetOpponentsChoiceCreaturePermanent extends TargetPermanent<TargetOpponentsChoiceCreaturePermanent> {
class TargetOpponentsChoiceCreaturePermanent extends TargetPermanent {
private UUID opponentId = null;

View file

@ -69,7 +69,7 @@ public class AvengingArrow extends CardImpl<AvengingArrow> {
}
}
class AvengingArrowTarget extends TargetPermanent<AvengingArrowTarget> {
class AvengingArrowTarget extends TargetPermanent {
public AvengingArrowTarget() {
super(1, 1, new FilterCreaturePermanent(), false);

View file

@ -87,7 +87,7 @@ public class NotOfThisWorld extends CardImpl<NotOfThisWorld> {
}
}
class TargetSpellTargetingControlledPermanent extends TargetObject<TargetSpellTargetingControlledPermanent> {
class TargetSpellTargetingControlledPermanent extends TargetObject {
public TargetSpellTargetingControlledPermanent() {

View file

@ -73,7 +73,7 @@ public class TurnAside extends CardImpl<TurnAside> {
return new TurnAside(this);
}
private class CustomTargetSpell extends TargetObject<CustomTargetSpell> {
private class CustomTargetSpell extends TargetObject {
protected FilterSpell filter;

View file

@ -120,7 +120,7 @@ class GaeasBlessingEffect extends OneShotEffect {
}
}
class GaeasBlessingTarget extends TargetCard<GaeasBlessingTarget> {
class GaeasBlessingTarget extends TargetCard {
public GaeasBlessingTarget() {
super(0, 3, Zone.GRAVEYARD, new FilterCard());

View file

@ -72,7 +72,7 @@ public class Intervene extends CardImpl<Intervene> {
return new Intervene(this);
}
private class InterveneTargetSpell extends TargetObject<InterveneTargetSpell> {
private class InterveneTargetSpell extends TargetObject {
public InterveneTargetSpell() {

View file

@ -121,7 +121,7 @@ class SearingBlazeEffect extends OneShotEffect {
}
class SearingBlazeTarget extends TargetPermanent<SearingBlazeTarget> {
class SearingBlazeTarget extends TargetPermanent {
public SearingBlazeTarget() {
super(1, 1, new FilterCreaturePermanent(), false);

View file

@ -39,9 +39,8 @@ import mage.players.Player;
/**
*
* @author BetaSteward_at_googlemail.com
* @param <T>
*/
public abstract class TargetAmount<T extends TargetAmount<T>> extends TargetImpl<T> {
public abstract class TargetAmount extends TargetImpl {
boolean amountWasSet = false;
DynamicValue amount;
@ -65,6 +64,9 @@ public abstract class TargetAmount<T extends TargetAmount<T>> extends TargetImpl
this.amountWasSet = target.amountWasSet;
}
@Override
public abstract TargetAmount copy();
public int getAmountRemaining() {
return remainingAmount;
}
@ -127,8 +129,8 @@ public abstract class TargetAmount<T extends TargetAmount<T>> extends TargetImpl
}
@Override
public List<T> getTargetOptions(Ability source, Game game) {
List<T> options = new ArrayList<>();
public List<? extends TargetAmount> getTargetOptions(Ability source, Game game) {
List<TargetAmount> options = new ArrayList<>();
Set<UUID> possibleTargets = possibleTargets(source.getSourceId(), source.getControllerId(), game);
addTargets(this, possibleTargets, options, source, game);
@ -136,13 +138,13 @@ public abstract class TargetAmount<T extends TargetAmount<T>> extends TargetImpl
return options;
}
protected void addTargets(TargetAmount<T> target, Set<UUID> targets, List<T> options, Ability source, Game game) {
protected void addTargets(TargetAmount target, Set<UUID> targets, List<TargetAmount> options, Ability source, Game game) {
if (!amountWasSet) {
setAmount(source, game);
}
for (UUID targetId: targets) {
for (int n = 1; n <= target.remainingAmount; n++) {
T t = target.copy();
TargetAmount t = target.copy();
t.addTarget(targetId, n, source, game, true);
if (t.remainingAmount > 0) {
if (targets.size() > 1) {

View file

@ -42,9 +42,8 @@ import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
* @param <T>
*/
public class TargetCard<T extends TargetCard<T>> extends TargetObject<TargetCard<T>> {
public class TargetCard extends TargetObject {
protected FilterCard filter;

View file

@ -42,9 +42,8 @@ import java.util.*;
/**
*
* @author BetaSteward_at_googlemail.com
* @param <T>
*/
public abstract class TargetImpl<T extends TargetImpl<T>> implements Target {
public abstract class TargetImpl implements Target {
protected Map<UUID, Integer> targets = new LinkedHashMap<>();
protected Map<UUID, Integer> zoneChangeCounters = new HashMap<>();
@ -60,7 +59,7 @@ public abstract class TargetImpl<T extends TargetImpl<T>> implements Target {
protected boolean atRandom = false;
@Override
public abstract T copy();
public abstract TargetImpl copy();
public TargetImpl() {
this(false);
@ -70,7 +69,7 @@ public abstract class TargetImpl<T extends TargetImpl<T>> implements Target {
this.notTarget = notTarget;
}
public TargetImpl(final TargetImpl<T> target) {
public TargetImpl(final TargetImpl target) {
this.targetName = target.targetName;
this.zone = target.zone;
this.maxNumberOfTargets = target.maxNumberOfTargets;
@ -340,14 +339,14 @@ public abstract class TargetImpl<T extends TargetImpl<T>> implements Target {
}
@Override
public List<T> getTargetOptions(Ability source, Game game) {
List<T> options = new ArrayList<T>();
public List<? extends TargetImpl> getTargetOptions(Ability source, Game game) {
List<TargetImpl> options = new ArrayList<>();
Set<UUID> possibleTargets = possibleTargets(source.getSourceId(), source.getControllerId(), game);
possibleTargets.removeAll(getTargets());
Iterator<UUID> it = possibleTargets.iterator();
while (it.hasNext()) {
UUID targetId = it.next();
T target = this.copy();
TargetImpl target = this.copy();
target.clearChosen();
target.addTarget(targetId, source, game, true);
if (!target.isChosen()) {

View file

@ -38,9 +38,8 @@ import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
* @param <T>
*/
public abstract class TargetObject<T extends TargetObject<T>> extends TargetImpl<T> {
public abstract class TargetObject extends TargetImpl {
protected TargetObject() {}

View file

@ -42,9 +42,8 @@ import mage.game.permanent.Permanent;
/**
*
* @author BetaSteward_at_googlemail.com
* @param <T>
*/
public class TargetPermanent<T extends TargetPermanent<T>> extends TargetObject<TargetPermanent<T>> {
public class TargetPermanent extends TargetObject {
protected FilterPermanent filter;
@ -79,7 +78,7 @@ public class TargetPermanent<T extends TargetPermanent<T>> extends TargetObject<
this.notTarget = notTarget;
}
public TargetPermanent(final TargetPermanent<T> target) {
public TargetPermanent(final TargetPermanent target) {
super(target);
this.filter = target.filter.copy();
}

View file

@ -42,7 +42,7 @@ import java.util.UUID;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetPlayer<T extends TargetPlayer<T>> extends TargetImpl<TargetPlayer<T>> {
public class TargetPlayer extends TargetImpl {
protected FilterPlayer filter;

View file

@ -46,7 +46,7 @@ import java.util.UUID;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetSource extends TargetObject<TargetSource> {
public class TargetSource extends TargetObject {
protected FilterObject filter;

View file

@ -42,7 +42,7 @@ import mage.game.stack.StackObject;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetSpell extends TargetObject<TargetSpell> {
public class TargetSpell extends TargetObject {
protected FilterSpell filter;

View file

@ -42,7 +42,7 @@ import java.util.UUID;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetStackObject extends TargetObject<TargetStackObject> {
public class TargetStackObject extends TargetObject {
protected FilterStackObject filter;

View file

@ -47,7 +47,7 @@ import mage.target.TargetObject;
*/
public class TargetActivatedOrTriggeredAbility extends TargetObject<TargetActivatedOrTriggeredAbility> {
public class TargetActivatedOrTriggeredAbility extends TargetObject {
public TargetActivatedOrTriggeredAbility() {
this.minNumberOfTargets = 1;

View file

@ -33,9 +33,8 @@ import mage.target.TargetPermanent;
/**
* @author ayratn
* @param <T>
*/
public class TargetArtifactPermanent<T extends TargetArtifactPermanent<T>> extends TargetPermanent<TargetArtifactPermanent<T>> {
public class TargetArtifactPermanent extends TargetPermanent {
public TargetArtifactPermanent(boolean required) {
this();

View file

@ -35,7 +35,7 @@ import mage.target.TargetPermanent;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetAttackingCreature extends TargetPermanent<TargetAttackingCreature> {
public class TargetAttackingCreature extends TargetPermanent {
public TargetAttackingCreature() {
this(1, 1, new FilterAttackingCreature(), false);

View file

@ -35,7 +35,7 @@ import mage.target.TargetPermanent;
*
* @author nantuko
*/
public class TargetAttackingOrBlockingCreature extends TargetPermanent<TargetAttackingOrBlockingCreature> {
public class TargetAttackingOrBlockingCreature extends TargetPermanent {
public TargetAttackingOrBlockingCreature() {
this(1, 1, new FilterAttackingOrBlockingCreature(), false);

View file

@ -38,7 +38,7 @@ import mage.target.TargetCard;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetBasicLandCard extends TargetCard<TargetBasicLandCard> {
public class TargetBasicLandCard extends TargetCard {
public TargetBasicLandCard(Zone zone) {
super(zone);

View file

@ -43,7 +43,7 @@ import mage.target.TargetCard;
*/
public class TargetCardInASingleGraveyard extends TargetCard<TargetCardInASingleGraveyard> {
public class TargetCardInASingleGraveyard extends TargetCard {
public TargetCardInASingleGraveyard(int minNumTargets, int maxNumTargets, FilterCard filter) {
super(minNumTargets, maxNumTargets, Zone.GRAVEYARD, filter);

View file

@ -43,7 +43,7 @@ import mage.target.TargetCard;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetCardInExile extends TargetCard<TargetCardInExile> {
public class TargetCardInExile extends TargetCard {
private UUID zoneId;
private boolean allExileZones;

View file

@ -40,7 +40,7 @@ import mage.target.TargetCard;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetCardInGraveyard extends TargetCard<TargetCardInGraveyard> {
public class TargetCardInGraveyard extends TargetCard {
public TargetCardInGraveyard() {
this(1, 1, new FilterCard("card from a graveyard"));

View file

@ -40,7 +40,7 @@ import mage.target.TargetCard;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetCardInHand extends TargetCard<TargetCardInHand> {
public class TargetCardInHand extends TargetCard {
public TargetCardInHand() {
this(1, 1, new FilterCard());

View file

@ -47,7 +47,7 @@ import mage.target.TargetCard;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetCardInLibrary extends TargetCard<TargetCardInLibrary> {
public class TargetCardInLibrary extends TargetCard {
private int librarySearchLimit;

View file

@ -10,7 +10,7 @@ import mage.target.TargetCard;
import java.util.UUID;
public class TargetCardInOpponentsGraveyard extends TargetCard<TargetCardInOpponentsGraveyard> {
public class TargetCardInOpponentsGraveyard extends TargetCard {
protected boolean allFromOneOpponent;

View file

@ -40,7 +40,7 @@ import mage.target.TargetCard;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetCardInYourGraveyard extends TargetCard<TargetCardInYourGraveyard> {
public class TargetCardInYourGraveyard extends TargetCard {
public TargetCardInYourGraveyard() {
this(1, 1, new FilterCard("card from your graveyard"));

View file

@ -37,7 +37,7 @@ import mage.target.TargetPermanent;
* @author BetaSteward_at_googlemail.com
* @param <T>
*/
public class TargetControlledPermanent<T extends TargetControlledPermanent<T>> extends TargetPermanent<TargetControlledPermanent<T>> {
public class TargetControlledPermanent<T extends TargetControlledPermanent<T>> extends TargetPermanent {
public TargetControlledPermanent() {
this(1, 1, new FilterControlledPermanent(), false);

View file

@ -35,7 +35,7 @@ import mage.target.TargetPermanent;
*
* @author LevelX2
*/
public class TargetCreatureOrPlaneswalker<T extends TargetCreatureOrPlaneswalker<T>> extends TargetPermanent<TargetCreatureOrPlaneswalker<T>> {
public class TargetCreatureOrPlaneswalker<T extends TargetCreatureOrPlaneswalker<T>> extends TargetPermanent {
public TargetCreatureOrPlaneswalker() {
this(1, 1 ,new FilterCreatureOrPlaneswalkerPermanent(), false);

View file

@ -47,7 +47,7 @@ import java.util.UUID;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetCreatureOrPlayer extends TargetImpl<TargetCreatureOrPlayer> {
public class TargetCreatureOrPlayer extends TargetImpl {
protected FilterCreatureOrPlayer filter;

View file

@ -48,7 +48,7 @@ import mage.target.TargetAmount;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetCreatureOrPlayerAmount extends TargetAmount<TargetCreatureOrPlayerAmount> {
public class TargetCreatureOrPlayerAmount extends TargetAmount {
protected FilterCreatureOrPlayer filter;

View file

@ -35,7 +35,7 @@ import mage.target.TargetPermanent;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetCreaturePermanent extends TargetPermanent<TargetCreaturePermanent> {
public class TargetCreaturePermanent extends TargetPermanent {
public TargetCreaturePermanent() {
this(1, 1, new FilterCreaturePermanent(), false);

View file

@ -46,7 +46,7 @@ import mage.target.TargetAmount;
*
* @author North
*/
public class TargetCreaturePermanentAmount extends TargetAmount<TargetCreaturePermanentAmount> {
public class TargetCreaturePermanentAmount extends TargetAmount {
protected FilterCreaturePermanent filter;

View file

@ -47,7 +47,7 @@ import java.util.UUID;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetDefender extends TargetImpl<TargetDefender> {
public class TargetDefender extends TargetImpl {
protected FilterPlaneswalkerOrPlayer filter;
protected UUID attackerId;

View file

@ -42,7 +42,7 @@ import mage.filter.predicate.other.OwnerIdPredicate;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetDiscard extends TargetCard<TargetDiscard> {
public class TargetDiscard extends TargetCard {
private UUID playerId;

View file

@ -37,7 +37,7 @@ import mage.target.TargetPermanent;
*
* @param <T>
*/
public class TargetEnchantmentPermanent<T extends TargetEnchantmentPermanent<T>> extends TargetPermanent<TargetEnchantmentPermanent<T>> {
public class TargetEnchantmentPermanent<T extends TargetEnchantmentPermanent<T>> extends TargetPermanent {
public TargetEnchantmentPermanent(boolean required) {
this();

View file

@ -35,7 +35,7 @@ import mage.target.TargetPermanent;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetLandPermanent<T extends TargetLandPermanent<T>> extends TargetPermanent<TargetLandPermanent<T>> {
public class TargetLandPermanent<T extends TargetLandPermanent<T>> extends TargetPermanent {
public TargetLandPermanent() {
this(1, 1, new FilterLandPermanent(), false);

View file

@ -35,7 +35,7 @@ import mage.target.TargetPermanent;
*
* @author BetaSteward_at_googlemail.com
*/
public class TargetNonlandPermanent extends TargetPermanent<TargetNonlandPermanent> {
public class TargetNonlandPermanent extends TargetPermanent {
public TargetNonlandPermanent() {
this(1, 1, false);

View file

@ -40,7 +40,7 @@ import mage.target.TargetPlayer;
* @author BetaSteward_at_googlemail.com
* @author North
*/
public class TargetOpponent extends TargetPlayer<TargetOpponent> {
public class TargetOpponent extends TargetPlayer {
public TargetOpponent() {
this(false);

View file

@ -48,7 +48,7 @@ import java.util.UUID;
*
* @author nantuko
*/
public class TargetPermanentOrPlayer extends TargetImpl<TargetPermanentOrPlayer> {
public class TargetPermanentOrPlayer extends TargetImpl {
protected FilterPermanentOrPlayer filter;
protected FilterPermanent filterPermanent;

View file

@ -48,7 +48,7 @@ import mage.target.TargetImpl;
*
* @author LevelX
*/
public class TargetSpellOrPermanent extends TargetImpl<TargetSpellOrPermanent> {
public class TargetSpellOrPermanent extends TargetImpl {
protected FilterSpellOrPermanent filter;
protected FilterPermanent filterPermanent;