-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.py
executable file
·54 lines (42 loc) · 1.43 KB
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
#
# Copyright (C) Florian Denis - All Rights Reserved
# Unauthorized copying of this file, via any medium is strictly prohibited.
# Proprietary and confidential.
#
"""
Client for online simplified Belote game
"""
import argparse
import logging
import os
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
from belote.client import Client
from belote.transport import Transport
def main():
# Logging
logging.basicConfig(format='%(name)16s - %(levelname)8s - %(message)s')
logging.getLogger('belote').setLevel(logging.DEBUG)
log = logging.getLogger('cli')
default_name = os.environ['USER'] if 'USER' in os.environ else 'Guest'
backends = ['pygame', 'pyglet']
# Arguments
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('host', help='Host location')
parser.add_argument('-p', '--port', default=4242,
help='Port')
parser.add_argument('-f', '--fullscreen', action='store_true',
help='Fullscreen mode')
parser.add_argument('-n', '--name', default=default_name,
help='Player name')
parser.add_argument('-b', '--backend', choices=backends,
default=backends[0], help='GUI Backend')
args = parser.parse_args()
# Launch client instance
client = Client(
args.host, int(args.port),
args.name,
not bool(args.fullscreen), args.backend.upper())
client.run()
if __name__ == '__main__':
main()