More working build, trying to optimize

This commit is contained in:
Louis Burke 2024-10-11 00:04:05 -04:00
parent d28e1b855f
commit 6c30f0447b
15 changed files with 1463 additions and 2373 deletions

1348
.ninja_log

File diff suppressed because it is too large Load diff

View file

@ -2,7 +2,7 @@
package iditacards package iditacards
#AssetKind: "image" | "tex" | "template" | "cat" #AssetKind: "image" | "tex" | "texdoc" | "template" | "cat"
#Asset: { #Asset: {
// passed to convert to create the "print" version (usually to add bleed) // passed to convert to create the "print" version (usually to add bleed)
@ -37,6 +37,10 @@ package iditacards
source: string source: string
size: #Dimensions size: #Dimensions
} }
if kind == "texdoc" {
source: string
}
} }
// Assets are what actually need to be printed/created/etc // Assets are what actually need to be printed/created/etc

View file

@ -13,3 +13,10 @@ assets:
source: iditaboard.tex source: iditaboard.tex
size: 4875x3075 size: 4875x3075
instructions:
kind: texdoc
source: instructions.tex
instructions-anatomy:
kind: texdoc
source: instructions-anatomy.tex

File diff suppressed because it is too large Load diff

View file

@ -40,7 +40,7 @@ assets: {
for deckname, deck in decks for deckname, deck in decks
for cardname, freq in deck for cardname, freq in deck
let card = cards[cardname] { let card = cards[cardname] {
"\(deckname)-\(cardname)[\(freq.count)]": { "cards/\(deckname)-\(cardname)[\(freq.count)]": {
size: "750x1050" size: "750x1050"
print: "-set option:distort:viewport 825x1125-37-37 -virtual-pixel Edge -distort SRT 0 +repage" print: "-set option:distort:viewport 825x1125-37-37 -virtual-pixel Edge -distort SRT 0 +repage"
@ -72,7 +72,7 @@ pseudoassets: {
contents: [ contents: [
for cardname, freq in deck for cardname, freq in deck
for idx in list.Range(0, freq.count, 1) { for idx in list.Range(0, freq.count, 1) {
"\(deckname)-\(cardname)[\(freq.count)]" "cards/\(deckname)-\(cardname)[\(freq.count)]"
}, },
] ]
} }
@ -84,7 +84,7 @@ pseudoassets: {
for deckname, deck in decks for deckname, deck in decks
for cardname, card in deck { for cardname, card in deck {
for idx in list.Range(0, card.count, 1) { for idx in list.Range(0, card.count, 1) {
"\(deckname)-\(cardname)[\(card.count)]" "cards/\(deckname)-\(cardname)[\(card.count)]"
} }
}, },
] ]

View file

@ -33,13 +33,15 @@ def cuesources:
.w = (.size | split("x")[0]) | .w = (.size | split("x")[0]) |
.h = (.size | split("x")[1]) | .h = (.size | split("x")[1]) |
.rawsuffix = (if .print then "raw." else "" end) | .rawsuffix = (if .print then "raw." else "" end) |
"build output/\(.name).json: extract output/everything.json", "build output/.\(.name).json.stamp | output/\(.name).json: extract output/everything.json",
" filter = --arg asset '\(.name)' '.assets[$$asset].data'", " filter = --arg asset '\(.name)' '.assets[$$asset].data'",
" target = output/\(.name).json",
"build output/\(.name).tex: template2tex output/\(.name).json | templates/\(.template)", "build output/\(.name).tex: template2tex output/\(.name).json | templates/\(.template)",
" template = templates/\(.template)", " template = templates/\(.template)",
"build output/\(.name).pdf: tex2pdf output/\(.name).tex || output/\(.name).pdf.dd", "build output/\(.name).pdf: tex2pdf output/\(.name).tex || output/.\(.name).pdf.dd",
" dyndep = output/\(.name).pdf.dd", " dyndep = output/.\(.name).pdf.dd",
"build output/\(.name).pdf.dd: scantex output/\(.name).tex", "build output/.\(.name).pdf.dd: scantex output/\(.name).tex",
" target = output/\(.name).pdf",
"build output/\(.name).\(.rawsuffix)png: pdf2png output/\(.name).pdf", "build output/\(.name).\(.rawsuffix)png: pdf2png output/\(.name).pdf",
" w = \(.w)", " w = \(.w)",
" h = \(.h)", " h = \(.h)",
@ -56,13 +58,24 @@ def cuesources:
.w = (.size | split("x")[0]) | .w = (.size | split("x")[0]) |
.h = (.size | split("x")[1]) | .h = (.size | split("x")[1]) |
.rawsuffix = (if .print then "raw." else "" end) | .rawsuffix = (if .print then "raw." else "" end) |
"build output/\(.name).pdf: tex2pdf \(.source) || output/\(.name).pdf.dd", "build output/\(.name).pdf: tex2pdf \(.source) || output/.\(.name).pdf.dd",
" dyndep = output/\(.name).pdf.dd", " dyndep = output/.\(.name).pdf.dd",
"build output/\(.name).pdf.dd: scantex \(.source)", "build output/.\(.name).pdf.dd: scantex \(.source)",
" target = output/\(.name).pdf",
"build output/\(.name).\(.rawsuffix)png: pdf2png output/\(.name).pdf", "build output/\(.name).\(.rawsuffix)png: pdf2png output/\(.name).pdf",
" w = \(.w)", " w = \(.w)",
" h = \(.h)", " h = \(.h)",
(select(.print) | "build output/\(.name).png: convert output/\(.name).raw.png"), (select(.print) | "build output/\(.name).png: convert output/\(.name).raw.png"),
(select(.print) | " args = \(.print)") (select(.print) | " args = \(.print)")
),(
select(.kind == "texdoc") |
"build output/\(.name).pdf: tex2pdf2x \(.source) || output/.\(.name).pdf.dd",
" dyndep = output/.\(.name).pdf.dd",
"build output/.\(.name).pdf.dd: scantex \(.source)",
" target = output/\(.name).pdf"
),(
select(.kind == "cat") |
.ins = (.contents | map("output/\(.).pdf") | join(" ")) |
"build output/\(.name).pdf: pdfunite \(.ins)"
) )
) )

