From 9f910aba7d79d65dd5b59275b97d135afdb55b2d Mon Sep 17 00:00:00 2001 From: Ileyan <3003916@stud.hs-mannheim.de> Date: Mon, 1 Apr 2024 23:09:32 +0200 Subject: [PATCH] v.0.7: fml Bugfixes lol --- assets/skull.png | Bin 9071 -> 0 bytes assets/skull.png.import | 34 ----------------------- board/board.gd | 12 +++----- game.gd | 59 +++++++++++++++++++++++++++++++--------- 4 files changed, 50 insertions(+), 55 deletions(-) delete mode 100644 assets/skull.png delete mode 100644 assets/skull.png.import diff --git a/assets/skull.png b/assets/skull.png deleted file mode 100644 index fe46f5e251ce4da030d3636bc91fce28348c1c13..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9071 zcma)iXH-*7w00ULNC_S39ciLQI)ow}Av6(0st^#QC`t{G2vSr)I-#l*X}&Z8k#?kt zh9Zc7v`_>QkWhrszj)XE^ZmOg>twB&v(GLwXP(*5%p_Qt8!|EQGJrrJCSxN#D-Z~* z{qLryrPd6*D5(H}gh9r7IyNDB8#56#jyDJ^TbqG@wjQhv=7&g?j+V;`+>vxzWlS?r zW9YFk5|a_|{n03`A8TnK;KA`mdg}ZJ!4D%>(N`xQ_nJdKRyVg!Ag6ATZ=~#H>!(VC zB}IghFkD2O`iprH6F!uqRS;Lqi!Lhw0mc&Zciy-;vMdUz9bhGqTuuM`ywb33Z7axarh9-k^2ku4D zy9(8Cs~|3;r0FHJ301Umm+Dzv#A9k0DNVo?7Z^|C`P0@3<$Pj&msIPF@pH6zS<)>pMg)0+qL`~*Dnr@J zf54B~$x!TWC|w+#t2o#Mx0;(Q^??)UfX?E_cZ(mLetM!c58q9KFQt z#ho#>$a;NXm68~OpqFXRyiZaF`iS=u2u#GST4S9uT06gIcqBe}9v%?+%?m~nB!#th zkWn_Wa#tmQ2e)8(Ovlmzyq7qX`3Xx1l=pEU$s0SYrx!+w0DJ+z)>Y1ygEv-GrMctqCt224#t$V{JjWPF>@+D z>Q2RygVMZnSf8lXWyRyw#17g5k<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3Mn87abH!|fqS}-_Hj;U%5Ny?5n54ZE5;&&4f9Z=VabcLTZ}!KajxN2A=fPI{ zd8eWq&@z@wRPSH{UxOQbGv_7^!WFYU2`I4Ny+t1O#vJ>~{$K6PNgdBt>2L-2c2v*< zTfA{Ei%xB*X957XHLo1~9qIV|0VyraVSZe)>T>p9dBF!+gts1tun>Wb9#z_7D(Nll znd`{g%lYpPkb~&FGkSbaOkVP1SX=u__MN2WN14v5E|^@rd7+xBw!h(+erllT@Syd% z`S`hx0pc>Ro;{6*R^JvgWc*53P7Fp#DC+Y9etB~+sEQlEmg9h>&bh~?I4RuCWtG!< zpaG*aB^Jqz++W(r!poA&W$JtORGB+gHn8T4K-RDJXV*Rye+aK-0yTl8nzsCTDWs1j zz)eDg@GGGZA+jN*zMS1`Ih4O$)gK(mQ01|#^Gt*k!mLn3zEzqO&<@hLi)o5Q{0O6M zY}W4ljOg3~)+A5fp>UA9RFf2}LOs9EE(R#f5A@pZBg*F$^Yud>@c5lhrC{y`|96WC{rFm% zi9#v%+Z)wChz%CW>(})JKMsYr6U_4VUn{x21+Rc|y-s#QSt*cHl&O0KI1@*Z?_{4B zdY~dA;O$p~w6vab!>~Zd2QEik3#&RfsDhX?h*W7ToXz!pRc!UdZLaP7-%p String: @@ -82,7 +81,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 i in range(-2, 4, 1): - self.set_cell(tile_map_layer, Vector2i(i, column - 1), 1, Vector2i(1, 2), 0) + self.set_cell(tile_map_layer, Vector2i(i, column - 1), 1, Vector2i(3,0), 0) await get_tree().create_timer(0.25).timeout #Inhalt leer setzten (row -3 damit es mit 1 - 6 funktioniert) self.set_cell(tile_map_layer, Vector2i(i, column - 1)) @@ -94,9 +93,6 @@ func delete_column(column: int) -> void: var tile_map_cell_source_id = self.get_cell_source_id(tile_map_layer, tile_map_cell_position); var tile_map_cell_atlas_coords = self.get_cell_atlas_coords(tile_map_layer, tile_map_cell_position) var tile_map_cell_alternative = self.get_cell_alternative_tile(tile_map_layer, tile_map_cell_position) - print(tile_map_cell_source_id) - print(tile_map_cell_atlas_coords) - print(tile_map_cell_alternative) var new_tile_map_cell_position = Vector2i(i, j + 1) self.set_cell(tile_map_layer, new_tile_map_cell_position, tile_map_cell_source_id, tile_map_cell_atlas_coords, tile_map_cell_alternative) if j == 0: @@ -106,13 +102,13 @@ func delete_column(column: int) -> void: self.set_cell(tile_map_layer, Vector2i(i, j + 1)) func delete_row(row: int) -> void: for i in range(6): - self.set_cell(tile_map_layer, Vector2i(row - 3, i), 1, Vector2i(1, 2), 0) + self.set_cell(tile_map_layer, Vector2i(row - 3, i), 1, Vector2i(3,0), 0) await get_tree().create_timer(0.25).timeout #Inhalt leer setzten (row -3 damit es mit 1 - 6 funktioniert) self.set_cell(tile_map_layer, Vector2i(row - 3, i)) func _clear_enemy_tile(grid_pos: Vector2) -> void: self.set_cell(tile_map_layer, grid_pos) - self.set_cell(tile_map_layer, grid_pos, 1, Vector2i(1, 2), 0) + self.set_cell(tile_map_layer, grid_pos, 1, Vector2i(3,0), 0) await get_tree().create_timer(0.25).timeout #Inhalt leer setzten (row -3 damit es mit 1 - 6 funktioniert) self.set_cell(tile_map_layer, grid_pos) diff --git a/game.gd b/game.gd index 7fc7681..e31e2ed 100644 --- a/game.gd +++ b/game.gd @@ -41,7 +41,7 @@ func _ready(): sequence_needed = 4 board.reset() won = "" - ereignis.text = "Ereignis: " + ereignis.text = "" sequenz.text = "4 - Gewinnt!" wonPlayer.hide() nextPlayer.region_rect.position.x = current_player * 300 @@ -61,27 +61,40 @@ func _process(_delta): if Input.is_action_just_pressed("Click") and move_allowed: var grid_pos = board.gridpos_at_mouse() if enable_remove: - print(grid_pos) board._clear_enemy_tile(grid_pos) enable_remove = false elif board.get_state(Vector2(grid_pos.x, 0)) == board.empty_state: var new_pos = board._calculate_drop_pos(grid_pos) if board.set_state(new_pos, player_states[current_player]): if zuege >= 1: - move_allowed = false #Damit vor jedem Zug gewürfelt wird (Ab Runde 2) + move_allowed = false wuerfeln_erlaubt = true zuege += 1 blindBoard.visible = false + ereignis.text = "" won = _check_win() if won=="": switch_player() else: - print("Winner: ", won) wonPlayer.region_rect.position.x = player_states.find(won) * 300 if won == player_states[0]: + print(str(_sequence)) + _sequence = _sort_array(_sequence) + print(str(_sequence)) + var umgerechnet = _umrechnung(_sequence) + _sequence = _lol(umgerechnet, _sequence) + print(str(umgerechnet)) + print(str(_sequence)) for tile in _sequence: board.set_cell(1, tile, 1, Vector2i(0, 2), 0) else: + print(str(_sequence)) + _sequence = _sort_array(_sequence) + print(str(_sequence)) + var umgerechnet = _umrechnung(_sequence) + _sequence = _lol(umgerechnet, _sequence) + print(str(umgerechnet)) + print(str(_sequence)) for tile in _sequence: board.set_cell(1, tile, 1, Vector2i(3, 2), 0) wonPlayer.show() @@ -121,10 +134,37 @@ func _check_win() -> String: break _sequence.append(Vector2i(cell + check[0] * (i + j))) if same: + return state return "" +func _sort_array(arr :Array) -> Array: + arr.sort_custom(func(a,b): return a < b) + return arr + +func _umrechnung(arr :Array) -> Array: + var newArr = [] + for i in range(1,arr.size()-1,1): + newArr.append(arr[i-1]-arr[i]) + return newArr + +#(-1, 0)_ (0,-1)| (-1,-1)\, (-1,1)/ +func _lol(arr :Array, shortArr :Array) -> Array: + var bedingung + var vektoren = [Vector2i(-1,0),Vector2i(0,-1), Vector2i(-1,-1), Vector2i(-1,1)] + var newArr = [] + for e in vektoren: + if arr.count(e) >= 2: + bedingung = e + for i in range(1,arr.size()+1,1): + if (shortArr[i-1] - shortArr[i]) == e: + newArr.append(shortArr[i-1]) + newArr.append(shortArr[i]) + return newArr + + + #Generiert die Zufallszahl von 1-6 func _roll_dice() -> int: schnickLost = false @@ -141,7 +181,7 @@ func _roll_dice() -> int: await get_tree().create_timer(0.25).timeout _update_dice_sprite(zahl) - print(zahl) #Debug ausgabe, später löschen + if zahl == 1: switch_to_schnick() @@ -172,8 +212,6 @@ func _on_dice_button_pressed(): move_allowed = true _roll_dice() - - #Sucht sich für die entsprechende Augenzahl #die X und Y-Koordinaten in der Tilemap func _update_dice_sprite(result :int): @@ -208,12 +246,10 @@ func _get_dice_pos_y(result: int) -> int: #Nach dem Glücksradereignis wird die Siegesbedingung auf 5 gewinnt geändert func _five_wins() -> void: - print("5 Gewinnt aktiv") #Debug sequence_needed = 5 #Nach dem Glücksradereignis tauschen die Spieler die Symbole func _change_symbols(): - print("tausch") #debug current_player = 1 - current_player nextPlayer.region_rect.position.x = current_player * 300 var tempX = player1Sprite.region_rect.position.x @@ -226,7 +262,6 @@ func _change_symbols(): #Nach dem Glücksradereignis gewinnt der Spieler sofort func _instant_win(): won = player_states[current_player] - print("Winner: ", won) wonPlayer.region_rect.position.x = player_states.find(won) * 300 wonPlayer.show() nextPlayer.hide() @@ -235,7 +270,6 @@ func _instant_win(): func _instant_loose(): current_player = 1 - current_player won = player_states[current_player] - print("Winner: ", won) wonPlayer.region_rect.position.x = player_states.find(won) * 300 wonPlayer.show() nextPlayer.hide() @@ -243,8 +277,7 @@ func _instant_loose(): #Zum Testen der Events func _on_test_pressed(): - var rand = randi() % 6 + 1 - _dead_zone(rand) + _spin_the_wheel(14) func _spin_the_wheel(result: int) -> void: