Removed currently unused files

This commit is contained in:
Louis Burke 2024-10-16 00:23:48 -04:00
parent 68d85ba833
commit 93cdffb76e
14 changed files with 74 additions and 1502 deletions

124
Makefile
View file

@ -1,122 +1,8 @@
.PHONY: all clean check printrun cardrun decks prototype
.PRECIOUS: %.pdf %.png
default: everything
GENERATED_DIR?=generated
SENTINEL=$(GENERATED_DIR)/.sentinel
build.ninja: $(wildcard *.cue) $(wildcard *.yaml) configure.jq
cue export -- *.cue *.yaml | ./configure.jq --args -- *.cue *.yaml
default: check decks
all: check decks export
prototype: mini
everything: build.ninja
ninja
ASSET_TOML=assets.toml
include rules/*.mk
RAW_DECK_LIST=$(shell ./scripts/decklist.sh) first second third
DECK_LIST=$(RAW_DECK_LIST:%=$(GENERATED_DIR)/%)
DECK_DEPENDENCIES=$(DECK_LIST:%=%.d)
DECK_EXPORT_DIRS=$(DECK_LIST:%=outputs/%)
$(SENTINEL): cards.sql
./scripts/generate_cards.sh $(GENERATED_DIR)
-rm $(GENERATED_DIR)/first.list
-rm $(GENERATED_DIR)/second.list
-rm $(GENERATED_DIR)/third.list
touch $(GENERATED_DIR)/first.list
touch $(GENERATED_DIR)/second.list
touch $(GENERATED_DIR)/third.list
for card in legs/first/*.tex; do echo $${card%tex}pdf >> $(GENERATED_DIR)/first.list; done
for card in legs/second/*.tex; do echo $${card%tex}pdf >> $(GENERATED_DIR)/second.list; done
for card in legs/third/*.tex; do echo $${card%tex}pdf >> $(GENERATED_DIR)/third.list; done
mkdir -p $(DECK_EXPORT_DIRS)
touch $@
%.d: %.list
echo -n 'outputs/$(*F).pdf:' > $@
tr '\n' ' ' < $< >> $@
echo -e '\n\tpdfunite $$+ $$@' >> $@
cat $< | sed '/^$$/d' | sort | uniq -c | sed -e 's@ *\([[:digit:]]\+\) \(.\+/\)*\(.\+\).pdf@export: outputs/$*/\3[\1].png@' >> $@
cat $< | sed '/^$$/d' | sort | uniq -c | sed -e 's@ *\([[:digit:]]\+\) \(.\+/\)*\(.\+\).pdf@outputs/$*/\3[\1].png: \2\3[\1].png; cp \2\3[\1].png outputs/$*/\3[\1].png@' >> $@
mkdir -p outputs/$(*D)
echo 'decks: outputs/$(*F).pdf' >> $@
Makefile.deps: $(SENTINEL) $(DECK_DEPENDENCIES)
cat $^ > $@
#include Makefile.deps
export: outputs/cardback.png
export: outputs/iditaboard[face].png
export: instructions.pdf
%.pdf: %.tex
$(XELATEX) -interaction=batchmode -halt-on-error --shell-escape --output-directory=$(@D) $<
rm $*.aux
rm $*.log
instructions.pdf: instructions.tex instructions-anatomy.pdf
$(XELATEX) -interaction=batchmode -halt-on-error --shell-escape --output-directory=$(@D) $<
$(XELATEX) -interaction=batchmode -halt-on-error --shell-escape --output-directory=$(@D) $< # Twice, for TOC
mini: decks
pdfunite outputs/*.pdf tmp.pdf
pdfjam --nup 3x3 tmp.pdf --no-landscape --delta '0.5cm 0.5cm' --scale 0.9 -o outputs/mini_printrun.pdf
rm tmp.pdf
force-make:
clean:
-find cards -name '*.pdf' -delete
-find cards -name '*].png' -delete
-find cards -name '*-raw.png' -delete
-find outputs -name '*.pdf' -delete
-find outputs -name '*].png' -delete
-find outputs -name '*.d' -delete
-find legs -name '*.pdf' -delete
-find legs -name '*].png' -delete
-find legs -name '*-raw.png' -delete
-find . -name '*.aux' -delete
-find . -name '*.log' -delete
-rm -rf $(GENERATED_DIR)
-rm Makefile.deps
print-% : ; @echo $* = $($*)
# Rules for each multiplicity of png
%[1].png: %.pdf; ./cardtopng.sh $@
%[2].png: %.pdf; ./cardtopng.sh $@
%[3].png: %.pdf; ./cardtopng.sh $@
%[4].png: %.pdf; ./cardtopng.sh $@
%[5].png: %.pdf; ./cardtopng.sh $@
%[6].png: %.pdf; ./cardtopng.sh $@
%[7].png: %.pdf; ./cardtopng.sh $@
%[8].png: %.pdf; ./cardtopng.sh $@
%[9].png: %.pdf; ./cardtopng.sh $@
%[10].png: %.pdf; ./cardtopng.sh $@
%[11].png: %.pdf; ./cardtopng.sh $@
%[12].png: %.pdf; ./cardtopng.sh $@
%[13].png: %.pdf; ./cardtopng.sh $@
%[14].png: %.pdf; ./cardtopng.sh $@
%[15].png: %.pdf; ./cardtopng.sh $@
%[16].png: %.pdf; ./cardtopng.sh $@
%[17].png: %.pdf; ./cardtopng.sh $@
%[18].png: %.pdf; ./cardtopng.sh $@
%[19].png: %.pdf; ./cardtopng.sh $@
%[20].png: %.pdf; ./cardtopng.sh $@
%[21].png: %.pdf; ./cardtopng.sh $@
%[22].png: %.pdf; ./cardtopng.sh $@
%[23].png: %.pdf; ./cardtopng.sh $@
%[24].png: %.pdf; ./cardtopng.sh $@
%[25].png: %.pdf; ./cardtopng.sh $@
%[26].png: %.pdf; ./cardtopng.sh $@
%[27].png: %.pdf; ./cardtopng.sh $@
%[28].png: %.pdf; ./cardtopng.sh $@
%[29].png: %.pdf; ./cardtopng.sh $@
%[30].png: %.pdf; ./cardtopng.sh $@
%[31].png: %.pdf; ./cardtopng.sh $@
%[32].png: %.pdf; ./cardtopng.sh $@
%[33].png: %.pdf; ./cardtopng.sh $@
%[34].png: %.pdf; ./cardtopng.sh $@
%[35].png: %.pdf; ./cardtopng.sh $@
%[36].png: %.pdf; ./cardtopng.sh $@
%[image].png: %.pdf; ./cardtopng.sh $@

View file

@ -2,7 +2,7 @@
package iditacards
#AssetKind: "image" | "tex" | "texdoc" | "template" | "cat"
#AssetKind: "image" | "tex" | "texdoc" | "template" | "cat" | "svg"
#Asset: {
// passed to convert to create the "print" version (usually to add bleed)
@ -33,7 +33,7 @@ package iditacards
contents: [...string]
}
if kind == "tex" {
if kind == "tex" || kind == "svg" {
source: string
size: #Dimensions
}

View file

@ -1,44 +0,0 @@
# This file describes the assets of iditacards
# It is processed to produce the various source files that are then compiled
# into assets
# NOTE: [a. b] indicates that the object will be processed through the mako
# template templates/a.mako and output to generated/b. (templates/ and
# generated/ specified by arguments)
[card. "a_hat.tex"]
name = "A Hat"
costs.energy = 2
costs.health = 2
effects = { daydraw = "+1" }
image = "hat"
type = "attachment"
flavour = "I bet its a valve hat."
[card. "dog_chow.tex"]
name = "Dog Chow"
costs.energy = 3
cards.health = 3
effects = { speed = "+1" }
image = "dog_chow"
type = "attachment"
flavour = "A hungry dog is a slow dog."
[card. "good_dog.tex"]
name = "Good Dog"
costs.energy = 3
costs.health = 3
effects = { daydraw = "+1" }
image = "good_dog"
type = "dog"
flavour = "Good boy."
[deck. "starter1.mk"]
name = "starter1"
[deck. "starter1.mk". contents]
"A hat" = 1
"Breakfast" = 2

View file

@ -8,6 +8,21 @@ assets:
kind: image
source: cardback.png
cardback-firstleg:
kind: image
source: cardback.png
print: +level-colors black,"#9117FF"
cardback-secondleg:
kind: image
source: cardback.png
print: +level-colors black,"#17FF91"
cardback-thirdleg:
kind: image
source: cardback.png
print: +level-colors black,"#FF9117"
iditaboard:
kind: tex
source: iditaboard.tex
@ -20,3 +35,33 @@ assets:
instructions-anatomy:
kind: texdoc
source: instructions-anatomy.tex
die/cloud:
kind: svg
source: images/die/cloud.svg
size: 180x180
die/rain:
kind: svg
source: images/die/rain.svg
size: 180x180
die/snowflake:
kind: svg
source: images/die/snowflake.svg
size: 180x180
die/storm:
kind: svg
source: images/die/storm.svg
size: 180x180
die/sun:
kind: svg
source: images/die/sun.svg
size: 180x180
die/wind:
kind: svg
source: images/die/wind.svg
size: 180x180

View file

@ -1,42 +0,0 @@
#!/bin/bash
# Incremental build script.
# Main inputs are from the *.cue and *.yaml files in the top-level directory
# Assets are taken from raw/ tex/ mako/ etc and put into the output/ directory
# The output/ directory is populated with a ninja build script to do the
# actual build, along with source files that are updated for a build.
# Thus to build a full output in dir you would run: build.sh dir/ && cd dir/ && ninja build
# Once built once, a simple `ninja` in the output directory should suffice
# echo "new" | update file
# updates file with new content only if the content differs
update() {
fname="$1"
data="$(cat)"
new="$(echo "$data" | sha256sum | cut -d " " -f 1)"
old="$(sha256sum "$fname" | cut -d " " -f 1)"
if [ "$new" != "$old" ]; then
echo "Updating $fname"
echo "$data" > "$fname"
fi
}
outdir="${1:-output}/"
mkdir -p "$outdir"
json="$(cue export *.cue *.yaml)"
{
echo "# Generated by build.sh on $(date)"
echo "include ../rules.ninja"
EOF
} | update "$outdir/build.ninja"
# TODO: get json via `cue export *.cue *.yaml`

View file

@ -1,838 +0,0 @@
# vi: sw=2:ts=2:sts=2:et
cards:
a_hat: &a_hat
name: 'A Hat'
costs:
energy: 2
health: 2
effects:
daydraw: 1
image: hat
type: attachment
flavour: 'I bet its a valve hat.'
- &dog_chow
name: 'Dog Chow'
costs:
energy: 3
health: 3
effects:
speed: 1
image: dog_chow
type: attachment
flavour: 'A hungry dog is a slow dog.'
- &good_dog
name: 'Good Dog'
costs:
energy: 3
health: 3
effects:
- '\daydraw{+1}'
image: good_dog
type: dog
flavour: 'Good boy.'
- &husky
name: 'Husky'
costs:
energy: 2
health: 2
risk: 2
effects:
- '\daydraw{+1}'
- '\speed{+1}'
image: husky
type: dog
flavour: 'Standard mushing fare.'
- &wheel_dog
name: 'Wheel Dog'
costs:
energy: 3
health: 3
effects:
- '\speed{+1}'
- '\discardonkill'
- '\inplayatstart'
image: wheel_dog
type: dog
flavour: 'The dog right in front of the sled. Strong and steady.'
- &breakfast
name: 'Breakfast'
costs:
health: 3
effects:
- '\draw{3}'
image: breakfast
type: food
flavour: 'The most important meal of the day.'
- &lunch
name: 'Lunch'
costs:
energy: 3
effects:
- '\draw{3}'
image: lunch
type: food
flavour: 'What about second breakfast?'
- &dinner
name: 'Dinner'
costs:
energy: 2
health: 2
effects:
- '\draw{7}'
image: dinner
type: food
flavour: 'I hope you like salted fish.'
- &move
name: 'Move'
effects:
- '\move{1}'
image: move
type: movement
flavour: 'Just another day.'
- &mush
name: 'Mush'
costs:
energy: 2
health: 2
risk: 1
effects:
- '\move{10}'
image: mush
type: movement
flavour: "Comes from the french word ``Marche''."
- &first_aid
name: First Aid
costs:
energy: 2
health: 2
effects:
- '\see{3}'
- '\destroy{1}'
image: first_aid
type: personal
flavour: 'Reduces swelling.'
- &grandma_soup
name: Grandma Soup
costs:
energy: 1
health: 2
risk: 1
effects:
- '\see{10}'
- '\destroy{2}'
image: grandma_soup
type: personal
flavour: 'Cures what ails you.'
- &repair_sled
name: Repair Sled
costs:
energy: 1
health: 3
effects:
- '\supply{1}'
- '\take{2}'
image: repair_sled
type: sled
flavour: "It doesn't need to be pretty. It just has to work."
- &upgrade_sled
name: Upgrade Sled
costs:
energy: 2
health: 2
effects:
- '\supply{3}'
- '\take{1}'
image: upgrade_sled
type: sled
flavour: 'You have to keep your ride in top shape.'
- &buffer_panel
name: Buffer Panel
costs:
energy: 2
health: 2
effects:
- '\immortal'
- '\safepass'
image: buffer_panel
type: attachment
flavour: 'Did the primary buffer panel just fall of my gorram ship for no apparent reason?'
- &nuclear_reactor
name: Nuclear Reactor
costs:
energy: 2
health: 2
effects:
- '\speed{+5}'
- '\passdie'
image: nuclear_reactor
type: attachment
flavour: 'What could go wrong?'
- &engineer_dog
name: Engineer Dog
costs:
energy: 3
health: 5
risk: 1
effects:
- '\speed{$\times 2$}'
- '\nohold'
image: engineer_dog
type: dog
flavour: 'Nails and Gears.'
- &moose
name: Moose
costs:
energy: 5
risk: 3
effects:
- '\speed{+5}'
- '\immortal'
image: moose
type: dog
flavour: 'Majestic creatures. Hard to tame.'
- &waffle
name: Waffle
effects:
- '\draw{2}'
image: waffles
type: food
flavour: 'Waffles are \textbf{delicious}.'
- &whale_meat
name: Whale Meat
costs:
energy: 1
health: 1
effects:
- '\draw{5}'
- '\nohypothermia'
image: whale_meat
type: food
flavour: "It's like rubber."
- &hitch_a_ride
name: Hitch a Ride
costs:
energy: 1
effects:
- '\move{6}'
- '\damage{1}'
image: hitch_a_ride
type: movement
flavour: 'Probably not in the spirit of the race.'
- &tactical_play
name: Tactical Play
costs:
energy: 1
risk: 1
effects:
- '\move{0}'
- '\doubledistance'
image: tactical_play
type: movement
flavour: 'Make the most of it.'
- &meditate
name: Meditate
costs:
energy: 1
health: 1
effects:
- '\see{all}'
- '\destroy{0}'
image: meditate
type: personal
flavour: 'It \textit{is} just sitting.'
- &diamorphine
name: Diamorphine
costs:
energy: 1
health: 1
risk: 1
effects:
- '\see{all}'
- '\destroy{all}'
image: diamorphine
type: personal
flavour: 'Highly addicting.'
- &desperate_times
name: Desperate Times
costs:
energy: all
effects:
- '\supply{10}'
- '\take{5}'
image: desparate_times
type: sled
flavour: 'Desperate measures hotline, how may I help you?'
- &lead_sled
name: Lead Sled
costs:
energy: 1
health: 1
risk: 1
effects:
- '\supply{10}'
- '\take{10}'
image: lead_sled
type: sled
flavour: "At least it's not a zeppelin."
- &damaged
name: Damaged
costs:
energy: 1
health: 1
effects:
- '\damagetext'
image: damaged
type: damage
flavour: 'You have been hurt.'
- &dog_shoes
name: Dog Shoes
costs:
energy: 2
health: 3
effects:
- '\speed{+2}'
image: dog_shoes
type: attachment
flavour: 'Dogs look cute in shoes.'
- &squirrel
name: Squirrel
costs:
energy: 2
health: 2
risk: 1
effects:
- '\speed{+3}'
image: squirrel
type: attachment
flavour: 'Dogs \emph{hate} squirrels.'
- &tiara
name: Tiara
costs:
energy: 2
health: 2
risk: 1
effects:
- '\daydraw{+1}'
- '\speed{+1}'
image: tiara
type: attachment
flavour: 'Makes the dog feel special.'
- &bear
name: Bear
costs:
energy: 2
health: 2
risk: 2
effects:
- '\speed{+5}'
image: bear
type: dog
flavour: 'In hindsight, not the best idea.'
- &big_dog
name: Big Dog
costs:
energy: 2
health: 2
effects:
- '\speed{+3}'
image: big_dog
type: dog
flavour: "He's not red though."
- &greyhound
name: Greyhound
costs:
risk: 2
effects:
- '\speed{+3}'
- '\nohold'
image: greyhound
type: dog
flavour: 'What happens when you mix the colours on a husky? You get a grey hound.'
- &malamute
name: Malamute
costs:
energy: 2
health: 2
risk: 1
effects:
- '\daydraw{+2}'
image: malamute
type: dog
flavour: 'A common sled hauling breed.'
- &problem_dog
name: Problem Dog
costs:
energy: 1
health: 1
risk: 1
effects:
- '\daydraw{-1}'
- '\speed{+3}'
image: problem_dog
type: dog
flavour: "I swear, if you weren't so fast."
- &bison
name: Bison
costs:
energy: 2
risk: 1
effects:
- '\draw{5}'
image: bison
type: food
flavour: "It's very lean."
- &poutine
name: Poutine
costs:
health: 2
effects:
- '\draw{1}'
- '\nohypothermia'
image: poutine
type: food
flavour: 'The great Canadian carb!'
- &venison
name: Venison
costs:
health: 2
effects:
- '\draw{3}'
image: venison
type: food
flavour: 'Better than breakfast.'
- &steak
name: Steak
effects:
- '\draw{1}'
image: steak
type: food
flavour: "Well aren't you fancy."
- &jerky
name: Jerky
costs:
energy: 1
health: 1
effects:
- '\draw{3}'
image: jerky
type: food
flavour: 'Watch your sodium!'
- &midnight_sun
name: Midnight Sun
costs:
energy: 1
health: 1
risk: 1
effects:
- '\move{10}'
image: midnight_sun
type: movement
flavour: 'Strange things are done in the midnight sun.'
- &push
name: Push
costs:
energy: 1
effects:
- '\move{5}'
image: push
type: movement
flavour: 'Not a full mush, but still putting in some effort.'
- &slow_and_steady
name: Slow and Steady
effects:
- '\draw{1}'
- '\move{0}'
image: slow_and_steady
type: movement
flavour: 'Maybe a bit too slow.'
- &band_aid
name: Band Aid
effects:
- '\see{1}'
- '\destroy{1}'
image: band_aid
type: personal
flavour: 'Not much.'
- &bandage
name: Bandage
costs:
energy: 1
effects:
- '\see{5}'
- '\destroy{1}'
image: bandage
type: personal
flavour: 'Make sure you wrap it tight.'
- &brandy
name: Brandy
costs:
risk: 1
effects:
- '\see{5}'
- '\destroy{1}'
image: brandy
type: personal
flavour: 'Brought by a St.\ Bernard'
- &caffeine
name: Caffeine
costs:
health: 2
effects:
- '\draw{1}'
- '\see{2}'
- '\destroy{1}'
image: caffeine
type: personal
flavour: 'The greatest addiction ever.'
- &improvise
name: Improvise
effects:
- '\take{1}'
image: improvise
type: sled
flavour: 'MacGyver of the north.'
- &makeshift_sled
name: Makeshift Sled
costs:
energy: 1
health: 1
effects:
- '\supply{2}'
- '\take{6}'
image: makeshift_sled
type: sled
flavour: "Rickety, but it'll hold."
- &salvage
name: Salvage
costs:
energy: 1
health: 1
effects:
- '\supply{3}'
- '\take{2}'
image: salvage
type: sled
flavour: 'Take the good with the bad.'
- &antique_sled
name: Antique Sled
costs:
health: 5
effects:
- '\supply{2}'
- '\take{8}'
image: antique_sled
type: sled
flavour: 'Withstood the test of the time.'
- &rush
name: Rush
costs:
health: 3
risk: 1
effects:
- '\move{8}'
image: rush
type: movement
flavour: 'Hurry up!'
- &supply_run
name: Supply Run
effects:
- '\move{3}'
image: supply_run
type: movement
flavour: 'Not as easy as dropping by the grocery store.'
# The decks that the cards are in
# TODO: Add rarity?
decks:
- name: Starter1
cards:
- *a_hat
- *breakfast
- *breakfast
- *dinner
- *dog_chow
- *first_aid
- *first_aid
- *good_dog
- *grandma_soup
- *husky
- *lunch
- *lunch
- *move
- *move
- *move
- *move
- *mush
- *repair_sled
- *repair_sled
- *upgrade_sled
- *upgrade_sled
- *wheel_dog
- name: Starter2
cards:
- *a_hat
- *breakfast
- *breakfast
- *dinner
- *dog_chow
- *first_aid
- *first_aid
- *good_dog
- *grandma_soup
- *husky
- *lunch
- *lunch
- *move
- *move
- *move
- *move
- *mush
- *repair_sled
- *repair_sled
- *upgrade_sled
- *upgrade_sled
- *wheel_dog
- name: Starter3
cards:
- *a_hat
- *breakfast
- *breakfast
- *dinner
- *dog_chow
- *first_aid
- *first_aid
- *good_dog
- *grandma_soup
- *husky
- *lunch
- *lunch
- *move
- *move
- *move
- *move
- *mush
- *repair_sled
- *repair_sled
- *upgrade_sled
- *upgrade_sled
- *wheel_dog
- name: Starter4
cards:
- *a_hat
- *breakfast
- *breakfast
- *dinner
- *dog_chow
- *first_aid
- *first_aid
- *good_dog
- *grandma_soup
- *husky
- *lunch
- *lunch
- *move
- *move
- *move
- *move
- *mush
- *repair_sled
- *repair_sled
- *upgrade_sled
- *upgrade_sled
- *wheel_dog
- name: Damage
cards:
- *damaged
- *damaged
- *damaged
- *damaged
- *damaged
- *damaged
- *damaged
- *damaged
- *damaged
- *damaged
- name: Legendary
cards:
- *buffer_panel
- *desperate_times
- *diamorphine
- *engineer_dog
- *hitch_a_ride
- *lead_sled
- *meditate
- *moose
- *nuclear_reactor
- *tactical_play
- *waffle
- *whale_meat
- name: Race
cards:
- *bear
- *bear
- *big_dog
- *big_dog
- *dog_shoes
- *dog_shoes
- *greyhound
- *greyhound
- *improvise
- *improvise
- *midnight_sun
- *midnight_sun
- *problem_dog
- *problem_dog
- *push
- *push
- *rush
- *rush
- *slow_and_steady
- *slow_and_steady
- *squirrel
- *squirrel
- *supply_run
- *supply_run
- *tiara
- *tiara
- name: Survival
cards:
- *antique_sled
- *antique_sled
- *band_aid
- *band_aid
- *bandage
- *bandage
- *bison
- *bison
- *brandy
- *brandy
- *caffeine
- *caffeine
- *jerky
- *jerky
- *makeshift_sled
- *makeshift_sled
- *malamute
- *malamute
- *poutine
- *poutine
- *salvage
- *salvage
- *steak
- *steak
- *venison
- *venison
Legs:
- &farm
name: Farm
effects:
- '\allowednot{\includegraphics[width=1cm]{icons/starve.png}}'
spaces:
3: hypo
5: damage
7: hypo
- &fishing_hole
name: Fishing Hole
effects:
- '\daydraw{3}'
spaces:
3: damage
5: hypo
7: damage
- &hospital
name: Hospital
effects:
- '\freecardtype{personal}'
spaces:
3: starve
5: hypo
7: starve
- &new_moon
name: New Moon
effects:
- '\freecardtype{dog}'
spaces:
3: hypo
5: starve
7: hypo
- &repair_shop
name: Repair Shop
effects:
- '\freecardtype{sled}'
Legdecks:
- name: First
legs:
- *farm
- *fishing_hole
- *hospital
- *new_moon
# TODO: add legs

View file

@ -1,9 +0,0 @@
#!/bin/bash
# Syntax: cardtopng.sh cardname.png
OUTPUT=$1
INTERMEDIATE=$(echo "$1" | sed 's/\[.*\]\..*//')-raw.png
PDFNAME=$(echo "$1" | sed 's/\[.*\]\..*//').pdf
pdftoppm -scale-to-x 750 -scale-to-y 1050 -png $PDFNAME > $INTERMEDIATE
convert $INTERMEDIATE -set option:distort:viewport 825x1125-37-37 -virtual-pixel Edge -distort SRT 0 +repage $OUTPUT

View file

@ -102,17 +102,28 @@ def generate_cat_builds:
(.contents | map("output/" + . + ".raw.png") | join(" ")) as $rawcontents |
(.name | dirof) as $dir |
(.name | rawof) as $raw | "
build output/\($dir)\($raw).pdf: pdfunite \($pdfcontents)
build output/\($dir)\($raw).pdf | output/\($dir)\($raw)-mini.pdf: pdfunite \($pdfcontents)
build output/\($dir)\($raw).png: pngunite \($pngcontents)
build output/\($dir)\($raw).raw.png: pngunite \($rawcontents)
";
def generate_svg_builds:
(.size | split("x")[0]) as $w |
(.size | split("x")[1]) as $h |
(.name | dirof) as $dir |
(.name | rawof) as $raw | "
build output/\($dir)\($raw).png: svg2png \(.source)
w = \($w)
h = \($h)
";
def generate_builds:
(select(.kind == "template") | generate_template_builds),
(select(.kind == "image") | generate_image_builds),
(select(.kind == "tex") | generate_tex_builds),
(select(.kind == "texdoc") | generate_texdoc_builds),
(select(.kind == "cat") | generate_cat_builds);
(select(.kind == "cat") | generate_cat_builds),
(select(.kind == "svg") | generate_svg_builds);
def expandout: to_entries[] | .value + { name: .key };
def everything: (.assets, .pseudoassets) | expandout;

