diff --git a/Gemfile b/Gemfile index 244904c..d9b7cdc 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,3 @@ source 'https://rubygems.org' -gem 'squib' +gem "squib", path: "../squib/pkg" diff --git a/data/cards.xlsx b/data/cards.xlsx index 752fae8..260f729 100644 Binary files a/data/cards.xlsx and b/data/cards.xlsx differ diff --git a/graphics/bundled/icones_bannieres.svg b/graphics/bundled/icones_bannieres.svg index 9db23b7..182395c 100644 --- a/graphics/bundled/icones_bannieres.svg +++ b/graphics/bundled/icones_bannieres.svg @@ -7,7 +7,7 @@ viewBox="0 0 297 210" version="1.1" id="svg8" - inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)" + inkscape:version="1.4 (e7c3feb100, 2024-10-09)" sodipodi:docname="icones_bannieres.svg" xml:space="preserve" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" @@ -45,7 +45,7 @@ inverse="true" flatten="false" hide_clip="false" - message="Utilise la règle de remplissage « fill-rule: evenodd » de la boîte de dialogue <b>Fond et contour</b> en l'absence de résultat de mise à plat après une conversion en chemin." /> None: OUTPUT_DIR + "/" + obj[4:], svg_file, ] - print(f"exporting {obj[4:]}...", end="") + print(f"exporting {obj[4:]}...", end="", flush=True) res = subprocess.check_output(command) if res: print(f" An error might have occurred:\n{res}") diff --git a/scripts/generate_layouts.py b/scripts/generate_layouts.py index 8fba07f..a5d90ed 100644 --- a/scripts/generate_layouts.py +++ b/scripts/generate_layouts.py @@ -63,17 +63,50 @@ ALT_BANNER_TEXT_X, ALT_BANNER_TEXT_Y = central_sym(BANNER_TEXT_X, BANNER_TEXT_Y) # Effects EFFECT_FRAME_WIDTH = SAFE_WIDTH - 2 -EFFECT_FRAME_HEIGHT = 6 +EFFECT_FRAME_HEIGHT = 7 EFFECT_FRAME_RADIUS = 0.2 EFFECT_FRAME_MARGIN_BOTTOM = 4.1 EFFECT_FRAME_X = (TOTAL_WIDTH - EFFECT_FRAME_WIDTH) / 2. EFFECT_FRAME_Y = MAX_SAFE_Y - EFFECT_FRAME_MARGIN_BOTTOM - EFFECT_FRAME_HEIGHT -EFFECT_TEXT_MARGIN = 1 -EFFECT_TEXT_X = EFFECT_FRAME_X + EFFECT_TEXT_MARGIN -EFFECT_TEXT_Y = EFFECT_FRAME_Y + EFFECT_TEXT_MARGIN -EFFECT_TEXT_WIDTH = EFFECT_FRAME_WIDTH - 2 * EFFECT_TEXT_MARGIN -EFFECT_TEXT_HEIGHT = EFFECT_FRAME_HEIGHT - 2 * EFFECT_TEXT_MARGIN +EFFECT_ICON_MARGIN = .5 +EFFECT_ICON_SIZE = 1.5 +EFFECT_ICON_X = EFFECT_FRAME_X + EFFECT_ICON_MARGIN + (EFFECT_ICON_SIZE / 2.) + +EFFECT_TEXT_MARGIN = .2 + +EFFECT_SEPARATOR_HEIGHT = 1. +EFFECT_SEPARATOR_MARGIN = .05 +TOTAL_SEPARATOR_HEIGHT = EFFECT_SEPARATOR_HEIGHT + (2 * EFFECT_SEPARATOR_MARGIN) + +EFFECT_SEPARATOR_X = EFFECT_FRAME_X + (EFFECT_FRAME_WIDTH / 2.) +EFFECT_SEPARATOR_Y_2 = EFFECT_FRAME_Y + (EFFECT_FRAME_HEIGHT / 2.) +EFFECT_SEPARATOR_Y_3_0 = EFFECT_FRAME_Y + EFFECT_TEXT_MARGIN + (EFFECT_FRAME_HEIGHT - (2 * EFFECT_TEXT_MARGIN)) / 3. +EFFECT_SEPARATOR_Y_3_1 = EFFECT_FRAME_Y + EFFECT_TEXT_MARGIN + 2 * (EFFECT_FRAME_HEIGHT - (2 * EFFECT_TEXT_MARGIN)) / 3. + +EFFECT_TEXT_X = EFFECT_FRAME_X + EFFECT_ICON_MARGIN + EFFECT_ICON_SIZE + EFFECT_TEXT_MARGIN + +EFFECT_TEXT_HEIGHT_1 = EFFECT_FRAME_HEIGHT - 2 * EFFECT_TEXT_MARGIN +EFFECT_TEXT_Y_1 = EFFECT_FRAME_Y + EFFECT_TEXT_MARGIN + +EFFECT_TEXT_HEIGHT_2 = (EFFECT_FRAME_HEIGHT - (2 * EFFECT_TEXT_MARGIN) - TOTAL_SEPARATOR_HEIGHT) / 2. +EFFECT_TEXT_Y_2_0 = EFFECT_TEXT_Y_1 +EFFECT_TEXT_Y_2_1 = EFFECT_TEXT_Y_2_0 + EFFECT_TEXT_HEIGHT_2 + TOTAL_SEPARATOR_HEIGHT + +EFFECT_TEXT_HEIGHT_3 = (EFFECT_FRAME_HEIGHT - (2 * EFFECT_TEXT_MARGIN) - (2 * TOTAL_SEPARATOR_HEIGHT)) / 2. +EFFECT_TEXT_Y_3_0 = EFFECT_TEXT_Y_1 +EFFECT_TEXT_Y_3_1 = EFFECT_TEXT_Y_3_0 + EFFECT_TEXT_HEIGHT_3 + TOTAL_SEPARATOR_HEIGHT +EFFECT_TEXT_Y_3_2 = EFFECT_TEXT_Y_3_1 + EFFECT_TEXT_HEIGHT_3 + TOTAL_SEPARATOR_HEIGHT + +EFFECT_TEXT_WIDTH = EFFECT_FRAME_X + EFFECT_FRAME_WIDTH - EFFECT_TEXT_X - EFFECT_TEXT_MARGIN + +EFFECT_ICON_Y_1 = EFFECT_FRAME_Y + (EFFECT_FRAME_HEIGHT / 2.) +EFFECT_ICON_Y_2_0 = EFFECT_TEXT_Y_2_0 + (EFFECT_TEXT_HEIGHT_2 / 2.) +EFFECT_ICON_Y_2_1 = EFFECT_TEXT_Y_2_1 + (EFFECT_TEXT_HEIGHT_2 / 2.) +EFFECT_ICON_Y_3_0 = EFFECT_TEXT_Y_3_0 + (EFFECT_TEXT_HEIGHT_2 / 2.) +EFFECT_ICON_Y_3_1 = EFFECT_TEXT_Y_3_1 + (EFFECT_TEXT_HEIGHT_2 / 2.) +EFFECT_ICON_Y_3_2 = EFFECT_TEXT_Y_3_2 + (EFFECT_TEXT_HEIGHT_2 / 2.) + POKER_LAYOUT: str = f""" background: @@ -165,15 +198,91 @@ effect_frame: radius: {EFFECT_FRAME_RADIUS}c stroke_width: 0.3mm +effect_icon: + x: {EFFECT_ICON_X}c + width: {EFFECT_ICON_SIZE}c + height: {EFFECT_ICON_SIZE}c + anchor: :center + +effect_icon_1_0: + extends: effect_icon + y: {EFFECT_ICON_Y_1}c + +effect_icon_2_0: + extends: effect_icon + y: {EFFECT_ICON_Y_2_0}c + +effect_icon_2_1: + extends: effect_icon + y: {EFFECT_ICON_Y_2_1}c + +effect_icon_3_0: + extends: effect_icon + y: {EFFECT_ICON_Y_3_0}c + +effect_icon_3_1: + extends: effect_icon + y: {EFFECT_ICON_Y_3_1}c + +effect_icon_3_2: + extends: effect_icon + y: {EFFECT_ICON_Y_3_2}c + +effect_separator: + x: {EFFECT_SEPARATOR_X}c + anchor: :center + height: {EFFECT_SEPARATOR_HEIGHT}c + width: :scale + +effect_separator_2_0: + extends: effect_separator + y: {EFFECT_SEPARATOR_Y_2}c + +effect_separator_3_0: + extends: effect_separator + y: {EFFECT_SEPARATOR_Y_3_0}c + +effect_separator_3_1: + extends: effect_separator + y: {EFFECT_SEPARATOR_Y_3_1}c + effect_text: x: {EFFECT_TEXT_X}c - y: {EFFECT_TEXT_Y}c width: {EFFECT_TEXT_WIDTH}c - height: {EFFECT_TEXT_HEIGHT}c align: center valign: middle markup: true +effect_text_1_0: + extends: effect_text + y: {EFFECT_TEXT_Y_1}c + height: {EFFECT_TEXT_HEIGHT_1}c + +effect_text_2_0: + extends: effect_text + y: {EFFECT_TEXT_Y_2_0}c + height: {EFFECT_TEXT_HEIGHT_2}c + +effect_text_2_1: + extends: effect_text + y: {EFFECT_TEXT_Y_2_1}c + height: {EFFECT_TEXT_HEIGHT_2}c + +effect_text_3_0: + extends: effect_text + y: {EFFECT_TEXT_Y_3_0}c + height: {EFFECT_TEXT_HEIGHT_3}c + +effect_text_3_1: + extends: effect_text + y: {EFFECT_TEXT_Y_3_1}c + height: {EFFECT_TEXT_HEIGHT_3}c + +effect_text_3_2: + extends: effect_text + y: {EFFECT_TEXT_Y_3_2}c + height: {EFFECT_TEXT_HEIGHT_3}c + paparazzo: x: {PAPARAZZO_X}c y: {PAPARAZZO_Y}c diff --git a/src/deck.rb b/src/deck.rb index fbe75c7..2508f53 100644 --- a/src/deck.rb +++ b/src/deck.rb @@ -1,7 +1,7 @@ require 'squib' -DPI = 300 +DPI = 150 CELL_PX = DPI / 8.0 BLEED = 0.125 # In inches WIDTH = (2.5 + 2*BLEED) * DPI @@ -57,6 +57,35 @@ def get_art(data, idx) return "default_art_#{icon}#{icon_alt}.svg" end +def get_grouped_effects(data, idx) + if data['effet_1'].nil? + n_effects = 0 + elsif data['effet_2'].nil? + n_effects = 1 + elsif data['effet_3'].nil? + n_effects = 2 + else + n_effects = 3 + end + effects = [] + (0..3).each do |i| + effects.append([data["type_effet_#{i}"], data["effet_#{i}"]]) + end + return [n_effects, effects] +end + +def get_n_effects(data, idx) + if data['effet_1'][idx].nil? + 0 + elsif data['effet_2'][idx].nil? + 1 + elsif data['effet_3'][idx].nil? + 2 + else + 3 + end +end + def embed_custom(embed, id) embed.svg width: "#{EMBED_SIZE}c", height: "#{EMBED_SIZE}c", dx: '0c', dy: "#{EMBED_DY}c", key: ":#{id}:", file: "._graphics/#{id}.svg" end @@ -108,19 +137,35 @@ Squib::Deck.new( svg file: alt_banner_file, layout: 'alt_banner' text str: data['rang_alt'], layout: 'alt_banner_text' - fill_color = data['effet'].map { |effet| effet.nil? ? '#0000': '#f7f7f7ff' } - stroke_color = data['effet'].map { |effet| effet.nil? ? '#0000': '#cca9' } + fill_color = data['effet_1'].map { |effet| effet.nil? ? '#0000': '#f7f7f7ff' } + stroke_color = data['effet_1'].map { |effet| effet.nil? ? '#0000': '#cca9' } rect layout: 'effect_frame', fill_color: fill_color, stroke_color: stroke_color - text(str: data['effet'], layout: 'effect_text', font_size: EFFECT_FONT_SIZE, spacing: EFFECT_FONT_SPACING) do |embed| - embed_custom(embed, 'effet') - embed_custom(embed, 'magouille') - embed_custom(embed, 'pv') - embed_custom(embed, 'symbole_ind') - embed_custom(embed, 'symbole_gau') - embed_custom(embed, 'symbole_roy') - embed_custom(embed, 'symbole_ana') - embed_custom(embed, 'symbole_dro') - embed_custom(embed, 'symbole_eco') + + n_effects = (0..data['icone'].length).map { |idx| get_n_effects(data, idx) } + (1..3).each do |n| + n.times do |i| + # Effect texts + text(str: (0..data['icone'].length).map { |idx| (n == n_effects[idx]) ? data["effet_#{i+1}"][idx] : nil}, layout: "effect_text_#{n}_#{i}", font_size: EFFECT_FONT_SIZE, spacing: EFFECT_FONT_SPACING) do |embed| + embed_custom(embed, 'effet') + embed_custom(embed, 'magouille') + embed_custom(embed, 'pv') + embed_custom(embed, 'symbole_ind') + embed_custom(embed, 'symbole_gau') + embed_custom(embed, 'symbole_roy') + embed_custom(embed, 'symbole_ana') + embed_custom(embed, 'symbole_dro') + embed_custom(embed, 'symbole_eco') + end + + # Effect icons + svg file: (0..data['icone'].length).map { |idx| (n == n_effects[idx]) ? data["type_effet_#{i+1}"][idx] + ".svg" : nil}, layout: "effect_icon_#{n}_#{i}" + end + end + (2..3).each do |n| + #Effect separators + (n-1).times do |i| + svg file: (0..data['icone'].length).map { |idx| (n == n_effects[idx]) ? "separateur_effet.svg" : nil}, layout: "effect_separator_#{n}_#{i}" + end end build :debug do @@ -133,8 +178,8 @@ Squib::Deck.new( end build :showcase do - hand range: [0, 6, 13, 21, 38, 59, 65], trim_radius: inches(0.125), fill_color: 'black' - showcase range: [0, 6, 13, 21, 38, 59, 65], trim: inches(BLEED), trim_radius: inches(0.125), fill_color: 'black' + hand range: [0, 6, 13, 21, 38, 59, 62], trim_radius: inches(0.125), fill_color: 'black' + showcase range: [0, 6, 13, 21, 38, 59, 62], trim: inches(BLEED), trim_radius: inches(0.125), fill_color: 'black' end build :full do