main
Dozens B. McCuzzins 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 eps: cornbeast.eps
cornbeast.eps:
tmp/cornbeast.eps:
convert assets/cornbeast.png 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 name: cornquest
author: dozens author: dozens
date: 2023-10-13 created: 2022-10-04
updated: 2023-10-23
%rec: game %rec: game
%doc: a choose your own adventure %doc: a choose your own adventure

View File

@ -8,33 +8,17 @@ default:
_map: _map:
recsel -t game {{db}} | recfmt '"{{{{name}}": "{{{{id}}", ' recsel -t game {{db}} | recfmt '"{{{{name}}": "{{{{id}}", '
# build dot file # build dot file (tmp file)
# TODO: change id to name? or id /and/ name?
# TODO: how do you document a wicked sed script?
_dot: _dot:
#!/usr/bin/env zsh make dot
echo "digraph {" > tmp/dot
recsel -t game {{db}} \ # build data object (tmp file)
| recfmt '{{{{id}} -> {{{{text}}|' \ _data:
| sed -e 's/|/\n\n/g' \ make data
| 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
# build a graph of all the nodes # build a graph of all the nodes
graph: _data _dot graph:
mustache tmp/data tmp/dot \ make graph
| dot -Tpng > out/graph.png
# build data object
_data:
echo "{" $(just _map) "}" \
| sed -e 's/, }/ }/' \
> tmp/data
# plain output # plain output
build: _data build: _data
@ -65,8 +49,7 @@ watch-pdf:
# shuffle ids # shuffle ids
_shuffle: _shuffle:
recsel -t game -P id db/game.rec \ recsel -t game -P id -C db/game.rec \
| sed '/^$/d' \
| shuf --random-source=/dev/urandom \ | shuf --random-source=/dev/urandom \
| gsed -e '/^0$/d' -e '1 i 0' | gsed -e '/^0$/d' -e '1 i 0'
@ -93,27 +76,17 @@ renumber:
rm "$tmpfile" rm "$tmpfile"
# make ms # make ms
_ms: _data _ms:
recsel -t game {{db}} \ make ms
| rec2csv \
| csvjson \
| jq '. | { data: . }' \
| mustache - templates/story.ms.template \
> tmp/story.ms
# make pdf # make pdf
pdf: _ms pdf:
mustache tmp/data tmp/story.ms \ make pdf
| groff -ms -Tps -dpaper=a5 -P-pa5 \
| ps2pdfwr - out/story.pdf
# make ascii doc # make ascii doc
ascii: _ms ascii:
mustache tmp/data tmp/story.ms \ make ascii
| groff -ms -Tascii \
| sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" \
> out/story.txt
# generate tags # generate tags
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 insides. THE END. giant. It stops
@ -199,7 +199,7 @@
-4-
the other crea- than stone. There the other crea- than stone. There
@ -265,7 +265,7 @@
-5-
forward like the plaza. Every forward like the plaza. Every
@ -331,7 +331,7 @@
-6-
terribly excited. the year! If you terribly excited. the year! If you
@ -397,7 +397,7 @@
-7-
It gives you the tall. You run It gives you the tall. You run
@ -463,7 +463,7 @@
-8-
them. But you For a price. To them. But you For a price. To
@ -529,7 +529,7 @@
-9-
to a small clear- disapprovingly. to a small clear- disapprovingly.
@ -595,7 +595,7 @@
-10-
village and the Corn Mother. She village and the Corn Mother. She
@ -661,7 +661,7 @@
-11-
34 dire crow eggs. 34 dire crow eggs.
@ -727,7 +727,7 @@
-12-
cloud gazing! And keen on trying to cloud gazing! And keen on trying to
@ -793,7 +793,7 @@
-13-
attention goto 5. the hatchery. attention goto 5. the hatchery.
@ -859,7 +859,7 @@
-14-
hatchling. On the one, and separate hatchling. On the one, and separate
@ -925,7 +925,7 @@
-15-
corner. She de- component of the corner. She de- component of the
@ -991,7 +991,7 @@
-16-
51 misty lake. It's 51 misty lake. It's
@ -1057,7 +1057,7 @@
-17-
The clouds roll eventually creep The clouds roll eventually creep
@ -1123,7 +1123,7 @@
-18-
59 have a really 59 have a really
@ -1189,7 +1189,7 @@
-19-
hand down over and yahoos, send- hand down over and yahoos, send-
@ -1255,7 +1255,7 @@
-20-
far as you know. far as you know.

197
tmp/dot
View File

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