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
Moving game data definitons to data files #666
Comments
As the most recent comment says, JSON is widely used for that purpose. (Cata:DDA is indeed a great example) |
For idea how game data in JSON would look like, here is a sample of de-hardcoding [
{
"kind": "TRADE_EMBARGO_REALM_CHOICE",
"texts": []
},
{
"kind": "BORDER_WARS",
"texts": [
"Yarr, scurvy fleet %1$s spotted. Time to die!"
]
},
{
"kind": "ASK_PROTECTION",
"texts": [
"Are you interested in insurance? That's against pirates!",
"Ohoy, looks like you have nice fleet here. Not to lose it will cost for you.",
"Yarr! It would be a shame to scratch your fleet, but that can be avoid by paying this."
]
}
] I believe the sample is quite obvious, but here is explanation anyway:
I made a functional prototype of this. It works nicely and although it might look better, I think it serves it's purpose well. The I think that de-harcoding data to any common, flexible data format is a plus, because the data then can be easily transformed, edited and/or visualized using conventional tools. It is much easier to migrate data to other scheme or format, if it is actual data and not Java source file. If the need for different form of data arises, both in terms of object attributes/composition and stored representation, such conversion can be done way easier than now. (And it would prevent such "bugs" of including generated fields or the like, like mentioned above 🙂 ) |
I think there should be an issue for each data definition and first needs to define how to store data in JSON. For example in speech there could root level Speech, under it each space race and under each spacerace the actual lines. And yes I like that variation. So obvious ones are factories: ShipHullFactory, ShipComponentFactory, ArtifactFactory, TechFactory, BuildingFactory I would not try convert all of these at same time, since it would cause massive amount of testing. Plus I am also working with new ascension victory where I need to touch a bit there and here in code. I have been rebasing quite often so I am still good. |
That is not a good idea. And not just that! There could be even more SpeechSets for a single SpaceRace and the code could choose which one to use based on other conditions, like I would submit a PR with these changes. As you did not gave me a green light to use external JSON library, I am not submitting it AS-IS. (I did not had the time to rewrite it to use the in-house JSON parser).
The However, of the factories you mentioned, I want to kill two birds with one stone. Not just to de-hardcode data. I want the game to be (optionally) modular, which calls for redesign of internal code. Such changes would massively increase potential content of gameplays. And as a player, I want that a lot. ❤️ And as programmer, it makes things way more easier to work with. Component, data-driven designs are way more superior for game development, exactly due to the combination possibilities it can provide. Also it is the reason why I submitted all the refactors so far. I need code that can be safely refactored and easily understood. Currently, that's not the case. And to clarify my intents, any redesign I speak about is on internal, code level. I am trying to keep the gameplay exactly the same, without breaking or removing anything. Which is hard 🙁
Yes, I am aware of this. I hope you will finalize it soon 🤞 , since there are many changes needed to be able to close this issue 🙃 . Also, I highly recommend postpone all new features for the game "indefinitely" (bad name for a milestone, I know 🙂 ). Each game "subsystem" that will get cleaned-up and dehardcoded before adding new feature will mean less work overall. And as this project does not have deadlines or dependents, the need for new features is mostly driven by you yourself 😉 |
I am actually thinking that if 0.25.0 release should be done without Ascension victory. Current version has highly improved map drawing which increases performance on lower pcs plus other improvements. Then there would be just testing that all the features work. After this internal redesign could be started more safely. Also that new JSON-in-Java could be bring in. These redesign could be started on separate branch and later merge that to master. Yes, I agree your plan sounds really good. |
Then all the better. 👍 Any feature that does not exist in the code is one less thing to worry about and/or break during redesign/refactor. 🚀
I highly recommend keeping the redesign/refactor work on
Anyway, should I wait for you releasing 0.25.0 before submitting further cleanup PRs? I have two more that I can submit, if you want to add them to 0.25.0, although I think it does not worth it now. I would suggest that you focus on getting the release out of the door, while I will continue experimenting with new designs locally. And after the release some serious cleanup/refactor/redesign can begin! 😁 |
Redesign/refactor is easier on I check all the current issues which are open there are still two perks missing, but these could be also moved to 0.26.0 and then there is the feature you suggested that governor should not choose for next building project. After this there is testing left. I would like to play at least one full game, and hopefully it can played without no issues. If that's the case I think next release can be done. I think maybe it is better to wait for cleanup PRs, less things to test and go wrong... |
Fixes JUnits and old BuildingFactory could use case insensetive names on buildings. Now all techs and building names need to match. testResearchWiki() JUnit should reveal this.
Lot's of data moved into JSON. Closing. |
Continuation of discussion from #665 about de-hardcoding game data into data files.
TLDR:
The text was updated successfully, but these errors were encountered: