I’m creating a game where I want to have many actions a player can do but only let these be done depending on a set of criteria.
I’m imagining a set of records each an action and some extra attributes that define the required criteria. Example: Explore caves where criteria is minHealth of x% and maxInventory of y% full. I would then query these records and display a random top 3 for the player to choose to do.
I could read a file with each row being an action & criteria, loop through them checking criteria with if/elses and then display a random set after I’ve filtered through them. However I’m wondering is there a local database type structure/pattern/package I can use with a query like language to abstract and simplify this? Otherwise I feel my logic of if/elses and managing data structures will quickly become complex and out of hand.
Rather than fantasizing how unwritten code might go bad in the future, try instead writing some code.
As you develop the code, think about writing an API that encapsulates whatever queries you might want to make.
This has the double benefit of forcing you to come down from this abstract “a set of criteria” to actually coding up a few of them and getting everything going. Plus when you want to swap it all out for some other backing store (database, repository, whatever), nothing but the actual “retrieve data” API internals change.
If you can’t yet do the above because your design isn’t concrete enough, adding a database to the situation is definitely NOT the next step. Make at least a meaningful slice of the game first.
writing an API that encapsulates whatever queries you might want to make.
Yep agreed, that’s what I’m currently doing but wanted to double check if there was a common design pattern that fit the bill that I’m just not aware of and is worth also investigating. Coming from a NodeJS background so a lot less familiar whats available to be from C# and Unity .