net.sf.magicproject.stack
Class TargetHelper

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

public final class TargetHelper
extends java.lang.Object

Since:
0.90
Author:
Fabrice Daugan

Field Summary
static java.lang.String STR_CONTEXT1
          Code to represent the context of a spell.
static java.lang.String STR_CONTEXT2
          Code to represent the context2 of a spell.
static java.lang.String STR_SOURCE
          Code to represent the source of target action.
 
Method Summary
 void addTargetedBy(StackContext stackContext)
          Add a target Id displayed on each targeted components.
 boolean checkTarget(Ability ability, MCard source, Test test, int type, int choiceMode, ContextEventListener context, int restrictionZone, int hopCounter, boolean canBePreempted)
          Return true when there is the required amount of valid targets.
static TargetHelper getInstance()
          Return the unique instance of this class.
 java.lang.String getMyId(Targetable targetable)
          Return the target id of given component.
 java.lang.String getTargetPictureAsUrl()
          Return Url picture used to draw a targeted component when it is added to the current target list.
 java.awt.Image getTargetPictureSml()
          Return picture used to draw a targeted component when it is added to the current target list.
 void removeTargetedBy()
          Remove any target Id displayed on targeted components.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STR_SOURCE

public static final java.lang.String STR_SOURCE
Code to represent the source of target action.

See Also:
Constant Field Values

STR_CONTEXT1

public static final java.lang.String STR_CONTEXT1
Code to represent the context of a spell.

See Also:
Constant Field Values

STR_CONTEXT2

public static final java.lang.String STR_CONTEXT2
Code to represent the context2 of a spell.

See Also:
Constant Field Values
Method Detail

getInstance

public static TargetHelper getInstance()
Return the unique instance of this class.

Returns:
the unique instance of this class.

checkTarget

public boolean checkTarget(Ability ability,
                           MCard source,
                           Test test,
                           int type,
                           int choiceMode,
                           ContextEventListener context,
                           int restrictionZone,
                           int hopCounter,
                           boolean canBePreempted)
Return true when there is the required amount of valid targets.

Parameters:
ability - is the ability owning this test. The card component of this ability should correspond to the card owning this test too.
source - the card source of the target. Often is the card owning the current ability.
test - the constraint applied on the target. This test must be true to make valid a target.
type - the target type (player, card, both)
choiceMode - the choice mode like random, all, choosen by playerX,...
context - the associated context of current ability.
restrictionZone - the restriction zone. If is -1 the scan would be processed on all zones.
hopCounter - the minimum amount of target looked for. For optimisation purpose.
canBePreempted - true if the valid targets can be derterminated before runtime.
Returns:
true when there is the required amount of valid targets.

addTargetedBy

public void addTargetedBy(StackContext stackContext)
Add a target Id displayed on each targeted components.

Parameters:
stackContext - the stack context of source.

removeTargetedBy

public void removeTargetedBy()
Remove any target Id displayed on targeted components.


getTargetPictureSml

public java.awt.Image getTargetPictureSml()
Return picture used to draw a targeted component when it is added to the current target list. The returned picture is a 12 x 12 one.

Returns:
Picture used to draw a targeted component when it is added to the current target list.

getTargetPictureAsUrl

public java.lang.String getTargetPictureAsUrl()
Return Url picture used to draw a targeted component when it is added to the current target list. The returned picture is a 12 x 12 one.

Returns:
Url picture used to draw a targeted component when it is added to the current target list.

getMyId

public java.lang.String getMyId(Targetable targetable)
Return the target id of given component.

Parameters:
targetable - the component requesting it's target id.
Returns:
the target id (base 1) of given component. Return 'S' value if is the source. Return a null value if is neither the source, neither a target.


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