net.sf.magicproject.stack
Class ActionManager

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

public class ActionManager
extends java.lang.Object

The most important class of this application, and also the hardest to understand. This manager scheduls the actions handlers and the ability stack process.

Since:
0.86
Author:
Fabrice Daugan

Field Summary
 boolean advancedEffectMode
          Is the advanced mode is used there for effects part.
 boolean advancedMode
          Is the advanced mode is used there for cost part.
 Ability currentAbility
          the current ability in the stack
 MAction currentAction
          the active action managing the next player action
 int currentIdAction
          The index of current action
static int HANDLER_AD_REPLAY
          The final handler : replay.
static int HANDLER_INITIALIZATION
          The first handler : initialization.
 int hop
          like M68k processor bra instruction, indicates the jump to do to go to the next action.
 int idHandler
          Values are :
HANDLER_INITIALIZATION
HANDLER_AD_SERIALIZATION
HANDLER_AD_PREPARE_REPLAY
HANDLER_AD_REPLAY
HANDLER_PLAY_INIT
HANDLER_MIDDLE
HANDLER_EFFECTS
 int loopingIndex
          This tag indicate the index of current action using a 'for' or 'while' instruction, generating several events.
 int[] requiredMana
          Additional required mana.
 boolean waitingOnMiddle
          Are we waiting for triggered/activated choice
 
Method Summary
 MAction[] actionList()
          Action/Effect list.
 boolean clickOn(Ability ability)
          Called to specify the player choice for the current action
 boolean clickOn(JChoosenAction action)
          Called to specify the player choice for the current action.
 boolean clickOn(Mana mana)
          Called to specify the player choice for the current action
 boolean clickOn(MCard card)
          Called to specify the player choice for the current action
 boolean clickOn(Player player)
          Called to specify the player choice for the current action
 boolean clickOn(TriggeredCard triggeredCard)
          Called to specify the player choice for the current action
 void completeChoosenAction(boolean unitaryCompleted)
          Complete the current action.
 ContextEventListener getAbilityContext()
          Return the current ability's context.
 ActionContextWrapper getActionContext()
          Returns the context associated to the current action id.
 ActionContextWrapper getActionContext(int contextId)
          Returns the context associated to the specified action id.
 ActionContextWrapper getActionContextNull()
          Returns the context associated to the specified action id.
 ActionContextWrapper[] getAllActionContexts()
          Returns the whole action contexts of current step : cost OR effect.
 ActionContextWrapper[] getTotalActionContexts()
          Returns the whole action contexts : cost AND effect.
 void manualSkip()
          Send the message "manualSkip" to the active action of play.
 void reactivate()
          Reactivate the current action
 void setHop(int hop)
          Set the jump to do for the next action.
 void setRepeat(int nbNextAction)
          Will repeat the next action nbNextAction times
 void succeedClickOn(Ability ability)
          This function should be called by the 'clickOn' caller in case of the specified ability has been handled during the checking validity of this click in the clickOn(Ability) function.
 void succeedClickOn(JChoosenAction action)
          This function should be called by the 'clickOn' caller in case of the specified player has been handled during the checking validity of this click in the clickOn(JChoosenAction) function.
 void succeedClickOn(Mana mana)
          This function should be called by the 'clickOn' caller in case of the specified mana has been handled during the checking validity of this click in the clickOn(MMana) function.
 void succeedClickOn(MCard card)
          This function should be called by the 'clickOn' caller in case of the specified card has been handled during the checking validity of this click in the clickOn(Card) function.
 void succeedClickOn(Player player)
          This function should be called by the 'clickOn' caller in case of the specified player has been handled during the checking validity of this click in the clickOn(Player) function.
 void succeedClickOn(TriggeredCard card)
          This function should be called by the 'clickOn' caller in case of the specified triggered card has been handled during the checking validity of this click in the clickOn(MTriggeredCard) function.
 void updateRequiredMana(int[] requiredMana)
          Update the given required mana with the global required mana.
 void updateRequiredMana(Operation op, int reg, int value)
          Update the required mana of current ability.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hop

public int hop
like M68k processor bra instruction, indicates the jump to do to go to the next action. This jump is equal to 1 for normal ability, but for hop=3, the 2 actions following the current one will be skipped. Hop=0 means infinite loop.

Since:
0.52

currentAbility

public Ability currentAbility
the current ability in the stack


currentAction

public MAction currentAction
the active action managing the next player action


loopingIndex

public int loopingIndex
This tag indicate the index of current action using a 'for' or 'while' instruction, generating several events. While this tag is greater than 0, instead of resolving stacks, the current action still called as if the setRepeat() method was called.


currentIdAction

public int currentIdAction
The index of current action


waitingOnMiddle

public boolean waitingOnMiddle
Are we waiting for triggered/activated choice


idHandler

public int idHandler
Values are :
HANDLER_INITIALIZATION
HANDLER_AD_SERIALIZATION
HANDLER_AD_PREPARE_REPLAY
HANDLER_AD_REPLAY
HANDLER_PLAY_INIT
HANDLER_MIDDLE
HANDLER_EFFECTS


HANDLER_INITIALIZATION

public static final int HANDLER_INITIALIZATION
The first handler : initialization.

See Also:
Constant Field Values

HANDLER_AD_REPLAY

public static final int HANDLER_AD_REPLAY
The final handler : replay.

See Also:
Constant Field Values

advancedMode

public boolean advancedMode
Is the advanced mode is used there for cost part.


advancedEffectMode

public boolean advancedEffectMode
Is the advanced mode is used there for effects part.


requiredMana

