net.sf.magicproject.event.phase
Class BeforePhase

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

public class BeforePhase
extends TriggeredEvent

Since:
0.54
Author:
Fabrice Daugan

Field Summary
static Event EVENT
          The event type.
 
Fields inherited from class net.sf.magicproject.event.TriggeredEvent
replacement
 
Fields inherited from class net.sf.magicproject.event.MEventListener
CAN_I_CAST_ABILITIES, card, REPLACEMENT_ABILITIES, test, TRIGGRED_ABILITIES
 
Constructor Summary
BeforePhase(java.io.InputStream inputFile, MCard card)
          Create an instance of MEventBeforePhase by reading a file Offset's file must pointing on the first byte of this event
Structure of InputStream : Data[size] idZone [1] test [...]
 
Method Summary
 MEventListener appendOr(MEventListener other)
          Create and returns an union of this event and the specified one.
 MEventListener clone(MCard card)
          Return a copy of this with the specified owner
static void dispatchEvent()
          Dispatch this event to all active event listeners able to understand this event.
 Event getIdEvent()
          Return the idEvent of this event
 java.lang.String toHtmlString(Ability ability, ContextEventListener context)
          Return the HTML code representing this ability.
static boolean tryAction(int currentIdPhase)
          Dispatch this event to replacement abilites only.
 
Methods inherited from class net.sf.magicproject.event.TriggeredEvent
isActivated, isTriggered, registerToManager, removeFromManager
 
Methods inherited from class net.sf.magicproject.event.MEventListener
getIdPlace, isWellPlaced, isWellPlaced, reCheck, reCheck, reset
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EVENT

public static final Event EVENT
The event type.

Constructor Detail

BeforePhase

public BeforePhase(java.io.InputStream inputFile,
                   MCard card)
            throws java.io.IOException
Create an instance of MEventBeforePhase 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

dispatchEvent

public static void dispatchEvent()
Dispatch this event to all active event listeners able to understand this event. The listening events able to understand this event are this and other multiple event listeners. For each event listeners having responded they have been activated, the corresponding ability is added to the triggered buffer zone of player owning this ability.


tryAction

public static boolean tryAction(int currentIdPhase)
Dispatch this event to replacement abilites only. If one or several abilities have been activated this way, this function will return false. The return value must be checked. In case of false value, the caller should not call any stack resolution since activated abilities are being played. Unusually, when several replacement abilities are found for this event, ONLY the first replacement ability found is picked and played.

Parameters:
currentIdPhase - the current phase type identifiant (not index)
Returns:
true if the event has not been replaced.

clone

public MEventListener clone(MCard card)
Return a copy of this with the specified owner

Parameters:
card - is the card of the ability of this event
Returns:
copy of this event

getIdEvent

public final Event getIdEvent()
Return the idEvent of this event

Returns:
the idEvent of this event

toHtmlString

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

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

appendOr

public MEventListener appendOr(MEventListener other)
Description copied from class: MEventListener
Create and returns an union of this event and the specified one. Both event must have the same type. Test(s) and events attributes may be groupped depending instance of this event. If no possible append is possible null is returned.

Overrides:
appendOr in class MEventListener
Parameters:
other - the event to append with 'or' operator.
Returns:
a new event reprensenting 'this' or 'other'


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