private async Task PerformFarmingCycle(CancellationToken ct)
        {
            await bottomBarScreen.CloseAllWindows(ct);

            foreach (List <Village> villages in config.FarmVillages)
            {
                // Here we shuffle the villages, so it's less bot-like
                logger.Log("Shuffling villages...");
                villages.Shuffle();
                logger.Log("------------------------------------------------------------------------------------");

                foreach (Village vill in villages)
                {
                    logger.Log($"Processing request for {vill.name} ({vill.coordinates.x}|{vill.coordinates.y})...");

                    if (!IsServiceOn)
                    {
                        logger.Log($"Farming service is set to off. Breaking out of village loop.");
                        break;
                    }

                    if (unavailablePresetIds.Count == config.ArmyPresets.Count)
                    {
                        logger.Log($"Not enough units available. Breaking out of village loop.");
                        break;
                    }

                    unitAmounts = topBarScreen.GetUnitAmounts();

                    await TryToAttack(vill, ct);

                    await Task.Delay(random.Next(500, 1000), ct);

                    await bottomBarScreen.CloseAllWindows(ct);

                    logger.Log("------------------------------------------------------------------------------------");
                }
            }

            await bottomBarScreen.CloseAllWindows(ct);
        }
Beispiel #2
0
 public async Task CloseWindows()
 {
     await bottomBarScreen.CloseAllWindows(new CancellationTokenSource().Token);
 }