net.sf.magicproject.clickable.targetable.player
Class Player

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.player.Player
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener
Direct Known Subclasses:
Opponent, You

public abstract class Player
extends Targetable

Represents a player : name (avatar, preferences,...), mana and zones. Has also a register like cards to store data as life, poison, maximal number of cards in hand and number of cards to draw counter.
TODO support modifiers for player components, like cards.

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
 javax.swing.JSplitPane handSplitter
          The splitter of game/hand zones.
 int idPlayer
          id of the player
 javax.swing.JPanel mainPanel
          The panel containing the hand and the play
 ManaPool mana
          is the manas of this player
static int PLAYER_SIZE_HEIGHT
          Player view height
static int PLAYER_SIZE_WIDTH
          Player view width
 PlayerCard playerCard
          This card is used to represent this player as a card/
 ZoneManager zoneManager
          where all triggered abilities would go before to go to the stack
 
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
 
Method Summary
 void addTimestampReference()
          Increment the reference counter for the current timestamp of 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
 boolean declinePlay()
          Indicates if this player decline to play any ability with an empty stack.
 boolean declineResponseMe()
          Indicates if this player decline to response to the current effect.
 boolean declineResponseOpponent()
          Indicates if this player decline to response to the current effect owned by opponent.
 void decrementTimestampReference(int timestamp)
          Decrement the reference counter for the current timestamp of this card.
 void disHighLight()
          Remove any color of the border
 Deck getDeck()
          Return the current deck of player.
 int getId()
          Return the id of this component.
 Targetable getLastKnownTargetable(int timeStamp)
          Return this targetable as it was at the given timestamp.
abstract  java.lang.String getNickName()
          Return the player's name.
 Player getOpponent()
          Return the opponent player
 int getTimestamp()
          Return the timstamp value of this targetable.
 int getValue(int index)
          Return the value corresponding to the true register index.
static void init()
          Initialize the labels referencing to the registers of the MPlayer components.
 boolean isAbility()
          Is this targetable is an abilty or a spell
 boolean isCard()
          indicates if this target is a card
 boolean isCurrentPlayer()
          tell if this player is the current one
 boolean isSpell()
          Is this targetable is an abilty or a spell
abstract  boolean isYou()
          tell if this player is you
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void paint(java.awt.Graphics g)
           
 boolean processHiddenTriggered()
          Return true if there was one or several processed hidden triggered abilities
 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 reset(MPhase[] phases)
          Remove, and then fill the phases of this player
 void sendClickToOpponent()
          send to opponent the message indicating that we've clicked on this component
 void setActivePlayer()
          Set this player as active one
 void setDeck(Deck deck)
          Set the deck of this player.
 void setHandedPlayer()
          Set this player as handed one
 void setValue(int index, Operation operation, int rightValue)
          Set to the register of this card a value to a specified index.
 java.lang.String toString()
          return the player's name
static void unsetHandedPlayer()
          Remove to all players the possibility to do something
 void update(java.awt.Graphics g)
           
abstract  void updateReversed()
          Update the opponent side depending on the "enable reverse" options.
 boolean waitTriggeredBufferChoice(boolean resolveOnEmpty)
          Wait for the active player, then the non-active player to make choice of the order of triggered abilities to be put from the buffer to the stack
 
Methods inherited from class net.sf.magicproject.clickable.targetable.Targetable
actionPerformed, addModifier, addModifier, addPrivateNamedObject, clearDamages, clearPrivateNamedObject, getCreator, getOriginalTargetable, getPrivateNamedObject, getPrivateNamedObjects, getValueIndirection, isPlayer, removePrivateNamedObject, setCreator, targetize, targetize, tokenize
 
Methods inherited from class net.sf.magicproject.clickable.Clickable
disHighlight, highLight, mouseExited, 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, 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
 

Field Detail

PLAYER_SIZE_WIDTH

public static final int PLAYER_SIZE_WIDTH
Player view width

See Also:
Constant Field Values

PLAYER_SIZE_HEIGHT

public static final int PLAYER_SIZE_HEIGHT
Player view height

See Also:
Constant Field Values

