battleman: Implemented wait/unwait properly, fixed a couple of simple bugs

This commit is contained in:
2012-04-05 17:06:17 -04:00
parent a6d9943856
commit 035d8cba37
2 changed files with 26 additions and 15 deletions

View File

@ -14,7 +14,7 @@ sys.path.append('lib/')
import shelve
import argparse
import cmd
from cmd import Cmd
import os.path
import battle
from battle import CombatGroup
@ -89,11 +89,11 @@ def main():
class CommandParser(cmd.Cmd):
class CommandParser(Cmd):
"""Parse the commands from the command-line."""
def __init__(self, btl, session):
cmd.Cmd.__init__(self)
Cmd.__init__(self)
self.btl = btl
self.session = session
@ -116,25 +116,25 @@ class CommandParser(cmd.Cmd):
# This allows us to do partial command completion without <tab>,
# as long as
def default(self, line):
cmd, data, line = self.parseline(line)
cmds = self.completenames(cmd)
comm, data, line = self.parseline(line)
cmds = self.completenames(comm)
num_cmds = len(cmds)
if num_cmds == 1:
getattr(self, 'do_'+cmds[0])(data)
elif num_cmds > 1:
sys.stdout.write('Error: Ambiguous command: {}'.format(cmd))
sys.stdout.write('Error: Ambiguous command: {}'.format(comm))
else:
print 'Error: Unrecognized command {}'.format(cmd)
print 'Error: Unrecognized command {}'.format(comm)
# We are overriding do_help to avoid printing info about
# undocumented commands
def do_help(self, arg):
if arg:
Cmd.cmd.do_help(arg)
Cmd.do_help(self, arg)
else:
# Everything from here to the end is lifted straight
# out of Cmd.cmd.do_help()
# out of cmd.Cmd.do_help()
names = self.get_names()
cmds_doc = []
cmds_undoc = []