Browse Source

Strategická: Print setříděné výsledkové listiny

master
Jiří Kalvoda 2 years ago
parent
commit
1d948b5087
  1. 9
      server/bin/control_game

9
server/bin/control_game

@ -18,6 +18,7 @@ parser.add_argument("--restore", action="store_true")
parser.add_argument("--set-step-mode", type=str) parser.add_argument("--set-step-mode", type=str)
parser.add_argument("--set-step-s", type=int) parser.add_argument("--set-step-s", type=int)
parser.add_argument("--autosteps", action="store_true", help="Bude periodicky posouvat hru podle konfigurace") parser.add_argument("--autosteps", action="store_true", help="Bude periodicky posouvat hru podle konfigurace")
parser.add_argument("--ranking", action="store_true", help="Výsledky")
args = parser.parse_args() args = parser.parse_args()
@ -64,6 +65,14 @@ if args.autosteps:
sleep(step_in) sleep(step_in)
else: else:
game.lock() game.lock()
if args.ranking:
round_id = game.current_state().round
teams = ses.query(db.Team).filter_by(game_id=game_id).order_by(db.Team.team_id).all()
moves = ses.query(db.Move).filter_by(game_id=game_id, round=round_id).order_by(db.Move.team_id).all()
a = list(zip(teams, moves))
a.sort(key=lambda x: -x[1].points)
for i, x in enumerate(a):
print(f"{i+1:2} {x[1].points:6} {x[0].user.username}: {x[0].team_id}")
if args.born_per_round: if args.born_per_round:
print(args.born_per_round) print(args.born_per_round)
c = game.get_configuration() c = game.get_configuration()

Loading…
Cancel
Save