View file

@ -2,3 +2,7 @@
# The real configure script uses jq to parse cue output # The real configure script uses jq to parse cue output
cue export -- *.cue *.yaml | jq -r -f configure.jq --args -- *.cue *.yaml cue export -- *.cue *.yaml | jq -r -f configure.jq --args -- *.cue *.yaml
# TODO: generate line-by-line asset list with jq and process them to generate
# build.ninja in builddir="$1". Regenerate any changed *.jsons at configure
# time, hopefully ninja picks up those changes!

View file

View file

@ -79,7 +79,9 @@
\clearpage \clearpage
\section{Overview} \section{Overview}
% Your background story/recap on what situation the players are getting themselves into. It sets the scene (thematically, usually) for the entire game. % Your background story/recap on what situation the players are getting
% themselves into. It sets the scene (thematically, usually) for the entire
% game.
Iditacards is a game where you race your opponents in the last great race on Iditacards is a game where you race your opponents in the last great race on
earth - The Iditarod. You will face starvation, hypothermia, and inclement earth - The Iditarod. You will face starvation, hypothermia, and inclement
@ -89,7 +91,10 @@ form to come out ahead.
The first player to cross the finish line wins! The first player to cross the finish line wins!
\section{Components} \section{Components}
% This isnt so important for playtesters at this point, but is important for the final rulebook and print and plays (PnP). This way players (including yourself) know whether or not there are missing pieces, or in the case of PnP players, if they have everything they need in order to play. % This isnt so important for playtesters at this point, but is important for
% the final rulebook and print and plays (PnP). This way players (including
% yourself) know whether or not there are missing pieces, or in the case of PnP
% players, if they have everything they need in order to play.
This game contains many cards. They can be sorted based on the symbol in the This game contains many cards. They can be sorted based on the symbol in the
bottom right corner: bottom right corner:
@ -118,7 +123,10 @@ The game also contains:
\clearpage \clearpage
\section{Objective} \section{Objective}
% What the players are trying to accomplish. It should also make it clear how players are competing (free-for-all, teams, cooperative, etc.). This is the more technical/mechanical explanation of the 'Overview'. For example: “To be the last player with multiple spaceships orbiting the black hole”. % What the players are trying to accomplish. It should also make it clear how
% players are competing (free-for-all, teams, cooperative, etc.). This is the
% more technical/mechanical explanation of the 'Overview'. For example: “To be
% the last player with multiple spaceships orbiting the black hole”.
Every turn each player will move forward one space. The cards they play will Every turn each player will move forward one space. The cards they play will
increase this, while the places they encounter will work to decrease it. When increase this, while the places they encounter will work to decrease it. When
@ -126,7 +134,11 @@ the first player reaches the finish line the game ends. The finish line is the
square \emph{after} the last square on the board. square \emph{after} the last square on the board.
\section{Setup} \section{Setup}
% How to get the game ready for play. There shouldnt be anything in here that mentions what components are used for or why they are important--save that for the 'Gameplay' section. Just make sure that in this section everything is laid out clearly--if diagrams are necessary (they almost always are) dont be afraid to put those in! % How to get the game ready for play. There shouldnt be anything in here that
% mentions what components are used for or why they are important--save that for
% the 'Gameplay' section. Just make sure that in this section everything is laid
% out clearly--if diagrams are necessary (they almost always are) dont be
% afraid to put those in!
To start the game each player must pick a colour. They take the token of that To start the game each player must pick a colour. They take the token of that
colour and place it in the ``Start'' space. colour and place it in the ``Start'' space.
@ -145,7 +157,9 @@ Before starting the game everybody draws 6 cards. The first player to grab the
weather die goes first. They roll it, then take their turn. weather die goes first. They roll it, then take their turn.
\section{Gameplay} \section{Gameplay}
% The main gameplay section tells you how the game is broken up (rounds, turns, phases, etc.) and summarizes what players do in each of those stages. This section should explain the flow of the game from start to completion. % The main gameplay section tells you how the game is broken up (rounds, turns,
% phases, etc.) and summarizes what players do in each of those stages. This
% section should explain the flow of the game from start to completion.
The game is broken into turns. Each turn you may either play a card, or take The game is broken into turns. Each turn you may either play a card, or take
a new day. At the end of your turn you automatically move a distance equal to a new day. At the end of your turn you automatically move a distance equal to
@ -160,7 +174,11 @@ limit on hand size, however if there aren't enough cards in your deck to fill
your hand, then your hand will consist only of however many cards are available your hand, then your hand will consist only of however many cards are available
to be drawn. to be drawn.
% Once thats done, you go into the gameplay specifics, which should be explained in the order in which they occur in game. This is where you explain exactly what happens during each turn, action, round, etc. You also should have sections dedicated to complicated subjects and their edge cases (for instance, our section on Collisions for “Pulled into Darkness”). % Once thats done, you go into the gameplay specifics, which should be
% explained in the order in which they occur in game. This is where you explain
% exactly what happens during each turn, action, round, etc. You also should
% have sections dedicated to complicated subjects and their edge cases (for
% instance, our section on Collisions for “Pulled into Darkness”).
\subsection{Movement} \subsection{Movement}
As in any race, movement is important. Whenever you move you add your current As in any race, movement is important. Whenever you move you add your current
@ -185,7 +203,7 @@ If you pass the checkerboard finish line you win the game.
\subsection{Card Anatomy} \subsection{Card Anatomy}
\includegraphics{instructions-anatomy.pdf} \includegraphics{output/instructions-anatomy.pdf}
In this example card, the energy cost is \emph{X} the health cost is \emph{Y} In this example card, the energy cost is \emph{X} the health cost is \emph{Y}
and the risk cost is \emph{Z}. and the risk cost is \emph{Z}.

