net.sf.magicproject.action.target
Class AbstractTarget

java.lang.Object
  extended by net.sf.magicproject.action.MAction
      extended by net.sf.magicproject.action.UserAction
          extended by net.sf.magicproject.action.Target
              extended by net.sf.magicproject.action.target.AbstractTarget
All Implemented Interfaces:
ChoosenAction, Replayable, RollBackAction, StandardAction
Direct Known Subclasses:
SingletonTarget

public abstract class AbstractTarget
extends Target
implements StandardAction, ChoosenAction

Add to the target list card(s) or player(s) following the specified mode and the specified type. If mode is 'choose' or 'opponentchoose', then a 'targeted' event is raised when the choice is made. In case of 'all', 'random', 'me' or any predicted target, no event is generated. The test, and the type are necessary only for the modes 'random', 'all', 'choose' and 'opponentchoose' to list the valids targets. The target list is used by the most actions.
For example, if the next action 'damage', all cards/player from the target list would be damaged. When a new ability is added to the stack, a new list is created and attached to it. Actions may modify, acceess it until the ability is completely resolved.

Since:
0.86
Author:
Fabrice Daugan

Method Summary
 boolean choose(ActionContextWrapper actionContext, ContextEventListener context, Ability ability)
          No generated event.
 void disactivate(ActionContextWrapper actionContext, ContextEventListener context, Ability ability)
          No generated event.
abstract  Targetable getAbstractTarget(ContextEventListener context, Ability ability)
          Return the targetable added by this action.
 boolean play(ContextEventListener context, Ability ability)
          Generate event associated to this action.
 boolean replay(ActionContextWrapper actionContext, ContextEventListener context, Ability ability)
          Generate event associated to this action.
 void simulate(ActionContextWrapper actionContext, ContextEventListener context, Ability ability)
          No generated event.
 java.lang.String toHtmlString(Ability ability, ContextEventListener context, ActionContextWrapper actionContext)
          Return the HTML code representing this action.
abstract  java.lang.String toString(Ability ability)
          String representation of this action.
 
Methods inherited from class net.sf.magicproject.action.Target
getIdAction, rollback
 
Methods inherited from class net.sf.magicproject.action.UserAction
getActionName, manaNeeded, toHtmlString, toHtmlString
 
Methods inherited from class net.sf.magicproject.action.MAction
equal, parseTest, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

disactivate

public final void disactivate(ActionContextWrapper actionContext,
                              ContextEventListener context,
                              Ability ability)
Description copied from interface: ChoosenAction
No generated event. Unset this action as current one.

Specified by:
disactivate in interface ChoosenAction
Parameters:
actionContext - the context containing data saved by this action during the 'choose" proceess.
context - is the context attached to this action.
ability - is the ability owning this test. The card component of this ability should correspond to the card owning this test too.

choose

public final boolean choose(ActionContextWrapper actionContext,
                            ContextEventListener context,
                            Ability ability)
Description copied from interface: ChoosenAction
No generated event. Let the active player playing this action.

Specified by:
choose in interface ChoosenAction
Parameters:
actionContext - the context containing data saved by this action during the 'choose" proceess.
context - is the context attached to this action.
ability - is the ability owning this test. The card component of this ability should correspond to the card owning this test too.
Returns:
true if the stack can be resolved just after this call.

simulate

public final void simulate(ActionContextWrapper actionContext,
                           ContextEventListener context,
                           Ability ability)
No generated event. Simulate an action.

Parameters:
actionContext - the context containing data saved by this action during the 'choose" proceess.
ability - is the ability owning this test. The card component of this ability should correspond to the card owning this test too.
context - is the context attached to this action.

replay

public final boolean replay(ActionContextWrapper actionContext,
                            ContextEventListener context,
                            Ability ability)
Description copied from class: Target
Generate event associated to this action. Only one or several events are generated and may be collected by event listeners. Then play this action

Specified by:
replay in interface ChoosenAction
Specified by:
replay in interface Replayable
Specified by:
replay in class Target
Parameters:
actionContext - the context containing data saved by this action during the 'choose" proceess.
context - is the context attached to this action.
ability - is the ability owning this test. The card component of this ability should correspond to the card owning this test too.
Returns:
true if the stack can be resolved just after this call.

toHtmlString

public final java.lang.String toHtmlString(Ability ability,
                                           ContextEventListener context,
                                           ActionContextWrapper actionContext)
Description copied from interface: ChoosenAction
Return the HTML code representing this action. If this action is named, it's name will be returned. If not, if existing, the picture associated to this action is returned. Otherwise, built-in action's text will be returned.

Specified by:
toHtmlString in interface ChoosenAction
Parameters:
ability - is the ability owning this test. The card component of this ability should correspond to the card owning this test too.
context - is the context attached to this action.
actionContext - the context of this action.
Returns:
the HTML code representing this action. If this action is named, it's name will be returned. If not, if existing, the picture associated to this action is returned. Otherwise, built-in action's text will be returned.

play

public final boolean play(ContextEventListener context,
                          Ability ability)
Description copied from interface: StandardAction
Generate event associated to this action. Only one or several events are generated and may be collected by event listeners. Then play this action

Specified by:
play in interface StandardAction
Specified by:
play in class Target
Parameters:
context - is the context attached to this action.
ability - is the ability owning this test. The card component of this ability should correspond to the card owning this test too.
Returns:
true if the stack can be resolved just after this call.

getAbstractTarget

public abstract Targetable getAbstractTarget(ContextEventListener context,
                                             Ability ability)
Return the targetable added by this action.

Parameters:
ability - is the ability owning this test. The card component of this ability should correspond to the card owning this test too.
context - is the context attached to this action.
Returns:
the targetable added by this action.

toString

public abstract java.lang.String toString(Ability ability)
Description copied from class: MAction
String representation of this action.

Specified by:
toString in class Target
Parameters:
ability - is the ability owning this test. The card component of this ability should correspond to the card owning this test too.
Returns:
action name.
See Also:
Object.toString()


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