net.sf.magicproject.clickable.targetable.card
Class TriggeredCard

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by net.sf.magicproject.clickable.Clickable
                  extended by net.sf.magicproject.clickable.targetable.Targetable
                      extended by net.sf.magicproject.clickable.targetable.card.AbstractCard
                          extended by net.sf.magicproject.clickable.targetable.card.TriggeredCard
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, MonitorListener, StackContext
Direct Known Subclasses:
TriggeredCardChoice

public class TriggeredCard
extends AbstractCard
implements java.awt.event.MouseListener, StackContext

Since:
0.54, 0.86 Ability source is saved.
Author:
Fabrice Daugan
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
 long abilityID
          Is the ability making this triggered ability to be created.
static int cardHeight
          Height of original card to display
static int cardWidth
          Width of original card to display
static java.awt.Color STACKABLE_COLOR
          The color used to color the stackable component
 Ability triggeredAbility
          Triggered ability
 
Fields inherited from class net.sf.magicproject.clickable.targetable.card.AbstractCard
controller, reversed, visibility
 
Fields inherited from class net.sf.magicproject.clickable.targetable.Targetable
cachedAbilities, controllerModifier, indirections, registerModifiers, registers
 
Fields inherited from class net.sf.magicproject.clickable.Clickable
highLightColor, isHighLighted
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TriggeredCard(Ability triggeredAbility, ContextEventListener context, long abilityID)
           
 
Method Summary
 void abortion(AbstractCard card, Ability source)
          Remove the specified card from the stack.
 void addTimestampReference()
          Add a reference to this targetable.
 void checkAllCardsOf(Test test, java.util.List<Targetable> list, Ability ability)
          Checks all cards corresponding to this constraints
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
 int countAllCardsOf(Test test, Ability ability, boolean canBePreempted)
          Checks all cards corresponding to the specified constraints
 void decrementTimestampReference(int timestamp)
          Decrement the reference counter for the current timestamp of this card.
 ContextEventListener getAbilityContext()
          Return the current context.
 Ability getAbortingAbility()
          Return the ability causing the abortion of this ability.
 ActionManager getActionManager()
          Return the action manager of this context.
 DelayedCard getDelayedCard()
          Return the delayed card attached to this ability.
 Targetable getLastKnownTargetable(int timeStamp)
          Return this targetable as it was at the given timestamp.
 Targetable getOriginalTargetable()
          Return the original targetable without looking for the timestamp number.
 MCard getSourceCard()
          Return the card source of the current capcity/spell in the stack
 TargetedList getTargetedList()
          Return the target option of the current spell. this target option is owned by the current spell.
 int getTimestamp()
          Return the timstamp value of this targetable.
 java.lang.String getTooltipString()
          Return HTML tooltip string of this card.
static TriggeredCard getTriggeredCard(java.io.InputStream input)
          Return the component from information read throw net.sf.magicproject.network
 int getValue(int index)
          Return the value corresponding to the true register index.
 void highlightStackable()
          The border will be highligthed to a color identifying it easily as a token component.
 java.awt.Image image()
          Return the card's picture
 boolean isAbility()
          Is this targetable is an abilty or a spell
 boolean isACopy()
          Indicates if the current card in the stack is a copy or not
 boolean isSpell()
          Is this targetable is an abilty or a spell
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
          is called when mouse is on this card, will disp a preview
 void moveCard(int newIdPlace, Player newController, boolean newIsTapped, int idPosition)
          Move this card to a new place tapped or not under the control of a player
 boolean newSpell()
          Play this card as a spell.
 void paint(java.awt.Graphics g)
           
 void removeModifier(RegisterIndirection indirection, int index)
          Remove a register-indirection modifier from this component.
 void removeModifier(RegisterModifier modifier, int index)
          Remove a register modifier from this component.
 void sendClickToOpponent()
          send to opponent the message indicating that we've clicked on this component
 java.lang.String toString()
          return the card's name
 
Methods inherited from class net.sf.magicproject.clickable.targetable.card.AbstractCard
getCardName, getController, getDatabase, getMUI, getPreviewImage, isCard, mouseExited, needReverse, notifyChange, reverse, reverseAsNeeded, scaledImage
 
