Compare commits
No commits in common. "b6814c9f74bb0ee6aa7e0001a350a1bbe5922ed7" and "21479ce0826a446237ce3b64338fb4fa17564c90" have entirely different histories.
b6814c9f74
...
21479ce082
|
|
@ -14,8 +14,7 @@ async function preloadHandlebarsTemplates() {
|
||||||
'systems/DSA_4-1/templates/ui/partial-rollable-button.hbs',
|
'systems/DSA_4-1/templates/ui/partial-rollable-button.hbs',
|
||||||
'systems/DSA_4-1/templates/ui/partial-attribute-button.hbs',
|
'systems/DSA_4-1/templates/ui/partial-attribute-button.hbs',
|
||||||
'systems/DSA_4-1/templates/ui/partial-talent-editable.hbs',
|
'systems/DSA_4-1/templates/ui/partial-talent-editable.hbs',
|
||||||
'systems/DSA_4-1/templates/ui/partial-die.hbs',
|
'systems/DSA_4-1/templates/ui/partial-die.hbs'
|
||||||
'systems/DSA_4-1/templates/ui/partial-advantage-button.hbs'
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,4 +34,110 @@ export class Character extends Actor {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static onDroppedData(character, characterSheet, uuid) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async addSkillFromCompendiumByNameToActor(talentName, actor) {
|
||||||
|
const compendiumOfSkills = game.packs.get('DSA_4-1.talente-brw');
|
||||||
|
const talentId = compendiumOfSkills.index.find( skill => skill.name === talentName)
|
||||||
|
let talentObject = {}
|
||||||
|
const talent = await compendiumOfSkills.getDocument(talentId);
|
||||||
|
try {
|
||||||
|
const embeddedDocument = (await actor.createEmbeddedDocuments('Item', [talent]))[0]
|
||||||
|
if (embeddedDocument.type === "Skill") {
|
||||||
|
if (talent) {
|
||||||
|
talentObject = {
|
||||||
|
taw: 0,
|
||||||
|
talent: embeddedDocument.id,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`${talentName} not found in items`, error)
|
||||||
|
}
|
||||||
|
await actor.update({system: { talente: talentObject, ...actor.system.talente}})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds base skills according to the BRW to the given actor
|
||||||
|
* @param actor
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async #createBaseSkills(actor) {
|
||||||
|
const talentsByName = [
|
||||||
|
"Athletik", "Klettern", "Körperbeherrschung", "Schleichen", "Schwimmen", "Selbstbeherrschung", "Sich Verstecken", "Singen", "Sinnenschärfe", "Tanzen", "Zechen",
|
||||||
|
"Menschenkenntnis", "Überreden",
|
||||||
|
"Fährtensuchen", "Orientierung", "Wildnisleben",
|
||||||
|
"Götter/Kulte", "Rechnen", "Sagen/Legenden",
|
||||||
|
"Heilkunde: Wunden", "Holzbearbeitung", "Kochen", "Lederverarbeitung", "Malen/Zeichnen", "Schneidern"
|
||||||
|
]
|
||||||
|
|
||||||
|
const talente = []
|
||||||
|
|
||||||
|
talentsByName.forEach(talentName => {
|
||||||
|
|
||||||
|
this.addSkillFromCompendiumByNameToActor(
|
||||||
|
talentName,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
await actor.update({system: { talente: talente}})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the attributes of the given actor to their default values
|
||||||
|
* @param actor
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async #setBaseAttributes(actor) {
|
||||||
|
const startEigenschaften = {
|
||||||
|
"mu": {
|
||||||
|
start: 10,
|
||||||
|
aktuell: 10,
|
||||||
|
mod: 0
|
||||||
|
},
|
||||||
|
"kl": {
|
||||||
|
start: 10,
|
||||||
|
aktuell: 10,
|
||||||
|
mod: 0
|
||||||
|
},
|
||||||
|
"in": {
|
||||||
|
start: 10,
|
||||||
|
aktuell: 10,
|
||||||
|
mod: 0
|
||||||
|
},
|
||||||
|
"ch": {
|
||||||
|
start: 10,
|
||||||
|
aktuell: 10,
|
||||||
|
mod: 0
|
||||||
|
},
|
||||||
|
"ff": {
|
||||||
|
start: 10,
|
||||||
|
aktuell: 10,
|
||||||
|
mod: 0
|
||||||
|
},
|
||||||
|
"ge": {
|
||||||
|
start: 10,
|
||||||
|
aktuell: 10,
|
||||||
|
mod: 0
|
||||||
|
},
|
||||||
|
"ko": {
|
||||||
|
start: 10,
|
||||||
|
aktuell: 10,
|
||||||
|
mod: 0
|
||||||
|
},
|
||||||
|
"kk": {
|
||||||
|
start: 10,
|
||||||
|
aktuell: 10,
|
||||||
|
mod: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await actor.update({system: {attribute: startEigenschaften}})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,20 +80,25 @@ export class CharacterSheet extends ActorSheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
#addAdvantagesToContext(context) {
|
#addAdvantagesToContext(context) {
|
||||||
context.advantages = [];
|
const actorAdvantages = {}
|
||||||
const actorData = context.data;
|
const actorData = context.data;
|
||||||
Object.values(actorData.items).forEach( (item) => {
|
Object.values(actorData.items).forEach( (item) => {
|
||||||
if (item.type === "Advantage") {
|
if (item.type === "Advantage") {
|
||||||
context.advantages.push({
|
actorAdvantages[item._id] = item;
|
||||||
id: item._id,
|
|
||||||
name: item.name,
|
|
||||||
value: item.system.value,
|
|
||||||
options: item.system.auswahl,
|
|
||||||
description: item.system.description,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
if ( context.system.vornachteile.length >= 0) {
|
||||||
|
context.system.vornachteile.forEach( ( { vornachteil }, index) => {
|
||||||
|
context.vornachteile.push(
|
||||||
|
{
|
||||||
|
name: vornachteil.name,
|
||||||
|
value: vornachteil.value,
|
||||||
|
auswahl: vornachteil.auswahl,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#addAttributesToContext(context) {
|
#addAttributesToContext(context) {
|
||||||
|
|
@ -188,6 +193,18 @@ export class CharacterSheet extends ActorSheet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onDropDocument(event, item) {
|
||||||
|
console.log(item)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
_onDragStart(event) {
|
||||||
|
super._onDragStart(event);
|
||||||
|
const src = event.target
|
||||||
|
console.log(event)
|
||||||
|
event.dataTransfer.setData("plain/text", src.dataset.name);
|
||||||
|
}
|
||||||
|
|
||||||
_evaluateRoll(rolledDice, { taw, lowerThreshold = 1, upperThreshold = 20, countToMeisterlich = 3, countToPatzer = 3, werte = [] } ) {
|
_evaluateRoll(rolledDice, { taw, lowerThreshold = 1, upperThreshold = 20, countToMeisterlich = 3, countToPatzer = 3, werte = [] } ) {
|
||||||
let tap = taw;
|
let tap = taw;
|
||||||
let meisterlichCounter = 0;
|
let meisterlichCounter = 0;
|
||||||
|
|
@ -245,7 +262,8 @@ export class CharacterSheet extends ActorSheet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
openEmbeddedDocument(documentId) {
|
_onOpenSkill(documentId) {
|
||||||
|
console.log(this.object.items.get(documentId).sheet);
|
||||||
this.object.items.get(documentId).sheet.render(true)
|
this.object.items.get(documentId).sheet.render(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -297,12 +315,7 @@ export class CharacterSheet extends ActorSheet {
|
||||||
});
|
});
|
||||||
|
|
||||||
html.on('click', '.talent .name', (evt) => {
|
html.on('click', '.talent .name', (evt) => {
|
||||||
this.openEmbeddedDocument(evt.target.dataset.id);
|
this._onOpenSkill(evt.target.dataset.id);
|
||||||
evt.stopPropagation();
|
|
||||||
})
|
|
||||||
|
|
||||||
html.on('click', '.advantage .name', (evt) => {
|
|
||||||
this.openEmbeddedDocument(evt.target.dataset.id);
|
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -329,6 +342,7 @@ export class CharacterSheet extends ActorSheet {
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
let handler = ev => this._onDragStart(ev);
|
let handler = ev => this._onDragStart(ev);
|
||||||
// Find all items on the character sheet.
|
// Find all items on the character sheet.
|
||||||
html.find('.talent.rollable').each((i, li) => {
|
html.find('.talent.rollable').each((i, li) => {
|
||||||
|
|
@ -348,15 +362,6 @@ export class CharacterSheet extends ActorSheet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#handleDroppedAdvantage(actor, advantage) {
|
|
||||||
const array = Array.from(actor.items);
|
|
||||||
for ( let i = 0; i < array.length; i++ ) {
|
|
||||||
if (array[i].name === advantage.name) { // TODO: adjust for uniqueness
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static getElementByName(collection, id) {
|
static getElementByName(collection, id) {
|
||||||
const array = Array.from(collection);
|
const array = Array.from(collection);
|
||||||
for (const element of array) {
|
for (const element of array) {
|
||||||
|
|
@ -378,8 +383,6 @@ export class CharacterSheet extends ActorSheet {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "Skill":
|
case "Skill":
|
||||||
return characterSheet.#handleDroppedSkill(actor, document); // on false cancel this whole operation
|
return characterSheet.#handleDroppedSkill(actor, document); // on false cancel this whole operation
|
||||||
case "Advantage":
|
|
||||||
return characterSheet.#handleDroppedAdvantage(actor, document);
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ export async function importCharacter(actorId, file) {
|
||||||
let dom = domParser.parseFromString(xmlString, 'application/xml')
|
let dom = domParser.parseFromString(xmlString, 'application/xml')
|
||||||
|
|
||||||
let rawJson = getJsonFromXML(dom)
|
let rawJson = getJsonFromXML(dom)
|
||||||
let characterJson = mapRawJson(actor, rawJson)
|
let characterJson = mapRawJson(rawJson)
|
||||||
|
|
||||||
actor.update(characterJson)
|
actor.update(characterJson)
|
||||||
}
|
}
|
||||||
|
|
@ -70,22 +70,6 @@ function getJsonFromXML(dom) {
|
||||||
return jsonResult;
|
return jsonResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addSkillFromCompendiumByNameToActor(talentName, taw, actor) {
|
|
||||||
const compendiumOfSkills = game.packs.get('DSA_4-1.talente-brw');
|
|
||||||
const talentId = compendiumOfSkills.index.find( skill => skill.name === talentName)
|
|
||||||
if (talentId) {
|
|
||||||
|
|
||||||
const talent = await compendiumOfSkills.getDocument(talentId._id);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const embeddedDocument = (await actor.createEmbeddedDocuments('Item', [talent]))[0]
|
|
||||||
embeddedDocument.update({system: {taw: taw}});
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`${talentName} not found in items`, error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets the text content of a file
|
* gets the text content of a file
|
||||||
* @param file the file with the desired content
|
* @param file the file with the desired content
|
||||||
|
|
@ -117,11 +101,20 @@ function calculateBirthdate(json) {
|
||||||
return `${day}. ${month} ${year} BF`
|
return `${day}. ${month} ${year} BF`
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapSkills(actor, held) {
|
function mapSkills(rawJson) {
|
||||||
|
let talents = []
|
||||||
for (let talent in held.talentliste.talent) {
|
for (let talent in held.talentliste.talent) {
|
||||||
talent = held.talentliste.talent[talent]
|
talent = held.talentliste.talent[talent]
|
||||||
addSkillFromCompendiumByNameToActor(talent.name, talent.value, actor)
|
let talentItem = game.items.getName(talent.name)
|
||||||
|
if (talentItem) {
|
||||||
|
let talentJson = {
|
||||||
|
talent: talentItem,
|
||||||
|
taw: talent.value,
|
||||||
|
}
|
||||||
|
talents.push(talentJson)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return talents
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -129,7 +122,7 @@ function mapSkills(actor, held) {
|
||||||
* @param rawJson the json parsed from the Helden-Software XML
|
* @param rawJson the json parsed from the Helden-Software XML
|
||||||
* @returns {{}} a json representation of the character
|
* @returns {{}} a json representation of the character
|
||||||
*/
|
*/
|
||||||
function mapRawJson(actor, rawJson) {
|
function mapRawJson(rawJson) {
|
||||||
let json = {}
|
let json = {}
|
||||||
let held = rawJson.helden.held;
|
let held = rawJson.helden.held;
|
||||||
json.name = held.name
|
json.name = held.name
|
||||||
|
|
@ -272,7 +265,7 @@ function mapRawJson(actor, rawJson) {
|
||||||
json.sonderfertigkeiten = specialAbilities
|
json.sonderfertigkeiten = specialAbilities
|
||||||
json.liturgien = liturgies
|
json.liturgien = liturgies
|
||||||
|
|
||||||
mapSkills(actor, held)
|
json.talente = mapSkills(rawJson)
|
||||||
let spells = []
|
let spells = []
|
||||||
/*for (let spell in held.zauberliste.zauber) {
|
/*for (let spell in held.zauberliste.zauber) {
|
||||||
spell = held.zauberliste.zauber[spell]
|
spell = held.zauberliste.zauber[spell]
|
||||||
|
|
|
||||||
|
|
@ -61,8 +61,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="tab attributes" data-group="primary" data-tab="attributes">
|
<div class="tab attributes" data-group="primary" data-tab="attributes">
|
||||||
<ul>
|
<ul>
|
||||||
{{#each this.advantages}}
|
{{#each items}}
|
||||||
<li>{{> "systems/DSA_4-1/templates/ui/partial-advantage-button.hbs" this}}</li>
|
<li>{{this.name}}</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -161,4 +161,4 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
{{!-- Sheet Body --}}
|
{{!-- Sheet Body --}}
|
||||||
<section class="sheet-body" style="flex: 1">
|
<section class="sheet-body" style="flex: 1">
|
||||||
<div class="tab json" data-group="primary" data-tab="json">
|
<div class="tab json" data-group="primary" data-tab="json">
|
||||||
<pre style="overflow: auto; white-space: normal; position: relative; top: 8px; bottom: 8px; left: 8px; right: 8px">{{json}}</pre>
|
<pre style="overflow: auto">{{json}}</pre>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
<div class="advantage">
|
|
||||||
<span class="name" data-id="{{this.id}}">{{this.name}}</span>
|
|
||||||
</div>
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="block rollable {{this.type}} {{this.gruppe}}" data-id="{{this.id}}" data-taw="{{this.taw}}" data-name="{{this.name}}" data-eigenschaft1="{{this.eigenschaft1}}" data-eigenschaft2="{{this.eigenschaft2}}" data-eigenschaft3="{{this.eigenschaft3}}" data-taw="{{this.taw}}" data-rollEigenschaft1="{{this.rollEigenschaft1}}" data-rollEigenschaft2="{{this.rollEigenschaft2}}" data-rollEigenschaft3="{{this.rollEigenschaft3}}">
|
<div class="block rollable {{this.type}} {{this.gruppe}}" data-id="{{this.id}}" data-taw="{{this.taw}}'data-name="{{this.name}}" data-eigenschaft1="{{this.eigenschaft1}}" data-eigenschaft2="{{this.eigenschaft2}}" data-eigenschaft3="{{this.eigenschaft3}}" data-taw="{{this.taw}}" data-rollEigenschaft1="{{this.rollEigenschaft1}}" data-rollEigenschaft2="{{this.rollEigenschaft2}}" data-rollEigenschaft3="{{this.rollEigenschaft3}}">
|
||||||
|
|
||||||
<div class="die">
|
<div class="die">
|
||||||
{{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }}
|
{{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue