Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 4 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 64 additions and 5 deletions.
  1. +3 −1 client/qt/README.pyinstaller
  2. +47 −4 client/qt/src/tarabish/qt/table.py
  3. +14 −0 client/qt/tarabish.spec
View
4 client/qt/README.pyinstaller
@@ -16,7 +16,9 @@ Download thrift
Rename lib/py/src to thrift
Copy to local directory
-python c:\pyinstaller-1.5.1\Build.py tarabish.spec
+python c:\\pyinstaller-1.5.1\\Configure.py
+python c:\\pyinstaller-1.5.1\\Build.py tarabish.spec
+
File built to dist: tarabish.exe
View
51 client/qt/src/tarabish/qt/table.py
@@ -2,7 +2,7 @@
from tarabish.thrift.constants import (CLUBS, SPADES, HEARTS, DIAMONDS, PASS)
from tarabish.thrift.constants import (JACK, QUEEN, KING, ACE)
-from tarabish.thrift.ttypes import (Card, EventType, InvalidOperation)
+from tarabish.thrift.ttypes import (Card, EventType, InvalidOperation, RunType)
from PySide.QtCore import (Signal, QSize, QPoint, Qt, QPropertyAnimation,
QParallelAnimationGroup)
@@ -155,9 +155,6 @@ def minimumSizeHint(self):
class CardWidget(QWidget):
doubleclicked = Signal()
- suit = {CLUBS: "C", SPADES: "S", HEARTS: "H", DIAMONDS: "D"}
- value = {JACK: "J", QUEEN: "Q", KING: "K", ACE: "A"}
-
def __init__(self, resource_path, pyCard, parent=None):
super(CardWidget, self).__init__(parent)
@@ -345,10 +342,36 @@ def _suit_to_name(self, suit):
else:
return "Pass"
+ def _card_to_str(self, card):
+ suit = {CLUBS: "C", SPADES: "S", HEARTS: "H", DIAMONDS: "D"}
+ value = {JACK: "J", QUEEN: "Q", KING: "K", ACE: "A"}
+
+ if card.value > 10:
+ value_str = value[card.value]
+ else:
+ value_str = str(card.value)
+
+ suit_str = suit[card.suit]
+
+ return value_str + suit_str
+
+ def _cards_to_str(self, cards):
+ ret = ""
+ for card in cards:
+ ret += self._card_to_str(card)
+ ret += " "
+ return ret[:-1] # cut last space
+
def _seat_to_name(self, seat):
names = ['North', 'East', 'South', 'West']
return names[self._seat_to_position(seat)]
+ def _runtype_to_name(self, run):
+ if run == RunType.TWENTY:
+ return "twenty"
+ else:
+ return "fifty"
+
def get_seat_display(self, seat):
return self.seats[self._seat_to_position(seat)]
@@ -440,6 +463,13 @@ def __init__(self, table_id, seat_num, table_view, server, logger,
server.eventDispatcher.connect(EventType.HAND_DONE,
self.handle_hand_done, table_id)
+ server.eventDispatcher.connect(EventType.CALL_RUN,
+ self.handle_call_run, table_id)
+ server.eventDispatcher.connect(EventType.SHOW_RUN,
+ self.handle_show_run, table_id)
+ server.eventDispatcher.connect(EventType.NOSHOW_RUN,
+ self.handle_noshow_run, table_id)
+
self.card_buttons.call_run.connect(self.call_run)
self.card_buttons.show_run.connect(self.show_run)
self.card_buttons.play_bella.connect(self.play_bella)
@@ -558,6 +588,19 @@ def handle_take_trick(self, seat):
position = self._seat_to_position(seat)
self.table_top.clear_sweep(position)
+ def handle_call_run(self, seat, run):
+ self.logger.append("%s calls a %s" % (self._seat_to_name(seat),
+ self._runtype_to_name(run)))
+
+ def handle_show_run(self, seat, run, cards):
+ self.logger.append("%s shows a %s -- <b>%s</b>" % (self._seat_to_name(seat),
+ self._runtype_to_name(run), self._cards_to_str(cards)))
+
+ def handle_noshow_run(self, seat, run, better, high_value, is_trump,
+ other_seat):
+ self.logger.append("%s says %s's run is no good" %
+ (self._seat_to_name(other_seat), self._seat_to_name(seat)))
+
def _enable_play(self):
self.card_buttons.enable()
View
14 client/qt/tarabish.spec
@@ -0,0 +1,14 @@
+# -*- mode: python -*-
+a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'), os.path.join(HOMEPATH,'support\\useUnicode.py'), 'tarabish.py'],
+ pathex=['c:\\qt.win'])
+pyz = PYZ(a.pure)
+exe = EXE( pyz,
+ a.scripts,
+ a.binaries,
+ a.zipfiles,
+ a.datas + [('cards.svg', 'cards.svg', 'DATA'), ('pips.svg', 'pips.svg', 'DATA')],
+ name=os.path.join('dist', 'tarabish.exe'),
+ debug=False,
+ strip=False,
+ upx=True,
+ console=True )

No commit comments for this range

Something went wrong with that request. Please try again.