-
-
Notifications
You must be signed in to change notification settings - Fork 347
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
Abstract out game-specific logic #3223
Conversation
This is beyond my C# to review properly, but I wholeheartedly support the concept! Making it work across different games was always something on the future road map. The indexing infra doesn't necessarily require duplication, but we can certainly map out how we might achieve supporting multiple games. |
@techman83 yeah. I've been considering that maybe .netkans could have a new optional propety indicating which game they're for: "game": "KSP", This could be used to drive various game-specific validation checks, as well as where the Indexer commits them ( |
My only concern and something we don't have to come up with for this, would be schemas. A NetKAN is a subset of the CKAN schema. Would we have a schema per game, ensure our schema also is game independent, things like that? Actually after writing that, there is probably a lot that can be re-used. As a separate exercise we could go through the schema and figure out what is/isn't ksp specific. |
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.
Slowly digging through the changes. Fortunately most of them are just class renames, but still takes some time to filter out all of them.
Two notes to start with...
657a6ff
to
3123ee6
Compare
I just pushed a few localization fixes, also tried my luck with Chinese, with the assumption that "game" is translated to "游戏". 🤞 |
5bb7242
to
ab7ecdf
Compare
ab7ecdf
to
e2b51f9
Compare
What's the reason for removing the build map cache from the |
Does it belong there? Seems like we'd be setting ourselves up to store an unreasonable amount of data from many games, none of which is truly "configuration" in any conceivable sense. |
I agree that it doesn't belong into |
e647143
to
c6ef4a6
Compare
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.
Getting close. Two more small little things.
I've tested this branch quite a bit, and it is really solid so far.
c6ef4a6
to
e13b683
Compare
Pushed a small commit with minor clean-up, i.e. typo fixes and removing some unused imports, and made a field in |
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.
LGTM, I've forced enough rebases on you. The changes work excellently, and this is a huge jump forward for multi-game support in the future. It should simplify any metadata and infra changes that will be needed.
Thank your very much!
Motivation
The currently pledged release date for KSP 2 is sometime in 2022. Shortly after that, we would like to support it in CKAN, see #2863. But currently the code is shot through with KSP1-specific logic that is unlikely to work in both games, and we have no framework for adding support for other games.
Changes
Now we take a first step towards cleanly encapsulating game-specific logic such that we will be able to swap it out for other games in the future. This got a bit big, sorry about that.
Code summary:
IGame
interface encapsulates all the logic we need to support a game in the abstract.KerbalSpaceProgram
class that implements this interfaceIGame
GameInstance
(f.k.a.KSP
) holds a reference to theIGame
object associated with the game of which it represents an instanceGameInstanceManager
(f.k.a.KSPManager
) holds a list of known games, which are used to probe folders and determine which game to useIGame
parameter or retrieve it fromGameInstance.game
if they already have a game instanceJsonPropertyNamesChangedConverter
class allows us to change property names in JSON files while still migrating forward the old dataVisible changes:
IGame.ShortName
instead of being hard coded, so future games will be shown the same waySide fix:
ckan repo default uri
previously ignored its uri parameter and just set the default repo to the default URL (and then lied about it). As of this PR, it sets the default repo to the URL from the parameter, as expected.Limitations:
IGame
, it just instantiates anew KerbalSpaceProgram()
, since it doesn't have a game instance to check. We will need to add something more sophisticated here in the future, maybe a--game
parameter defaulting toKSP
. This will have to be figured out in a future PR.new KerbalSpaceProgram()
freely to bootstrap old code into the new reality. If and when we add more games, writing more Tests would make sense.new KerbalSpaceProgram()
. If and when we add another game, we would want to prompt the user to choose a game here.Future ideas:
NetKAN-Infra
services per each game