Coder Social home page Coder Social logo

dominiontabs's Introduction

Dominion Divider Generation

Tests

Introduction

This is a script and library to generate card dividers for storing cards for the game Dominion. If you are just looking go generate some dominion dividers, there is no need to install this script as I host a live version of this generator code. However, if you want to use arguments that I don't expose on that page, or change the code, or contribute to the project the full generation code (not the web interface or the fonts) is included here, and contributions are more than welcome.

Again, to generate tabs go to the Online Generator.

Installation

If you do need to install the package locally (the script provides a lot more options than the web-based generator), a simple pip install domdiv should suffice, providing a command by the name of dominion_dividers. However, see the note under Prerequisites->Fonts below as the default install will fall back on a font that doesn't match the cards (though most people don't notice). Run dominion_dividers <outfile> to get a pdf of all dividers with the default options, or run dominion_dividers --help to see the (extensive) list of options.

Additionally, to ensure the card dividers are generated sorted by correct alphabetical order (especially for languages with many accented characters (e.g. Czech)), you are advised to install the optional PyICU library. If PyICU is installed (instructions), the script will sort the card dividers based on selected language alphabet (e.g. in Czech z < ΕΎ). Otherwise, default sorting will be used (the cards beginning with accented characters will be at the end of the sorted set).

Documentation

The script has an extensive set of options that are relatively well documented via dominion_dividers --help. Some are hard to describe unless you see output samples, so we recommend running the script with various options to see which configuration you like. The help output is replicated here for reference.

Translations

When changing any of the card database files you should run the language update tool via doit update_languages. This produces the package version of the card db from the card db source. This will also be run automatically and checked into git when you push to github. You should make sure that the resulting changes to the package are what you intend by generating dividers in the relevant languages.

If you would like to help with translations to new (or updating existing) languages, please see instructions here.

Fonts

There are a number of fonts used in Dominion and many of them we cannot distribute with the package. We use fallbacks to commonly distributed fonts that work fine if you don't care the match the game exactly. If you do want to match, the script prints the preferred fonts if it uses fallbacks. Some come with programs like Adobe Reader and you can grab them from there.

Sadly, many of these fonts use features that are not support by the reportlab package. Thus, they need to first be converted to ttf (TrueType) format. I used the open source package fontforge to do the conversion. Included as 'tools/convert_font.ff' is a script for fontforge to do the conversion, on Mac OS X with fontforge installed through macports or homebrew you can just run commands like ./tools/convert_font.ff MinionPro-Regular.otf.

If you select language in domdiv options which is not supported in ISO/IEC 8859-1:1998 (Latin1) (e.g. Czech), you will have to obtain Times Roman TTF fonts as well (see ./src/domdiv/fonts/README.md for details).

To supply fonts locally, put them in a directory and supply the relative path to it to the script via the --font-dir option. Alternatively you can copy the converted .ttf files to the fonts directory in the domdiv package/directory, then perform the package install below.

Using as a library

The library will be installed as domdiv with the main entry point being domdiv.main.generate(options). It takes a Namespace of options as generated by python's argparser module. You can either use domdiv.main.parse_opts(cmdline_args) to get such an object by passing in a list of command line options (like sys.argv), or directly create an appropriate object by assigning the correct values to its attributes, starting from an empty class or an actual argparse Namespace object.

Developing

Install requirements via pip install -r requirements.txt. Then, run pre-commit install. You can use pip install -e .[dev] to install the dominion_dividers script so that it calls your checked out code, enabling you to run edited code without having to perform an install every time. This also installs needed dev dependencies, or if you want the pinned versions use pip install -r dev-requirements.txt instead.

Feel free to comment on boardgamegeek at https://boardgamegeek.com/thread/926575/web-page-generate-tabbed-dividers or file issues on github (https://github.com/sumpfork/dominiontabs/issues).

Tests can be run (and their dependencies installed) via pip install .[dev] and then doit test. They will also run if/when you push a branch or make a PR.

Image Sources

