コード例 #1
0
ファイル: Board.cs プロジェクト: pboninsk/ComputerBridge
        private void ParseSuit(string cards, Seats owner)
        {
            /// s AKQ63
            /// S A K Q 6 3
            Suits s = SuitHelper.FromXML(cards.Substring(0, 1));

            cards = cards.Substring(1);
            for (int i = 0; i < cards.Length; i++)
            {
                if (cards[i] != ' ' && cards[i] != '-')
                {
                    Ranks r = Rank.From(cards[i]);
                    this.theDistribution.Give(owner, s, r);
                }
            }
        }
コード例 #2
0
        /// <summary>Constructor</summary>
        /// <param name="fromXML">XML describing the bid</param>
        public Bid(string fromXML)
        {
            if (fromXML == null)
            {
                throw new ArgumentNullException("fromXML");
            }
            this.explanation = "";
            if (fromXML.Contains(";"))
            {
                string[] parts = fromXML.Split(';');
                if (parts.Length >= 2)
                {
                    this.explanation = parts[1];
                }
                if (parts.Length >= 3)
                {
                    this.humanExplanation = parts[2];
                }
                fromXML = parts[0];
            }

            if (fromXML.Contains("!"))
            {
                int p = fromXML.IndexOf('!');
                this.explanation = fromXML.Substring(p + 1);
                fromXML          = fromXML.Substring(0, p);
                this.NeedsAlert();
            }

            switch (fromXML.ToLowerInvariant())
            {
            case "p":
            case "pass":
            case "passes":
                this.level   = BidLevels.Pass;
                this.special = SpecialBids.Pass;
                break;

            case "x":
            case "dbl":
            case "double":
            case "doubles":
            case "36":
                this.level   = BidLevels.Pass;
                this.special = SpecialBids.Double;
                break;

            case "xx":
            case "rdbl":
            case "redouble":
            case "redoubles":
            case "37":
                this.level   = BidLevels.Pass;
                this.special = SpecialBids.Redouble;
                break;

            default:
                this.special = SpecialBids.NormalBid;
                this.level   = (BidLevels)(Convert.ToByte(fromXML[0]) - 48);
                this.suit    = SuitHelper.FromXML(fromXML.Substring(1));
                break;
            }
        }
コード例 #3
0
 public Card(string cardDescription) : this(SuitHelper.FromXML(cardDescription.Substring(0, 1)), Bridge.Rank.From(cardDescription.Substring(1, 1)))
 {
 }