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

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.MCard
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseWheelListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, MonitorListener, Tappable
Direct Known Subclasses:
CardCopy, LastKnownCard, PlayerCard, SystemCard

public class MCard
extends AbstractCard
implements Tappable, java.awt.event.MouseWheelListener

This class corresponds to the graphical element of a specified card, and correponds to an actor. When loading a new card, first we take care that a card with same name has not been already loaded in order to save memory, so all cards having the same name share the same Image object.

Since:
0.52 "enableReverse" option, 0.70 support modifiers, 0.71 art and rule author, 0.72 support static effects, removed art-author, 0.85 property pictures are displayed, 0.90 database + card model, 0.91 keywords added, externalized to CardModel, explicit attachment object, and is movable.
Author:
Fabrice Daugan , Stefano "Kismet" Lenzi
See Also:
IdCardColors, 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
 AbilityModifier abilityModifier
          The ability modifiers on this object.
 int cachedIdCard
          The modified idcard.
 int cachedIdColor
          The modified color.
 java.util.Set<java.lang.Integer> cachedProperties
          List of properties of this card.
 int[] cachedRegisters
          The modified registers.
 ColorModifier colorModifier
          The colors modifiers on this object.
 IdCardModifier idCardModifier
          The idcard modifiers on this object.
 Player originalController
          The original player.
 PlayableZoneModifier playableZoneModifier
          The playable zone modifiers on this object.
 PropertyModifier propertyModifier
          The properties modifiers on this object.
 boolean tapped
          Indicates if this card should be tapped or not.
 
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
MCard(MCard cardRef, DatabaseCard database)
          Create a new instance of Card exactly like cardRef instance.
MCard(java.lang.String cardName, java.io.InputStream inputFile, Player controller, Player owner, java.util.Map<java.lang.String,java.lang.String> constraints)
          Create a new instance of Card reading from a file.
MCard(java.lang.String pictureName, MCard cardRef)
          Create a new instance of tokenized Card.
 
Method Summary
 void addModifier(AbilityModifier modifier)
          Add a modifier to this object
 void addModifier(ColorModifier modifier)
          Add a modifier to this object
 void addModifier(ControllerModifier modifier)
          Add a modifier to this object
 void addModifier(IdCardModifier modifier)
          Add a modifier to this object
 void addModifier(PlayableZoneModifier modifier)
          Add a modifier to this object
 void addModifier(PropertyModifier modifier)
          Add a modifier to this object
 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
 void clearDamages()
          remove all damages on this card
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.
 boolean equals(java.lang.Object obj)
           
 java.util.Collection<MCard> getAttachedCards()
          Return the attached cards.
 int[] getBytes()
          Return the int array representing this card.
static MCard getCard(java.io.InputStream input)
          Return the component from information read throw net.sf.magicproject.network
 CardModel getCardModel()
          Returns the cardModel reference of this card.
 MZone getContainer()
          Return the container of this card.
 Ability getDummyAbility()
          Return a default ability associated to this card.
 int getIdCard()
          returns all IdCards of this card
 int getIdColor()
          returns all IdColors of this card
 int getIdZone()
          Return the zone identifant of this card.
static int getIdZone(int idZone, boolean tapped)
          Return a zone code representing the zone and the state of this card.
static int getIdZone(int idZone, ContextEventListener context)
          Return the place where is this card.
 Targetable getLastKnownTargetable(int timeStamp)
          Return this targetable as it was at the given timestamp.
 ModifierModel getModifierModels()
           
 int getNbObjects(java.lang.String objectName, Test objectTest)
          Return occurences number of the given object with the given name attached to this card.
 DatabaseCard getOriginalDatabase()
          Return the original database as imprinted.
 Player getOwner()
          Return card's owner.
 java.util.Set<java.lang.Integer> getProperties()
          Return all properties of this card
 int getTimestamp()
          Return the timstamp value of this targetable.
 java.lang.String getTooltipString()
          Return HTML tooltip string of this card.
 int getValue(int index)
          Return the value corresponding to the true register index.
 int getValueIndirection(int index)
          Return the value corresponding to the true register index.
 boolean hasDirtyDataBase()
          Return true if this card has a database configuration different from the original one.
 int hashCode()
           
 boolean hasIdCard(int idCard)
          Indicates if the specified sort of card idCard contains the card's sort.
