Compare commits
No commits in common. "454faf8fe699007474c9d6f00155cbefa6e2c3d3" and "fa4531cd32f04d92ed8a089923ed1613b97bb575" have entirely different histories.
454faf8fe6
...
fa4531cd32
|
|
@ -43,8 +43,7 @@ export class PlayerCharacterDataModel extends foundry.abstract.TypeDataModel {
|
||||||
so: new NumberField({ required: true, integer: true }),
|
so: new NumberField({ required: true, integer: true }),
|
||||||
gilde: new StringField(),
|
gilde: new StringField(),
|
||||||
}),
|
}),
|
||||||
talente: new ArrayField ( new SchemaField(
|
talente: new ArrayField ( new ForeignDocumentField(Item) ),
|
||||||
{taw: new NumberField(), talent: new ForeignDocumentField(Item) })),
|
|
||||||
zauber: new ArrayField ( new ForeignDocumentField(Item) ),
|
zauber: new ArrayField ( new ForeignDocumentField(Item) ),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -53,49 +52,4 @@ export class PlayerCharacterDataModel extends foundry.abstract.TypeDataModel {
|
||||||
super._initialize(options);
|
super._initialize(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onCreate(data, options, userId) {
|
|
||||||
// prepare base talents
|
|
||||||
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 => {
|
|
||||||
const talent = game.items.getName(talentName);
|
|
||||||
console.log(talent);
|
|
||||||
if (talent) {
|
|
||||||
talente.push({
|
|
||||||
taw: 0,
|
|
||||||
talent
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
console.error(`${talentName} not found in items`)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// push base talents
|
|
||||||
game.actors.getName(data.name).update({system: {talente}})
|
|
||||||
|
|
||||||
const startEigenschaften = {
|
|
||||||
"mu": 10,
|
|
||||||
"kl": 10,
|
|
||||||
"in": 10,
|
|
||||||
"ch": 10,
|
|
||||||
"ff": 10,
|
|
||||||
"ge": 10,
|
|
||||||
"ko": 10,
|
|
||||||
"kk": 10,
|
|
||||||
}
|
|
||||||
|
|
||||||
game.actors.getName(data.name).update({system: {attribute: startEigenschaften}})
|
|
||||||
super._onCreate(data, options, userId);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -7,21 +7,4 @@ export class Character extends Actor {
|
||||||
this.prepareEmbeddedDocuments();
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
|
import { BaseItem } from "./base-item.mjs";
|
||||||
|
|
||||||
export class Skill extends Item {
|
export class Skill extends BaseItem {
|
||||||
/**
|
/**
|
||||||
* Augment the basic Item data model with additional dynamic data.
|
* Augment the basic Item data model with additional dynamic data.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
export class Spell extends Item {
|
import { BaseItem } from "./base-item.mjs";
|
||||||
|
|
||||||
|
export class Spell extends BaseItem {
|
||||||
/**
|
/**
|
||||||
* Augment the basic Item data model with additional dynamic data.
|
* Augment the basic Item data model with additional dynamic data.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -34,63 +34,14 @@ export class CharacterSheet extends ActorSheet {
|
||||||
// Add the actor's data to context.data for easier access, as well as flags.
|
// Add the actor's data to context.data for easier access, as well as flags.
|
||||||
context.system = actorData.system;
|
context.system = actorData.system;
|
||||||
context.flags = actorData.flags;
|
context.flags = actorData.flags;
|
||||||
context.attributes = [
|
|
||||||
{
|
|
||||||
eigenschaft: "mu",
|
|
||||||
name: "Mut",
|
|
||||||
wert: actorData.system.attribute.mu ?? 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
eigenschaft: "kl",
|
|
||||||
name: "Klugheit",
|
|
||||||
wert: actorData.system.attribute.kl ?? 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
eigenschaft: "in",
|
|
||||||
name: "Intuition",
|
|
||||||
wert: actorData.system.attribute.in ?? 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
eigenschaft: "ch",
|
|
||||||
name: "Charisma",
|
|
||||||
wert: actorData.system.attribute.ch ?? 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
eigenschaft: "ff",
|
|
||||||
name: "Fingerfertigkeit",
|
|
||||||
wert: actorData.system.attribute.ff ?? 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
eigenschaft: "ge",
|
|
||||||
name: "Geschicklichkeit",
|
|
||||||
wert: actorData.system.attribute.ge ?? 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
eigenschaft: "ko",
|
|
||||||
name: "Konstitution",
|
|
||||||
wert: actorData.system.attribute.ko ?? 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
eigenschaft: "kk",
|
|
||||||
name: "Körperkraft",
|
|
||||||
wert: actorData.system.attribute.kk ?? 0,
|
|
||||||
},
|
|
||||||
|
|
||||||
];
|
|
||||||
context.skills = [];
|
context.skills = [];
|
||||||
if ( context.system.talente?.length >= 0) {
|
if ( context.system.talente?.length >= 0) {
|
||||||
context.system.talente.forEach(talent => {
|
context.system.talente.forEach(talent => {
|
||||||
console.log(talent);
|
const tempTalent = talent();
|
||||||
const taw = talent.taw;
|
console.log(tempTalent.system.probe);
|
||||||
const talentObjekt = game.items.get(talent.talent);
|
|
||||||
const eigenschaften = Object.values(talentObjekt.system.probe);
|
|
||||||
context.skills.push({
|
context.skills.push({
|
||||||
talentName: talentObjekt.name,
|
talentName: tempTalent.name,
|
||||||
taw: taw,
|
probe: `ROLLDATA(${Object.values(tempTalent.system.probe).join("/")})`
|
||||||
rollEigenschaft1: this.prepareEigenschaftRoll(actorData, eigenschaften[0]),
|
|
||||||
rollEigenschaft2: this.prepareEigenschaftRoll(actorData, eigenschaften[1]),
|
|
||||||
rollEigenschaft3: this.prepareEigenschaftRoll(actorData, eigenschaften[2]),
|
|
||||||
probe: `(${eigenschaften.join("/")})`
|
|
||||||
});
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
@ -100,97 +51,9 @@ export class CharacterSheet extends ActorSheet {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareEigenschaftRoll(actorData, name) {
|
|
||||||
return actorData.system.attribute[name.toLowerCase()]
|
|
||||||
}
|
|
||||||
|
|
||||||
async _onTalentRoll(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
const dataset = event.currentTarget.dataset;
|
|
||||||
console.log(dataset)
|
|
||||||
if (dataset.rolleigenschaft1) {
|
|
||||||
let roll1 = new Roll("3d20", this.actor.getRollData());
|
|
||||||
|
|
||||||
let evaluated1 = (await roll1.evaluate())
|
|
||||||
|
|
||||||
const dsaDieRollEvaluated = this._evaluateRoll(evaluated1.terms[0].results, {
|
|
||||||
taw: dataset.taw,
|
|
||||||
werte: [dataset.rolleigenschaft1, dataset.rolleigenschaft2, dataset.rolleigenschaft3],
|
|
||||||
})
|
|
||||||
|
|
||||||
if (dsaDieRollEvaluated.tap >= 0) { // erfolg
|
|
||||||
evaluated1.toMessage({
|
|
||||||
speaker: ChatMessage.getSpeaker({actor: this.actor}),
|
|
||||||
flavor: ` ${dsaDieRollEvaluated.meisterlich?'Meisterlich geschafft':'Geschafft'} mit ${dsaDieRollEvaluated.tap} Punkten übrig`,
|
|
||||||
rollMode: game.settings.get('core', 'rollMode'),
|
|
||||||
})
|
|
||||||
} else { // misserfolg
|
|
||||||
evaluated1.toMessage({
|
|
||||||
speaker: ChatMessage.getSpeaker({actor: this.actor}),
|
|
||||||
flavor: ` ${dsaDieRollEvaluated.meisterlich?'Gepatzt':''} mit ${Math.abs(dsaDieRollEvaluated.tap)} Punkten daneben`,
|
|
||||||
rollMode: game.settings.get('core', 'rollMode'),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_evaluateRoll(rolledDice, { taw, lowerThreshold = 1, upperThreshold = 20, countToMeisterlich = 3, countToPatzer = 3, werte = [] } ) {
|
|
||||||
let tap = taw;
|
|
||||||
let meisterlichCounter = 0;
|
|
||||||
let patzerCounter = 0;
|
|
||||||
let failCounter = 0;
|
|
||||||
|
|
||||||
rolledDice.forEach( (rolledDie, index) => {
|
|
||||||
if (tap < 0 && rolledDie.result > werte[index]) {
|
|
||||||
tap -= rolledDie.result - werte[index];
|
|
||||||
if (tap <0) { // konnte nicht vollständig ausgeglichen werden
|
|
||||||
failCounter++;
|
|
||||||
}
|
|
||||||
} else if (rolledDie.result > werte[index]) { // taw ist bereits aufgebraucht und wert kann nicht ausgeglichen werden
|
|
||||||
tap -= rolledDie.result - werte[index];
|
|
||||||
failCounter++;
|
|
||||||
}
|
|
||||||
if (rolledDie.result <= lowerThreshold) meisterlichCounter++;
|
|
||||||
if (rolledDie.result > upperThreshold) patzerCounter++;
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
|
||||||
tap,
|
|
||||||
meisterlich: meisterlichCounter === countToMeisterlich,
|
|
||||||
patzer: patzerCounter === countToPatzer,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_onAttributeRoll(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
const dataset = event.currentTarget.dataset;
|
|
||||||
if (dataset.roll) {
|
|
||||||
let label = dataset.label ? `[Attribut] ${dataset.label}` : '';
|
|
||||||
let roll = new Roll(dataset.roll, this.actor.getRollData());
|
|
||||||
roll.toMessage({
|
|
||||||
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
|
|
||||||
flavor: label,
|
|
||||||
rollMode: game.settings.get('core', 'rollMode'),
|
|
||||||
});
|
|
||||||
return roll;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
activateListeners(html) {
|
activateListeners(html) {
|
||||||
super.activateListeners(html);
|
super.activateListeners(html);
|
||||||
|
|
||||||
html.on('click', '.attribut.rollable', (evt) => {
|
|
||||||
console.log(evt);
|
|
||||||
this._onAttributeRoll(evt);
|
|
||||||
});
|
|
||||||
|
|
||||||
html.on('click', '.talent.rollable', (evt) => {
|
|
||||||
console.log(evt);
|
|
||||||
this._onTalentRoll(evt);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Everything below here is only needed if the sheet is editable
|
// Everything below here is only needed if the sheet is editable
|
||||||
if (!this.isEditable) return;
|
if (!this.isEditable) return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"_id": "o1nYjhmMP0Zzlcw6",
|
"_id": "o1nYjhmMP0Zzlcw6",
|
||||||
"_key": "!items!o1nYjhmMP0Zzlcw6",
|
"_key": "!items!o1nYjhmMP0Zzlcw6",
|
||||||
"type": "Skill",
|
"type": "Skill",
|
||||||
"name": "Sich Verstecken",
|
"name": "Sich verstecken",
|
||||||
"system": {
|
"system": {
|
||||||
"gruppe": "Körperlich",
|
"gruppe": "Körperlich",
|
||||||
"probe": [
|
"probe": [
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,6 @@
|
||||||
<img class="profile-img" src="{{actor.img}}" data-edit="img" title="{{actor.name}}" height="100" width="100"/>
|
<img class="profile-img" src="{{actor.img}}" data-edit="img" title="{{actor.name}}" height="100" width="100"/>
|
||||||
<div class="header-fields">
|
<div class="header-fields">
|
||||||
<h1 class="charname"><input name="name" type="text" value="{{actor.name}}" placeholder="Name"/></h1>
|
<h1 class="charname"><input name="name" type="text" value="{{actor.name}}" placeholder="Name"/></h1>
|
||||||
<div class="attribute">
|
|
||||||
{{#each attributes}}
|
|
||||||
<button class="attribut rollable" data-label="{{this.name}}" data-roll="1d20cs<=@{{this.eigenschaft}}">
|
|
||||||
<span class="attribut-wert">
|
|
||||||
{{this.wert}}
|
|
||||||
</span>
|
|
||||||
<span class="attribut-name">
|
|
||||||
{{this.name}}
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
{{/each}}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
|
@ -46,10 +34,9 @@
|
||||||
<div class="tab skills" data-group="primary" data-tab="skills">
|
<div class="tab skills" data-group="primary" data-tab="skills">
|
||||||
<ul>
|
<ul>
|
||||||
{{#each skills}}
|
{{#each skills}}
|
||||||
<li><div class="talent rollable" data-taw="{{this.taw}}" data-rollEigenschaft1="{{this.rollEigenschaft1}}" data-rollEigenschaft2="{{this.rollEigenschaft2}}" data-rollEigenschaft3="{{this.rollEigenschaft3}}">
|
<li><div>
|
||||||
<b>{{this.talentName}}</b>
|
<b>{{this.talentName}}</b>
|
||||||
{{this.probe}}
|
{{this.probe}}
|
||||||
TAW: {{this.taw}}
|
|
||||||
</div></li>
|
</div></li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue