Mercurial > repos > snowblizz-super-API-ideas
changeset 253:79943fcf4de2
Re #268: Restructure stats for re-use
* Add multi-stat properties to unit types
* Deprecate single versions and make them return just the first stat line (since we guarantee at least one line)
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 26 Apr 2010 19:49:51 +0000 |
parents | a54da5a8b5bb |
children | cdda78975be1 |
files | api/Objects/UnitType.cs |
diffstat | 1 files changed, 51 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/api/Objects/UnitType.cs Sun Apr 25 15:07:08 2010 +0000 +++ b/api/Objects/UnitType.cs Mon Apr 26 19:49:51 2010 +0000 @@ -195,28 +195,59 @@ } /// <value> - /// The set of <see cref="Stat"/>s for the unit in a format that is valid for the game system. + /// The first of the <see cref="Stat"/>s lines for the unit. /// </value> + [Obsolete("Use UnitStatsArrays instead")] public Stat[] UnitStatsArray { get { - Stat[] statsArray = null; + return UnitStatsArrays[0]; + } + } + + //// <value> + /// The first ot the <see cref="Stat"/>s lines for the unit including an additional column that contains the unit type name + /// </value> + [Obsolete("Use UnitStatsArrays instead")] + public Stat[] UnitStatsArrayWithName + { + get + { + return UnitStatsArraysWithName[0]; + } + } + + /// <value> + /// The array of <see cref="Stat"/>s for each of the unit's stat lines + /// </value> + public Stat[][] UnitStatsArrays + { + get + { + Stat[][] statsArray = null; if (stats != null) { - statsArray = stats.StatsArray; + statsArray = new Stat[][]{ stats.StatsArray }; } else if (unitMemberTypes.Count > 0) { - UnitMemberType[] memberTypeArray = DictionaryUtils.ToArray(unitMemberTypes); - statsArray = memberTypeArray[0].StatsArray; + int memTypeCount = unitMemberTypes.Count; + statsArray = new Stat[memTypeCount][]; + int i = 0; + + foreach (UnitMemberType memType in unitMemberTypes.Values) + { + statsArray[i] = memType.StatsArray; + i++; + } } else { SystemStats systemStats = GameSystem.StandardSystemStats; Stats tempStats = new Stats(systemStats); - statsArray = tempStats.StatsArray; + statsArray = new Stat[][]{ tempStats.StatsArray }; } return statsArray; @@ -224,28 +255,35 @@ } //// <value> - /// The set of <see cref="Stat"/>s for the unit including an additional column that contains the unit type name + /// The array of <see cref="Stat"/>s for each of the unit's stat lines including an additional column that contains the unit type name /// </value> - public Stat[] UnitStatsArrayWithName + public Stat[][] UnitStatsArraysWithName { get { - Stat[] statsArray = null; + Stat[][] statsArray; if (stats != null) { - statsArray = ExtendStatsArrayWithName(stats.StatsArray); + statsArray = new Stat[][]{ ExtendStatsArrayWithName(stats.StatsArray) }; } else if (unitMemberTypes.Count > 0) { - UnitMemberType[] memberTypeArray = DictionaryUtils.ToArray(unitMemberTypes); - statsArray = memberTypeArray[0].StatsArrayWithName; + int memTypeCount = unitMemberTypes.Count; + statsArray = new Stat[memTypeCount][]; + int i = 0; + + foreach (UnitMemberType memType in unitMemberTypes.Values) + { + statsArray[i] = memType.StatsArrayWithName; + i++; + } } else { SystemStats systemStats = GameSystem.StandardSystemStats; Stats tempStats = new Stats(systemStats); - statsArray = ExtendStatsArrayWithName(tempStats.StatsArray); + statsArray = new Stat[][]{ ExtendStatsArrayWithName(tempStats.StatsArray) }; } return statsArray;