1
0
Disbranĉigi 0
Ĉi tiu deponejo arĥiviĝis je 2024-01-28. Vi povas vidi kaj elŝuti dosierojn, sed ne povas puŝi nek raporti problemojn nek tirpeti.
unixchesscollection/render.sh

63 lines
1.5 KiB
Bash
Raw Permalink Normal View History

2017-03-26 16:03:29 -05:00
#!/bin/sh
2017-03-28 06:36:27 -05:00
####################
# Name: render.sh
# Lisc: ISC
# Main: jadedctrl
# Desc: Render that board.json, m8.
#####################
2017-03-26 16:03:29 -05:00
file=$1
height=$(lib/json.sh -s height $file)
width=$(lib/json.sh -s width $file)
heighti=$height
2017-03-26 16:03:29 -05:00
while [ $heighti -ne 0 ]
2017-03-26 16:03:29 -05:00
do
widthi=0
while [ $widthi -ne $width ]
do
widthi=$((widthi+1))
2017-03-27 07:04:52 -05:00
if grep "${widthi},${heighti}" $file > /dev/null
2017-03-26 16:03:29 -05:00
then
2017-03-27 07:04:52 -05:00
point_data=$(sh lib/json.sh $file | grep board/pieces/${widthi},${heighti}/ | grep =)
point_data=$(echo $point_data | sed 's/ = /=/g' | sed 's/ /^/g')
string_one=$(echo $point_data | awk -F^ '{print $1}')
string_two=$(echo $point_data | awk -F^ '{print $2}')
if echo $string_one | grep team= > /dev/null
2017-03-27 07:04:52 -05:00
then
team=$( echo $string_one | sed 's/.*=//')
piece=$(echo $string_two | sed 's/.*=//')
elif echo $string_one | grep piece= > /dev/null
2017-03-27 07:04:52 -05:00
then
piece=$(echo $string_one | sed 's/.*=//')
team=$(echo $string_two | sed 's/.*=//')
2017-03-27 07:04:52 -05:00
fi
text=$(sh lib/json.sh -s ${team}/pieces/${piece}/text $file)
else
2017-03-26 16:03:29 -05:00
text=" "
fi
if [ $(echo "$heighti % 2" | bc) -eq 1 ]
then
if [ $(echo "$widthi % 2" | bc) -eq 1 ]
then
2017-03-26 16:08:42 -05:00
printf "$(tput setab 7)$(tput setaf 0) $text"
2017-03-26 16:03:29 -05:00
else
2017-03-26 16:08:42 -05:00
printf "$(tput setab 0)$(tput setaf 7) $text"
2017-03-26 16:03:29 -05:00
fi
else
if [ $(echo "$widthi % 2" | bc) -eq 0 ]
then
2017-03-26 16:08:42 -05:00
printf "$(tput setab 7)$(tput setaf 0) $text"
2017-03-26 16:03:29 -05:00
else
2017-03-26 16:08:42 -05:00
printf "$(tput setab 0)$(tput setaf 7) $text"
2017-03-26 16:03:29 -05:00
fi
fi
done
heighti=$((heighti-1))
2017-03-26 16:03:29 -05:00
printf "\033[m\n"
done
printf '\033[m\n'