diff --git a/TODO.md b/TODO.md index b7f45ab..23dbc87 100644 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,3 @@ -1. Power ups - * spawn a new random piece powerup 2. Visual polish * a visual / title in the left sidebar * multiple square tiles to add variation diff --git a/src/Game.gd b/src/Game.gd index e8c5fe2..4f037d5 100644 --- a/src/Game.gd +++ b/src/Game.gd @@ -261,7 +261,7 @@ func _ready(): get_node("/root/Game/EndMenu/VBoxContainer/Fail Game").connect("pressed", self, "_on_fail_game") get_node("/root/Game/EndMenu/VBoxContainer/Win Game").connect("pressed", self, "_on_win_game") get_node("/root/Game/PanelRight/VBox/PieceInfo").connect("stat_change_requested", self, "_on_piece_stat_change_requested") - get_node("/root/Game/PanelRight/VBox/PieceInfo/Vbox/Powerup").connect("pressed", self, "try_spawn_powerup") + get_node("/root/Game/PanelRight/VBox/PieceInfo/Vbox/Powerup").connect("pressed", self, "try_spawn_powerup", [true]) reset_game_state() func _on_piece_stat_change_requested(piece, attribute, value): @@ -271,7 +271,7 @@ func _on_piece_stat_change_requested(piece, attribute, value): func _input(ev): if Input.is_action_just_pressed("ui_cancel"): - print(ev) + #print(ev) self._on_escape(false, "Paused") func _on_escape(force_visible = false, message = null): @@ -297,7 +297,8 @@ func reset_game_state(): self.turn = 0 for p in get_tree().get_nodes_in_group("pieces"): p.queue_free() - + for p in get_tree().get_nodes_in_group("powerup"): + p.queue_free() self.board_squares = {} var x = 0; var y = 0; @@ -452,7 +453,7 @@ func _on_new_turn(): if self.reinforcements == null and not just_spawned: var chance = lerp(0, 50, 1 - float(opponent_pieces.size())/16.0) var i = self.rng.randi() % 100 - print("Roll for reinforcements ", i, " < ", chance) + #print("Roll for reinforcements ", i, " < ", chance) if i < chance: self.reinforcements = 2 self.reinforcements_size = 1 @@ -555,6 +556,9 @@ func _process(delta): for m in moves: if m.has("target"): priority_moves.append(m) + continue + if self.board_squares[m['pos']]['powerup'] != null: + priority_moves.append(m) if not priority_moves.empty(): # @TODO Check for the most "valuable" piece to take var i = self.rng.randi() % (priority_moves.size()) @@ -585,7 +589,7 @@ func _physics_process(delta): var s = null for m in matches: if m["collider"].get_parent() is Square: - print(m["collider"].get_parent()) + #print(m["collider"].get_parent()) s = m["collider"].get_parent() if s == null: # No valid position, we'll return the piece to where it should be @@ -599,7 +603,7 @@ func _physics_process(delta): if pf.squares[k].get_ref() == s: dest = k if dest != null: - print(dest) + #print(dest) var dest_valid = false; for m in moves: if m['pos'] == dest: @@ -708,8 +712,7 @@ var available_powerups = { # @TODO remove attack_only from pawn # @TODO choose a new movement pattern } -func try_spawn_powerup(): - print('blah') +func try_spawn_powerup(var force = false): var try = 0 var i = null var sq = null @@ -724,7 +727,8 @@ func try_spawn_powerup(): return i = null var c = self.rng.randi() % 100 - print("Chance: ", c) + if force: + c = self.rng.randi() % 46 + 55 for k in self.available_powerups.keys(): if c >= k: i = k @@ -751,13 +755,36 @@ func try_spawn_powerup(): func apply_powerup_to_piece(square): print("Applying powerup ", square['powerup'], " to piece ", square['piece']) # @TODO Play a sound - if square['powerup'].target_attribute == "special": - print("Special powerups not implemented yet") + var powerup = square['powerup'] + if powerup.target_attribute == "special": + if powerup.target_value == "spawn_unit": + var for_opponent = true + var group = "opponent" + if square['piece'].is_in_group("player"): + for_opponent = false + group = "player" + var coords = choose_reinforcements(1, for_opponent, false) + for c in coords: + square = self.board_squares[c] + new_piece(square['reinforcement'], group, c) + square = self.board_squares[c] + if self.reinforcement_buff != null: + square['piece'].damage += self.reinforcement_buff + square['piece'].movement += self.reinforcement_buff + square['piece'].health += self.reinforcement_buff + if self.reinforcement_buff > 5: + square['piece'].jump = true + else: + print("Unknown special powerup: ", powerup.target_value) else: - if square['powerup'].target_value == "increase": - var value = square['piece'].get(square['powerup'].target_attribute) + 1 - square['piece'].set(square['powerup'].target_attribute, value) + if powerup.target_value == "increase": + var value = square['piece'].get(powerup.target_attribute) + 1 + square['piece'].set(powerup.target_attribute, value) + elif powerup.target_value == "set_true": + square['piece'].set(powerup.target_attribute, true) + else: + print("Unknown value type: ", powerup.target_value) if square['piece'] == self.selected_piece: get_node("/root/Game/PanelRight/VBox/PieceInfo").set_piece_info(square['piece']) - square['powerup'].queue_free() + powerup.queue_free() square['powerup'] = null