public final int[] requiredMana
Additional required mana. May contain some negative amount.

Method Detail

actionList

public MAction[] actionList()
Action/Effect list.

Returns:
Action/Effect list.

getAbilityContext

public ContextEventListener getAbilityContext()
Return the current ability's context.

Returns:
the current ability's context.

manualSkip

public void manualSkip()
Send the message "manualSkip" to the active action of play. If the "skip/cancel" event is accepted by this action, we resolve the stack.


setRepeat

public void setRepeat(int nbNextAction)
Will repeat the next action nbNextAction times

Parameters:
nbNextAction - is the times that the next action will be repeated

getActionContextNull

public ActionContextWrapper getActionContextNull()
Returns the context associated to the specified action id.

Returns:
the context associated to the specified action id.

getActionContext

public ActionContextWrapper getActionContext(int contextId)
Returns the context associated to the specified action id.

Parameters:
contextId - the requestion acion id.
Returns:
the context associated to the specified action id.

getActionContext

public ActionContextWrapper getActionContext()
Returns the context associated to the current action id.

Returns:
the context associated to the current action id.

getAllActionContexts

public ActionContextWrapper[] getAllActionContexts()
Returns the whole action contexts of current step : cost OR effect.

Returns:
the whole action contexts of current step : cost OR effect.
See Also:
getAllActionContexts()

getTotalActionContexts

public ActionContextWrapper[] getTotalActionContexts()
Returns the whole action contexts : cost AND effect.

Returns:
the whole action contexts : cost AND effect.
See Also:
getAllActionContexts()

setHop

public void setHop(int hop)
Set the jump to do for the next action. If the specified "hop" is 0, the next action would be the current one.

Parameters:
hop - the jump to do for the next action.

clickOn

public boolean clickOn(MCard card)
Called to specify the player choice for the current action

Parameters:
card - the clicked card by the active player for the current action
Returns:
true if this click has been managed. Return false if this click has been ignored

clickOn

public boolean clickOn(Player player)
Called to specify the player choice for the current action

Parameters:
player - the clicked player by the active player for the current action
Returns:
true if this click has been managed. Return false if this click has been ignored

clickOn

public boolean clickOn(TriggeredCard triggeredCard)
Called to specify the player choice for the current action

Parameters:
triggeredCard - the clicked triggered card by the active player for the current action
Returns:
true if this click has been managed. Return false if this click has been ignored

clickOn

public boolean clickOn(Ability ability)
Called to specify the player choice for the current action

Parameters:
ability - the clicked ability by the active player for the current action
Returns:
true if this click has been managed. Return false if this click has been ignored

clickOn

public boolean clickOn(Mana mana)
Called to specify the player choice for the current action

Parameters:
mana - the clicked mana by the active player for the current action
Returns:
true if this click has been managed. Return false if this click has been ignored

clickOn

public boolean clickOn(JChoosenAction action)
Called to specify the player choice for the current action.

Parameters:
action - the clicked action by the active player for the current action
Returns:
true if this click has been managed. Return false if this click has been ignored

succeedClickOn

public void succeedClickOn(MCard card)
This function should be called by the 'clickOn' caller in case of the specified card has been handled during the checking validity of this click in the clickOn(Card) function.

Parameters:
card - the card that was clicked and successfuly handled by the clickOn(Card) function.
See Also:
clickOn(MCard)

succeedClickOn

public void succeedClickOn(Ability ability)
This function should be called by the 'clickOn' caller in case of the specified ability has been handled during the checking validity of this click in the clickOn(Ability) function.

Parameters:
ability - the ability that was clicked and successfuly handled by the clickOn(Ability) function.
See Also:
clickOn(Ability)

succeedClickOn

public void succeedClickOn(TriggeredCard card)
This function should be called by the 'clickOn' caller in case of the specified triggered card has been handled during the checking validity of this click in the clickOn(MTriggeredCard) function.

Parameters:
card - the triggered card that was clicked and successfuly handled by the clickOn(MTriggeredCard) function.
See Also:
clickOn(TriggeredCard)

succeedClickOn

public void succeedClickOn(Mana mana)
This function should be called by the 'clickOn' caller in case of the specified mana has been handled during the checking validity of this click in the clickOn(MMana) function.

Parameters:
mana - the mana that was clicked and successfuly handled by the clickOn(MMana) function.
See Also:
clickOn(Mana)

succeedClickOn

public void succeedClickOn(Player player)
This function should be called by the 'clickOn' caller in case of the specified player has been handled during the checking validity of this click in the clickOn(Player) function.

Parameters:
player - the player that was clicked and successfuly handled by the clickOn(Player) function.
See Also:
clickOn(Player)

succeedClickOn

public void succeedClickOn(JChoosenAction action)
This function should be called by the 'clickOn' caller in case of the specified player has been handled during the checking validity of this click in the clickOn(JChoosenAction) function.

Parameters:
action - the action that was clicked and successfuly handled by the clickOn(JChoosenAction) function.
See Also:
clickOn(JChoosenAction)

completeChoosenAction

public void completeChoosenAction(boolean unitaryCompleted)
Complete the current action.

Parameters:
unitaryCompleted - is this action is completed as many times as required?

reactivate

public void reactivate()
Reactivate the current action


updateRequiredMana

public void updateRequiredMana(Operation op,
                               int reg,
                               int value)
Update the required mana of current ability.

Parameters:
op - the operation to apply to the required mana.
reg - the register index to update
value - the value to update.

updateRequiredMana

public void updateRequiredMana(int[] requiredMana)
Update the given required mana with the global required mana.

Parameters:
requiredMana - the required mana to update.


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