Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load basic building data #557

Merged
merged 9 commits into from
Feb 16, 2025
Merged

Load basic building data #557

merged 9 commits into from
Feb 16, 2025

Conversation

esbudylin
Copy link
Contributor

This commit implements loading basic building data from save and scenario files. It loads the list of possible buildings; however, loading data on already existing buildings is not yet implemented.

Additionally, this commit implements loading of the currently produced units and buildings from save files.

Next, I intend to work on loading existing buildings and adding logic for creating new ones.

This commit implements loading basic building data from save and
scenario files. It loads the list of possible buildings; however,
loading data on already existing buildings is not yet implemented.

Additionally, this commit implements loading of the currently produced
units and buildings from save files.
Copy link
Contributor

@TomWerner TomWerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice!

public class Building : IProducible {
public string name { get; set; }
public int shieldCost { get; set; }
public int populationCost { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you leave a comment explaining what population cost is for buildings?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see you left a comment in ImportCiv3.cs - could you add that here too? Is it possible to mark this as const with a value of 0 to make it clearer this is to just satisfy the interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think an interface member can be declared as a constant. In general, I think the purpose of this interface is to allow buildings to have a population cost in modded rule sets, so I don't think this field needs to be restricted. I added a comment to clarify a situation with Civ3 rules.

@@ -189,6 +190,7 @@ public GameData ToGameData() {
public List<Resource> Resources = new List<Resource>();
public List<SaveUnit> Units = new List<SaveUnit>();
public List<UnitPrototype> UnitPrototypes = new List<UnitPrototype>();
public List<Building> Buildings = new();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you run the tests locally then in C7GameDataTests/data/output/gotm_save_0.json you should be able to grab the list of buildings from the base game rules. Could you copy paste those into c7-static-map-save.json?

Copy link
Contributor Author

@esbudylin esbudylin Feb 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer! I've added the building data to the save.

Previously, the test saved the sample save in data/ directory but then
tried to look for in data/saves directory.
@TomWerner
Copy link
Contributor

I'll get #548 merged, I fixed the goofy test issue there.

"buildings": [
{
"name": "Palace",
"shieldCost": 100,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR, but we'll need to figure out how this works, because the palace cost increases over time or per city, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a write-up on the palace cost on Civfanatics https://forums.civfanatics.com/threads/cost-of-the-palace-for-c3c.107789/ It looks like the the palace cost depends on the number of cities.

@@ -64533,87 +64950,5 @@
"tech-44"
]
}
],
"citizenTypes": [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like these got lost in a merge, could you restore them?

PRTO[] unitPrototypes = biq.Prto ?? defaultBiq.Prto;

return city.ConstructingType switch {
0 => ("Warrior", ProducibleType.UNIT), // TODO: Wealth production is not implemented yet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make this "Worker"? Warriors aren't always producible

@esbudylin esbudylin merged commit 81f4c4c into Development Feb 16, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants