Compare commits

...

2 Commits

10 changed files with 2094 additions and 48 deletions

8
.idea/.gitignore vendored 100644
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

1855
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,7 @@
"@foundryvtt/foundryvtt-cli": "^3.0.0",
"cb": "^0.1.1",
"del": "^8.0.1",
"fvtt-types": "npm:@league-of-foundry-developers/foundry-vtt-types@^13.346.0-beta.20250812191140",
"gulp": "^5.0.1",
"gulp-replace": "^1.1.4",
"gulp-sass": "^6.0.1",

View File

@ -1,6 +1,7 @@
import { PlayerCharacterDataModel } from "./module/character/character.mjs";
import { PlayerCharacterDataModel } from "./module/data/character.mjs";
import { SkillSheet } from "./module/sheets/skillSheet.mjs";
import { SpellSheet } from "./module/sheets/spellSheet.mjs";
import { CharacterSheet } from "./module/sheets/characterSheet.mjs";
import { SkillDataModel } from "./module/data/skill.mjs";
import { SpellDataModel } from "./module/data/spell.mjs";
import { Character } from "./module/documents/character.mjs";
@ -22,6 +23,12 @@ Hooks.once("init", () => {
console.log("DSA 4.1 is ready for development!")
Actors.registerSheet('dsa41.character', CharacterSheet, {
types: ["character"],
makeDefault: true,
label: 'DSA41.CharacterLabels.Item'
})
// Register sheet application classes
Items.registerSheet('dsa41.skill', SkillSheet, {
types: ["Skill"],

View File

@ -1,8 +1,8 @@
import { Skill } from "./Items/skill.mjs";
import { Spell } from "./Items/spell.mjs";
import {SkillDataModel} from "./skill.mjs";
import {SpellDataModel} from "./spell.mjs";
const {
SchemaField, NumberField, StringField, ArrayField, BooleanField, EmbeddedCollectionField,
SchemaField, NumberField, StringField, ArrayField, BooleanField, ForeignDocumentField
} = foundry.data.fields;
export class PlayerCharacterDataModel extends foundry.abstract.TypeDataModel {
@ -43,17 +43,13 @@ export class PlayerCharacterDataModel extends foundry.abstract.TypeDataModel {
so: new NumberField({ required: true, integer: true }),
gilde: new StringField(),
}),
talente: new EmbeddedCollectionField( { model: Skill }),
zauber: new EmbeddedCollectionField( { model: Spell }),
liturgien: new ArrayField(new SchemaField({
name: new StringField(),
})),
kampfwerte: new ArrayField(new SchemaField({
name: new StringField(),
at: new NumberField({ required: true, integer: true }),
pa: new NumberField({ required: true, integer: true }),
})),
talente: new ArrayField ( new ForeignDocumentField(Item) ),
zauber: new ArrayField ( new ForeignDocumentField(Item) ),
}
}
_initialize(options) {
super._initialize(options);
}
}

View File

@ -1,9 +1,27 @@
export class Character extends Item {
export class Character extends Actor {
/**
* 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;
}
}

View File

@ -0,0 +1,127 @@
export class CharacterSheet extends ActorSheet {
/**@override */
static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ['dsa41', 'sheet', 'actor', 'character'],
width: 520,
height: 480,
tabs: [
{
navSelector: '.sheet-tabs',
contentSelector: '.sheet-body',
initial: 'description',
},
],
});
}
/** @override */
get template() {
return `systems/DSA_4-1/templates/actor/actor-character-sheet.hbs`;
}
/** @override */
getData() {
// Retrieve the data structure from the base sheet. You can inspect or log
// the context variable to see the structure, but some key properties for
// sheets are the actor object, the data object, whether or not it's
// editable, the items array, and the effects array.
const context = super.getData();
// Use a safe clone of the actor data for further operations.
const actorData = context.data;
// Add the actor's data to context.data for easier access, as well as flags.
context.system = actorData.system;
context.flags = actorData.flags;
context.attributs = [
{
attribut: "mu",
name: "Mut",
wert: actorData.system.attribute.mu ?? 0,
},
{
attribut: "kl",
name: "Klugheit",
wert: actorData.system.attribute.kl ?? 0,
},
{
attribut: "in",
name: "Intuition",
wert: actorData.system.attribute.in ?? 0,
},
{
attribut: "ch",
name: "Charisma",
wert: actorData.system.attribute.ch ?? 0,
},
{
attribut: "ff",
name: "Fingerfertigkeit",
wert: actorData.system.attribute.ff ?? 0,
},
{
attribut: "ge",
name: "Geschicklichkeit",
wert: actorData.system.attribute.ge ?? 0,
},
{
attribut: "ko",
name: "Konstitution",
wert: actorData.system.attribute.ko ?? 0,
},
{
attribut: "kk",
name: "Körperkraft",
wert: actorData.system.attribute.kk ?? 0,
},
];
context.skills = [];
if ( context.system.talente?.length >= 0) {
context.system.talente.forEach(talent => {
const tempTalent = talent();
console.log(tempTalent.system.probe);
context.skills.push({
talentName: tempTalent.name,
probe: `ROLLDATA(${Object.values(tempTalent.system.probe).join("/")})`
});
})
}
console.log(context);
return context;
}
_onRoll(event) {
event.preventDefault();
const dataset = event.currentTarget.dataset;
console.log(dataset)
if (dataset.roll) {
let label = dataset.label ? `[Attribut] ${dataset.label}` : '';
console.log(this.actor.getRollData());
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) {
super.activateListeners(html);
html.on('click', '.attribut.rollable', (evt) => {
console.log(evt);
this._onRoll(evt);
});
// Everything below here is only needed if the sheet is editable
if (!this.isEditable) return;
}
}

