def bidBuilder(dictionary: dict) -> Bidding:
     if "__type__" in dictionary and dictionary["__type__"] == "Bidding":
         result = Bidding()
         result.current = dictionary["current"]
         result.whoStarts = dictionary["whoStarts"]
         result.nrOfPoints = dictionary["nrOfPoints"]
         result.nrOfCards = dictionary["nrOfCards"]
         return result
     else:
         return dictionary
Exemple #2
0
def testIsDblAllowed():
    bidding = Bidding()

    bidding.current = [ ]
    assert not bidding.isAllowed('X')

    bidding.current = [ '1♣', '2♦' ]
    assert bidding.isAllowed('X')

    bidding.current = [ '1♣', '2♦', 'pass' ]
    assert not bidding.isAllowed('X')

    bidding.current = [ '1♣', '2♦', 'X' ]
    assert not bidding.isAllowed('X')

    bidding.current = [ '1♣', '2♦', 'pass', 'pass' ]
    assert bidding.isAllowed('X')

    bidding.current = ['1♣', 'X']
    assert not bidding.isAllowed('X')
Exemple #3
0
def testSerializesBids():
    a = Bidding()
    a.current = ['pass', 'X', '1♣']
    result = bid2Json(a)
    assert result == '{"__type__": "Bidding", "current": ["pass", "X", "1♣"], "whoStarts": "N", "nrOfPoints": null, "nrOfCards": {}}'
Exemple #4
0
def testNoDblOnPartner():
    bidding = Bidding()

    bidding.current = ['X', 'X', 'pass']

    assert not bidding.isAllowed('X')
Exemple #5
0
def testRdblnoDbl():
    bidding = Bidding()

    bidding.current = ['1♣']
    assert not bidding.isAllowed('XX')
Exemple #6
0
def testDoubleRdbl():
    bidding = Bidding()

    bidding.current = ["1♣", 'XX']
    assert not bidding.isAllowed('XX')
Exemple #7
0
def testIsRdblAllowed():
    bidding = Bidding()

    bidding.current = ["1♣", 'X']
    assert bidding.isAllowed('XX')
def testLeaderN():
    bidding = Bidding()
    bidding.current = ['1♥', 'pass', '1SA', 'pass', 'pass', 'pass']
    bidding.whoStarts = north

    assert bidding.contract() == ('1SA', south)
def testLeaderW():
    bidding = Bidding()
    bidding.current = ['1♥', 'pass', '1SA', 'pass', '2♦', 'pass', 'pass', '2♥', 'pass', 'pass', '3♣', 'pass', 'pass', 'pass']
    bidding.whoStarts = east

    assert bidding.contract() == ('3♣', west)