View file

@ -1,98 +0,0 @@
#!/usr/bin/env python3
""" Generates build.ninja for iditacards build in output/. """
import glob
import subprocess
import json
import os
cue_sources = glob.glob(f'*.cue')
yaml_sources = glob.glob(f'*.yaml')
sources = cue_sources + yaml_sources
everything = json.loads(subprocess.run(['cue', 'export', '--'] + sources, stdout=subprocess.PIPE).stdout)
assets = everything['assets']
pseudos = everything['pseudoassets']
all_assets = { **assets, **pseudos }
print('# Generated from configure.sh, do not edit this file!\n')
with open(f'{script_dir}/rules.ninja', 'r') as f:
print(f.read())
print(f'''
base = .
rule configure
description = recreate $out using $in
command = $in > $out
generator = 1
restat = 1
build build.ninja: configure ./configure.py | {' '.join(sources)}
build output/.everything.json: cuegen {' '.join(sources)}
filter = .
''')
for name, asset in all_assets.items():
assetdir = os.path
if asset['kind'] == 'template':
print(f'''
build output/.{name}.update | .{name}.json: extract .everything.json
filter = --arg asset '{name}' '.assets[$$asset].data'
target = .{name}.json
build tex/{name}.tex: template2tex .{name}.json | ../templates/{asset["template"]}
template = ../templates/{asset["template"]}
build {name}.pdf: tex2pdf tex/{name}.tex || .{name}.pdf.dd
dyndep = .{name}.pdf.dd
build .{name}.pdf.dd: scantex tex/{name}.tex
target = {name}.pdf
build {name}.{'raw.' if 'print' in asset else ''}png: pdf2png {name}.pdf
w = {asset['size'].split('x')[0]}
h = {asset['size'].split('x')[1]}
''')
if asset['kind'] == 'image':
print(f'''
build {name}.{'raw.' if 'print' in asset else ''}png: copy ../{asset['source']}
''')
if asset['kind'] == 'tex':
print(f'''
build {name}.pdf: tex2pdf ../{asset['source']} || .{name}.pdf.dd
dyndep = .{name}.pdf.dd
build .{name}.pdf.dd: scantex ../{asset['source']}
target = {name}.pdf
build {name}.{'raw.' if 'print' in asset else ''}png: pdf2png {name}.pdf
w = {asset['size'].split('x')[0]}
h = {asset['size'].split('x')[1]}
''')
if asset['kind'] == 'texdoc':
print(f'''
build {name}.pdf: tex2pdf2x ../{asset['source']} || .{name}.pdf.dd
dyndep = .{name}.pdf.dd
build .{name}.pdf.dd: scantex ../{asset['source']}
target = {name}.pdf
''')
if asset['kind'] == 'cat':
print(f'''
build {name}.pdf: pdfunite {' '.join(content + '.pdf' for content in asset['contents'])}
''')
if 'print' in asset:
print(f'''
build {name}.png: convert {name}.raw.png
args = {asset['print']}
''')

