Script 'schedule': take into account the result of unaccomplished games.

This commit is contained in:
vonavi 2015-01-01 21:54:56 +03:00
parent 6050f7cfe6
commit f64071cc96

View File

@ -113,7 +113,7 @@ function show_tour_sequence {
function output_tour_info { function output_tour_info {
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|1/2|0-1)" local res_re="(1|½|0|\+|-)"
local tour_num= date_beg= date_end= local tour_num= date_beg= date_end=
local white= black= result= game_date= local white= black= result= game_date=
# Lines with game info # Lines with game info
@ -130,7 +130,7 @@ function output_tour_info {
output_lines+=$(sed -E "s/$date_re +//" <<< "$line") output_lines+=$(sed -E "s/$date_re +//" <<< "$line")
# Append the link of game to the end of output line # Append the link of game to the end of output line
if $SHOW_LINK; then if $SHOW_LINK; then
[[ -n $result ]] && append_game_url [[ $result =~ ^(\+|-)*$ ]] || append_game_url
fi fi
output_lines+="\n" output_lines+="\n"
fi fi
@ -177,8 +177,9 @@ function get_tour_dates {
function keep_game_info { function keep_game_info {
local keep=1 local keep=1
if [[ $line =~ $date_re\ +([^\ ]+)\ +-\ +([^\ ]+)(\ +$res_re)? ]]; then if [[ $line =~ $date_re\ +([^\ ]+)\ +-\ +([^\ ]+)(\ +$res_re-$res_re)? ]]; then
white=${BASH_REMATCH[4]} black=${BASH_REMATCH[5]} result=${BASH_REMATCH[7]} white=${BASH_REMATCH[4]} black=${BASH_REMATCH[5]}
result=${BASH_REMATCH[7]}-${BASH_REMATCH[8]}
game_date=${BASH_REMATCH[3]}-${BASH_REMATCH[2]}-${BASH_REMATCH[1]} game_date=${BASH_REMATCH[3]}-${BASH_REMATCH[2]}-${BASH_REMATCH[1]}
# If the player was passed as an argument, check if it is his game or not # If the player was passed as an argument, check if it is his game or not
@ -187,7 +188,7 @@ function keep_game_info {
keep=0 keep=0
else else
# Keep line if the game is not finished # Keep line if the game is not finished
[[ -z $result ]] && keep=0 [[ $result == "-" ]] && keep=0
fi fi
fi fi
fi fi
@ -213,14 +214,14 @@ function info_output_term {
players=$(grep -o "[^ ]*${PLAYER}[^ ]*" <<< "$line") players=$(grep -o "[^ ]*${PLAYER}[^ ]*" <<< "$line")
for name in $players; do for name in $players; do
# PLAYER is a part of 'game_url' or 'result' # PLAYER is a part of 'game_url' or 'result'
[[ $name =~ ^http:// || $name =~ ^${res_re}$ ]] && continue [[ $name =~ ^http:// || $name =~ ^${res_re}-${res_re}$ ]] && continue
line=$(sed -E "s/(${name})/$(tput setaf 1)\1$(tput sgr0)/" <<< "$line") line=$(sed -E "s/(${name})/$(tput setaf 1)\1$(tput sgr0)/" <<< "$line")
done done
fi fi
# Highlight result # Highlight result
line=$(sed -E "s~ ${res_re}( |$)~ $(tput setaf 6)\1$(tput sgr0)\2~" <<< "$line") line=$(sed -E "s~ ${res_re}-${res_re}( |$)~ $(tput setaf 6)\1-\2$(tput sgr0)~" <<< "$line")
echo "$line" echo "$line"
done done
@ -252,9 +253,7 @@ function info_output_html {
echo " <tbody>" echo " <tbody>"
echo -en "$output_lines" | while read white hyphen black result url; do echo -en "$output_lines" | while read white hyphen black result url; do
[[ $result == 1/2 ]] && result=½-½
[[ -n $url ]] && result="<a href=\"${url}\">${result}</a>" [[ -n $url ]] && result="<a href=\"${url}\">${result}</a>"
echo " <tr>" echo " <tr>"
echo " <td>${white} - ${black}</td><td class=\"result\">${result}</td>" echo " <td>${white} - ${black}</td><td class=\"result\">${result}</td>"
echo " </tr>" echo " </tr>"