Exemple #1
0
        public bool ResolveWolves(List<Hunter> huntersEncountered, UserInterface ui)
        {
            Logger.WriteToDebugLog("Hunter" + (huntersEncountered.Count() > 0 ? "s" : "") + " encountered Wolves");
            Logger.WriteToGameLog("Hunter" + (huntersEncountered.Count() > 0 ? "s" : "") + " encountered Wolves");
            ui.TellUser(huntersEncountered.First().Name + " ");
            for (int i = 1; i < huntersEncountered.Count(); i++)
            {
                ui.TellUser("and " + huntersEncountered[i].Name + " ");
            }
            ui.TellUser("encountered Wolves");
            bool hasPistol = false;
            bool hasRifle = false;
            for (int i = 1; i < huntersEncountered.Count(); i++)
            {
                int answer = ui.GetHunterEquipmentForWolves(huntersEncountered[i].Name);
                switch (answer)
                {
                    case 1: hasPistol = true; break;
                    case 2: hasRifle = true; break;
                    case 3: hasPistol = true; hasRifle = true; break;
                }
            }
            int numberOfWeaponTypes = (hasPistol ? 1 : 0) + (hasRifle ? 1 : 0);
            if (numberOfWeaponTypes == 2)
            {
                Logger.WriteToDebugLog("Wolves are negated by Pistol and Rifle");
                Logger.WriteToGameLog("Wolves are negated by Pistol and Rifle");
                ui.TellUser("Wolves are negated by Pistol and Rifle");
            }
            else
            {
                for (int i = 1; i < huntersEncountered.Count(); i++)
                {
                    Logger.WriteToDebugLog(huntersEncountered[i].Name + " loses " + (numberOfWeaponTypes == 1 ? "1" : "2") + " health");
                    Logger.WriteToGameLog(huntersEncountered[i].Name + " loses " + (numberOfWeaponTypes == 1 ? "1" : "2") + " health");
                    ui.TellUser(huntersEncountered[i].Name + " loses " + (numberOfWeaponTypes == 1 ? "1" : "2") + " health");
                    huntersEncountered[i].Health -= (2 - numberOfWeaponTypes);
                }

            }
            return !HandlePossibleHunterDeath(ui);
        }