/// <summary>Alter the bid</summary> /// <param name="l">Level of the bid</param> /// <param name="s">Suit of the bid</param> /// <param name="alert">Alert the bid</param> public void Set(int l, Suits s, bool alert) { if (l > 7 || l < 0) { throw new FatalBridgeException("level must be 1..7: {0}", l); } this.special = SpecialBids.NormalBid; this.suit = s; this.level = (BidLevels)l; this.alert = alert; }
/// <summary>Constructor</summary> /// <param name="s">Suit of the bid</param> /// <param name="l">Level of the bid</param> public Bid(Suits s, BidLevels l) { if (l > BidLevels.Level7) { throw new ArgumentOutOfRangeException("l", l.ToString()); } if (s > Suits.NoTrump) { throw new ArgumentOutOfRangeException("s", s.ToString()); } this.suit = s; this.level = l; this.special = SpecialBids.NormalBid; this.explanation = ""; this.alert = false; this.Hint = false; }
/// <summary>Constructor</summary> /// <param name="index">Index of the bid</param> /// <param name="newExplanation">Explanation of the bid</param> public Bid(int index, string newExplanation, bool alert, string newHumanExplanation) { switch (index) { case 0: this.level = BidLevels.Pass; this.special = SpecialBids.Pass; break; case 36: this.level = BidLevels.Pass; this.special = SpecialBids.Double; break; case 37: this.level = BidLevels.Pass; this.special = SpecialBids.Redouble; break; default: { if (index > 35) { throw new FatalBridgeException("invalid index: {0}", index); } this.special = SpecialBids.NormalBid; this.suit = (Suits)((index - 1) % 5); this.level = (BidLevels)(((index - 1) / 5) + 1); break; } } if (this.level > BidLevels.Level7) { throw new InvalidCastException("level " + this.level.ToString()); } if (this.suit > Suits.NoTrump) { throw new InvalidCastException("suit " + this.suit.ToString()); } this.explanation = newExplanation; this.alert = alert; this.humanExplanation = newHumanExplanation; }
/// <summary>Constructor</summary> public void SetRedoublet() { this.special = SpecialBids.Redouble; this.level = BidLevels.Pass; this.alert = false; }
/// <summary>Constructor</summary> public void SetPass() { this.special = SpecialBids.Pass; this.level = BidLevels.Pass; this.alert = false; }
/// <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; } }
/// <summary>Constructor</summary> /// <param name="specialBid">Special bid</param> public Bid(SpecialBids specialBid) { this.special = specialBid; this.level = BidLevels.Pass; this.explanation = ""; }