#! /bin/sh -e

cvt () {
    out=${1%.svg}.png
    [ -f $out ] || inkscape -o $out $1 > /dev/null
}

mkdir -p out

for i in src/card-treasure*.svg; do
    echo "=== $i"
    base=$(basename $i .svg)
    cp $i out/
    cvt $i out/$base.png
done

while read name; do
    echo "=== $name"
    fn=${name%% *}

    echo "    - card"
    svg=out/card-room-front-$fn.svg
    sed "s/Hydroponics/$name/" src/card-room-front.svg > $svg
    cvt $svg

    echo "    - tile front"
    svg=out/tile-front-$fn.svg
    sed "s/Hydroponics/$name/" src/tile-front.svg > $svg
    cvt $svg

    echo "    - tile back"
    svg=out/tile-back-$fn.svg
    sed "s/Hydroponics/$name/" src/tile-back.svg > $svg
    cvt $svg
done << EOD
Airlock
Gym
Kitchen
Lounge
Chem Lab
Radio Room
Hydroponics
Botany Lab
Rec Room
Lavatory
Galley
Pantry
Sick Bay
Workshop
Storage
Control Room
Filter Room
Green Quarters
Orange Quarters
Electronics
Cargo Bay
Dog Room
Alien Exam Room
Coal Cart
EOD
