示例#1
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");
        }