net.sf.magicproject.action
Class ModifyTargetableRegister

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

public class ModifyTargetableRegister
extends ModifyRegister
implements ChoosenAction, InitAction, RollBackAction

This action is used to modifiy a register of a player or a card.
This action can use the target list when is played : the address (idToken=register name + register index) must be IdTokens#TARGET. So the target list must set before this action would be played.

Since:
0.71, 0.85 useless operation are ignored and not genrated.
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.
 boolean equal(MAction constraintAction)
          Return true if this action matches with the given action.
 Actiontype getIdAction()
          Return the index of this action.
 boolean init(ActionContextWrapper actionContext, ContextEventListener context, Ability ability)
          No generated event.
static boolean modifyRegister(MCard source, Targetable targetable, int index, int value, Operation op)
          Generate event associated to this action.
 Test parseTest(Test test)
          Return the given test where values depending on values of this action have been replaced.
 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 toHtmlString(Ability ability, ContextEventListener context, ActionContextWrapper actionContext)
          Return the HTML code representing this action.
 java.lang.String toString(Ability ability)
          String representation of this action.
 
Methods inherited from class net.sf.magicproject.action.ModifyRegister
countAllCardsOf, toHtmlString
 
Methods inherited from class net.sf.magicproject.action.UserAction
getActionName, manaNeeded, toHtmlString
 
Methods inherited from class net.sf.magicproject.action.MAction
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 ModifyRegister
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.

choose

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

disactivate

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

replay

public boolean replay(ActionContextWrapper actionContext,
                      ContextEventListener context,
                      Ability ability)
Description copied from interface: ChoosenAction
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 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.

toHtmlString

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

modifyRegister

public static boolean modifyRegister(MCard source,
                                     Targetable targetable,
                                     int index,
                                     int value,
                                     Operation op)
Generate event associated to this action. Only one or several events are generated and may be collected by event listeners. Then play this action

Parameters:
source - the source, and the concerned card to this modification
targetable - the component to modify
index - the register's index
value - right value of operation
op - identifiant of the operation applied to the specified card
Returns:
true

parseTest

public Test parseTest(Test test)
Description copied from class: MAction
Return the given test where values depending on values of this action have been replaced.

Overrides:
parseTest in class MAction
Parameters:
test - the test containing eventually some values depending on parameters of this action.
Returns:
a parsed test.

equal

public boolean equal(MAction constraintAction)
Description copied from class: MAction
Return true if this action matches with the given action.

Overrides:
equal in class MAction
Parameters:
constraintAction - the constraint action.
Returns:
true if this action matches with the given action.

toString

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

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