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
|
// transform JSON from sw5e.com to Foundry friendly format
|
||||||
// and insert new actor
|
// and insert new actor
|
||||||
static async transform(rawCharacter){
|
static async transform(rawCharacter){
|
||||||
const sourceCharacter = JSON.parse(rawCharacter); //source character
|
const sourceCharacter = JSON.parse(rawCharacter);
|
||||||
|
|
||||||
const details = {
|
const details = {
|
||||||
species: sourceCharacter.attribs.find(e => e.name == "race").current,
|
species: sourceCharacter.attribs.find(e => e.name == "race").current,
|
||||||
|
@ -131,12 +131,14 @@ export default class CharacterImporter {
|
||||||
|
|
||||||
let actor = await Actor.create(targetCharacter);
|
let actor = await Actor.create(targetCharacter);
|
||||||
|
|
||||||
|
//add class and level
|
||||||
const profession = sourceCharacter.attribs.find(e => e.name == "class").current;
|
const profession = sourceCharacter.attribs.find(e => e.name == "class").current;
|
||||||
let professionLevel = sourceCharacter.attribs.find(e => e.name == "class_display").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
|
professionLevel = parseInt( professionLevel.replace(/[^0-9]/g,'') ); //remove a-z, leaving only integers
|
||||||
CharacterImporter.addClasses(profession, professionLevel, actor);
|
CharacterImporter.addClasses(profession, professionLevel, actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//currently only works with 1 class
|
||||||
static async addClasses(profession, level, actor){
|
static async addClasses(profession, level, actor){
|
||||||
let classes = await game.packs.get('sw5e.classes').getContent();
|
let classes = await game.packs.get('sw5e.classes').getContent();
|
||||||
let assignedClass = classes.find( c => c.name === profession );
|
let assignedClass = classes.find( c => c.name === profession );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue