-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_game.sh
executable file
·137 lines (94 loc) · 3.17 KB
/
generate_game.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
# Read all the lines in replacelist_robot.txt and use them to construct sed strings
workdir=$(pwd)
output_folder='_generated_game'
abs_replace_list_file=$workdir/pronouns_and_replacements.txt
function do_replacings() {
filename=$1
while read line;do
if [ "$line" == "" ]
then
continue # skip empty lines
fi
if [ "${line:0:1}" = "#" ]
then
continue # Skip lines starting with #
fi
# This reads the to_replace and replace_with from the file in the following format:
# "to_replace:replace_with"
to_replace=${line%%:*}
replace_with=${line##*:}
echo sed -i 's/'"$to_replace"'/'"$replace_with"'/g' "$filename"
sed -i 's/'"$to_replace"'/'"$replace_with"'/g' "$filename"
done < $abs_replace_list_file
}
folders="Characterbooks
Newspaper
Readme"
rm -rf $output_folder
mkdir $output_folder
for foldername in $folders
do
cp -r $foldername $output_folder/$foldername
done
# Put the general rules in the character books folder, so it can be included
pandoc -f markdown -t latex -o ./$output_folder/Characterbooks/rules.tex General_Rules.md
for foldername in $folders
do
echo cd "$workdir"/$output_folder/$foldername
cd "$workdir"/$output_folder/$foldername
for file in *.md
do
basename=${file%.*}
echo "------------ ${file##*/} ------------"
do_replacings $file
echo pandoc -f markdown -t latex -o "$basename".pdf $file
pandoc -f markdown -t latex --template="template.tex" -o "$basename".pdf $file
done
find . -type f -not -name '*pdf' -print0 | xargs -0 rm --
done
cd $workdir
# Make the placemats
foldername="Placecards"
cp -r $foldername $output_folder/$foldername
echo cd "$workdir"/$output_folder/$foldername
cd "$workdir"/$output_folder/$foldername
for file in *.tex
do
basename=${file%.*}
echo "------------ ${file##*/} ------------"
do_replacings $file
pdflatex $file > pdflatex.log
done
find . -type f -not -name '*pdf' -print0 | xargs -0 rm --
cd $workdir
# Make the script to rename the files
cp pdf_rename_script_raw.txt pdf_rename_script_generated.sh
do_replacings pdf_rename_script_generated.sh
chmod +x pdf_rename_script_generated.sh
# Run the pdf rename script inside the characterbooks folder
echo
echo Renaming pdf files of characterbooks...
cd "$workdir"/$output_folder/Characterbooks
$workdir/pdf_rename_script_generated.sh
echo Done
echo
# Copy the art assets to the $output_folder
cd $workdir
echo
echo Copy the evidence art assets to $output_folder
echo
mkdir $output_folder/Evidence_pieces
cp art_assets/Evidence_piece_1.pdf $output_folder/Evidence_pieces
cd $workdir
# Test to see whether there are any ones we missed:
echo
echo
echo -------------------------------------------------------------------------
echo The following are some missed replacements:
echo
find ./$output_folder -iname "*.md" | xargs grep --color=always -n -E "=[^=]*="
echo
echo Specify values for these values in "$abs_replace_list_file"
echo -------------------------------------------------------------------------
echo All done