View file

@ -1,141 +0,0 @@
#!/bin/bash
# Outputs a build.ninja script for placing into $1 (or output/ if omitted)
scriptdir="$(dirname -- "${BASH_SOURCE[0]}")"
builddir="${1-output}"
cue_sources=( "$scriptdir"/*.cue "$scriptdir"/*.yaml )
everything="$(cue export -- "${cue_sources[@]}" | jq -c)"
ASSET_TO_JSON="| to_entries[] | .value + { name: .key }"
mapfile -t assets < <(jq -c ".assets $ASSET_TO_JSON" <<<"$everything")
mapfile -t pseudos < <(jq -c ".pseudoassets $ASSET_TO_JSON" <<<"$everything")
# base is the directory that contains the script
base="$(realpath -s --relative-to="$builddir" "$scriptdir")"
# root is the directory that the assets are generated into
root=.
relative_cue_sources=( )
for cue_source in "${cue_sources[@]}"; do
relative_cue_sources+=( "$base/$cue_source" )
done
cat <<EOF
# Generated from configure.sh, do not edit this file!
base = $base
EOF
cat "$scriptdir/rules.ninja"
cat <<EOF
rule configure
description = recreate build.ninja using $base/configure.sh
command = $base/configure.sh $root
generator = 1
restat = 1
build ./build.ninja: configure | $base/configure.sh ${relative_cue_sources[*]}
build $root/.everything.json: cuegen ${relative_cue_sources[*]}
filter = .
EOF
for asset in "${assets[@]}" "${pseudos[@]}"; do
# reset asset variables, also quiets shellcheck
name=
print=
kind=
source=
template=
size=
data=
contents=
eval "$(jq -r 'to_entries[] | "\(.key)=\(.value|@text|@sh)"' <<<"$asset")"
rawsuffix="$(echo -n "$print" | sed 's/.*/raw./')"
case $kind in
template)
cat <<EOF
build $root/.$name.updated | $root/.$name.json: extract $root/.everything.json
filter = --arg asset '$name' '.assets[\$\$asset].data'
target = $root/.$name.json
build $root/tex/$name.tex: template2tex $root/.$name.json | $base/templates/$template
template = $base/templates/$template
build $root/$name.pdf: tex2pdf $root/tex/$name.tex || $root/.$name.pdf.dd
dyndep = $root/.$name.pdf.dd
build $root/.$name.pdf.dd: scantex $root/tex/$name.tex
target = $root/$name.pdf
build $root/$name.${rawsuffix}png: pdf2png $root/$name.pdf
w = ${size%x*}
h = ${size#*x}
EOF
;;
image)
cat <<EOF
build $root/$name.${rawsuffix}png: copy $base/$source
EOF
;;
tex)
cat <<EOF
build $root/$name.pdf: tex2pdf $base/$source || $root/.$name.pdf.dd
dyndep = $root/.$name.pdf.dd
build $root/.$name.pdf.dd: scantex $base/$source
target = $root/$name.pdf
build $root/$name.${rawsuffix}png: pdf2png $root/$name.pdf
w = ${size%x*}
h = ${size#*x}
EOF
;;
texdoc)
cat <<EOF
build $root/$name.pdf: tex2pdf2x $base/$source || $root/.$name.pdf.dd
dyndep = $root/.$name.pdf.dd
build $root/.$name.pdf.dd: scantex $base/$source
target = $root/$name.pdf
EOF
;;
cat)
mapfile -t ins < <(jq -r ".[]" <<<"$contents")
echo -n "build $root/$name.pdf: pdfunite"
for i in "${ins[@]}"; do
echo -n " $root/$i.pdf"
done
echo
;;
*)
echo "ERROR! UNKNOWN ASSET TYPE $kind!" >&2
;;
esac
# always run convert if print is non-empty
if [ -n "$print" ]; then
cat <<EOF
build $root/$name.png: convert $root/$name.raw.png
args = $print
EOF
fi
done

