Skip to content
Divided by Zer0 edited this page Mar 9, 2022 · 12 revisions

Hand

Extends: CardContainer < Area2D

Description

A type of CardContainer that stores its Card objects with full visibility to the player and provides methods for adding new ones and reorganizing them

Enumerations

ExcessCardsBehaviour

const ExcessCardsBehaviour: Dictionary = {"ALLOW":1,"DISALLOW":0,"DISCARD_DRAWN":2,"DISCARD_OLDEST":3}

Specifies the behaviour to follow when trying to draw a card and we exceed our hand size

Property Descriptions

bottom_margin

var bottom_margin: float

The maximum amount of cards allowed to draw in this hand Offsets the hand position based on the configuration

excess_discard_pile_name

export var excess_discard_pile_name: String = ""

Specify the name of the pile to discard excess cards When "Discard Drawn" or "Discard Oldest" is specified in excess_cards

hand_size

export var hand_size: int = 10

Specify the name of the pile to discard excess cards When "Discard Drawn" or "Discard Oldest" is specified in excess_cards The maximum hand size. What happens if this is exceeded is determined by excess_cards

excess_cards

export var excess_cards = 0

Specify the name of the pile to discard excess cards When "Discard Drawn" or "Discard Oldest" is specified in excess_cards The maximum hand size. What happens if this is exceeded is determined by excess_cards Determines the behaviour of cards over the hand limit

  • DISALLOWED: When hand is at limit, no more cards will be added to it
  • ALLOWED: More cards than the limit can be added to the hand. The developer has to provide some logic on how to deal with the excess
  • "DISCARD_DRAWN": When cards exceed the limit, the new card will be automatically discarded
  • "DISCARD_OLDEST": When cards exceed the limit, the oldest card in the hand will be automatically discarded

Method Descriptions

prepare_excess_discard_pile

func prepare_excess_discard_pile() -> void

get_rightmost_card

func get_rightmost_card() -> Card

A wrapper for the CardContainer's get_last_card() which make sense for the cards' index in a hand

get_leftmost_card

func get_leftmost_card() -> Card

A wrapper for the CardContainer's get_first_card() which make sense for the cards' index in a hand

shuffle_cards

func shuffle_cards() -> void

Visibly shuffles all cards in hand

draw_card

func draw_card(pile: Pile) -> Card

Takes the top card from the specified CardContainer and adds it to this node Returns a card object drawn

get_final_placement_node

func get_final_placement_node(card: Card) -> Node

re_place

func re_place() -> var

Overrides the re_place() function of CardContainer in order to also resize the hand rect, according to how many other CardContainers exist in the same row/column

Clone this wiki locally