# HG changeset patch # User IBBoard # Date 1272311391 0 # Node ID 79943fcf4de2aef9468a48eda2422dbaa4886d3e # Parent a54da5a8b5bb22372187e0dd2b3cc9b564aa2984 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) diff -r a54da5a8b5bb -r 79943fcf4de2 api/Objects/UnitType.cs --- 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 @@ } /// - /// The set of s for the unit in a format that is valid for the game system. + /// The first of the s lines for the unit. /// + [Obsolete("Use UnitStatsArrays instead")] public Stat[] UnitStatsArray { get { - Stat[] statsArray = null; + return UnitStatsArrays[0]; + } + } + + //// + /// The first ot the s lines for the unit including an additional column that contains the unit type name + /// + [Obsolete("Use UnitStatsArrays instead")] + public Stat[] UnitStatsArrayWithName + { + get + { + return UnitStatsArraysWithName[0]; + } + } + + /// + /// The array of s for each of the unit's stat lines + /// + 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 @@ } //// - /// The set of s for the unit including an additional column that contains the unit type name + /// The array of s for each of the unit's stat lines including an additional column that contains the unit type name /// - 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;