示例#1
0
        private bool ResolveEncountersAtLocation(Hunter hunter, Map map, Location location, UserInterface ui)
        {
            Dracula.OrderEncounters(hunter, location);
            foreach (EncounterDetail enc in map.LocationDetails(location).Encounters)
            {
                enc.isRevealed = true;
                ui.TellUser(enc.name + " is revealed");
            }
            ui.drawGameState(this);
            bool resolveNextEncounter = true;
            bool discardEncounter = true;
            List<EncounterDetail> encountersBeingDiscarded = new List<EncounterDetail>();
            EncounterDetail firstEncounter = null;
            EncounterDetail secondEncounter = null;

            if (map.LocationDetails(location).Encounters.Count() > 0)
            {
                firstEncounter = map.LocationDetails(location).Encounters.First();
            }
            if (map.LocationDetails(location).Encounters.Count() > 1)
            {
                secondEncounter = map.LocationDetails(location).Encounters[1];
            }
            if (firstEncounter != null)
            {
                bool encounterCancelled = false;
                foreach (Hunter h in Hunters)
                {
                    int hunterIndex = IndexOfHunter(h);
                    if (h.CurrentLocation == location)
                    {
                        if (ui.AskIfHunterIsPlayingSecretWeapon(h.Name))
                        {

                            DiscardEventFromHunterAtIndex("Secret Weapon", hunterIndex, ui);
                            Logger.WriteToDebugLog(h.Name + " played Secret Weapon");
                            Logger.WriteToGameLog(h.Name + " played Secret Weapon");
                            EventDetail draculaEventCardA = Dracula.WillPlayDevilishPower(this, ui);
                            bool eventIsCancelled = false;
                            if (draculaEventCardA != null)
                            {
                                switch (draculaEventCardA.name)
                                {
                                    case "DevilishPower":
                                        ui.TellUser("Dracula played Devilish power to cancel this event");
                                        Logger.WriteToDebugLog("Dracula played Devilish Power");
                                        DiscardEventFromDracula("Devilish Power");
                                        int hunterPlayingGoodluck = ui.AskWhichHunterIsUsingGoodLuckToCancelEvent();
                                        if (hunterPlayingGoodluck > -1)
                                        {
                                            DiscardEventFromHunterAtIndex("Good Luck", hunterPlayingGoodluck, ui);
                                        }
                                        else
                                        {
                                            eventIsCancelled = true;
                                        }
                                        break;
                                }
                            }
                            if (!eventIsCancelled)
                            {
                                PlaySecretWeaponBeforeEncounter(hunterIndex, ui);
                            }
                        }
                        EventDetail draculaEventCard;
                        if (ui.AskIfHunterIsPlayingForeWarned(h.Name))
                        {
                            draculaEventCard = Dracula.WillPlayDevilishPower(this, ui);
                            bool eventIsCancelled = false;
                            if (draculaEventCard != null)
                            {
                                switch (draculaEventCard.name)
                                {
                                    case "DevilishPower":
                                        ui.TellUser("Dracula played Devilish power to cancel this event");
                                        DiscardEventFromDracula("Devilish Power");
                                        int hunterPlayingGoodluck = ui.AskWhichHunterIsUsingGoodLuckToCancelEvent();
                                        if (hunterPlayingGoodluck > -1)
                                        {
                                            DiscardEventFromHunterAtIndex("Good Luck", hunterPlayingGoodluck, ui);
                                        }
                                        else
                                        {
                                            eventIsCancelled = true;
                                        }

                                        break;
                                }
                            }
                            if (!eventIsCancelled)
                            {
                                PlayForewarnedBeforeEncounter(hunterIndex, ui);
                                encounterCancelled = true;
                            }
                        }
                    }
                }
                if (encounterCancelled)
                {
                    resolveNextEncounter = true;
                    discardEncounter = true;
                }
                else
                {
                    resolveNextEncounter = ResolveEncounter(firstEncounter, hunter, out discardEncounter, ui);
                }
                if (discardEncounter)
                {
                    map.LocationDetails(location).Encounters.Remove(firstEncounter);
                    EncounterPool.Add(firstEncounter);
                    firstEncounter.isRevealed = false;
                }
                else if (firstEncounter.name == "Bats" || firstEncounter.name == "Fog")
                {
                    EncounterLimbo.Add(firstEncounter);
                    map.LocationDetails(location).Encounters.Remove(firstEncounter);
                }
            }
            if (secondEncounter != null)
            {
                bool encounterCancelled = false;
                foreach (Hunter h in Hunters)
                {
                    int hunterIndex = IndexOfHunter(h);
                    if (h.CurrentLocation == location)
                    {
                        if (ui.AskIfHunterIsPlayingSecretWeapon(h.Name))
                        {

                            DiscardEventFromHunterAtIndex("Secret Weapon", hunterIndex, ui);
                            Logger.WriteToDebugLog(h.Name + " played Secret Weapon");
                            Logger.WriteToGameLog(h.Name + " played Secret Weapon");
                            EventDetail draculaEventCardA = Dracula.WillPlayDevilishPower(this, ui);
                            bool eventIsCancelled = false;
                            if (draculaEventCardA != null)
                            {
                                switch (draculaEventCardA.name)
                                {
                                    case "DevilishPower":
                                        ui.TellUser("Dracula played Devilish power to cancel this event");
                                        Logger.WriteToDebugLog("Dracula played Devilish Power");
                                        DiscardEventFromDracula("Devilish Power");
                                        int hunterPlayingGoodluck = ui.AskWhichHunterIsUsingGoodLuckToCancelEvent();
                                        if (hunterPlayingGoodluck > -1)
                                        {
                                            DiscardEventFromHunterAtIndex("Good Luck", hunterPlayingGoodluck, ui);
                                        }
                                        else
                                        {
                                            eventIsCancelled = true;
                                        }
                                        break;
                                }
                            }
                            if (!eventIsCancelled)
                            {
                                PlaySecretWeaponBeforeEncounter(hunterIndex, ui);
                            }
                        }
                        EventDetail draculaEventCard;
                        if (ui.AskIfHunterIsPlayingForeWarned(h.Name))
                        {
                            draculaEventCard = Dracula.WillPlayDevilishPower(this, ui);
                            bool eventIsCancelled = false;
                            if (draculaEventCard != null)
                            {
                                switch (draculaEventCard.name)
                                {
                                    case "DevilishPower":
                                        ui.TellUser("Dracula played Devilish power to cancel this event");
                                        DiscardEventFromDracula("Devilish Power");
                                        int hunterPlayingGoodluck = ui.AskWhichHunterIsUsingGoodLuckToCancelEvent();
                                        if (hunterPlayingGoodluck > -1)
                                        {
                                            DiscardEventFromHunterAtIndex("Good Luck", hunterPlayingGoodluck, ui);
                                        }
                                        else
                                        {
                                            eventIsCancelled = true;
                                        }

                                        break;
                                }
                            }
                            if (!eventIsCancelled)
                            {
                                PlayForewarnedBeforeEncounter(hunterIndex, ui);
                                encounterCancelled = true;
                            }
                        }
                    }
                }
                if (encounterCancelled)
                {
                    resolveNextEncounter = true;
                    discardEncounter = true;
                }
                else
                {
                    resolveNextEncounter = ResolveEncounter(secondEncounter, hunter, out discardEncounter, ui);
                }
                if (discardEncounter)
                {
                    map.LocationDetails(location).Encounters.Remove(secondEncounter);
                    EncounterPool.Add(secondEncounter);
                }
                else if (secondEncounter.name == "Bats" || secondEncounter.name == "Fog")
                {
                    EncounterLimbo.Add(secondEncounter);
                    map.LocationDetails(location).Encounters.Remove(secondEncounter);
                }
            }
            return resolveNextEncounter;
        }