Final Motion Component - Development Log #434

In this week's devlog Michi explains why implementing the last missing motion component was a bit more complicated than it seems at first glance.

Avatar Michi

Michi (molp)

Following up on last week's devlog #433: I created the motion component to start workforce programs, but wasn't able to finish the server side of it. This has to do with how the workforce programs work. Today I want to shed some light on the inner workings of that game mechanic.

You might be familiar with the "programs" tab in the LR (local rules) command of a planet:

workforce programs

As a regular user of that command you'll be able to see active program and the upcoming program, if there are any. If the player is the governor of the planet the upcoming program section (if there is none yet) is replaced with the workforce program selection and an action button to add the selected program to the list.

It is a very direct mechanic: The governor selects the program and hits the button. If there is no issue, the selected program is either activated directly or scheduled for the next week and the costs deducted from the governors account.

The server side is more involved though: The action arrives at the company actor and that actor checks if the sender is actually the governor. It then retrieves the currently used currency from the planet. Then the current population size is requested from the planet. This data is used to validate the cost of the program, since most programs have a base price and a variable factor based on the population size. Once all this is verified the company tells the administration center about the new program. The admin center adds it to its lists and the notifies the population actor, so it can execute the program with the next population report. As you can see, it requires quite a bit of communication between the different actors.

When switching over from the direct interaction with the workforce programs to motion, I ran into problems. Let's consider the motion goes through. What happens if the government doesn't have the necessary funds to start the project? What happens if we already have an active and upcoming program? Should the motion just be without effect? How would the members of parliament know?

To fix this, we decided that the motion should, instead of directly starting the program, create a contract between the government and the faction that has two conditions: one for the payment and one to start the workforce program. That way if there is a problem, like lacking funds, the member of parliament that hits the fulfill button on the payment condition will get immediate feedback with a proper error message. Same goes for the start of the workforce program. The contract makes the whole interaction more indirect, but also solves the problems I mentioned, without us rewriting the entire workforce program code.

The workforce programs have been the last motion component that lacked implementation and I will now focus on the next missing topics, like parliament size.

As always: we'd love to hear what you think: join us on Discord or the forums!

Happy trading!