-
-
Notifications
You must be signed in to change notification settings - Fork 681
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
Add the ability to lock states, provinces, cultures, and religions #902
Conversation
…s being generated
✅ Deploy Preview for afmg ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Hello and thanks for the PR. I will try to change it soon. It may need some changes to inline with other code and make it easier to migrate to a new codebase (see #842) |
I've noticed a few bugs while testing on my own map in the preview:
I'll be fixing those soon. |
Awaiting for your confirmation and then will review. There are some concerns on performance and also whether it will be possible to move the code to the vite branch as well (please check it if you can). |
I've done a quick check and besides code moving from one file to another because of the vite migration, I think the main thing that could break would be the removal of |
It's not directly related to the PR, but there is an undecided question on whether we need to split the code for the 1st generation and regenerations. 1st generation usually requires less attributes and has to be very fast. Regeneration is a result of user's action, it can take more time, but usually it's more complicated. Like in our case 1st generation doesn't need to consider locked elements, also for the 1st generation we are sure about the data state. I am not yet sure whether it makes sense to split the function into 2 ones or keep everything in one place. Generally the code should be as simple as possible, so splitting may have sense. But it will require some rework. |
I've fixed most of the bugs I found, but I may have missed some. Let me know if you find anything! For bug 3., basically the problem is that, if I lock a state, but not the provinces of that state, the province regeneration will still ignore the provinces. I wonder, if I regenerate the provinces, should the state lock still prevent regeneration? Or should it only consider the state lock if regenerating states (which regenerate provinces too). What do you think? |
In my honest opinion having worked in the codebase for a few days, I do think some separation should happen. One of the toughest part of the feature (especially for religions) was trying to figure out where to handle locking in regeneration given the code includes both. There was a bug, for example, where the labels would regenerate for lock states and my fix broke when loading an existing map, I had a hard time finding where I need to fix that. I think that's a bit out of scope for this PR though. Maybe a good opportunity for a follow up? |
Both solutions work fine, I don't have a preference here. |
# Conflicts: # versioning.js
…rovinces directly.
I went with the second option using an added parameter to the |
@Azgaar I fixed all the bug I found while testing with random maps and my own maps, I even saved my personal campaign map and it's loading and regenerating fine with this version. I think it's ready to review. |
Good, I will try to review today. I also see some potential improvements. Not like it all was good before, the code is very messy, but it will make sense to improve and we add new features. Like all |
For sure, please let me know if you'd like me to implement some here or as a follow up 🙂. I also have a few improvements in mind that I was thinking about suggesting in discussions. One big thing I'd like to do, for example, is to break up the generation files between domains. Like instead of a |
Yes, some enhancements can be made later. Big redesign goes as this Vite migration/refactoring. |
I will merge to the PR to a preliminary branch, then make a few changed and marge to master if everything is fine |
No problem, let me know if I can help with anything! |
Vite branch can take years to come, so if you want a see the result in production faster, you can take some current buggy code like Submap. It's an important functionality, but it's not working in lots of cases. Also see our trello board and issues list here. It may be better to concentrate on bugs. |
Started to work on refactoring, I see a lot of places where code is not effective and can be enhanced. Like when we regenerate states old id should gone, we should not store it and use for some operations, it will create a mess (also it is a data model change). The refactoring progresses slowly, so it may take some time. |
…efactoring (#910) * Add the ability to lock states, provinces, cultures, and religions (#902) * Add the basis for locking everything, code and test the culture locking * Got the religion generator working, but not the tree. There are cycles being generated * Religions work now, including the tree view * Got the states and provinces working as well, all good and ready * Refresh the province editor when regenerating * Implement the versioning steps * Fix the state naming and color changing even when locked * The fix did not work with loaded maps, fix that too * Fix a few more bugs and address the PR feedback * Fix the state expanding event when they're locked bug * Implement some logic to ignore state being locked when regenerating provinces directly. * refactor(#902): start with states regenertion * refactor(#902): locked states cells to be assigned on start * refactor(#902): lock state - keep label * refactor(#902): lock provinces * refactor(#902): regenerate states - update provinces * refactor(#902): regenerate cultures * refactor(#902): regenerate religions Co-authored-by: Guillaume St-Pierre <[email protected]> Co-authored-by: Azgaar <[email protected]>
Fully merged now. |
Description
This PR adds the ability to lock states, provinces, cultures, and religions using pretty much the same UX as locking burgs. They all work by making sure the cells keep their own for each respective types and by preventing whatever is regenerated from taking over the cells of locked elements. Some of the code is a bit messy since I started with cultures, then moved to religion (the most arduous one), and finished with states/provinces (the easier ones, which alloweb me to think about some optimizations). I've made sure to document the code along the way so it makes sense.
I've recorded some videos of the feature working.
Cultures
Here are the culture regeneration working with a locked culture. The colors can overlap one another since there isn't any logic for that when a culture is regenerated, but it is properly kept as-is. I've also made sure to prevent cultures from using one of the locked culture cell as their origin.
Enregistrement.d.ecran.le.2022-12-07.a.21.00.09.mov
Religions
The most complicated one and possibly the one most prone to issues. I've added the same features as for the cultures, but I've also made sure that any locked religion will be replaced alongside the other religions in the religion origin tree. At the moment, the tree doesn't keep the old relations alive if all religions is a branch are locked, something for later.
Enregistrement.d.ecran.le.2022-12-09.a.16.49.51.mov
States
States will be locked and no state may use its cells as its capital. It also locks all provinces in a locked state, the assumption is that a locked state shouldn't change at all. Since province generation is part of a state's generation, that locks itself as well.
Enregistrement.d.ecran.le.2022-12-09.a.16.50.38.mov
Provinces
Was mostly built as part of the state locking. It will regenerate all provinces except the locked one (either from state or province) and the province generation makes sure that cells can't be stolen by newly generated provinces when in the same state (can't happen between states).
Enregistrement.d.ecran.le.2022-12-09.a.16.52.02.mov
The bug at the end of the video where I have to click to open the editor again to refresh the list has been since fixed.
Type of change
Versioning