Beispiel #1
0
        private void ButtonOk_Click(object sender, EventArgs e)
        {
            var card = Card.FindCard(new Card(
                                         (Color)comboBoxColor.SelectedValue,
                                         (Shape)comboBoxShape.SelectedValue,
                                         (Fill)comboBoxFill.SelectedValue,
                                         (Count)comboBoxCount.SelectedValue).GetHashCode());

            Console.WriteLine(card);

            // Ensure existing card is kept around.
            if (_button.Tag is Card existing)
            {
                _game.RemoveCardFromPlay(existing, false);
            }

            _game.AddCardToEnd(card);

            this.Close();
        }
Beispiel #2
0
        public void SetState(GameState gameState)
        {
            if (gameState != null)
            {
                // Reset current gamestate.
                Card.ResetCards();

                var removedFromDeck = new List <int>(gameState.InPlay.Length + gameState.Won.Length);

                for (var i = 0; i < gameState.InPlay.Length; i++)
                {
                    Card.FindCard(gameState.InPlay[i]).ChangeStatusTo(Position.Play);
                }

                for (var i = 0; i < gameState.Won.Length; i++)
                {
                    Card.FindCard(gameState.Won[i]).ChangeStatusTo(Position.Won);
                }

                UpdateCards?.Invoke();
                CalculateOptionsForAllCards();
            }
        }