arcanistzed / pdf-sheet

A system agnostic tool to export your Foundry character sheet to a PDF!
https://arcanist.me
MIT License
14 stars 58 forks source link

[Bug]: most DnD Exports does not work #120

Open dbo-po opened 11 months ago

dbo-po commented 11 months ago

Expected Behavior

I select the mapping, click on expert, select in mapping mentioned PDF => get filled PDF

Current Behavior

If i try to export my DnD Character, the most of the mappings bring the error grafik The only DnD Mapping which works is the mapping for "charakterbogen_ataendler_v2.8.1.pdf".

Log: grafik

Steps to Reproduce

1) go to settings 2) set Mapping to a DnD Sheept except the ataendler 3) save 4) download PDF which is mentioned in the mapping 5) open DnD player Char 6) Export to PDF 7) select downloaded pdf 8) -> Error

Context

No response

Version

0.24.9

Foundry VTT Version

11.315

Operating System

Windows 10

Browser / App

Firefox

Game System

DnD 5e

Modules Disabled

fverdoja commented 10 months ago

Can confirm, same issue here, only the ataendler mapping exports correctly.

I can provide the json of one of sheets that fails to export if it can help.

Version

0.24.9

Foundry VTT Version

11.315

Game System

DnD5e 2.4.1

fverdoja commented 10 months ago

I can provide the json of one of sheets that fails to export if it can help.

Here it is: fvtt-Actor-jebeddo-dei-mari-Ixby2TiGJNDB3KBu.json

davelamorte commented 10 months ago

Like I said in other posts, the workaround is simple, delete any extra language. If you only leave "common" it works. I don't know anything how to fix the issue on the code.. otherwise I would have done myself; I found out about the workaround after a little testing weeks ago!

ALXLight commented 10 months ago

The problem is the languages is not a straight map but an object, so line " a = @ system.traits.languages.value.map(x => game.dnd5e.config.languages[x]).first();" wont work. It shold be rewritten ro recoursive search for getting obj[x] if it is string or dive deeper for f(obj[x].children).

UPD. Managed to get it work for 'dnd5eV11extended'.

replaced a = @ system.traits.languages.value.map(x => game.dnd5e.config.languages[x]).first(); by

function findValRecursively(m, x)
{
  for(let k in m)
  {
    if(k == x)
      return m[k];
    if(m[k] instanceof Object){
      let res = findValRecursively(m[k].children, x);
      if (res) 
      return res;
    }
  }
}
a =  @ system.traits.languages.value.map(x => findValRecursively(game.dnd5e.config.languages,x)).first();

Not sure if it is a good way but it works for me