squib
A Ruby DSL for prototyping card games.
Squib | A Ruby DSL for prototyping card games
I want to change the font in Squib.
How do I do this.
There is a font folder and also I can see where I set the font in the layout, do I need to set it anywhere else.
I'm wanting to use FiraSans-Regular.otf and FiraSans-Heavy.otf
Source: (StackOverflow)
I added this block to my deck.rb:
text(str: 'Gain 1 :tribute:') do |embed|
embed.svg key: ':tribute:', file: 'tribute.svg'
end
However, this puts "Gain 1 [my icon here]" into the top left of every card, but not where the card text says "Gain 1 tribute."
If I add this line, in an attempt to make it specify the "Ability" column in my .csv file:
%w(Ability).each do |key|
Then I get an error message:
"Syntax error, unexpected end-of-input, expecting keyword_end."
What do I need to add to my deck.rb, exactly, in order to make it use the tribute.svg
icon wherever cards within the Ability column have the text, "Gain 1 tribute"?
Here's my current deck.rb:
require 'squib'
require 'game_icons'
Squib::Deck.new(cards: 4, layout: %w(hand.yml layout.yml)) do
background color: '#FFFFFF'
data = csv file: 'country.csv'
png file: data['Art'], layout: 'Art'
%w(Title Ability Quote Type Subtype).each do |key|
text str: data[key], layout: key, markup: true
end
%w(Tribute Power Dominion).each do |key|
svg file: "#{key.downcase}.svg", layout: "#{key}Icon"
text str: data[key], layout: key
end
text(str: 'Gain 1 :tribute:', x: 275, y: 745) do |embed|
embed.svg key: ':tribute:', file: 'tribute.svg'
end
save_png prefix: 'country_'
end
Source: (StackOverflow)
Here's exactly what I want to do: Whenever one of my cards has within the Ability column of my .csv the text "Gains 1 tribute", the output is "Gains 1 [my tribute icon]" within the text box of the card, formatted so that it's part of the regular Ability text. Is this possible?
P.S. Also, how do I make icons have transparent backgrounds? I've saved them from game-icons.net as such, but they always display with a white background. Here's what I've tried:
require 'squib'
require 'game_icons'
Squib::Deck.new(cards: 4, layout: %w(hand.yml layout.yml), width: 825, height: 1425) do
background color: '#FFFFFF'
rect x: 0, y: 0, width: 825, height: 1425, x_radius: 38, y_radius: 38
data = csv file: 'country.csv'
png file: data['Art'], layout: 'Art'
png file: 'textbox.png', x: 50, y: 890
png file: 'titlebox.png', x: 65, y: 30
tribute = data['Tribute']
colorl = tribute.collect { |x| fg(x) }
background color: tribute.map.with_index { |x,i| bg_grad(x, attrr[i]) }
text str: data['Tribute'], layout: :Tribute, color: colorl
svg file: tribute.collect {|x| icon(x)}, layout: :TributeIcon
end
%w(Title Ability Quote Type Subtype).each do |key|
text str: data[key], layout: key, markup: true
end
%w(Tribute Power Dominion).each do |key|
svg file: "#{key.downcase}.svg", layout: "#{key}Icon"
text str: data[key], layout: key
end
save_png prefix: 'country_'
end
However, I'm now getting an expected-end-of-input error!
Source: (StackOverflow)
I am trying to get Squib to embed images. I have an excel doc (totm.xlsx) that has fields for Title, Gold, Description, etc. In the Excel doc, most of the cards have :A: or :M: in the description and I would like to replace those with a small SVG icon.
The following code coughs up 'unidentified local method [embed]' and a litany of other errors:
require 'squib'
Squib::Deck.new(cards: 54) do
background color: :white
data = xlsx file: 'totm.xlsx'
text str: data['Title'], x: 250, y: 55, font: 'Arial 12'
text str: data['Gold'], x: 65, y: 65, font: 'Arial 12'
text(str: data['Description'], x: 65, y: 600, font: 'Arial 12') do [embed]
embed.svg key: ':A:', width: 28, height: 28, file: 'battle-axe.svg'
embed.svg key: ':M:', width: 28, height: 28, file: 'burning-meteor.svg'
end
text str: data['Flavortext'], x: 65, y: 100, font: 'Arial 12'
text str: data['Type'], x: 65, y: 400, font: 'Arial 12'
save_sheet prefix: 'totm_sheet_', margin: 75, gap: 5, trim: 37
end
In the examples with embedding text, the code always uses a single named string, embed_text, but I would like to call an array of strings.
embed_text = 'Take 1 :tool: and gain 2 :health:.'
text(str: embed_text, font: 'Sans', font_size: [18, 32, 45],
x: 0, y: 0, width: 180, height: 300, valign: :bottom,
align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
end
Source: (StackOverflow)