Beispiel #1
0
    def setBiddingResult(self, declarer, contract):
        """Set bidding result

        The effect of this method is to set the text of the label to one
        indicating the declarer and the contract reached. If declarer or
        contract is None, the text is cleared.

        Keyword Arguments:
        declarer -- the declarer determined by the bidding
        declarer -- the contract determined by the bidding
        """
        if declarer and contract:
            declarer_format = positions.positionLabel(declarer)
            try:
                bid_format = formatBid(contract[BID_TAG])
                doubling_format = DOUBLING_FORMATS[contract[DOUBLING_TAG]]
            except Exception:
                raise messaging.ProtocolError("Invalid contract: %r" %
                                              contract)
            # TODO: Localization
            self.setText("{declarer} declares {bid} {doubling}".format(
                declarer=declarer_format,
                bid=bid_format,
                doubling=doubling_format))
        else:
            self.clear()
Beispiel #2
0
 def testSetBiddingResult(self):
     self._result_label.setBiddingResult(
         self._declarer, dict(bid=self._bid, doubling=self._doubling))
     text = self._result_label.text()
     self.assertIn(positions.positionLabel(self._declarer), text)
     self.assertIn(bidding.formatBid(self._bid), text)
     self.assertIn(bidding.DOUBLING_FORMATS[self._doubling], text)
Beispiel #3
0
    def __init__(self, parent=None):
        """Initialize call table

        Keyword Arguments:
        parent -- the parent widget
        """
        super().__init__(0, len(positions.Position), parent)
        self.setHorizontalHeaderLabels(
            positions.positionLabel(position)
            for position in positions.Position)
        self.setVulnerability(
            {tag: False
             for tag in positions.PARTNERSHIP_TAGS})
        self._reset_calls()
Beispiel #4
0
    def setPlayerPosition(self, position):
        """Set position of the current player

        The position must be set before setting cards. Cards for the current
        player are laid at the bottom of the area.
        """
        self._position = positions.asPosition(position)
        hand_map = {}
        for position, hand, label in zip(
                positions.rotate(self._position), self._hand_panels,
                self._position_labels):
            hand_map[position] = (hand, label)
            label.setText(positions.positionLabel(position))
            label.resize(hand.width(), label.height())
        self._hand_map = hand_map
        self._trick_panel.setPlayerPosition(self._position)
Beispiel #5
0
    def setPlayerPosition(self, position):
        """Set position of the current player

        The position must be set before setting cards. Cards for the current
        player are laid at the bottom of the area.
        """
        self._position = positions.asPosition(position)
        hand_map = {}
        for position, hand, label in zip(positions.rotate(self._position),
                                         self._hand_panels,
                                         self._position_labels):
            hand_map[position] = (hand, label)
            label.setText(positions.positionLabel(position))
            label.resize(hand.width(), label.height())
        self._hand_map = hand_map
        self._trick_panel.setPlayerPosition(self._position)