It's been over a decade since I did anything non-assembler.
... I'll just let this one slide.
For some common cases: Mafia win if (mafiapeeps >= nonmafiapeeps) and (no_non_mafia_killers() == true)
Survivors win if (game_state_someone_won() == true) and (survivor_alive() == true)
SKs win if (players_alive() == 1) and (SK_alive() == true)
Well, if you have basic wincons like this, it might work.
Alternatively, if each player is a class ... hmm, no that idea won't work. I was going to say that each player's wincon could be a pointer to a linked list of other players who are blocking said player's wincon (and said players are removed from said list as they die), but that won't work for checking a survivor's wincon. Could be tweaked perhaps? Maybe have different wincon classes? Like a death_wincon would be like I described above, but you can also have a doom_wincon class which checks the current day value against it's threshold value. Survivor_wincon checks to see if a "someone won" flag has been set.
I think this is thinking a bit too low-level. See below.
In so far as abilities are concerned, I think you might need to break that up into different ability classes or something as well. Would a PGO's ability fit with your defined ability class? Or any reactive ability, really.
Just to look at the Xylbot role list for some tricky ability implementations: Beta Werewolf, Super-Saint, Eavesdropper, Forensics Expert, Gunsmith, Astrologer, etc.
Also a lot of conditional abilities like tracking, watching, delayer, CPR doctor, etc. ...
I'd prefer making a system where each "extra" ability can just be added on content.
I was thinking more around generating "events" (actual or pseudo), which wincons and other triggers can subscribe to.
Or rather, that "triggers" can subscribe to, and wincons incorporate those triggers. So would triggered abilities.
For those you mentioned:
Beta Werewolf: Subscribe to "kill" events. If criteria (is night & target is Alpha) met, cancel the event.
Super-Saint: Kill last to vote, doesn't seem too hard - just look at vote queue.
Eavesdropper: Eeeh... I wouldn't want to use this in nearly any setup, but technically: Subscribe to message send events, then unsub at end of night.
Forensics Expert: Dead players are still in the game. Likely either the mod processes the actual role text, or it could be a % chance per ability?
Gunsmith: This is kinda iffy in terms that just this role requires "extra information" on the type of kill.
Hmm.
For several of these (notably Gunsmith), would require extra information to be added to each role OR for a list of "gun roles" to be incorporated into the Gunsmith role (in the checker). However, for most it actually seems like an Event-driven architecture would be optimal.
Yes, in a role-heavy game it helps to encorporate the triggers into a list of things to check at each action resolution.
So I've been working on a balanced role generator partly inspired by your chart that modularises the use phase/ability/target type. Adding weights to the elements and adding flaws/buffs accordingly. Still very much a work in progress, but these are the sorts of roles it's been spitting out:
(Night)(Target/Self) You can protect. All protects against you fail.
(Night)(Target 1-2) You can block. Your abilities have a 50% chance of targeting yourself.
(Anytime)(Target) You can kill. You die if your vote is on a town player when they are lynched. You have 50% chance of giving your ability away to a random player after each lynch.
Wouldn't it make a bit more sense to generate roles with several abilities? As in, the third one would be:
(Anytime)(Target) You can kill.
(Auto) You die if your vote is on a town player when they are lynched.
(Auto) You have 50% chance of giving your ability away to a random player after each lynch.
[You could say this is one guilt-feeling vigilante
]