Gaming is good for the brain: Python resolution to a problem

Playing my favorite game, Forge Of Empires (shortly FoE) recently I stuck to a problem.

For those of you who haven't heard of this awesome web2 online game its levels are called "Eras", starting from "Stone Age" with a small city and up to the highest era for 2023 and 2024, called "Space Age Titan".

With each new era, a certain free extensions are available to expand your city and a certain limited number of paid, with diamonds, that's the money equivalent of the game. So with each new era, the cities become bigger and bigger.

Some of the buildings have the feature to be upgraded to the latest era via a "Renovation Kit" or upgraded one era up via a "One Up Kit".

So here is the game problem I stumbled upon. I reached a moment when all my upgradable buildings are already maxed. So I don't need any more Reno kits as far as I have enough One Up kits to upgrade all my buildings once a new era is opened by the game developers. So, how do I count all my upgradable buildings. I wouldn't do that manually as here is how my city looks at the moment:

Those are hundreds of buildings and some of them are quite small, taking 1 square (the city space unit).
The game itself doesn't provide that info.

There is a wonderful browser addon, called FoE Helper, developed by a talented German developer.

It has a map feature:

Unfortunately it doesn't show the building counts, but the squares taken instead, so, not useful enough in my case.
However, it has a "Copy city data" button that copies, in my case, a huge 16 MB JSON file in the clipboard.

Pasted inside Visual Studio Code, originally it looks like this:

Not quite human-readable but the Outline VSC windows helps a bit to explore its content and figure out I should be querying the "CityMapData" block elements for certain "type" attributes:

After a short research a came to this popular query language for JSON data, called JMESPath:

I spent some time learning it and it is a great language, something like Regular Expressions for JSON but I soon realized it would take me more time to learn it than manually counting all the buildings, LOL.

So here Python came to help. Shortly I came up with this neat script :)

Now I have a quick script that prints for me a Python Set with all the counts of the types of buildings in my city and the total number of One Up Kits needed.

I guess I can sell all my Renovation Kits now at the Antiques Dealer as I currently have about 300 One Up Kits but as my city produces 2-3 of them each day, I feel I am pretty much covered as there aren't any news about a new era yet.

So from now on, when I reconstruct the city, I just have to copy my city data and save the json file and just re-execute the script to get the updated total needed. Easy-peasy...

To those of you who play FoE:

Happy Forging!

Posted Using InLeo Alpha



0
0
0.000
11 comments
avatar
(Edited)

I played this game, but I stopped when some of my progress was reverted.

0
0
0.000
avatar

Now that is really strange. I am not sure I've ever heard of anything similar. On which server did you play? What era were you in?

0
0
0.000
avatar
(Edited)

If I remember it right the server is Korch. My last login my account got reverted to the Stone Age era.

0
0
0.000
avatar

That's really strange, I'll have to ask around and come back if something comes out.
I think I heard about a player who had multiple accounts but it was just levels removed from his Great Buildings and not any reversion.

0
0
0.000
avatar

Yes, strange, but I am thinking, could it be that the world I am playing in is removed? It made me think that way because when I came back after a long hiatus the "these are the world you've already played in" is blank.

image.png

0
0
0.000
avatar

Korch is active, I could tell that by the orange world selection button. So it's definitely there.
Which server is that? Korch world exists on many of them, if not all. ;)

0
0
0.000
avatar

It was blank when I returned after a long hiatus, it didn't offer what server I last played.

0
0
0.000
avatar

1


This post has been selected for upvote from our token accounts by @lightcaptured! Based on your tags you received upvotes from the following account(s):

- @dhedge.bonus
- @dhedge.leo
- @dhedge.pob
- @dhedge.cent
- @dhedge.neoxag
- @dhedge.waiv
- @dhedge.alive

@lightcaptured has 7 vote calls left today.

Hold 10 or more DHEDGE to unlock daily dividends. Hold 100 or more DHEDGE to unlock thread votes. Calling in our curation accounts currently has a minimum holding requirement of 100 DHEDGE. The more DHEDGE you hold, the higher upvote you can call in. Buy DHEDGE on Tribaldex or earn some daily by joining one of our many delegation pools at app.dhedge.cc.

0
0
0.000