120
make.py
View file

@ -1,120 +0,0 @@
#!/usr/bin/env python3
"""
Used as a tool by the Makefile.
Updates only those files whose contents are changed by changes to the given yaml
file.
"""
import sys
from textwrap import dedent
import yaml
def read_cards(filename=None):
"""
Reads the given file as yaml into card information data.
"""
if filename is not None:
with open(filename, 'r') as yaml_file:
data = yaml.load(yaml_file, Loader=yaml.FullLoader)
else:
data = yaml.load(sys.stdin, Loader=yaml.FullLoader)
return data
def card_to_tex(card, deck, rarity):
"""
Returns a card's LaTeX as a string.
"""
head = f"""\
\\documentclass{{iditacard}}
\\cardtype{{{card['type']}}}
\\rarity{{{rarity}}}
\\deck{{{deck}}}
\\begin{{document}}
\\begin{{card}}
\\art{{{card['image']}}}
"""
effect_text = "\\quad".join(card['effects'] if 'effects' in card else [])
tail = f"""\
\\name{{{card['name']}}}
\\text{{{effect_text}}}
\\flava{{{card['flavour']}}}
\\type{{{card['type']}}}
\\end{{card}}
\\end{{document}}\
"""
costs = card["costs"]
costr = ""
if 'energy' in costs and costs['energy'] != 0:
costr += f" \\energy{{{costs['energy']}}}\n"
if 'health' in costs and costs['health'] != 0:
costr += f" \\health{{{costs['health']}}}\n"
if 'risk' in costs and costs['risk'] != 0:
costr += f" \\risk{{{costs['risk']}}}\n"
return dedent(head) + costr + dedent(tail)
def leg_to_tex(leg, level):
"""
Returns a leg's LaTeX as a string.
"""
head = f"""\
\\documentclass{{iditacard}}
\\leglevel{{{level}}}
\\begin{{document}}
\\begin{{leg}}
\\legname{{{leg['name']}}}
"""
spaces = ""
for space in range(1, 11):
if str(space) in leg['spaces']:
icon = f"\\legspaceicon{{{leg['spaces'][space]}}}"
spaces += f" \\onlegspace{{{space}}}{{{icon}}}\n"
effect_text = "\\quad".join(leg['effects'] if 'effects' in leg else [])
tail = f"""\
\\legeffect{{{effect_text}}}
\\end{{leg}}
\\end{{document}}\
"""
return dedent(head) + spaces + dedent(tail)
def dump_decks_to(decks, directory):
"""
Dumps all tex from decks to the given directory.
For each deck in decks it will generate:
- a directory within the given directory with the same name
- .tex files for each card in the deck in the above directory
- .list file in the given directory with the same name as the deck
- one line in the list file for each pdf that would go into said deck
"""
return 'TODO'
# TODO: fill out dump_decks_to, create dump_legs_to and call them with the
# appropriate directory in main (using sys.argv)
#
# also write a script to extract all deck names for use in the makefile (to be
# assigned to the DECK_LIST/DECK_DEPENDENCIES variables
def main():
"""
Main entry point.
"""
cards = read_cards()
print(card_to_tex(cards['cards'][0], "thedeck", "therarity"))
if __name__ == '__main__':
main()

