Files
Kalulu/resources/user/user_difficulty.gd
T
2024-06-11 12:00:20 +02:00

24 lines
787 B
GDScript

extends Resource
class_name UserDifficulty
signal difficulty_changed()
# Stores the user history for all the minigames
# Key -> minigame_name : String
# Value -> UserMinigameHistory
@export
var minigames_histories: Dictionary = {}
# Gets the difficulty of the user for the given minigame
func get_difficulty(minigame_name: String) -> int:
return minigames_histories.get(minigame_name, UserMinigameHistory.new()).difficulty
# Adds a game to the minigame history of the user and update difficulty if needed
func add_game(minigame_name: String, minigame_won: bool) -> void:
var history : UserMinigameHistory = minigames_histories.get(minigame_name, UserMinigameHistory.new())
history.add_game(minigame_won)
minigames_histories[minigame_name] = history
difficulty_changed.emit()