Implement more dice checks
This commit is contained in:
parent
f7de541341
commit
ce07155494
40
UI/Card.gd
40
UI/Card.gd
@ -15,6 +15,8 @@ const TYPE_COLORS = [
|
||||
export (Resource) var card_info
|
||||
|
||||
var input_dice = []
|
||||
var addition_dice_amount = card_info.addition_amount
|
||||
|
||||
|
||||
func _ready():
|
||||
|
||||
@ -35,6 +37,8 @@ func _ready():
|
||||
|
||||
|
||||
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
|
||||
@ -45,11 +49,41 @@ 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)
|
||||
|
||||
if len(input_dice) == card_info.number_of_dice:
|
||||
# -- 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:
|
||||
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):
|
||||
run_card()
|
||||
|
||||
|
||||
func run_card():
|
||||
pass
|
||||
# calculate the damage amount
|
||||
var damage = card_info.damage_amount_addition
|
||||
for dice in input_dice:
|
||||
damage += card_info.damage_dice_multiplyer * dice
|
||||
|
Loading…
Reference in New Issue
Block a user