View file

@ -1,37 +0,0 @@
#!/usr/bin/env python3
"""
Used as a tool by the Makefile to generate sources from the assets.toml file.
"""
import toml
from mako.template import Template
def update_file(fname, contents):
"""
Updates the given file with the given contents unless .fname.hash matches
hash(contents).
"""
try:
with open(f'.{fname}.hash', 'r') as fhash:
if fhash.read() == str(contents):
return
except:
pass
with open(fname, 'w') as f:
f.write(contents)
def main(infile, outdir):
"""
Entry point: generates outputs based on data in input files.
"""
with open(infile, 'r') as f:
data = toml.load(infile)
for template_name in data:
template = Template(filename=template_name)
for output_name in data[template_name]:
result = template.render(**data[template_name][output_name])
update_file(outdir + '/' + output_name, result)

View file

@ -3,6 +3,10 @@
pool tex_pool
depth = 4
# Inkscape doesn't like running multiple processes sometimes
pool ink_pool
depth = 1
# 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
@ -73,3 +77,8 @@ rule pdfunite
rule pngunite
description = unite pngs to create a mosaic
command = magick montage -mode concatenate $in $out
rule svg2png
description = convert svg $in to ${w}x$h png $out
command = inkscape -w $w -h $h $in -o $out 2>/dev/null
pool = ink_pool

