public class Card
extends java.lang.Object
implements java.lang.Comparable
Modifier and Type | Field and Description |
---|---|
static boolean |
noVerso
If true; all cards are always shown with the face up (for debugging purposes).
|
Constructor and Description |
---|
Card(Deck deck,
int cardNb)
Creates a card instance from given deck using the give card number
Keep in mind that the current card actor is undefined (null) until the
card is displayed in the gamegrid using the hand's draw() method
or attributeActor() is called.
|
Card(Deck deck,
T suit,
R rank)
Same as Create(deck, suit, rank, isVerso) with isVerso = false.
|
Card(Deck deck,
T suit,
R rank,
boolean isVerso)
Creates a card instance from given deck using the given suit and rank.
|
Modifier and Type | Method and Description |
---|---|
CardActor |
associateActor(double scaleFactor,
double rotationAngle)
Calculates the current card actor with given scale factor and rotation angle
from the seed actor taken from the card's deck.
|
Card |
clone()
Deep copy of a card with same attributes, including the card actor,
but is handless (getHand() returns null).
|
Card |
cloneAndAdd()
Same as cloneAndAdd(double rotationAngle) with rotationAngle of
current card.
|
Card |
cloneAndAdd(double rotationAngle)
Deep copy of a card with same attributes, including the card actor,
but is handless (getHand() returns null).
|
int |
compareTo(java.lang.Object other)
Implementation of comparable interface.
|
boolean |
equals(java.lang.Object obj)
Checks if the given card has the same suit and rank as the current card
(overrides Object.equals()).
|
CardActor |
getCardActor()
Returns the card actor reference of the card.
|
int |
getCardNumber()
Returns the card number of the current card.
|
Deck |
getDeck()
Returns the deck reference attributed to this card.
|
java.awt.Dimension |
getDimension()
Returns the current card dimension (scaling accounted).
|
Hand |
getHand()
Returns the hand the card belongs to.
|
java.lang.Enum |
getRank()
Returns the card's rank
|
int |
getRankId()
Returns the card's rank id.
|
double |
getRotationAngle()
Returns the current rotation angle.
|
double |
getScaleFactor()
Returns the current scale (zoom) factor.
|
java.lang.Enum |
getSuit()
Returns the card's suit.
|
int |
getSuitId()
Returns the card's suit id.
|
int |
getValue()
Returns the value of the card.
|
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
isInHand(Hand hand)
Returns true, if the current card is part of the given hand.
|
boolean |
isVerso()
Returns true, if the card cover (back) will be shown.
|
void |
removeFromHand(boolean redraw)
Removes the card from its hand.
|
void |
setVerso(boolean isVerso)
Determines if the card's face or cover (back) will be shown.
|
void |
slideToTarget(Location targetLocation,
int slideStep)
Same as slideToTarget(targetLocation, slideStep, blocking) with blocking = true.
|
void |
slideToTarget(Location targetLocation,
int slideStep,
boolean blocking)
If the card is added to the GameGrid, handless and visible, moves
the card actor from current location to
the given location using the given number of steps per GameGrid's
simulation cycle.
|
java.lang.String |
toString()
Returns a string representation in the format "suit-rank".
|
void |
transfer(Hand targetHand,
boolean doDraw)
Animated or non-animated transfer from current hand to new hand using the
currently defined target area.
|
void |
transferNonBlocking(Hand targetHand,
boolean doDraw)
Same as transfer(targetHand, doDraw), but
the methods returns immediately.
|
public static boolean noVerso
public Card(Deck deck, T suit, R rank)
T
- the Enum type of the suitR
- the Enum type of the rankdeck
- the deck where to the the cards seed actorsuit
- the card suitrank
- the card rankpublic Card(Deck deck, T suit, R rank, boolean isVerso)
T
- the Enum type of the suitR
- the Enum type of the rankdeck
- the deck where to the the cards seed actorsuit
- the card suitrank
- the card rankisVerso
- if true the card cover (back) will be shown; otherwise the face will be shownpublic Card(Deck deck, int cardNb)
deck
- the deck where to the the cards seed actorcardNb
- the card number as defined in the Deck classDeck.getSuitId(int cardNb)
,
Deck.getRankId(int cardNb)
public CardActor associateActor(double scaleFactor, double rotationAngle)
scaleFactor
- the scale factor (1: no scaling) applied to the image transformationrotationAngle
- the rotation angle (in degrees, clockwise) applied to the image transformationpublic Card clone()
clone
in class java.lang.Object
public Card cloneAndAdd()
public Card cloneAndAdd(double rotationAngle)
rotationAngle
- the modified rotation angle of the card clonepublic CardActor getCardActor()
public int getCardNumber()
public double getScaleFactor()
public double getRotationAngle()
public java.awt.Dimension getDimension()
public Deck getDeck()
public java.lang.Enum getSuit()
public int getSuitId()
public java.lang.Enum getRank()
public int getRankId()
public int compareTo(java.lang.Object other)
compareTo
in interface java.lang.Comparable
public boolean isVerso()
public void setVerso(boolean isVerso)
isVerso
- the visibilty used for the card; if true, the card cover (back)
is active (sprite Id = 1); otherwise the card face is active (sprite Id = 0)public java.lang.String toString()
toString
in class java.lang.Object
public boolean isInHand(Hand hand)
public int getValue()
public void removeFromHand(boolean redraw)
redraw
- if true, a redraw is automatically done;
otherwise redraw is not invokedpublic void slideToTarget(Location targetLocation, int slideStep)
targetLocation
- the location where the card should arriveslideStep
- the number of steps moved in one cyclepublic void slideToTarget(Location targetLocation, int slideStep, boolean blocking)
targetLocation
- the location where the card should arriveslideStep
- the number of steps moved in one cycleblocking
- if true, the methods blocks until the card arrives at the
target; otherwise the method returns immediatelypublic void transfer(Hand targetHand, boolean doDraw)
targetHand
- the hand where to move the carddoDraw
- if true, the hand the card belongs to and the target hand are drawn
(stacked arrangments are always drawn)Hand.transfer(Card card, Hand targetHand, boolean blocking, boolean redraw)
,
TargetArea
public void transferNonBlocking(Hand targetHand, boolean doDraw)
targetHand
- the hand where to transfer the carddoDraw
- if true, the hand the card belongs to and the target hand are drawn
(stacked arrangments are always drawn)public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object whose suit and rank is checkedpublic int hashCode()
hashCode
in class java.lang.Object
public Hand getHand()