Skip to content

Commit

Permalink
Add comments and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Turtyo committed Apr 21, 2024
1 parent 04c01ee commit 98941b7
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 7 deletions.
3 changes: 3 additions & 0 deletions #Scenes/Events/skipEventButton.gd
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
extends Button
## Code for the button that allows the player to skip the event in placeholder scenes

## Enable / Disable the button based on the debug variable DEBUG_SKIP_EVENT
func _ready() -> void:
self.disabled = not DebugVar.DEBUG_SKIP_EVENT


## Activate the event ending function when the button is pressed
func _on_pressed() -> void:
PlayerManager.player_room.room_event.on_event_ended()
6 changes: 4 additions & 2 deletions #Scenes/SceneScripts/MainMenu.gd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extends Control
## Control the flow from the main menu



## What happens when the start button is pressed
func _on_start_pressed() -> void:
if not PlayerManager.is_player_initial_position_set:
SceneManager.goto_scene("res://#Scenes/MapUI.tscn")
Expand All @@ -10,9 +10,11 @@ func _on_start_pressed() -> void:
pass


## Scene to be loaded when option button is pressed
func _on_options_pressed() -> void:
SceneManager.goto_scene("res://#Scenes/OptionsMenu.tscn")


## Kill the game when the quit button is pressed
func _on_quit_pressed() -> void:
get_tree().quit()
1 change: 1 addition & 0 deletions #Scenes/mapReturnButton.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
extends Button
## Control the functions of the return button on the map scene.

## Disable the return button if the player is not in a room yet.
func _ready() -> void:
Expand Down
1 change: 1 addition & 0 deletions Global/DEBUG_VAR.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ extends Node
## Player can move freely on the map without having to finish the current event or move in the range of its normal movement
const DEBUG_FREE_MOVEMENT: bool = false

## Player can skip the placeholder events by pressing on the skip button
const DEBUG_SKIP_EVENT: bool = false
4 changes: 3 additions & 1 deletion Global/Global_Enums.gd
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ enum PossibleModifierNames {
}
# ! don't forget to update _ENTITY_STAT_DICT_SELECTOR in EntityStats.gd if you modify this

## All the possible types of events
## @experimental
enum EventType {
Random, # ! Random should always be the first element (see EventRandom)
Heal,
Mob,
Shop,
}
}
3 changes: 2 additions & 1 deletion Managers/EnemyManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extends Node
## Globally accessible for easy access to the enemies
## They are for now only accessible through the battler which is not very practical

## The list of enemies to spawn
@export var enemy_list: Array[Entity]:
set(list):
enemy_list = list
enemy_list = list
3 changes: 3 additions & 0 deletions Managers/PhaseManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ extends Node

signal on_game_start
signal on_phase_changed(new_phase: GlobalEnums.Phase, old_phase: GlobalEnums.Phase)
## When a player wins the event
signal on_event_win
## When the player is dead (reduced to 0 health)
signal on_defeat

var current_phase: GlobalEnums.Phase = GlobalEnums.Phase.NONE
Expand All @@ -32,6 +34,7 @@ func _start_game() -> void:
on_game_start.emit()


## Change phases in the game (mainly used in combat for now)
func set_phase(phase: GlobalEnums.Phase) -> void:
if (current_phase == phase):
return
Expand Down
2 changes: 2 additions & 0 deletions Managers/SceneManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,7 @@ func on_defeat() -> void:
# TODO show defeat screen
pass

## Finish the event [br]
## Give rewards, allow player to move on the map
func on_event_win() -> void:
PlayerManager.player_room.room_event.on_event_ended()
5 changes: 5 additions & 0 deletions Map/RoomUI.gd
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
extends Control
class_name RoomUI
## Holds the information about the visual of the room on the map display

## The actual room object
var room: RoomBase
## The text to display for the room
@export var label: Label
## The button linked to the room on the map
@export var button: TextureButton


Expand Down Expand Up @@ -33,6 +37,7 @@ func get_room_rect() -> Rect2:
func get_center_point() -> Vector2:
return Vector2(get_center_X(), get_center_Y())

