Prototype icon indicating copy to clipboard operation
Prototype copied to clipboard

Add the worker action for irrigation

Open TomWerner opened this issue 11 months ago • 5 comments

Like #493, we should support irrigating tiles, and loading save files that have irrigation.

TomWerner avatar Jan 18 '25 17:01 TomWerner

@TomWerner I see the basic irrigation action is done already, correct? But the multi Turn part is missing. Do you minbd if I try my hand at this?

KulkoBSW avatar Feb 09 '25 11:02 KulkoBSW

Please do!

A couple of pointers:

  • This doc has some notes about how stacks of workers operate
  • Tfrm.cs has the worker move costs. I'm guessing the Required field in that struct is an index into the list of techs, but I don't know for sure. I'm also not sure what the Order string is there. Any easy way to printf debug this kind of thing is with Console.WriteLog statements and then running the unit tests, which loads a standard game and some scenarios. To see the logs you'll want dotnet test -v n.
  • Unit.cs in the sav section has information about active worker jobs and based on this forum post this unknown buffer might be the worker speed (native vs captured worker).

TomWerner avatar Feb 09 '25 14:02 TomWerner

@TomWerner I have about good practices that came up while using the terraform data.

I would like to change the WorkerJob attribute directly to a reference of a Terraform object. This would make all of the corresponding functions much easier to write and faster to run. However it means that at some points I need to switch from the order to the Terraform by finding the correct terraform with a linq query.

The first spot is the irrigate function. This function gets called by message and currently has no references to the gamedata. Here I wonder if it is allowed/possible to send the list of terraforms with the ActionToEngineMsg function? Or if it is okay, to calculate the cirrect Terraform berforehand and then call the ActionToEngineMsg with that terraform as a parameter.

The second spot is when mapping old save data to our format. If I understand it correctly we are using the old formats readOnly, meaning, after creating the game from them we only use our own save format to save the game afterwards, so I would not need a function which converts terraforms back into numbers, correct? but for the convertion when reading the current worker jobs of units I would at this time only need an attribute in the terraform which shows that number. Now I feel bad about adding an attribute that get never used at any later point in time. Any suggestion on how this could best be handled. (PS The solution in the current code is that horrible hardcoding that should surely not be used anymore.)

Thanks for any Pointers and If you would rather see the copmplete code first, I can also provide a draft pull request with one of the options.

KulkoBSW avatar Mar 04 '25 06:03 KulkoBSW

This function gets called by message and currently has no references to the gamedata

Within the process function of a MessageToEngine subclass it's totally ok to access the game data via EngineStorage.gameData, like we do here: https://github.com/C7-Game/Prototype/blob/e14a7a8e54c4aac794478427c93b0ca46ee1cce1/C7Engine/EntryPoints/MessageToEngine.cs#L57

If I understand it correctly we are using the old formats readOnly, meaning, after creating the game from them we only use our own save format to save the game afterwards, so I would not need a function which converts terraforms back into numbers, correct?

Correct.

but for the convertion when reading the current worker jobs of units I would at this time only need an attribute in the terraform which shows that number. Now I feel bad about adding an attribute that get never used at any later point in time. Any suggestion on how this could best be handled. (PS The solution in the current code is that horrible hardcoding that should surely not be used anymore.)

Within ImportCiv3.cs I would feel comfortable indexing into the imported list of terraform objects by the worker job index in the sav file.

So something like save.Terraforms[savObj.workerJobIndex] (variable names made up).

TomWerner avatar Mar 04 '25 15:03 TomWerner

Open Todos

  • Check for blocking between WorkerJobs
  • Choose the correct animation (currently everybody is irrigating) (DONE)
  • Implement the generic version for saving and loading (DONE)
  • Find out how to best test the WorkerAI (DONE)
  • The Tooltext is still missing (DONE)
  • Fix MultiworkerJobs, to finish all workers at once, [OUT OF SCOPE]

KulkoBSW avatar Mar 06 '25 03:03 KulkoBSW