require 'squib' require 'game_icons' module Icons def self.getIcon(name, color = 'black') return GameIcons.get(name). recolor(fg: color, bg: 'white', fg_opacity: 1.0, bg_opacity: 0.0). string end AUDIENCE = getIcon 'delapouite/person' MUSIC = getIcon 'delapouite/musical-score' LOVE = getIcon 'skoll/hearts' ANGER = getIcon 'skoll/fist' JOY = getIcon 'lorc/delighted' SAD = getIcon 'lorc/tear-tracks' end VOLUMES = { "ppp" => 1, "pp" => 2, "p" => 3, "mp" => 4, "mf" => 5, "f" => 6, "ff" => 7, "fff" => 8, } data = Squib.csv file: 'data.csv' Squib::Deck.new(cards: data.nrows) do use_layout file: 'economy.yml' use_layout file: 'layout.yml' background color: 'white' cut_zone safe_zone text layout: :title, str: data.name, ellipsize: :autoscale # svg layout: :art, data: Icons::MUSIC text layout: :art, align: :center, valign: :middle, str: data.traits do |embed| embed.svg key: 'l', width: 128, height: 128, data: Icons::LOVE embed.svg key: 'a', width: 128, height: 128, data: Icons::ANGER embed.svg key: 'j', width: 128, height: 128, data: Icons::JOY embed.svg key: 's', width: 128, height: 128, data: Icons::SAD end rect layout: :description text layout: :description, str: data.effect.zip(data.blurb).map { |e, b| "#{e}#{if b then "\n#{b}" end}" } do |embed| embed.svg key: '{A}', width: 32, height: 32, data: Icons::AUDIENCE embed.svg key: '{l}', width: 32, height: 32, data: Icons::LOVE embed.svg key: '{a}', width: 32, height: 32, data: Icons::ANGER embed.svg key: '{j}', width: 32, height: 32, data: Icons::JOY embed.svg key: '{s}', width: 32, height: 32, data: Icons::SAD end text layout: :volume, markup: true, str: data.volume.map { |v| "#{v} (#{VOLUMES[v]})" } text layout: :audience, ellipsize: :autoscale, str: data.audience.map { |au| "{A}#{au}"} do |embed| embed.svg key: '{A}', width: 48, height: 48, data: Icons::AUDIENCE end save format: :png save_sheet prefix: "sheet", columns: 5, rows: 4, trim: '0.125in', count_format: '' end