Mercurial > repos > IBDev-IBBoard.WarFoundry.API
diff api/Objects/UnitType.cs @ 81:032b174fc17a
Re #10 - Refactoring for readability
* Remove "trainwreck code" by making Unit and UnitType publish methods to get arrays of stats
* Remove "trainwreck code" by making Unit, UnitType and Stats publish methods to get value of one stat
* Make factory use new methods
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 27 May 2009 19:43:09 +0000 |
parents | 91cf8efbea0b |
children | 3ea0ab04352b |
line wrap: on
line diff
--- a/api/Objects/UnitType.cs Tue May 19 19:00:48 2009 +0000 +++ b/api/Objects/UnitType.cs Wed May 27 19:43:09 2009 +0000 @@ -48,7 +48,7 @@ MaxSize = maximumSize; BaseUnitCost = unitCost; CostPerTrooper = trooperCost; - UnitStats = unitStats; + SetUnitStats(unitStats); foreach (UnitRequirement requirement in requirements) { @@ -193,21 +193,38 @@ } /// <value> - /// The <see cref=" Stats"/> for the unit in a format that is valid for the game system. + /// The set of <see cref="Stat"/>s for the unit in a format that is valid for the game system. /// </value> - public Stats UnitStats + public Stat[] UnitStatsArray { get { - return stats; + return stats.StatsArray; } - set - { - if (value!=null) - { - stats = value; - } - } + } + + //// <value> + /// The set of <see cref="Stat"/>s for the unit including an additional column that contains the unit type name + /// </value> + public Stat[] UnitStatsArrayWithName + { + get + { + Stat[] extendedStats = new Stat[stats.StatCount+1]; + extendedStats[0] = new Stat(new StatSlot("Name"), Name); + stats.StatsArray.CopyTo(extendedStats, 1); + return extendedStats; + } + } + + public void SetUnitStats(Stats newStats) + { + stats = newStats; + } + + public string GetStatValue(string statName) + { + return stats.GetStatValue(statName); } public void AddEquipmentItem(UnitEquipmentItem item)