Skip to content

CardContainer

Divided by Zer0 edited this page Mar 9, 2022 · 22 revisions

CardContainer

Extends: Area2D

Description

The CardContainer is meant to have Card objects as children nodes and arrange their indexing and visibility

Enumerations

Anchors

const Anchors: Dictionary = {"BOTTOM_LEFT":8,"BOTTOM_MIDDLE":7,"BOTTOM_RIGHT":6,"CONTROL":9,"LEFT_MIDDLE":5,"NONE":0,"RIGHT_MIDDLE":4,"TOP_LEFT":3,"TOP_MIDDLE":2,"TOP_RIGHT":1}

The various automatic Anchors possible for a CardContainer NONE means the container will not stay anchored to the screen and will not adjust its position if the viewport changes. Use this setting if your game is not expected to use different resolutions or you want this CardContainer to be placed somewhere other than the edge of the viewport (although you could adjust that in code as well)

All other options will automatically adjust the position of the CardContainer if the resolution changes

Property Descriptions

placement

export var placement = 0

Spefifies the anchor of the card on the screen layout This placement will be retained as the window is resized.

overlap_shift_direction

export var overlap_shift_direction = 0

Spefifies the anchor of the card on the screen layout This placement will be retained as the window is resized. In case of multiple CardContainers using the same anchor placement, specifies whether this container should displace itself to make space for the others, and how.

index_shift_priority

export var index_shift_priority = 0

Spefifies the anchor of the card on the screen layout This placement will be retained as the window is resized. In case of multiple CardContainers using the same anchor placement, specifies whether this container should displace itself to make space for the others, and how. In case of multiple CardContainers using the same anchor placement specifies which container should be displaced more.

card_size

export var card_size: Vector2 = "(150, 240)"

Spefifies the anchor of the card on the screen layout This placement will be retained as the window is resized. In case of multiple CardContainers using the same anchor placement, specifies whether this container should displace itself to make space for the others, and how. In case of multiple CardContainers using the same anchor placement specifies which container should be displaced more.

show_manipulation_buttons

export var show_manipulation_buttons: bool = true

If set to false, no manipulation buttons will appear when hovering over this container.

accumulated_shift

var accumulated_shift: Vector2

Used for debugging Stores how much this container has moved from its original anchor placement as a result of other containers sharing the same anchor placement

manipulation_buttons

var manipulation_buttons: Node

Used for debugging Stores how much this container has moved from its original anchor placement as a result of other containers sharing the same anchor placement ManipulationButtons node

manipulation_buttons_tween

var manipulation_buttons_tween: Node

Used for debugging Stores how much this container has moved from its original anchor placement as a result of other containers sharing the same anchor placement ManipulationButtons node ManipulationButtons tween node

control

var control: Node

Used for debugging Stores how much this container has moved from its original anchor placement as a result of other containers sharing the same anchor placement ManipulationButtons node ManipulationButtons tween node Control node

shuffle_button

var shuffle_button: Node

Used for debugging Stores how much this container has moved from its original anchor placement as a result of other containers sharing the same anchor placement ManipulationButtons node ManipulationButtons tween node Control node Shuffle button

highlight

var highlight: Node

Used for debugging Stores how much this container has moved from its original anchor placement as a result of other containers sharing the same anchor placement ManipulationButtons node ManipulationButtons tween node Control node Shuffle button Container higlight

Method Descriptions

are_cards_still_animating

func are_cards_still_animating() -> bool

hide_buttons

func hide_buttons() -> void

Hides manipulation buttons

show_buttons

func show_buttons() -> void

Shows manipulation buttons

get_all_manipulation_buttons

func get_all_manipulation_buttons() -> Array

Getter for all_manipulation_buttons

Updates Array with all manipulation_button group nodes, By using group, different tree structures are allowed

get_class

func get_class()

Overrides the built-in get_class to return "CardContainer" instead of "Area2D"

get_all_cards

func get_all_cards() -> Array

Returns an array with all children nodes which are of Card class

get_card_count

func get_card_count() -> int

Returns an int with the amount of children nodes which are of Card class

get_card

func get_card(idx: int) -> Card

Returns a card object of the card in the specified index among all cards.

get_card_index

func get_card_index(card: Card) -> int

Returns an int of the index of the card object requested

has_card

func has_card(card: Card) -> bool

Returns true if this card container has a Card object matching the specified one

has_card_name

func has_card_name(card_name: String) -> bool

Returns true is any card in this card container has a canonical_name that matches the provided argument.

get_random_card

func get_random_card() -> Card

Returns a random card object among the children nodes

get_last_card

func get_last_card() -> Card

Return the card with the lowest index

get_first_card

func get_first_card() -> Card

Teturn the card with the highest index

shuffle_cards

func shuffle_cards() -> void

Randomly rearranges the order of the Card nodes.

get_final_placement_node

func get_final_placement_node(card: Card) -> Node

Overridable function to allow the container to specify different effects to happen when a card is attempted to be added It should always return a valid node to put the card in

For example, this can be used by a Hand to discard excess cards warning-ignore:unused_argument

translate_card_index_to_node_index

func translate_card_index_to_node_index(index: int) -> int

Translates requested card index to true node index. By that, we mean the index the Card object it would have among all its siblings, inlcuding non-Card nodes

re_place

func re_place()

Adjusts the placement of the node, according to the placement var So that it always stays in the same approximate location

Signals

  • signal shuffle_completed():
Clone this wiki locally