Class: Card

Card(suit, rank, owner)

Represents a card in a card deck.

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.
Source:

Extends

  • HTMLElement

Classes

Card

Methods

hideCard() → {Card}

Hides the card, showing its back instead of its face.
Source:
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
Name Type Attributes Default Description
speed number <optional>
this.owner.animationSpeed The animation speed in milliseconds.
Source:
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
Name Type Attributes Default Description
x Object <optional>
'center' Rotation x origin.
y Object <optional>
'center' Rotation y origin.
options Object <optional>
Rotation options.
Properties
Name Type Attributes Default Description
speed number <optional>
this.owner.animationSpeed The animation speed in milliseconds.
Source:
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.
Source:
Returns:
- The current card instance for method chaining.
Type
Card

showCard() → {Card}

Displays the card face-up, showing its suit and rank.
Source:
Returns:
- The current card instance for method chaining.
Type
Card

toString() → {string}

Converts the card to its string representation.
Source:
Returns:
- The card's name (e.g., "H10" for 10 of hearts).
Type
string