static boolean hasIdCard(int idCardBIG, int idCardMatched)
          Indicates if idCardBIG contains completely idCardMatched.
 boolean hasIdColor(int idColor)
          Indicates if the specified color idColor contains the card's colors.
static boolean hasIdColor(int idColorBIG, int idColorMatched)
          Indicates if the specified color idColorBIG contains the other specified color idColorMatched.
 boolean hasIdType(int idType)
          indicates if this card has this idType
 boolean hasPropertyNotFromCreator(int idType, MCard creator)
          indicates if this card has this idType.
 void highLight(boolean... highlightedZones)
          The border will be highligthed to yellow
static boolean intersectionIdCard(int idCardBIG, int idCardMatched)
          Indicates if idCardBIG contains partially idCardMatched.
 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 isAttached()
          Indicated if this card is attached or not.
 boolean isSameIdZone(int idZone)
          Compare a zone with the current card'szone
static boolean isSameIdZone(int idZone, int other)
           
 boolean isSamePosition(int position)
          Indicates wether this card suits to the specified position code.
 boolean isSameState(int zoneConstaint)
           Indicates if this card match with the specified place and constraint.
 boolean isSpell()
          Is this targetable is an abilty or a spell
static boolean isTapped(int idZone)
          Indicates wether the card with the specified zone identifiant is tapped or not.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
           
 void moveCard(int destinationZone, Player newController, boolean newIsTapped, int idPosition)
          Move this card to a new place tapped or not under the control of a player
 boolean needReverse()
          Is this card need to be reversed to suit to the player view.
 boolean playableZone(int supposedZone, int idZone)
          Indicates this card can be played from a specified zone.
 void refreshAbilities()
          Refresh the granted abilities of this card.
 void refreshController()
          Refresh the controller of this card, and raise an event if the value has been changed.
 void refreshIdCard()
          Refresh the idcard of this card, and raise an event if the value has been changed.
 void refreshIdColor()
          Refresh the colors of this card, and raise an event if the value has been changed.
 void refreshProperties(int property)
          Refresh the properties of this card, and raise an event if the value has been changed.
 void refreshRegisters(int index)
          Refresh the registers of this card, and raise an event if the value has been changed.
 void registerAbilities(int zone)
          Register abilities of this card, supposing card is in the specified zone.
 void registerReplacementAbilities(int zone)
          Register abilities of this card, supposing card is in the specified zone.
 void removeModifier(AbilityModifier modifier)
          Remove the specified ability-modifier
 void removeModifier(ColorModifier modifier)
          Remove the specified color-modifier.
 void removeModifier(ControllerModifier modifier)
          Remove the specified controller-modifier
 void removeModifier(IdCardModifier modifier)
          Remove the specified idcard-modifier
 void removeModifier(PlayableZoneModifier modifier)
          Remove the specified playable zone-modifier
 void removeModifier(PropertyModifier modifier)
          Remove the specified property-modifier
 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 returnCard(Visibility visibility)
          Show/hide the back face of the card.
 void reverse(boolean reversed)
          Reverse this card if the specified parameter is true
 void sendClickToOpponent()
          send to opponent the message indicating that we've clicked on this component
 void setDataBase(DatabaseCard database)
          Update the card model.
 void setIdZone(int idZone)
          Set a new zone for this card.
 void setOwner(Player owner)
          Set the new owner of this card.
 void setValue(int index, Operation operation, int rightValue)
          Set to the register of this card a value to a specified index.
 void tap(boolean tapped)
          Tap/untap this component
 void targetize(boolean... highlightedZones)
          The border will be highligthed to a color identifying it easily as a targetable component.
 void unregisterAbilities()
          Unregister useless abilities from the eventManager.
 void updateAbilities()
          [un]Register ActivatedAbilities depending on the current zone of this card
 
