Skip to content

Commit

Permalink
standard-conforming error messages sending jsons.
Browse files Browse the repository at this point in the history
also accept uppercase in commands by converting to lowercase.
  • Loading branch information
Your Name committed Dec 27, 2010
1 parent c3c3362 commit 6947408
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions serv/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import table
import script

debug_oneman = True
debug_oneman = False
debug_nick = 'zipio'

class Schedule:
Expand Down Expand Up @@ -39,8 +39,9 @@ def start(self, scriptObj):
try:
self.currentAct = self.actIter.next()
except StopIteration:
#self.adapter.reply('start() END...')
raise Exception('Internal Error: script didn\'t do anything!')
emptyscript = {'internalerror': 'emptyscript',
'message': "script didn't do anything!"}
self.adapter.reply(json.dumps(emptyscript))
else:
self.displayAct()
def pmHands(self, cardsDealt):
Expand All @@ -60,14 +61,19 @@ def update(self, player, response):
if not self.running:
return
if player is None:
self.adapter.reply('You didn\'t specify a player.')
# Only valid for debugging!
noplay = {'error': 'noplayer',
'message': "You didnt't specify a player."}
self.adapter.reply(json.dumps(noplay))
return
elif (isinstance(self.currentAct, script.Action) and
player != self.currentAct.player.nickname):
# People are allowed to sit out, out of turn
if (response[0] != script.Action.SitOut and
response[0] != script.Action.AutopostBlinds):
self.adapter.reply('Don\'t act out of turn!')
outturn = {'error': 'notyourturn',
'message': "Don't act out of turn."}
self.adapter.reply(json.dumps(outturn))
return
if response[0] not in self.currentAct.actionNames():
self.displayAct()
Expand Down Expand Up @@ -158,6 +164,8 @@ def msg(self, user, message):
if self.cash is not None:
print self.cash

# Make command lower case for clumsy users
command = command.lower()
try:
self.runCommand(player, command, param)
except Exception as e:
Expand Down

0 comments on commit 6947408

Please sign in to comment.