Compare commits

..

2 Commits

Author SHA1 Message Date
Daniel Lehmann 7084d586a8 Merge branch 'main' of https://gitty.informatik.hs-mannheim.de/3004405/TicTacToeExtreme 2024-03-29 17:47:09 +01:00
Daniel Lehmann 552667e797 v0.5.1
Alle Glücksradaufgaben sind drin
2024-03-29 17:46:17 +01:00
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 #Löscht eine Zeile nach dem Glücksrad ereignis
func delete_column(column: int) -> void: 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): for i in range(-2, 4, 1):
var tile_map_layer = 1 var tile_map_layer = 1
var tile_map_cell_position = Vector2i(i,j) var tile_map_cell_position = Vector2i(i,j)
@ -97,8 +97,9 @@ func delete_column(column: int) -> void:
func delete_row(row: int) -> void: func delete_row(row: int) -> void:
var tile_map_layer = 1 var tile_map_layer = 1
for i in range(6): for i in range(6):
#Inhalt leer setzten #Inhalt leer setzten (row -3 damit es mit 1 - 6 funktioniert)
self.set_cell(tile_map_layer, Vector2i(row - 2, i)) self.set_cell(tile_map_layer, Vector2i(row - 3, i))

23
game.gd
View File

@ -3,6 +3,7 @@ extends Node2D
var current_player: int = 0 var current_player: int = 0
var player_states := ["Circle", "Cross"] var player_states := ["Circle", "Cross"]
var won := "" var won := ""
var five_wins = false
var count = 0 var count = 0
@ -67,6 +68,12 @@ func _check_win() -> String:
for check in _checks: for check in _checks:
for i in range(3): for i in range(3):
var same = true var same = true
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): for j in range(4):
if board.get_state(cell + check[0] * (i + j)) != state: if board.get_state(cell + check[0] * (i + j)) != state:
same = false same = false
@ -129,3 +136,19 @@ func _get_dice_pos_y(result: int) -> int:
6: return 410 6: return 410
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