Comments (5)
Spork bonus ship could be removed, since all those spaceraces require new balancing any way.
That image alignment and ship images could be just pointer to another object/class in SpaceRace class eventually.
from open-realms-of-stars.
There was at least one case where pseudo-race's ID in
createOne()
method was wrongly written. I suggest to create a static constant and use it instead of writing it each time. Also, using theOptional<>
orcreateOr()
methods can help to detect such cases, as it forces programmer to explicitly say, what to do in case that value is absent, possibly throwing an error when something goes awry. (I found it. It is in Diplomacy.java, textSpaceRaceFactory.createOne("SPACE_PIRATES"));
It is possible there are other such cases.)
Good catch, I had these bunch of place with _. Using static would be much bettter.
Regarding design, if you plan to ever introduce "races created at runtime" (procedurally-generated or similar), the
SpaceRaceFactory
class usage and code will likely have to be revised dramatically. This is because of the (dreaded) global state. It is still very "enumish" and thus not suitable for such design - in case ofRaceTraits
,Buildings
, "Bridge Graphics", etc. global state is not such a deal-breaker, as those objects are likely to be predefined before program launch (by programmer/modder) and work as available "blocks to build from". Races are more a thing that "can be built from the available blocks" at runtime (think like Planets vs. Buildings - Buildings are predefined in data files, their individual "setup" on a Planet is not).
My idea was to add space race editor directly into main menu. When player click load game or new game then SpaceRaces would reinitialized. Currently there is no way to do, but it should be just static method that calls singletons init() method.
In actual editor there should be warning if space race is deleted that old save files might not fuction anymore.
So technically, the
SpaceRaceFactory
now works as a "race preset loader". And by quick glance, a whole lot of code is still designed to treatSpaceRace
s as "globally available information" rather than "ad-hoc data". Usage of thecreateOne()
method of the factory can help to find such cases. Removing the global-state ofSpaceRace
data will also likely include things like saving race data to save files or something. But sinceSpaceRace
is normal class with normal objects now, potential removal of the global state is at least conceivable. 😄And if you do not plan to add "races made at runtime", and leave this to "modding" only, then everything's great!
That editor from main menu is a bit like tool for modding. Just easier UI than opening JSON editor.
In any case, the removal of the
SpaceRace
enum
is still a major step forward. 👍
Yes, I agree.
from open-realms-of-stars.
@tuomount I suggest you look into the StarMap
-related stuff. The file is hard to navigate and refactor for me (it is over 4500 lines of code, with many responsibilities).
Additionally, it might worth splitting StarMap.java
, moving map generation elsewhere, so the file is more focused and understandable (and shorter!). I don't consider behavior of StarMap generation as something that StarMap
class should do, since functions as "game board" object for runtime of a single game match.
A StarMapGenerator
class or something is practically a must.
from open-realms-of-stars.
@tuomount I quickly reviewed the code in the little free time I have these days and I saw you have managed to successfully dehardcode the SpaceRace
enum
. That's marvelous! Congratulations! 🥳
Here is some feedback on the changes and outcomes, if you are interested.
There was at least one case where pseudo-race's ID in createOne()
method was wrongly written. I suggest to create a static constant and use it instead of writing it each time. Also, using the Optional<>
or createOr()
methods can help to detect such cases, as it forces programmer to explicitly say, what to do in case that value is absent, possibly throwing an error when something goes awry.
(I found it. It is in Diplomacy.java, text SpaceRaceFactory.createOne("SPACE_PIRATES"));
It is possible there are other such cases.)
Regarding design, if you plan to ever introduce "races created at runtime" (procedurally-generated or similar), the SpaceRaceFactory
class usage and code will likely have to be revised dramatically.
This is because of the (dreaded) global state. It is still very "enumish" and thus not suitable for such design - in case of RaceTraits
, Buildings
, "Bridge Graphics", etc. global state is not such a deal-breaker, as those objects are likely to be predefined before program launch (by programmer/modder) and work as available "blocks to build from". Races are more a thing that "can be built from the available blocks" at runtime (think like Planets vs. Buildings - Buildings are predefined in data files, their individual "setup" on a Planet is not).
So technically, the SpaceRaceFactory
now works as a "race preset loader". And by quick glance, a whole lot of code is still designed to treat SpaceRace
s as "globally available information" rather than "ad-hoc data". Usage of the createOne()
method of the factory can help to find such cases.
Removing the global-state of SpaceRace
data will also likely include things like saving race data to save files or something.
But since SpaceRace
is normal class with normal objects now, potential removal of the global state is at least conceivable. 😄
And if you do not plan to add "races made at runtime", and leave this to "modding" only, then everything's great!
In any case, the removal of the SpaceRace
enum
is still a major step forward. 👍
from open-realms-of-stars.
There are no more SpaceRace enum. Closing.
from open-realms-of-stars.
Related Issues (20)
- Water level/type on planet HOT 1
- Proper design for Space Pirates and "pseudo realms" HOT 2
- Planet radiation type HOT 1
- Galactic Event system rewrite HOT 3
- Armed freighters mechanic design HOT 7
- Moving Diplomacy SpeechLines to data files HOT 6
- Space Race Editor HOT 2
- New space trait: Plantlife form
- Redesign realm setup view HOT 1
- Refactor Government into class and read data from JSON HOT 1
- Zero gravity beings value planet wrongly HOT 1
- Possibility to ask third party planet locations
- Government Editor
- Check and improve tutorial
- If one the alliance party makes peace with third party peace should both alliance parties
- Flathub package HOT 1
- Doomed starting scenarios should be visible in background story.
- Ready made space race for plant life
- BUG: Realm color does not change in realm setup view in dropdown menu
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from open-realms-of-stars.