Script 'game-add': fix the alternation of players' sides.

This commit is contained in:
vonavi 2014-12-13 20:56:26 +03:00
parent 27d6ac21db
commit bdc1411b4e

View File

@ -196,7 +196,7 @@ function game_validate {
# Players' sides should interchange # Players' sides should interchange
local length=$(echo -en "$ply_names" | wc -l) local length=$(( $(echo -en "$ply_names" | wc -l) / 2 ))
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
@ -206,9 +206,9 @@ function game_validate {
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
ply_ordered+="${white}\n" ply_ordered+="${white}\n${black}\n"
else else
ply_ordered+="${black}\n" ply_ordered+="${black}\n${white}\n"
fi fi
done done