main
dozens 2023-10-23 09:14:55 -06:00
parent 123bd2feb8
commit 60e19b8cff
6 changed files with 241 additions and 126 deletions

View File

@ -1,4 +1,70 @@
# convert png to eps for embedding in pdf
.PHONY: eps
eps: cornbeast.eps
tmp/cornbeast.eps:
cornbeast.eps:
convert assets/cornbeast.png cornbeast.eps
# create dot file
.PHONY: dot
dot: tmp/dot
tmp/dot: db/game.rec
echo "digraph {" > tmp/dot
recsel -t game db/game.rec \
| recfmt '{{id}} -> {{text}}|' \
| sed -e 's/|/\n\n/g' \
| sed -e '/./{H;$!d;}' -e 'x; s/\n//g; G;' \
| sed -e 's/}}[^{]*{{/}} {{/g' -e 's/> [^{]* {{/> {{/' \
| sed -e 's/}}[^{]*/}} /' \
| sed -e 's/[^}]$$//' \
| sed -e 's/^\([0-9]*\) -> [^{].*/\1/' \
| sed -e 's/}} {{/}}, {{/g' \
>> tmp/dot
echo "}" >> $@
# create data object
.PHONY: data
data: tmp/data
tmp/data: db/game.rec
echo "{" `just _map` "}" \
| sed -e 's/, }/ }/' \
> $@
# create the graph
.PHONY: graph
graph: out/graph.png
out/graph.png: tmp/data tmp/dot
mustache tmp/data tmp/dot \
| dot -Tpng > $@
# create the ms template file
.PHONY: ms
ms: tmp/story.ms
tmp/story.ms: tmp/data templates/story.ms.template
recsel -t game db/game.rec \
| rec2csv \
| csvjson \
| jq '. | { data: . }' \
| mustache - templates/story.ms.template \
> $@
# make the pdf output
.PHONY: pdf
pdf: out/story.pdf
out/story.pdf: tmp/story.ms
mustache tmp/data tmp/story.ms \
| groff -ms -Tps -dpaper=a5 -P-pa5 \
| ps2pdfwr - $@
# make the ascii output
.PHONY: ascii
ascii: out/story.txt
out/story.txt: tmp/data tmp/story.ms
mustache tmp/data tmp/story.ms \
| groff -ms -Tascii \
| sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" \
> $@
# generate u-ctags
tags: db/game.rec
ctags --options=./lib/game.ctags db/game.rec

View File

@ -3,7 +3,8 @@
name: cornquest
author: dozens
date: 2023-10-13
created: 2022-10-04
updated: 2023-10-23
%rec: game
%doc: a choose your own adventure

View File

@ -8,33 +8,17 @@ default:
_map:
recsel -t game {{db}} | recfmt '"{{{{name}}": "{{{{id}}", '
# build dot file
# TODO: change id to name? or id /and/ name?
# TODO: how do you document a wicked sed script?
# build dot file (tmp file)
_dot:
#!/usr/bin/env zsh
echo "digraph {" > tmp/dot
recsel -t game {{db}} \
| recfmt '{{{{id}} -> {{{{text}}|' \
| sed -e 's/|/\n\n/g' \
| sed -e '/./{H;$!d;}' -e 'x; s/\n//g; G;' \
| sed -e 's/}}[^{]*{{{{/}} {{{{/g' -e 's/> [^{]* {{{{/> {{{{/' \
| sed -e 's/}}[^{]*/}} /' \
| sed -e '/{{{{/!d' -e 's/\.$//' \
| sed -e 's/> \(.*\)$/> { \1 };/' \
>> tmp/dot
echo "}" >> tmp/dot
make dot
# build data object (tmp file)
_data:
make data
# build a graph of all the nodes
graph: _data _dot
mustache tmp/data tmp/dot \
| dot -Tpng > out/graph.png
# build data object
_data:
echo "{" $(just _map) "}" \
| sed -e 's/, }/ }/' \
> tmp/data
graph:
make graph
# plain output
build: _data
@ -65,8 +49,7 @@ watch-pdf:
# shuffle ids
_shuffle:
recsel -t game -P id db/game.rec \
| sed '/^$/d' \
recsel -t game -P id -C db/game.rec \
| shuf --random-source=/dev/urandom \
| gsed -e '/^0$/d' -e '1 i 0'
@ -93,27 +76,17 @@ renumber:
rm "$tmpfile"
# make ms
_ms: _data
recsel -t game {{db}} \
| rec2csv \
| csvjson \
| jq '. | { data: . }' \
| mustache - templates/story.ms.template \
> tmp/story.ms
_ms:
make ms
# make pdf
pdf: _ms
mustache tmp/data tmp/story.ms \
| groff -ms -Tps -dpaper=a5 -P-pa5 \
| ps2pdfwr - out/story.pdf
pdf:
make pdf
# make ascii doc
ascii: _ms
mustache tmp/data tmp/story.ms \
| groff -ms -Tascii \
| sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" \
> out/story.txt
ascii:
make ascii
# generate tags
tags:
ctags --options=./lib/game.ctags db/game.rec
make tags

