net.sf.magicproject.event.phase
Class EndOfPhase

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

public class EndOfPhase
extends TriggeredEvent

End of phase events. Raised just before to go to the next phase
If idPhase value is NO_CARE, this event would be acivated at each end of phase

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
EndOfPhase(java.io.InputStream inputFile, MCard card)
          Create an instance of MEventEndOfPhase by reading a file Offset's file must pointing on the first byte of this event
Structure of InputStream : Data[size] idZone [1] test [...]
EndOfPhase(int idZone, Test test, MCard card, Expression idPhase, PhaseFilter phaseFilter)
          Creates a new instance of MEventEndOfPhase specifying all attributes of this class.
 
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

EndOfPhase

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

EndOfPhase

public EndOfPhase(int idZone,
                  Test test,
                  MCard card,
                  Expression idPhase,
                  PhaseFilter phaseFilter)
Creates a new instance of MEventEndOfPhase specifying all attributes of this class. All parameters are copied, not cloned. So this new object shares the card and the specified codes

Parameters:
idZone - the place constraint to activate this event
test - the test of this event
card - is the card owning this card
idPhase - the looked for phase identifiant
phaseFilter - the filter.
Method Detail

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

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 found replacement ability is picked and played.

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

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.