summaryrefslogtreecommitdiff
path: root/ql/console.py
diff options
context:
space:
mode:
authorMichal Zimniewicz <michzimny@gmail.com>2016-10-09 11:27:06 +0200
committerMichal Zimniewicz <michzimny@gmail.com>2016-10-09 11:27:06 +0200
commit0a27bbf9ce1f5b1a52bc62ff4d9e5c2f960b030c (patch)
treedf4a562b9e2452bc288264156c1e47bf6fcedeb3 /ql/console.py
Initial commit
Diffstat (limited to 'ql/console.py')
-rwxr-xr-xql/console.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/ql/console.py b/ql/console.py
new file mode 100755
index 0000000..0c741ca
--- /dev/null
+++ b/ql/console.py
@@ -0,0 +1,37 @@
+from .orm.utils import get_num_of_tables
+from .lineup import Lineup
+from .completer import Completer
+
+
+class Console(object):
+
+ def __init__(self, round, segment, table=None):
+ self.round = round
+ self.segment = segment
+ self.start_from_table = table if table is not None else 1
+
+ @property
+ def tables(self):
+ return [ i for i in range(self.start_from_table, get_num_of_tables() + 1) ]
+
+ def run(self):
+ for table in self.tables:
+ self.process_table(table)
+
+ def process_table(self, table):
+ lineup = self.get_lineup(table)
+ print(lineup.info)
+ print()
+ for team in lineup.teams:
+ Completer.install_new_completer(team.player_names)
+ for pair in team.pairs:
+ while True:
+ print(pair.info)
+ value = input("Player: ")
+ if not value:
+ print()
+ break
+ pair.set_player(value)
+
+ def get_lineup(self, table):
+ return Lineup(self.round, self.segment, table)