Methods inherited from class net.sf.magicproject.clickable.targetable.Targetable
actionPerformed, addModifier, addModifier, addPrivateNamedObject, clearDamages, clearPrivateNamedObject, getCreator, getId, getPrivateNamedObject, getPrivateNamedObjects, getValueIndirection, isPlayer, removePrivateNamedObject, setCreator, targetize, targetize, tokenize
 
Methods inherited from class net.sf.magicproject.clickable.Clickable
disHighLight, disHighlight, highLight, mousePressed, mouseReleased
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.event.MouseListener
mouseExited, mousePressed, mouseReleased
 

Field Detail

triggeredAbility

public Ability triggeredAbility
Triggered ability


abilityID

public long abilityID
Is the ability making this triggered ability to be created.


cardHeight

public static int cardHeight
Height of original card to display


cardWidth

public static int cardWidth
Width of original card to display


STACKABLE_COLOR

public static final java.awt.Color STACKABLE_COLOR
The color used to color the stackable component

Constructor Detail

TriggeredCard

public TriggeredCard(Ability triggeredAbility,
                     ContextEventListener context,
                     long abilityID)
Parameters:
triggeredAbility - the triggered ability associated to this card
context - the context of the associated triggered ability
abilityID - is the ability's Id making this triggered ability to be created.
Method Detail

getTargetedList

public TargetedList getTargetedList()
Return the target option of the current spell. this target option is owned by the current spell. May be reseted, changed by the spell itself.

Specified by:
getTargetedList in interface StackContext
Returns:
the targeted list of this context.

getAbilityContext

public ContextEventListener getAbilityContext()
Return the current context. Null if current ability is not a triggered one.

Specified by:
getAbilityContext in interface StackContext
Returns:
the current context. Null if current ability is not a triggered one.

getActionManager

public ActionManager getActionManager()
Return the action manager of this context.

Specified by:
getActionManager in interface StackContext
Returns:
the action manager of this context.

getSourceCard

public MCard getSourceCard()
Return the card source of the current capcity/spell in the stack

Specified by:
getSourceCard in interface StackContext
Returns:
the card source of the current capcity/spell in the stack

newSpell

public boolean newSpell()
Play this card as a spell.

Returns:
true if this card has been completky played and if the stack can be resolved after this call.

isACopy

public boolean isACopy()
Description copied from class: AbstractCard
Indicates if the current card in the stack is a copy or not

Specified by:
isACopy in class AbstractCard
Returns:
true if the current card in the stack is a copy or not

countAllCardsOf

public int countAllCardsOf(Test test,
                           Ability ability,
                           boolean canBePreempted)
Description copied from class: AbstractCard
Checks all cards corresponding to the specified constraints

Specified by:
countAllCardsOf in class AbstractCard
Parameters:
test - applied to count valid cards
ability - is the ability owning this test. The card component of this ability should correspond to the card owning this test too.
canBePreempted - true if the valid targets can be derterminated before runtime.
Returns:
amount of card matching with the specified test

checkAllCardsOf

public void checkAllCardsOf(Test test,
                            java.util.List<Targetable> list,
                            Ability ability)
Description copied from class: AbstractCard
Checks all cards corresponding to this constraints

Specified by:
checkAllCardsOf in class AbstractCard
Parameters:
test - applied to count valid cards
list - the list containing the founded cards
ability - is the ability owning this test. The card component of this ability should correspond to the card owning this test too.

isAbility

public final boolean isAbility()
Description copied from class: Targetable
Is this targetable is an abilty or a spell

Specified by:
isAbility in class Targetable
Returns:
true id this targetable is an ability

isSpell

public final boolean isSpell()
Description copied from class: Targetable
Is this targetable is an abilty or a spell

Specified by:
isSpell in class Targetable
Returns:
true id this targetable is a spell

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class javax.swing.JComponent

image

public java.awt.Image image()
Description copied from class: AbstractCard
Return the card's picture

Overrides:
image in class AbstractCard
Returns:
the card's picture

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener
Overrides:
mouseClicked in class Clickable

sendClickToOpponent

public void sendClickToOpponent()
Description copied from class: Clickable
send to opponent the message indicating that we've clicked on this component

