/// <summary> /// Resolves the situation when Dracula plays an Ally card /// </summary> /// <param name="game">The GameState</param> /// <param name="eventPlayedByDracula">The Ally Event</param> /// <param name="logic">The artificial intelligence component</param> private static void PlayDraculaAlly(GameState game, Event eventPlayedByDracula, DecisionMaker logic) { Console.WriteLine("Dracula drew ally {0}", eventPlayedByDracula.Name()); Event allyToKeep; if (game.DraculaAlly == null) { allyToKeep = eventPlayedByDracula; } else { game.EventDiscard.Add(game.DraculaAlly); allyToKeep = logic.ChooseAllyToKeep(game, game.DraculaAlly.Event, eventPlayedByDracula); } game.DraculaAlly = game.EventDiscard.Find(card => card.Event == allyToKeep); game.EventDiscard.Remove(game.DraculaAlly); Console.WriteLine("{0} kept", allyToKeep.Name()); game.Dracula.EncounterHandSize = game.DraculaAlly.Event == Event.DraculasBrides ? 7 : 5; game.Dracula.EventHandSize = game.DraculaAlly.Event == Event.ImmanuelHildesheim ? 6 : 4; }
/// <summary> /// Determines if Dracula is playing Devilish Power to cancel an Event played by a Hunter /// </summary> /// <param name="game">The GameState</param> /// <param name="eventBeingPlayedNow">The Event being played now</param> /// <param name="eventInitiallyPlayed">The Event initially played at the beginning of this exchange</param> /// <param name="logic">The artificial intelligence component</param> /// <returns>True if Dracula successfully plays Devilish Power</returns> private static bool DraculaIsPlayingDevilishPowerToCancelEvent(GameState game, Event eventBeingPlayedNow, Event eventInitiallyPlayed, DecisionMaker logic, HunterPlayer hunterPlayingEvent) { if (logic.ChooseToCancelEventWithDevilishPower(game, eventBeingPlayedNow, eventInitiallyPlayed, hunterPlayingEvent)) { Console.WriteLine("Dracula is playing Devilish Power to cancel {0}", eventBeingPlayedNow.Name()); game.Dracula.DiscardEvent(Event.DevilishPower, game.EventDiscard); if (HunterPlayingGoodLuckToCancelDraculaEvent(game, Event.DevilishPower, eventInitiallyPlayed, logic) > 0) { return false; } return true; } return false; }
/// <summary> /// Determines if a Hunter is playing Good Luck to cancel an Event played by Dracula /// </summary> /// <param name="game">The GameState</param> /// <param name="draculaEventBeingPlayed">The Event being played now</param> /// <param name="eventInitiallyPlayed">The Event initially played at the beginning of this exchange</param> /// <param name="logic">The artificial intelligence component</param> /// <returns>An int corresponding to the Hunter playing Good Luck, 0 if none</returns> private static int HunterPlayingGoodLuckToCancelDraculaEvent(GameState game, Event draculaEventBeingPlayed, Event eventInitiallyPlayed, DecisionMaker logic) { Console.WriteLine( "Will anyone play Good Luck to cancel {0}? 0= Nobody, {1}= {2}, {3}= {4}, {5}= {6}, {7}= {8}", draculaEventBeingPlayed.Name(), (int)Hunter.LordGodalming, Hunter.LordGodalming.Name(), (int)Hunter.DrSeward, Hunter.DrSeward.Name(), (int)Hunter.VanHelsing, Hunter.VanHelsing.Name(), (int)Hunter.MinaHarker, Hunter.MinaHarker.Name()); var answer = -1; while (answer == -1) { if (int.TryParse(Console.ReadLine(), out answer)) { if (answer < 0 || answer > 4) { answer = -1; } } } if (answer > 0) { game.Hunters[answer].DiscardEvent(game, Event.GoodLuck); if (DraculaIsPlayingDevilishPowerToCancelEvent(game, Event.GoodLuck, eventInitiallyPlayed, logic, game.Hunters[answer])) { game.Dracula.DiscardEvent(Event.DevilishPower, game.EventDiscard); return 0; } } return answer; }