From 33db092023a3ffba698755119603cd00dbab8a86 Mon Sep 17 00:00:00 2001 From: Louis Burke Date: Mon, 16 Sep 2024 00:38:22 -0400 Subject: [PATCH] Preservation commit before deciding on a data format --- Makefile | 28 +- assets.toml | 44 +++ assets.yaml | 641 +++++++++++++++++++++++++++++++++ cards.yaml.recovered | 838 +++++++++++++++++++++++++++++++++++++++++++ make_mako.py | 37 ++ rules/checks.mk | 18 + rules/conversion.mk | 6 + rules/generated.mk | 6 + rules/mako.mk | 15 + rules/outputs.mk | 7 + rules/rsync.mk | 4 + templates/card.mako | 6 + templates/deck.mako | 10 + templates/test.mako | 3 + test.json | 31 ++ 15 files changed, 1669 insertions(+), 25 deletions(-) create mode 100644 assets.toml create mode 100644 assets.yaml create mode 100644 cards.yaml.recovered create mode 100644 make_mako.py create mode 100644 rules/checks.mk create mode 100644 rules/conversion.mk create mode 100644 rules/generated.mk create mode 100644 rules/mako.mk create mode 100644 rules/outputs.mk create mode 100644 rules/rsync.mk create mode 100644 templates/card.mako create mode 100644 templates/deck.mako create mode 100644 templates/test.mako create mode 100644 test.json diff --git a/Makefile b/Makefile index c7a0da3..0a00f59 100644 --- a/Makefile +++ b/Makefile @@ -8,25 +8,9 @@ default: check decks all: check decks export prototype: mini -# Check existence of necessary executables -CONVERT:=$(shell command -v convert 2> /dev/null) -XELATEX:=$(shell command -v xelatex 2> /dev/null) -PDFTOPPM:=$(shell command -v pdftoppm 2> /dev/null) -PDFUNITE:=$(shell command -v pdfunite 2> /dev/null) +ASSET_TOML=assets.toml -check: $(SENTINEL) -ifndef CONVERT - $(error "convert not found. Please install imagemagick") -endif -ifndef XELATEX - $(error "xelatex not found. Please install xetex") -endif -ifndef PDFTOPPM - $(error "pdftoppm not found. Please install poppler") -endif -ifndef PDFUNITE - $(error "pdfunite not found. Please install poppler") -endif +include rules/*.mk RAW_DECK_LIST=$(shell ./scripts/decklist.sh) first second third DECK_LIST=$(RAW_DECK_LIST:%=$(GENERATED_DIR)/%) @@ -59,13 +43,7 @@ $(SENTINEL): cards.sql Makefile.deps: $(SENTINEL) $(DECK_DEPENDENCIES) cat $^ > $@ -include Makefile.deps - -outputs/iditaboard[face].png: iditaboard.pdf - $(PDFTOPPM) -scale-to-x 4875 -scale-to-y 3075 -png $< > $@ - -outputs/cardback.png: cardback.png - cp $< $@ +#include Makefile.deps export: outputs/cardback.png export: outputs/iditaboard[face].png diff --git a/assets.toml b/assets.toml new file mode 100644 index 0000000..6f98093 --- /dev/null +++ b/assets.toml @@ -0,0 +1,44 @@ +# 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 + + + diff --git a/assets.yaml b/assets.yaml new file mode 100644 index 0000000..cdce07a --- /dev/null +++ b/assets.yaml @@ -0,0 +1,641 @@ +# This file describes the assets of iditacards +# vim: fdm=marker + +# It is processed to produce various source files that are then compiled into +# assets + +# TODO: Change the system to be more like the toml. Just have a: b: generate +# b using a.mako, but a: -b does not. (except unlike l4den, yaml can't mix +# arrays and objects, so maybe use _: -b -c -...?) + +# Any object with an "output" key will be processed to produce said output by +# using its "template" key as a mako template and passing "data" is data. + +cards: # {{{ + - &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.' + +# }}} + +decks: + - name: Starter1 + cards: + - &a_hat1 + data: + <<: *a_hat + rarity: common + deck: Starter1 + output: "cards/a_hat1.tex" + template: "templates/card.mako" + - *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 + diff --git a/cards.yaml.recovered b/cards.yaml.recovered new file mode 100644 index 0000000..0ddd02a --- /dev/null +++ b/cards.yaml.recovered @@ -0,0 +1,838 @@ +# The cards +cards: + - &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 diff --git a/make_mako.py b/make_mako.py new file mode 100644 index 0000000..d6f11f2 --- /dev/null +++ b/make_mako.py @@ -0,0 +1,37 @@ +#!/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) diff --git a/rules/checks.mk b/rules/checks.mk new file mode 100644 index 0000000..df83e67 --- /dev/null +++ b/rules/checks.mk @@ -0,0 +1,18 @@ +# Checks existence of necessary executables +CONVERT:=$(shell command -v convert 2> /dev/null) +XELATEX:=$(shell command -v xelatex 2> /dev/null) +PDFTOPPM:=$(shell command -v pdftoppm 2> /dev/null) +PDFUNITE:=$(shell command -v pdfunite 2> /dev/null) + +ifndef CONVERT + $(error "convert not found. Please install imagemagick") +endif +ifndef XELATEX + $(error "xelatex not found. Please install xetex") +endif +ifndef PDFTOPPM + $(error "pdftoppm not found. Please install poppler") +endif +ifndef PDFUNITE + $(error "pdfunite not found. Please install poppler") +endif diff --git a/rules/conversion.mk b/rules/conversion.mk new file mode 100644 index 0000000..3736e72 --- /dev/null +++ b/rules/conversion.mk @@ -0,0 +1,6 @@ +%.pdf: %.tex + $(XELATEX) -interaction=batchmode -halt-on-error --shell-escape --output-directory=$(@D) $< + rm $*.aux + rm $*.log + + diff --git a/rules/generated.mk b/rules/generated.mk new file mode 100644 index 0000000..a0d036d --- /dev/null +++ b/rules/generated.mk @@ -0,0 +1,6 @@ +ASSET_NAMES=$(shell aq -it -oj -r '.[] | keys | .[]' < $(ASSET_TOML)) +GENERATED_SOURCES=$(ASSET_NAMES:%=$(GENERATED_DIR)/%) + +update_sources: $(ASSET_TOML) + ./make_mako.py $^ $(GENERATED_DIR) + diff --git a/rules/mako.mk b/rules/mako.mk new file mode 100644 index 0000000..37d4e60 --- /dev/null +++ b/rules/mako.mk @@ -0,0 +1,15 @@ +ASSETS=$(shell aq -it -oj -r '.[] | keys[]' < $(ASSET_TOML)) +GENERATED_ASSETS=$(patsubst %,generated/%,$(ASSETS)) + +MAKO_SCRIPT=from mako.template import Template; \ + import json; \ + import sys; \ + print(Template(filename=sys.argv[1]).render(**json.load(sys.stdin))) +AQ_FIND_SCRIPT=to_entries[] | select(.value|has("$*")) + +$(GENERATED_ASSETS): generated/%: $(ASSET_TOML) + TEMPLATE="templates/$$(aq -it -oj -r '$(AQ_FIND_SCRIPT) | .key' < $^).mako"; \ + aq -it -oj '$(AQ_FIND_SCRIPT) | .value["$*"]' < $^ \ + | python -c '$(MAKO_SCRIPT)' "$$TEMPLATE" > $@.raw + rsync --remove-source-files --checksum $@.raw $@ + diff --git a/rules/outputs.mk b/rules/outputs.mk new file mode 100644 index 0000000..71383aa --- /dev/null +++ b/rules/outputs.mk @@ -0,0 +1,7 @@ +outputs/iditaboard[face].png: iditaboard.pdf + $(PDFTOPPM) -scale-to-x 4875 -scale-to-y 3075 -png $< > $@ + +outputs/cardback.png: cardback.png + cp $< $@ + + diff --git a/rules/rsync.mk b/rules/rsync.mk new file mode 100644 index 0000000..712bcc3 --- /dev/null +++ b/rules/rsync.mk @@ -0,0 +1,4 @@ +# Shorthand rule for copying the standard input to the result file +define rsync-copy +cat > $@.raw; rsync --remove-source-files --checksum $@.raw $@ +endef diff --git a/templates/card.mako b/templates/card.mako new file mode 100644 index 0000000..989690d --- /dev/null +++ b/templates/card.mako @@ -0,0 +1,6 @@ +## % TODO: how to get the deck info? +\documentclass{iditacard} + +\cardtype{${type}} +## \rarity{${rarity}} +## \deck{${deck}} diff --git a/templates/deck.mako b/templates/deck.mako new file mode 100644 index 0000000..ffb9c12 --- /dev/null +++ b/templates/deck.mako @@ -0,0 +1,10 @@ +<% + # Creates a flattened map of repeated elements + components = [x for (k, v) in contents.items() for x in [k]*v] +%> +outputs/${name}.pdf: ${' '.join(components)}; pdfunite $+ $@ +% for (card, count) in contents.items(): +export: outputs/generated/${name}/${card}[${count}].png +outputs/generated/${name}/${card}[${count}].png: generated/${card}.png; cp $^ $@ +% endfor +decks: outputs/${name}.pdf diff --git a/templates/test.mako b/templates/test.mako new file mode 100644 index 0000000..7f57826 --- /dev/null +++ b/templates/test.mako @@ -0,0 +1,3 @@ +% for (k, v) in data.items(): +${k} is ${v}! +% endfor diff --git a/test.json b/test.json new file mode 100644 index 0000000..8948bbb --- /dev/null +++ b/test.json @@ -0,0 +1,31 @@ +{ + "data": { + "a_hat.tex": { + "name": "A Hat", + "costs": { + "energy": 2, + "health": 2 + }, + "effects": { + "daydraw": "+1" + }, + "image": "hat", + "type": "attachment", + "flavour": "I bet its a valve hat." + }, + "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." + } + }}