zoneManager

public ZoneManager zoneManager
where all triggered abilities would go before to go to the stack


idPlayer

public int idPlayer
id of the player


mana

public ManaPool mana
is the manas of this player


playerCard

public PlayerCard playerCard
This card is used to represent this player as a card/


mainPanel

public javax.swing.JPanel mainPanel
The panel containing the hand and the play


handSplitter

public javax.swing.JSplitPane handSplitter
The splitter of game/hand zones.

Method Detail

updateReversed

public abstract void updateReversed()
Update the opponent side depending on the "enable reverse" options.


reset

public void reset(MPhase[] phases)
Remove, and then fill the phases of this player

Parameters:
phases - the phases to add.

isCard

public boolean isCard()
Description copied from class: Targetable
indicates if this target is a card

Specified by:
isCard in class Targetable
Returns:
true if this target is a card

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

isYou

public abstract boolean isYou()
tell if this player is you

Returns:
true if this player is you

isCurrentPlayer

public boolean isCurrentPlayer()
tell if this player is the current one

Returns:
true if this player is the current one

getOpponent

public Player getOpponent()
Return the opponent player

Returns:
the opponent player

disHighLight

public void disHighLight()
Description copied from class: Clickable
Remove any color of the border

Overrides:
disHighLight in class Clickable

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

update

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

init

public static void init()
Initialize the labels referencing to the registers of the MPlayer components.


toString

public java.lang.String toString()
return the player's name

Specified by:
toString in class Targetable
Returns:
the player's name

getNickName

public abstract java.lang.String getNickName()
Return the player's name.

Returns:
the player's name

declineResponseMe

public boolean declineResponseMe()
Indicates if this player decline to response to the current effect.

Returns:
true if this player decline to response to the current effect.
Since:
0.30, 0.31 an option "skip all even opponent's spell" is suported, 0.80 "medium decline" is suported
See Also:
MPhase.declineResponseMe()

declinePlay

public boolean declinePlay()
Indicates if this player decline to play any ability with an empty stack.

Returns:
if this player decline to play any ability with an empty stack.
Since:
0.30, 0.31 an option "skip all even opponent's spell" is suported, 0.80 "medium decline" is suported
See Also:
MPhase.breakpoint()

declineResponseOpponent

public boolean declineResponseOpponent()
Indicates if this player decline to response to the current effect owned by opponent.

Returns:
true if this player decline to response to the current effect owned by opponent.
Since:
0.30, 0.31 an option "skip all even opponent's spell" is suported, 0.80 "medium decline" is suported
See Also:
MPhase.declineResponseOpponent()

setActivePlayer

public void setActivePlayer()
Set this player as active one


setHandedPlayer

public void setHandedPlayer()
Set this player as handed one


unsetHandedPlayer

public static void unsetHandedPlayer()
Remove to all players the possibility to do something


waitTriggeredBufferChoice

public boolean waitTriggeredBufferChoice(boolean resolveOnEmpty)
Wait for the active player, then the non-active player to make choice of the order of triggered abilities to be put from the buffer to the stack

Parameters:
resolveOnEmpty - if true, the stack resolution would be broken if no triggered abilities have been played instead of playing the WaitActivatedChoice action.
Returns:
true if NO high priority triggered ability has been played from the TBZ. So the stack can be resolved.

processHiddenTriggered

public boolean processHiddenTriggered()
Return true if there was one or several processed hidden triggered abilities

Returns:
true if there was one or several processed hidden triggered abilities

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener
Overrides:
mouseClicked 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

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

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.

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.

mouseEntered

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

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.

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.

addTimestampReference

public void addTimestampReference()
Increment the reference counter for the current timestamp of this card.

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.

paint

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

getId

public int getId()
Description copied from class: Targetable
Return the id of this component. For instance, this id is only relevant for players.

Overrides:
getId in class Targetable
Returns:
the id of this component.

setDeck

public void setDeck(Deck deck)
Set the deck of this player.

Parameters:
deck - the deck of this player.

getDeck

public Deck getDeck()
Return the current deck of player.

Returns:
the current deck of player.


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