From 60e19b8cff9bb574f3a65f89ba754ea68d364587 Mon Sep 17 00:00:00 2001 From: dozens Date: Mon, 23 Oct 2023 09:14:55 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 70 +++++++++++++++++- db/game.rec | 3 +- justfile | 59 ++++----------- out/story.pdf | Bin 351205 -> 351205 bytes out/story.txt | 38 +++++----- tmp/dot | 197 ++++++++++++++++++++++++++++++++++---------------- 6 files changed, 241 insertions(+), 126 deletions(-) diff --git a/Makefile b/Makefile index 19aabef..6c44db2 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/db/game.rec b/db/game.rec index 939659b..52ad615 100644 --- a/db/game.rec +++ b/db/game.rec @@ -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 diff --git a/justfile b/justfile index dcac307..99c2f4f 100644 --- a/justfile +++ b/justfile @@ -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 diff --git a/out/story.pdf b/out/story.pdf index ff23e0106d419f892c7ce83b148965cd90494402..44e5465fa3c7fc057a45f47fcc6326af944eb59d 100644 GIT binary patch delta 181 zcmaF5UG(X8(S{br7N!>F7M3lnH9_o_RtA< zEmM~F2eUG%TN+pzS?C&=sT&xmYjWxP=BKzMmZWO9SQ!}@85;tz0a(TMZK13eSe@KV sEX@tf-3%NJo!u-gjLpmp3=Q3!EG=9Njg1YAoDJ-32&tHUBAQhe04$9!&j0`b delta 181 zcmaF5UG(X8(S{br7N!>F7M3lnH9_p=R)(flMn=<{gIG=AoP9y8M|qM>O$-u~l2UXN zEt8k`2eUG%n;V)M8R;6BsT&xmYjWxP=BKzMmZWO9SQ!}@85;tz0a(TMZK13eSe=|L s-JG1v9bFvVTn!D(%uJkJjoi%5Of3!EjGUZ|OwH_U2&tHUBAQhe0Apw{!~g&Q diff --git a/out/story.txt b/out/story.txt index 3bcba41..b17a554 100644 --- a/out/story.txt +++ b/out/story.txt @@ -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. diff --git a/tmp/dot b/tmp/dot index 6fb1327..02ff49d 100644 --- a/tmp/dot +++ b/tmp/dot @@ -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}} + }