Alle Glücksradaufgaben sind drin
main
Daniel Lehmann 2024-03-29 17:46:17 +01:00
parent a1aca34d89
commit 552667e797
2 changed files with 31 additions and 7 deletions

View File

@ -79,7 +79,7 @@ func _calculate_drop_pos(grid_pos: Vector2) -> Vector2:
#Löscht eine Zeile nach dem Glücksrad ereignis
func delete_column(column: int) -> void:
for j in range((column - 2), -1, -1):
for j in range((column - 3), -1, -1):
for i in range(-2, 4, 1):
var tile_map_layer = 1
var tile_map_cell_position = Vector2i(i,j)
@ -97,8 +97,9 @@ func delete_column(column: int) -> void:
func delete_row(row: int) -> void:
var tile_map_layer = 1
for i in range(6):
#Inhalt leer setzten
self.set_cell(tile_map_layer, Vector2i(row - 2, i))
#Inhalt leer setzten (row -3 damit es mit 1 - 6 funktioniert)
self.set_cell(tile_map_layer, Vector2i(row - 3, i))

31
game.gd
View File

@ -3,6 +3,7 @@ extends Node2D
var current_player: int = 0
var player_states := ["Circle", "Cross"]
var won := ""
var five_wins = false
var count = 0
@ -67,10 +68,16 @@ func _check_win() -> String:
for check in _checks:
for i in range(3):
var same = true
for j in range(4):
if board.get_state(cell + check[0] * (i + j)) != state:
same = false
break
if five_wins:
for j in range(5):
if board.get_state(cell + check[0] * (i + j)) != state:
same = false
break
else:
for j in range(4):
if board.get_state(cell + check[0] * (i + j)) != state:
same = false
break
if same:
return state
return ""
@ -129,3 +136,19 @@ 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:
five_wins = true
#Nach dem Glücksradereignis tauschen die Spieler die Symbole
func _change_symbols() -> void:
current_player = 1 - current_player
nextPlayer.region_rect.position.x = current_player * 300
#Nach dem Glücksradereignis gewinnt der Spieler sofort
func _instant_win():
print("Winner: ", won)
wonPlayer.region_rect.position.x = player_states.find(won) * 300
wonPlayer.show()
nextPlayer.hide()
board.active = false