net.sf.magicproject.stack
Class TargetedList

java.lang.Object
  extended by net.sf.magicproject.stack.TargetedList

public class TargetedList
extends java.lang.Object

MTargetedList.java Created on 8 oct. 2003 represents list of targets : player(s) and/or card(s).

Since:
0.2, 0.53 manage the abortion when resoving a spell
Author:
Fabrice Daugan
See Also:
Card, Player

Field Summary
 java.util.List<Targetable> list
          represents all targeted card(s) and/or player(s)
 Ability source
          Source of this target spell/ability
 
Constructor Summary
TargetedList(Ability source)
          Creates a new instance of MTargetedList
 
Method Summary
 void addTarget(int eventOption, Targetable targeted, Test test, boolean raiseEvent)
          Add a player/card to the targeted list
If the current target options indicates that an event has to be generated when a target is choosen, the event Targeted is dispatched.
 void clear()
          Indicates that we're no longer looking for the targets
 TargetedList cloneList()
          Return a clone of this list.
 Targetable get(int index)
          Return the target placed at index
 Targetable getFirst()
          Return the first target
 Targetable getLast()
          Return the last target
 boolean isEmpty()
          Indicates if there are targets
 int recheckList(Ability ability)
          Recheck the whole list of targets added with raised event.
 void remove(int index)
          Return a target from the list
 void remove(Targetable target)
          Return the specified target from the list
 void removeLast()
          Remove the last target
 void removeQueue()
          Remove all component but the first.
 void removeTail()
          Remove all component but the last.
 void removeTargeted(Targetable target)
          Return the specified target from the list
 int size()
          Retourne la taille de la liste
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

list

public java.util.List<Targetable> list
represents all targeted card(s) and/or player(s)


source

public Ability source
Source of this target spell/ability

Constructor Detail

TargetedList

public TargetedList(Ability source)
Creates a new instance of MTargetedList

Parameters:
source - the source of this list of targets
Method Detail

addTarget

public void addTarget(int eventOption,
                      Targetable targeted,
                      Test test,
                      boolean raiseEvent)
Add a player/card to the targeted list
If the current target options indicates that an event has to be generated when a target is choosen, the event Targeted is dispatched.

Parameters:
eventOption - is the event mode : Force, default, none. Depending this value, the added target will be rechecked before resolution process
targeted - the player to add to the list
test - is the used filter. All objects making false this test are removed from the specified list and from the constraint really targeted list.
raiseEvent - if false, is any case, no event can be triggered.

get

public Targetable get(int index)
Return the target placed at index

Parameters:
index - the target register to extract from the list
Returns:
the target placed at index

getLast

public Targetable getLast()
Return the last target

Returns:
the last target

getFirst

public Targetable getFirst()
Return the first target

Returns:
the first target

removeLast

public void removeLast()
Remove the last target


remove

public void remove(int index)
Return a target from the list

Parameters:
index - the index of the element to be removed.

remove

public void remove(Targetable target)
Return the specified target from the list

Parameters:
target - the target to be removed.

removeTargeted

public void removeTargeted(Targetable target)
Return the specified target from the list

Parameters:
target - the target to be removed.

removeQueue

public void removeQueue()
Remove all component but the first.


removeTail

public void removeTail()
Remove all component but the last.


isEmpty

public boolean isEmpty()
Indicates if there are targets

Returns:
true if there are targets

size

public int size()
Retourne la taille de la liste

Returns:
number of targets

clear

public void clear()
Indicates that we're no longer looking for the targets


recheckList

public int recheckList(Ability ability)
Recheck the whole list of targets added with raised event.

Parameters:
ability - is the ability owning this request. The card component of this ability should correspond to the card owning this request too.
Returns:
the amount of remaining object making true the specified test.

cloneList

public TargetedList cloneList()
Return a clone of this list.

Returns:
a clone of this list.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2003-2007 Magic-Project. All Rights Reserved.