Specified by:
sendClickToOpponent in class Clickable

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

getTriggeredCard

public static TriggeredCard getTriggeredCard(java.io.InputStream input)
                                      throws java.io.IOException
Return the component from information read throw net.sf.magicproject.network

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

moveCard

public void moveCard(int newIdPlace,
                     Player newController,
                     boolean newIsTapped,
                     int idPosition)
Description copied from class: AbstractCard
Move this card to a new place tapped or not under the control of a player

Overrides:
moveCard in class AbstractCard
Parameters:
newIdPlace - the new place for this card
newController - new controler of this card. If null, the controler is the owner.
newIsTapped - dertermines if this card will come tapped or not
idPosition - from IdPositions

getTooltipString

public java.lang.String getTooltipString()
Description copied from class: AbstractCard
Return HTML tooltip string of this card.

Specified by:
getTooltipString in class AbstractCard
Returns:
HTML tooltip string of this card.

mouseEntered

public final void mouseEntered(java.awt.event.MouseEvent e)
Description copied from class: AbstractCard
is called when mouse is on this card, will disp a preview

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Overrides:
mouseEntered in class AbstractCard
Parameters:
e - is the mouse event

toString

public java.lang.String toString()
Description copied from class: AbstractCard
return the card's name

Overrides:
toString in class AbstractCard
Returns:
the card's name

getValue

public int getValue(int index)
Description copied from class: Targetable
Return the value corresponding to the true register index.

Specified by:
getValue in class Targetable
Parameters:
index - the register index
Returns:
the value corresponding to the true register index.

removeModifier

public void removeModifier(RegisterModifier modifier,
                           int index)
Description copied from class: Targetable
Remove a register modifier from this component.

Specified by:
removeModifier in class Targetable
Parameters:
modifier - the register modifier to remove.
index - index of register to remove.

removeModifier

public void removeModifier(RegisterIndirection indirection,
                           int index)
Description copied from class: Targetable
Remove a register-indirection modifier from this component.

Specified by:
removeModifier in class Targetable
Parameters:
indirection - the register-indirection modifier to remove.
index - index of register indirection to remove.

highlightStackable

public void highlightStackable()
The border will be highligthed to a color identifying it easily as a token component.

See Also:
STACKABLE_COLOR

getLastKnownTargetable

public Targetable getLastKnownTargetable(int timeStamp)
Description copied from class: Targetable
Return this targetable as it was at the given timestamp.

Specified by:
getLastKnownTargetable in class Targetable
Parameters:
timeStamp - the timestamp number.
Returns:
this targetable as it was at the given timestamp.

getOriginalTargetable

public Targetable getOriginalTargetable()
Description copied from class: Targetable
Return the original targetable without looking for the timestamp number.

Overrides:
getOriginalTargetable in class Targetable
Returns:
the original targetable without looking for the timestamp number.

addTimestampReference

public void addTimestampReference()
Description copied from class: Targetable
Add a reference to this targetable.

Specified by:
addTimestampReference in class Targetable

getTimestamp

public int getTimestamp()
Description copied from class: Targetable
Return the timstamp value of this targetable.

Specified by:
getTimestamp in class Targetable
Returns:
the timstamp value of this targetable.

decrementTimestampReference

public void decrementTimestampReference(int timestamp)
Description copied from class: Targetable
Decrement the reference counter for the current timestamp of this card.

Specified by:
decrementTimestampReference in class Targetable
Parameters:
timestamp - is the reference to decrement.

abortion

public void abortion(AbstractCard card,
                     Ability source)
Description copied from interface: StackContext
Remove the specified card from the stack. If it's a spell, it goes to the abortion place, otherwise it would be simply removed. After calling this method, caller should call the normal 'resolveStack' method.

Specified by:
abortion in interface StackContext
Parameters:
card - the card to make abort.
source - the ability source.

getAbortingAbility

public Ability getAbortingAbility()
Description copied from interface: StackContext
Return the ability causing the abortion of this ability.

Specified by:
getAbortingAbility in interface StackContext
Returns:
the ability causing the abortion of this ability.

getDelayedCard

public DelayedCard getDelayedCard()
Return the delayed card attached to this ability.

Returns:
the delayed card attached to this ability.


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