示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LlConsole.Game"/> class.
        /// </summary>
        /// <param name="configuration">XML configuration.</param>
        public Game(XmlDocument configuration)
        {
            if (configuration == null)
                        {
                                throw new ArgumentNullException(
                                        "configuration",
                                        "Cannot create new game with empty XML");
                        }

                        XmlNodeList dice = configuration.GetElementsByTagName("Dice");
                        if (dice.Count > 0)
                        {
                                this.diceCount = XmlHelper.FromXmlIfExists<int>(dice[0], "Count", this.diceCount);
                                this.diceSides = XmlHelper.FromXmlIfExists<int>(dice[0], "Sides", this.diceSides);
                        }

                        XmlNodeList props = configuration.GetElementsByTagName("Location");
                        foreach (XmlNode prop in props)
                        {
                                var l = new Location(prop);
                                this.Add(l);
                        }

                        Location.SetBoard(this.Board);

                        XmlNodeList peeps = configuration.GetElementsByTagName("Player");
                        foreach (XmlNode pers in peeps)
                        {
                                var p = new Player(pers);
                                p.Where = this.Board[0];
                                this.Add(p);
                        }

                        XmlNodeList cards = configuration.GetElementsByTagName("FirstCard");
                        foreach (XmlNode card in cards)
                        {
                                var c = new Card(card);
                                this.Add(c, false);
                        }

                        cards = configuration.GetElementsByTagName("SecondCard");
                        foreach (XmlNode card in cards)
                        {
                                var c = new Card(card);
                                this.Add(c, true);
                        }
        }
示例#2
0
 /// <summary>
 /// Add the specified card to the correct.
 /// </summary>
 /// <param name="c">The new card.</param>
 /// <param name="secondPile">If set to <c>true</c>, use the second pile.</param>
 public void Add(Card c, bool secondPile)
 {
     List<Card> pile = secondPile ? this.Pile2 : this.Pile1;
                 pile.Add(c);
 }