Methods inherited from class net.sf.magicproject.clickable.targetable.card.AbstractCard
getCardName, getController, getDatabase, getMUI, getPreviewImage, image, isCard, mouseEntered, mouseExited, notifyChange, reverseAsNeeded, scaledImage, toString
 
Methods inherited from class net.sf.magicproject.clickable.targetable.Targetable
actionPerformed, addModifier, addModifier, addPrivateNamedObject, clearPrivateNamedObject, getCreator, getId, getOriginalTargetable, getPrivateNamedObject, getPrivateNamedObjects, isPlayer, removePrivateNamedObject, setCreator, targetize, tokenize
 
Methods inherited from class net.sf.magicproject.clickable.Clickable
disHighLight, disHighlight, 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, paint, 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
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

cachedIdCard

public int cachedIdCard
The modified idcard.


cachedIdColor

public int cachedIdColor
The modified color.


cachedRegisters

public int[] cachedRegisters
The modified registers.


originalController

public final Player originalController
The original player.


tapped

public boolean tapped
Indicates if this card should be tapped or not.


colorModifier

public ColorModifier colorModifier
The colors modifiers on this object.


idCardModifier

public IdCardModifier idCardModifier
The idcard modifiers on this object.


abilityModifier

public AbilityModifier abilityModifier
The ability modifiers on this object.


propertyModifier

public PropertyModifier propertyModifier
The properties modifiers on this object.


playableZoneModifier

public PlayableZoneModifier playableZoneModifier
The playable zone modifiers on this object.


cachedProperties

public java.util.Set<java.lang.Integer> cachedProperties
List of properties of this card.

Constructor Detail

MCard

public MCard(java.lang.String cardName,
             java.io.InputStream inputFile,
             Player controller,
             Player owner,
             java.util.Map<java.lang.String,java.lang.String> constraints)
Create a new instance of Card reading from a file.

Parameters:
cardName - the card name
inputFile - is the file readed, containing information
controller - is the controller of this card
owner - is the owner of this card
constraints - the constraints of the card for database management

MCard

public MCard(MCard cardRef,
             DatabaseCard database)
Create a new instance of Card exactly like cardRef instance. Is called only from clone method.

Parameters:
cardRef - is the model for this new instance
database - the database of this new card.

MCard

public MCard(java.lang.String pictureName,
             MCard cardRef)
Create a new instance of tokenized Card. This constructor should be called only to obtain the a copy of the specified card sharing registers and abilities. Also, any modification done on registers or ability of one of these cards will be visible on the other. The zone information of cards is not shared, and the new card will have it's zone initialized with stack identifier instead of side. The picture used for this card will be the specified one if it is not null. Otherwise the cardRef picture will be used.

Parameters:
pictureName - is the picture name used to represent the copy. May be null.
cardRef - is the model for this instance
See Also:
IdZones.STACK
Method Detail

isAbility

public 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 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

isSamePosition

public boolean isSamePosition(int position)
Indicates wether this card suits to the specified position code.

Parameters:
position - the matching position code
Returns:
true if this card suits to the specified position code.
See Also:
IdPositions.ON_THE_BOTTOM, IdPositions.ON_THE_TOP

getContainer

public MZone getContainer()
Return the container of this card.

Returns:
the container of this card.

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

hasIdCard

public boolean hasIdCard(int idCard)
Indicates if the specified sort of card idCard contains the card's sort.

Parameters:
idCard - are the sorts we match.
Returns:
true if the specified sort idCard contains the card's sort.
See Also:
hasIdCard(int,int)

hasIdCard

