Пример #1
0
        public virtual List <Card> selectCardsOrNone(List <Card> fromList, int nUpToCardsToSelect, string question, string extraName = "none")
        {
            List <Card> resChoise = new List <Card>();

            for (int i = 0; i < nUpToCardsToSelect; ++i)
            {
                int decidedIndex = makeDescision(CardChoiseContext.WithNoneOption(fromList, question, extraName)) - 1;
                if (decidedIndex < 0)
                {
                    return(resChoise);
                }
                resChoise.Add(fromList[decidedIndex]);
                fromList.RemoveAt(decidedIndex);
            }
            return(resChoise);
        }
Пример #2
0
 public virtual int chooseUnitsPlaceInRow(List <Unit> neigthboors)
 {
     return(makeDescision(CardChoiseContext.WithNoneOption(neigthboors, "Select a unit to left", "Become the most left")));
 }
Пример #3
0
        public static int deckCreatingDialog(
            List <Card> deckCards,
            List <Card> collectionCads,
            ConsoleWindowText deckWindow,
            ConsoleWindowText collectionWindow,
            ConsoleWindowText descriptionWindow,
            ConsoleWindowText console)
        {
            CardChoiseContext choiseCollection =
                CardChoiseContext.WithNoneOption(collectionCads, "COLLECTION", "Finish deck building");
            CardChoiseContext choiseDeck =
                CardChoiseContext.WithNoneOption(deckCards, "DECK", "Save deck");

            // turning a deck into Card and Count

            Console.CursorVisible = false;

            PreviewType wasPreviewType = previewType;

            previewType = PreviewType.inCollection;

            collectionWindow.ClearLogWindow();
            collectionWindow.AddLog((choiseCollection.Question.Length == 0 ? "Make a descision:" : (choiseCollection.Question + ":")).PadRight(collectionWindow.Width), ConsoleColor.Yellow, ConsoleColor.DarkGreen);
            int collectionSelected = 0, collectionFromIndex = 0, deckSelected = 0, deckFromIndex = 0;

            RedrawScrollCollection(null, choiseCollection.ChoiseOptions, 0, 0, collectionWindow);
            RedrawScrollCollection(null, choiseDeck.ChoiseOptions, 0, 0, deckWindow);
            while (true)
            {
                RedrawScrollCollection(null, choiseCollection.ChoiseOptions, collectionSelected, collectionFromIndex, collectionWindow, true);
                RedrawScrollCollection(null, choiseDeck.ChoiseOptions, deckSelected, deckFromIndex, deckWindow, false);
                ScrollChooser(ref collectionSelected, ref collectionFromIndex, choiseCollection, collectionWindow, descriptionWindow, ConsoleKey.Tab, ConsoleKey.LeftArrow,
                              RedrawScrollCollection,
                              () =>
                {
                    if (collectionSelected == 0)
                    {
                        return;
                    }
                    deckCards.Add(collectionCads[collectionSelected - 1].spawnCard());
                    choiseDeck = CardChoiseContext.WithNoneOption(deckCards, "DECK", "Save deck");
                    RedrawScrollCollection(null, choiseDeck.ChoiseOptions, deckSelected, deckFromIndex, deckWindow, false);
                    DeckBuilder.Check(deckCards, console);
                });
                RedrawScrollCollection(null, choiseCollection.ChoiseOptions, collectionSelected, collectionFromIndex, collectionWindow, false);
                RedrawScrollCollection(null, choiseDeck.ChoiseOptions, deckSelected, deckFromIndex, deckWindow, true);
                ScrollChooser(ref deckSelected, ref deckFromIndex, choiseDeck, deckWindow, descriptionWindow, ConsoleKey.Tab, ConsoleKey.RightArrow,
                              RedrawScrollCollection,
                              () =>
                {
                    if (deckSelected == 0)
                    {
                        return;
                    }
                    choiseDeck.RemoveAt(deckSelected);
                    if (deckSelected >= choiseDeck.OptionsCount)
                    {
                        deckSelected = choiseDeck.OptionsCount - 1;
                    }
                    deckWindow.ClearLogWindow();
                    RedrawScrollCollection(null, choiseDeck.ChoiseOptions, deckSelected, deckFromIndex, deckWindow);
                    DeckBuilder.Check(deckCards, console);
                });
            }
            choiseCollection.HighlightSelected(-1);
            collectionWindow.ClearLogWindow();

            previewType = wasPreviewType;
            return(collectionSelected);
        }