View File

@ -73,7 +73,21 @@
],
"documentTypes": {
"Actor": {
"character": {}
"character": {
"numberFields": [
"groesse", "alter", "gewicht"
],
"stringFields": [
"name"
],
"schemaFields": [
"attribute", "meta"
],
"arrayFields": [
"talente",
"zauber"
]
}
},
"Item": {
"Skill": {

View File

@ -0,0 +1,57 @@
<form class="{{cssClass}} {{actor.type}} flexcol" autocomplete="off">
{{!-- Sheet Header --}}
<header class="sheet-header">
{{!-- Header stuff goes here --}}
<img class="profile-img" src="{{actor.img}}" data-edit="img" title="{{actor.name}}" height="100" width="100"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{actor.name}}" placeholder="Name"/></h1>
<div class="attribute">
{{#each attributs}}
<button class="attribut rollable" data-label="{{this.name}}" data-roll="1d20cs<=@{{this.attribut}}">
<span class="attribut-wert">
{{this.wert}}
</span>
<span class="attribut-name">
{{this.name}}
</span>
</button>
{{/each}}
</div>
</div>
</header>
{{!-- Sheet Tab Navigation --}}
<nav class="sheet-tabs tabs" data-group="primary">
<a class="item" data-tab="overview">Übersicht</a>
<a class="item" data-tab="skills">Talente</a>
</nav>
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="tab description" data-group="primary" data-tab="description">
<div><label>Spezies
<input type="text" name="system.meta.spezies.value" value="{{system.meta.spezies}}"/>
</label>
</div>
<div><label>Kultur<input type="text" name="system.meta.kultur.value" value="{{system.meta.kultur}}"/></label>
</div>
<div><label>Profession<input type="text" name="system.meta.profession.value"
value="{{system.meta.profession}}"/></label>
</div>
<div><label>Geschlecht<input type="text" name="system.meta.geschlecht.value"
value="{{system.meta.geschlecht}}"/></label>
</div>
</div>
<div class="tab skills" data-group="primary" data-tab="skills">
<ul>
{{#each skills}}
<li><div class="talent rollable" data-roll="1d20cs<=@{{this.p1}}">
<b>{{this.talentName}}</b>
{{this.probe}}
</div></li>
{{/each}}
</ul>
</div>
</section>
</form>

View File

@ -1,27 +0,0 @@
<form class="{{cssClass}} {{actor.type}} flexcol" autocomplete="off">
{{!-- Sheet Header --}}
<header class="sheet-header">
{{!-- Header stuff goes here --}}
<img class="profile-img" src="{{actor.img}}" data-edit="img" title="{{actor.name}}" height="100" width="100"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{actor.name}}" placeholder="Name"/></h1>
</div>
</header>
{{!-- Sheet Tab Navigation --}}
<nav class="sheet-tabs tabs" data-group="primary">
<a class="item" data-tab="overview">Übersicht</a>
<a class="item" data-tab="skills">Talente</a>
</nav>
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="tab description" data-group="primary" data-tab="description">
<input type="text" name="system.meta.spezies.value" value="{{system.meta.spezies.value}}" />
<input type="text" name="system.meta.kultur.value" value="{{system.meta.kultur.value}}" />
<input type="text" name="system.meta.profession.value" value="{{system.meta.profession.value}}" />
<input type="text" name="system.meta.geschlecht.value" value="{{system.meta.geschlecht.value}}" />
</div>
</section>
</form>