Well, yesterday I just played some more games through to the point I got bored or tired of micromanaging. Twice I had expansionist civs that got a free city or settler very early, and in both games China attacked it very early. In the second game I had a very high food start so I actually had four total cities when China attacked, and they walked all the way around my furthest-out one to get to the city from the hut-popped settler. Pretty sure that's a coincidence, but odd that it happened more or less back-to-back.
But this is the wrong category for that. This morning I did find the difficulty setting. It's not quite where my interpretation of Antal1987's dumps said it was, but it was close, and this is the GQL query:
Code:
{
difficulty: int32s(section: "GAME", nth: 2, offset: 20, count: 1)
}
The "difficulty:" part of that query is an alias which will come in handy. Instead of coding all the queries in friendly queries I can use aliases that self-document what I'm fetching and not have to change the parsing code. It also allows me to get multiple "int32s()" results in one query.
Anyway, 0 is Chieftan, 1 is Warlord, etc., etc.. In the default game, anyway. I suspect (but am not sure) that the difficulty names are stored in the BIQ, so to do it properly I think I'd have to reference the embedded BIQ if present or read the default BIQ which in theory could be replaced by a user who wants their default epic game rules modified. For now I'll just assume the default game but try to allow for being able to do it "properly" in the future.
---
As far as UI, I briefly checked into polyfills, but IE11 has the additional problem of not supporting the newer versions of Javascript, so I'd have to polyfill *and* transpile. Naw, I'll wait a few months for the new webview to be completed. I briefly tried the new version of webview, but it didn't work.
...
or did I? I just realized while typing this that ... well, something something Go modules, and I may not have been using the version of webview I thought I was. Now I'll need to go try again. Explanation in the spoiler.
---
Uh, what else? I'm having an itch for batch operations. For example, run through all the sav files in a folder and query each one. That would be great for helping to decode sav files.
I think my next step is to refactor the polling and query code to be more generic, so each UI page can define a query and how to interpret the data, and the same JS code works for each page.
Also, I need a hexdump page. I have the hexDump query defined, but it doesn't line up well when viewed in the JSON reply.
---
This past week or two is the first time I've really used the GraphQL code I made a year or two ago. It really makes it easier to poke around at the sav file data!
---
Oh, and even though I've punted on trying to "natively" read the file into data structures, I find myself analyzing the bigger structure of the data. My current belief is that there is a container object/class, and a BIQ child and a game-data child, and that's the whole structure. The BIQ may or may not be present in the sav depending on if it's default or custom.
What this means for my purposes is that I'm pretty sure all the counts for sections (city counts, colony counts, leader counts, etc.) are going to be in what I call the 2nd GAME section. Antal1987's data dumps seem to agree.
My biggest problem in parsing the sav before was unexpected things popping up like CLNY (colonies). And also the CITY entries were not shaped consistently. But I think the total city count must be in the 2nd GAME section, and so the internal structure for each CITY is likely early in that section.
Those thoughts combined with the GraphQL query abilities and some of these batch ideas I have give me hope to figure out a few things I couldn't before.
---
Edit: I'm really starting to think I need to explicitly separate BIQ from per-game data in the queries. Yeah...maybe have three root queries:
- Query entire file
- Query BIQ
- Query game
And the default BIQ can be parsed if a custom one isn't. This idea formed while being concerned about e.g. finding the first TILE of the game map and having to first detect if a BIQ with a custom map is present. But if I give the option of querying the BIQ vs the game then I only have to solve the problem once and not in the query language.