From 6a6e74efa8d5c31adc67b7e9733214fb64c5eed3 Mon Sep 17 00:00:00 2001 From: CactiChameleon9 Date: Sat, 16 Jul 2022 16:12:32 +0100 Subject: [PATCH] Add UI support for addition dice, remove card once used --- UI/Card.gd | 17 +++++++++++++++-- UI/Card.tscn | 13 +++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/UI/Card.gd b/UI/Card.gd index 81d694b..c33c87b 100644 --- a/UI/Card.gd +++ b/UI/Card.gd @@ -15,7 +15,11 @@ const TYPE_COLORS = [ export (Resource) var card_info var input_dice = [] -var addition_dice_amount = card_info.addition_amount +var addition_dice_amount : int setget _set_addition_dice + + +func _set_addition_dice(new_amount): + $VBox/AutoGrid/InputDice0/Number.text = String(new_amount) func _ready(): @@ -34,6 +38,10 @@ func _ready(): # change the name and description $VBox/Name.text = card_info.name $VBox/Description.text = card_info.description + + #maybe set the addition amount + if card_info.addition_dice: + self.addition_dice_amount = card_info.addition_amount func dice_inputted(dice_number : int): @@ -70,7 +78,7 @@ func dice_inputted(dice_number : int): # -- RUN DICE CHECKS -- if card_info.addition_dice: - addition_dice_amount -= dice_number + self.addition_dice_amount -= dice_number input_dice.remove(0) if addition_dice_amount > 0: return @@ -135,4 +143,9 @@ func run_card(): emit_signal("return_dice", dice_number) + #clear the input dice input_dice = [] + + #card is used, disappear + queue_free() + diff --git a/UI/Card.tscn b/UI/Card.tscn index f25ab9b..d73dfe5 100644 --- a/UI/Card.tscn +++ b/UI/Card.tscn @@ -7,7 +7,7 @@ [ext_resource path="res://AutoGridContainer - Full Version/AutoGridContainer.tscn" type="PackedScene" id=5] [ext_resource path="res://Assets/Metropolis-font/Metropolis-Medium.ttf" type="DynamicFontData" id=6] -[sub_resource type="StyleBoxFlat" id=6] +[sub_resource type="StyleBoxFlat" id=8] bg_color = Color( 0.858824, 0.278431, 0.345098, 1 ) corner_radius_top_left = 20 corner_radius_top_right = 20 @@ -45,7 +45,7 @@ card_info = ExtResource( 2 ) [node name="PanelContainer" type="PanelContainer" parent="."] anchor_right = 1.0 anchor_bottom = 1.0 -custom_styles/panel = SubResource( 6 ) +custom_styles/panel = SubResource( 8 ) [node name="VBox" type="VBoxContainer" parent="."] anchor_right = 1.0 @@ -59,14 +59,14 @@ margin_bottom = -10.0 margin_right = 263.0 margin_bottom = 31.0 custom_fonts/font = SubResource( 2 ) -text = "The Card Name" +text = "Broadsword" align = 1 autowrap = true [node name="AutoGrid" parent="VBox" instance=ExtResource( 5 )] margin_top = 35.0 margin_right = 263.0 -margin_bottom = 259.0 +margin_bottom = 256.0 [node name="InputDice0" type="TextureRect" parent="VBox/AutoGrid"] margin_left = 9.0 @@ -90,12 +90,13 @@ align = 1 valign = 1 [node name="Description" type="Label" parent="VBox"] -margin_top = 263.0 +margin_top = 260.0 margin_right = 263.0 margin_bottom = 353.0 rect_min_size = Vector2( 0, 90 ) custom_fonts/font = SubResource( 5 ) -text = "Description" +text = "Does damage equal to the sum of both dice to all enemies +Range: 2 spaces" align = 1 valign = 1 autowrap = true