View file

@ -19,7 +19,7 @@ legs: [string]: #Leg
assets: { assets: {
for legname, leg in legs { for legname, leg in legs {
"\(legname)[1]": { "legs/\(legname)[1]": {
size: "750x1050" size: "750x1050"
print: "-set option:distort:viewport 825x1125-37-37 -virtual-pixel Edge -distort SRT 0 +repage" print: "-set option:distort:viewport 825x1125-37-37 -virtual-pixel Edge -distort SRT 0 +repage"
@ -40,7 +40,7 @@ pseudoassets: {
"\(deckname)": { "\(deckname)": {
kind: "cat" kind: "cat"
contents: [ contents: [
for legname, one in legs {"\(legname)[1]"}, for legname, one in legs {"legs/\(legname)[1]"},
] ]
} }
} }

View file

@ -1,6 +1,12 @@
# The legs (TODO: export shorthands for each leg effect in iditacard.cls so that # The legs (TODO: export shorthands for each leg effect in iditacard.cls so that
# the cue generation/gomplate instantiation can be simplified) # the cue generation/gomplate instantiation can be simplified)
#
# TODO: consider returning to the old leg system, it allowed for more
# flavour and less clutter, its main downside was that the game was too
# "complicated" and that slowed it down, perhaps decrease the density of legs
# while still using the old card-based system?
legs: legs:
# First legs
farm: farm:
name: 'Farm' name: 'Farm'
level: firstleg level: firstleg
@ -9,3 +15,70 @@ legs:
3: hypo 3: hypo
5: damage 5: damage
7: hypo 7: hypo
fishing_hole:
name: 'Fishing Hole'
level: firstleg
effect: '\daydraw{3}'
spaces:
3: damage
5: hypo
7: damage
hospital:
name: 'Hospital'
level: firstleg
effect: '\freecardtype{personal}'
spaces:
3: starve
5: hypo
7: starve
new_moon:
name: 'New Moon'
level: firstleg
effect: '\freecardtype{dog}'
spaces:
3: hypo
5: starve
7: hypo
repair_shop:
name: 'Repair Shop'
level: firstleg
effect: '\freecardtype{sled}'
spaces:
3: starve
5: damage
7: starve
volcano:
name: 'Volcano'
level: firstleg
effect: '\allowednot{\includegraphics[width=1cm]{icons/hypo.png}}'
spaces:
3: damage
5: starve
7: damage
# Second legs
downhill:
name: 'Downhill'
level: secondleg
effect: '\speed{3}'
spaces:
2: hypo
4: damage
6: damage
8: hypo
junkyard:
name: 'Junkyard'
level: secondleg
effect: '\healthcosts{-1}'
spaces:
2: damage
4: hypo
6: hypo
8: damage

View file

@ -1,15 +1,26 @@
# TeX compilation takes a lot of resources and can hang a system, only do about
# 4 at a time
pool tex_pool
depth = 4
# uncomment restats when ninja stops segfaulting when you do so -.- (ninja; touch legs.yaml; ninja)
# TODO: clean up the output directory by messing with this and configure.jq
# hide all json/tex/etc in hidden files?
rule template2tex rule template2tex
description = convert $in to $out using $template as a template description = convert $in to $out using $template as a template
command = gomplate --left-delim '«' --right-delim '»' -c .=$in < $template > $out command = gomplate --left-delim '«' --right-delim '»' -c .=$in < $template > $out
rule cuegen rule cuegen
description = run cue on $in to produce $out description = run cue on $in to produce $out
command = cue export $in > $out command = cue export $in | bash update.sh $out
# restat = 1
rule extract rule extract
description = extract $out from $in via jq filter $filter description = extract $out from $in via jq filter $filter
command = jq $filter < $in | bash update.sh $out command = jq -c $filter < $in | bash update.sh $out
restat = 1 # restat = 1
rule tex2pdf rule tex2pdf
description = render tex from $in to $out description = render tex from $in to $out
@ -21,10 +32,28 @@ rule tex2pdf
--output-directory=$$(dirname $out) $in >/dev/null $ --output-directory=$$(dirname $out) $in >/dev/null $
&& [ $$(basename -s .tex $in) = $$(basename -s .pdf $out) ] $ && [ $$(basename -s .tex $in) = $$(basename -s .pdf $out) ] $
|| mv $$(dirname $out)/$$(basename -s .tex $in).pdf $out || mv $$(dirname $out)/$$(basename -s .tex $in).pdf $out
pool = tex_pool
rule tex2pdf2x
description = render tex from $in to $out twice (for toc)
command = $
xelatex $
-interaction=batchmode $
-halt-on-error $
--shell-escape $
--output-directory=$$(dirname $out) $in >/dev/null $
&& xelatex $
-interaction=batchmode $
-halt-on-error $
--shell-escape $
--output-directory=$$(dirname $out) $in >/dev/null $
&& { [ $$(basename -s .tex $in) = $$(basename -s .pdf $out) ] $
|| mv $$(dirname $out)/$$(basename -s .tex $in).pdf $out; }
pool = tex_pool
rule scantex rule scantex
description = scan tex $in for dependencies description = scan tex $in for dependencies
command = bash scantex.sh $in $out > $out command = bash scantex.sh $in $target > $out
rule pdf2png rule pdf2png
description = convert pdf $in to png $out with size $w by $h description = convert pdf $in to png $out with size $w by $h
@ -37,3 +66,11 @@ rule convert
rule copy rule copy
description = copy $in to $out description = copy $in to $out
command = cp $in $out command = cp $in $out
rule pdfunite
description = unite pdfs to create $out
command = $
pdfunite $in $out $
&& pdfjam --nup 3x3 $out $
--no-landscape --delta '0.5cm 0.5cm' --scale 0.9 $
-o $$(dirname $out)/$$(basename -s .pdf $out)-mini.pdf >/dev/null 2>&1

View file

@ -10,10 +10,10 @@ temp="$(mktemp -p .)"
trap 'rm -rf ${temp} ${temp}.*' EXIT INT trap 'rm -rf ${temp} ${temp}.*' EXIT INT
cp "$src" "$temp.tex" cp "$src" "$temp.tex"
xelatex -recorder "$temp.tex" >/dev/null xelatex -recorder --shell-escape "$temp.tex" >/dev/null
deps="$(awk -v ORS=' ' -v "temp=$temp" -v "repl=${src%%.*}" '/INPUT \./ {gsub(temp,repl,$2); print $2}' < "$temp.fls")" deps="$(awk -v "temp=$temp" -v "repl=${src%%.*}" '/INPUT \./ {gsub(temp,repl,$2); print $2}' < "$temp.fls" | sort | uniq | tr '\n' ' ')"
outs="$(awk -v ORS=' ' -v "temp=${temp#*/}" -v "repl=${dst%%.*}" '/OUTPUT / {gsub(temp,repl,$2); print $2}' < "$temp.fls")" outs="$(awk -v "temp=${temp#*/}" -v "repl=${dst%%.*}" '/OUTPUT / {gsub(temp,repl,$2); print $2}' < "$temp.fls" | sort | uniq | tr '\n' ' ')"
echo -n "build $tgt" echo -n "build $tgt"
[ -z "$outs" ] || echo -n " | $outs" [ -z "$outs" ] || echo -n " | $outs"

View file

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
# Counts the number of cards in the given deck. # Counts the number of cards in the given deck.
yq r -j cards.yaml | jq -r --arg deckname "$1" '.decks[] | select(.name | test($deckname; "i")) | .cards | length' yq r -j cards.yaml | jq -r --arg deckname "$1" '.decks[$deckname] | values | map(.count) | add'

View file

@ -10,5 +10,5 @@ new="$(sha256sum <<<"$input" | cut -d " " -f 1)"
old="$(sha256sum "$output" 2>/dev/null | cut -d " " -f 1)" old="$(sha256sum "$output" 2>/dev/null | cut -d " " -f 1)"
if [ "$new" != "$old" ]; then if [ "$new" != "$old" ]; then
echo -n "$input" > "$output" echo "$input" > "$output"
fi fi