diff --git a/game.gd b/game.gd index a03bbf8..6a73baa 100644 --- a/game.gd +++ b/game.gd @@ -5,7 +5,6 @@ var player_states := ["Circle", "Cross"] var won := "" var five_wins = false - @onready var board := $Board as Board @onready var nextPlayer := $GUI/NextPlayer as Sprite2D @onready var wonPlayer := $GUI/WonPlayer as Sprite2D @@ -36,7 +35,6 @@ func _process(_delta): var new_pos = board._calculate_drop_pos(grid_pos) if board.set_state(new_pos, player_states[current_player]): won = _check_win() - #count = count + 1 if won=="": current_player = 1 - current_player nextPlayer.region_rect.position.x = current_player * 300 @@ -82,7 +80,7 @@ func _check_win() -> String: #Generiert die Zufallszahl von 1-6 -func _roll_dice(): +func _roll_dice() -> int: var zahl = randi() % 6 + 1 var animation_help var zahl_davor @@ -134,6 +132,8 @@ func _get_dice_pos_y(result: int) -> int: 6: return 410 return 410 + + #Nach dem Glücksradereignis wird die Siegesbedingung auf 5 gewinnt geändert func _five_wins() -> void: print("5 Gewinnt aktiv") #Debug @@ -162,4 +162,32 @@ func _instant_win(): #Zum Testen der Events func _on_test_pressed(): - board._clear_enemy_tile(Vector2(0,5)) + board.delete_row(3) + + +func _spin_the_wheel(result: int) -> void: + if result <= 5: + _instant_win() + elif result <= 15: + print("1 ding löschen")#Debug + if Input.is_action_just_pressed("Click"): + var grid_pos = board.gridpos_at_mouse() + board._clear_enemy_tile(grid_pos) + elif result <= 30: + _change_symbols() + elif result <= 45: + _five_wins() + elif result <= 65: + print("delete column")#Debug + board.delete_column(2) + elif result <= 85: + print("delete row")#Debug + board.delete_row(3) + elif result <= 100: + print("größer als 85")#Debug + + +#Am Glücksrad drehen +func _on_spin_the_wheel_pressed(): + var zahl = randi() % 100 + 1 + _spin_the_wheel(zahl) diff --git a/game.tscn b/game.tscn index 62bd5f6..5a63ac3 100644 --- a/game.tscn +++ b/game.tscn @@ -94,6 +94,13 @@ offset_bottom = 701.0 theme_override_font_sizes/font_size = 35 text = "Test" +[node name="Spin the Wheel" type="Button" parent="GUI"] +offset_left = 1395.0 +offset_top = 691.0 +offset_right = 1710.0 +offset_bottom = 835.0 +text = "Spin the Wheel" + [node name="Player1Label" type="Label" parent="GUI"] offset_left = 164.0 offset_top = 45.0 @@ -129,3 +136,4 @@ region_rect = Rect2(307, 108, 86, 86) [connection signal="pressed" from="GUI/RestartButton" to="." method="_on_restart_button_pressed"] [connection signal="pressed" from="GUI/DiceButton" to="." method="_on_dice_button_pressed"] [connection signal="pressed" from="GUI/Test" to="." method="_on_test_pressed"] +[connection signal="pressed" from="GUI/Spin the Wheel" to="." method="_on_spin_the_wheel_pressed"]