Constructor
new Card(suit, rank, owner)
Creates a new card instance.
Parameters:
Name | Type | Description |
---|---|---|
suit |
string | The suit of the card (e.g., hearts, spades). |
rank |
string | number | The rank of the card (e.g., 2, 10, K). |
owner |
Object | The parent deck or table managing the card. |
Extends
- HTMLElement
Classes
Methods
hideCard() → {Card}
Hides the card, showing its back instead of its face.
Returns:
- The current card instance for method chaining.
- Type
- Card
moveTo(x, y, optionsopt) → {Promise.<void>}
Moves the card to a specified position with animation.
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
number | The X-coordinate to move the card to. | |||||||||||
y |
number | The Y-coordinate to move the card to. | |||||||||||
options |
Object |
<optional> |
Movement options.
Properties
|
Returns:
- Resolves after the movement animation completes.
- Type
- Promise.<void>
rotate(angle, originopt, optionsopt) → {Promise.<void>}
Rotates the card to a specified angle with animation.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
angle |
number | The angle in degrees to rotate the card. | ||||||||||||||||
origin |
Object |
<optional> |
Rotation origin.
Properties
|
|||||||||||||||
options |
Object |
<optional> |
Rotation options.
Properties
|
Returns:
- Resolves after the rotation animation completes.
- Type
- Promise.<void>
setzIndex(zIndex) → {Card}
Sets the z-index of the card, controlling its stack order.
Parameters:
Name | Type | Description |
---|---|---|
zIndex |
number | The z-index to set. |
Returns:
- The current card instance for method chaining.
- Type
- Card
showCard() → {Card}
Displays the card face-up, showing its suit and rank.
Returns:
- The current card instance for method chaining.
- Type
- Card
toString() → {string}
Converts the card to its string representation.
Returns:
- The card's name (e.g., "H10" for 10 of hearts).
- Type
- string