I’m having a lot of fun with Ink, but it’s also taking me a while to get used to its idioms. And sometimes I’ll run into something like this, where I can think of a few different ways to implement it, and none of them seem ideal. I’m curious what the “right” way is to do this.
Imagine there are several different factions, and several different dispositions each faction can take toward you: friendly, neutral, hostile, etc. Every faction always has exactly one disposition, but multiple factions can have the same disposition. (In other words, it’s a various-to-one relation.)
At bare minimum, I need to be able to check “what is the disposition of this faction”. But I’d like to also be able to conveniently ask questions like “how many hostile factions are there”, and “do these two factions have the same disposition”.
What’s the most Ink-y way to handle this? I’m sure it involves lists somehow, but I’m not sure how. (Ways I’ve considered so far: there’s a list of dispositions, and each faction is a variable; there’s a list of factions, and each disposition is a variable.)
… and while this method is Incredibly Hacky, we’ve used it in production now three or four times, so it does appear robust! I’d love to build a proper relation feature into the language proper, though, as it’s incredibly useful as soon as you want to do any kind of basic simulation. We’ll see if we manage it.
Oh, this is great! Looks like this gets you any number of various-to-various relations, and then to make other kinds of relations, you can just write a wrapper around relate that un-relates one side or the other first? I think that’ll work perfectly for my use case! Thank you!
Followup: since my relation is various-to-one, I know each faction will always have exactly one disposition, and can call unrelate(faction, Feeling, whatIs(faction, Feeling)) before setting a new one.
But if I had a various-to-various relation, and wanted to unlink one element from all others, is there an easy way to achieve that? Would unrelate(faction, Feeling, Disposition) (passing the entire list of Dispositions) accomplish that?