/// <summary>Convert the bid to a XML string</summary> /// <returns>String</returns> public string ToXML() { string s; switch (this.special) { case SpecialBids.Pass: s = "Pass"; break; case SpecialBids.Double: s = "X"; break; case SpecialBids.Redouble: s = "XX"; break; case SpecialBids.NormalBid: s = ((int)this.level).ToString() + SuitHelper.ToXML(this.suit); break; default: return("?"); } if (this.alert) { s += "!"; } return(s); }
/// <summary>Convert the bid to a localized string</summary> /// <returns>String</returns> public string ToText() { switch (this.special) { case SpecialBids.Pass: return(LocalizationResources.Pass); case SpecialBids.Double: return("x"); case SpecialBids.Redouble: return("xx"); case SpecialBids.NormalBid: return(((int)this.level).ToString() + SuitHelper.ToLocalizedString(this.suit)); default: return("?"); } }
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); } } }
/// <summary>Convert the bid to a string</summary> /// <returns>String</returns> public override string ToString() { switch (this.special) { case SpecialBids.Pass: return("Pass"); case SpecialBids.Double: return("x"); case SpecialBids.Redouble: return("xx"); case SpecialBids.NormalBid: //return ((int)this.level).ToString() + (this.suit == Suits.NoTrump // ? SuitConverter.ToXML(this.suit) // : "" + SuitConverter.ToChar(this.suit)); return(((int)this.level).ToString() + SuitHelper.ToXML(this.suit)); default: return("?"); } }
private void SeatSuit2String(Seats seat, Suits suit, StringBuilder result) { result.Append(SuitHelper.ToXML(suit) + " "); int length = 0; for (Ranks rank = Ranks.Ace; rank >= Ranks.Two; rank--) { if (this.Owns(seat, suit, rank)) { result.Append(Rank.ToXML(rank)); length++; } } for (int l = length + 1; l <= 13; l++) { result.Append(" "); } }
/// <summary>Convert the bid to a digit and a special suit character</summary> /// <returns>String</returns> public string ToSymbol() { string result = string.Empty; switch (this.special) { case SpecialBids.Pass: result = LocalizationResources.Pass; break; case SpecialBids.Double: result = "x"; break; case SpecialBids.Redouble: result = "xx"; break; case SpecialBids.NormalBid: result = ((int)this.level).ToString() + (this.suit == Suits.NoTrump ? LocalizationResources.NoTrump : "" + SuitHelper.ToUnicode(this.suit)); break; default: result = "?"; break; } if (this.alert) { result += "!"; } return(result); }
/// <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; } }
public override string ToString() { return("" + SuitHelper.ToLocalizedString(Suit).ToLowerInvariant() + Bridge.Rank.ToXML(Rank)); }
public Card(string cardDescription) : this(SuitHelper.FromXML(cardDescription.Substring(0, 1)), Bridge.Rank.From(cardDescription.Substring(1, 1))) { }
public override string ToString() { return(SuitHelper.ToParser(this.Suit).ToLowerInvariant() + Bridge.Rank.ToXML(this.Rank)); }
public override string ToString() { return("" + SuitHelper.ToString(Suit) + Bridge.Rank.ToXML(Rank)); }