29 November 2021 by jr101dallas
⇠ Back to PostsWork the Plan
I’m starting to feel a little like these posts are a little repettitive, but also, I guess that’s kind of the point. I’ve set out a system, to keep myself on track and moving forward. So, no apologies, here’s the work list.
- create interface IDefenseMods
- create an Armor class that is IItem and IDefenseMods
- tests for Armor
- add a default Armor instance to Entity
- add Armor case to Entity tests
- create a model for DefenseMods
- add DefenseMods tests
- create the extensions for adding DefenseMods
- add tests for the extensions
- set up use of the calculations in Collision
- verify and possibly add to current tests around the calculations and removal of the targeted Entity
Getting Started
Except for a pernicious typo in a filename, missing a file extension, the start of the work was easy enough. I did have to reorder some steps though because the interface needs the model. Here’s the interface, model, and item.
public interface IDefenseMods
{
public DefenseMods GetDefenseModifiers();
}
public class DefenseMods
{
public int totalAblation;
public int totalArmor;
}
public class Armor : IItem, IDefenseMods
{
private int BonusAblation = 8;
private int BonusArmor = 8;
public DefenseMods GetDefenseModifiers()
{
return new DefenseMods()
{
totalAblation = BonusAblation,
totalArmor = BonusArmor
};
}
}
There’s really only one test on the model. The tests on Armor are highly parallel to the tests on Weapon.
[TestMethod]
public void DefaultDefenseModsHasValuesZero()
{
var defMod = new DefenseMods();
Assert.AreEqual(0, defMod.totalAblation);
Assert.AreEqual(0, defMod.totalArmor);
}
[TestMethod]
public void DefaultArmorIsIItem()
{
var armor = new Armor();
Assert.IsTrue(armor is IItem);
}
[TestMethod]
public void DefaultArmorIsIAimMods()
{
var armor = new Armor();
Assert.IsTrue(armor is IDefenseMods);
}
[TestMethod]
public void ArmorTotalAblationIsEight()
{
var armor = new Armor();
var mods = armor.GetDefenseModifiers();
Assert.AreEqual(8, mods.totalAblation, "Armor totalAblation isn't the expected value.");
}
[TestMethod]
public void ArmorTotalArmorIsEight()
{
var armor = new Armor();
var mods = armor.GetDefenseModifiers();
Assert.AreEqual(8, mods.totalArmor, "Armor totalArmor isn't the expected value.");
}
Remaining Steps
That leaves the following steps still to go.
- add a default Armor instance to Entity(Factory)
- add Armor case to Entity tests
- create the extensions for adding DefenseMods
- add tests for the extensions
- set up use of the calculations in Collision
- verify and possibly add to current tests around the calculations and removal of the targeted Entity
I noticed as I worked that I’d forgotten that I’d purposely chosen to put the component addition to the entity in EntityFactory and updated that step. The rest I think are still valid, at least for the moment.
tags: code - collision - model - defense - armor