public static boolean hasIdCard(int idCardBIG,
                                int idCardMatched)
Indicates if idCardBIG contains completely idCardMatched.

Parameters:
idCardBIG - are the set of types.
idCardMatched - are the type we match.
Returns:
true if idCardBIG contains completely idCardMatched.

intersectionIdCard

public static boolean intersectionIdCard(int idCardBIG,
                                         int idCardMatched)
Indicates if idCardBIG contains partially idCardMatched.

Parameters:
idCardBIG - are the set of types.
idCardMatched - are the type we match.
Returns:
true if idCardBIG contains partially idCardMatched.

hasIdColor

public boolean hasIdColor(int idColor)
Indicates if the specified color idColor contains the card's colors.

Parameters:
idColor - are the colors we match.
Returns:
true if the specified color idColor contains the card's colors.
See Also:
hasIdColor(int,int)

hasIdColor

public static boolean hasIdColor(int idColorBIG,
                                 int idColorMatched)
Indicates if the specified color idColorBIG contains the other specified color idColorMatched.

Parameters:
idColorBIG - are the colors that idColorMatched must have
idColorMatched - are the colors we match.
Returns:
true if the specified color idColorBIG contains the other specified color idColorMatched.

isSameState

public boolean isSameState(int zoneConstaint)
The zones are compared, then the constraint tapped/untapped is checked.
If zoneConstaint is ID__ANYWHERE, return true.
If zoneConstaint is same as current zone of this card and the constraint is validated, return true

Parameters:
zoneConstaint - the zone id and optional tapped information.
Returns:
true if zoneConstaint is ID__ANYWHERE or zoneConstaint is same as current place of this card and the constraint is verified.
See Also:
IdZones.PLAY_TAPPED, IdZones.PLAY_UNTAPPED, IdZones

isSameIdZone

public boolean isSameIdZone(int idZone)
Compare a zone with the current card'szone

Parameters:
idZone - the other zone
Returns:
true the specified zone, and the current card's zone are the same.

isSameIdZone

public static boolean isSameIdZone(int idZone,
                                   int other)
Parameters:
idZone - the other zone
other - another zone
Returns:
true the specified zones are the same.

getIdZone

public int getIdZone()
Return the zone identifant of this card.

Returns:
the zone identifant of this card. IdZones#PLAY, IdZones#HAND,...
See Also:
IdZones, IdZones

getIdZone

public static int getIdZone(int idZone,
                            ContextEventListener context)
Return the place where is this card.

Parameters:
idZone - the zone identifiantt This identifiant may contain staus information like "tapped", "untapped"
context - The optional context attached to the request.
Returns:
the place identifiant corresponding to the specified zone, and with any status information
See Also:
IdZones

getIdZone

public static int getIdZone(int idZone,
                            boolean tapped)
Return a zone code representing the zone and the state of this card.

Parameters:
idZone - the zone identifiantt without status information like "tapped", "untapped"
tapped - indicate the state of this car.
Returns:
the place identifiant corresponding to the specified zone, and with any status information
See Also:
IdZones

getIdColor

public int getIdColor()
returns all IdColors of this card

Returns:
all IdColors of this card
See Also:
IdCardColors

getIdCard

public int getIdCard()
returns all IdCards of this card

Returns:
all IdCards of this card

hasIdType

public boolean hasIdType(int idType)
indicates if this card has this idType

Parameters:
idType - is the type required
Returns:
true if this card has the required type

hasPropertyNotFromCreator

public boolean hasPropertyNotFromCreator(int idType,
                                         MCard creator)
indicates if this card has this idType.

Parameters:
idType - is the type required
creator - the card that has created the modifier to ignore.
Returns:
true if this card has the required type

needReverse

public boolean needReverse()
Description copied from class: AbstractCard
Is this card need to be reversed to suit to the player view.

Overrides:
needReverse in class AbstractCard
Returns:
true if this card need to be reversed to suit to the player view.

