Exemple #1
0
        public List <IInfobox> GetInfobox(string wikiText)
        {
            if (string.IsNullOrWhiteSpace(wikiText))
            {
                return(null);
            }

            var result = new List <IInfobox>();

            var buildingName = getBuildingName(wikiText);

            if (string.IsNullOrWhiteSpace(buildingName))
            {
            }

            var buildingType = getBuildingType(wikiText);

            if (buildingType == BuildingType.Unknown)
            {
            }

            var productionInfo = getProductionInfo(wikiText);

            if (productionInfo == null && buildingType == BuildingType.Production)
            {
            }

            var supplyInfo = getSupplyInfo(wikiText);
            var unlockInfo = getUnlockInfo(wikiText);

            var specialBuildingNameHelper = new SpecialBuildingNameHelper();

            buildingName = specialBuildingNameHelper.CheckSpecialBuildingName(buildingName);

            var parsedInfobox = new Infobox
            {
                Name            = buildingName,
                Type            = buildingType,
                ProductionInfos = productionInfo,
                SupplyInfos     = supplyInfo,
                UnlockInfos     = unlockInfo,
                //Region
            };

            result.Add(parsedInfobox);

            return(result);
        }
Exemple #2
0
        public List <IInfobox> GetInfobox(string wikiText)
        {
            if (string.IsNullOrWhiteSpace(wikiText))
            {
                return(null);
            }

            var result = new List <IInfobox>();

            //same for both
            var buildingName = getBuildingName(wikiText);

            if (string.IsNullOrWhiteSpace(buildingName))
            {
            }

            //parse wikitext 2 times. first time with parameter "OW", second time with parameter "NW"
            foreach (var curRegion in possibleRegions)
            {
                var buildingType = getBuildingType(wikiText, curRegion);
                if (buildingType == BuildingType.Unknown)
                {
                }

                var productionInfo = getProductionInfo(wikiText, curRegion);
                if (productionInfo == null && buildingType == BuildingType.Production)
                {
                }

                var supplyInfo = getSupplyInfo(wikiText, curRegion);
                var unlockInfo = getUnlockInfo(wikiText, curRegion);

                var specialBuildingNameHelper = new SpecialBuildingNameHelper();
                buildingName = specialBuildingNameHelper.CheckSpecialBuildingName(buildingName);

                var region = WorldRegion.Unknown;
                switch (curRegion)
                {
                case "OW":
                    region = WorldRegion.OldWorld;
                    break;

                case "NW":
                    region = WorldRegion.NewWorld;
                    break;

                default:
                    break;
                }

                var parsedInfobox = new Infobox
                {
                    Name            = buildingName,
                    Type            = buildingType,
                    ProductionInfos = productionInfo,
                    SupplyInfos     = supplyInfo,
                    UnlockInfos     = unlockInfo,
                    Region          = region
                };

                result.Add(parsedInfobox);
            }

            return(result);
        }