Skip to content

Commit

Permalink
Code check-in
Browse files Browse the repository at this point in the history
  • Loading branch information
flosch committed Nov 14, 2011
1 parent 994f8e3 commit fb85b9d
Show file tree
Hide file tree
Showing 11 changed files with 1,615 additions and 0 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions asciitron.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env python
import asciitron
asciitron.main()
43 changes: 43 additions & 0 deletions asciitron/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-

import argparse

from server import TronServer
from client import TronClient

def main():
parser = argparse.ArgumentParser(description='TronClient Game')
parser.add_argument('-p', '--port', dest='port', type=int,
default=9158, help='communication port, default: 9158')

subparsers = parser.add_subparsers()

client_parser = subparsers.add_parser('connect', help='Connect to a game')
client_parser.add_argument('hostname', help='server hostname')
client_parser.add_argument('playerid', type=int, help='player id')
client_parser.add_argument('--beep', action='store_true',
help='beeps during game countdown to notify the user')

server_parser = subparsers.add_parser('serve', help='Serve a game')
server_parser.add_argument('playercount', type=int, help='number of players')

args = parser.parse_args()
args = vars(args)

if args.has_key('hostname'):
# Connect to a server
tron = TronClient(hostname=args['hostname'],
player_id=args['playerid'],
port=args['port'],
beep=args['beep'])
try:
tron.run()
finally:
tron.stop()
else:
# Run a server
server = TronServer(player_count=args['playercount'], port=args['port'])
try:
server.serve()
except KeyboardInterrupt:
server.stop()
3 changes: 3 additions & 0 deletions asciitron/client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from tronclient import TronClient
Loading

0 comments on commit fb85b9d

Please sign in to comment.