39 lines
921 B
JavaScript
39 lines
921 B
JavaScript
import {importCharacter} from "../xml-import/xml-import.mjs";
|
|
|
|
export class Character extends Actor {
|
|
|
|
import() {
|
|
let input = document.createElement('input')
|
|
input.type = 'file'
|
|
input.accept = '.xml'
|
|
input.onchange = e => {
|
|
importCharacter(this.id, e.target.files[0])
|
|
}
|
|
input.click()
|
|
}
|
|
/**
|
|
* Augment the basic Item data model with additional dynamic data.
|
|
*/
|
|
prepareData() {
|
|
super.prepareData();
|
|
this.prepareEmbeddedDocuments();
|
|
}
|
|
|
|
getRollData() {
|
|
const data = super.getRollData();
|
|
|
|
if (this.type !== 'character') return;
|
|
|
|
// Copy the ability scores to the top level, so that rolls can use
|
|
// formulas like `@str.mod + 4`.
|
|
if (data.attribute) {
|
|
for (let [k, v] of Object.entries(data.attribute)) {
|
|
data[k] = foundry.utils.deepClone(v);
|
|
}
|
|
}
|
|
console.log(data);
|
|
return data;
|
|
}
|
|
|
|
|
|
} |