EduNetworkBuilder/Web/scripts/CombinePuzzles.sh

28 lines
792 B
Bash
Raw Normal View History

#!/bin/bash
function GetOrder()
{
level=$1
#grep sortorder *.json | sed 's/\"//g;s/sortorder://;s/,/ /;s/://;s/\(Level[0-9]*\)\(.*\)json\(.*\)$/\1 \3 \1\2json/;s/ */ /g'
grep sortorder *.json | sed 's/\"//g;s/sortorder://;s/,/ /;s/://;s/\(Level[0-9]*\)\(.*\)json\(.*\)$/\3 \1\2json/;s/ */ /g' | grep $level | sort -g | sed 's/.*Level/Level/'
}
cd Resources
echo "allpuzzles=[" > ../allpuzzles.js
counter=0
for a in 0 1 2 3 4 5 6; do
GetOrder Level$a
done | while read onelevel; do
#We need to compile it
if [ $counter -gt 0 ]; then
echo "," >> ../allpuzzles.js
fi
counter=$((counter+1))
name=${onelevel/.json/}
echo $name
cat $onelevel | sed "s/\"Network\": {/\"Network\": {\n\"name\": \"$name\",\n/" >> ../allpuzzles.js
done
echo "]" >> ../allpuzzles.js