Exemplo n.º 1
0
def move_allowed(protocol, own_side, player_side, card, hand) :
    contract = protocol.contract
    if contract  is None :
        return False
    decl = contract[-1]
    valid_card = bridge.valid_card(hand, card, protocol.moves)
    res = (player_side == own_side 
           or (decl == own_side and player_side == bridge.partner_side(own_side))) and valid_card 
    return res
Exemplo n.º 2
0
 def test_card_wrong_suit(self) :
     self.assertFalse(bridge.valid_card([1, 14], 1, [15]), 'another suit - disallowed')
Exemplo n.º 3
0
 def test_card_no_suit(self) :
     self.assertTrue(bridge.valid_card([1], 1, [15]), 'no same suit - allowed')
Exemplo n.º 4
0
 def test_card_right_suit(self) :
     self.assertTrue(bridge.valid_card([1], 1, [0]), 'same suit - allowed')
Exemplo n.º 5
0
 def test_card_new_round(self) :
     self.assertTrue(bridge.valid_card([1], 1, []), 'new round - everything allowed')
Exemplo n.º 6
0
 def test_card_played_already(self) :
     self.assertFalse(bridge.valid_card([1], 1, [1]), 'card is already played')
Exemplo n.º 7
0
 def test_card_not_in_hand(self) :
     self.assertFalse(bridge.valid_card([2], 1, []), 'card not in hand')