Skip to content

TokenDrawer

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

TokenDrawer

Extends: Node2D

Description

This script handles interactions with the token drawer on a Card.

Property Descriptions

is_drawer_open

var is_drawer_open: bool
  • Setter: set_is_drawer_open

A flag on whether the token drawer is currently open

owner_card

var owner_card

Stores a reference to the Card that is hosting this node

Method Descriptions

set_is_drawer_open

func set_is_drawer_open(value: bool) -> void

Setter for is_drawer_open Simply calls token_drawer()

token_drawer

func token_drawer(requested_state: bool = true) -> var

Reveals or Hides the token drawer

The drawer will not appear while another animation is ongoing and it will appear only while the card is on the board.

mod_token

func mod_token(token_name: String, mod: int = 1, set_to_mod: bool = false, check: bool = false, tags: Array = "Manual") -> int

Adds a token to the card

If the token of that name doesn't exist, it creates it according to the config.

If the amount of existing tokens of that type drops to 0 or lower, the token node is also removed.

get_all_tokens

func get_all_tokens() -> Dictionary

Returns a dictionary of card tokens name on this card.

  • Key is the name of the token.
  • Value is the token scene.

get_token

func get_token(token_name: String) -> Token

Returns the token node of the provided name or null if not found.

get_token_count

func get_token_count(token_name: String) -> int

Returns only the token count if it exists. Else it returns 0

are_hovered

func are_hovered() -> bool

Returns true, when the mouse cursor is over the drawer. This is used to retain focus on the card while the player is manipulating tokens.