There is a separate repo for the image sources. While these are optional, they can be useful reference and/or used for creating new or recreating old tab banners, icons, etc. Many of these were originally scans of the physical game. Some of them have a lot of layers and are approaching 1GB in size, so they are hosted via Git LFS. As the Github version of that incurs a higher monthly cost, I instead host them on a private LFS server. If you would like the images or would like to contribute images let me know and I can make you an account on said server, or you I can copy them for you for easier access.

Docker

The project can be compiled into a container:

docker build . -t dominiontabs

Once you have the dominiontabs container you can run it from your CLI and pass it arguments like so, mapping the local directory to where the script will run so you can use local fonts and access the output file (example produces German dividers for Seaside 2nd edition):

docker run -v .:/app dominiontabs --language=de --expansions=seaside2ndEdition

  1. Bind mount to an output directory (-v) and tell the script to output there so that we get a PDF in the local filesystem when things are done (--outfile ./output/foo.pdf).
  2. Add the --rm argo to tell docker not to save a container each time it runs.
  3. Point to the fonts built in to the image with --font-dir /fonts
  4. Add a few CLI args to reduce the runtime and file size (--expansions cornucopia).

So now we have

docker run -v $PWD/output:/app/output --rm dominiontabs --font-dir /fonts --expansions cornucopia --outfile ./output/dominion_dividers_docker.pdf

(Replace $PWD with %cd% on Windows OS)

Once that runs you should have under your current directory:

./output/dominion_dividers_docker.pdf

From there you feel free to add other arguments as you like!

dominiontabs's People

Contributors

aarongilly avatar bszonye avatar dennislaumen avatar despian avatar github-actions[bot] avatar gwen1230 avatar idlaviv avatar inigogutierrez avatar jdgordon avatar md5i avatar mr-ice avatar mrgrain avatar msykora avatar nickv2002 avatar nstraz avatar openam avatar piroxxi avatar pjmikkol avatar pmolodo avatar rmammouth avatar robertre avatar robertre2 avatar rystan avatar smrky1 avatar splatteredbits avatar sumpfork avatar tcnuk avatar wdoekes avatar wvoigt avatar xedorian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dominiontabs's Issues

Hovel

Hovel has the wrong colors and two coin images, one overlapping the other.

Landmarks Banner Art Missing

Unlike all other dividers, the tab for the Landmarks divider has no banner art. Was expecting something similar to the Events banner, but green.

Possession rules need to be updated

Per Empires rulebook page 4

"Possession (from Dominion: Alchemy) now has errata that causes it to also give the Possessing player
all tokens the Possessed player would get, which includes Debt tokens."

Page and Peasant Cost

From BGG thread comment: Found an error just now with the Adventures tabs - the upgrades to Page and Peasant should have an asterisk in their cost.

Avery Label Vertical Alignment

From Kaleb Eubank (Grindar on BGG):

I used the Avery 5167 option on the tab generator (all expansions, sleeved, vertical if it matters, figured the last 2 would just be ignored since the avery label is fixed size). Does it generate the page from the bottom up? I printed them onto the label paper and what it looks like is the bottom one on each row is centered perfect, but the ones with the corners that stick up must be like a pixel too tall because as you go up the page they slowly shift further and further up. At the top it's still usable but the color from the one below is bleeding onto the bottom edge of the last label and the top edge. I'm attaching a pic of a typical bottom row so you can see it in action...bottom one seems centered, but by the top of the pic the top edge is already off the label. Of course, printed with no scaling.

Sample

Alternative Minion Pro Font Download Option

A website called FontsGeek is offering downloads of Minion Pro: Regular, Bold, and Italic

These files still need to be run through ./convert.ff (I handled the FontForge dependency with HomeBrew on my Mac) and they need slight renaming to match the file names expected by the script. However, it's an easier option than extracting them from an install of Adobe Reader.

@sumpfork are you okay with us providing a link to this on the front page?

Add Card counts to database, have option to print on dividers

I want the option to print the number of cards on the divider, with the following extras:

  1. For groupings, if only the one divider is printed, then that displays the sum of all the cards under that grouping.
  2. The same goes for Events and Prizes

PDF Output Displays Borders On Every Other Page

Submitted form from web front end at:

http://sandflea.org/

using settings as indicated in "Form Settings.png"

