andymeneely / squib

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

It'd be nice if the built-in layouts were specified a little differently in the code #389

Open joem opened 4 months ago

joem commented 4 months ago

Is your feature request related to a problem? Please describe.

When looking at Squib example code, I'm often confused by what is a built-in layout and what isn't. I know there are only a few built-ins currently, but I'm not too good at remembering things I only use occasionally, so it get's confusing.

Describe the solution you'd like

I think it would be nice if the built-in layouts were specified as symbols instead of file names. Besides lessening confusion, this seems more Ruby-ish to me. So instead of something like Squib::Deck.new cards: 1, layout: 'hand.yml' do you'd have Squib::Deck.new cards: 1, layout: :hand do.

I imagine (but haven't checked yet) that the current code has multiple paths that it looks for specified layout files in (one of which is the /lib/squib/builtin/layouts/ directory of the Squib installation), and that's why you have to specify a full file name for built-ins. I think you could keep that (so you don't break older code) and add an additional check to see if the argument passed is a symbol, and if so, internally convert it to a file name and look for it only in the built-in's directory.

Describe alternatives you've considered

I'm not sure what a good alternative would be.

Not sure I have time right now to try working on this, sorry.