Hi dear readers!
This is the second entry in my blog about the game I'm working on. Let's look into what was added/changed in the past two weeks.
The first thing I added was more cities. This was quite trivial after I did the basic historical research.
The second one was adding city populations. I wanted to control how many units can players recruit and the best thing to do that was capping it by population.
These were the plans for population originally:
"Represents the population of the city. It is controlled by the birth rate and death rate mechanics.
Initially,each settlement has a higher birth rate than the death rate,but this can be influenced by squalor and diseases.
If squalor is low then the birth rate increases, if it is high, then the birth rate decreases. When there is a disease outbreak, the death rate grows significantly.
Population is required to raise armies/units and providesone gold income for each population once each real-life day."
I added both the death rate and the birth rate mechanisms. Based on historical sources, the birth rate was 40 people per 1000 people per year. The death rate was 38, but I set it to 30 instead to give way to wars (that should ideally contribute an extra 8 persons 🤔).
Also, each person gives 1 gold on every real-life day so people will think twice about raising armies (which might provide plenty of income in case of a victory, but not much if the armies stand around doing nothing or even worse keep losing).
Gold was the first resource I had to add, so I needed to create a "resource system" as well, which is at the moment just linking the resources to the nations in the game. Each nation has a field for each resource and when the game refreshes, the nation's money is recalculated based on the population (added together) the nation has.
I added districts as well with the base of buildings:
Building a district costs 500 gold and takes 8 real-life hours.
There are five districts in the game: Industrial, Military, Cultural (incl. Religious), Entertainment, and Agricultural.
Villages can have two districts, small cities can have three, large cities can have four and metropolises can have five (city level is based on population).
I also had to add an event system to support the building times. The application updates every game once every 30 seconds.
This was the time I decided that enough is enough! Saving everything to the database as it should be expected to be in a relation-based DB was very cumbersome. I decided that it would be better if I saved the whole game state (except a few variables) as JSON. This makes the saving/loading a lot easier and I wouldn't search for games based on the game state anyway.
Now, the game table looks like this:
<changeSet id="2" author="laxika">
<createTable tableName="game">
<column name="id" type="bigint" autoIncrement="true">
<constraints primaryKey="true"/>
</column>
<column name="status" type="varchar(16)"/>
<column name="gameState" type="json"/>
</createTable>
<createIndex indexName="ix_status" tableName="game">
<column name="status"/>
</createIndex>
</changeSet>
The settlement, nation, and district tables are no longer there. I synchronize on the game instance every time I change something (to make changes atomic) and save the game data every 10 turns (5 minutes).
Also, there were some UI changes as well, but the design is still very wireframe-like 🙂.
Top comments (0)