Page 1 output was good as displayed in "Output Good Borders.png"
Page 2 output was missing borders as displayed in "Output No Borders.png"

See attachments...
Thanks for your amazing contributions!
Warm regards,
blue-onyx

OS X 10.8.5 viewing the generated PDFs in Mac Preview 6.0.1

form settings
output good borders
output no borders

One sided version with rules

From BGG user InfoCynic:

Is it possible to generate:
* 1-sided
* Omit card text
* Include rules text 

That way if we're printing on one-sided labels or taping a lightweight paper to something heavier, we
have the important info (the rules text). We can always read the cards if we want to know what they
say.```

Show previews of different options

If there were picture previews of each option then we wouldn't have to generate an entire pdf just to see what one small change does.

Exclude Individual Events should also apply to Landmarks

Landmarks, like Events, are 1x cards that most people will want to group together. I think the option we already have to group Events is sufficient (no need for a second option). When this flag is toggled, only the Landmark group should be printed instead of dividers for each Landmark.

Add Action/Treasure banner image

The Empire expansions has cards of this type that have a mixed banner image. We are currently using a simple Treasure banner instead. Easiest would be to scan the image from the box insert and add it in the same place as the others - code change is minimal.

cards.yaml missing Adventures cards

It looks like the Adventures card set was only added to dominion_cards.txt and dominion_card_extras.txt, so the yaml database doesn't have these cards.

Make web code public and fully automate deployment

This is a bit of a note to myself and a bigger project, but I'd like to see

  • the django project that runs the website be public in another git repo
  • the deployment process of the web service be fully automated, i.e.
    • make the web site on my serving host
    • checkout out the relevant two repos
    • configure the website properly

Another option would be to move the service to something like AWS and use lambdas for the actual generation. I have quite a bit of experience with this and it might be cheaper and easier to deploy in the long run, but it would involve moving the whole existing website to AWS to be worthwhile.

Add option for Center Tab

Posted on Board Game Geek (thanks again):
This is a great tool. For something as simple and straightforward as dividers for a card game, you have gone way above and beyond and customized a way to satisfy all of us very picky and particular individuals.

I am a Python novice, so I must admit that the majority of code is beyond me. I've done my best to see if I can find the location of one minor detail in your divider generator, but I haven't had the luck. Even if I did, I'm not sure I'd be able to run the script.

Would it be possible to add an option for the tabs to be centered? They'd be the same size as tabs on the left or right, but centered, instead of full? A tiny detail compared to some of the more complex/useful issues your trying to solve, but I thought I'd ask.

Either way, this is a spectacular offering. Thank you.

3 tab option

From BGG thread, zombie13 wrote:

These tabs (and generator) rock. I don't suppose it would be too much trouble to make them 3-tab instead of 2-tab (right, center, left)? I really prefer 3 tab, but can't program python to save my life.

Allow for grouping of additional setup cards (i.e. 'Page Upgrades', 'Prizes')

In order to properly get the back-and-forth tabs working, we need to have the option to leave out all the page and peasant upgrades as well as tournament prizes and mercenary / madman -- basically an option to treat all cards that are not normally in the supply as a separate set would do, but making it such that all page upgrades were lumped together, etc would also be nice.

Request for Placeholder Randomizer Tab

Could we get a Placeholder/Randomizer tab? I would think a blue banner would suffice.

On a similar note it seems odd to me with Empires coming out that there Events (and I presume Landmarks) have set icons on their banner. Events are no longer expansion specific. Also its a bit distracting/odd looking since the icon covers part of the banner pattern which kinda blurs both the pattern and icon together in an not so readable way. Same goes for the coin icons on events. Would it be possible to include an option to print Events, Landmarks, Randomizers without set Icons/Coins at the end of the PDF as well so we wouldn't have to print off 3 extra pages for each of these since they will likely be scattered throughout the document.

Italian language option doesn't work with --read_yaml option

Trying to run the program with both the Italian language option with the --read_yaml option fails because there is no yaml file with the translation. Without the yaml option everything works fine.

The version hosted online returns a blank pdf if you choose the Italian option probably for the same reason.

C:\Users\Adam\Documents\GitHub\dominiontabs>dominion_tabs.py --read_yaml --langu
age it > yaml.txt

Traceback (most recent call last):
  File "C:\Users\Adam\Documents\GitHub\dominiontabs\dominion_tabs.py", line 1181
, in <module>
    tabs.main(sys.argv[1:])
  File "C:\Users\Adam\Documents\GitHub\dominiontabs\dominion_tabs.py", line 898,
 in main
    return self.generate(options, fname)
  File "C:\Users\Adam\Documents\GitHub\dominiontabs\dominion_tabs.py", line 1068
, in generate
    os.path.join(self.filedir, "card_db", options.language, "cards.yaml"), "r")
IOError: [Errno 2] No such file or directory: 'C:\\Users\\Adam\\Documents\\GitHu
b\\dominiontabs\\card_db\\it\\cards.yaml'
    b\\dominiontabs\\card_db\\it\\cards.yaml'

Group Special Cards (Shelters) are incorrect color

When Shelters are grouped the banner label is white and red. the banner label should be solely red as not all shelters are not Action-Shelters. (White-Red) The color all shelters have in common is red. This is also how Dark Ages lists Shelters in the box insert.

BTW great job on putting together this program.

Make deployment more trackable

Deployment to the online generator should:

  • use a tag
  • include that tag in the changelog online
  • give a link to the included change diff
  • ideally be more automated

Differnt Sorting

In my opinion. one of the best features are the tabs on alternating sides, for better handling.
Though with alternating tabs, the order of the slides becomes relevant. They ordered alphabetically by default. It would be great to give the option to sort them first by expansion and then by pricepoint.
This would mirror the order in the standardbox.

Add unit tests

Checking the actual pdf output would be quite a bit of work, so for now

  • check that the various flags execute ok
  • check that the input files are valid JSON of the expected format
  • add these tests for github to run

Add A3 papersize

Hi, would be possible to add "A3" paper size with no page margin? This would allow to print 16 dividers on each page. Thanks :-)

"Page not found." error

I just got a new(to me) expansion and went to generate the next set of tabs and got a "Page not found." error message.

I just created a few sets of tabs in November without issue. My guess is the update on 12/1/2015 may have added a little bug.

I did a little more testing and have found this issue only appears when you check the 'Cropmarks instead of outlines' option.
Please let me know if you need any more information or screenshots. This error should be easily replicated though.

Get rid of old style card spec files in favour of yaml version

The yaml needs some thoughts and fixing, but the old style is awful to maintain. Its only advantage is that sometimes copying from web pages that have card lists gives you something that's close to the old style - maybe there should be a conversion script saved off during the switch.

Add other languages from BGG

Boardgamegeek.com has a bunch translated instruction books. It might be possible to use those to add additional languages to this project.

Option to print alternating tabs in same orientation.

This would require different side-by-side cards to be printed front, back, front, etc., but if the resulting pdf is sent to a printer that will cut the tab notches out, they won't have to flip every other card to line them up properly.

No license specified

There is no open source or creative commons license specified, which technically means that the project, code, and resources fall under default restrictive copyright. I suspect based on your comments on the generator page, that you want it to be able to be used by others, but legally right now that can't be done without permission.

Add optional padding between cards

Request from a BGG user where the print shop request the cards not be touching. I added code for padding, but it is not yet exposed on the site, and it doesn't work with the cropmarks option.

dominion_tabs.py fails: ImportError: No module named yaml

When I try to run

> python dominion_tabs.py -h

I get:

Traceback (most recent call last):
File "dominion_tabs.py", line 15, in
import yaml
ImportError: No module named yaml

I'm running Mac OS X Yosemite. I'm a software developer, but have never used Python before so don't know how to get this module installed. I tried running pip install yaml, pip install python-yaml, but neither worked.

I expected that pythong setup.py install would have installed all needed dependencies. Please update setup.py so it installs the yaml module.

Spelling Errors

Do you want us to create issues when we find spelling errors or put them all in one issue? Either way there is one in the rules text for the Noble Brigand.

However, buying a Noble Brigand is not "playing an Attack card," and so cads like Moat cannot respond to that

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.