Esempio n. 1
0
        /// <summary> Gets the final contract of the bidding </summary>
        /// <returns> The final contract of the bidding - an object of the class Contract </returns>
        public Contract getContract(int dealID)
        {
            Bid lastBid = getLastStrainBid();

            if (lastBid == null)
            {
                return(null);
            }
            Bid  modifier                = bidding.Last.Previous.Previous.Previous.Value;
            bool isDoubled               = modifier.getValue() == "X";
            bool isRedoubled             = modifier.getValue() == "XX";
            int  declarer                = (dealID - 1) % 4;
            int  idx                     = declarer;
            LinkedListNode <Bid> current = bidding.First;

            while (current.Value != lastBid)
            {
                current = current.Next;
                idx++;
            }
            int mod = idx % 2;

            idx     = declarer;
            current = bidding.First;
            while (current.Value.getValue() != lastBid.getValue() || idx % 2 != mod)
            {
                current = current.Next;
                idx++;
                declarer++;
            }
            declarer %= 4;
            return(new Contract(lastBid.getLevel(), new Strain(lastBid.getValue()), isDoubled, isRedoubled, true, declarer == 0 ? "N" : declarer == 1 ? "E" : declarer == 2 ? "S" : "W"));
        }
Esempio n. 2
0
 public bool compare(Bid other)
 {
     if (other == null)
     {
         return(true);
     }
     if (level > other.getLevel())
     {
         return(true);
     }
     if (level == other.getLevel())
     {
         string[] ranks = new string[5] {
             "C", "D", "H", "S", "NT"
         };
         return(Array.IndexOf(ranks, strain.value) > Array.IndexOf(ranks, other.getValue()));
     }
     return(false);
 }