Skip to content

Development tips

Robert Konigsberg edited this page Sep 15, 2021 · 4 revisions

Server debugging

Browser debugging

It's very useful to install the Vue Devtools extension. Check out the instructions, it's pretty easy to use, and instead of just fighting your way through the debugger, you can see each component on the page, their properties, and data. Really helps pinpoint problems.

Being a Database Superuser with the Local Filesystem Database.

When developing, sometimes you need to manually test a very specific case: maybe you need 2 titanium and Security Fleet in the play area, or you need to be the Helion corporation. Maybe you're testing a solo game, and want the game to last a few more generations. Or maybe you just want 100,000 MC.

Make a file named .env in the project's root directory (on the same level as src/, not in src/):

LOCAL_FS_DB=on

By setting this environment variable you're changing the data is stored locally. Instead of storing data in Sqlite, it uses a local filesystem.

So go start up a new game and get to the page where you select initial cards. If you're watching the log, the important thing is to see this line:

saving 830b6f5b289d at position 0

You'll get a different save id of course, but, copy that save id into the clipboard, because we're going to look for that game in the database.

$ cd ./db/files
$ $ ls *830b6f5b289d*
game-830b6f5b289d.json

OK, so, see, using the LOCAL_FS_DB environment variable, instead of having a Sqlite database, everything is a file. Use your favorite editor to view the file. It'll be big. But it's purely readable JSON.

$ vi game-830b6f5b289d.json 

The top of the file isn't very interesting, but scroll through -- it's everything about the game. And so, if you want to change anything about the game, you can just edit this file!

Want a bunch of megacredits? Find the players section and change the values you want!

  "players": [
    {
      "id": "83ad352ac531",
      "terraformRating": 14,
      "hasIncreasedTerraformRatingThisGeneration": false,
      "terraformRatingAtGenerationStart": 14,
#      "megaCredits": 0,
      "megaCredits": 10000,
      "megaCreditProduction": 0,
      "steel": 0,
      "steelProduction": 0,
      "titanium": 0,
      "titaniumProduction": 0,

(Look, you can't actually put a # in the file. JSON is pretty finicky.) But save the file, and then -- and this is important -- shut down the server and restart it. And finally refresh your game page.

That not enough? How about you give yourself another starting corporation?

"players": [
  "dealtCorporationCards": [
    "Helion",
    "United Nations Mars Initiative"
  ],
]

Becomes

"players": [
  "dealtCorporationCards": [
    "Helion",
    "United Nations Mars Initiative",
    "Phoblog"
  ],
]

Like I said, JSON is finicky - - you have to make sure that each line ends with a comma, EXCEPT the last line.

Anyway, you can do all kinds of things - change the cards you were dealt, or the cards in a player's hand, or who owns a tile. Just remember these three things:

  1. Find the game's file in ./db/files
  2. Edit the file, but remember that JSON is finicky.
  3. Always restart the server after a change, and then refresh the browser.

Undo without using the app

If you're using the text-based filesystem database, you also have an easy way to do undos or tell the difference between game versions. But it's very late, so I'll deal with it tomorrow.

Loading someone else's game for testing.