moveCard

public void moveCard(int destinationZone,
                     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:
destinationZone - 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

isTapped

public static boolean isTapped(int idZone)
Indicates wether the card with the specified zone identifiant is tapped or not.

Parameters:
idZone - the zone id + tapped position information.
Returns:
true if the card with the specified zone identifiant is tapped or not.

registerAbilities

public void registerAbilities(int zone)
Register abilities of this card, supposing card is in the specified zone.

Parameters:
zone - The supposed zone this card will go to

getDummyAbility

public Ability getDummyAbility()
Return a default ability associated to this card. There is no garantee this method returns always the samae ability.

Returns:
a default ability associated to this card.

registerReplacementAbilities

public void registerReplacementAbilities(int zone)
Register abilities of this card, supposing card is in the specified zone.

Parameters:
zone - The supposed zone this card will go to

unregisterAbilities

public void unregisterAbilities()
Unregister useless abilities from the eventManager.


tap

public void tap(boolean tapped)
Description copied from interface: Tappable
Tap/untap this component

Specified by:
tap in interface Tappable
Parameters:
tapped - if true the component will be tapped

reverse

public void reverse(boolean reversed)
Description copied from class: AbstractCard
Reverse this card if the specified parameter is true

Overrides:
reverse in class AbstractCard
Parameters:
reversed - if true the card will be tured as if your controled controls it

returnCard

public void returnCard(Visibility visibility)
Show/hide the back face of the card. You have to call the repaint() method to update the graphics if necessary.

Parameters:
visibility - the visibility of this card

highLight

public void highLight(boolean... highlightedZones)
Description copied from class: Clickable
The border will be highligthed to yellow

Overrides:
highLight in class Clickable
Parameters:
highlightedZones - the set of highlighted zone.

targetize

public void targetize(boolean... highlightedZones)
Description copied from class: Targetable
The border will be highligthed to a color identifying it easily as a targetable component.

Overrides:
targetize in class Targetable
Parameters:
highlightedZones - the set of highlighted zone.

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener

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

getBytes

public final int[] getBytes()
Return the int array representing this card. This array can be send throw network.

Returns:
bytes representing this card.

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

getCard

public static MCard getCard(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 card read from the specified input stream
Throws:
java.io.IOException - if error occurred when reading the message

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.

getValueIndirection

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

Overrides:
getValueIndirection in class Targetable
Parameters:
index - the register index
Returns:
the value corresponding to the true register index.

addModifier

public void addModifier(ColorModifier modifier)
Add a modifier to this object

Parameters:
modifier - the color-modifier to add to this object

addModifier

public void addModifier(IdCardModifier modifier)
Add a modifier to this object

Parameters:
modifier - the idcard-modifier to add to this object

addModifier

public void addModifier(AbilityModifier modifier)
Add a modifier to this object

Parameters:
modifier - the ability-modifier to add to this object

addModifier

public void addModifier(PropertyModifier modifier)
Add a modifier to this object

Parameters:
modifier - the property-modifier to add to this object

addModifier

public void addModifier(ControllerModifier modifier)
Add a modifier to this object

Parameters:
modifier - the controller-modifier to add to this object

addModifier

public void addModifier(PlayableZoneModifier modifier)
Add a modifier to this object

Parameters:
modifier - the playable zone-modifier to add to this object

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.

removeModifier

public void removeModifier(IdCardModifier modifier)
Remove the specified idcard-modifier

Parameters:
modifier - the idcard-modifier to be removed from this object

removeModifier

public void removeModifier(AbilityModifier modifier)
Remove the specified ability-modifier

Parameters:
modifier - the ability-modifier to be removed from this object

removeModifier

public void removeModifier(ControllerModifier modifier)
Remove the specified controller-modifier

Parameters:
modifier - the controller-modifier to be removed from this object

removeModifier

public void removeModifier(PropertyModifier modifier)
Remove the specified property-modifier

Parameters:
modifier - the property-modifier to be removed from this object

removeModifier

public void removeModifier(PlayableZoneModifier modifier)
Remove the specified playable zone-modifier

Parameters:
modifier - the playable zone-modifier to be removed from this object

removeModifier

public void removeModifier(ColorModifier modifier)
Remove the specified color-modifier.

Parameters:
modifier - the color-modifier to be removed from this object

isAttached

public boolean isAttached()
Indicated if this card is attached or not.

Returns:
true value if this card is attached.

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.

refreshIdCard

public void refreshIdCard()
Refresh the idcard of this card, and raise an event if the value has been changed.


refreshAbilities

public void refreshAbilities()
Refresh the granted abilities of this card. No event raised.


refreshIdColor

public void refreshIdColor()
Refresh the colors of this card, and raise an event if the value has been changed.


refreshProperties

public void refreshProperties(int property)
Refresh the properties of this card, and raise an event if the value has been changed. NOTE : there is no cache for properties.

Parameters:
property - the property to refresh.

refreshRegisters

public void refreshRegisters(int index)
Refresh the registers of this card, and raise an event if the value has been changed.

Parameters:
index - is the register index to refresh

refreshController

public void refreshController()
Refresh the controller of this card, and raise an event if the value has been changed.


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.

playableZone

public boolean playableZone(int supposedZone,
                            int idZone)
Indicates this card can be played from a specified zone.

Parameters:
supposedZone - the zone where the this card would be played from.
idZone - the zone where this card can be played from.
Returns:
true if this card is playable from the supposed zone

updateAbilities

public void updateAbilities()
[un]Register ActivatedAbilities depending on the current zone of this card


setValue

public void setValue(int index,
                     Operation operation,
                     int rightValue)
Set to the register of this card a value to a specified index. The given operation is uesed to apply operation on old and the given value. To set the given value as the new one, use the "set" operation.

Parameters:
index - is the index of register to modify
operation - the operation to use
rightValue - is the value to use as right operande for the operation

setIdZone

public void setIdZone(int idZone)
Set a new zone for this card.

Parameters:
idZone - the new zone.

addTimestampReference

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

Specified by:
addTimestampReference in class 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.

getProperties

public java.util.Set<java.lang.Integer> getProperties()
Return all properties of this card

Returns:
all properties of this card

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.

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.

getNbObjects

public int getNbObjects(java.lang.String objectName,
                        Test objectTest)
Return occurences number of the given object with the given name attached to this card.

Parameters:
objectName - the object's name to find within the register modfiers chain.
objectTest - The test applied on specific modifier to be removed.
Returns:
occurences number of the given object with the given name attached to this card.

clearDamages

public void clearDamages()
Description copied from class: Targetable
remove all damages on this card

Overrides:
clearDamages in class Targetable

getModifierModels

public ModifierModel getModifierModels()
Returns:
the shared modifier models.
Since:
0.91
See Also:
CardModel.getModifierModels()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getCardModel

public CardModel getCardModel()
Returns the cardModel reference of this card.

Returns:
the cardModel reference of this card.

setOwner

public void setOwner(Player owner)
Set the new owner of this card.

Parameters:
owner - the new owner.

getOwner

public Player getOwner()
Return card's owner.

Returns:
card's owner.

setDataBase

public void setDataBase(DatabaseCard database)
Update the card model. Also, post some refresh request on some attributes of this card.

Parameters:
database - the new database of this card.

hasDirtyDataBase

public boolean hasDirtyDataBase()
Return true if this card has a database configuration different from the original one.

Returns:
true if this card has a database configuration different from the original one.

getOriginalDatabase

public DatabaseCard getOriginalDatabase()
Return the original database as imprinted.

Returns:
the original database.

getAttachedCards

public java.util.Collection<MCard> getAttachedCards()
Return the attached cards.

Returns:
the attached cards.


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