Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Commit

Permalink
Dice fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VargaDot committed Mar 6, 2024
1 parent 1099407 commit 800ddc7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
4 changes: 3 additions & 1 deletion game/Game.gd
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ func _diceManager():
currentGame = GAME_STATES.IDLE
var dice1 = randi_range(1, 6)
var dice2 = randi_range(1, 6)
var flagged:bool = false
if dice1 != dice2: Khana.ModifyDoubleCount(currentPlayer, false)
else:
flagged = true
Khana.ModifyDoubleCount(currentPlayer, true)
if Khana.GetAgentDoublesCount(currentPlayer) == 3:
Khana.ToggleAgentFreedom(currentPlayer)
Expand All @@ -83,7 +85,7 @@ func _diceManager():
pass
var roll = dice1 + dice2
print("dice rolled! ", roll)
emit_signal("RequestDice", roll)
emit_signal("RequestDice", dice1, dice2, flagged)
Khana.MoveAgent(currentPlayer, roll)
print(currentPlayer, " advanced to ", Khana.GetAgentPosition(currentPlayer))

Expand Down
27 changes: 10 additions & 17 deletions ui/dice/Dice.gd
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
extends Control

var dice1
var dice2
func _on_game_request_dice(diceRoll):
if diceRoll > 12: printerr("Invalid dice roll outcome")

# X represents the frames for AnimatedSprite2D
dice1 = diceRoll - 2
dice1 /= 2

if dice1 % 1 != 0:
if dice1 == 6: dice2 = dice1 - 1
else: dice2 = dice1 + 1
else: dice2 = dice1


var die1
var die2
func _on_game_request_dice(dice1, dice2, flagged):
die1 = dice1 - 1
die2 = dice2 - 1
_launchTimer()

show()
%Dice1.play("rolling")
%Dice2.play("rolling")
%Dice1.frame = randi_range(0,5)
%Dice2.frame = randi_range(0,5)

func _launchTimer():
var t:float = randf_range(1.25,3.25)
Expand All @@ -37,7 +30,7 @@ func _onTimeout():
else:
%Dice1.stop()
%Dice2.stop()
%Dice1.frame = dice1
%Dice2.frame = dice2
%Dice1.frame = die1
%Dice2.frame = die2
ranOnce = false

0 comments on commit 800ddc7

Please sign in to comment.