net.sf.magicproject.event
Class CanICast

java.lang.Object
  extended by net.sf.magicproject.event.MEventListener
      extended by net.sf.magicproject.event.CanICast
All Implemented Interfaces:
RegisterableEvent

public class CanICast
extends MEventListener

Since:
0.54, 0.93 recheck the card position during ability matching to avoid playable spell from stack.
Author:
Fabrice Daugan

Field Summary
 
Fields inherited from class net.sf.magicproject.event.MEventListener
CAN_I_CAST_ABILITIES, card, REPLACEMENT_ABILITIES, test, TRIGGRED_ABILITIES
 
Constructor Summary
CanICast(java.io.InputStream inputFile, MCard card)
          Create an instance of CanICast by reading a file Offset's file must pointing on the first byte of this event
Structure of InputStream : Data[size] [super] idCard [Expression]
 
Method Summary
 MEventListener clone(MCard card)
          Return a copy of this with the specified owner
static void dispatchEvent(int idActivePlayer, java.util.List<Ability> res, java.util.List<Ability> advRes)
          Dispatch this event to all active event listener able to understand this event.
static void dispatchManaAbilityEvent(int idActivePlayer, java.util.List<Ability> res)
          Dispatch this event to all active event listener able to understand this event.
 Event getIdEvent()
          Return the idEvent of this event
 int getPlayableIdCard()
          Return set of playable idCard
 boolean isActivated()
          Indicates if this event corresponds to an activated ability
 boolean isMatching(Ability ability, int idActivePlayer)
          Tell if the current event matches with this event.
 boolean isMatchingManaAbility(Ability ability, int idActivePlayer)
          Tell if the current event matches with this event.
 boolean isTriggered()
          Indicates if this event corresponds to a triggered ability
 boolean isWellPlaced()
          Tell if the card is well placed for this event to be playable
 boolean isWellPlaced(int idZone)
          Tell if the card is well placed for this event to be playable
 void registerToManager(Ability ability)
          register this event to the event manager
 void removeFromManager(Ability ability)
          remove from the manager this event if doesn't match with the new context
 boolean updateManaAbilityTag(MAction... actionList)
          Iterate on given actions looking for a 'give mana' action.
 
Methods inherited from class net.sf.magicproject.event.MEventListener
appendOr, getIdPlace, reCheck, reCheck, reset, toHtmlString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CanICast

public CanICast(java.io.InputStream inputFile,
                MCard card)
         throws java.io.IOException
Create an instance of CanICast by reading a file Offset's file must pointing on the first byte of this event

Parameters:
inputFile - is the file containing this event
card - is the card owning this event
Throws:
java.io.IOException - if error occurred during the reading process from the specified input stream
Method Detail

clone

public MEventListener clone(MCard card)
Description copied from class: MEventListener
Return a copy of this with the specified owner

Specified by:
clone in class MEventListener
Parameters:
card - is the card of the ability of this event
Returns:
copy of this event

isActivated

public final boolean isActivated()
Description copied from class: MEventListener
Indicates if this event corresponds to an activated ability

Specified by:
isActivated in class MEventListener
Returns:
true if this event corresponds to an activated ability

isTriggered

public final boolean isTriggered()
Description copied from class: MEventListener
Indicates if this event corresponds to a triggered ability

Specified by:
isTriggered in class MEventListener
Returns:
true if this event corresponds to a triggered ability

registerToManager

public final void registerToManager(Ability ability)
Description copied from interface: RegisterableEvent
register this event to the event manager

Specified by:
registerToManager in interface RegisterableEvent
Specified by:
registerToManager in class MEventListener
Parameters:
ability - owning this event

removeFromManager

public final void removeFromManager(Ability ability)
Description copied from interface: RegisterableEvent
remove from the manager this event if doesn't match with the new context

Specified by:
removeFromManager in interface RegisterableEvent
Specified by:
removeFromManager in class MEventListener
Parameters:
ability - owning this event

isMatching

public boolean isMatching(Ability ability,
                          int idActivePlayer)
Tell if the current event matches with this event. If there is an additional code to check, it'would be checked if the main event matches with the main event

Parameters:
ability - is the ability owning this test. The card component of this ability should correspond to the card owning this test too.
idActivePlayer - id of active player
Returns:
true if the current event match with this event

isMatchingManaAbility

public boolean isMatchingManaAbility(Ability ability,
                                     int idActivePlayer)
Tell if the current event matches with this event. If there is an additional code to check, it'would be checked if the main event matches with the main event

Parameters:
ability - is the ability owning this test. The card component of this ability should correspond to the card owning this test too.
idActivePlayer - id of active player
Returns:
true if the current event match with this event

isWellPlaced

public boolean isWellPlaced()
Description copied from class: MEventListener
Tell if the card is well placed for this event to be playable

Overrides:
isWellPlaced in class MEventListener
Returns:
true if the card is well placed for this event to be playable

isWellPlaced

public boolean isWellPlaced(int idZone)
Description copied from class: MEventListener
Tell if the card is well placed for this event to be playable

Overrides:
isWellPlaced in class MEventListener
Parameters:
idZone - the supposed zone where card is.
Returns:
true if the card is well placed for this event to be playable

dispatchEvent

public static void dispatchEvent(int idActivePlayer,
                                 java.util.List<Ability> res,
                                 java.util.List<Ability> advRes)
Dispatch this event to all active event listener able to understand this event. The listening events able to understand this event are this and other multiple event listeners

Parameters:
idActivePlayer - id of active player
res - list in which playable abilities would be added
advRes - list in which advanced playable abilities would be added
See Also:
isMatching(Ability, int)

dispatchManaAbilityEvent

public static void dispatchManaAbilityEvent(int idActivePlayer,
                                            java.util.List<Ability> res)
Dispatch this event to all active event listener able to understand this event.

Parameters:
idActivePlayer - id of active player
res - list in which playable abilities would be added
See Also:
isMatching(Ability, int)

updateManaAbilityTag

public boolean updateManaAbilityTag(MAction... actionList)
Iterate on given actions looking for a 'give mana' action. If one or several are found, the playable idCard of this event will be replaced by IdTokens.MANA_ABILITY

Parameters:
actionList - list of actions
Returns:
true if at least one 'give mana' action has been found in the specified list.

getPlayableIdCard

public int getPlayableIdCard()
Return set of playable idCard

Returns:
set of playable idCard

getIdEvent

public final Event getIdEvent()
Description copied from class: MEventListener
Return the idEvent of this event

Specified by:
getIdEvent in class MEventListener
Returns:
the idEvent of this event


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