Пример #1
0
        private IGameState PlayDevelopmentCard(IGameState state, IGameActions actions)
        {
            Console.WriteLine("Which development card do you wish to play:");
            Console.WriteLine("0) None");
            int i     = 1;
            var cards = new Dictionary <int, DevelopmentCard>();

            foreach (var c in state.GetOwnDevelopmentCards().Where(c => c != DevelopmentCard.VictoryPoint))
            {
                Console.WriteLine(i + ") " + c);
                cards.Add(i, c);
                i++;
            }
            int selection = int.Parse(Console.ReadLine() ?? "0");

            if (selection == 0)
            {
                return(null);
            }
            Console.WriteLine("You played the card " + cards[selection]);
            hasPlayedDevCard = true;
            switch (cards[selection])
            {
            case DevelopmentCard.Knight:
                return(actions.PlayKnight());

            case DevelopmentCard.Monopoly:
                Console.WriteLine("Choose the resource type to get monopoly on");
                return(actions.PlayMonopoly(selectResource()));

            case DevelopmentCard.RoadBuilding:
                Console.WriteLine("Decide where to build the two roads");
                var road1 = getRoadPosition();
                var road2 = getRoadPosition();
                return(actions.PlayRoadBuilding(road1, road2));

            case DevelopmentCard.YearOfPlenty:
                Console.WriteLine("Choose which two resources you want to draw");
                return(actions.PlayYearOfPlenty(selectResource(), selectResource()));
            }
            return(null);
        }
Пример #2
0
 private IGameState PlayDevelopmentCard(IGameState state, IGameActions actions)
 {
     Console.WriteLine("Which development card do you wish to play:");
     Console.WriteLine("0) None");
     int i = 1;
     var cards = new Dictionary<int, DevelopmentCard>();
     foreach (var c in state.GetOwnDevelopmentCards().Where(c => c != DevelopmentCard.VictoryPoint))
     {
         Console.WriteLine(i + ") " + c);
         cards.Add(i, c);
         i++;
     }
     int selection = int.Parse(Console.ReadLine() ?? "0");
     if (selection == 0) return null;
     Console.WriteLine("You played the card " + cards[selection]);
     hasPlayedDevCard = true;
     switch (cards[selection])
     {
         case DevelopmentCard.Knight:
             return actions.PlayKnight();
         case DevelopmentCard.Monopoly:
             Console.WriteLine("Choose the resource type to get monopoly on");
             return actions.PlayMonopoly(selectResource());
         case DevelopmentCard.RoadBuilding:
             Console.WriteLine("Decide where to build the two roads");
             var road1 = getRoadPosition();
             var road2 = getRoadPosition();
             return actions.PlayRoadBuilding(road1, road2);
         case DevelopmentCard.YearOfPlenty:
             Console.WriteLine("Choose which two resources you want to draw");
             return actions.PlayYearOfPlenty(selectResource(), selectResource());
     }
     return null;
 }