2023-11-08 14:28:55 +11:00
|
|
|
extends Node2D
|
|
|
|
class_name CardInHand
|
|
|
|
|
|
|
|
var stats : Card
|
|
|
|
@export var rarity_sprite : Sprite2D
|
2023-11-15 15:19:40 +11:00
|
|
|
@export var title_text : Label
|
|
|
|
@export var description : RichTextLabel
|
2023-11-16 00:07:41 +11:00
|
|
|
@export var target_label : Label
|
2023-11-08 14:28:55 +11:00
|
|
|
|
|
|
|
func set_card(value):
|
|
|
|
stats = value
|
2023-12-08 03:05:11 +11:00
|
|
|
title_text.text = stats.display_name
|
2023-11-16 00:07:41 +11:00
|
|
|
target_label.text = str(Data.TargetType.keys()[stats.tower_stats.target_type])
|
2023-11-08 14:28:55 +11:00
|
|
|
rarity_sprite.region_rect = Rect2(64 * stats.rarity, 0, 64, 64)
|
2023-11-15 15:19:40 +11:00
|
|
|
|
|
|
|
|
|
|
|
func process_card_text(card_text : CardText) -> String:
|
|
|
|
var processed_string = card_text.text
|
|
|
|
for stat in card_text.attributes:
|
|
|
|
processed_string = processed_string.replace(stat.key, str(stat.value))
|
|
|
|
processed_string = processed_string.replace("/", "[color=red]")
|
|
|
|
processed_string = processed_string.replace("\\", "[color=black]")
|
|
|
|
return processed_string
|
2023-11-08 14:28:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
func view_weapon():
|
2023-11-15 15:19:40 +11:00
|
|
|
description.text = process_card_text(stats.weapon_stats)
|
2023-11-16 00:07:41 +11:00
|
|
|
target_label.text = "Both"
|
2023-11-08 14:28:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
func view_tower():
|
2023-11-15 15:19:40 +11:00
|
|
|
description.text = process_card_text(stats.tower_stats)
|
2023-11-17 20:49:38 +11:00
|
|
|
target_label.text = str(Data.TargetType.keys()[stats.tower_stats.target_type])
|