Binary file not shown.

View File

@ -67,7 +67,7 @@
-2-
@ -133,7 +133,7 @@
-3-
insides. THE END. giant. It stops
@ -199,7 +199,7 @@
-4-
the other crea- than stone. There
@ -265,7 +265,7 @@
-5-
forward like the plaza. Every
@ -331,7 +331,7 @@
-6-
terribly excited. the year! If you
@ -397,7 +397,7 @@
-7-
It gives you the tall. You run
@ -463,7 +463,7 @@
-8-
them. But you For a price. To
@ -529,7 +529,7 @@
-9-
to a small clear- disapprovingly.
@ -595,7 +595,7 @@
-10-
village and the Corn Mother. She
@ -661,7 +661,7 @@
-11-
34 dire crow eggs.
@ -727,7 +727,7 @@
-12-
cloud gazing! And keen on trying to
@ -793,7 +793,7 @@
-13-
attention goto 5. the hatchery.
@ -859,7 +859,7 @@
-14-
hatchling. On the one, and separate
@ -925,7 +925,7 @@
-15-
corner. She de- component of the
@ -991,7 +991,7 @@
-16-
51 misty lake. It's
@ -1057,7 +1057,7 @@
-17-
The clouds roll eventually creep
@ -1123,7 +1123,7 @@
-18-
59 have a really
@ -1189,7 +1189,7 @@
-19-
hand down over and yahoos, send-
@ -1255,7 +1255,7 @@
-20-
far as you know.

197
tmp/dot
View File

