1
Fork 0

Allow to parse the result of an unaccomplished game.

master
vonavi 2015-01-01 14:25:01 +03:00
parent 2b57870138
commit 8a85193ce3
1 changed files with 4 additions and 4 deletions

View File

@ -27,13 +27,13 @@ function parse_tour_info {
local tour_info=$(cat "${REPO_DIR}/${TOURNAMENT}/tours/${tour}/tour_info"; echo)
local date_re="[0-9?]{2}\.[0-9?]{2}\.[0-9?]{4}"
local res_re="(1-0|0-1)"
local res_re="(1|½|0|\+|-)"
while read line; do
if [[ $line =~ ^($date_re)\ +([^\ ]+)\ +-\ +([^\ ]+)(\ +$res_re)? ]]; then
if [[ $line =~ ^($date_re)\ +([^\ ]+)\ +-\ +([^\ ]+)(\ +$res_re-$res_re)? ]]; then
local date=${BASH_REMATCH[1]}
local white=${BASH_REMATCH[2]}
local black=${BASH_REMATCH[3]}
local result=${BASH_REMATCH[5]}
local result=${BASH_REMATCH[5]}-${BASH_REMATCH[6]}
local round=$(echo "($tour - 1)/($ply_count - 1) + 1" | bc)
parse_to_ini
((game_counter += 1))
@ -47,7 +47,7 @@ function parse_to_ini {
[[ ! $date =~ \? ]] && echo "date = $date"
echo "white = $white"
echo "black = $black"
[[ -n $result ]] && echo "result = \"$result\""
[[ $result == "-" ]] || echo "result = \"$result\""
echo
}