tresinformal / drakkar

The tresinformal video game called 'Drakkar'
GNU General Public License v3.0
11 stars 4 forks source link

Save the game state #478

Open richelbilderbeek opened 2 years ago

richelbilderbeek commented 2 years ago

Depends on:

It is important to be able to save the game state, for example, in bug reports or maybe in testing, where we can load a game state.

richelbilderbeek commented 2 years ago

Make this test come true:

  #ifdef FIX_ISSUE_478
  // Saving a game and loading it, must result in the same game
  {
    const game g;
    const std::string filename = "test.txt";
    save(g, filename); // To prevent a bloated/Winnebago class
    const game h = load(filename);
    assert(g == h);
  }
  #endif // FIX_ISSUE_478
swom commented 2 years ago

@richelbilderbeek I think writing by hand all input and output operators is going to be quite tedious and could anyway lead to brittle architecture. What about using the json library I use in my more recent projects with just one template save and load function?

richelbilderbeek commented 1 year ago

Hi @swom, I am quite late with responding I see. Sorry for having gotten too sloppy :-) .

I would argue against using another library, as this demands an action of the whole team. If we get it 'for free' using CMake, then I'd definitely be up for it! Till then, a simple CSV would suffice.