From b4f33f30b62a9ea506e8ccff7ca178afba471ccd Mon Sep 17 00:00:00 2001 From: CactiChameleon9 Date: Sun, 17 Jul 2022 16:47:27 +0100 Subject: [PATCH] Setup signals to give information from running cards --- Assets/CardDB/CardBD.gd | 16 +--------------- Global.gd | 15 +++++++++++++++ Scenes/BattleScene.gd | 6 ++++++ Scenes/BattleScene.tscn | 3 +++ UI/Card.gd | 21 +++++++++++++++------ UI/CardView.gd | 12 ++++++++++++ project.godot | 4 ++++ 7 files changed, 56 insertions(+), 21 deletions(-) create mode 100644 Global.gd diff --git a/Assets/CardDB/CardBD.gd b/Assets/CardDB/CardBD.gd index 424aa11..eecb615 100644 --- a/Assets/CardDB/CardBD.gd +++ b/Assets/CardDB/CardBD.gd @@ -9,20 +9,6 @@ enum TYPE { MOVEMENT } -enum EFFECT { - POISON - BURN - CONFUSION - WEAKNESS - - SPLIT - DOUBLE - HALF - FLIP - DUPLICATE - REROLL -} - enum ACCEPTED_DICE { DICE_1 DICE_2 @@ -44,7 +30,7 @@ export (int) var move_dice_multiplyer export (int) var damage_amount_addition export (int) var damage_dice_multiplyer -export (Array, EFFECT) var effects +export (Array, Global.EFFECT) var effects export (Array, ACCEPTED_DICE) var accepted_dice diff --git a/Global.gd b/Global.gd new file mode 100644 index 0000000..ea113e0 --- /dev/null +++ b/Global.gd @@ -0,0 +1,15 @@ +extends Node + +enum EFFECT { + POISON + BURN + CONFUSION + WEAKNESS + + SPLIT + DOUBLE + HALF + FLIP + DUPLICATE + REROLL +} diff --git a/Scenes/BattleScene.gd b/Scenes/BattleScene.gd index 88833d5..8a0dc55 100644 --- a/Scenes/BattleScene.gd +++ b/Scenes/BattleScene.gd @@ -22,6 +22,12 @@ func _ready(): $UI/DiceView.roll_dice() +func do_damage_around_player(damage, damage_range): + pass + +func do_effect_around_player(effect, effect_range): + pass + func set_player_to_move(movement_range : int = 0): player_to_move = true player_movement_range = movement_range diff --git a/Scenes/BattleScene.tscn b/Scenes/BattleScene.tscn index 300a7bf..d0e10bc 100644 --- a/Scenes/BattleScene.tscn +++ b/Scenes/BattleScene.tscn @@ -76,5 +76,8 @@ margin_left = 1.52588e-05 margin_top = -7.62939e-06 grow_horizontal = 0 +[connection signal="do_damage" from="UI/CardView" to="." method="do_damage_around_player"] +[connection signal="do_effect" from="UI/CardView" to="." method="do_effect_around_player"] +[connection signal="do_movement" from="UI/CardView" to="." method="set_player_to_move"] [connection signal="return_dice" from="UI/CardView" to="UI/DiceView" method="roll_dice"] [connection signal="dice_selected" from="UI/DiceView" to="UI/CardView" method="set_currently_holding_dice"] diff --git a/UI/Card.gd b/UI/Card.gd index fa71eba..7a51f0c 100644 --- a/UI/Card.gd +++ b/UI/Card.gd @@ -2,6 +2,9 @@ tool extends Control signal return_dice(dice_number) +signal do_movement(movement_range) +signal do_damage(damage, damage_range) +signal do_effect(effect, effect_range) const TYPE_COLORS = [ Color("#db4758"), # DAMAGE @@ -121,11 +124,12 @@ func run_card(): var damage = card_info.damage_amount_addition for dice_number in input_dice: damage += card_info.damage_dice_multiplyer * dice_number + emit_signal("do_damage", damage, card_info.effect_damage_range) # do any utility dice returns for dice_number in input_dice: - if card_info.EFFECT.SPLIT in card_info.effects: + if Global.EFFECT.SPLIT in card_info.effects: var halfed_dice = float(dice_number)/2.0 var new_dice1 = halfed_dice @@ -139,7 +143,7 @@ func run_card(): emit_signal("return_dice", new_dice1) emit_signal("return_dice", new_dice2) - if card_info.EFFECT.DOUBLE in card_info.effects: + if Global.EFFECT.DOUBLE in card_info.effects: var new_dice1 = dice_number * 2 var new_dice2 = 0 @@ -151,7 +155,7 @@ func run_card(): emit_signal("return_dice", new_dice1) if new_dice2 != 0: emit_signal("return_dice", new_dice1) - if card_info.EFFECT.HALF in card_info.effects: + if Global.EFFECT.HALF in card_info.effects: var new_dice = float(dice_number)/2.0 #if decimal valued, add 0.5 or - 0.5 at random @@ -160,14 +164,19 @@ func run_card(): emit_signal("return_dice", new_dice) - if card_info.EFFECT.FLIP in card_info.effects: + if Global.EFFECT.FLIP in card_info.effects: # all opposite sides of a dice add up to 7 emit_signal("return_dice", 7 - dice_number) - if card_info.EFFECT.DUPLICATE in card_info.effects: + if Global.EFFECT.DUPLICATE in card_info.effects: emit_signal("return_dice", dice_number) emit_signal("return_dice", dice_number) - + + # for each effect, emit do effect with the range + for effect in card_info.effects: + emit_signal("do_effect", effect, card_info.effect_damage_range) + + emit_signal("do_movement", card_info.movement) #clear the input dice input_dice = [] diff --git a/UI/CardView.gd b/UI/CardView.gd index 8c4bccb..5ba87f3 100644 --- a/UI/CardView.gd +++ b/UI/CardView.gd @@ -1,6 +1,9 @@ extends Control signal return_dice(dice_number) +signal do_movement(movement_range) +signal do_damage(damage, damage_range) +signal do_effect(effect, effect_range) const card = preload("res://UI/Card.tscn") const card_db_string = "res://Assets/CardDB/%s.tres" @@ -16,6 +19,12 @@ var currently_holding_dice = null func emit_return_dice(dice_number): emit_signal("return_dice", dice_number) +func emit_do_movement(movement_range): + emit_signal("do_movement", movement_range) +func emit_do_damage(damage, damage_range): + emit_signal("do_damage", damage, damage_range) +func emit_do_effect(effect, effect_range): + emit_signal("do_effect", effect, effect_range) func set_currently_holding_dice(dice_number : int): @@ -80,6 +89,9 @@ func draw_card(specific_card : String = ""): # connect new_card.return_dice signal to self.emit_return_dice new_card.connect("return_dice", self, "emit_return_dice") + new_card.connect("do_movement", self, "emit_do_movement") + new_card.connect("do_damage", self, "emit_do_damage") + new_card.connect("do_effect", self, "emit_do_effect") # add the current card to the list of card current_cards.append(new_card) diff --git a/project.godot b/project.godot index e289f34..d220367 100644 --- a/project.godot +++ b/project.godot @@ -24,6 +24,10 @@ config/name="Quit Rolling Around" run/main_scene="res://Scenes/BattleScene.tscn" config/icon="res://icon.png" +[autoload] + +Global="*res://Global.gd" + [display] window/size/width=1280