Allow to parse the result of an unaccomplished game.

This commit is contained in:
vonavi 2015-01-01 14:25:01 +03:00
parent 2b57870138
commit 8a85193ce3

View File

@ -27,13 +27,13 @@ function parse_tour_info {
local tour_info=$(cat "${REPO_DIR}/${TOURNAMENT}/tours/${tour}/tour_info"; echo) 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 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 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 date=${BASH_REMATCH[1]}
local white=${BASH_REMATCH[2]} local white=${BASH_REMATCH[2]}
local black=${BASH_REMATCH[3]} 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) local round=$(echo "($tour - 1)/($ply_count - 1) + 1" | bc)
parse_to_ini parse_to_ini
((game_counter += 1)) ((game_counter += 1))
@ -47,7 +47,7 @@ function parse_to_ini {
[[ ! $date =~ \? ]] && echo "date = $date" [[ ! $date =~ \? ]] && echo "date = $date"
echo "white = $white" echo "white = $white"
echo "black = $black" echo "black = $black"
[[ -n $result ]] && echo "result = \"$result\"" [[ $result == "-" ]] || echo "result = \"$result\""
echo echo
} }