What is the best way to track Summary?

What’s the best and optimized way to track summary (for example kills) and be able to show it later like this:


In the screenshot theres 3 parts to the game. Im going to call each part a “chapter”

each chapter looks something like

type Chapter = {
  name : string,
  difficulty : string,
  events = {Event},
}

so the first one would be {name = "Familiar Ruins, difficulty = "Insane"} with its events

Each event is something like

type Event = {
  display : string,
  value : any,
  update : (self : Event, ...) -> (),
}

so the button event could be something like

ButtonEvent = {
  display = "",
  value = 0,
  update = function(self)
    self.value += 1
    self.display = `Pressed {self.value} buttons`
  end
}

Then somewhere else you can use this module and call a function like
GameSummary.logEvent("buttonEvent")

at the end of the game you just display the .display properties of all the events for each chapter

and you would need some more functionality to reset everything when the game is over, if you want to have multiple games