net.sf.magicproject.action
Class Repeat

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

public class Repeat
extends UserAction
implements StandardAction, InitAction

Repeat the next action n times. If the value is negative or zero, the next action would be skipped.

Since:
0.54
Author:
Fabrice Daugan

Method Summary
 Actiontype getIdAction()
          return the id of this action.
 int getPreemptionTimes(Ability ability, Targetable tested)
          Return nb times to repeat the next action exactly as it will be when the ability will be executed..Return -1 if value cannot be pre-empted.
 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 replayOnDemand(ActionContextWrapper actionContext, ContextEventListener context, Ability ability)
          Replay the next action the amount of context times.
 java.lang.String toHtmlString(Ability ability, ContextEventListener context)
          Return the HTML code representing this action.
 java.lang.String toString(Ability ability)
          return the string representation of this action
 
Methods inherited from class net.sf.magicproject.action.UserAction
getActionName, manaNeeded, 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()
return the id of this action. This action has been read from the mdb file.

Specified by:
getIdAction in class UserAction
Returns:
the id 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.

replayOnDemand

public void replayOnDemand(ActionContextWrapper actionContext,
                           ContextEventListener context,
                           Ability ability)
Replay the next action the amount of context times.

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.

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)
return the 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:
the string representation of this action
See Also:
Object.toString()

toHtmlString

public java.lang.String toHtmlString(Ability ability,
                                     ContextEventListener context)
Description copied from class: MAction
Return the HTML code representing this action. If no picture is associated to this action, only text will be returned.

Overrides:
toHtmlString 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.
context - is the context attached to this action.
Returns:
the HTML code representing this action. If no picture is associated to this action, only text will be returned.
See Also:
MAction.toString(Ability), MAction.toHtmlString(Ability, int, ContextEventListener)

getPreemptionTimes

public int getPreemptionTimes(Ability ability,
                              Targetable tested)
Return nb times to repeat the next action exactly as it will be when the ability will be executed..Return -1 if value cannot be pre-empted.

Parameters:
ability - is the ability owning this test. The card component of this ability should correspond to the card owning this test too.
tested - the tested card
Returns:
nb times to repeat the next action.Return -1 if value is not static.


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