Exemplo n.º 1
0
 /// <summary>
 /// Matures an Encounter
 /// </summary>
 /// <param name="game">The GameState</param>
 /// <param name="encounterTileBeingMatured">The EncounterTile being matured</param>
 /// <param name="logic">The artificial intelligence component</param>
 private static void MatureEncounter(GameState game, EncounterTile encounterTileBeingMatured, DecisionMaker logic)
 {
     switch (encounterTileBeingMatured.Encounter)
     {
         case Encounter.Ambush:
             Console.WriteLine("Dracula matured Ambush");
             var hunterToAmbush = logic.ChooseHunterToAmbush(game);
             if (hunterToAmbush != Hunter.Nobody)
             {
                 var encounterToAmbushWith = logic.ChooseEncounterTileToAmbushHunterWith(game, hunterToAmbush);
                 ResolveEncounterTile(game, encounterToAmbushWith, new List<Hunter> { hunterToAmbush }, logic, -1);
                 game.Dracula.DiscardEncounterTile(game, encounterToAmbushWith);
                 game.EncounterPool.Add(encounterToAmbushWith);
             }
             break;
         case Encounter.DesecratedSoil:
             Console.WriteLine("Dracula matured Desecrated Soil");
             game.Dracula.ClearTrailDownTo(game, 3);
             logic.TrimAllPossibleTrails(3);
             for (var i = 0; i < 2; i++)
             {
                 Console.WriteLine(
                     "Draw an Event card. If it is a Hunter card, name it, otherwise type \"take\"");
                 var line = "";
                 var eventDrawn = Event.None;
                 do
                 {
                     line = Console.ReadLine();
                     eventDrawn = Enumerations.GetEventFromString(line);
                 } while (eventDrawn == Event.None &&
                          !"take".StartsWith(line.ToLower()));
                 if (eventDrawn == Event.None)
                 {
                     var eventPlayedByDracula = game.Dracula.TakeEvent(game.EventDeck, game.EventDiscard);
                     PlayImmediatelyDraculaCard(game, eventPlayedByDracula, logic);
                     if (game.Dracula.EventHand.Count() > game.Dracula.EventHandSize)
                     {
                         Console.WriteLine("Dracula discarded {0}", game.Dracula.DiscardEvent(logic.ChooseEventToDiscard(game), game.EventDiscard).Name());
                     }
                 }
                 else
                 {
                     var eventCardDiscarded = game.EventDeck.Find(card => card.Event == eventDrawn);
                     game.EventDeck.Remove(eventCardDiscarded);
                     game.EventDiscard.Add(eventCardDiscarded);
                 }
             }
             break;
         case Encounter.NewVampire:
             Console.WriteLine("Dracula matured a New Vampire");
             game.AdjustVampires(2);
             game.Dracula.ClearTrailDownTo(game, 1);
             logic.TrimAllPossibleTrails(1); break;
     }
     game.EncounterPool.Add(encounterTileBeingMatured);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Resolves an Encounter of Desecrated Soil for a group of Hunters
 /// </summary>
 /// <param name="game">The GameState</param>
 /// <param name="huntersInvolved">A list of Hunters involved in the Encounter</param>
 /// <param name="logic">The artificial intelligence component</param>
 /// <returns>True if the Hunters can continue resolving Encounters</returns>
 private static bool ResolveDesecratedSoil(GameState game, List<Hunter> huntersInvolved, DecisionMaker logic)
 {
     Console.WriteLine("Draw an Event card. If it is a Hunter card, name it, otherwise type \"take\"");
     var line = "";
     var eventDrawn = Event.None;
     do
     {
         line = Console.ReadLine();
         eventDrawn = Enumerations.GetEventFromString(line);
     } while (eventDrawn == Event.None && !"take".StartsWith(line.ToLower()));
     if ("take".StartsWith(line.ToLower()))
     {
         var eventPlayedByDracula = game.Dracula.TakeEvent(game.EventDeck, game.EventDiscard);
         PlayImmediatelyDraculaCard(game, eventPlayedByDracula, logic);
         if (game.Dracula.EventHand.Count() > game.Dracula.EventHandSize)
         {
             Console.WriteLine("Dracula disacarded {0}", game.Dracula.DiscardEvent(logic.ChooseEventToDiscard(game), game.EventDiscard).Name());
         }
     }
     else
     {
         var eventCardDiscarded = game.EventDeck.Find(card => card.Event == eventDrawn);
         if (eventCardDiscarded != null)
         {
             Console.WriteLine("{0} discarded", eventDrawn);
             game.EventDeck.Remove(eventCardDiscarded);
             game.EventDiscard.Add(eventCardDiscarded);
         }
     }
     return true;
 }
Exemplo n.º 3
0
        private static void Main(string[] args)
        {
            var game = new GameState();
            var logic = new DecisionMaker();

            if (args.Length > 0)
            {
                try
                {
                    game = new FileLoader().LoadGameState(args[0]);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Environment.Exit(10);
                }
            }
            else
            {
                for (var i = 1; i < 5; i++)
                {
                    Console.WriteLine("Where is {0} starting?", game.Hunters[i].Hunter.Name());
                    var destination = Location.Nowhere;
                    var line = "";
                    while (destination == Location.Nowhere ||
                           (game.Map.TypeOfLocation(destination) != LocationType.SmallCity &&
                            game.Map.TypeOfLocation(destination) != LocationType.LargeCity))
                    {
                        line = Console.ReadLine();
                        destination = Enumerations.GetLocationFromString(line);
                        Console.WriteLine(destination.Name());
                        if (game.Map.TypeOfLocation(destination) != LocationType.SmallCity &&
                            game.Map.TypeOfLocation(destination) != LocationType.LargeCity)
                        {
                            Console.WriteLine("You must start in a city");
                        }
                    }
                    game.Hunters[i].MoveTo(destination);
                }
                int rubbish = -1;
                game.Dracula.MoveTo(logic.ChooseStartLocation(game), Power.None, out rubbish);
                logic.InitialisePossibilityTree(game);
                while (game.Dracula.EncounterHand.Count() < game.Dracula.EncounterHandSize)
                {
                    game.Dracula.DrawEncounter(game.EncounterPool);
                }
                EndHunterTurn(game, logic);
            }

            var commandSet = new CommandSet();

            do
            {
                DrawGameState(game);
                commandSet = GetCommandSet();

                switch (commandSet.command)
                {
                    case "trade": TradeCardsBetweenHunters(game, commandSet.argument1, commandSet.argument2); break;
                    case "r":
                    case "rest": RestHunter(game, commandSet.argument1); break;
                    case "retrieve": RetrieveCardFromDiscard(game, commandSet.argument1, commandSet.argument2); break;
                    case "w":
                    case "water":
                        UseHolyWaterAtHospital(game, commandSet.argument1); break;
                    case "h":
                    case "help":
                        DisplayHelp(); break;
                    case "f":
                    case "front":
                        HandleEncountersInFrontOfHunter(game, commandSet.argument1, logic); break;
                    case "y":
                    case "cycle":
                        CycleDeck(game, commandSet.argument1); break;
                    case "s":
                    case "resolve":
                        SpendResolve(game, commandSet.argument1, commandSet.argument2, logic); break;
                    case "c":
                    case "catch":
                        CatchTrain(game, commandSet.argument1, logic); break;
                    case "e":
                    case "event":
                        PlayEvent(game, commandSet.argument1, commandSet.argument2, logic); break;
                    case "u":
                    case "use":
                        UseItem(game, commandSet.argument1, commandSet.argument2); break;
                    case "g":
                    case "group":
                        SetupGroup(game, commandSet.argument1); break;
                    case "t":
                    case "take":
                        var eventPlayedByDracula = game.Dracula.TakeEvent(game.EventDeck, game.EventDiscard);
                        PlayImmediatelyDraculaCard(game, eventPlayedByDracula, logic);
                        while (game.Dracula.EventHand.Count() > game.Dracula.EventHandSize)
                        {
                            Console.WriteLine("Dracula discarded {0}", game.Dracula.DiscardEvent(logic.ChooseEventToDiscard(game), game.EventDiscard).Name());
                        }; break;
                    case "reveal":
                        RevealCardInTrailAtPosition(game, commandSet.argument1); break;
                    case "z":
                    case "end":
                        EndHunterTurn(game, logic); break;
                    case "state":
                        DisplayState(game, commandSet.argument1, logic); break;
                    case "a":
                    case "discard":
                        DiscardCard(game, commandSet.argument1, commandSet.argument2); break;
                    case "d":
                    case "draw":
                        DrawCard(game, commandSet.argument1, commandSet.argument2);
                        CheckForDiscardRequired(game);
                        CheckForCardsRevealedForBeingBitten(game); break;
                    case "save":
                        SaveGameState(game, commandSet.argument1); break;
                    case "load":
                        try
                        {
                            game = new FileLoader().LoadGameState(commandSet.argument1);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                            Environment.Exit(10);
                        }
                        break;
                    case "m":
                    case "move":
                        HandleMoveOperation(game, commandSet.argument1, commandSet.argument2, logic); break;
                    case "exit":
                        Console.WriteLine("Fare well"); break;
                    default:
                        Console.WriteLine("I didn't understand that"); break;
                }
            } while (commandSet.command != "exit");
        }