From 530eac25f94b14bcfcf8519023206af2fd386887 Mon Sep 17 00:00:00 2001 From: dakkar Date: Sun, 23 Oct 2011 14:01:13 +0100 Subject: mostra livello 0 ovvero, non saltare stringhe false, solo stringhe vuote --- incantesimi/excel_to_incantesimi.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'incantesimi/excel_to_incantesimi.pl') diff --git a/incantesimi/excel_to_incantesimi.pl b/incantesimi/excel_to_incantesimi.pl index e2d1899..95e0c95 100644 --- a/incantesimi/excel_to_incantesimi.pl +++ b/incantesimi/excel_to_incantesimi.pl @@ -113,7 +113,7 @@ __DATA__ [% FOREACH spell IN spells %] \incantesimo{type=spell, -[%- FOREACH field IN fieldmap; IF spell.item(field.key) %] +[%- FOREACH field IN fieldmap; IF spell.item(field.key) != '' %] [% field.value %]={[% lt(spell.item(field.key)) %]}, [%- END; END %] } [% IF (loop.count() % 6) %]& [% ELSE %] \\ [% END -%] -- cgit v1.2.3 From b0f883f8b8b29265b3a2d8a5577b4e6d9e1357cf Mon Sep 17 00:00:00 2001 From: dakkar Date: Sun, 23 Oct 2011 14:10:51 +0100 Subject: gestisci incantesimi di dominio (2Âș foglio) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- incantesimi/excel_to_incantesimi.pl | 65 ++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 16 deletions(-) (limited to 'incantesimi/excel_to_incantesimi.pl') diff --git a/incantesimi/excel_to_incantesimi.pl b/incantesimi/excel_to_incantesimi.pl index 95e0c95..674d0b1 100644 --- a/incantesimi/excel_to_incantesimi.pl +++ b/incantesimi/excel_to_incantesimi.pl @@ -9,6 +9,7 @@ use Data::Printer; # excel => latex my %fieldmap = ( spellname => 'name', + name => 'name', level => 'level', school => 'scuola', comp => 'components', @@ -18,7 +19,7 @@ my %fieldmap = ( duration => 'durata', st => 'st', sr => 'sr', - spell => 'descrizione', + description => 'descrizione', special => 'specialcomp', page => 'ref', notes => 'note', @@ -33,25 +34,56 @@ my $parser = Spreadsheet::ParseExcel->new(); my $wb = $parser->parse($input_filename) or die $parser->error; -my $spells = parse_table($wb->worksheet('Incantesimi') - // $wb->worksheet(0)); +sheet_2_latex( + sheet_name => 'Incantesimi', + output_filename => "${output_filename}.incantesimi.tex", +); +sheet_2_latex( + sheet_name => 'Domini', + sheet_idx => 1, + output_filename => "${output_filename}.domini.tex", + skip_col => 1, +); + +{ +my $template; +sub template { + $template //= do {local $/;}; + return $template; +} +} -munge($spells); -p $spells; -my $template = Template->new(); -$template->process( - \*DATA, - { - spells => $spells, +sub sheet_2_latex { + my %opts = ( + sheet_idx => 0, fieldmap => \%fieldmap, - lt => \&latexise, - }, - $output_filename, -) + @_, + ); + + my $spells = parse_table( + $wb->worksheet($opts{sheet_name}) + // $wb->worksheet($opts{sheet_idx}), + $opts{skip_col}, + ); + + munge($spells); + + my $template = Template->new(); + $template->process( + \template(), + { + spells => $spells, + fieldmap => $opts{fieldmap}, + lt => \&latexise, + }, + $opts{output_filename}, + ) or die $template->error; +} sub parse_table { - my ($ws) = @_; + my ($ws,$skip_col) = @_; + $skip_col //= 0; my ($min_col,$max_col) = $ws->col_range(); my ($min_row,$max_row) = $ws->row_range(); @@ -59,6 +91,7 @@ sub parse_table { $min_col .. $max_col; for my $h (@headings) { + $h =~ s{^spell\W}{}i; $h =~ s{\W.*$}{}; $h = lc($h); } @@ -67,7 +100,7 @@ sub parse_table { for my $row ((1+$min_row) .. $max_row) { # allow and skip empty rows - next unless eval { $ws->get_cell($row,$min_col)->value }; + next unless eval { $ws->get_cell($row,$min_col+$skip_col)->value }; my %record; keys @headings; -- cgit v1.2.3 From 3a845849d6d63dbfc363c0d34a4acdf1c975124d Mon Sep 17 00:00:00 2001 From: dakkar Date: Sun, 23 Oct 2011 15:10:57 +0100 Subject: fattorizzazione, e poteri --- incantesimi/excel_to_incantesimi.pl | 18 +++++++++++++++++- incantesimi/incantesimi.cmd.tex | 31 +++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 7 deletions(-) (limited to 'incantesimi/excel_to_incantesimi.pl') diff --git a/incantesimi/excel_to_incantesimi.pl b/incantesimi/excel_to_incantesimi.pl index 674d0b1..d1c82cf 100644 --- a/incantesimi/excel_to_incantesimi.pl +++ b/incantesimi/excel_to_incantesimi.pl @@ -1,6 +1,7 @@ #!/usr/bin/perl use strict; use warnings; +use utf8; use Spreadsheet::ParseExcel; use LaTeX::Encode; use Template; @@ -10,10 +11,16 @@ use Data::Printer; my %fieldmap = ( spellname => 'name', name => 'name', + ability => 'name', level => 'level', + equiv => 'level', school => 'scuola', + source => 'source', + uses => 'uses', + type => 'type', comp => 'components', ct => 'tempo', + at => 'tempo', range => 'range', target => 'target', duration => 'durata', @@ -44,6 +51,13 @@ sheet_2_latex( output_filename => "${output_filename}.domini.tex", skip_col => 1, ); +sheet_2_latex( + sheet_name => 'AbilitĂ  speciali', + sheet_idx => 2, + output_filename => "${output_filename}.special.tex", + command => 'potere', + skip_col => 1, +); { my $template; @@ -57,6 +71,7 @@ sub sheet_2_latex { my %opts = ( sheet_idx => 0, fieldmap => \%fieldmap, + command => 'incantesimo', @_, ); @@ -74,6 +89,7 @@ sub sheet_2_latex { { spells => $spells, fieldmap => $opts{fieldmap}, + command => $opts{command}, lt => \&latexise, }, $opts{output_filename}, @@ -145,7 +161,7 @@ __DATA__ \matrix { [% FOREACH spell IN spells %] -\incantesimo{type=spell, +\[% command %]{ [%- FOREACH field IN fieldmap; IF spell.item(field.key) != '' %] [% field.value %]={[% lt(spell.item(field.key)) %]}, [%- END; END %] diff --git a/incantesimi/incantesimi.cmd.tex b/incantesimi/incantesimi.cmd.tex index 3ceb4b9..d4c09f1 100644 --- a/incantesimi/incantesimi.cmd.tex +++ b/incantesimi/incantesimi.cmd.tex @@ -5,6 +5,7 @@ \usepackage[OT1]{fontenc} \usepackage{pgfkeys} \usepackage{tikz} +\usepackage{ifthen} \usetikzlibrary{calc} \usetikzlibrary{shapes.multipart} @@ -59,16 +60,20 @@ \tikzset{/spells/note/.initial={}} \tikzset{/spells/ref/.initial={}} \tikzset{/spells/tempo/.initial={1 a}} +\tikzset{/spells/tempostr/.initial={}} \tikzset{/spells/level/.initial={Must be passed in}} +\tikzset{/spells/levelstr/.initial={}} \tikzset{/spells/name/.initial={Must be passed in}} \tikzset{/spells/scuola/.initial={Must be passed in}} +\tikzset{/spells/source/.initial={Must be passed in}} \tikzset{/spells/durata/.initial={Must be passed in}} \tikzset{/spells/components/.initial={Must be passed in}} +\tikzset{/spells/uses/.initial={Must be passed in}} \tikzset{/spells/descrizione/.initial={Must be passed in}} \tikzset{/spells/target/.initial={Must be passed in}} \tikzset{/spells/range/.initial={Must be passed in}} -\newcommand{\incantesimo}[1]{% +\newcommand{\spellcard}[1]{% %\begin{scope}[every node/.style={draw,ultra thin},/spells/.cd,#1] \begin{scope}[/spells/.cd,#1] \node[carta] (card) {}; @@ -91,7 +96,7 @@ %lato sud est \node [anchor=south east,above angles label] (tempo) at (card.east |- prep.north) - {\textsf{CT: \pgfkeysvalueof{/spells/tempo}}}; + {\pgfkeysvalueof{/spells/tempostr}}; \node [anchor=north east,side label] (ref) at ($(tempo.north east) + (0,3mm)$) {\pgfkeysvalueof{/spells/ref}}; @@ -107,11 +112,11 @@ %sottotitoli -\node [anchor=north east,align=flush right,rectangle,subt label] (scuola) at (type.south west) - {\emph{\pgfkeysvalueof{/spells/scuola}}}; +\node [anchor=north east,align=flush right,rectangle,subt label] (source) at (type.south west) + {\emph{\pgfkeysvalueof{/spells/source}}}; \node [anchor=north west,rectangle split,rectangle split parts=2,rectangle split part align={left,flushright},subt label] - (components) at ($(scuola.south -| card.west) - (0mm,0mm)$) + (components) at ($(source.south -| card.west) - (0mm,0mm)$) {\textsc{\pgfkeysvalueof{/spells/components}}\nodepart{two}{\tiny\pgfkeysvalueof{/spells/specialcomp}}}; @@ -131,8 +136,22 @@ %lato est \node [anchor=north west,side label] (lvl) at ($0.8*(card.east)+0.2*(card.north east)$) - {\textbf{LVL \pgfkeysvalueof{/spells/level}}}; + {\textbf{\pgfkeysvalueof{/spells/levelstr}}}; \end{scope}% } + +\newcommand{\incantesimo}[1]{% +\pgfkeys{/spells/.cd,#1}\spellcard{type=spell, + tempostr={CT: \pgfkeysvalueof{/spells/tempo}}, + source={\pgfkeysvalueof{scuola}}, + levelstr={LVL \pgfkeysvalueof{/spells/level}}, +}} + +\newcommand{\potere}[1]{% +\pgfkeys{/spells/.cd,level={},type=special,#1}\spellcard{ + tempostr={AT: \pgfkeysvalueof{/spells/tempo}}, + components={\pgfkeysvalueof{/spells/uses}}, + levelstr={\ifthenelse{\equal{\pgfkeysvalueof{/spells/level}}{}}{}{EqvLvl~\pgfkeysvalueof{/spells/level}}} +}} -- cgit v1.2.3