a new begining
This commit is contained in:
1 parent
9568be0211
commit
24c81dbcf8
38 files changed
+1313
-424
No files matched your search
@@ -0,0 +1,128 @@
|
||||
.application.sheet.M6 {
|
||||
background-color: #d3d7d7;
|
||||
color: #595d5f;
|
||||
|
||||
section {
|
||||
.sheet-header {
|
||||
margin-top: 8px;
|
||||
img {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
left: 44%;
|
||||
background-color: #d3d7d7;
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
input {
|
||||
margin-bottom: 4px;
|
||||
&:focus {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
input {
|
||||
background-color: #fdfeff;
|
||||
color: black;
|
||||
border-radius: 0;
|
||||
&.skill {
|
||||
max-width: 2rem;
|
||||
text-align: center;
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
&.attribut {
|
||||
max-width: 2rem;
|
||||
text-align: center;
|
||||
margin: 0 0.5rem;
|
||||
}
|
||||
&.text {
|
||||
&.right {
|
||||
text-align: end;
|
||||
}
|
||||
}
|
||||
}
|
||||
p {
|
||||
&.center {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
fieldset {
|
||||
background-color: #eedecd;
|
||||
}
|
||||
|
||||
.sheet-header {
|
||||
img {
|
||||
border-radius: 0 0 50% 50%;
|
||||
border: solid 16px #d3d7d7;
|
||||
border-top: none;
|
||||
flex: 0 0 100px;
|
||||
object-fit: fill;
|
||||
}
|
||||
}
|
||||
.tab {
|
||||
height: 100%;
|
||||
padding-top: 10px;
|
||||
}
|
||||
.tab[data-tab="items"] {
|
||||
ul {
|
||||
list-style: none;
|
||||
padding-left: 5px;
|
||||
}
|
||||
.itemHeader {
|
||||
border-bottom: 1px solid var(--color-border-light-primary);
|
||||
.type-label {
|
||||
font-size: 20px;
|
||||
}
|
||||
.document-controls {
|
||||
flex: 0 0 100px;
|
||||
}
|
||||
}
|
||||
.item {
|
||||
img {
|
||||
border: none;
|
||||
flex: 0 0 30px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
.document-controls {
|
||||
flex: 0 0 50px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.tab[data-tab="effects"] {
|
||||
ul {
|
||||
list-style: none;
|
||||
padding-left: 5px;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.effects-header {
|
||||
font-size: 16px;
|
||||
border-bottom: 1px solid var(--color-border-light-primary);
|
||||
.document-controls {
|
||||
flex: 0 0 100px;
|
||||
}
|
||||
}
|
||||
.effect {
|
||||
.effect-label {
|
||||
img {
|
||||
border: none;
|
||||
flex: 0 0 30px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
.effect-name {
|
||||
line-height: 24px;
|
||||
}
|
||||
}
|
||||
.effect-duration {
|
||||
flex: 0 0 130px;
|
||||
}
|
||||
.document-controls {
|
||||
flex: 0 0 80px;
|
||||
}
|
||||
}
|
||||
.effect-label {
|
||||
flex: 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
# fvtt-ts-react-boilerplate
|
||||
# midgard6-lvd
|
||||
|
||||
A TypeScript + React + Vite boilerplate for building Foundry VTT (V14) game systems on top of **ApplicationV2**, with full type safety via [`fvtt-types`](https://github.com/League-of-Foundry-Developers/foundry-vtt-types).
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"Midgard6": {
|
||||
"Biography": {
|
||||
"name": "Name",
|
||||
"spezies": "Spezies",
|
||||
"kultur": "Kultur",
|
||||
"abenteuertyp": "Abenteuertyp",
|
||||
"glaube": "Glaube",
|
||||
"mondgestalt": "Mondgestalt"
|
||||
},
|
||||
"Skills": {
|
||||
"gruppen": {
|
||||
"kampf": "Kampf",
|
||||
"geist": "Geist",
|
||||
"körper": "Körper",
|
||||
"ausdruck": "Ausdruck",
|
||||
"magie": "Magie"
|
||||
},
|
||||
"athletik": "Athletik",
|
||||
"anführen": "Anführen",
|
||||
"beweglichkeit": "Beweglichkeit",
|
||||
"bildung": "Bildung",
|
||||
"darbietung": "Darbietung",
|
||||
"einschüchterung": "Einschüchterung",
|
||||
"empathie": "Empathie",
|
||||
"fernkampf": "Fernkampf",
|
||||
"fingerfertigkeit": "Fingerfertigkeit",
|
||||
"gassenwissen": "Gassenwissen",
|
||||
"handwerk": "Handwerk",
|
||||
"heilkunst": "Heilkunst",
|
||||
"heimlichkeit": "Heimlichkeit",
|
||||
"kulturwissen": "Kulturwissen",
|
||||
"nahkampf": "Nahkampf",
|
||||
"manipulation": "Manipulation",
|
||||
"thaumaturgie": "Thaumaturgie",
|
||||
"tierführung": "Tierführung",
|
||||
"überlebenskunst": "Überlebenskunst",
|
||||
"überzeugen": "Überzeugen",
|
||||
"wahrnehmung": "Wahrnehmung",
|
||||
"zaubern": "Zaubern",
|
||||
"zauberwissen": "Zauberwissen"
|
||||
},
|
||||
"Sheets": {
|
||||
"Tabs": {
|
||||
"properties": "Fertigkeiten",
|
||||
"items": "Gegenstände",
|
||||
"effects": "Effekte"
|
||||
}
|
||||
},
|
||||
"Item": {
|
||||
"Quantity": "Anzahl",
|
||||
"Description": "Beschreibung"
|
||||
}
|
||||
},
|
||||
"TYPES": {
|
||||
"Actor": {
|
||||
"character": "Charakter"
|
||||
},
|
||||
"Item": {
|
||||
"item": "Gegenstand"
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"BOILERPLATE": {
|
||||
"Midgard6": {
|
||||
"Attributes": {
|
||||
"strength": "Strength",
|
||||
"agility": "Agility",
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"BOILERPLATE": {
|
||||
"Attributes": {
|
||||
"strength": "Force",
|
||||
"agility": "Agilité",
|
||||
"spirit": "Esprit"
|
||||
},
|
||||
"Sheet": {
|
||||
"Biography": "Biographie",
|
||||
"Total": "Total",
|
||||
"TotalMod": "Modificateur total",
|
||||
"ChatPlaceholder": "Dites quelque chose...",
|
||||
"SendToChat": "Envoyer dans le chat"
|
||||
},
|
||||
"Item": {
|
||||
"Quantity": "Quantité",
|
||||
"Description": "Description"
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+8
-44
@@ -1,16 +1,12 @@
|
||||
{
|
||||
"name": "fvtt-ts-react-boilerplate",
|
||||
"name": "midgard6-lvd",
|
||||
"version": "0.8.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "fvtt-ts-react-boilerplate",
|
||||
"name": "midgard6-lvd",
|
||||
"version": "0.8.2",
|
||||
"dependencies": {
|
||||
"react": "^18.3.0",
|
||||
"react-dom": "^18.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.4",
|
||||
"@types/react": "^18.3.0",
|
||||
@@ -19,7 +15,7 @@
|
||||
"eslint": "^9.39.4",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"fvtt-types": "^13.346.0-beta.20251209192131",
|
||||
"fvtt-types": "^13.346.0-beta.20250812191140",
|
||||
"globals": "^17.7.0",
|
||||
"prettier": "^3.8.4",
|
||||
"sass": "^1.101.0",
|
||||
@@ -4994,9 +4990,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/fvtt-types": {
|
||||
"version": "13.346.0-beta.20251209192131",
|
||||
"resolved": "https://registry.npmjs.org/fvtt-types/-/fvtt-types-13.346.0-beta.20251209192131.tgz",
|
||||
"integrity": "sha512-4HhASmSpoibRAo1eeEtkZCSqy68yGFuT6Mkh2nNjM35cot43yo5JBB64owGQ9PK30hY8Ko1OucdjSDf87zdYRg==",
|
||||
"version": "13.346.0-beta.20250812191140",
|
||||
"resolved": "https://registry.npmjs.org/fvtt-types/-/fvtt-types-13.346.0-beta.20250812191140.tgz",
|
||||
"integrity": "sha512-Xa+89ZzxvaGrY507LWb0DY3s6HIOak7pXZGjRuxT+6rLRjluQduiylqAOm4ZTQCRfh7+HdbrUsmrZOKoE/xadQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -5922,6 +5918,7 @@
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/js-yaml": {
|
||||
@@ -6332,6 +6329,7 @@
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
|
||||
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"js-tokens": "^3.0.0 || ^4.0.0"
|
||||
@@ -7136,31 +7134,6 @@
|
||||
"safe-buffer": "^5.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react": {
|
||||
"version": "18.3.1",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",
|
||||
"integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"loose-envify": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-dom": {
|
||||
"version": "18.3.1",
|
||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz",
|
||||
"integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"loose-envify": "^1.1.0",
|
||||
"scheduler": "^0.23.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^18.3.1"
|
||||
}
|
||||
},
|
||||
"node_modules/react-is": {
|
||||
"version": "16.13.1",
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
|
||||
@@ -7491,15 +7464,6 @@
|
||||
"@parcel/watcher": "^2.4.1"
|
||||
}
|
||||
},
|
||||
"node_modules/scheduler": {
|
||||
"version": "0.23.2",
|
||||
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz",
|
||||
"integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"loose-envify": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/semver": {
|
||||
"version": "6.3.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
||||
|
||||
+2
-6
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "fvtt-ts-react-boilerplate",
|
||||
"name": "midgard6-lvd",
|
||||
"version": "0.8.2",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
@@ -21,7 +21,7 @@
|
||||
"eslint": "^9.39.4",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"fvtt-types": "^13.346.0-beta.20251209192131",
|
||||
"fvtt-types": "^13.346.0-beta.20250812191140",
|
||||
"globals": "^17.7.0",
|
||||
"prettier": "^3.8.4",
|
||||
"sass": "^1.101.0",
|
||||
@@ -29,9 +29,5 @@
|
||||
"typescript-eslint": "^8.62.0",
|
||||
"vite": "^5.4.0",
|
||||
"vitest": "^4.1.9"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^18.3.0",
|
||||
"react-dom": "^18.3.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
export const systemID = "midgard6-lvd";
|
||||
|
||||
/**
|
||||
* Translates repository paths to Foundry Data paths.
|
||||
* @param {string} path - A path relative to the root of this repository.
|
||||
* @returns {string} The path relative to the Foundry data folder.
|
||||
*/
|
||||
export const systemPath = (path) => `systems/${systemID}/src/${path}`;
|
||||
@@ -0,0 +1,228 @@
|
||||
function defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
biography: new fields.SchemaField({
|
||||
mondgestalt: new fields.StringField({ initial: "" }),
|
||||
abenteuertyp: new fields.StringField({ initial: "" }),
|
||||
glaube: new fields.StringField({ initial: "" }),
|
||||
spezies: new fields.StringField({ initial: "" }),
|
||||
kultur: new fields.StringField({ initial: "" })
|
||||
}),
|
||||
resources: new fields.SchemaField({
|
||||
leben: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
min: 0,
|
||||
initial: 4
|
||||
}),
|
||||
max: new fields.NumberField({
|
||||
required: true,
|
||||
initial: 8
|
||||
})
|
||||
}),
|
||||
ausdauer: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
min: 0,
|
||||
initial: 4
|
||||
}),
|
||||
max: new fields.NumberField({
|
||||
required: true,
|
||||
initial: 44
|
||||
})
|
||||
})
|
||||
}),
|
||||
skills: new fields.SchemaField({
|
||||
kampf: new fields.SchemaField(
|
||||
{
|
||||
anführen: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
fernkampf: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
nahkampf: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
})
|
||||
},
|
||||
{ label: "kampf" }
|
||||
),
|
||||
körper: new fields.SchemaField(
|
||||
{
|
||||
athletik: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
beweglichkeit: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
fingerfertigkeit: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
heimlichkeit: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
wahrnehmung: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
})
|
||||
},
|
||||
{ label: "körper" }
|
||||
),
|
||||
ausdruck: new fields.SchemaField(
|
||||
{
|
||||
darbietung: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
einschüchterung: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
empathie: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
gassenwissen: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
manipulation: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
überzeugen: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
})
|
||||
},
|
||||
{ label: "ausdruck" }
|
||||
),
|
||||
geist: new fields.SchemaField(
|
||||
{
|
||||
bildung: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
handwerk: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
heilkunst: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
kulturwissen: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
tierführung: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
überlebenskunst: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
})
|
||||
},
|
||||
{ label: "geist" }
|
||||
),
|
||||
magie: new fields.SchemaField(
|
||||
{
|
||||
thaumaturgie: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
zaubern: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
}),
|
||||
zauberwissen: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5
|
||||
})
|
||||
},
|
||||
{ label: "magie" }
|
||||
)
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
export class CharacterData extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema = defineSchema;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
function defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
biography: new fields.HTMLField({ initial: "" }),
|
||||
attributes: new fields.SchemaField({
|
||||
strength: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
integer: true,
|
||||
initial: 10
|
||||
}),
|
||||
agility: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
integer: true,
|
||||
initial: 10
|
||||
}),
|
||||
spirit: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
integer: true,
|
||||
initial: 10
|
||||
})
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
export class CharacterData extends foundry.abstract.TypeDataModel<
|
||||
ReturnType<typeof defineSchema>,
|
||||
Actor.Implementation
|
||||
> {
|
||||
static defineSchema = defineSchema;
|
||||
}
|
||||
@@ -12,9 +12,6 @@ function defineSchema() {
|
||||
};
|
||||
}
|
||||
|
||||
export class ItemData extends foundry.abstract.TypeDataModel<
|
||||
ReturnType<typeof defineSchema>,
|
||||
Item.Implementation
|
||||
> {
|
||||
export class ItemData extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema = defineSchema;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Searches through an object recursively and localizes strings.
|
||||
* @param {Record<string, unknown>} object
|
||||
*/
|
||||
export function localizeHelper(object) {
|
||||
for (const [key, value] of Object.entries(object)) {
|
||||
// const type = foundry.utils.getType(value)
|
||||
switch (typeof value) {
|
||||
case "object":
|
||||
if (value) localizeHelper(value);
|
||||
break;
|
||||
case "string":
|
||||
if (key === "label") object[key] = game.i18n.localize(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Prepare the data structure for Active Effects which are currently embedded in an Actor or Item.
|
||||
* @param {ActiveEffect[]} effects A collection or generator of Active Effect documents to prepare sheet data for.
|
||||
* @return {object} Data for rendering.
|
||||
*/
|
||||
export function prepareActiveEffectCategories(effects) {
|
||||
const categories = {
|
||||
temporary: {
|
||||
type: "temporary",
|
||||
label: game.i18n.localize("M6.Effect.Temporary"),
|
||||
effects: []
|
||||
},
|
||||
passive: {
|
||||
type: "passive",
|
||||
label: game.i18n.localize("M6.Effect.Passive"),
|
||||
effects: []
|
||||
},
|
||||
inactive: {
|
||||
type: "inactive",
|
||||
label: game.i18n.localize("M6.Effect.Inactive"),
|
||||
effects: []
|
||||
}
|
||||
};
|
||||
|
||||
// Iterate over active effects, classifying them into categories
|
||||
for (const e of effects) {
|
||||
if (!e.active) categories.inactive.effects.push(e);
|
||||
else if (e.isTemporary) categories.temporary.effects.push(e);
|
||||
else categories.passive.effects.push(e);
|
||||
}
|
||||
|
||||
// Sort each category
|
||||
for (const c of Object.values(categories)) {
|
||||
c.effects.sort((a, b) => (a.sort || 0) - (b.sort || 0));
|
||||
}
|
||||
return categories;
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,378 @@
|
||||
import { systemPath } from "../constants.mjs";
|
||||
import { prepareActiveEffectCategories } from "../helpers/utils.mjs";
|
||||
|
||||
const { api, sheets } = foundry.applications;
|
||||
|
||||
/**
|
||||
* Extend the basic ActorSheet with some very simple modifications.
|
||||
*/
|
||||
export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorSheetV2) {
|
||||
/** @inheritdoc */
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["M6", "actor"],
|
||||
window: {
|
||||
icon: "fa-solid fa-dice-d10",
|
||||
resizable: true
|
||||
},
|
||||
position: {
|
||||
width: 800,
|
||||
height: 800
|
||||
},
|
||||
actions: {
|
||||
viewDoc: this.#viewDoc,
|
||||
createDoc: this.#createDoc,
|
||||
deleteDoc: this.#deleteDoc,
|
||||
toggleEffect: this.#toggleEffect,
|
||||
rollSkill: this.#rollSkill
|
||||
},
|
||||
form: {
|
||||
submitOnChange: true
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
static TABS = {
|
||||
primary: {
|
||||
tabs: [
|
||||
{
|
||||
id: "properties"
|
||||
},
|
||||
{
|
||||
id: "items"
|
||||
},
|
||||
{
|
||||
id: "effects"
|
||||
}
|
||||
],
|
||||
initial: "properties",
|
||||
labelPrefix: "Midgard6.Sheets.Tabs"
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/** @inheritdoc */
|
||||
static PARTS = {
|
||||
header: {
|
||||
template: systemPath("templates/actor/header.hbs")
|
||||
},
|
||||
stats: {
|
||||
template: systemPath("templates/actor/stats.hbs")
|
||||
},
|
||||
tabs: {
|
||||
template: "templates/generic/tab-navigation.hbs"
|
||||
},
|
||||
properties: {
|
||||
template: systemPath("templates/shared/properties.hbs"),
|
||||
scrollable: [""]
|
||||
},
|
||||
items: {
|
||||
template: systemPath("templates/actor/items.hbs"),
|
||||
scrollable: [""]
|
||||
},
|
||||
effects: {
|
||||
template: systemPath("templates/shared/effects.hbs"),
|
||||
scrollable: [""]
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/** @inheritdoc */
|
||||
_initializeApplicationOptions(options) {
|
||||
const initialized = super._initializeApplicationOptions(options);
|
||||
|
||||
initialized.classes.push(initialized.document.type);
|
||||
|
||||
return initialized;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/** @inheritdoc */
|
||||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
|
||||
Object.assign(context, {
|
||||
owner: this.document.isOwner,
|
||||
limited: this.document.limited,
|
||||
actor: this.actor,
|
||||
system: this.actor.system,
|
||||
skills: this.actor.system.skills,
|
||||
flags: this.actor.flags,
|
||||
config: CONFIG
|
||||
});
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/** @inheritdoc */
|
||||
async _preparePartContext(partId, context) {
|
||||
switch (partId) {
|
||||
case "effects":
|
||||
context.effects = prepareActiveEffectCategories(this.actor.allApplicableEffects());
|
||||
context.tab = context.tabs[partId];
|
||||
break;
|
||||
case "properties":
|
||||
context.fields = await this._getSkills();
|
||||
context.tab = context.tabs[partId];
|
||||
break;
|
||||
case "items":
|
||||
context.itemTypes = this._getItems();
|
||||
context.tab = context.tabs[partId];
|
||||
break;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the system fields for the form-fields generic.
|
||||
* @returns {object[]}
|
||||
*/
|
||||
async _getFields() {
|
||||
const doc = this.actor;
|
||||
const source = doc._source;
|
||||
const systemFields = CONFIG.Actor.dataModels[doc.type]?.schema.fields;
|
||||
const fieldSets = [];
|
||||
// TODO: Find a clever way to handle enrichment
|
||||
for (const field of Object.values(systemFields ?? {})) {
|
||||
const path = `system.${field.name}`;
|
||||
if (field instanceof foundry.data.fields.SchemaField) {
|
||||
const fieldset = { fieldset: true, legend: field.label, fields: [] };
|
||||
await this.#addSystemFields(fieldset, field.fields, source, path);
|
||||
fieldSets.push(fieldset);
|
||||
} else {
|
||||
fieldSets.push({ outer: { field, value: foundry.utils.getProperty(source, path) } });
|
||||
}
|
||||
}
|
||||
return fieldSets;
|
||||
}
|
||||
|
||||
async _getSkills() {
|
||||
const doc = this.actor;
|
||||
const source = doc._source;
|
||||
const systemFields = CONFIG.Actor.dataModels[doc.type]?.schema.fields.skills.fields;
|
||||
const fieldSets = [];
|
||||
// TODO: Find a clever way to handle enrichment
|
||||
for (const field of Object.values(systemFields ?? {})) {
|
||||
const path = `system.skills.${field.name}`;
|
||||
if (field instanceof foundry.data.fields.SchemaField) {
|
||||
const fieldset = {
|
||||
fieldset: true,
|
||||
legend: `Midgard6.Skills.gruppen.${field.label}`,
|
||||
fields: []
|
||||
};
|
||||
await this.#addSystemFields(fieldset, field.fields, source, path);
|
||||
fieldSets.push(fieldset);
|
||||
} else {
|
||||
fieldSets.push({ outer: { field, value: foundry.utils.getProperty(source, path) } });
|
||||
}
|
||||
}
|
||||
return fieldSets;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Recursively add system model fields to the fieldset.
|
||||
*/
|
||||
async #addSystemFields(fieldset, schema, source, _path = "system") {
|
||||
for (const field of Object.values(schema)) {
|
||||
const path = `${_path}.${field.name}`;
|
||||
if (field instanceof foundry.data.fields.SchemaField) {
|
||||
this.#addSystemFields(fieldset, field.fields, source, path);
|
||||
} else if (field.constructor.hasFormSupport) {
|
||||
fieldset.fields.push({
|
||||
field,
|
||||
value: foundry.utils.getProperty(source, path),
|
||||
localizationName: "Midgard6.Skills." + field.name
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Adapted from Actor#itemTypes.
|
||||
*/
|
||||
_getItems() {
|
||||
const types = Object.fromEntries(
|
||||
game.documentTypes.Item.map((t) => {
|
||||
return [t, { label: game.i18n.localize(CONFIG.Item.typeLabels[t]), items: [] }];
|
||||
})
|
||||
);
|
||||
for (const item of this.actor.items) {
|
||||
types[item.type].items.push(item);
|
||||
}
|
||||
// Only show Base if it's actually being used
|
||||
if (types.base.items.length === 0) delete types.base;
|
||||
return types;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Actions performed after any render of the Application.
|
||||
* Post-render steps are not awaited by the render process.
|
||||
* @param {ApplicationRenderContext} context Prepared context data.
|
||||
* @param {RenderOptions} options Provided render options.
|
||||
* @protected
|
||||
* @inheritdoc
|
||||
*/
|
||||
async _onRender(context, options) {
|
||||
await super._onRender(context, options);
|
||||
this.#disableOverrides();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
/* Event handlers */
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Renders an embedded document's sheet.
|
||||
*
|
||||
* @this M6ActorSheet
|
||||
* @param {PointerEvent} event The originating click event.
|
||||
* @param {HTMLElement} target The capturing HTML element which defined a [data-action].
|
||||
* @protected
|
||||
*/
|
||||
static async #viewDoc(event, target) {
|
||||
const doc = this._getEmbeddedDocument(target);
|
||||
doc.sheet.render(true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Handles item deletion.
|
||||
*
|
||||
* @this M6ActorSheet
|
||||
* @param {PointerEvent} event The originating click event.
|
||||
* @param {HTMLElement} target The capturing HTML element which defined a [data-action].
|
||||
* @protected
|
||||
*/
|
||||
static async #deleteDoc(event, target) {
|
||||
const doc = this._getEmbeddedDocument(target);
|
||||
doc.delete();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Handle creating a new Owned Item or ActiveEffect for the actor using initial data defined in the HTML dataset.
|
||||
*
|
||||
* @this M6ActorSheet
|
||||
* @param {PointerEvent} event The originating click event.
|
||||
* @param {HTMLElement} target The capturing HTML element which defined a [data-action].
|
||||
* @private
|
||||
*/
|
||||
static async #createDoc(event, target) {
|
||||
const docCls = getDocumentClass(target.dataset.documentClass);
|
||||
const docData = {
|
||||
name: docCls.defaultName({
|
||||
type: target.dataset.type,
|
||||
parent: this.actor
|
||||
})
|
||||
};
|
||||
for (const [dataKey, value] of Object.entries(target.dataset)) {
|
||||
if (["action", "documentClass"].includes(dataKey)) continue;
|
||||
foundry.utils.setProperty(docData, dataKey, value);
|
||||
}
|
||||
docCls.create(docData, { parent: this.actor });
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Determines effect parent to pass to helper.
|
||||
*
|
||||
* @this M6ActorSheet
|
||||
* @param {PointerEvent} event The originating click event.
|
||||
* @param {HTMLElement} target The capturing HTML element which defined a [data-action].
|
||||
* @private
|
||||
*/
|
||||
static async #toggleEffect(event, target) {
|
||||
const effect = this._getEmbeddedDocument(target);
|
||||
effect.update({ disabled: !effect.disabled });
|
||||
}
|
||||
|
||||
static async #rollSkill(event, target) {
|
||||
console.warn(event, target.dataset);
|
||||
// Construct the Roll instance
|
||||
const skillValue = target.dataset.value;
|
||||
let roll = new Roll("2d20kh + @skill", { skill: skillValue }, { flavor: target.dataset.name });
|
||||
|
||||
// The parsed terms of the roll formula
|
||||
console.log("Roll:", roll); // [Die, OperatorTerm, NumericTerm, OperatorTerm, NumericTerm]
|
||||
|
||||
// Execute the roll
|
||||
await roll.evaluate();
|
||||
|
||||
roll.toMessage();
|
||||
|
||||
roll.toAnchor();
|
||||
// let message = new Message(roll);
|
||||
// console.warn(message);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
/* Helper functions */
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Fetches the embedded document representing the containing HTML element.
|
||||
*
|
||||
* @param {HTMLElement} target The element subject to search.
|
||||
* @returns {Item|ActiveEffect} The embedded Item or ActiveEffect.
|
||||
*/
|
||||
_getEmbeddedDocument(target) {
|
||||
const docRow = target.closest("li[data-document-class]");
|
||||
if (docRow.dataset.documentClass === "Item") {
|
||||
return this.actor.items.get(docRow.dataset.itemId);
|
||||
} else if (docRow.dataset.documentClass === "ActiveEffect") {
|
||||
const parent =
|
||||
docRow.dataset.parentId === this.actor.id
|
||||
? this.actor
|
||||
: this.actor.items.get(docRow?.dataset.parentId);
|
||||
return parent.effects.get(docRow.dataset.effectId);
|
||||
} else {
|
||||
console.warn("Could not find document class");
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
/* Actor override handling */
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Submit a document update based on the processed form data.
|
||||
* @param {SubmitEvent} event The originating form submission event.
|
||||
* @param {HTMLFormElement} form The form element that was submitted.
|
||||
* @param {object} submitData Processed and validated form data to be used for a document update.
|
||||
* @returns {Promise<void>}
|
||||
* @protected
|
||||
* @inheritdoc
|
||||
*/
|
||||
async _processSubmitData(event, form, submitData) {
|
||||
const overrides = foundry.utils.flattenObject(this.actor.overrides);
|
||||
for (const k of Object.keys(overrides)) delete submitData[k];
|
||||
this.document.update(submitData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Disables inpM6 subject to active effects.
|
||||
*/
|
||||
#disableOverrides() {
|
||||
const flatOverrides = foundry.utils.flattenObject(this.actor.overrides);
|
||||
for (const override of Object.keys(flatOverrides)) {
|
||||
const input = this.element.querySelector(`[name="${override}"]`);
|
||||
if (input) input.disabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import React from "react";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import { CharacterSheetApp } from "./components/CharacterSheetApp";
|
||||
|
||||
export class CharacterSheet extends foundry.applications.sheets.ActorSheetV2 {
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["fvtt-ts-react-boilerplate", "sheet", "actor"],
|
||||
position: { width: 600, height: 480 }
|
||||
};
|
||||
|
||||
#root: Root | null = null;
|
||||
|
||||
override async _renderHTML(
|
||||
...args: Parameters<foundry.applications.sheets.ActorSheetV2["_renderHTML"]>
|
||||
) {
|
||||
return args[0];
|
||||
}
|
||||
|
||||
override _replaceHTML(
|
||||
...args: Parameters<foundry.applications.sheets.ActorSheetV2["_replaceHTML"]>
|
||||
) {
|
||||
const content = args[1];
|
||||
if (!this.#root) this.#root = createRoot(content);
|
||||
this.#root.render(React.createElement(CharacterSheetApp, { actor: this.document }));
|
||||
}
|
||||
|
||||
override async close(...args: Parameters<foundry.applications.sheets.ActorSheetV2["close"]>) {
|
||||
this.#root?.unmount();
|
||||
this.#root = null;
|
||||
return super.close(...args);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { fmtMod, modifier } from "./CharacterSheetApp.logic";
|
||||
|
||||
describe("modifier", () => {
|
||||
it("matches the d20-style table around the 10 baseline", () => {
|
||||
expect(modifier(10)).toBe(0);
|
||||
expect(modifier(11)).toBe(0);
|
||||
expect(modifier(12)).toBe(1);
|
||||
expect(modifier(9)).toBe(-1);
|
||||
expect(modifier(20)).toBe(5);
|
||||
});
|
||||
});
|
||||
|
||||
describe("fmtMod", () => {
|
||||
it("prefixes non-negative values with +", () => {
|
||||
expect(fmtMod(0)).toBe("+0");
|
||||
expect(fmtMod(3)).toBe("+3");
|
||||
});
|
||||
|
||||
it("leaves negative values as-is", () => {
|
||||
expect(fmtMod(-2)).toBe("-2");
|
||||
});
|
||||
});
|
||||
@@ -1,6 +0,0 @@
|
||||
// Pure game-logic helpers, deliberately kept free of any Foundry global.
|
||||
// Code that touches `actor`/`ChatMessage`/etc. needs a running Foundry instance
|
||||
// and isn't realistically unit-testable — this is the boundary to keep that out.
|
||||
export const modifier = (score: number) => Math.floor((score - 10) / 2);
|
||||
|
||||
export const fmtMod = (mod: number) => (mod >= 0 ? `+${mod}` : `${mod}`);
|
||||
@@ -1,38 +0,0 @@
|
||||
.sheet {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.attributes {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.attributeLabel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-size: 0.8rem;
|
||||
text-transform: capitalize;
|
||||
|
||||
.modifier {
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.totals {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.chatRow {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
import React, { useState } from "react";
|
||||
import styles from "./CharacterSheetApp.module.scss";
|
||||
import { localize } from "../../i18n";
|
||||
import { modifier, fmtMod } from "./CharacterSheetApp.logic";
|
||||
|
||||
export function CharacterSheetApp({ actor }: { actor: Actor.Implementation }) {
|
||||
const system = actor.system;
|
||||
const attrs = system.attributes;
|
||||
const [chatMessage, setChatMessage] = useState("");
|
||||
|
||||
const updateAttribute = (key: "strength" | "agility" | "spirit", value: number) => {
|
||||
actor.update({ system: { attributes: { [key]: value } } });
|
||||
};
|
||||
|
||||
const updateBiography = (value: string) => {
|
||||
actor.update({ system: { biography: value } });
|
||||
};
|
||||
|
||||
const sendChatMessage = () => {
|
||||
if (!chatMessage.trim()) return;
|
||||
ChatMessage.create({
|
||||
speaker: ChatMessage.getSpeaker({ actor }),
|
||||
content: chatMessage
|
||||
});
|
||||
setChatMessage("");
|
||||
};
|
||||
|
||||
// derived purely from current doc state — recomputed every render, no local state needed
|
||||
const total = attrs.strength + attrs.agility + attrs.spirit;
|
||||
const totalMod = modifier(attrs.strength) + modifier(attrs.agility) + modifier(attrs.spirit);
|
||||
|
||||
return (
|
||||
<div className={styles.sheet}>
|
||||
<h1>{actor.name}</h1>
|
||||
<div className={styles.attributes}>
|
||||
{(["strength", "agility", "spirit"] as const).map((key) => (
|
||||
<label className={styles.attributeLabel} key={key}>
|
||||
{localize(`BOILERPLATE.Attributes.${key}`)}
|
||||
<input
|
||||
type="number"
|
||||
value={attrs[key]}
|
||||
onChange={(e) => updateAttribute(key, Number(e.target.value))}
|
||||
/>
|
||||
<span className={styles.modifier}>{fmtMod(modifier(attrs[key]))}</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
<div className={styles.totals}>
|
||||
<span>
|
||||
{localize("BOILERPLATE.Sheet.Total")}: {total}
|
||||
</span>
|
||||
<span>
|
||||
{localize("BOILERPLATE.Sheet.TotalMod")}: {fmtMod(totalMod)}
|
||||
</span>
|
||||
</div>
|
||||
<label className={styles.attributeLabel}>
|
||||
{localize("BOILERPLATE.Sheet.Biography")}
|
||||
<textarea defaultValue={system.biography} onBlur={(e) => updateBiography(e.target.value)} />
|
||||
</label>
|
||||
|
||||
<div className={styles.chatRow}>
|
||||
<input
|
||||
type="text"
|
||||
placeholder={localize("BOILERPLATE.Sheet.ChatPlaceholder")}
|
||||
value={chatMessage}
|
||||
onChange={(e) => setChatMessage(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && sendChatMessage()}
|
||||
/>
|
||||
<button type="button" onClick={sendChatMessage}>
|
||||
{localize("BOILERPLATE.Sheet.SendToChat")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
.sheet {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-size: 0.8rem;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
import React from "react";
|
||||
import styles from "./ItemSheetApp.module.scss";
|
||||
import { localize } from "../../i18n";
|
||||
|
||||
export function ItemSheetApp({ item }: { item: Item.Implementation }) {
|
||||
const system = item.system;
|
||||
|
||||
const updateQuantity = (value: number) => {
|
||||
item.update({ system: { quantity: value } });
|
||||
};
|
||||
|
||||
const updateDescription = (value: string) => {
|
||||
item.update({ system: { description: value } });
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.sheet}>
|
||||
<h1>{item.name}</h1>
|
||||
<label className={styles.label}>
|
||||
{localize("BOILERPLATE.Item.Quantity")}
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
value={system.quantity}
|
||||
onChange={(e) => updateQuantity(Number(e.target.value))}
|
||||
/>
|
||||
</label>
|
||||
<label className={styles.label}>
|
||||
{localize("BOILERPLATE.Item.Description")}
|
||||
<textarea
|
||||
defaultValue={system.description}
|
||||
onBlur={(e) => updateDescription(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import React from "react";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import { ItemSheetApp } from "./components/ItemSheetApp";
|
||||
|
||||
export class ItemSheet extends foundry.applications.sheets.ItemSheetV2 {
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["fvtt-ts-react-boilerplate", "sheet", "item"],
|
||||
position: { width: 480, height: 360 }
|
||||
};
|
||||
|
||||
#root: Root | null = null;
|
||||
|
||||
override async _renderHTML(
|
||||
...args: Parameters<foundry.applications.sheets.ItemSheetV2["_renderHTML"]>
|
||||
) {
|
||||
return args[0];
|
||||
}
|
||||
|
||||
override _replaceHTML(
|
||||
...args: Parameters<foundry.applications.sheets.ItemSheetV2["_replaceHTML"]>
|
||||
) {
|
||||
const content = args[1];
|
||||
if (!this.#root) this.#root = createRoot(content);
|
||||
this.#root.render(React.createElement(ItemSheetApp, { item: this.document }));
|
||||
}
|
||||
|
||||
override async close(...args: Parameters<foundry.applications.sheets.ItemSheetV2["close"]>) {
|
||||
this.#root?.unmount();
|
||||
this.#root = null;
|
||||
return super.close(...args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { CharacterData } from "./data/character-data.mjs";
|
||||
import { ItemData } from "./data/item-data.mjs";
|
||||
import { M6ActorSheet } from "./sheets/character-sheet.mjs";
|
||||
|
||||
Hooks.once("init", () => {
|
||||
CONFIG.Actor.dataModels.character = CharacterData;
|
||||
CONFIG.Actor.trackableAttributes = {
|
||||
pc: {
|
||||
bar: ["resources.leben", "resources.ausdauer"],
|
||||
value: ["level"]
|
||||
},
|
||||
npc: {
|
||||
bar: ["resources.leben", "resources.ausdauer"],
|
||||
value: []
|
||||
}
|
||||
};
|
||||
CONFIG.Item.dataModels.item = ItemData;
|
||||
|
||||
foundry.applications.apps.DocumentSheetConfig.registerSheet(Actor, "midgard6-lvd", M6ActorSheet, {
|
||||
types: ["character"],
|
||||
makeDefault: true
|
||||
});
|
||||
// foundry.applications.apps.DocumentSheetConfig.registerSheet(Item, "midgard6-lvd", ItemSheet, {
|
||||
// types: ["item"],
|
||||
// makeDefault: true
|
||||
// });
|
||||
});
|
||||
@@ -1,28 +0,0 @@
|
||||
import { CharacterData } from "./data/character-data";
|
||||
import { ItemData } from "./data/item-data";
|
||||
import { CharacterSheet } from "./sheets/character-sheet";
|
||||
import { ItemSheet } from "./sheets/item-sheet";
|
||||
|
||||
Hooks.once("init", () => {
|
||||
CONFIG.Actor.dataModels.character = CharacterData;
|
||||
CONFIG.Item.dataModels.item = ItemData;
|
||||
|
||||
foundry.applications.apps.DocumentSheetConfig.registerSheet(
|
||||
Actor,
|
||||
"fvtt-ts-react-boilerplate",
|
||||
CharacterSheet,
|
||||
{
|
||||
types: ["character"],
|
||||
makeDefault: true
|
||||
}
|
||||
);
|
||||
foundry.applications.apps.DocumentSheetConfig.registerSheet(
|
||||
Item,
|
||||
"fvtt-ts-react-boilerplate",
|
||||
ItemSheet,
|
||||
{
|
||||
types: ["item"],
|
||||
makeDefault: true
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
<div className={{styles.sheet}}>
|
||||
<h1>{{actor.name}}</h1>
|
||||
<div className={{styles.skills}}>
|
||||
{{(["anführen", "fernkampf", "nahkampf"] as const).map((key) => (
|
||||
<label className={{styles.attributeLabel}} key={{key}}>
|
||||
{{localize(`Midgard6.skills.${key}`)}}
|
||||
<input
|
||||
type="number"
|
||||
value={{attrs[key]}}
|
||||
onChange="{{(e) => updateAttribute(key, Number(e.target.value))}}"/>
|
||||
<span className={{styles.modifier}}>{{fmtMod(modifier(attrs[key]))}}</span>
|
||||
</label>
|
||||
))}}
|
||||
</div>
|
||||
<div className={{styles.totals}}>
|
||||
<span>
|
||||
{{localize("Midgard6.Sheet.Total")}}: {{total}}
|
||||
</span>
|
||||
<span>
|
||||
{{localize("Midgard6.Sheet.TotalMod")}}: {{fmtMod(totalMod)}}
|
||||
</span>
|
||||
</div>
|
||||
<label className={{styles.attributeLabel}}>
|
||||
{{localize("Midgard6.Sheet.Biography")}}
|
||||
<textarea defaultValue={{system.biography}} onBlur="{{(e) => updateBiography(e.target.value)}}" />
|
||||
</label>
|
||||
|
||||
<div className={{styles.chatRow}}>
|
||||
<input
|
||||
type="text"
|
||||
placeholder={{localize("Midgard6.Sheet.ChatPlaceholder")}}
|
||||
value={{chatMessage}}
|
||||
onChange="{{(e) => setChatMessage(e.target.value)}}"
|
||||
onKeyDown="{{(e) => e.key === "Enter" && sendChatMessage()}}"
|
||||
/>
|
||||
<button type="button" onClick={{sendChatMessage}}>
|
||||
{{localize("Midgard6.Sheet.SendToChat")}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,23 @@
|
||||
<header class="sheet-header flexrow">
|
||||
<div class="flexcolumn">
|
||||
<input class="text" type="text" placeholder="{{localize "Midgard6.Biography.name"}}" name="name" value="{{actor.name}}" />
|
||||
<input class="text" type="text" placeholder="{{localize "Midgard6.Biography.spezies"}}" name="system.biography.spezies" value="{{system.biography.spezies}}" />
|
||||
<input class="text" type="text" placeholder="{{localize "Midgard6.Biography.kultur"}}" name="system.biography.kultur" value="{{system.biography.kultur}}" />
|
||||
</div>
|
||||
<img
|
||||
class="profile-img"
|
||||
src="{{actor.img}}"
|
||||
alt="{{actor.name}}"
|
||||
{{#if editable}}
|
||||
data-action="editImage"
|
||||
data-edit="img"
|
||||
{{/if}}
|
||||
data-tooltip="{{actor.name}}"
|
||||
height="100" width="100"
|
||||
>
|
||||
<div class="flexcolumn">
|
||||
<input class="text right" type="text" placeholder="{{localize "Midgard6.Biography.abenteuertyp"}}" name="system.biography.abenteuertyp" value="{{system.biography.abenteuertyp}}" />
|
||||
<input class="text right" type="text" placeholder="{{localize "Midgard6.Biography.glaube"}}" name="system.biography.glaube" value="{{system.biography.glaube}}" />
|
||||
<input class="text right" type="text" placeholder="{{localize "Midgard6.Biography.mondgestalt"}}" name="system.biography.mondgestalt" value="{{system.biography.mondgestalt}}" />
|
||||
</div>
|
||||
</header>
|
||||
@@ -0,0 +1,47 @@
|
||||
{{! Items Tab }}
|
||||
<section class="tab scrollable {{tab.cssClass}}" data-group="primary" data-tab="items">
|
||||
<ul class="itemTypes">
|
||||
{{#each itemTypes as |group type|}}
|
||||
<li class="itemHeader flexrow">
|
||||
<div class="type-label">
|
||||
{{group.label}}
|
||||
</div>
|
||||
<div class="document-controls">
|
||||
{{#if @root.editable}}
|
||||
<a class="item-control item-create"
|
||||
title="{{localize 'DOCUMENT.Create' type=group.label}}"
|
||||
data-action="createDoc"
|
||||
data-document-class="Item"
|
||||
data-type="{{type}}"
|
||||
>
|
||||
<i class="fas fa-plus"></i>
|
||||
{{localize "DOCUMENT.New" type=group.label}}
|
||||
</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
</li>
|
||||
<ul class="items">
|
||||
{{#each group.items as |item|}}
|
||||
<li class="item flexrow draggable" data-item-id="{{item._id}}" data-document-class="Item">
|
||||
<img src="{{item.img}}" alt="{{item.name}}" width="24" height="24">
|
||||
<div class="item-name">{{item.name}}</div>
|
||||
<div class="document-controls">
|
||||
<a class="item-control item-edit"
|
||||
title="{{localize 'DOCUMENT.Update' type=item.name}}"
|
||||
data-action="viewDoc">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
{{#if @root.editable}}
|
||||
<a class="item-control item-delete"
|
||||
title="{{localize 'DOCUMENT.Delete' type=item.name}}"
|
||||
data-action="deleteDoc">
|
||||
<i class="fas fa-trash"></i>
|
||||
</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</section>
|
||||
@@ -0,0 +1,65 @@
|
||||
<section class="flexrow">
|
||||
<fieldset>
|
||||
<legend>LP</legend>
|
||||
<div class="flexrow">
|
||||
<input
|
||||
class="attribut"
|
||||
type="number"
|
||||
name="system.resources.leben.value"
|
||||
value="{{system.resources.leben.value}}"
|
||||
/>
|
||||
<p class="center">/</p>
|
||||
<input
|
||||
class="attribut"
|
||||
type="number"
|
||||
name="system.resources.leben.max"
|
||||
value="{{system.resources.leben.max}}"
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>AP</legend>
|
||||
<div class="flexrow">
|
||||
<input
|
||||
class="attribut"
|
||||
type="number"
|
||||
name="system.resources.ausdauer.value"
|
||||
value="{{system.resources.leben.value}}"
|
||||
/>
|
||||
<p class="center">/</p>
|
||||
<input
|
||||
class="attribut"
|
||||
type="number"
|
||||
name="system.resources.ausdauer.max"
|
||||
value="{{system.resources.leben.max}}"
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Reflexe</legend>
|
||||
<input
|
||||
class="attribut"
|
||||
type="number"
|
||||
name="system.resources.leben.value"
|
||||
value="{{system.resources.leben.value}}"
|
||||
/>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Willenskraft</legend>
|
||||
<input
|
||||
class="attribut"
|
||||
type="number"
|
||||
name="system.resources.leben.value"
|
||||
value="{{system.resources.leben.value}}"
|
||||
/>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Zähigkeit</legend>
|
||||
<input
|
||||
class="attribut"
|
||||
type="number"
|
||||
name="system.resources.leben.value"
|
||||
value="{{system.resources.leben.value}}"
|
||||
/>
|
||||
</fieldset>
|
||||
</section>
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
<div class="form-group">
|
||||
<label>{{localize "Type"}}</label>
|
||||
<div class="form-fields">
|
||||
<select name="type">
|
||||
{{selectOptions types selected=type}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,14 @@
|
||||
<header class="sheet-header flexrow">
|
||||
<img
|
||||
class="profile-img"
|
||||
src="{{item.img}}"
|
||||
alt="{{item.name}}"
|
||||
{{#if editable}}
|
||||
data-action="editImage"
|
||||
data-edit="img"
|
||||
{{/if}}
|
||||
data-tooltip="{{item.name}}"
|
||||
height="100" width="100"
|
||||
>
|
||||
{{formInput itemFields.name value=item.name}}
|
||||
</header>
|
||||
@@ -0,0 +1,59 @@
|
||||
{{! Effects Tab }}
|
||||
<section class="tab effects flexcol scrollable {{tab.cssClass}}" data-group="primary" data-tab="effects">
|
||||
<ul class="effects-list">
|
||||
{{#each effects as |section sid|}}
|
||||
<li class="effects-header flexrow draggable" data-effect-type="{{section.type}}">
|
||||
<div class="effect-label flexrow">
|
||||
{{localize section.label}}
|
||||
</div>
|
||||
<div class="effect-source">
|
||||
{{localize "EFFECT.FIELDS.origin.label"}}
|
||||
</div>
|
||||
<div class="effect-duration">{{localize "EFFECT.TABS.duration"}}</div>
|
||||
<div class="document-controls flexrow">
|
||||
<a class="effect-controls"
|
||||
data-action="createDoc" data-document-class="ActiveEffect"
|
||||
{{!-- <!-- eslint-disable-next-line @html-eslint/no-duplicate-attrs --> --}}
|
||||
{{#if (eq section.type "inactive" )}} data-disabled="true"
|
||||
{{else if (eq section.type "temporary" )}} data-duration.rounds="1" {{/if}}
|
||||
data-origin="{{@root.document.uuid}}"
|
||||
title="{{localize 'DOCUMENT.Create' type=(localize 'DOCUMENT.ActiveEffect')}}"
|
||||
data-img="icons/svg/aura.svg"
|
||||
>
|
||||
<i class="fas fa-plus"></i>
|
||||
{{localize "DOCUMENT.New" type=(localize "UTS.Effect.Label")}}
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<ul class="effect-list">
|
||||
{{#each section.effects as |effect|}}
|
||||
<li class="effect flexrow draggable" data-effect-id="{{effect.id}}" data-parent-id="{{effect.parent.id}}"
|
||||
data-document-class="ActiveEffect">
|
||||
<div class="effect-label flexrow">
|
||||
<img class="effect-image" src="{{effect.img}}" alt="{{effect.name}}" height="24" width="24">
|
||||
<div class="effect-name">{{effect.name}}</div>
|
||||
</div>
|
||||
<div class="effect-source">{{effect.sourceName}}</div>
|
||||
<div class="effect-duration">{{effect.duration.label}}</div>
|
||||
<div class="document-controls flexrow">
|
||||
{{#if @root.editable}}
|
||||
<a class="effect-control" data-action="toggleEffect" title="{{localize 'UTS.Effect.Toggle'}}">
|
||||
<i class="fas {{#if effect.disabled}}fa-check{{else}}fa-times{{/if}}"></i>
|
||||
</a>
|
||||
{{/if}}
|
||||
<a class="effect-control" data-action="viewDoc" title="{{localize 'DOCUMENT.Update' type=(localize 'DOCUMENT.ActiveEffect')}}">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
{{#if @root.editable}}
|
||||
<a class="effect-control" data-action="deleteDoc" title="{{localize 'DOCUMENT.Delete' type=(localize 'DOCUMENT.ActiveEffect')}}">
|
||||
<i class="fas fa-trash"></i>
|
||||
</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</section>
|
||||
@@ -0,0 +1,31 @@
|
||||
<section
|
||||
class="standard-form tab scrollable {{tab.cssClass}}"
|
||||
data-group="primary"
|
||||
data-tab="properties"
|
||||
>
|
||||
{{#each fields}}
|
||||
{{#if fieldset}}
|
||||
<fieldset>
|
||||
<legend>{{localize legend}}</legend>
|
||||
{{#each fields}}
|
||||
<div class="flexrow" style="max-width: 10rem;">
|
||||
<a
|
||||
class="flexrow"
|
||||
data-action="rollSkill"
|
||||
data-name="{{localize localizationName}}"
|
||||
data-value="{{value}}"
|
||||
>
|
||||
<i class="flex0 fa-solid fa-dice-d20"></i>
|
||||
<p class="flex1" style="margin-left: 4px; max-width:7rem">{{localize
|
||||
localizationName
|
||||
}}</p>
|
||||
</a>
|
||||
<input class="skill" type="number" name="{{field.fieldPath}}" value="{{value}}" />
|
||||
</div>
|
||||
{{/each}}
|
||||
</fieldset>
|
||||
{{else}}
|
||||
{{formGroup outer.field value=outer.value localize=true}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</section>
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,103 @@
|
||||
.application.sheet.M6.actor.character {
|
||||
background-color: red;
|
||||
|
||||
section {
|
||||
> .sheet-header {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
input {
|
||||
color: green;
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
.application.sheet.M6 {
|
||||
max-height: 90%;
|
||||
|
||||
&.actor,
|
||||
&.item {
|
||||
.window-content {
|
||||
padding-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.sheet-header {
|
||||
background-color: red;
|
||||
color: red;
|
||||
img {
|
||||
border: none;
|
||||
flex: 0 0 100px;
|
||||
object-fit: contain;
|
||||
}
|
||||
input[name="name"] {
|
||||
height: 2.5em;
|
||||
font-size: 2rem;
|
||||
}
|
||||
}
|
||||
.tab {
|
||||
height: 100%;
|
||||
padding-top: 10px;
|
||||
}
|
||||
.tab[data-tab="items"] {
|
||||
ul {
|
||||
list-style: none;
|
||||
padding-left: 5px;
|
||||
}
|
||||
.itemHeader {
|
||||
border-bottom: 1px solid var(--color-border-light-primary);
|
||||
.type-label {
|
||||
font-size: 20px;
|
||||
}
|
||||
.document-controls {
|
||||
flex: 0 0 100px;
|
||||
}
|
||||
}
|
||||
.item {
|
||||
img {
|
||||
border: none;
|
||||
flex: 0 0 30px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
.document-controls {
|
||||
flex: 0 0 50px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.tab[data-tab="effects"] {
|
||||
ul {
|
||||
list-style: none;
|
||||
padding-left: 5px;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.effects-header {
|
||||
font-size: 16px;
|
||||
border-bottom: 1px solid var(--color-border-light-primary);
|
||||
.document-controls {
|
||||
flex: 0 0 100px;
|
||||
}
|
||||
}
|
||||
.effect {
|
||||
.effect-label {
|
||||
img {
|
||||
border: none;
|
||||
flex: 0 0 30px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
.effect-name {
|
||||
line-height: 24px;
|
||||
}
|
||||
}
|
||||
.effect-duration {
|
||||
flex: 0 0 130px;
|
||||
}
|
||||
.document-controls {
|
||||
flex: 0 0 80px;
|
||||
}
|
||||
}
|
||||
.effect-label {
|
||||
flex: 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
-13
@@ -1,31 +1,31 @@
|
||||
{
|
||||
"id": "fvtt-ts-react-boilerplate",
|
||||
"id": "midgard6-lvd",
|
||||
"version": "0.8.2",
|
||||
"title": "FVTT TS+React Boilerplate",
|
||||
"title": "Midgard: Legenden von Damatu",
|
||||
"url": "",
|
||||
"description": "A TypeScript + React + Vite boilerplate for Foundry VTT V14 system development",
|
||||
"description": "Eine Midgard: LvD implementation",
|
||||
"license": "LICENSE.txt",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nyukhu",
|
||||
"url": "https://foundryvtt.com",
|
||||
"name": "Byroks",
|
||||
"url": "https://git.byroks.com",
|
||||
"flags": {}
|
||||
}
|
||||
],
|
||||
"esmodules": ["dist/system.mjs"],
|
||||
"styles": ["dist/style.css"],
|
||||
"styles": ["dist/style.css", "M6.css"],
|
||||
"languages": [
|
||||
{
|
||||
"lang": "de",
|
||||
"name": "Deutsch",
|
||||
"path": "lang/de.json",
|
||||
"flags": {}
|
||||
},
|
||||
{
|
||||
"lang": "en",
|
||||
"name": "English",
|
||||
"path": "lang/en.json",
|
||||
"flags": {}
|
||||
},
|
||||
{
|
||||
"lang": "fr",
|
||||
"name": "Français",
|
||||
"path": "lang/fr.json",
|
||||
"flags": {}
|
||||
}
|
||||
],
|
||||
"documentTypes": {
|
||||
@@ -44,6 +44,12 @@
|
||||
"download": "",
|
||||
"grid": {
|
||||
"distance": 5,
|
||||
"units": "ft"
|
||||
"units": "m"
|
||||
},
|
||||
"flags": {
|
||||
"hotReload": {
|
||||
"extensions": ["css", "html", "hbs", "json"],
|
||||
"paths": ["M6.css", "templates", "lang"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2022", "DOM"],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"types": ["fvtt-types"],
|
||||
"jsx": "react-jsx",
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noEmit": true,
|
||||
"isolatedModules": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
+1
-1
@@ -15,7 +15,7 @@ export default defineConfig({
|
||||
outDir: "dist",
|
||||
emptyOutDir: true,
|
||||
lib: {
|
||||
entry: "src/system.ts",
|
||||
entry: "src/system.mjs",
|
||||
formats: ["es"],
|
||||
fileName: () => "system.mjs"
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user