changeset 254:cdda78975be1

Fixes #268: Restructure stats for re-use * Present new stats through Unit * Add property to get array of type IDs
author IBBoard <dev@ibboard.co.uk>
date Sun, 02 May 2010 15:45:31 +0000
parents 79943fcf4de2
children 0db25d5d0992
files api/Objects/Stats.cs api/Objects/Unit.cs api/Objects/UnitMemberType.cs api/Objects/UnitType.cs
diffstat 4 files changed, 59 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/api/Objects/Stats.cs	Mon Apr 26 19:49:51 2010 +0000
+++ b/api/Objects/Stats.cs	Sun May 02 15:45:31 2010 +0000
@@ -20,7 +20,6 @@
 			sysStats = systemStats;
 			int statCount = sysStats.SlotCount;
 			stats = new List<Stat>(statCount);
-			int i = 0;
 
 			foreach (StatSlot slot in sysStats.StatSlots)
 			{
--- a/api/Objects/Unit.cs	Mon Apr 26 19:49:51 2010 +0000
+++ b/api/Objects/Unit.cs	Sun May 02 15:45:31 2010 +0000
@@ -472,15 +472,35 @@
 			}
 		}
 
+		[Obsolete("Use UnitStatsArrays instead")]
 		public Stat[] UnitStatsArray
 		{
 			get { return UnitType.UnitStatsArray; }
 		}
+		
+		public Stat[][] UnitStatsArrays
+		{
+			get { return UnitType.UnitStatsArrays; }
+		}
 
+		[Obsolete("Use UnitStatsArraysWithName instead")]
 		public Stat[] UnitStatsArrayWithName
 		{
 			get { return UnitType.UnitStatsArrayWithName; }
 		}
+		
+		public Stat[][] UnitStatsArraysWithName
+		{
+			get { return UnitType.UnitStatsArraysWithName; }
+		}
+		
+		public string[] UnitStatsArrayIDs
+		{
+			get 
+			{
+				return UnitType.UnitStatsArrayIDs;
+			}
+		}
 
 		public string GetStatValue(string statName)
 		{
--- a/api/Objects/UnitMemberType.cs	Mon Apr 26 19:49:51 2010 +0000
+++ b/api/Objects/UnitMemberType.cs	Sun May 02 15:45:31 2010 +0000
@@ -19,6 +19,14 @@
 		{
 			stats = typeStats;
 		}
+		
+		public string StatsID
+		{
+			get 
+			{
+				return stats.StatsID;
+			}
+		}
 
 		/// <value>
 		/// The set of <see cref="Stat"/>s for the unit member type in a format that is valid for the game system.
--- a/api/Objects/UnitType.cs	Mon Apr 26 19:49:51 2010 +0000
+++ b/api/Objects/UnitType.cs	Sun May 02 15:45:31 2010 +0000
@@ -225,7 +225,7 @@
 		{
 			get
 			{
-				Stat[][] statsArray = null;
+				Stat[][] statsArray;
 				
 				if (stats != null)
 				{
@@ -253,6 +253,36 @@
 				return statsArray;
 			}
 		}
+		
+		public string[] UnitStatsArrayIDs
+		{
+			get 
+			{
+				string[] ids;
+				
+				if (stats != null)
+				{
+					ids = new string[]{ stats.StatsID };
+				}
+				else if (unitMemberTypes.Count > 0)
+				{
+					ids = new string[unitMemberTypes.Count];
+					int i = 0;
+					
+					foreach (UnitMemberType memType in unitMemberTypes.Values)
+					{
+						ids[i] = memType.StatsID;
+						i++;
+					}
+				}
+				else
+				{
+					ids = new string[]{ GameSystem.StandardSystemStatsID };
+				}
+				
+				return ids;
+			}
+		}
 
 		//// <value>
 		/// 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