andymeneely / squib

A Ruby DSL for prototyping card games.
http://squib.rocks
MIT License
918 stars 67 forks source link

draw_layouts method to draw multiple layouts at once with their type specified in layout instead of script #213

Closed sparr closed 7 years ago

sparr commented 7 years ago

This patch provides a new DSL method for drawing one or more layouts at once. draw_layouts takes a param named "pattern" which is a regex to choose which layouts to draw. Also any layouts to be drawn this way need a new "type" field in the yaml to indicate which method should be used to draw them.

This will allow a single generic call to draw cutlines whether they are a rectangle or a circle or made of multiple primitives.

example test script and layout file in this gist: https://gist.github.com/sparr/650cdcb20d71a443ecc4604dbf467bb9

the layout file duplicates the existing shapes sample script

the script puts all shapes on one card, just layouts with names ending in "-1" and "-2" on the other two cards, with the -2 layouts having their colors overridden.

seeking feedback on this feature in general, this implementation, the naming of the new method and options, necessary tests, etc.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.2%) to 99.432% when pulling 7d39ea6259f6a22b5dc3e52d3ac19cdb8cf59ca6 on sparr:FEATURE-draw_layouts into 566d0dfaca48eb1bde88ad4b474973153ac7ef08 on andymeneely:master.

andymeneely commented 7 years ago

Yes, it would be Ruby code. That way you could draw/do complex things before and after the main loop.