示例#1
0
 private static string GetCall(Bid bid)
 {
     if (bid.Pass)
     {
         return("Pass");
     }
     if (bid.ReDouble)
     {
         return("XX");
     }
     if (bid.Double)
     {
         return("X");
     }
     return(bid.Level.ToString()
            + PBNSuitMapper.GetstringFromSuit(bid.Suit));
 }
示例#2
0
        public static string GetstringFromContract(Contract contract)
        {
            if (contract.Level == 0)
            {
                return("Pass");
            }
            var ret = new StringBuilder();

            ret.Append(contract.Level);
            ret.Append(PBNSuitMapper.GetstringFromSuit(contract.Suit));
            if (contract.ReDoubled)
            {
                ret.Append("XX");
            }
            else if (contract.Doubled)
            {
                ret.Append("X");
            }
            return(ret.ToString());
        }
示例#3
0
        public static Contract GetContractFromstring(string contract)
        {
            if (string.IsNullOrEmpty(contract))
            {
                return(null);
            }
            Contract ret = new Contract();

            if (contract == "Pass")
            {
                return(new Contract());
            }
            var level = int.Parse(contract.Substring(0, 1));
            var suit  = PBNSuitMapper.GetSuitFromstring(contract[1].ToString());

            var reDoubled = contract.Contains("XX");
            var doubled   = false;

            if (ret.ReDoubled || contract.Contains("X"))
            {
                doubled = true;
            }
            return(new Contract(level, suit, doubled, reDoubled, Direction.South, 0));
        }