Skip to content

Commit

Permalink
wip: logging puzzle stats in the main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
russmatney committed Feb 23, 2024
1 parent 65ed077 commit af42c0d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/PuzzleSet.gd
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,15 @@ var analyzed_game_def: GameDef

# returns a cached game_def, or parses a new one
func get_game_def():
# TODO enrich game_def puzzle_defs with complete/incomplete flags and other player stats

if analyzed_game_def != null:
return analyzed_game_def
if game_def != null:
return game_def

game_def = Puzz.parse_game_def(get_puzzle_script_path())

return game_def

func get_puzzles():
Expand Down
21 changes: 21 additions & 0 deletions src/menus/MainMenu.gd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@tool
extends CanvasLayer

@onready var start_button = $%StartButton
Expand All @@ -20,3 +21,23 @@ func _ready():
options_button.pressed.connect(func(): Navi.nav_to(options_menu))
credits_button.pressed.connect(func(): Navi.nav_to(credits_menu))
quit_button.pressed.connect(func(): get_tree().quit())

var puzzles_completed = 0
var puzzles_available = 0
for ps in Store.get_puzzle_sets():
Log.pr("is ps completed?", ps)
for p in ps.get_puzzles():
# TODO check the puzzle, not the puzzle set
if ps.is_completed():
Log.pr("is p completed?", p)
puzzles_completed += 1
if ps.is_unlocked():
puzzles_available += 1

Log.pr("Puzzle stats!", {
events=len(Store.get_events()),
puzzle_sets=len(Store.get_puzzle_sets()),
puzzles_completed=puzzles_completed,
puzzles_available=puzzles_available,
themes=len(Store.get_themes()),
})

0 comments on commit af42c0d

Please sign in to comment.