コード例 #1
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.SetWindowSize(Console.LargestWindowWidth, Console.LargestWindowHeight);
            SolitaireGame solitaire = new SolitaireGame();

            solitaire.Play();
        }
コード例 #2
0
 public void clearGame()
 {
     this.currentGame.removeMenuElements(this.MainMenu);
     this.currentGame.removeInfoElements(this.Info);
     this.currentGame.clear();
     this.MainCanvas.Children.Clear();
     this.currentGame = null;
 }
コード例 #3
0
        public Options(SolitaireGame game)
        {
            InitializeComponent();

            this.setupKeyboardShortcuts();
            this.updateUi();
            this.init = false;
        }
コード例 #4
0
 public override void Init(StateMachine machine)
 {
     game = (SolitaireGame)machine;
     game.SelectedStackIndex = -1;
     game.StatusMessages.Clear();
     game.StatusMessages.Add("Press a number to select a stack.");
     game.DrawGame();
     input = new ConsoleInput();
 }
コード例 #5
0
 public override void Init(StateMachine machine)
 {
     game = (SolitaireGame)machine;
     game.StatusMessages.Clear();
     game.StatusMessages.Add("What would you like to do next?");
     game.StatusMessages.Add("Press up/down arrows to decide how many cards to move.");
     game.StatusMessages.Add("Press a 0-9 to select a destination.");
     game.DrawGame();
     input = new ConsoleInput();
 }
コード例 #6
0
ファイル: SolitaireDrawer.cs プロジェクト: ntwiles/card-games
        public void DrawSolitaireGame(SolitaireGame game, CardStack deck, CardStack drawStack, List <StackColumn> columns, List <string> messages)
        {
            Console.Clear();

            drawGame(game, deck, drawStack, columns);

            drawTitle(solitaireTitle);

            writeMessages(messages);
        }
コード例 #7
0
        public void selectGame(Type gameType)
        {
            if (this.currentGame != null)
            {
                if (this.currentGame.GetType() == gameType)
                {
                    this.currentGame.restart();
                    return;
                }

                this.clearGame();
            }

            this.currentGame = (SolitaireGame)Activator.CreateInstance(gameType, new object[] { this.MainCanvas });
            this.currentGame.addMenuElements(this.MainMenu);
            this.currentGame.addInfoElements(this.Info);
            this.currentGame.positionResizeElements();
            this.Title = this.currentGame.getTitle();

            Data.SelectedGame = this.currentGame.getGameKey();
        }
コード例 #8
0
ファイル: SolitaireDrawer.cs プロジェクト: ntwiles/card-games
        // TODO: Abstract each step into its own method.
        private void drawGame(SolitaireGame game, CardStack deck, CardStack drawStack, List <StackColumn> columns)
        {
            var cardDrawer = new CardDrawer();

            // Draw the stack number for the draw stack.
            int posX = GAME_PADDING_X + STACK_SPAN + STACK_NUMBER_LOCAL_OFFSET;
            int posY = GAME_PADDING_Y;

            drawStackNumber(posX, posY, 0, game.SelectedStackIndex == 0);

            // Draw the deck.
            if (deck.Count > 0)
            {
                posX = GAME_PADDING_X;
                posY = GAME_PADDING_Y + DRAW_STACK_OFFSET_Y;
                cardDrawer.DrawCard(posX, posY);
            }

            // Draw the draw stack.
            if (drawStack.Count > 0)
            {
                posX = GAME_PADDING_X + STACK_SPAN;
                posY = GAME_PADDING_Y + DRAW_STACK_OFFSET_Y;
                bool highlight = game.SelectedStackIndex == 0;
                cardDrawer.DrawCard(posX, posY, drawStack[drawStack.Count - 1], highlight);
            }

            for (int i = 0; i < columns.Count; i++)
            {
                CardStack faceDownStack = columns[i].FaceDownStack;
                CardStack faceUpStack   = columns[i].FaceUpStack;

                // Draw the stack numbers for the main stack.
                posX = GAME_PADDING_X + i * STACK_SPAN + STACK_NUMBER_LOCAL_OFFSET;
                posY = GAME_PADDING_Y + MAIN_STACK_OFFSET_Y;
                drawStackNumber(posX, posY, i + 1, game.SelectedStackIndex == i + 1);

                // Draw face down cards.
                if (faceDownStack.Count > 0 && faceUpStack.Count == 0)
                {
                    // There's nothing covering them.
                    posX = GAME_PADDING_X + i * STACK_SPAN;
                    posY = GAME_PADDING_Y + MAIN_STACK_OFFSET_Y + 1;
                    cardDrawer.DrawCard(posX, posY);
                }
                else if (faceDownStack.Count > 0)
                {
                    // There are face up cards on top, only draw a sliver.
                    posX = GAME_PADDING_X + i * STACK_SPAN;
                    posY = GAME_PADDING_Y + MAIN_STACK_OFFSET_Y + 1;
                    cardDrawer.DrawCardSliverTop(posX, posY);
                }

                int numDrawnCards = 0;

                bool stackHighlighted = game.SelectedStackIndex == i + 1;

                // Draw face up cards.
                for (int ii = 0; ii < faceUpStack.Count; ii++)
                {
                    Card card = faceUpStack[ii];

                    int  invertedCardNum = faceUpStack.Count - ii;
                    bool cardHighlighted = game.NumCardsSelected >= invertedCardNum;
                    bool highlight       = stackHighlighted && cardHighlighted;

                    // Draw the top card at full length.
                    if (ii == faceUpStack.Count - 1)
                    {
                        posX = GAME_PADDING_X + i * STACK_SPAN;
                        posY = GAME_PADDING_Y + MAIN_STACK_OFFSET_Y + MAIN_STACK_SECONDARY_OFFSET_Y + numDrawnCards * 2;

                        cardDrawer.DrawCard(posX, posY, card, highlight);
                    }
                    // And the rest just draw partially.
                    else
                    {
                        posX = GAME_PADDING_X + i * STACK_SPAN;
                        posY = GAME_PADDING_Y + MAIN_STACK_OFFSET_Y + MAIN_STACK_SECONDARY_OFFSET_Y + numDrawnCards * 2;

                        cardDrawer.DrawFaceUpCardTop(posX, posY, card, highlight);
                        numDrawnCards++;
                    }
                }

                Console.WriteLine("\n\n\n\n\n\n\n\n");
            }
        }