From 1d4de1e2ad929a1cde84827f9f3c2421fdb80944 Mon Sep 17 00:00:00 2001 From: Andy Meneely Date: Mon, 9 Oct 2017 15:16:58 -0400 Subject: [PATCH] cli: create an --advanced layout [skip ci] Needs to be documented (new page?) and needs to be updated for unit tests. --- CHANGELOG.md | 1 + bin/squib | 25 +------- lib/squib.rb | 3 +- .../builtin/projects/advanced/.gitignore | 4 ++ lib/squib/builtin/projects/advanced/ABOUT.md | 19 ++++++ lib/squib/builtin/projects/advanced/Gemfile | 11 ++++ lib/squib/builtin/projects/advanced/Guardfile | 21 ++++++ lib/squib/builtin/projects/advanced/IDEAS.md | 22 +++++++ .../builtin/projects/advanced/PLAYTESTING.md | 26 ++++++++ lib/squib/builtin/projects/advanced/Rakefile | 27 ++++++++ .../projects/advanced/_output/gitkeep.txt | 1 + .../builtin/projects/advanced/config.yml | 49 ++++++++++++++ .../builtin/projects/advanced/data/game.xlsx | Bin 0 -> 8656 bytes .../projects/advanced/docs/PNP NOTES.md | 4 ++ .../builtin/projects/advanced/docs/RULES.md | 21 ++++++ .../builtin/projects/advanced/img/example.svg | 60 ++++++++++++++++++ .../projects/advanced/layouts/deck.yml | 27 ++++++++ .../builtin/projects/advanced/src/deck.rb | 34 ++++++++++ .../builtin/projects/advanced/src/version.rb | 3 + lib/squib/commands/cli.rb | 38 +++++++++++ lib/squib/commands/new.rb | 40 ++++++++++-- 21 files changed, 406 insertions(+), 30 deletions(-) create mode 100644 lib/squib/builtin/projects/advanced/.gitignore create mode 100644 lib/squib/builtin/projects/advanced/ABOUT.md create mode 100644 lib/squib/builtin/projects/advanced/Gemfile create mode 100644 lib/squib/builtin/projects/advanced/Guardfile create mode 100644 lib/squib/builtin/projects/advanced/IDEAS.md create mode 100644 lib/squib/builtin/projects/advanced/PLAYTESTING.md create mode 100644 lib/squib/builtin/projects/advanced/Rakefile create mode 100644 lib/squib/builtin/projects/advanced/_output/gitkeep.txt create mode 100644 lib/squib/builtin/projects/advanced/config.yml create mode 100644 lib/squib/builtin/projects/advanced/data/game.xlsx create mode 100644 lib/squib/builtin/projects/advanced/docs/PNP NOTES.md create mode 100644 lib/squib/builtin/projects/advanced/docs/RULES.md create mode 100644 lib/squib/builtin/projects/advanced/img/example.svg create mode 100644 lib/squib/builtin/projects/advanced/layouts/deck.yml create mode 100644 lib/squib/builtin/projects/advanced/src/deck.rb create mode 100644 lib/squib/builtin/projects/advanced/src/version.rb create mode 100644 lib/squib/commands/cli.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 16a904c..89eb86d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Features: * Layouts now support `*=` and `/=` operators in addition to `+=` and `-=` (#200). * `save_pdf` method also supports `rtl` by @vador * New DSL methods `safe_zone` and `cut_zone` will draw a rectangle inset from the margins for quick proof checking +* New "advanced layout" option if you do `squib new --advanced yourgame` (@andymeneely) Compatibility: * DPI is correctly respected with font sizes now. To convert to Squib v0.14+, divide your old font sizes by 3. By @felixleong diff --git a/bin/squib b/bin/squib index 6995849..fb57465 100755 --- a/bin/squib +++ b/bin/squib @@ -2,27 +2,4 @@ require 'squib' require 'mercenary' -Mercenary.program(:squib) do |p| - p.version Squib::VERSION - p.description 'A Ruby DSL for prototyping card games' - p.syntax 'squib [options]' - - p.command(:new) do |c| - c.syntax 'new PATH' - c.description 'Creates a new Squib project scaffolding in PATH. Must be a new directory or already empty.' - - c.action do |args, options| - Squib::Commands::New.new.process(args) - end - end - - p.command(:make_sprue) do |c| - c.syntax 'make_sprue' - c.description 'Creates a sprue definition file.' - - c.action do |args, options| - Squib::Commands::MakeSprue.new.process(args) - end - end - -end +Squib::CLI.new.run diff --git a/lib/squib.rb b/lib/squib.rb index 53bd644..18062f8 100644 --- a/lib/squib.rb +++ b/lib/squib.rb @@ -3,8 +3,7 @@ require 'cairo' require 'pango' require 'rsvg2' require_relative 'squib/version' -require_relative 'squib/commands/new' -require_relative 'squib/commands/make_sprue' +require_relative 'squib/commands/cli' require_relative 'squib/deck' require_relative 'squib/card' diff --git a/lib/squib/builtin/projects/advanced/.gitignore b/lib/squib/builtin/projects/advanced/.gitignore new file mode 100644 index 0000000..7598f0b --- /dev/null +++ b/lib/squib/builtin/projects/advanced/.gitignore @@ -0,0 +1,4 @@ +_output/*.png +_output/*.pdf +~$* +.DS_Store diff --git a/lib/squib/builtin/projects/advanced/ABOUT.md b/lib/squib/builtin/projects/advanced/ABOUT.md new file mode 100644 index 0000000..3c7b272 --- /dev/null +++ b/lib/squib/builtin/projects/advanced/ABOUT.md @@ -0,0 +1,19 @@ +My Awesome Game +=============== + +Check out my awesome game! + + +Objective +--------- + + + +Gameplay +-------- + + + +Ending the Game +--------------- + diff --git a/lib/squib/builtin/projects/advanced/Gemfile b/lib/squib/builtin/projects/advanced/Gemfile new file mode 100644 index 0000000..2ddf5a5 --- /dev/null +++ b/lib/squib/builtin/projects/advanced/Gemfile @@ -0,0 +1,11 @@ +source 'https://rubygems.org' + +gem 'squib' +gem 'guard' +gem 'guard-rake' + +# If you do any simulation or anything fancy, you might want this +# gem 'rspec' # Unit testing with behavior-driven development + +# If you want to generate PDFs manually (e.g. rules) this is good +# gem 'prawn' diff --git a/lib/squib/builtin/projects/advanced/Guardfile b/lib/squib/builtin/projects/advanced/Guardfile new file mode 100644 index 0000000..91e471b --- /dev/null +++ b/lib/squib/builtin/projects/advanced/Guardfile @@ -0,0 +1,21 @@ +group :default do + guard 'rake', :task => 'default' do + watch %r{data/.*\.xlsx$} + watch %r{data/.*\.csv$} + watch %r{src/.*\.rb$} + watch %r{.*\.yml} + watch %r{img/.*\.svg$} + watch %r{img/.*\.png$} + end +end + +group :deck do + guard 'rake', :task => 'default' do + watch %r{data/.*\.xlsx$} + watch %r{data/.*\.csv$} + watch %r{src/.*\.rb$} + watch %r{.*\.yml} + watch %r{img/.*\.svg$} + watch %r{img/.*\.png$} + end +end diff --git a/lib/squib/builtin/projects/advanced/IDEAS.md b/lib/squib/builtin/projects/advanced/IDEAS.md new file mode 100644 index 0000000..0adc549 --- /dev/null +++ b/lib/squib/builtin/projects/advanced/IDEAS.md @@ -0,0 +1,22 @@ +# Title Ideas + +* First idea +* Second idea + + +# Things to Try + +* Idea +* Idea + +# Feedback Ideas + +* Feedback +* Feedback + +# Problems To Work On + +* Problem +* Problem + + diff --git a/lib/squib/builtin/projects/advanced/PLAYTESTING.md b/lib/squib/builtin/projects/advanced/PLAYTESTING.md new file mode 100644 index 0000000..844ff90 --- /dev/null +++ b/lib/squib/builtin/projects/advanced/PLAYTESTING.md @@ -0,0 +1,26 @@ +# Playtesting Log + +# Playtest Report Survey + +## Basic Info + * Num. Players: + * How many sessions of this game have you played before? + * How long did you play? + * How did you prepare for teaching the rules? Read the sheet with everyone there, or did someone read it ahead of time? + * What types of players played with you? What are their favorite games? + * What version were you testing? + * What date did you play? + +## Did it work? + * Was there a moment that you felt the game was "broken"? Describe what happened. + * How close were the scores? Did everyone feel like they had a fair chance at winning? + * Were there any moments that you had to go back to the rules for clarification? What resulted of that - are you still unclear, or was it just a misunderstanding? + * Any ideas for clearer rules? + * Any ideas for clearer icons, artwork, in-game helps, etc? + +## Was it fun? + * Based on the description, artwork, branding, etc. was this game what you expected? + * Were the theme, artwork, and icons engaging? + * Did this game have the depth of strategy that you were expecting? + * What were the moments that people felt like they were having the most fun? The least fun? + * Assuming trivial issues are fixed, would you recommend this to someone else? diff --git a/lib/squib/builtin/projects/advanced/Rakefile b/lib/squib/builtin/projects/advanced/Rakefile new file mode 100644 index 0000000..7872b00 --- /dev/null +++ b/lib/squib/builtin/projects/advanced/Rakefile @@ -0,0 +1,27 @@ +require 'squib' +require 'irb' +require 'rake/clean' + +# Add Rake's clean & clobber tasks +CLEAN.include('_output/*').exclude('_output/gitkeep.txt') + +desc 'By default, just build the deck without extra options' +task default: [:deck] + +desc 'Build everything, with all the options' +task all: [:with_pnp, :with_proofs, :deck] + +desc 'Build the deck' +task(:deck) { load 'src/deck.rb' } + +desc 'Enable proof lines' +task(:with_proofs) do + puts "Enabling proofing lines." + Squib.enable_build_globally :proofs +end + +desc 'Enable print-and-play builds' +task(:with_pnp) do + puts "Enabling print-and-play builds." + Squib.enable_build_globally :pnp +end diff --git a/lib/squib/builtin/projects/advanced/_output/gitkeep.txt b/lib/squib/builtin/projects/advanced/_output/gitkeep.txt new file mode 100644 index 0000000..044bca6 --- /dev/null +++ b/lib/squib/builtin/projects/advanced/_output/gitkeep.txt @@ -0,0 +1 @@ +Keep this here so that Git knows to keep the _output directory on a fresh clone \ No newline at end of file diff --git a/lib/squib/builtin/projects/advanced/config.yml b/lib/squib/builtin/projects/advanced/config.yml new file mode 100644 index 0000000..85dc231 --- /dev/null +++ b/lib/squib/builtin/projects/advanced/config.yml @@ -0,0 +1,49 @@ +# Settings in the config.yml are overriding Squib's defaults. Anything in the main script will override this. + +# DPI is used in making PDFs and in unit conversions +# Default: 300 +#dpi: 72 + +#antialias: best #recommended. Only about 10% slower than fast +#antialias: default # set the anti-aliasing algorithm. default defers to the underlying graphics device. See http://www.cairographics.org/manual/cairo-cairo-t.html#cairo-antialias-t + +# Text hints are used to show the boundaries of text boxes. +# Can be enabled/disabled at the command-level, or set globally with `set` +#text_hint: '#F00' + +# Show progress bars on the command line for potentially long-running operations +progress_bars: true + +#Enable some custom colors that can be used in any color +#custom_colors: +# foo: '#abc' + +#For reading image file command (e.g. png and svg), read from this directory instead +img_dir: img +#img_dir: img-bw + +# Use a SVG cairo back end, instead of an in-memory buffer +# backend: :memory # default +# backend: :svg # can create scalable pdfs, but rendering done at the printer level is not as good as Cairo. + +# Configure what text markup uses replace characters +# Below are the defaults +# lsquote: "\u2018" #note that Yaml wants double quotes here to use escape chars +# rsquote: "\u2019" +# ldquote: "\u201C" +# rdquote: "\u201D" +# em_dash: "\u2014" +# en_dash: "\u2013" +# ellipsis: "\u2026" + +# We can also disallow smart quotes and only allow explicit replacements with ``LaTeX-style'' quotes. +# smart_quotes: false + +# By default, Squib warns when a text box is ellipsized. This can get verbose +# and can be turned off here +warn_ellipsize: true # default +# warn_ellipsize: false # turn off entirely + +# By default, Squib will warn if a PNG is being up-scaled. +warn_png_scale: true # default +# warn_png_scale: false # turn off entirely diff --git a/lib/squib/builtin/projects/advanced/data/game.xlsx b/lib/squib/builtin/projects/advanced/data/game.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..fadeff5b67c75ab1ad326bf6219d9946c1933488 GIT binary patch literal 8656 zcmeHMby!sEw;s9%7`g`$DM<-IxWpZovs?0NRy&wln^?|kvD^{ww+nyMI>v0>}sl4m+X&0GL<+ z02u%m{ehg5qZ`!G%~Tie40V0Tnb^9GV_&~4qH>BiS z?}ulH78m2vH_<=1v5u4M6>o5(Zk2}p+?UN#ORoyIokh!j_yOyIICa@HtD&s)vOUkK zp~ej}f`aHW*q+3Na;8FHZt4B#>exu3ENa4?9qjR1oO=z^5FXp>m)BV+g=+8xKDY0y ze~~Q-lagb3eRHiC{p91OM1O}Nx+;e|HAKYgi8eQ_$|wDn7A<~(`!_1mTp9Fu5|Ggx z z@-f>~qHcPzTwdpHdM*|?8XKjTrSbliXQS;(48cK)>%o>_UtU=__gf?AmO2veyB9Uo z=bIB(?g3T6@cOlkTd{la*Fm_hAt0MMz^A5dl0$meGW2!4y~F#$RJ&AX2}DmPL_}iJ zrvXWxkEr6xMZWJzGemPQa%31668DJczN7r?@)84}`8PMM)#GD6 zL~-vP>Ma4vO-*4?dskkbAJ>1~^S{_9|I+o+cr}eqK48d>@_A?<^8H*aNLJNTM!A_u z*AH=bmbfGl)KF>4{3X&-|-s@X>o5Z;NH5@anOagv~^K>_x9vV!l@?toJz;_0F zJ&-~~OBiI|+Bpj&NHHIi+3$#9ISn2RV&Foy%fNw3SY)JI8=EED1VpK>WQ~&XeOwvj zB5TL&EHt4n^RLSvHjae|+79u#^V_M!T)caTz4F*t@Ax3?HqRd~( z5*4rNw0sTJyTiHdDLqRE+*i~hFBmIso;EH9pNf!C_p-NOHmJAy_SVgoPN-_|5&H@F zTY4a=top@r?E{_IP4yBG`Z9F>w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U7nm5`33qG#@Q<{Z8Cc2TAz=W;a8wG8bxMqhBw?9S zr*DVFcHwR)1mt`%SJPpR3}Y|8anU#LsXQG)ha=N;i;*_7u|;5I%d*1g6_$D4SCv#2 z4wezThy9KZ$1?pw;lub-IQ2(MppsqVLOs;DV-nBj-c6Jc92Wr>cyhhC}PI2DK z4+INBD+E_%zSuFi2>XlG3$J&TB3;dQW6y%A=$q++XDdARCcSn{$h%#8d14ecPiR|V z)rl`yxF@phD%fvTm5pP5R!6obRrt8th7!V!g^n%I5;@g04a;i9cq%_jAW3HP*`}3S z2p1`C+Ehdf7>mBsRBlPLH0+KPZb>Rd}DNkEW9>smg@s<(aqDZ2~D@kRw529_v7X<+~K zCRJj1PkW>tS3_1CTbzYBS)FtUBP?SwZy!P=#Y8Hu` zO29Hv@^oC-Q)Ldt+zStP;#hP!LfU(~$(H1oa14=c-rI+7yNdKgJ|5?r&vHD7kfERR zu23|esWTMYH19em_b<&fJuAq6>()$)cx#N$O20eOz~4KrYHU2{YtYN!MBW!FH^DoR zyS_{WioFYL3u$0m^*uV)Ez_LZ=3_x}ywDG-{O;qyJbcbE%penGla#ww^vn zxs|9M#?}^lc21V?Yu4$yzdDpg4eBiFWJ8@OMadbZMz}#?I#4&aAF{;N=UY4w8%Ky) z7Le~1U-cXsEy?AZfVjATxJ3$mNhSPPORF$52*eCM{++a;5;htBw#?)Z?kd8X6-391 zu>7?$V&zS26^5cdF$Mqt`YZJxIXnN$eAKM`aiqupT$<34w^k1WIuWnO+aY?OP*0--%++n2bv9Tv7qOHi zL+yNXG;QnNwH{gv9f3(nCg_F08gm^WNad9o?bB6bv5GnG*YsG%#soM|@Pep5gn280 zca^GzQohTyq?5$}$##OO(Y$>WgiVr%PX^!&%@!RgR7o3Y1WG>2XAQS7haZ^`zb_Y} zu^qZ3JwmnOPVW}ZGk3cVv<<7l&F + + + + + + + image/svg+xml + + + + + + + + + diff --git a/lib/squib/builtin/projects/advanced/layouts/deck.yml b/lib/squib/builtin/projects/advanced/layouts/deck.yml new file mode 100644 index 0000000..e50d9e1 --- /dev/null +++ b/lib/squib/builtin/projects/advanced/layouts/deck.yml @@ -0,0 +1,27 @@ +name: + x: 90 + y: 90 + width: 500 + height: 50 + font: Arial 18 + valign: middle + align: left + ellipsize: false + +ATK: + x: 90 + y: 190 + width: 200 + height: 50 + font: Arial 12 + valign: middle + align: left + ellipsize: false +DEF: + extends: ATK + y: += 75 + +version: + font: Arial 6 + x: 725 + y: 45 diff --git a/lib/squib/builtin/projects/advanced/src/deck.rb b/lib/squib/builtin/projects/advanced/src/deck.rb new file mode 100644 index 0000000..044fd02 --- /dev/null +++ b/lib/squib/builtin/projects/advanced/src/deck.rb @@ -0,0 +1,34 @@ +require 'squib' +require_relative 'version' + +# Note: run this code by running "rake" at the command line +# To see full list of options, run "rake -T" + +data = Squib.xlsx file: 'data/game.xlsx', sheet: 0 + +Squib::Deck.new(cards: data.nrows) do + background color: :white + use_layout file: 'layouts/deck.yml' + + text str: data.name, layout: :name + + text str: data.atk.map { |s| "#{s} ATK" }, layout: :ATK + text str: data.def.map { |s| "#{s} DEF" }, layout: :DEF + + svg file: 'example.svg' + + text str: MySquibGame::VERSION, layout: :version + + build(:proofs) do + safe_zone + cut_zone + end + + save format: :png + + build(:pnp) do + save_sheet prefix: 'pnp_sheet_', + trim: '0.125in', + rows: 3, columns: 3 + end +end diff --git a/lib/squib/builtin/projects/advanced/src/version.rb b/lib/squib/builtin/projects/advanced/src/version.rb new file mode 100644 index 0000000..d017193 --- /dev/null +++ b/lib/squib/builtin/projects/advanced/src/version.rb @@ -0,0 +1,3 @@ +module MySquibGame + VERSION = '1.0' +end diff --git a/lib/squib/commands/cli.rb b/lib/squib/commands/cli.rb new file mode 100644 index 0000000..d7687ee --- /dev/null +++ b/lib/squib/commands/cli.rb @@ -0,0 +1,38 @@ +require_relative 'new' +require_relative 'make_sprue' + +module Squib + class CLI + + def run + Mercenary.program(:squib) do |p| + p.version Squib::VERSION + p.description 'A Ruby DSL for prototyping card games' + p.syntax 'squib [options]' + + p.command(:new) do |c| + c.syntax 'new PATH' + c.description 'Creates a new basic Squib project scaffolding in PATH. Must be a new directory or already empty.' + + c.option 'advanced', '--advanced', 'Create the advanced layout' + + c.action do |args, options| + advanced = options.key? 'advanced' + Squib::Commands::New.new.process(args, advanced) + end + end + + p.command(:make_sprue) do |c| + c.syntax 'make_sprue' + c.description 'Creates a sprue definition file.' + + c.action do |args, options| + Squib::Commands::MakeSprue.new.process(args) + end + end + + end + end + + end +end diff --git a/lib/squib/commands/new.rb b/lib/squib/commands/new.rb index d2cd3ab..d98e3c4 100644 --- a/lib/squib/commands/new.rb +++ b/lib/squib/commands/new.rb @@ -23,21 +23,53 @@ module Squib # :nodoc: # @api private - def process(args) - raise ArgumentError.new('Please specify a path.') if args.empty? + def process(args, advanced) + raise empty_path_error if args.empty? new_project_path = File.expand_path(args.join(' '), Dir.pwd) - template_path = File.expand_path('../builtin/projects/basic', File.dirname(__FILE__)) FileUtils.mkdir_p new_project_path if !Dir["#{new_project_path}/**/*"].empty? $stderr.puts "#{new_project_path} exists and is not empty. Doing nothing and quitting." else Dir.chdir(new_project_path) do - FileUtils.cp_r template_path + '/.', new_project_path + FileUtils.cp_r template_path(advanced) + '/.', new_project_path end end puts "Created basic Squib project in #{new_project_path}." + puts advanced_message if advanced + end + + def empty_path_error + ArgumentError.new('Please specify a path.') + end + + def template_path(advanced) + path = case advanced + when true + '../builtin/projects/advanced' + else + '../builtin/projects/basic' + end + File.expand_path(path, File.dirname(__FILE__)) + end + + def advanced_message + <<~EOS + +This is the advanced layout designed for larger games. Everything is +organized into separate directories and the workflow is all based on +the Rakefile. + +From within this directory, run `bundle install` to install extra +gems. + +After that, run `rake` to build. Check out the Rakefile for more. + +Happy Squibbing! And best of luck with your game. + -Andy (@andymeneely) + + EOS end end