net.sf.magicproject.clickable.ability
Class UserAbility

java.lang.Object
  extended by net.sf.magicproject.clickable.ability.Ability
      extended by net.sf.magicproject.clickable.ability.UserAbility
All Implemented Interfaces:
Unregisterable, ResolveStackHandler
Direct Known Subclasses:
ActivatedAbility, TriggeredAbility

public abstract class UserAbility
extends Ability

A non-abstract ability.

Author:
Fabrice Daugan

Field Summary
 
Fields inherited from class net.sf.magicproject.clickable.ability.Ability
optimizer, priority
 
Constructor Summary
UserAbility(java.io.InputStream inputFile, MCard card)
          Create an instance of UserAbility
Structure of InputStream : Data[size] event [Event] cost [Action[]] effect [Action[]]
 
Method Summary
 MAction[] actionList()
          Return list of actions to play to cast this ability
 boolean checkObjectActions()
          Checks too the other actions requiring a particular state, such as the presence of an object.
 boolean checkTargetActions()
          Verify in the 'cost' part there is no target action may cause abortion of this ability.
static void clickOn(java.io.InputStream input)
          This method is invoked when opponent has clicked on this object. this call should be done from the net.sf.magicproject.network listener
abstract  Ability clone(MCard container)
          return a copy of this ability
TODO remove param container since it is not used in this constructor As default, return null
 MAction[] effectList()
          Return list of actions effects of this ability
 MEventListener eventComing()
          Return matched to activate this ability matched to activate this ability.
 MCard getCard()
          Return card where is this ability.
 boolean isMatching()
          compare the current event to the event activating this ability.
 int[] manaNeeded(ContextEventListener context)
          return the amount of mana needed (constant part only) to play this ability
 void mouseClicked(int index)
          is called when you click on me
 boolean recheckTargets()
          Is this ability contains targeting action.
 java.lang.String toHtmlString(ContextEventListener context)
          Return the HTML code representing this ability.
 java.lang.String toString()
           
 boolean triggerIt(ContextEventListener context)
          called when this ability is going to be triggered This method would add this ability to the triggered zone, or perform another play action
 
Methods inherited from class net.sf.magicproject.clickable.ability.Ability
addLinkedAbility, equals, getAbilityTitle, getCardCopy, getController, getLog, getName, getPictureName, getTargetable, getTriggeredClone, getTriggeredCloneChoice, hashCode, hasHighPriority, isAutoResolve, isHidden, isPlayAsSpell, optimizeRegisterToManager, registerToManager, removeFromManager, resolveStack, setEvent
 
Methods inherited from class java.lang.Object
equals, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UserAbility

public UserAbility(java.io.InputStream inputFile,
                   MCard card)
            throws java.io.IOException
Create an instance of UserAbility

Parameters:
inputFile - file containing this ability
card - referenced card
Throws:
java.io.IOException - if error occurred during the reading process from the specified input stream
Since:
0.81 constraints on actions of this ability are supported
Method Detail

clone

public abstract Ability clone(MCard container)
Description copied from class: Ability
return a copy of this ability
TODO remove param container since it is not used in this constructor As default, return null

Overrides:
clone in class Ability
Parameters:
container - is not used here
Returns:
copy of this ability

getCard

public MCard getCard()
Description copied from class: Ability
Return card where is this ability. As default, it return null.

Specified by:
getCard in interface Unregisterable
Specified by:
getCard in class Ability
Returns:
true card where is this ability

checkTargetActions

public final boolean checkTargetActions()
Description copied from class: Ability
Verify in the 'cost' part there is no target action may cause abortion of this ability.

Overrides:
checkTargetActions in class Ability
Returns:
true if all actions in the 'cost' part can be played.

checkObjectActions

public final boolean checkObjectActions()
Description copied from class: Ability
Checks too the other actions requiring a particular state, such as the presence of an object.

Overrides:
checkObjectActions in class Ability
Returns:
true if the other actions requiring a particular state, such as the presence of an object are OK.

recheckTargets

public final boolean recheckTargets()
Description copied from class: Ability
Is this ability contains targeting action.

Overrides:
recheckTargets in class Ability
Returns:
true if this ability contains targeting action.

isMatching

public boolean isMatching()
Description copied from class: Ability
compare the current event to the event activating this ability. If matching, verify that there enougth mana in the player's mana pool

Specified by:
isMatching in class Ability
Returns:
true if this ability can be played responding the current event

manaNeeded

public int[] manaNeeded(ContextEventListener context)
Description copied from class: Ability
return the amount of mana needed (constant part only) to play this ability

Overrides:
manaNeeded in class Ability
Parameters:
context - the current context of this ability.
Returns:
array of mana needed to play this ability

toString

public final java.lang.String toString()
Overrides:
toString in class Ability

toHtmlString

public java.lang.String toHtmlString(ContextEventListener context)
Description copied from class: Ability
Return the HTML code representing this ability.

Overrides:
toHtmlString in class Ability
Parameters:
context - the context needed by event activated
Returns:
the HTML code representing this ability.

eventComing

public final MEventListener eventComing()
Description copied from class: Ability
Return matched to activate this ability matched to activate this ability. As default, return null.

Overrides:
eventComing in class Ability
Returns:
event matched to activate this ability

actionList

public final MAction[] actionList()
Description copied from class: Ability
Return list of actions to play to cast this ability

Specified by:
actionList in class Ability
Returns:
list of actions to play to cast this ability

effectList

public final MAction[] effectList()
Description copied from class: Ability
Return list of actions effects of this ability

Specified by:
effectList in class Ability
Returns:
list of actions effects of this ability

triggerIt

public boolean triggerIt(ContextEventListener context)
Description copied from class: Ability
called when this ability is going to be triggered This method would add this ability to the triggered zone, or perform another play action

Overrides:
triggerIt in class Ability
Parameters:
context - the context needed by event activated
Returns:
true if this ability has been added to the triggered buffer zone, return false otherwise

mouseClicked

public final void mouseClicked(int index)
is called when you click on me

Parameters:
index - is the index of this ability within the choice list of playable abilities of the card owning this ability.

clickOn

public static void clickOn(java.io.InputStream input)
                    throws java.io.IOException
This method is invoked when opponent has clicked on this object. this call should be done from the net.sf.magicproject.network listener

Parameters:
input - input stream of our net.sf.magicproject.network connection
Throws:
java.io.IOException - if error occurred when reading the message


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