예제 #1
0
        void DemoAllIslands()
        {
            Telegraph telegraph = new Telegraph();

            if (!telegraph.GetAllIslands(out var allIslands))
            {
                Console.WriteLine("Couldn't find any islands");
                return;
            }


            Console.WriteLine(allIslands.Count);
            allIslands = allIslands.Where(island => island.name.Length > 0 && island.name.Length < 20).ToList();

            foreach (var island in allIslands)
            {
                Console.WriteLine($"\n\nFound island {island.name} - {island.id}");

                if (!telegraph.GetIslandConsumption(island.id, out var consumption))
                {
                    continue;
                }

                foreach (var con in consumption)
                {
                    Console.WriteLine($"{con.resourceType.ToString()} - {con.rate}");
                }

                if (!telegraph.GetIslandBuildings(island.id, out var buildings))
                {
                    continue;
                }

                // foreach (var building in buildings)
                // {
                //     Console.WriteLine($"{building.id} - {building.buidlingType} - {building.rawBuildingTypeID}");
                // }

                var validBuildings      = buildings.Where(b => b.buidlingType != Building.Invalid).ToList();
                var productionBuildings = validBuildings.Where(b => RDAHelper.GetProductionBuildings().Contains(b.buidlingType)).ToList();
                Console.WriteLine($"{buildings.Count} buildings ({validBuildings.Count} valid, {productionBuildings.Count} production)");

                foreach (var building in productionBuildings)
                {
                    if (!telegraph.GetBuildingProduction(island.id, building.id, out var productionNode))
                    {
                        continue;
                    }
                    Console.WriteLine($"Building {building.id} - {building.buidlingType.ToString()} - {productionNode.rate} {productionNode.output}");
                }
            }
        }
예제 #2
0
        public List <IslandRawDetails> GetIslandDetails()
        {
            if (!_telegraph.GetAllIslands(out var allIslands))
            {
                Console.WriteLine("Couldn't find any islands");
                return(new List <IslandRawDetails>());
            }

            allIslands = allIslands
                         .Where(island => island.name.Length > 0 && island.name.Length < 20)
                         .OrderBy(i => i.name)
                         .ToList();
            var allIslandsDetails = new List <IslandRawDetails>();

            foreach (var island in allIslands)
            {
                // Console.WriteLine($"Found island {island.name} - {island.id}");

                if (!_telegraph.GetIslandConsumption(island.id, out var consumption))
                {
                    continue;
                }

                // foreach(var con in consumption)
                // {
                //     Console.WriteLine($"{con.resourceType.ToString()} - {con.rate}");
                // }

                if (!_telegraph.GetIslandBuildings(island.id, out var buildings))
                {
                    continue;
                }

                var validBuildings      = buildings.Where(b => b.buidlingType != Building.Invalid).ToList();
                var productionBuildings = RDAHelper.GetProductionBuildings();

                var productionNodes = new List <ProductionNode>();
                foreach (var building in validBuildings)
                {
                    if (!productionBuildings.Contains(building.buidlingType))
                    {
                        continue;
                    }
                    if (!_telegraph.GetBuildingProduction(island.id, building.id, out var productionNode))
                    {
                        continue;
                    }
                    productionNodes.Add(productionNode);
                    // Console.WriteLine($"Building {building.id} - {building.buidlingType.ToString()} = {productionNode.output} @ {productionNode.rate}");
                }

                allIslandsDetails.Add(new IslandRawDetails
                {
                    IslandData       = island,
                    ConsumptionNodes = consumption,
                    ProductionNodes  = productionNodes
                });
            }

            // Console.WriteLine("Loaded all islands");

            return(allIslandsDetails);
        }