示例#1
0
        /// <summary>
        /// Checks if the input string is a TW coordinate
        /// </summary>
        public Point?GetCoordinates(string input)
        {
            Match match = VillagePattern.Match(input.Trim());

            if (match.Success)
            {
                int x;
                int y;
                if (int.TryParse(match.Groups[1].Value, out x) && int.TryParse(match.Groups[2].Value, out y) &&
                    x > 0 && x < 1000 && y > 0 && y < 1000)
                {
                    return(new Point(x, y));
                }
            }
            return(null);
        }
示例#2
0
        /// <summary>
        /// Checks if the input string is a village
        /// </summary>
        public Village GetVillage(string input)
        {
            Match match = VillagePattern.Match(input.Trim());

            if (match.Success)
            {
                int x;
                int y;
                if (int.TryParse(match.Groups[1].Value, out x) && int.TryParse(match.Groups[2].Value, out y))
                {
                    var loc = new Point(x, y);
                    if (Default.Villages.ContainsKey(loc))
                    {
                        return(Default.Villages[loc]);
                    }
                }
            }
            return(null);
        }