RuleSets are here!
I finally found a decent way to create rulesets. I've implemented the first four rules. These rules can be used across all kinds of objects inside the gaming system. The first four are:
- AddStatToAttributeRule
- DecreaseAttributeRule
- IncreaseAttributeRule
- SubstractStatFromAttributeRule
There are also unit tests that make sure that these are working appropriately.
I had to do some interesting "under the hood" work to get these to work property. The most onery task was to implement the System.IComparable interface in AttributeWRM and StatWRM. I'm doing some fancy conversion with generics, but I'm doing this so that the actual implementation of a rule is a one liner.
To increase an attribute, you do this:
new IncreaseAttributeRule().Execute(this.PlayerThing, "Damage", 2);
To decrease an attribute you do this:
new DecreaseAttributeRule().Execute(this.PlayerThing, "Damage", 2);
You can also do stuff a bit more complicated like adding the value of a stat to an attribute like this:
new AddStatToAttributeRule<GameStat, GameAttribute>().Execute(this.PlayerThing, "Warrior", "Damage");
To reverse this rule, we do this:
new SubstractStatFromAttributeRule<GameStat, GameAttribute>().Execute(this.PlayerThing, "Warrior", "Damage");
I needed to implement all of this functionality, to be able to build the basic combat system for WRM. I believe that this will let us move forward and implement spells with effects as well. Very exciting! 