@ -1,63 +1,138 @@
digraph {
0 -> { {{corndress}} {{cornoveralls}} };
1 -> { {{hut}} };
2 -> { {{panic}} };
4 -> { {{path}} {{continue}} {{hack}} };
5 -> { {{askgiant}} {{gazing}} };
6 -> { {{destroy}} {{part}} };
7 -> { {{altar}} };
8 -> { {{shears}} {{escape}} };
9 -> { {{doze}} };
10 -> { {{treeline}} };
11 -> { {{flute}} };
12 -> { {{rejected}} };
13 -> { {{beginning}} };
14 -> { {{games}} };
15 -> { {{grab}} };
16 -> { {{tag}} {{hideandseek}} {{lavamonster}} };
17 -> { {{restart}} {{resist}} };
19 -> { {{whelp}} };
20 -> { {{dark}} };
21 -> { {{games}} {{altar}} };
22 -> { {{char}} };
23 -> { {{agree}} {{refuse}} };
24 -> { {{treeline}} };
25 -> { {{hut}} };
26 -> { {{placate}} {{abscond}} };
27 -> { {{beast}} {{hide}} };
28 -> { {{dash}} };
30 -> { {{truth}} {{refusegiant}} };
31 -> { {{witchaggro}} {{witchnice}} };
32 -> { {{altar}} };
33 -> { {{dark}} };
34 -> { {{altarcorn}} {{eavesdrop}} };
36 -> { {{baby}} };
37 -> { {{liar}} {{askgiant}} };
38 -> { {{charm}} };
39 -> { {{search}} {{crumbs}} };
40 -> { {{panic}} {{calm}} };
41 -> { {{giant}} {{nogiant}} };
42 -> { {{greedy}} {{escape}} };
43 -> { {{dash}} };
44 -> { {{fwiends}} {{scram}} };
45 -> { {{char}} };
46 -> { {{grab}} };
47 -> { {{hide}} {{path}} };
48 -> { {{lake}} };
49 -> { {{witchaggro}} {{ride}} };
52 -> { {{clouds}} };
53 -> { {{warren}} };
54 -> { {{approach}} {{wait}} };
55 -> { {{dark}} };
56 -> { {{egg}} {{noegg}} };
57 -> { {{clouds}} };
58 -> { {{panic}} };
59 -> { {{direct}} {{indirect}} };
60 -> { {{restart}} };
61 -> { {{charm}} };
64 -> { {{liar}} };
65 -> { {{accept}} {{witchaggro}} };
66 -> { {{clouds}} };
67 -> { {{crowask}} {{crowdemand}} };
68 -> { {{stay}} {{explore}} };
0 -> {{corndress}}, {{cornoveralls}}
1 -> {{hut}}
2 -> {{panic}}
3
4 -> {{path}}, {{continue}}, {{hack}}
5 -> {{askgiant}}, {{gazing}}
6 -> {{destroy}}, {{part}}
7 -> {{altar}}
8 -> {{shears}}, {{escape}}
9 -> {{doze}}
10 -> {{treeline}}
11 -> {{flute}}
12 -> {{rejected}}
13 -> {{beginning}}
14 -> {{games}}
15 -> {{grab}}
16 -> {{tag}}, {{hideandseek}}, {{lavamonster}}
17 -> {{restart}}, {{resist}}
18
19 -> {{whelp}}
20 -> {{dark}}
21 -> {{games}}, {{altar}}
22 -> {{char}}
23 -> {{agree}}, {{refuse}}
24 -> {{treeline}}
25 -> {{hut}}
26 -> {{placate}}, {{abscond}}
27 -> {{beast}}, {{hide}}
28 -> {{dash}}
30 -> {{truth}}, {{refusegiant}}
31 -> {{witchaggro}}, {{witchnice}}
32 -> {{altar}}
33 -> {{dark}}
34 -> {{altarcorn}}, {{eavesdrop}}
35
36 -> {{baby}}
37 -> {{liar}}, {{askgiant}}
38 -> {{charm}}
39 -> {{search}}, {{crumbs}}
40 -> {{panic}}, {{calm}}
41 -> {{giant}}, {{nogiant}}
42 -> {{greedy}}, {{escape}}
43 -> {{dash}}
44 -> {{fwiends}}, {{scram}}
45 -> {{char}}
46 -> {{grab}}
47 -> {{hide}}, {{path}}
48 -> {{lake}}
49 -> {{witchaggro}}, {{ride}}
50
51
52 -> {{clouds}}
53 -> {{warren}}
54 -> {{approach}}, {{wait}}
55 -> {{dark}}
56 -> {{egg}}, {{noegg}}
57 -> {{clouds}}
58 -> {{panic}}
59 -> {{direct}}, {{indirect}}
60 -> {{restart}}
61 -> {{charm}}
62
63
64 -> {{liar}}
65 -> {{accept}}, {{witchaggro}}
66 -> {{clouds}}
67 -> {{crowask}}, {{crowdemand}}
68 -> {{stay}}, {{explore}}
}