-
Notifications
You must be signed in to change notification settings - Fork 21
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
Conversation
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice!
C7GameData/Building.cs
Outdated
public class Building : IProducible { | ||
public string name { get; set; } | ||
public int shieldCost { get; set; } | ||
public int populationCost { get; set; } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
I'll get #548 merged, I fixed the goofy test issue there. |
"buildings": [ | ||
{ | ||
"name": "Palace", | ||
"shieldCost": 100, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
C7/Text/c7-static-map-save.json
Outdated
@@ -64533,87 +64950,5 @@ | |||
"tech-44" | |||
] | |||
} | |||
], | |||
"citizenTypes": [ |
There was a problem hiding this comment.
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?
C7GameData/ImportCiv3.cs
Outdated
PRTO[] unitPrototypes = biq.Prto ?? defaultBiq.Prto; | ||
|
||
return city.ConstructingType switch { | ||
0 => ("Warrior", ProducibleType.UNIT), // TODO: Wealth production is not implemented yet |
There was a problem hiding this comment.
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
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.