forked from GitHub-Mirrors/foundry-sw5e
Update characterImporter.js
This commit is contained in:
parent
52fd477d39
commit
6f90f19ad1
1 changed files with 3 additions and 1 deletions
|
@ -3,7 +3,7 @@ export default class CharacterImporter {
|
|||
// transform JSON from sw5e.com to Foundry friendly format
|
||||
// and insert new actor
|
||||
static async transform(rawCharacter){
|
||||
const sourceCharacter = JSON.parse(rawCharacter); //source character
|
||||
const sourceCharacter = JSON.parse(rawCharacter);
|
||||
|
||||
const details = {
|
||||
species: sourceCharacter.attribs.find(e => e.name == "race").current,
|
||||
|
@ -131,12 +131,14 @@ export default class CharacterImporter {
|
|||
|
||||
let actor = await Actor.create(targetCharacter);
|
||||
|
||||
//add class and level
|
||||
const profession = sourceCharacter.attribs.find(e => e.name == "class").current;
|
||||
let professionLevel = sourceCharacter.attribs.find(e => e.name == "class_display").current;
|
||||
professionLevel = parseInt( professionLevel.replace(/[^0-9]/g,'') ); //remove a-z, leaving only integers
|
||||
CharacterImporter.addClasses(profession, professionLevel, actor);
|
||||
}
|
||||
|
||||
//currently only works with 1 class
|
||||
static async addClasses(profession, level, actor){
|
||||
let classes = await game.packs.get('sw5e.classes').getContent();
|
||||
let assignedClass = classes.find( c => c.name === profession );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue