-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadd_round
executable file
·86 lines (64 loc) · 2.24 KB
/
add_round
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#! /usr/bin/perl -w
# Goat: Gentil Organisateur et Administrateur de Tournois
# Copyright (C) 2006-2018 Yves Rutschle
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more
# details.
#
# The full text for the General Public License is here:
# http://www.gnu.org/licenses/gpl.html
=head1 NAME
add_round -- creates a new round in a tournament
=head1 SYNOPSIS
add_round --file <toperm> [--date <date>]
=head1 DESCRIPTION
I<add_round> simply creates an empty round in a tournament.
In conjunction with I<add_game>, it can be used to import
pairings made with another program.
If the B<date> is specified, it will be displayed in
all reminders. If not specified, one month from now is
picked, just like the B<pair> program.
You would go about it as such:
add_round -f toperm -d "19 juin 2017"
add_game -f toperm --black [email protected] --white [email protected]
add_game -f toperm --black [email protected] --white [email protected]
[...]
goat --status
=cut
use strict;
use Tournament;
use Getopt::Long;
use Pod::Usage;
use GoatLib;
use GoatConfig;
# Interpret command line
my ($testing, $param_final_date, $help);
GetOptions(
'help' => \$help,
'date=s' => \$param_final_date,
) or die pod2usage();
die pod2usage(-verbose=>2) if defined $help;
my $Tournament = Tournament->load($TOURNAMENT_FILE);
my $round_num = ($Tournament->round_number || 0) + 1;
print "Creating round $round_num\n";
my $round = Round->new($round_num);
# make date or get from opt
my $final_date;
if (defined $param_final_date) {
$final_date = parse_datestr($param_final_date);
die "Wrong date format $param_final_date." unless defined $final_date;
} else {
$final_date = my_time + 30 * 24 * 3600; # one month in the future
}
$round->final_date($final_date);
$Tournament->add_round($round_num, $round);
$Tournament->save($TOURNAMENT_FILE);