Browse Source

cli: create an --advanced layout

[skip ci]

Needs to be documented (new page?) and needs to be updated for unit tests.
dev
Andy Meneely 8 years ago
parent
commit
1d4de1e2ad
  1. 1
      CHANGELOG.md
  2. 25
      bin/squib
  3. 3
      lib/squib.rb
  4. 4
      lib/squib/builtin/projects/advanced/.gitignore
  5. 19
      lib/squib/builtin/projects/advanced/ABOUT.md
  6. 11
      lib/squib/builtin/projects/advanced/Gemfile
  7. 21
      lib/squib/builtin/projects/advanced/Guardfile
  8. 22
      lib/squib/builtin/projects/advanced/IDEAS.md
  9. 26
      lib/squib/builtin/projects/advanced/PLAYTESTING.md
  10. 27
      lib/squib/builtin/projects/advanced/Rakefile
  11. 1
      lib/squib/builtin/projects/advanced/_output/gitkeep.txt
  12. 49
      lib/squib/builtin/projects/advanced/config.yml
  13. BIN
      lib/squib/builtin/projects/advanced/data/game.xlsx
  14. 4
      lib/squib/builtin/projects/advanced/docs/PNP NOTES.md
  15. 21
      lib/squib/builtin/projects/advanced/docs/RULES.md
  16. 60
      lib/squib/builtin/projects/advanced/img/example.svg
  17. 27
      lib/squib/builtin/projects/advanced/layouts/deck.yml
  18. 34
      lib/squib/builtin/projects/advanced/src/deck.rb
  19. 3
      lib/squib/builtin/projects/advanced/src/version.rb
  20. 38
      lib/squib/commands/cli.rb
  21. 40
      lib/squib/commands/new.rb

1
CHANGELOG.md

@ -11,6 +11,7 @@ Features:
* Layouts now support `*=` and `/=` operators in addition to `+=` and `-=` (#200). * Layouts now support `*=` and `/=` operators in addition to `+=` and `-=` (#200).
* `save_pdf` method also supports `rtl` by @vador * `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 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: Compatibility:
* DPI is correctly respected with font sizes now. To convert to Squib v0.14+, divide your old font sizes by 3. By @felixleong * DPI is correctly respected with font sizes now. To convert to Squib v0.14+, divide your old font sizes by 3. By @felixleong

25
bin/squib

@ -2,27 +2,4 @@
require 'squib' require 'squib'
require 'mercenary' require 'mercenary'
Mercenary.program(:squib) do |p| Squib::CLI.new.run
p.version Squib::VERSION
p.description 'A Ruby DSL for prototyping card games'
p.syntax 'squib <subcommand> [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

3
lib/squib.rb

@ -3,8 +3,7 @@ require 'cairo'
require 'pango' require 'pango'
require 'rsvg2' require 'rsvg2'
require_relative 'squib/version' require_relative 'squib/version'
require_relative 'squib/commands/new' require_relative 'squib/commands/cli'
require_relative 'squib/commands/make_sprue'
require_relative 'squib/deck' require_relative 'squib/deck'
require_relative 'squib/card' require_relative 'squib/card'

4
lib/squib/builtin/projects/advanced/.gitignore vendored

@ -0,0 +1,4 @@
_output/*.png
_output/*.pdf
~$*
.DS_Store

19
lib/squib/builtin/projects/advanced/ABOUT.md

@ -0,0 +1,19 @@
My Awesome Game
===============
Check out my awesome game!
Objective
---------
Gameplay
--------
Ending the Game
---------------

11
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'

21
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

22
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

26
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?

27
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

1
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

49
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

BIN
lib/squib/builtin/projects/advanced/data/game.xlsx

Binary file not shown.

4
lib/squib/builtin/projects/advanced/docs/PNP NOTES.md

@ -0,0 +1,4 @@
Print and Play Notes
====================
Fill this out to give tips on how to play this with print and play.

21
lib/squib/builtin/projects/advanced/docs/RULES.md

@ -0,0 +1,21 @@
# Intro
What is this game about? How many players?
# Objective
What is the object of the game?
# Components
What are the components? List them out.
# Gameplay
What does each turn look like? Describe a turn.
# Scoring
How is victory assigned?

60
lib/squib/builtin/projects/advanced/img/example.svg

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg8"
version="1.1"
viewBox="0 0 210 297"
height="297mm"
width="210mm"
sodipodi:docname="example.svg"
inkscape:version="0.92.0 r15299">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1680"
inkscape:window-height="987"
id="namedview7"
showgrid="false"
inkscape:zoom="0.5946522"
inkscape:cx="407.78854"
inkscape:cy="201.53619"
inkscape:window-x="-8"
inkscape:window-y="162"
inkscape:window-maximized="1"
inkscape:current-layer="svg8" />
<defs
id="defs2" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
transform="translate(3.5595036,70.300197)">
<path
id="path4485"
d="m 176.52631,170.79195 -68.8031,39.72348 -68.80309,-39.72348 1e-6,-79.446968 68.803089,-39.723484 68.8031,39.723484 z"
style="opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;stroke:#ed00ff;stroke-width:0.70555556;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99954044"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

27
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

34
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

3
lib/squib/builtin/projects/advanced/src/version.rb

@ -0,0 +1,3 @@
module MySquibGame
VERSION = '1.0'
end

38
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 <subcommand> [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

40
lib/squib/commands/new.rb

@ -23,21 +23,53 @@ module Squib
# :nodoc: # :nodoc:
# @api private # @api private
def process(args) def process(args, advanced)
raise ArgumentError.new('Please specify a path.') if args.empty? raise empty_path_error if args.empty?
new_project_path = File.expand_path(args.join(' '), Dir.pwd) 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 FileUtils.mkdir_p new_project_path
if !Dir["#{new_project_path}/**/*"].empty? if !Dir["#{new_project_path}/**/*"].empty?
$stderr.puts "#{new_project_path} exists and is not empty. Doing nothing and quitting." $stderr.puts "#{new_project_path} exists and is not empty. Doing nothing and quitting."
else else
Dir.chdir(new_project_path) do 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
end end
puts "Created basic Squib project in #{new_project_path}." 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
end end

Loading…
Cancel
Save