## Change the player position to match the position of the room he is in, load the scene related to the room if [param switch_scene] is true
func _set_player_position_based_on_room(switch_scene: bool = true) -> void:
PlayerManager.player_position = room.room_position
SignalBus.clicked_next_room_on_map.emit(self, switch_scene)
Expand Down
2 changes: 2 additions & 0 deletions Tests/test_debug_var.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ extends GutTest
## Ensures that all the DEBUG variables (which let you do stuff you are not supposed to, for testing purposes) are set to false. [br]
## This prevents us from accidentally leaving them on and potentially building a release with them on.
func test_all_DEBUG_false() -> void:
# Get all the consts of DebugVar
# ! This supposes that all the DebugVar are constants, which they should be
var list_of_debug: Dictionary = DebugVar.get_script().get_script_constant_map()
print(list_of_debug)
for debug_var: bool in list_of_debug.values():
Expand Down
5 changes: 4 additions & 1 deletion UI/CardPileUISetter.gd
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
extends Node
class_name CardPileUISetter
## Controls what happens when clicking on a card pile
##
## Will load all the cards in the given pile and put them in a grid format

## Which scene to instantiate the grid in, this is important for positioning
@onready var parent: Control


@export var pile_count_label: Label = null
@onready var cardUI: PackedScene = preload("res://#Scenes/CardScrollUI.tscn")

Expand Down
3 changes: 3 additions & 0 deletions UI/DeckPileUISetter.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
extends CardPileUISetter
class_name DeckPileUISetter
## A type of card pile, used only for showing the complete deck of cards.

## The parent is different from the other card piles, since this particular card pile is part of an overlay [br]
## This means the scene it needs to be instantiated in is not the overlay directly (which would be the parent), but the scene that contains the overlay. [br]
func _ready() -> void:
super()
parent = $"../.."
Expand Down
1 change: 1 addition & 0 deletions UI/MapButton.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extends TextureButton

func _pressed() -> void:
assert(MapManager.is_map_initialized(), "Please instantiate map")
# The map is part of an overlay, meaning the actual scene in which to instantiate the map is the parent of the overlay
var parent: Control = $"../.."
var map: Control = map_scene.instantiate()

Expand Down
13 changes: 11 additions & 2 deletions UI/MapUI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,19 @@ func _ready() -> void:
# disable the button if the player can't access the room
texture_button.disabled = not (DebugVar.DEBUG_FREE_MOVEMENT or accessible_rooms_by_player.has(room))
room_display.room = room
# Show the player on map by checking the room he is in
if (PlayerManager.is_player_in_room(room)):
current_player_room = room_display
texture_button.disabled = true
texture_button.texture_disabled = room_with_player_texture
# Add a room as a child of room_addition_node
room_addition_node.add_child(room_display)
# Name to be shown on the map for the current room
room_display.set_label(room.get_room_abbreviation())
# Progress through the map by incrementing the position to show the next room
room_display.position = position_for_next_room
room_display.floor_index = floor_index
# Add the room to the array of rooms for the floor
room_ui_array[floor_index].append(room_display)
else:
room_ui_array[floor_index].append(null)
Expand Down Expand Up @@ -185,11 +190,15 @@ func _get_combined_room_width(texture_rect: TextureButton) -> float:
func get_combined_room_height(texture_rect: TextureButton) -> float:
return MapManager.map_width_array.size() * (texture_rect.get_size().y + _padding_offset) + _padding_offset

# Callback function for when a player selects a room
# If the room hasn't been lit when we navigate there, then set it to dimly lit
## Callback function for when a player selects a room
## If the room hasn't been lit when we navigate there, then set it to dimly lit
## Load the scene of the room that the player has selected
func _on_room_clicked(clicked_room: RoomUI, switch_scene: bool) -> void:
current_player_room = clicked_room
var room_event: EventBase = current_player_room.room.room_event
# TODO choose a proper way to select scenes
# * This might be done by adding a selection index to rooms that have events to load the specific event
# * This would need to be set when the map is first created probably, to ensure a proper distribution
var selected_scene_index: int = 0
if switch_scene:
SceneManager.goto_scene_map(room_event, selected_scene_index)
Expand Down

0 comments on commit 98941b7

Please sign in to comment.