32 lines
862 B
GDScript
32 lines
862 B
GDScript
extends Node
|
|
|
|
@export var full_deck: Dictionary[int, Card]
|
|
@export var card_textures: Dictionary[int, Texture]
|
|
@export var card_fallback_texture: Texture
|
|
|
|
func get_shuffled_cards(client_ids: Array[String], cards_to_pick: int) -> Dictionary: # Dictionary[String, Array[int]]
|
|
var dict: Dictionary = {}
|
|
var deck: Array[int] = full_deck.keys()
|
|
deck.shuffle()
|
|
var card_index = 0
|
|
for client_id in client_ids:
|
|
var player_deck: Array[int] = []
|
|
for j in cards_to_pick:
|
|
player_deck.append(deck[card_index])
|
|
card_index += 1
|
|
dict[client_id] = player_deck
|
|
|
|
# Add trump card, if there are cards left in the deck
|
|
if card_index == 60:
|
|
dict["trump"] = -1
|
|
else:
|
|
dict["trump"] = deck[card_index]
|
|
|
|
return dict
|
|
|
|
func get_card_texture(card_id: int) -> Texture:
|
|
if card_textures.has(card_id):
|
|
return card_textures[card_id]
|
|
|
|
return card_fallback_texture
|