superject/cards/deck.rb

70 lines
1.6 KiB
Ruby

require 'squib'
# Squib::Deck.new cards: 3, layout: 'economy.yml' do
# background color: 'white'
# rect layout: 'cut' # cut line as defined by TheGameCrafter
# rect layout: 'safe' # safe zone as defined by TheGameCrafter
# text str: ['Occasion','Qualifier','Virus','Reflection'] , layout: 'title'
# text str: 'S.P.A.C.E.', layout: 'description'
# save format: :png
# end
data = Squib.csv file: 'cards.csv'
layouts = ['economy.yml', 'space-layout-1.yml']
c1 = '#9f68ed'
c2 = '#ed9f68'
c3 = '#b5ed68'
c4 = '#eeeeee'
# conditional coloring
# https://squib.readthedocs.io/en/v0.15.0/colors.html?highlight=color#samples
color = c1
Squib::Deck.new cards: data['name'].size, layout: layouts do
# set background colour per card type
bg = data['type'].map do |t|
if (t.eql? 'O')
c1
elsif (t.eql? 'Q')
c2
elsif (t.eql? 'Q')
c3
else
c4
end
end
# set fill colour per card type
fg = data['type'].map do |t|
if (t.eql? 'O')
c2
elsif (t.eql? 'Q')
c1
elsif (t.eql? 'Q')
c4
else
c4
end
end
background color: bg
rect fill_color: fg , x: 78, y: 78, width: '2.25in', height: '3.25in', radius: 32
rect layout: 'cut' # cut line as defined by TheGameCrafter
rect layout: 'safe' # safe zone as defined by TheGameCrafter
text str: data['name'], layout: 'title'
text str: data['type'], layout: 'type'
text str: data['text'], layout: 'description'
svg file: data['illustration'], layout: 'illustration'
# output a png of each card and pdf of the deck
save_png
save_pdf
end