changeset 309:7e1b27843b0d

Fixes #99: Define "points" values in GameSystem * Implement fall-back in case only one value has been set
author IBBoard <dev@ibboard.co.uk>
date Sun, 20 Feb 2011 16:00:11 +0000
parents e1438fb9024c
children f7c3c1b39726
files api/Objects/GameSystem.cs
diffstat 1 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/api/Objects/GameSystem.cs	Sun Feb 13 21:03:12 2011 +0000
+++ b/api/Objects/GameSystem.cs	Sun Feb 20 16:00:11 2011 +0000
@@ -324,14 +324,30 @@
 		
 		public string GetPointsAbbrev(double pointTemp)
 		{
-			string str = (pointTemp == 1 ? SystemPtsAbbrevSingle : SystemPtsAbbrevPlural);
-			return (str == null ? "" : str);
+			string abbrev = (pointTemp == 1 ? GetPreferredString(SystemPtsAbbrevSingle, SystemPtsAbbrevPlural) : GetPreferredString(SystemPtsAbbrevPlural, SystemPtsAbbrevSingle));
+			return abbrev;
 		}
 
 		public string GetPointsName(double pointTemp)
 		{
-			string str = (pointTemp == 1 ? SystemPtsNameSingle : SystemPtsNamePlural);
-			return (str == null ? "" : str);
+			string ptsName = (pointTemp == 1 ? GetPreferredString(SystemPtsNameSingle, SystemPtsNamePlural) : GetPreferredString(SystemPtsNamePlural, SystemPtsNameSingle));
+			return ptsName;
+		}
+		
+		private string GetPreferredString(string str1, string str2)
+		{
+			string preferred = "";
+			
+			if (str1 != null)
+			{
+				preferred = str1;
+			}
+			else if (str2 != null)
+			{
+				preferred = str2;
+			}
+			
+			return preferred;
 		}
 	}
 }