#!/bin/bash
#set -eux

rm -rf cardsets

if [ 1 ]; then
	cardsets_dir=PySolFC-Cardsets

	if [ ! -d ${cardsets_dir} ]; then
  	echo '### downloading cardset repo'

		mkdir ${cardsets_dir}
		pushd ${cardsets_dir}

		mkdir repo
		pushd repo
		git init
		git remote add -t master origin https://github.com/shlomif/PySolFC-Cardsets.git
		git fetch --depth 1 origin 3.0
		git checkout -q FETCH_HEAD
		popd

  	echo '### choose a minimal set'

		for d in $(cat ../minimal.txt)
		do
			mv repo/${d} .
		done
		rm repo -rf

 		echo '### processing cardsets'

		../../scripts/cardconv gif png
		for i in cardset-*-png; do
			rm -rf `basename $i -png`
		done
		popd
	fi
    # cp -a ${cardsets_dir} ${cardsets_dir}-orig

	ln -s ${cardsets_dir} cardsets
fi

pushd cardsets
    echo '### resize big cardsets'

	for i in cardset-*; do
		../resizecards $i
	done
popd

echo '### end cardsets'
