Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated with lots of changes and bug fixes.

  • Loading branch information...
commit 1d043da26dcc35410ef047a58dd27b7abda9805c 1 parent 387a21b
Your Name authored
Showing with 43 additions and 16 deletions.
  1. +43 −16 wsex.py
View
59 wsex.py
@@ -82,7 +82,7 @@ def privmsg(self, user, channel, msg):
self.window.set_table(dealmsg)
elif 'error' in dealmsg:
self.window.report_error(dealmsg)
- elif 'status' in dealmsg:
+ elif 'update' in dealmsg:
self.window.report_status(dealmsg)
elif 'actions' in dealmsg:
self.window.allow_actions(dealmsg)
@@ -250,6 +250,8 @@ def __init__(self):
def raising_range(self):
if 'raise' in self.current_actions:
return self.current_actions['raise']
+ elif 'bet' in self.current_actions:
+ return self.current_actions['bet']
return 1, 1
def raise_box_changed(self, value):
@@ -274,7 +276,10 @@ def raise_slider_changed(self, value):
value = i*interval + ra
raise_text = '%.0f'%value
self.raise_edit_box.setText(raise_text)
- self.raise_button.setText('Raise %s'%raise_text)
+ if 'bet' in self.current_actions:
+ self.raise_button.setText('Bet %s'%raise_text)
+ else:
+ self.raise_button.setText('Raise %s'%raise_text)
def blank_cards(self):
self.cards[0].setPixmap(self.blank_card)
@@ -389,10 +394,13 @@ def report_error(self, msg):
self.add_line('<font color="red">%s: %s</font>'%(error, errmsg))
def report_status(self, msg):
- status = msg['status']
- stmsg = msg['message']
+ status = msg['update']
+ if 'message' in msg:
+ stmsg = msg['message']
+ else:
+ stmsg = ''
self.add_line('<b>%s: %s</b>'%(status, stmsg))
- if status == 'newhand':
+ if status == 'new hand':
self.new_hand = True
self.blank_cards()
self.hide_actions()
@@ -424,25 +432,31 @@ def allow_actions(self, msg):
self.call_button.show()
if 'raise' in actions:
raise_range = actions['raise']
- raise_text = str(raise_range[0])
- self.raise_button.setText('Raise %s'%raise_text)
- self.raise_edit_box.setText(raise_text)
- self.raise_button.show()
- self.raise_edit_box.show()
- self.raise_slider.show()
+ self.setup_raise(raise_range, False)
elif 'bet' in actions:
- ###
- pass
+ bet_range = actions['bet']
+ self.setup_raise(bet_range, True)
self.current_actions = actions
+ def setup_raise(self, raise_range, doing_betting):
+ raise_text = str(raise_range[0])
+ if doing_betting:
+ self.raise_button.setText('Bet %s'%raise_text)
+ else:
+ self.raise_button.setText('Raise %s'%raise_text)
+ self.raise_edit_box.setText(raise_text)
+ self.raise_button.show()
+ self.raise_edit_box.show()
+ self.raise_slider.show()
+
def fold_clicked(self):
acts = self.current_actions
- if 'postsb' in acts:
- self.send_command('postsb')
- elif 'postbb' in acts:
+ if 'postbb' in acts:
self.send_command('postbb')
elif 'postsbbb' in acts:
self.send_command('postsbbb')
+ elif 'postsb' in acts:
+ self.send_command('postsb')
elif 'fold' in acts:
self.send_command('fold')
else:
@@ -464,6 +478,13 @@ def raise_clicked(self):
self.send_command('raise %d'%acts['raise'][0])
else:
self.send_command('raise %d'%bet)
+ elif 'bet' in acts:
+ try:
+ bet = int(self.raise_edit_box.text())
+ except ValueError:
+ self.send_command('bet %d'%acts['bet'][0])
+ else:
+ self.send_command('bet %d'%bet)
def hide_actions(self):
self.fold_button.hide()
@@ -481,6 +502,8 @@ def add_line(self, line):
self.action_view.setHtml(text)
sb = self.action_view.verticalScrollBar()
sb.setSliderPosition(sb.maximum())
+ end_cursor = QTextCursor(self.action_view.document())
+ end_cursor.movePosition(QTextCursor.End)
def show_hand(self, msg):
hand = msg['cards']
@@ -527,6 +550,10 @@ def show_action(self, user, msg, hero=False):
msg = msg.split(' ')
msg = msg[0], int(msg[1])
peract = 'raises to %d'%msg[1]
+ elif 'bet' in msg:
+ msg = msg.split(' ')
+ msg = msg[0], int(msg[1])
+ peract = 'bets to %d'%msg[1]
elif 'call' in msg:
peract = 'calls'
elif 'check' in msg:
Please sign in to comment.
Something went wrong with that request. Please try again.