Created
August 31, 2017 12:51
-
-
Save finnbar/e47001e469f95e56d2b9bcf3ebb0f327 to your computer and use it in GitHub Desktop.
Mega Space Cards
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'squib' | |
#Squib::logger.level = Logger::DEBUG | |
# Need to modify Merge Module to be a sensible length, or shrink font. | |
keywords = ["Standard Part", "tech strength range", "send", "merged", "merge", "docked", "destroyed", "destroys", "destroy", "trashing", "trashed", "trashes", "trash", "carry", "carried", "Malicious AI (1)", "Malicious AI (2)", "Malicious AI (3)", "Sticky (2)", "Sticky (4)", "scatters", "scattered", "scatter", "focused", "strength"] | |
htmlescape = [["&", "&"], ["'", "'"], ["\"", """], ["<", "<"], [">", ">"]] | |
data = Squib.csv(file: 'Mega Space Cards - Parts Cards.csv', explode: 'Quantity') do |header, value| | |
case header | |
when 'Effect' | |
if value.nil? | |
value | |
else | |
htmlescape.each {|unescaped, escaped| value.gsub! unescaped, escaped} | |
keywords.each {|keyword| value.gsub! keyword, "<b>#{keyword}</b>"} | |
keywords.each {|keyword| value.gsub! keyword.capitalize, "<b>#{keyword.capitalize}</b>"} | |
value | |
end | |
when 'Flavour Text' | |
if value.nil? | |
value | |
else | |
htmlescape.each {|unescaped, escaped| value.gsub! unescaped, escaped} | |
value | |
end | |
else | |
value | |
end | |
end | |
Squib::Deck.new(cards: data['Name'].size, layout: 'layout.yml', width: '63mm', height: '88mm') do | |
# 744 x 1040 | |
background color: :white | |
rect layout: 'AllText' | |
text str: data['Name'], layout: :Title | |
rect layout: 'TitleBox' | |
text str: data['Strength'], layout: :Power | |
rect layout: 'PowerBox' | |
text str: data['Energy'], layout: :Energy | |
rect layout: 'EnergyBox' | |
text str: data['Type'], layout: :Type | |
rect layout: 'TypeBox' | |
text str: data['Effect'], layout: :Effect, markup: true, valign: :top | |
text str: data['Flavour Text'], layout: :Flavour, markup: true, valign: :bottom | |
text str: data['Faction'].zip(data['Number']).map {|f,n| f + n.to_s}, layout: :Identifier | |
text str: data['Quantity'], layout: :Count, align: :right | |
save_pdf(width: '210mm', height: '297mm') | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AllText: | |
font: Nasalization Regular 40 | |
align: center | |
Title: | |
extends: AllText | |
font: Nasalization Regular 35 | |
width: 744 | |
y: 450 | |
TitleBox: | |
extends: Title | |
y: 430 | |
height: 100 | |
Stat: | |
extends: AllText | |
y: 20 | |
width: 194 | |
StatBox: | |
extends: Stat | |
y: 0 | |
height: 100 | |
Power: | |
extends: Stat | |
x: 0 | |
PowerBox: | |
extends: StatBox | |
x: 0 | |
Energy: | |
extends: Stat | |
x: 550 | |
EnergyBox: | |
extends: StatBox | |
x: 550 | |
Effect: | |
extends: AllText | |
font: Nasalization Regular 28 | |
height: 470 | |
x: 20 | |
width: 704 | |
y: 550 | |
Flavour: | |
extends: AllText | |
font: Nasalization Italic 22 | |
height: 470 | |
x: 60 | |
width: 624 | |
y: 550 | |
Identifier: | |
extends: AllText | |
font: Nasalization Regular 18 | |
height: 20 | |
x: 5 | |
y: 1010 | |
Count: | |
extends: Identifier | |
x: 710 | |
width: 29 | |
Type: | |
extends: Stat | |
width: 744 | |
TypeBox: | |
extends: StatBox | |
width: 744 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment