Hello all,
I’m currently attempting to implement the Game Of Thrones board game in Unity for personal edification.
I’m at the point where I’m trying to implement the effects of house cards on combat.
House Cards have various effects on combat and “occur” at different trigger points - only on a loss or victory, when support strength is calculated, and so on. For extensibility reasons I’d like to be able to create a system which readily supports most new mechanics for house cards in any expansions that are published (more about using good principles in my code-learning endeavors than a desire to make all the GoT games)
Presently I have a instantiatable Combat class which stores all the data and methods for the combat (who is participating, where, the strength/support/etc of each party). My difficulty is understanding the correct Pattern/Model for this.
I’m presently debating two options and I don’t know which is better or if a 3rd option is better:
1 - At each phase of combat, check for the presence of a function on the HouseCard object that corresponds to the moment, and if it exists, call it. Seems like I’d be using a lot of type.GetMethod(string methodName) which looks sloppy and isn’t elegant - but it’d probably work.
2 - Create a series of events and pump them with a default delegate (normal operations) and allow houseCards to rewrite the delegate with their own function, if they have. Much more elegant, but, problem: Sometimes each player can have a house card which attaches to the same event - in which case, I want to call both versions but I dont want to call the original version
All advice is appreciated!
Thank you!