Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TraditionalCard"/> class.
        /// </summary>
        /// <param name="type">The card suit. Supports only a single value.</param>
        /// <param name="value">The card's value. Only single values are
        /// supported.</param>
        /// <param name="holdingCardCollection">The holding card collection.</param>
        internal TraditionalCard(CardSuit type, CardValue value,
                                 CardPacket holdingCardCollection)
        {
            // Check for single type
            switch (type)
            {
            case CardSuit.Club:
            case CardSuit.Diamond:
            case CardSuit.Heart:
            case CardSuit.Spade:
                break;

            default:
            {
                throw new ArgumentException(
                          "type must be single value", "type");
            }
            }

            // Check for single value
            switch (value)
            {
            case CardValue.Ace:
            case CardValue.Two:
            case CardValue.Three:
            case CardValue.Four:
            case CardValue.Five:
            case CardValue.Six:
            case CardValue.Seven:
            case CardValue.Eight:
            case CardValue.Nine:
            case CardValue.Ten:
            case CardValue.Jack:
            case CardValue.Queen:
            case CardValue.King:
            case CardValue.FirstJoker:
            case CardValue.SecondJoker:
                break;

            default:
            {
                throw new ArgumentException(
                          "value must be single value", "value");
            }
            }

            Type  = type;
            Value = value;
            HoldingCardCollection = holdingCardCollection;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CardsGame"/> class.
        /// </summary>
        /// <param name="decks">The amount of decks in the game.</param>
        /// <param name="jokersInDeck">The amount of jokers in each deck.</param>
        /// <param name="suits">The suits which will appear in each deck. Multiple 
        /// values can be supplied using flags.</param>
        /// <param name="cardValues">The card values which will appear in each deck. 
        /// Multiple values can be supplied using flags.</param>
        /// <param name="minimumPlayers">The minimal amount of players 
        /// for the game.</param>
        /// <param name="maximumPlayers">The maximal amount of players 
        /// for the game.</param>
        /// <param name="tableBounds">The table bounds.</param>
        /// <param name="dealerPosition">The dealer position.</param>
        /// <param name="placeOrder">A function which translates a player's index to
        /// his rendering location on the game table.</param>
        /// <param name="theme">The name of the theme to use for the 
        /// game's assets.</param>
        /// <param name="game">The associated game object.</param>
        public CardsGame(int decks, int jokersInDeck, CardSuit suits, CardValue cardValues,
            int minimumPlayers, int maximumPlayers, GameTable gameTable, string theme, Game game)
        {
            rules = new List<GameRule>();
            players = new List<Player>();
            dealer = new CardPacket(decks, jokersInDeck, suits, cardValues);

            Game = game;
            MinimumPlayers = minimumPlayers;
            MaximumPlayers = maximumPlayers;

            this.Theme = theme;
            cardsAssets = new Dictionary<string, Texture2D>();
            GameTable = gameTable;
            GameTable.DrawOrder = -10000;
            game.Components.Add(GameTable);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CardsGame"/> class.
        /// </summary>
        /// <param name="decks">The amount of decks in the game.</param>
        /// <param name="jokersInDeck">The amount of jokers in each deck.</param>
        /// <param name="suits">The suits which will appear in each deck. Multiple
        /// values can be supplied using flags.</param>
        /// <param name="cardValues">The card values which will appear in each deck.
        /// Multiple values can be supplied using flags.</param>
        /// <param name="minimumPlayers">The minimal amount of players
        /// for the game.</param>
        /// <param name="maximumPlayers">The maximal amount of players
        /// for the game.</param>
        /// <param name="tableBounds">The table bounds.</param>
        /// <param name="dealerPosition">The dealer position.</param>
        /// <param name="placeOrder">A function which translates a player's index to
        /// his rendering location on the game table.</param>
        /// <param name="theme">The name of the theme to use for the
        /// game's assets.</param>
        /// <param name="game">The associated game object.</param>
        public CardsGame(int decks, int jokersInDeck, CardSuit suits, CardValue cardValues,
                         int minimumPlayers, int maximumPlayers, GameTable gameTable, string theme, Game game)
        {
            rules   = new List <GameRule>();
            players = new List <Player>();
            dealer  = new CardPacket(decks, jokersInDeck, suits, cardValues);

            Game           = game;
            MinimumPlayers = minimumPlayers;
            MaximumPlayers = maximumPlayers;

            this.Theme          = theme;
            cardsAssets         = new Dictionary <string, Texture2D>();
            GameTable           = gameTable;
            GameTable.DrawOrder = -10000;
            game.Components.Add(GameTable);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Load the basic contents for a card game (the card assets)
        /// </summary>
        public void LoadContent()
        {
            SpriteBatch = new SpriteBatch(Game.GraphicsDevice);
            // Initialize a full deck
            CardPacket fullDeck = new CardPacket(1, 2, CardSuit.AllSuits,
                                                 CardsFramework.CardValue.NonJokers | CardsFramework.CardValue.Jokers);
            string assetName;

            // Load all card assets
            for (int cardIndex = 0; cardIndex < 54; cardIndex++)
            {
                assetName = UIUtilty.GetCardAssetName(fullDeck[cardIndex]);
                LoadUITexture("Cards", assetName);
            }
            // Load card back picture
            LoadUITexture("Cards", "CardBack_" + Theme);

            // Load the game's font
            Font = Game.Content.Load <SpriteFont>(string.Format(@"Fonts\Regular"));

            GameTable.Initialize();
        }
Exemplo n.º 5
0
 /// <summary>
 /// Moves the card from its current <see cref="CardPacket"/> to the specified <paramref name="hand"/>.
 /// This method of operation prevents any one card instance from being held by more than one
 /// <see cref="CardPacket"/> at the same time.
 /// </summary>
 /// <param name="hand">The receiving hand.</param>
 public void MoveToHand(Hand hand)
 {
     HoldingCardCollection.Remove(this);
     HoldingCardCollection = hand;
     hand.Add(this);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="TraditionalCard"/> class.
        /// </summary>
        /// <param name="type">The card suit. Supports only a single value.</param>
        /// <param name="value">The card's value. Only single values are 
        /// supported.</param>
        /// <param name="holdingCardCollection">The holding card collection.</param>
        internal TraditionalCard(CardSuit type, CardValue value,
            CardPacket holdingCardCollection)
        {
            // Check for single type
            switch (type)
            {
                case CardSuit.Club:
                case CardSuit.Diamond:
                case CardSuit.Heart:
                case CardSuit.Spade:
                    break;
                default:
                    {
                        throw new ArgumentException(
                            "type must be single value", "type");
                    }
            }

            // Check for single value
            switch (value)
            {
                case CardValue.Ace:
                case CardValue.Two:
                case CardValue.Three:
                case CardValue.Four:
                case CardValue.Five:
                case CardValue.Six:
                case CardValue.Seven:
                case CardValue.Eight:
                case CardValue.Nine:
                case CardValue.Ten:
                case CardValue.Jack:
                case CardValue.Queen:
                case CardValue.King:
                case CardValue.FirstJoker:
                case CardValue.SecondJoker:
                    break;
                default:
                    {
                        throw new ArgumentException(
                            "value must be single value", "value");
                    }
            }

            Type = type;
            Value = value;
            HoldingCardCollection = holdingCardCollection;
        }
 /// <summary>
 /// Moves the card from its current <see cref="CardPacket"/> to the specified <paramref name="hand"/>. 
 /// This method of operation prevents any one card instance from being held by more than one
 /// <see cref="CardPacket"/> at the same time.
 /// </summary>
 /// <param name="hand">The receiving hand.</param>
 public void MoveToHand(Hand hand)
 {
     HoldingCardCollection.Remove(this);
     HoldingCardCollection = hand;
     hand.Add(this);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Load the basic contents for a card game (the card assets)
        /// </summary>
        public void LoadContent()
        {
            SpriteBatch = new SpriteBatch(Game.GraphicsDevice);
            // Initialize a full deck
            CardPacket fullDeck = new CardPacket(1, 2, CardSuit.AllSuits,
                CardsFramework.CardValue.NonJokers | CardsFramework.CardValue.Jokers);
            string assetName;

            // Load all card assets
            for (int cardIndex = 0; cardIndex < 54; cardIndex++)
            {
                assetName = UIUtilty.GetCardAssetName(fullDeck[cardIndex]);
                LoadUITexture("Cards", assetName);
            }
            // Load card back picture
            LoadUITexture("Cards", "CardBack_" + Theme);

            // Load the game's font
            Font = Game.Content.Load<SpriteFont>(string.Format(@"Fonts\Regular"));

            GameTable.Initialize();
        }