Script 'game-add': display the list of games.
This commit is contained in:
parent
77b9063170
commit
a2500e5094
16
game-add
16
game-add
@ -197,12 +197,14 @@ function game_validate {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Players' sides should interchange
|
# Players' sides should interchange
|
||||||
|
|
||||||
local length=$(echo -en "$ply_names" | wc -l)
|
local length=$(echo -en "$ply_names" | wc -l)
|
||||||
if $ADD_GAMES && [[ -n $res_old ]]; then
|
if $ADD_GAMES && [[ -n $res_old ]]; then
|
||||||
local residue=$(( $(wc -w <<< "$res_old") % 2 ))
|
local residue=$(( $(wc -w <<< "$res_old") % 2 ))
|
||||||
else
|
else
|
||||||
local residue=0
|
local residue=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local ply_ordered=
|
local ply_ordered=
|
||||||
for ((i = 0; i < length; i++)); do
|
for ((i = 0; i < length; i++)); do
|
||||||
if (( i % 2 == residue )); then
|
if (( i % 2 == residue )); then
|
||||||
@ -211,7 +213,16 @@ function game_validate {
|
|||||||
ply_ordered+="${black}\n"
|
ply_ordered+="${black}\n"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# List found games
|
||||||
|
echo "$(tput setaf 2)Found games:$(tput sgr0)"
|
||||||
|
game_display "$ply_names"
|
||||||
|
|
||||||
if [[ "$ply_names" != "$ply_ordered" ]]; then
|
if [[ "$ply_names" != "$ply_ordered" ]]; then
|
||||||
|
# List expected games
|
||||||
|
echo "$(tput setaf 2)Expected games:$(tput sgr0)"
|
||||||
|
game_display "$ply_ordered"
|
||||||
|
|
||||||
local answer
|
local answer
|
||||||
echo -n "Approve games with wrong players' sides? (Y/n)> "
|
echo -n "Approve games with wrong players' sides? (Y/n)> "
|
||||||
read answer
|
read answer
|
||||||
@ -219,6 +230,11 @@ function game_validate {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function game_display {
|
||||||
|
echo -e "$1" | xargs -n2 \
|
||||||
|
| sed "s/ / - /;s/^/$(tput setaf 6)*$(tput sgr0) /"
|
||||||
|
}
|
||||||
|
|
||||||
function game_store_pgns {
|
function game_store_pgns {
|
||||||
game_dir=$(ls -1 -d 2>/dev/null \
|
game_dir=$(ls -1 -d 2>/dev/null \
|
||||||
${REPO_DIR}/${TOURNAMENT}/tours/${TOUR}/*-${white}-vs-${black})
|
${REPO_DIR}/${TOURNAMENT}/tours/${TOUR}/*-${white}-vs-${black})
|
||||||
|
Loading…
Reference in New Issue
Block a user