Compare commits
No commits in common. "6a6e74efa8d5c31adc67b7e9733214fb64c5eed3" and "f7de5413413ab7dca84905cde5e6a52995a0dfe8" have entirely different histories.
6a6e74efa8
...
f7de541341
102
UI/Card.gd
102
UI/Card.gd
@ -15,12 +15,6 @@ const TYPE_COLORS = [
|
||||
export (Resource) var card_info
|
||||
|
||||
var input_dice = []
|
||||
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():
|
||||
|
||||
@ -39,14 +33,8 @@ func _ready():
|
||||
$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):
|
||||
|
||||
# -- SINGLE DICE CHECKS --
|
||||
#check if dice is within dice range
|
||||
if dice_number >= 1 and dice_number <= 6:
|
||||
return
|
||||
@ -57,95 +45,11 @@ func dice_inputted(dice_number : int):
|
||||
emit_signal("return_dice", dice_number)
|
||||
return
|
||||
|
||||
#add the dice to the input if it passes individual checks
|
||||
|
||||
input_dice.append(dice_number)
|
||||
|
||||
# -- MULTI DICE CHECKS --
|
||||
#if same dice requirement, then check if true
|
||||
if card_info.same_dice_requirement:
|
||||
var same_dice = true
|
||||
|
||||
for i in range(1, len(input_dice)):
|
||||
if input_dice[i-1] != input_dice[i]:
|
||||
same_dice = false
|
||||
break
|
||||
|
||||
# if not all the same dice then return all of the dice
|
||||
if not same_dice:
|
||||
for _i in len(input_dice):
|
||||
emit_signal("return_dice", input_dice[0])
|
||||
input_dice.remove(0)
|
||||
|
||||
# -- RUN DICE CHECKS --
|
||||
if card_info.addition_dice:
|
||||
self.addition_dice_amount -= dice_number
|
||||
input_dice.remove(0)
|
||||
if addition_dice_amount > 0:
|
||||
return
|
||||
else:
|
||||
run_card()
|
||||
|
||||
if (len(input_dice) == card_info.number_of_dice
|
||||
and not card_info.addition_dice):
|
||||
if len(input_dice) == card_info.number_of_dice:
|
||||
run_card()
|
||||
|
||||
|
||||
func run_card():
|
||||
# calculate the damage amount
|
||||
var damage = card_info.damage_amount_addition
|
||||
for dice_number in input_dice:
|
||||
damage += card_info.damage_dice_multiplyer * dice_number
|
||||
|
||||
# do any utility dice returns
|
||||
for dice_number in input_dice:
|
||||
|
||||
if card_info.EFFECT.SPLIT in card_info.effects:
|
||||
var halfed_dice = float(dice_number)/2.0
|
||||
|
||||
var new_dice1 = halfed_dice
|
||||
var new_dice2 = halfed_dice
|
||||
|
||||
#if decimal value, then minus half and add half
|
||||
if halfed_dice % 1 != 0:
|
||||
new_dice1 -= 0.5
|
||||
new_dice2 += 0.5
|
||||
|
||||
emit_signal("return_dice", new_dice1)
|
||||
emit_signal("return_dice", new_dice1)
|
||||
|
||||
if card_info.EFFECT.DOUBLE in card_info.effects:
|
||||
var new_dice1 = dice_number * 2
|
||||
var new_dice2 = 0
|
||||
|
||||
#dice has to be smaller than 7
|
||||
if new_dice1 > 6:
|
||||
new_dice1 -= 6
|
||||
new_dice2 = 6
|
||||
|
||||
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:
|
||||
var new_dice = float(dice_number)/2.0
|
||||
|
||||
#if decimal valued, add 0.5 or - 0.5 at random
|
||||
if new_dice % 1 != 0:
|
||||
new_dice += round(randf()) - 0.5
|
||||
|
||||
emit_signal("return_dice", new_dice)
|
||||
|
||||
if card_info.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:
|
||||
emit_signal("return_dice", dice_number)
|
||||
emit_signal("return_dice", dice_number)
|
||||
|
||||
|
||||
#clear the input dice
|
||||
input_dice = []
|
||||
|
||||
#card is used, disappear
|
||||
queue_free()
|
||||
|
||||
pass
|
||||
|
13
UI/Card.tscn
13
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=8]
|
||||
[sub_resource type="StyleBoxFlat" id=6]
|
||||
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( 8 )
|
||||
custom_styles/panel = SubResource( 6 )
|
||||
|
||||
[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 = "Broadsword"
|
||||
text = "The Card Name"
|
||||
align = 1
|
||||
autowrap = true
|
||||
|
||||
[node name="AutoGrid" parent="VBox" instance=ExtResource( 5 )]
|
||||
margin_top = 35.0
|
||||
margin_right = 263.0
|
||||
margin_bottom = 256.0
|
||||
margin_bottom = 259.0
|
||||
|
||||
[node name="InputDice0" type="TextureRect" parent="VBox/AutoGrid"]
|
||||
margin_left = 9.0
|
||||
@ -90,13 +90,12 @@ align = 1
|
||||
valign = 1
|
||||
|
||||
[node name="Description" type="Label" parent="VBox"]
|
||||
margin_top = 260.0
|
||||
margin_top = 263.0
|
||||
margin_right = 263.0
|
||||
margin_bottom = 353.0
|
||||
rect_min_size = Vector2( 0, 90 )
|
||||
custom_fonts/font = SubResource( 5 )
|
||||
text = "Does damage equal to the sum of both dice to all enemies
|
||||
Range: 2 spaces"
|
||||
text = "Description"
|
||||
align = 1
|
||||
valign = 1
|
||||
autowrap = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user