#!/bin/sh #################### # Name: render.sh # Lisc: ISC # Main: jadedctrl # Desc: Render that board.json, m8. ##################### file=$1 height=$(lib/json.sh -s height $file) width=$(lib/json.sh -s width $file) heighti=0 while [ $heighti -ne $height ] do heighti=$((heighti+1)) widthi=0 while [ $widthi -ne $width ] do widthi=$((widthi+1)) if grep "${widthi},${heighti}" $file > /dev/null then 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 then team=$( echo $string_one | sed 's/.*=//') piece=$(echo $string_two | sed 's/.*=//') elif echo $string_one | grep piece= > /dev/null then piece=$(echo $string_one | sed 's/.*=//') team=$(echo $string_two | sed 's/.*=//') fi text=$(sh lib/json.sh -s ${team}/pieces/${piece}/text $file) else text=" " fi if [ $(echo "$heighti % 2" | bc) -eq 1 ] then if [ $(echo "$widthi % 2" | bc) -eq 1 ] then printf "$(tput setab 7)$(tput setaf 0) $text" else printf "$(tput setab 0)$(tput setaf 7) $text" fi else if [ $(echo "$widthi % 2" | bc) -eq 0 ] then printf "$(tput setab 7)$(tput setaf 0) $text" else printf "$(tput setab 0)$(tput setaf 7) $text" fi fi done printf "\033[m\n" done printf '\033[m\n'