Exemplo n.º 1
0
        public string DailyEvent()
        {
            string dailyPrint = "";

            if (townPopulation.Count != 0)
            {
                int randomValue;
                randomDailyEventsEnum dailyEvent = new randomDailyEventsEnum();
                dailyEvent = RandomDailyEvent();
                switch (dailyEvent)
                {
                case randomDailyEventsEnum.zombieAttack:
                    int         attack      = rand.Next(100);
                    BaseDefense baseDefense = new BaseDefense();
                    if (attack >= baseDefense.calculateDefense())
                    {
                        dailyPrint = "You were attacked";
                        int preMath = 3 * ((population / 10) + 1);
                        int test    = rand.Next(preMath);
                        if (test >= population)
                        {
                            test = population - 1;
                        }
                        System.Diagnostics.Debug.WriteLine($"Test: {test}");
                        for (int i = 0; i <= test; i++)
                        {
                            randomValue = rand.Next(townPopulation.Count);
                            System.Diagnostics.Debug.WriteLine($"Random: {randomValue}");
                            dailyPrint = dailyPrint + ($"\nDied: {Game.townPopulation[randomValue].name}");
                            Game.townPopulation.RemoveAt(randomValue);
                        }
                        population = Game.townPopulation.Count;

                        System.Diagnostics.Debug.WriteLine($"Population: {population}");
                    }
                    break;

                case randomDailyEventsEnum.zombieHordeAttack:
                    break;

                case randomDailyEventsEnum.survivorDied:
                    if (Corot.Research.Research.antiVenomComplete == false)
                    {
                        dailyPrint = "A disease outbreak occured";
                        int preMath = 3 * ((population / 10) + 1);
                        int test    = rand.Next(preMath);
                        if (test >= population)
                        {
                            test = population - 1;
                        }
                        System.Diagnostics.Debug.WriteLine($"Test: {test}");
                        for (int i = 0; i <= test; i++)
                        {
                            randomValue = rand.Next(townPopulation.Count);
                            System.Diagnostics.Debug.WriteLine($"Random: {randomValue}");
                            dailyPrint = dailyPrint + ($"\nDied: {Game.townPopulation[randomValue].name}");
                            Game.townPopulation.RemoveAt(randomValue);
                        }
                        population = Game.townPopulation.Count;

                        System.Diagnostics.Debug.WriteLine($"Population: {population}");
                    }
                    else
                    {
                        dailyPrint = "A disease outbreak was cured";
                    }
                    break;

                case randomDailyEventsEnum.survivorFound:
                    int researchMultiplier = 1;
                    if (Corot.Research.Research.signsComplete == true)
                    {
                        researchMultiplier += 1;
                    }
                    if (Corot.Research.Research.radioComplete == true)
                    {
                        researchMultiplier += 1;
                    }
                    for (int i = 0; i < rand.Next(2 * researchMultiplier); i++)
                    {
                        People.People people = new People.People();
                        Game.townPopulation.Add(people);
                    }
                    population = Game.townPopulation.Count;
                    dailyPrint = dailyPrint + ("New people added");
                    break;

                case randomDailyEventsEnum.extraFood:
                    Food      += rand.Next(20);
                    dailyPrint = dailyPrint + ($"We found {Food} food");
                    break;

                case randomDailyEventsEnum.rottedFood:
                    int rot = rand.Next((Food / 2));
                    Food      -= rot;
                    dailyPrint = dailyPrint + ($"{rot} Food went bad");
                    break;

                case randomDailyEventsEnum.boringDay:
                    dailyPrint = dailyPrint + ("Boring day");
                    break;

                default:
                    break;
                }
            }
            return(dailyPrint);
        }