net.sf.magicproject.action
Class Hop

java.lang.Object
  extended by net.sf.magicproject.action.MAction
      extended by net.sf.magicproject.action.UserAction
          extended by net.sf.magicproject.action.Hop
All Implemented Interfaces:
InitAction, Replayable, RollBackAction, StandardAction

public class Hop
extends UserAction
implements StandardAction, InitAction, RollBackAction

Change the normal jump(1) in the current actions chain, to another one . This jump can be positive or negative. Zero mean infinite loop.

Since:
0.60, 0.72 support counter ability
Author:
Fabrice Daugan

Method Summary
 Actiontype getIdAction()
          Return the index of this action.
 boolean init(ActionContextWrapper actionContext, ContextEventListener context, Ability ability)
          No generated event.
 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 rollback(ActionContextWrapper actionContext, ContextEventListener context, Ability ability)
          No generated event.
 java.lang.String toString(Ability ability)
          String representation of this action.
 
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

getIdAction

public final Actiontype getIdAction()
Description copied from class: MAction
Return the index of this action. As default, this is a zero id

Specified by:
getIdAction in class UserAction
Returns:
the index of this action.
See Also:
Actiontype

init

public boolean init(ActionContextWrapper actionContext,
                    ContextEventListener context,
                    Ability ability)
Description copied from interface: InitAction
No generated event. Let the active player playing this action.
Generally, this method is used to initialize the context of this action such as required mana, or fixing some values.
Be aware this method can be called several times if there it is in a loop (hop usage), so manage this case to prevent a reset of context each time this method is called during the initialization phase.

Specified by:
init in interface InitAction
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.

replay

public boolean replay(ActionContextWrapper actionContext,
                      ContextEventListener context,
                      Ability ability)
Description copied from interface: InitAction
Generate event associated to this action. One or several events are generated and may be collected by event listeners. Then play this action.
In this method, you should use the context you have stored in the initialization phase with the init method.
This method is only called once, so all stuffs (action and event) must be done in one shot.

Specified by:
replay in interface InitAction
Specified by:
replay in interface Replayable
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.

rollback

public void rollback(ActionContextWrapper actionContext,
                     ContextEventListener context,
                     Ability ability)
Description copied from interface: RollBackAction
No generated event. Rollback an action.

Specified by:
rollback in interface RollBackAction
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.

play

public 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
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.

toString

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

Specified by:
toString in class UserAction
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.