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 diff
     1.1 --- a/api/Objects/GameSystem.cs	Sun Feb 13 21:03:12 2011 +0000
     1.2 +++ b/api/Objects/GameSystem.cs	Sun Feb 20 16:00:11 2011 +0000
     1.3 @@ -324,14 +324,30 @@
     1.4  		
     1.5  		public string GetPointsAbbrev(double pointTemp)
     1.6  		{
     1.7 -			string str = (pointTemp == 1 ? SystemPtsAbbrevSingle : SystemPtsAbbrevPlural);
     1.8 -			return (str == null ? "" : str);
     1.9 +			string abbrev = (pointTemp == 1 ? GetPreferredString(SystemPtsAbbrevSingle, SystemPtsAbbrevPlural) : GetPreferredString(SystemPtsAbbrevPlural, SystemPtsAbbrevSingle));
    1.10 +			return abbrev;
    1.11  		}
    1.12  
    1.13  		public string GetPointsName(double pointTemp)
    1.14  		{
    1.15 -			string str = (pointTemp == 1 ? SystemPtsNameSingle : SystemPtsNamePlural);
    1.16 -			return (str == null ? "" : str);
    1.17 +			string ptsName = (pointTemp == 1 ? GetPreferredString(SystemPtsNameSingle, SystemPtsNamePlural) : GetPreferredString(SystemPtsNamePlural, SystemPtsNameSingle));
    1.18 +			return ptsName;
    1.19 +		}
    1.20 +		
    1.21 +		private string GetPreferredString(string str1, string str2)
    1.22 +		{
    1.23 +			string preferred = "";
    1.24 +			
    1.25 +			if (str1 != null)
    1.26 +			{
    1.27 +				preferred = str1;
    1.28 +			}
    1.29 +			else if (str2 != null)
    1.30 +			{
    1.31 +				preferred = str2;
    1.32 +			}
    1.33 +			
    1.34 +			return preferred;
    1.35  		}
    1.36  	}
    1.37  }