Exemplo n.º 1
0
        /// <summary>
        /// Extracts buildings.
        /// </summary>
        /// <param name="content">Content to extract.</param>
        /// <returns>Extracted building data.</returns>
        public static BuildingData[] Buildings(string content)
        {
            var mc = GetMatches(content, "b*");
            var data = new BuildingData[mc.Count];

            for (int i = 0; i < mc.Count; i++)
            {
                int id = mc[i].Groups["id"].Value.AsInt() + 18;
                var type = BuildingType.EMPTY;
                int level = 0;

                if (mc[i].Groups["full"].Success)
                {
                    type = (BuildingType)mc[i].Groups["type"].Value.AsInt();
                    level = mc[i].Groups["level"].Value.AsInt();
                }

                data[i] = new BuildingData(id, type, level);
            }

            return data;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Extracts fields.
        /// </summary>
        /// <param name="content">Content to extract.</param>
        /// <returns>Extracted field data.</returns>
        public static BuildingData[] Fields(string content)
        {
            var mc = GetMatches(content, "f*");
            var data = new BuildingData[mc.Count];

            for (int i = 0; i < mc.Count; i++)
            {
                int id = mc[i].Groups["id"].Value.AsInt();
                int level = mc[i].Groups["level"].Value.AsInt();
                BuildingType type = BuildingType.UNKNOWN;

                string typeStr = mc[i].Groups["type"].Value;

                switch (typeStr)
                {
                    case "Orman":
                        type = BuildingType.WOODCUTTER;
                        break;
                    case "Tuğla":
                        type = BuildingType.CLAY_PIT;
                        break;
                    case "Demir":
                        type = BuildingType.IRON_MINE;
                        break;
                    case "Tarla":
                        type = BuildingType.CROPLAND;
                        break;
                }

                data[i] = new BuildingData(id, type, level);
            }

            return data;
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Adds a new building requirement to profile.
        /// </summary>
        /// <param name="type">Structure type.</param>                         
        /// <param name="level">Structure level.</param>
        /// <param name="id">Id value.</param>
        /// <returns></returns>
        public BuildingData AddBuildingRequirement(
            BuildingType type,
            int level,
            int id = 0)
        {
            if (BuildingRequirements.Any(i => i.Type == type))
            {
                return BuildingRequirements.First(i => i.Type == type);
            }

            var br = new BuildingData(id, type, level);
            BuildingRequirements.Add(br);
            return br;
        }