View file

@ -1,50 +0,0 @@
#!/bin/bash
# TODO: there should be some way to use -recorder to get list of dependencies
# somehow, though I'd hate to regenerate the whole PDF just to make dependencies
# note that the snapshot package is even better
# NOTE: next thing to try is the create temporary document with
# \RequirePackage{snapshot} appended to the top, then run xelatex normally and
# process the output *.dep (or *.log) file to extract the necessary
# requirements. It may be possible to use additional xelatex flags to reduce
# unnecessary work
echo 'ninja_dyndep_version = 1'
src="$1"
dst="$2"
tgt="${dst%%.*}.pdf"
aux="${dst%%.*}.aux"
log="${dst%%.*}.log"
# get_tex command
# returns the argument of \command{...} in the src document
get_tex() {
grep "[\]$1" "$src" | sed 's/.*{\(.*\)}.*/\1/'
}
deps=( )
if grep -q '\\documentclass{iditacard}' "$src"; then
deps+=(
# The class file
'iditacard.cls'
# The artwork
"images/card/$(get_tex art).png"
# The deckmark
"images/deck/$(get_tex deck).png"
)
fi
read -r -a rawimages <<<"$(grep -o '\\includegraphics[^}]*}' "$src" | sed 's/.*{\(.*\)}.*/images\/\1/')"
deps+=( "${rawimages[@]}" )
if [ "${#deps[@]}" -gt 0 ]; then
echo "build $tgt | $aux $log : dyndep | ${deps[*]}"
else
echo "build $tgt | $aux $log : dyndep"
fi