From c91b8956f6011826bf3cbef3a09342e27aea5237 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sun, 3 Jan 2021 20:37:30 +0100 Subject: [PATCH 01/32] add data for profile info --- src/lang/en.json | 14 +++++++++++++- src/module/actor/actor-data.ts | 20 ++++++++++++++++++++ src/module/config.ts | 26 +++++++++++++++++++++++++- src/template.json | 18 +++++++++++++++++- 4 files changed, 75 insertions(+), 3 deletions(-) diff --git a/src/lang/en.json b/src/lang/en.json index de17c09b..f529b69c 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -78,8 +78,20 @@ "DS4.BaseInfoClass": "Class", "DS4.BaseInfoHeroClass": "Hero Class", "DS4.BaseInfoRacialAbilities": "Racial Abilites", + "DS4.BaseInfoCulture": "Culture", "DS4.ProgressionLevel": "Level", "DS4.ProgressionExperiencePoints": "Experience Points", "DS4.ProgressionTalentPoints": "Talent Points", - "DS4.ProgressionProgressPoints": "Progress Points" + "DS4.ProgressionProgressPoints": "Progress Points", + "DS4.LanguageLanguages": "Languages", + "DS4.LanguageAlphabets": "Alphabets", + "DS4.ProfileGender": "Gender", + "DS4.ProfileBirthday": "Birthday", + "DS4.ProfileBirthplace": "Birthplace", + "DS4.ProfileAge": "Age", + "DS4.ProfileHeight": "Height", + "DS4.ProfilHairColor": "Hair Color", + "DS4.ProfileWeight": "Weight", + "DS4.ProfileEyeColor": "Eye Color", + "DS4.ProfileSpecialCharacteristics": "Special Characteristics" } diff --git a/src/module/actor/actor-data.ts b/src/module/actor/actor-data.ts index 93385b65..746ae439 100644 --- a/src/module/actor/actor-data.ts +++ b/src/module/actor/actor-data.ts @@ -4,6 +4,8 @@ export interface DS4ActorDataType { combatValues: DS4ActorDataCombatValues; baseInfo: DS4ActorDataBaseInfo; progression: DS4ActorDataProgression; + language: DS4ActorDataLanguage; + profile: DS4ActorDataProfile; } interface DS4ActorDataAttributes { @@ -55,6 +57,7 @@ interface DS4ActorDataBaseInfo { class: string; heroClass: string; racialAbilities: string; + culture: string; } interface DS4ActorDataProgression { @@ -63,3 +66,20 @@ interface DS4ActorDataProgression { talentPoints: UsableResource; progressPoints: UsableResource; } + +interface DS4ActorDataLanguage { + languages: string; + alphabets: string; +} + +interface DS4ActorDataProfile { + gender: string; + birthday: string; + birthplace: string; + age: number; + height: number; + hairColor: string; + weight: number; + eyeColor: string; + specialCharacteristics: string; +} diff --git a/src/module/config.ts b/src/module/config.ts index 89d285cf..deafe0db 100644 --- a/src/module/config.ts +++ b/src/module/config.ts @@ -135,10 +135,11 @@ export const DS4 = { class: "DS4.BaseInfoClass", heroClass: "DS4.BaseInfoHeroClass", racialAbilities: "DS4.BaseInfoRacialAbilities", + culture: "DS4.BaseInfoCulture", }, /** - * Definme the progression info of a character + * Define the progression info of a character */ progression: { level: "DS4.ProgressionLevel", @@ -146,4 +147,27 @@ export const DS4 = { talentPoints: "DS4.ProgressionTalentPoints", progressPoints: "DS4.ProgressionProgressPoints", }, + + /** + * Define the language info of a character + */ + language: { + languages: "DS4.LanguageLanguages", + alphabets: "DS4.LanguageAlphabets", + }, + + /** + * Define the profile info of a character + */ + profile: { + gender: "DS4.ProfileGender", + birthday: "DS4.ProfileBirthday", + birthplace: "DS4.ProfileBirthplace", + age: "DS4.ProfileAge", + height: "DS4.ProfileHeight", + hairColor: "DS4.ProfilHairColor", + weight: "DS4.ProfileWeight", + eyeColor: "DS4.ProfileEyeColor", + specialCharacteristics: "DS4.ProfileSpecialCharacteristics", + }, }; diff --git a/src/template.json b/src/template.json index b78fd3e1..fe663ed3 100644 --- a/src/template.json +++ b/src/template.json @@ -83,7 +83,8 @@ "race": "", "class": "", "heroClass": "", - "racialAbilities": "" + "racialAbilities": "", + "culture": "" }, "progression": { "level": 0, @@ -96,6 +97,21 @@ "total": 0, "used": 0 } + }, + "language": { + "languages": "", + "alphabets": "" + }, + "profile": { + "gender": "", + "birthday": "", + "birthplace": "", + "age": 0, + "height": 0, + "hairColor": "", + "weight": 0, + "eyeColor": "", + "specialCharacteristics": "" } } }, From 98ce35f83159c6b393db7d0041bd82b02dc1d5f8 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sun, 3 Jan 2021 20:54:45 +0100 Subject: [PATCH 02/32] Add dummy profile tab to character sheet --- src/lang/en.json | 2 ++ src/module/ds4.ts | 3 +++ src/templates/actor/actor-sheet.hbs | 8 ++++++-- src/templates/actor/partials/profile.hbs | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/templates/actor/partials/profile.hbs diff --git a/src/lang/en.json b/src/lang/en.json index f529b69c..8159ced0 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -5,6 +5,8 @@ "DS4.DescriptionAbbr": "Desc", "DS4.Details": "Details", "DS4.Effects": "Effects", + "DS4.Profile": "Profile", + "DS4.Items": "Items", "DS4.AttackType": "Attack Type", "DS4.AttackTypeAbbr": "AT", "DS4.WeaponBonus": "Weapon Bonus", diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 358074b0..2fef8f04 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -39,6 +39,7 @@ async function registerHandlebarsPartials() { "systems/ds4/templates/actor/partials/items-overview.hbs", "systems/ds4/templates/actor/partials/attributes-traits.hbs", "systems/ds4/templates/actor/partials/combat-values.hbs", + "systems/ds4/templates/actor/partials/profile.hbs", ]; return loadTemplates(templatePaths); } @@ -66,6 +67,8 @@ Hooks.once("setup", function () { "combatValues", "baseInfo", "progression", + "language", + "profile", ]; // Exclude some from sorting where the default order matters diff --git a/src/templates/actor/actor-sheet.hbs b/src/templates/actor/actor-sheet.hbs index 475ce2fd..aa9658d4 100644 --- a/src/templates/actor/actor-sheet.hbs +++ b/src/templates/actor/actor-sheet.hbs @@ -90,8 +90,9 @@ {{!-- Sheet Tab Navigation --}} {{!-- Sheet Body --}} @@ -101,6 +102,9 @@ {{editor content=data.biography target="data.biography" button=true owner=owner editable=editable}} + {{! Profile Tab --}} + {{> systems/ds4/templates/actor/partials/profile.hbs}} + {{!-- Items Tab --}} {{> systems/ds4/templates/actor/partials/items-overview.hbs}} diff --git a/src/templates/actor/partials/profile.hbs b/src/templates/actor/partials/profile.hbs new file mode 100644 index 00000000..4755d267 --- /dev/null +++ b/src/templates/actor/partials/profile.hbs @@ -0,0 +1 @@ +
\ No newline at end of file From 2cb04112880f84d884168cff057af51388fd7574 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sun, 3 Jan 2021 23:26:31 +0100 Subject: [PATCH 03/32] Add basic form of editable profile fields to profile tab --- src/module/config.ts | 15 +++++++++++++++ src/templates/actor/partials/profile.hbs | 12 +++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/module/config.ts b/src/module/config.ts index deafe0db..c5c1dea3 100644 --- a/src/module/config.ts +++ b/src/module/config.ts @@ -170,4 +170,19 @@ export const DS4 = { eyeColor: "DS4.ProfileEyeColor", specialCharacteristics: "DS4.ProfileSpecialCharacteristics", }, + + /** + * Define the profile info types for hanndlebars of a character + */ + profileDTypes: { + gender: "String", + birthday: "String", + birthplace: "String", + age: "Number", + height: "Number", + hairColor: "String", + weight: "Number", + eyeColor: "String", + specialCharacteristics: "String", + }, }; diff --git a/src/templates/actor/partials/profile.hbs b/src/templates/actor/partials/profile.hbs index 4755d267..def5d419 100644 --- a/src/templates/actor/partials/profile.hbs +++ b/src/templates/actor/partials/profile.hbs @@ -1 +1,11 @@ -
\ No newline at end of file +
+
+ {{#each data.profile as |profile-data-value profile-data-key|}} +
+ + +
+ {{/each}} +
+
\ No newline at end of file From 520aab8b72ed0d9e34e741088fd05a28b7a22451 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Mon, 4 Jan 2021 00:19:51 +0100 Subject: [PATCH 04/32] cleanup profile --- src/templates/actor/partials/profile.hbs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/templates/actor/partials/profile.hbs b/src/templates/actor/partials/profile.hbs index def5d419..b0034128 100644 --- a/src/templates/actor/partials/profile.hbs +++ b/src/templates/actor/partials/profile.hbs @@ -2,7 +2,9 @@
{{#each data.profile as |profile-data-value profile-data-key|}}
- +
From f8deca4cd48d76d6a6e9d5c0321fc191ebb288f9 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Mon, 4 Jan 2021 21:51:58 +0100 Subject: [PATCH 05/32] add culture and save space with base infos and progression infos --- src/ds4.scss | 1 + src/module/ds4.ts | 1 + src/scss/components/_basic_property.scss | 6 + .../components/_character_progression.scss | 30 +++++ src/scss/global/_flex.scss | 6 + src/scss/global/_grid.scss | 4 +- src/templates/actor/actor-sheet.hbs | 114 +++++++----------- .../actor/partials/character-progression.hbs | 15 +++ 8 files changed, 102 insertions(+), 75 deletions(-) create mode 100644 src/scss/components/_character_progression.scss create mode 100644 src/templates/actor/partials/character-progression.hbs diff --git a/src/ds4.scss b/src/ds4.scss index 2fedca1f..a3b14a06 100644 --- a/src/ds4.scss +++ b/src/ds4.scss @@ -20,4 +20,5 @@ @import "scss/components/character_values"; @import "scss/components/attributes_traits"; @import "scss/components/combat_values"; + @import "scss/components/character_progression"; } diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 2fef8f04..cf43adb8 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -40,6 +40,7 @@ async function registerHandlebarsPartials() { "systems/ds4/templates/actor/partials/attributes-traits.hbs", "systems/ds4/templates/actor/partials/combat-values.hbs", "systems/ds4/templates/actor/partials/profile.hbs", + "systems/ds4/templates/actor/partials/character-progression.hbs", ]; return loadTemplates(templatePaths); } diff --git a/src/scss/components/_basic_property.scss b/src/scss/components/_basic_property.scss index 6f725dad..e284529c 100644 --- a/src/scss/components/_basic_property.scss +++ b/src/scss/components/_basic_property.scss @@ -1,6 +1,9 @@ .basic-properties { flex: 0 0 100%; + gap: 2px; .basic-property { + padding-left: 1px; + padding-right: 1px; .basic-property-label { font-weight: bold; } @@ -9,5 +12,8 @@ display: block; width: 100%; } + .input-divider { + text-align: center; + } } } diff --git a/src/scss/components/_character_progression.scss b/src/scss/components/_character_progression.scss new file mode 100644 index 00000000..8e663cbb --- /dev/null +++ b/src/scss/components/_character_progression.scss @@ -0,0 +1,30 @@ +.progression { + .progression-entry { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: flex-end; + align-items: center; + + padding-right: 3px; + h2.progression-label { + font-family: $font-heading; + display: block; + height: 50px; + padding: 0px; + color: $c-light-grey; + border: none; + line-height: 50px; + margin: $header-top-margin 0; + text-align: right; + //flex: 0; + } + input.progression-value { + margin-left: 5px; + flex: 0 0 40px; + text-align: left; + border: none; + background-color: transparent; + } + } +} diff --git a/src/scss/global/_flex.scss b/src/scss/global/_flex.scss index 271c64b3..3f23d105 100644 --- a/src/scss/global/_flex.scss +++ b/src/scss/global/_flex.scss @@ -18,6 +18,9 @@ .flex1 { flex: 1; } + .flex125 { + flex: 1.25; + } .flex15 { flex: 1.5; } @@ -51,6 +54,9 @@ .flex1 { flex: 1; } + .flex125 { + flex: 1.25; + } .flex15 { flex: 1.5; } diff --git a/src/scss/global/_grid.scss b/src/scss/global/_grid.scss index 8498a314..b8903f70 100644 --- a/src/scss/global/_grid.scss +++ b/src/scss/global/_grid.scss @@ -28,8 +28,8 @@ } .grid-6col { - grid-column: span 5 / span 5; - grid-template-columns: repeat(5, minmax(0, 1fr)); + grid-column: span 6 / span 6; + grid-template-columns: repeat(6, minmax(0, 1fr)); } .grid-7col { diff --git a/src/templates/actor/actor-sheet.hbs b/src/templates/actor/actor-sheet.hbs index aa9658d4..461eaff5 100644 --- a/src/templates/actor/actor-sheet.hbs +++ b/src/templates/actor/actor-sheet.hbs @@ -2,89 +2,57 @@ {{!-- Sheet Header --}}
-
+

-
-
- {{!-- The grid classes are defined in scss/global/_grid.scss. To use, use both the "grid" and "grid-Ncol" - class where "N" can be any number from 1 to 12 and will create that number of columns. --}} -
- {{!-- "flex-group-center" is also defined in the _grid.scss file and it will add a small amount of - padding, a border, and will center all of its child elements content and text. --}} -
- -
- + {{> systems/ds4/templates/actor/partials/character-progression.hbs}} + +
+
+ + +
+
+ + +
+
+ +
+ / +
-
-
-
- -
- -
-
-
- -
- / - -
-
-
- -
- / - -
-
+
+ +
+ / +
-
- -
- -
+
+ +
-
- -
- -
-
-
- -
- -
-
-
- -
- -
+
+ +
- +
+
{{> systems/ds4/templates/actor/partials/attributes-traits.hbs}} {{> systems/ds4/templates/actor/partials/combat-values.hbs}} -
diff --git a/src/templates/actor/partials/character-progression.hbs b/src/templates/actor/partials/character-progression.hbs new file mode 100644 index 00000000..4b1790f4 --- /dev/null +++ b/src/templates/actor/partials/character-progression.hbs @@ -0,0 +1,15 @@ +
+
+

+

+ +
+
+

+

+ +
+
From f2f40a8e89fe168fe4789206e92701adc0031c39 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Mon, 4 Jan 2021 22:12:19 +0100 Subject: [PATCH 06/32] make some input fiels accept only number --- src/templates/actor/actor-sheet.hbs | 8 ++++---- src/templates/actor/partials/character-progression.hbs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/templates/actor/actor-sheet.hbs b/src/templates/actor/actor-sheet.hbs index 461eaff5..989ab3a0 100644 --- a/src/templates/actor/actor-sheet.hbs +++ b/src/templates/actor/actor-sheet.hbs @@ -20,10 +20,10 @@
- / -
@@ -31,10 +31,10 @@
- / -
diff --git a/src/templates/actor/partials/character-progression.hbs b/src/templates/actor/partials/character-progression.hbs index 4b1790f4..f22376f0 100644 --- a/src/templates/actor/partials/character-progression.hbs +++ b/src/templates/actor/partials/character-progression.hbs @@ -2,14 +2,14 @@

-

-
From 9de78b4940182d24dacd9dc7ff5379d6a179822e Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Wed, 6 Jan 2021 00:02:30 +0100 Subject: [PATCH 07/32] small style fixes --- src/scss/components/_attributes_traits.scss | 4 ++-- src/scss/global/_window.scss | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/scss/components/_attributes_traits.scss b/src/scss/components/_attributes_traits.scss index 19cef982..09cb469b 100644 --- a/src/scss/components/_attributes_traits.scss +++ b/src/scss/components/_attributes_traits.scss @@ -8,7 +8,6 @@ } .attribute-value { border: 2px groove $c-border-groove; - line-height: $default-input-height; font-size: 1.5em; text-align: center; padding-left: 2px; @@ -17,6 +16,7 @@ input, .attribute-value-total { grid-column: span 2; + line-height: $default-input-height; } } } @@ -32,7 +32,6 @@ .trait-value { border: 2px groove $c-border-groove; font-size: 1.5em; - line-height: $default-input-height; text-align: center; padding-left: 2px; padding-right: 2px; @@ -40,6 +39,7 @@ input, .trait-value-total { grid-column: span 2; + line-height: $default-input-height; } } } diff --git a/src/scss/global/_window.scss b/src/scss/global/_window.scss index bbe12083..36985d71 100644 --- a/src/scss/global/_window.scss +++ b/src/scss/global/_window.scss @@ -1,5 +1,12 @@ .window-app { font-family: $font-primary; + input[type="text"], + input[type="number"], + input[type="password"], + input[type="date"], + input[type="time"] { + width: 100%; + } } .rollable { From 74be1d4e13f2a630c65cf951b3f06f493019b2db Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Wed, 6 Jan 2021 00:59:22 +0100 Subject: [PATCH 08/32] put release artifacts in ds4 directory --- .gitlab-ci.yml | 5 +++-- src/system.json | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c3370fa4..bc2e0930 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,11 +45,12 @@ build: stage: build script: - npm run build + - mv dist ds4 cache: <<: *global_cache artifacts: paths: - - dist + - ds4 expire_in: 1 week deploy: @@ -58,7 +59,7 @@ deploy: dependencies: - build script: - - rsync --delete -az ./dist/ rsync://${DEPLOYMENT_USER}@${DEPLOYMENT_SERVER}:${DEPLOYMENT_PATH} + - rsync --delete -az ./ds4/ rsync://${DEPLOYMENT_USER}@${DEPLOYMENT_SERVER}:${DEPLOYMENT_PATH} environment: name: production url: https://vtt.f3l.de/ diff --git a/src/system.json b/src/system.json index 3929e3ab..43f2245b 100644 --- a/src/system.json +++ b/src/system.json @@ -22,7 +22,7 @@ "gridUnits": "m", "primaryTokenAttribute": "combatValues.hitPoints.current", "url": "https://git.f3l.de/dungeonslayers/ds4", - "manifest": "https://git.f3l.de/dungeonslayers/ds4/-/blob/master/src/system.json", - "download": "https://git.f3l.de/dungeonslayers/ds4/-/archive/master/ds4-master.zip", + "manifest": "https://git.f3l.de/dungeonslayers/ds4/-/raw/latest/src/system.json?inline=false", + "download": "https://git.f3l.de/dungeonslayers/ds4/-/jobs/artifacts/latest/download?job=build", "license": "MIT" } From 150a0ea487d9379026ce3351d1fdc05c8318f8ca Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 01:24:37 +0100 Subject: [PATCH 09/32] added talents overview and sheet - added talents item type: - added scss - added to template.json (Item.types, Item.talent) - added to config.ts itemTypes - added type definition - added localizations - added talent overview tab to actor sheet - made total rank calculated upon data preparation by adding a prepareData method to DS4Item --- src/ds4.scss | 1 + src/lang/en.json | 10 +- src/module/config.ts | 1 + src/module/ds4.ts | 1 + src/module/item/item-data.ts | 12 ++- src/module/item/item.ts | 10 +- src/scss/components/_talents.scss | 3 + src/template.json | 10 +- src/templates/actor/actor-sheet.hbs | 8 +- .../actor/partials/talents-overview.hbs | 95 +++++++++++++++++++ src/templates/item/talent-sheet.hbs | 63 ++++++++++++ 11 files changed, 208 insertions(+), 6 deletions(-) create mode 100644 src/scss/components/_talents.scss create mode 100644 src/templates/actor/partials/talents-overview.hbs create mode 100644 src/templates/item/talent-sheet.hbs diff --git a/src/ds4.scss b/src/ds4.scss index 2fedca1f..b69bbd1f 100644 --- a/src/ds4.scss +++ b/src/ds4.scss @@ -16,6 +16,7 @@ @import "scss/components/basic_property"; @import "scss/components/tabs"; @import "scss/components/items"; + @import "scss/components/talents"; @import "scss/components/description"; @import "scss/components/character_values"; @import "scss/components/attributes_traits"; diff --git a/src/lang/en.json b/src/lang/en.json index de17c09b..5227291e 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -5,6 +5,8 @@ "DS4.DescriptionAbbr": "Desc", "DS4.Details": "Details", "DS4.Effects": "Effects", + "DS4.Items": "Items", + "DS4.Talents": "Talents & Abilities", "DS4.AttackType": "Attack Type", "DS4.AttackTypeAbbr": "AT", "DS4.WeaponBonus": "Weapon Bonus", @@ -33,6 +35,7 @@ "DS4.ItemTypeShield": "Shield", "DS4.ItemTypeTrinket": "Trinket", "DS4.ItemTypeEquipment": "Equipment", + "DS4.ItemTypeTalent": "Talent", "DS4.ArmorType": "Armor Type", "DS4.ArmorTypeAbbr": "AT", "DS4.ArmorMaterialType": "Material Type", @@ -81,5 +84,10 @@ "DS4.ProgressionLevel": "Level", "DS4.ProgressionExperiencePoints": "Experience Points", "DS4.ProgressionTalentPoints": "Talent Points", - "DS4.ProgressionProgressPoints": "Progress Points" + "DS4.ProgressionProgressPoints": "Progress Points", + "DS4.TalentRank": "Rank", + "DS4.TalentRankBase": "Acquired Ranks", + "DS4.TalentRankMax": "Maximum Ranks", + "DS4.TalentRankMod": "Additional Ranks", + "DS4.TalentRankTotal": "Total Ranks" } diff --git a/src/module/config.ts b/src/module/config.ts index 89d285cf..502927ef 100644 --- a/src/module/config.ts +++ b/src/module/config.ts @@ -48,6 +48,7 @@ export const DS4 = { shield: "DS4.ItemTypeShield", trinket: "DS4.ItemTypeTrinket", equipment: "DS4.ItemTypeEquipment", + talent: "DS4.ItemTypeTalent", }, /** diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 358074b0..4bcf2223 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -37,6 +37,7 @@ async function registerHandlebarsPartials() { "systems/ds4/templates/item/partials/effects.hbs", "systems/ds4/templates/item/partials/body.hbs", "systems/ds4/templates/actor/partials/items-overview.hbs", + "systems/ds4/templates/actor/partials/talents-overview.hbs", "systems/ds4/templates/actor/partials/attributes-traits.hbs", "systems/ds4/templates/actor/partials/combat-values.hbs", ]; diff --git a/src/module/item/item-data.ts b/src/module/item/item-data.ts index 58f4dc90..a2cbc61b 100644 --- a/src/module/item/item-data.ts +++ b/src/module/item/item-data.ts @@ -1,5 +1,7 @@ +import { ModifiableData } from "../actor/actor-data"; + // TODO: Actually add a type for data -export type DS4ItemDataType = DS4Weapon | DS4Armor | DS4Shield | DS4Trinket | DS4Equipment; +export type DS4ItemDataType = DS4Weapon | DS4Armor | DS4Shield | DS4Trinket | DS4Equipment | DS4Talent; // types @@ -14,6 +16,14 @@ interface DS4Armor extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable, DS4It armorType: "body" | "helmet" | "vambrace" | "greaves" | "vambraceGreaves"; } +export interface DS4Talent extends DS4ItemBase { + talentRank: DS4TalentRank; +} + +interface DS4TalentRank extends ModifiableData { + max: number; +} + interface DS4Shield extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable, DS4ItemProtective {} interface DS4Trinket extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable {} interface DS4Equipment extends DS4ItemBase, DS4ItemPhysical {} diff --git a/src/module/item/item.ts b/src/module/item/item.ts index c32f0cfe..814a6e15 100644 --- a/src/module/item/item.ts +++ b/src/module/item/item.ts @@ -1,6 +1,6 @@ import { DS4Actor } from "../actor/actor"; import { DS4ActorDataType } from "../actor/actor-data"; -import { DS4ItemDataType } from "./item-data"; +import { DS4ItemDataType, DS4Talent } from "./item-data"; /** * Extend the basic Item with some very simple modifications. @@ -12,10 +12,18 @@ export class DS4Item extends Item { */ prepareData(): void { super.prepareData(); + this.prepareDerivedData(); // Get the Item's data // const itemData = this.data; // const actorData = this.actor ? this.actor.data : {}; // const data = itemData.data; } + + prepareDerivedData(): void { + if (this.type === "talent") { + const data: DS4Talent = this.data.data as DS4Talent; + data.talentRank.total = data.talentRank.base + data.talentRank.mod; + } + } } diff --git a/src/scss/components/_talents.scss b/src/scss/components/_talents.scss new file mode 100644 index 00000000..2f8db41b --- /dev/null +++ b/src/scss/components/_talents.scss @@ -0,0 +1,3 @@ +.talent-ranks-equation { + text-align: center; +} diff --git a/src/template.json b/src/template.json index b78fd3e1..f412936e 100644 --- a/src/template.json +++ b/src/template.json @@ -100,7 +100,7 @@ } }, "Item": { - "types": ["weapon", "armor", "shield", "trinket", "equipment"], + "types": ["weapon", "armor", "shield", "trinket", "equipment", "talent"], "templates": { "base": { "description": "" @@ -137,6 +137,14 @@ }, "equipment": { "templates": ["base", "physical"] + }, + "talent": { + "templates": ["base"], + "talentRank": { + "base": 0, + "max": 0, + "mod": 0 + } } } } diff --git a/src/templates/actor/actor-sheet.hbs b/src/templates/actor/actor-sheet.hbs index 475ce2fd..b22aae3b 100644 --- a/src/templates/actor/actor-sheet.hbs +++ b/src/templates/actor/actor-sheet.hbs @@ -90,8 +90,9 @@ {{!-- Sheet Tab Navigation --}} {{!-- Sheet Body --}} @@ -101,6 +102,9 @@ {{editor content=data.biography target="data.biography" button=true owner=owner editable=editable}} + {{!-- Talents Tab --}} + {{> systems/ds4/templates/actor/partials/talents-overview.hbs}} + {{!-- Items Tab --}} {{> systems/ds4/templates/actor/partials/items-overview.hbs}} diff --git a/src/templates/actor/partials/talents-overview.hbs b/src/templates/actor/partials/talents-overview.hbs new file mode 100644 index 00000000..03a9335d --- /dev/null +++ b/src/templates/actor/partials/talents-overview.hbs @@ -0,0 +1,95 @@ +{{!-- ======================================================================== --}} +{{!-- INLINE PARTIAL DEFINITIONS --}} +{{!-- ======================================================================== --}} + +{{!-- +!-- Render an "add" button for a given data type. +!-- +!-- @param datType: hand over the dataType to the partial as hash parameter +--}} +{{#*inline "addItemButton"}} + +{{/inline}} +{{!-- +!-- Render a group of an "edit" and a "delete" button for the current item. +!-- The current item is defined by the data-item-id HTML property of the parent li element. +--}} +{{#*inline "itemControlButtons"}} +
+ + +
+{{/inline}} + + +{{#*inline "talentRankValue"}} + +{{/inline}} + +{{!-- +!-- Render a talent list row from a given item. +!-- It is a flexbox with a child for each item value of interest. +!-- The partial assumes a variable item to be given in the context. +!-- +!-- @param item: hand over the item to the partial as hash parameter +!-- @param partial-block: hand over custom children of the flexbox in the partial block. +--}} +{{#*inline "talentListEntry"}} +
  • + {{!-- image --}} +
    + +
    + {{!-- name --}} + +
    + {{!-- acquired rank --}} + {{> talentRankValue item=item property='base' localizeString='DS4.TalentRankBase'}} + ( of + {{!-- maximum acquirable rank --}} + {{> talentRankValue item=item property='max' localizeString='DS4.TalentRankMax'}} + ) + + {{!-- additional ranks --}} + {{> talentRankValue item=item property='mod' localizeString='DS4.TalentRankMod'}} + = + {{!-- derived total rank --}} + {{item.data.data.talentRank.total}} +
    + {{!-- description --}} +
    {{{item.data.data.description}}}
    + {{!-- control buttons --}} + {{> itemControlButtons}} +
  • +{{/inline}} + + +{{!-- ======================================================================== --}} + + +
    +
      +
    1. + {{!-- image --}} +
      + {{!-- name --}} +
      {{localize 'DS4.ItemName'}}
      + {{!-- rank info --}} +
      {{localize 'DS4.TalentRank'}}
      + {{!-- description --}} +
      {{localize 'DS4.Description'}}
      + {{!-- add button --}} + {{> addItemButton dataType='talent' }} +
    2. + {{#each itemsByType.talent as |item id|}} + {{> talentListEntry item=item}} + {{/each}} +
    +
    \ No newline at end of file diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs new file mode 100644 index 00000000..400999c7 --- /dev/null +++ b/src/templates/item/talent-sheet.hbs @@ -0,0 +1,63 @@ + +{{#*inline "talentRankSideProperty" }} +
    + + +
    +{{/inline}} + + +
    +
    + +
    +

    +

    {{localize (lookup config.itemTypes item.type)}}

    +
    +
    + + {{!-- Sheet Tab Navigation --}} + + + {{!-- Sheet Body --}} +
    + {{!-- The item tab for details. --}} +
    + {{!-- As you add new fields, add them in here! --}} +
    + {{!-- TODO: remove duplication of isOwned section here and in description.hbs--}} + {{#if isOwned}} + {{#if (ne data.equipped undefined)}}
    + + +
    + {{/if}} +
    + + {{actor.name}} +
    + {{else}} + {{localize "DS4.NotOwned"}} + {{/if}} + {{> talentRankSideProperty data=data property='base' localizeString='DS4.TalentRankBase' }} + {{> talentRankSideProperty data=data property='max' localizeString='DS4.TalentRankMax'}} + {{> talentRankSideProperty data=data property='mod' localizeString='DS4.TalentRankMod'}} + {{> talentRankSideProperty data=data property='total' localizeString='DS4.TalentRankTotal' disabled='disabled'}} +
    +
    + {{editor content=data.description target="data.description" button=true owner=owner editable=editable}} +
    +
    + +
    + + {{!-- Effects Tab --}} + {{> systems/ds4/templates/item/partials/effects.hbs}} + +
    From 6d02f1623a9b7cc8ede66057150bd384203a6b67 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Wed, 6 Jan 2021 01:30:21 +0100 Subject: [PATCH 10/32] reference a version tag in the download url --- src/system.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/system.json b/src/system.json index 43f2245b..a57664c3 100644 --- a/src/system.json +++ b/src/system.json @@ -22,7 +22,7 @@ "gridUnits": "m", "primaryTokenAttribute": "combatValues.hitPoints.current", "url": "https://git.f3l.de/dungeonslayers/ds4", - "manifest": "https://git.f3l.de/dungeonslayers/ds4/-/raw/latest/src/system.json?inline=false", - "download": "https://git.f3l.de/dungeonslayers/ds4/-/jobs/artifacts/latest/download?job=build", + "manifest": "https://git.f3l.de/dungeonslayers/ds4/-/raw/master/src/system.json?inline=false", + "download": "https://git.f3l.de/dungeonslayers/ds4/-/jobs/artifacts/0.1.0/download?job=build", "license": "MIT" } From b4f697f9cc1dee8b4604a56d9ed3e8bfeae99750 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Wed, 6 Jan 2021 01:31:23 +0100 Subject: [PATCH 11/32] format gulpfile --- gulpfile.js | 858 ++++++++++++++++++++++++++-------------------------- 1 file changed, 429 insertions(+), 429 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 83aa3820..dc62e8b7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,429 +1,429 @@ -const gulp = require("gulp"); -const fs = require("fs-extra"); -const path = require("path"); -const chalk = require("chalk"); -const archiver = require("archiver"); -const stringify = require("json-stringify-pretty-compact"); -const typescript = require("typescript"); - -const ts = require("gulp-typescript"); -const less = require("gulp-less"); -const sass = require("gulp-sass"); -const git = require("gulp-git"); - -const argv = require("yargs").argv; - -sass.compiler = require("sass"); - -function getConfig() { - const configPath = path.resolve(process.cwd(), "foundryconfig.json"); - let config; - - if (fs.existsSync(configPath)) { - config = fs.readJSONSync(configPath); - return config; - } else { - return; - } -} - -function getManifest() { - const json = {}; - - if (fs.existsSync("src")) { - json.root = "src"; - } else { - json.root = "dist"; - } - - const modulePath = path.join(json.root, "module.json"); - const systemPath = path.join(json.root, "system.json"); - - if (fs.existsSync(modulePath)) { - json.file = fs.readJSONSync(modulePath); - json.name = "module.json"; - } else if (fs.existsSync(systemPath)) { - json.file = fs.readJSONSync(systemPath); - json.name = "system.json"; - } else { - return; - } - - return json; -} - -/** - * TypeScript transformers - * @returns {typescript.TransformerFactory} - */ -function createTransformer() { - /** - * @param {typescript.Node} node - */ - function shouldMutateModuleSpecifier(node) { - if (!typescript.isImportDeclaration(node) && !typescript.isExportDeclaration(node)) return false; - if (node.moduleSpecifier === undefined) return false; - if (!typescript.isStringLiteral(node.moduleSpecifier)) return false; - if (!node.moduleSpecifier.text.startsWith("./") && !node.moduleSpecifier.text.startsWith("../")) return false; - if (path.extname(node.moduleSpecifier.text) !== "") return false; - return true; - } - - /** - * Transforms import/export declarations to append `.js` extension - * @param {typescript.TransformationContext} context - */ - function importTransformer(context) { - return (node) => { - /** - * @param {typescript.Node} node - */ - function visitor(node) { - if (shouldMutateModuleSpecifier(node)) { - if (typescript.isImportDeclaration(node)) { - const newModuleSpecifier = typescript.createLiteral(`${node.moduleSpecifier.text}.js`); - return typescript.updateImportDeclaration( - node, - node.decorators, - node.modifiers, - node.importClause, - newModuleSpecifier - ); - } else if (typescript.isExportDeclaration(node)) { - const newModuleSpecifier = typescript.createLiteral(`${node.moduleSpecifier.text}.js`); - return typescript.updateExportDeclaration( - node, - node.decorators, - node.modifiers, - node.exportClause, - newModuleSpecifier - ); - } - } - return typescript.visitEachChild(node, visitor, context); - } - - return typescript.visitNode(node, visitor); - }; - } - - return importTransformer; -} - -const tsConfig = ts.createProject("tsconfig.json", { - getCustomTransformers: (_program) => ({ - after: [createTransformer()], - }), -}); - -/********************/ -/* BUILD */ -/********************/ - -/** - * Build TypeScript - */ -function buildTS() { - return gulp.src("src/**/*.ts").pipe(tsConfig()).pipe(gulp.dest("dist")); -} - -/** - * Build Less - */ -function buildLess() { - return gulp.src("src/*.less").pipe(less()).pipe(gulp.dest("dist")); -} - -/** - * Build SASS - */ -function buildSASS() { - return gulp.src("src/*.scss").pipe(sass().on("error", sass.logError)).pipe(gulp.dest("dist")); -} - -/** - * Copy static files - */ -async function copyFiles() { - const statics = ["lang", "fonts", "assets", "templates", "module.json", "system.json", "template.json"]; - try { - for (const file of statics) { - if (fs.existsSync(path.join("src", file))) { - await fs.copy(path.join("src", file), path.join("dist", file)); - } - } - return Promise.resolve(); - } catch (err) { - Promise.reject(err); - } -} - -/** - * Watch for changes for each build step - */ -function buildWatch() { - gulp.watch("src/**/*.ts", { ignoreInitial: false }, buildTS); - gulp.watch("src/**/*.less", { ignoreInitial: false }, buildLess); - gulp.watch("src/**/*.scss", { ignoreInitial: false }, buildSASS); - gulp.watch(["src/fonts", "src/lang", "src/templates", "src/*.json"], { ignoreInitial: false }, copyFiles); -} - -/********************/ -/* CLEAN */ -/********************/ - -/** - * Remove built files from `dist` folder - * while ignoring source files - */ -async function clean() { - const name = path.basename(path.resolve(".")); - const files = []; - - // If the project uses TypeScript - if (fs.existsSync(path.join("src", `${name}.ts`))) { - files.push( - "lang", - "templates", - "assets", - "module", - `${name}.js`, - "module.json", - "system.json", - "template.json" - ); - } - - // If the project uses Less or SASS - if (fs.existsSync(path.join("src", `${name}.less`)) || fs.existsSync(path.join("src", `${name}.scss`))) { - files.push("fonts", `${name}.css`); - } - - console.log(" ", chalk.yellow("Files to clean:")); - console.log(" ", chalk.blueBright(files.join("\n "))); - - // Attempt to remove the files - try { - for (const filePath of files) { - await fs.remove(path.join("dist", filePath)); - } - return Promise.resolve(); - } catch (err) { - Promise.reject(err); - } -} - -/********************/ -/* LINK */ -/********************/ - -/** - * Link build to User Data folder - */ -async function linkUserData() { - const name = path.basename(path.resolve(".")); - const config = fs.readJSONSync("foundryconfig.json"); - - let destDir; - try { - if ( - fs.existsSync(path.resolve(".", "dist", "module.json")) || - fs.existsSync(path.resolve(".", "src", "module.json")) - ) { - destDir = "modules"; - } else if ( - fs.existsSync(path.resolve(".", "dist", "system.json")) || - fs.existsSync(path.resolve(".", "src", "system.json")) - ) { - destDir = "systems"; - } else { - throw Error(`Could not find ${chalk.blueBright("module.json")} or ${chalk.blueBright("system.json")}`); - } - - let linkDir; - if (config.dataPath) { - if (!fs.existsSync(path.join(config.dataPath, "Data"))) - throw Error("User Data path invalid, no Data directory found"); - - linkDir = path.join(config.dataPath, "Data", destDir, name); - } else { - throw Error("No User Data path defined in foundryconfig.json"); - } - - if (argv.clean || argv.c) { - console.log(chalk.yellow(`Removing build in ${chalk.blueBright(linkDir)}`)); - - await fs.remove(linkDir); - } else if (!fs.existsSync(linkDir)) { - console.log(chalk.green(`Copying build to ${chalk.blueBright(linkDir)}`)); - await fs.symlink(path.resolve("./dist"), linkDir); - } - return Promise.resolve(); - } catch (err) { - Promise.reject(err); - } -} - -/*********************/ -/* PACKAGE */ -/*********************/ - -/** - * Package build - */ -async function packageBuild() { - const manifest = getManifest(); - - return new Promise((resolve, reject) => { - try { - // Remove the package dir without doing anything else - if (argv.clean || argv.c) { - console.log(chalk.yellow("Removing all packaged files")); - fs.removeSync("package"); - return; - } - - // Ensure there is a directory to hold all the packaged versions - fs.ensureDirSync("package"); - - // Initialize the zip file - const zipName = `${manifest.file.name}-v${manifest.file.version}.zip`; - const zipFile = fs.createWriteStream(path.join("package", zipName)); - const zip = archiver("zip", { zlib: { level: 9 } }); - - zipFile.on("close", () => { - console.log(chalk.green(zip.pointer() + " total bytes")); - console.log(chalk.green(`Zip file ${zipName} has been written`)); - return resolve(); - }); - - zip.on("error", (err) => { - throw err; - }); - - zip.pipe(zipFile); - - // Add the directory with the final code - zip.directory("dist/", manifest.file.name); - - zip.finalize(); - } catch (err) { - return reject(err); - } - }); -} - -/*********************/ -/* PACKAGE */ -/*********************/ - -/** - * Update version and URLs in the manifest JSON - */ -function updateManifest(cb) { - const packageJson = fs.readJSONSync("package.json"); - const config = getConfig(), - manifest = getManifest(), - rawURL = config.rawURL, - repoURL = config.repository, - manifestRoot = manifest.root; - - if (!config) cb(Error(chalk.red("foundryconfig.json not found"))); - if (!manifest) cb(Error(chalk.red("Manifest JSON not found"))); - if (!rawURL || !repoURL) cb(Error(chalk.red("Repository URLs not configured in foundryconfig.json"))); - - try { - const version = argv.update || argv.u; - - /* Update version */ - - const versionMatch = /^(\d{1,}).(\d{1,}).(\d{1,})$/; - const currentVersion = manifest.file.version; - let targetVersion = ""; - - if (!version) { - cb(Error("Missing version number")); - } - - if (versionMatch.test(version)) { - targetVersion = version; - } else { - targetVersion = currentVersion.replace(versionMatch, (substring, major, minor, patch) => { - console.log(substring, Number(major) + 1, Number(minor) + 1, Number(patch) + 1); - if (version === "major") { - return `${Number(major) + 1}.0.0`; - } else if (version === "minor") { - return `${major}.${Number(minor) + 1}.0`; - } else if (version === "patch") { - return `${major}.${minor}.${Number(patch) + 1}`; - } else { - return ""; - } - }); - } - - if (targetVersion === "") { - return cb(Error(chalk.red("Error: Incorrect version arguments."))); - } - - if (targetVersion === currentVersion) { - return cb(Error(chalk.red("Error: Target version is identical to current version."))); - } - console.log(`Updating version number to '${targetVersion}'`); - - packageJson.version = targetVersion; - manifest.file.version = targetVersion; - - /* Update URLs */ - - const result = `${rawURL}/v${manifest.file.version}/package/${manifest.file.name}-v${manifest.file.version}.zip`; - - manifest.file.url = repoURL; - manifest.file.manifest = `${rawURL}/master/${manifestRoot}/${manifest.name}`; - manifest.file.download = result; - - const prettyProjectJson = stringify(manifest.file, { - maxLength: 35, - indent: "\t", - }); - - fs.writeJSONSync("package.json", packageJson, { spaces: "\t" }); - fs.writeFileSync(path.join(manifest.root, manifest.name), prettyProjectJson, "utf8"); - - return cb(); - } catch (err) { - cb(err); - } -} - -function gitAdd() { - return gulp.src("package").pipe(git.add({ args: "--no-all" })); -} - -function gitCommit() { - return gulp.src("./*").pipe( - git.commit(`v${getManifest().file.version}`, { - args: "-a", - disableAppendPaths: true, - }) - ); -} - -function gitTag() { - const manifest = getManifest(); - return git.tag(`v${manifest.file.version}`, `Updated to ${manifest.file.version}`, (err) => { - if (err) throw err; - }); -} - -const execGit = gulp.series(gitAdd, gitCommit, gitTag); - -const execBuild = gulp.parallel(buildTS, buildLess, buildSASS, copyFiles); - -exports.build = gulp.series(clean, execBuild); -exports.watch = buildWatch; -exports.clean = clean; -exports.link = linkUserData; -exports.package = packageBuild; -exports.update = updateManifest; -exports.publish = gulp.series(clean, updateManifest, execBuild, packageBuild, execGit); +const gulp = require("gulp"); +const fs = require("fs-extra"); +const path = require("path"); +const chalk = require("chalk"); +const archiver = require("archiver"); +const stringify = require("json-stringify-pretty-compact"); +const typescript = require("typescript"); + +const ts = require("gulp-typescript"); +const less = require("gulp-less"); +const sass = require("gulp-sass"); +const git = require("gulp-git"); + +const argv = require("yargs").argv; + +sass.compiler = require("sass"); + +function getConfig() { + const configPath = path.resolve(process.cwd(), "foundryconfig.json"); + let config; + + if (fs.existsSync(configPath)) { + config = fs.readJSONSync(configPath); + return config; + } else { + return; + } +} + +function getManifest() { + const json = {}; + + if (fs.existsSync("src")) { + json.root = "src"; + } else { + json.root = "dist"; + } + + const modulePath = path.join(json.root, "module.json"); + const systemPath = path.join(json.root, "system.json"); + + if (fs.existsSync(modulePath)) { + json.file = fs.readJSONSync(modulePath); + json.name = "module.json"; + } else if (fs.existsSync(systemPath)) { + json.file = fs.readJSONSync(systemPath); + json.name = "system.json"; + } else { + return; + } + + return json; +} + +/** + * TypeScript transformers + * @returns {typescript.TransformerFactory} + */ +function createTransformer() { + /** + * @param {typescript.Node} node + */ + function shouldMutateModuleSpecifier(node) { + if (!typescript.isImportDeclaration(node) && !typescript.isExportDeclaration(node)) return false; + if (node.moduleSpecifier === undefined) return false; + if (!typescript.isStringLiteral(node.moduleSpecifier)) return false; + if (!node.moduleSpecifier.text.startsWith("./") && !node.moduleSpecifier.text.startsWith("../")) return false; + if (path.extname(node.moduleSpecifier.text) !== "") return false; + return true; + } + + /** + * Transforms import/export declarations to append `.js` extension + * @param {typescript.TransformationContext} context + */ + function importTransformer(context) { + return (node) => { + /** + * @param {typescript.Node} node + */ + function visitor(node) { + if (shouldMutateModuleSpecifier(node)) { + if (typescript.isImportDeclaration(node)) { + const newModuleSpecifier = typescript.createLiteral(`${node.moduleSpecifier.text}.js`); + return typescript.updateImportDeclaration( + node, + node.decorators, + node.modifiers, + node.importClause, + newModuleSpecifier, + ); + } else if (typescript.isExportDeclaration(node)) { + const newModuleSpecifier = typescript.createLiteral(`${node.moduleSpecifier.text}.js`); + return typescript.updateExportDeclaration( + node, + node.decorators, + node.modifiers, + node.exportClause, + newModuleSpecifier, + ); + } + } + return typescript.visitEachChild(node, visitor, context); + } + + return typescript.visitNode(node, visitor); + }; + } + + return importTransformer; +} + +const tsConfig = ts.createProject("tsconfig.json", { + getCustomTransformers: (_program) => ({ + after: [createTransformer()], + }), +}); + +/********************/ +/* BUILD */ +/********************/ + +/** + * Build TypeScript + */ +function buildTS() { + return gulp.src("src/**/*.ts").pipe(tsConfig()).pipe(gulp.dest("dist")); +} + +/** + * Build Less + */ +function buildLess() { + return gulp.src("src/*.less").pipe(less()).pipe(gulp.dest("dist")); +} + +/** + * Build SASS + */ +function buildSASS() { + return gulp.src("src/*.scss").pipe(sass().on("error", sass.logError)).pipe(gulp.dest("dist")); +} + +/** + * Copy static files + */ +async function copyFiles() { + const statics = ["lang", "fonts", "assets", "templates", "module.json", "system.json", "template.json"]; + try { + for (const file of statics) { + if (fs.existsSync(path.join("src", file))) { + await fs.copy(path.join("src", file), path.join("dist", file)); + } + } + return Promise.resolve(); + } catch (err) { + Promise.reject(err); + } +} + +/** + * Watch for changes for each build step + */ +function buildWatch() { + gulp.watch("src/**/*.ts", { ignoreInitial: false }, buildTS); + gulp.watch("src/**/*.less", { ignoreInitial: false }, buildLess); + gulp.watch("src/**/*.scss", { ignoreInitial: false }, buildSASS); + gulp.watch(["src/fonts", "src/lang", "src/templates", "src/*.json"], { ignoreInitial: false }, copyFiles); +} + +/********************/ +/* CLEAN */ +/********************/ + +/** + * Remove built files from `dist` folder + * while ignoring source files + */ +async function clean() { + const name = path.basename(path.resolve(".")); + const files = []; + + // If the project uses TypeScript + if (fs.existsSync(path.join("src", `${name}.ts`))) { + files.push( + "lang", + "templates", + "assets", + "module", + `${name}.js`, + "module.json", + "system.json", + "template.json", + ); + } + + // If the project uses Less or SASS + if (fs.existsSync(path.join("src", `${name}.less`)) || fs.existsSync(path.join("src", `${name}.scss`))) { + files.push("fonts", `${name}.css`); + } + + console.log(" ", chalk.yellow("Files to clean:")); + console.log(" ", chalk.blueBright(files.join("\n "))); + + // Attempt to remove the files + try { + for (const filePath of files) { + await fs.remove(path.join("dist", filePath)); + } + return Promise.resolve(); + } catch (err) { + Promise.reject(err); + } +} + +/********************/ +/* LINK */ +/********************/ + +/** + * Link build to User Data folder + */ +async function linkUserData() { + const name = path.basename(path.resolve(".")); + const config = fs.readJSONSync("foundryconfig.json"); + + let destDir; + try { + if ( + fs.existsSync(path.resolve(".", "dist", "module.json")) || + fs.existsSync(path.resolve(".", "src", "module.json")) + ) { + destDir = "modules"; + } else if ( + fs.existsSync(path.resolve(".", "dist", "system.json")) || + fs.existsSync(path.resolve(".", "src", "system.json")) + ) { + destDir = "systems"; + } else { + throw Error(`Could not find ${chalk.blueBright("module.json")} or ${chalk.blueBright("system.json")}`); + } + + let linkDir; + if (config.dataPath) { + if (!fs.existsSync(path.join(config.dataPath, "Data"))) + throw Error("User Data path invalid, no Data directory found"); + + linkDir = path.join(config.dataPath, "Data", destDir, name); + } else { + throw Error("No User Data path defined in foundryconfig.json"); + } + + if (argv.clean || argv.c) { + console.log(chalk.yellow(`Removing build in ${chalk.blueBright(linkDir)}`)); + + await fs.remove(linkDir); + } else if (!fs.existsSync(linkDir)) { + console.log(chalk.green(`Copying build to ${chalk.blueBright(linkDir)}`)); + await fs.symlink(path.resolve("./dist"), linkDir); + } + return Promise.resolve(); + } catch (err) { + Promise.reject(err); + } +} + +/*********************/ +/* PACKAGE */ +/*********************/ + +/** + * Package build + */ +async function packageBuild() { + const manifest = getManifest(); + + return new Promise((resolve, reject) => { + try { + // Remove the package dir without doing anything else + if (argv.clean || argv.c) { + console.log(chalk.yellow("Removing all packaged files")); + fs.removeSync("package"); + return; + } + + // Ensure there is a directory to hold all the packaged versions + fs.ensureDirSync("package"); + + // Initialize the zip file + const zipName = `${manifest.file.name}-v${manifest.file.version}.zip`; + const zipFile = fs.createWriteStream(path.join("package", zipName)); + const zip = archiver("zip", { zlib: { level: 9 } }); + + zipFile.on("close", () => { + console.log(chalk.green(zip.pointer() + " total bytes")); + console.log(chalk.green(`Zip file ${zipName} has been written`)); + return resolve(); + }); + + zip.on("error", (err) => { + throw err; + }); + + zip.pipe(zipFile); + + // Add the directory with the final code + zip.directory("dist/", manifest.file.name); + + zip.finalize(); + } catch (err) { + return reject(err); + } + }); +} + +/*********************/ +/* PACKAGE */ +/*********************/ + +/** + * Update version and URLs in the manifest JSON + */ +function updateManifest(cb) { + const packageJson = fs.readJSONSync("package.json"); + const config = getConfig(), + manifest = getManifest(), + rawURL = config.rawURL, + repoURL = config.repository, + manifestRoot = manifest.root; + + if (!config) cb(Error(chalk.red("foundryconfig.json not found"))); + if (!manifest) cb(Error(chalk.red("Manifest JSON not found"))); + if (!rawURL || !repoURL) cb(Error(chalk.red("Repository URLs not configured in foundryconfig.json"))); + + try { + const version = argv.update || argv.u; + + /* Update version */ + + const versionMatch = /^(\d{1,}).(\d{1,}).(\d{1,})$/; + const currentVersion = manifest.file.version; + let targetVersion = ""; + + if (!version) { + cb(Error("Missing version number")); + } + + if (versionMatch.test(version)) { + targetVersion = version; + } else { + targetVersion = currentVersion.replace(versionMatch, (substring, major, minor, patch) => { + console.log(substring, Number(major) + 1, Number(minor) + 1, Number(patch) + 1); + if (version === "major") { + return `${Number(major) + 1}.0.0`; + } else if (version === "minor") { + return `${major}.${Number(minor) + 1}.0`; + } else if (version === "patch") { + return `${major}.${minor}.${Number(patch) + 1}`; + } else { + return ""; + } + }); + } + + if (targetVersion === "") { + return cb(Error(chalk.red("Error: Incorrect version arguments."))); + } + + if (targetVersion === currentVersion) { + return cb(Error(chalk.red("Error: Target version is identical to current version."))); + } + console.log(`Updating version number to '${targetVersion}'`); + + packageJson.version = targetVersion; + manifest.file.version = targetVersion; + + /* Update URLs */ + + const result = `${rawURL}/v${manifest.file.version}/package/${manifest.file.name}-v${manifest.file.version}.zip`; + + manifest.file.url = repoURL; + manifest.file.manifest = `${rawURL}/master/${manifestRoot}/${manifest.name}`; + manifest.file.download = result; + + const prettyProjectJson = stringify(manifest.file, { + maxLength: 35, + indent: "\t", + }); + + fs.writeJSONSync("package.json", packageJson, { spaces: "\t" }); + fs.writeFileSync(path.join(manifest.root, manifest.name), prettyProjectJson, "utf8"); + + return cb(); + } catch (err) { + cb(err); + } +} + +function gitAdd() { + return gulp.src("package").pipe(git.add({ args: "--no-all" })); +} + +function gitCommit() { + return gulp.src("./*").pipe( + git.commit(`v${getManifest().file.version}`, { + args: "-a", + disableAppendPaths: true, + }), + ); +} + +function gitTag() { + const manifest = getManifest(); + return git.tag(`v${manifest.file.version}`, `Updated to ${manifest.file.version}`, (err) => { + if (err) throw err; + }); +} + +const execGit = gulp.series(gitAdd, gitCommit, gitTag); + +const execBuild = gulp.parallel(buildTS, buildLess, buildSASS, copyFiles); + +exports.build = gulp.series(clean, execBuild); +exports.watch = buildWatch; +exports.clean = clean; +exports.link = linkUserData; +exports.package = packageBuild; +exports.update = updateManifest; +exports.publish = gulp.series(clean, updateManifest, execBuild, packageBuild, execGit); From fed3209c5803b5d10a004102b7059576585a3379 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Wed, 6 Jan 2021 03:22:25 +0100 Subject: [PATCH 12/32] update the readme --- README.md | 73 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 56 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 8119bbdb..4222e363 100644 --- a/README.md +++ b/README.md @@ -3,50 +3,89 @@ An implementation of the Dungeonslayers 4 game system for [Foundry Virtual Tabletop](http://foundryvtt.com). -## Prerequisites +This system provides character sheet support for Actors and Items and mechanical +support for dice and rules necessary to +play games of Dungeponslayers 4. -In order to build this system, a recent version of `npm` is required. +## Installation -## Building +To install and use the Dungeonslayers 4 system for Foundry Virtual Tabletop, +simply paste the following URL into the **Install System** dialog on the Setup +menu of the application. -To build the system, first install all required dependencies: +https://git.f3l.de/dungeonslayers/ds4/-/raw/master/src/system.json?inline=false + +## Development + +### Prerequisits + +In order to build this system, recent versions of `node` and `npm` are required. +We recommend using the latest lts version of `node`, which is `v14.15.4` at the +time of writing. If you use `nvm` to manage your `node` versions, you can simply +run +``` +nvm install +``` + +in the project's root directory. + +You also need to install the the project's dependencies. To do so, run ``` npm install ``` -Then build the project by running +### Building + +You can build the project by running ``` npm run build ``` -If you'd like the built system to be automatically linked to your local Foundry -VTT installation's data folder, add a file called `foundryconfig.json` to the -project root with the following contents: +Alternatively, you can run + +``` +npm run build:watch +``` + +to watch for changes and automatically build as necessary. + +### Linking the built system to Foundry VTT + +In order to provide a fluent development experience, it is recommended to link +the built system to your local Foundry VTT installation's data folder. In order +to do so, first add a file called `foundryconfig.json` to the project root with +the following content: ``` { - "dataPath": "//.local/share/FoundryVTT", - "repository": "", - "rawURL": "" + "dataPath": "/.local/share/FoundryVTT" } ``` +On platforms other than Linux you need to adjust the path accordingly. + Then run ``` npm run link ``` -If you want the system to be continuously build upon every saved change, just -run +### Running the tests + +You can run the tests with the following command: ``` -npm run build:watch +npm test ``` -# Licensing +## Contributing + +Code and content contributions are accepted. Please feel free to submit issues +to the issue tracker or submit merge requests for code changes. + +## Licensing Dungeonslayers (© Christian Kennig) is licensed under [CC BY-NC-SA 3.0](https://creativecommons.org/licenses/by-nc-sa/3.0/de/deed.en). @@ -56,5 +95,5 @@ CC BY-NC-SA 3.0. Hence the modified icons are also published under this license. A copy of this license can be found under [src/assets/official/LICENSE](src/assets/official/LICENSE). -The rest of this project is licensed under the MIT License, a copy of which can -be found under [LICENSE](LICENSE). +The software component of this project is licensed under the MIT License, a copy +of which can be found under [LICENSE](LICENSE). From 637b70c5d2364c51007f93e506c3d3247481a6e8 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 11:39:39 +0100 Subject: [PATCH 13/32] added invalidity hints to item side-properties - added :invalid definition to side-properties CSS - defined common color for invalidity - now using disabled input for automatically calculated properties --- src/scss/components/_description.scss | 7 ++++++- src/scss/components/_items.scss | 7 ++++--- src/scss/utils/_colors.scss | 1 + src/templates/actor/partials/talents-overview.hbs | 3 ++- src/templates/item/partials/description.hbs | 4 ++-- src/templates/item/talent-sheet.hbs | 7 +++++++ 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/scss/components/_description.scss b/src/scss/components/_description.scss index 8bd3b18b..72080381 100644 --- a/src/scss/components/_description.scss +++ b/src/scss/components/_description.scss @@ -22,7 +22,12 @@ text-align: left; width: calc(100% - 2px); } - + input:invalid { + background-color: $c-invalid-input; + } + input:disabled { + background-color: transparent; + } input[type="checkbox"] { width: auto; height: 100%; diff --git a/src/scss/components/_items.scss b/src/scss/components/_items.scss index 4dd97f78..fea61e0c 100644 --- a/src/scss/components/_items.scss +++ b/src/scss/components/_items.scss @@ -31,6 +31,7 @@ input { border: 0; padding: 0; + background-color: transparent; } input[type="checkbox"] { @@ -38,6 +39,9 @@ height: 100%; margin: 0px; } + input:invalid { + background-color: $c-invalid-input; + } } .item-name { @@ -54,9 +58,6 @@ width: 2.5em; padding: 0; } - .item-num-val:invalid { - background-color: color.mix(lightcoral, $c-light-grey, 25%); - } .item-description { font-size: 75%; diff --git a/src/scss/utils/_colors.scss b/src/scss/utils/_colors.scss index 7a2200d1..55fb8c0a 100644 --- a/src/scss/utils/_colors.scss +++ b/src/scss/utils/_colors.scss @@ -2,3 +2,4 @@ $c-white: #fff; $c-black: #000; $c-light-grey: #777; $c-border-groove: #eeede0; +$c-invalid-input: rgba(lightcoral, 50%); diff --git a/src/templates/actor/partials/talents-overview.hbs b/src/templates/actor/partials/talents-overview.hbs index 03a9335d..81839750 100644 --- a/src/templates/actor/partials/talents-overview.hbs +++ b/src/templates/actor/partials/talents-overview.hbs @@ -29,6 +29,7 @@ {{#*inline "talentRankValue"}} {{/inline}} @@ -61,7 +62,7 @@ {{> talentRankValue item=item property='mod' localizeString='DS4.TalentRankMod'}} = {{!-- derived total rank --}} - {{item.data.data.talentRank.total}} + {{> talentRankValue item=item property='total' localizeString='DS4.TalentRankTotal' disabled='disabled'}} {{!-- description --}}
    {{{item.data.data.description}}}
    diff --git a/src/templates/item/partials/description.hbs b/src/templates/item/partials/description.hbs index 1776f1f2..c1c7ae26 100644 --- a/src/templates/item/partials/description.hbs +++ b/src/templates/item/partials/description.hbs @@ -20,10 +20,10 @@ {{else}} - {{localize "DS4.NotOwned"}} + {{localize "DS4.NotOwned"}} {{/if}} -
    +
    {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
    \ No newline at end of file diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs index 400999c7..27529f06 100644 --- a/src/templates/item/talent-sheet.hbs +++ b/src/templates/item/talent-sheet.hbs @@ -1,3 +1,7 @@ +{{!-- ======================================================================== --}} +{{!-- INLINE PARTIAL DEFINITIONS --}} +{{!-- ======================================================================== --}} + {{#*inline "talentRankSideProperty" }}
    @@ -9,6 +13,9 @@ {{/inline}} +{{!-- ======================================================================== --}} + +
    From c98c64de1ef74bcdb72a1bbe41db478e6ad5971a Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 11:35:56 +0100 Subject: [PATCH 14/32] Apply 1 suggestion(s) to 1 file(s) --- src/module/item/item-data.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/module/item/item-data.ts b/src/module/item/item-data.ts index a2cbc61b..4bf5f16d 100644 --- a/src/module/item/item-data.ts +++ b/src/module/item/item-data.ts @@ -1,6 +1,5 @@ import { ModifiableData } from "../actor/actor-data"; -// TODO: Actually add a type for data export type DS4ItemDataType = DS4Weapon | DS4Armor | DS4Shield | DS4Trinket | DS4Equipment | DS4Talent; // types From 17b5eee90250afbc9d4dee3943dcfe660d9653f5 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 11:36:06 +0100 Subject: [PATCH 15/32] Apply 1 suggestion(s) to 1 file(s) --- src/module/item/item.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/item/item.ts b/src/module/item/item.ts index 814a6e15..2859aedf 100644 --- a/src/module/item/item.ts +++ b/src/module/item/item.ts @@ -22,7 +22,7 @@ export class DS4Item extends Item { prepareDerivedData(): void { if (this.type === "talent") { - const data: DS4Talent = this.data.data as DS4Talent; + const data = this.data.data as DS4Talent; data.talentRank.total = data.talentRank.base + data.talentRank.mod; } } From 98f31d9e8c13c9d613c3999b66c3229686370e08 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 11:52:11 +0100 Subject: [PATCH 16/32] renamed talent property from talentRank to rank --- src/module/item/item-data.ts | 2 +- src/module/item/item.ts | 2 +- src/template.json | 2 +- src/templates/actor/partials/talents-overview.hbs | 5 +++-- src/templates/item/talent-sheet.hbs | 6 +++--- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/module/item/item-data.ts b/src/module/item/item-data.ts index 4bf5f16d..be1a0042 100644 --- a/src/module/item/item-data.ts +++ b/src/module/item/item-data.ts @@ -16,7 +16,7 @@ interface DS4Armor extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable, DS4It } export interface DS4Talent extends DS4ItemBase { - talentRank: DS4TalentRank; + rank: DS4TalentRank; } interface DS4TalentRank extends ModifiableData { diff --git a/src/module/item/item.ts b/src/module/item/item.ts index 2859aedf..e9a1aa3e 100644 --- a/src/module/item/item.ts +++ b/src/module/item/item.ts @@ -23,7 +23,7 @@ export class DS4Item extends Item { prepareDerivedData(): void { if (this.type === "talent") { const data = this.data.data as DS4Talent; - data.talentRank.total = data.talentRank.base + data.talentRank.mod; + data.rank.total = data.rank.base + data.rank.mod; } } } diff --git a/src/template.json b/src/template.json index f412936e..39b96699 100644 --- a/src/template.json +++ b/src/template.json @@ -140,7 +140,7 @@ }, "talent": { "templates": ["base"], - "talentRank": { + "rank": { "base": 0, "max": 0, "mod": 0 diff --git a/src/templates/actor/partials/talents-overview.hbs b/src/templates/actor/partials/talents-overview.hbs index 81839750..f70421e3 100644 --- a/src/templates/actor/partials/talents-overview.hbs +++ b/src/templates/actor/partials/talents-overview.hbs @@ -1,6 +1,7 @@ {{!-- ======================================================================== --}} {{!-- INLINE PARTIAL DEFINITIONS --}} {{!-- ======================================================================== --}} +{{!-- TODO: remove duplicate add and delete button definition --}} {{!-- !-- Render an "add" button for a given data type. @@ -28,9 +29,9 @@ {{#*inline "talentRankValue"}} {{/inline}} diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs index 27529f06..0c9dc198 100644 --- a/src/templates/item/talent-sheet.hbs +++ b/src/templates/item/talent-sheet.hbs @@ -5,10 +5,10 @@ {{#*inline "talentRankSideProperty" }}
    - + + {{#if (eq property 'base') }}max="{{data.rank.max}}"{{/if}} + name="data.rank.{{property}}" value="{{lookup data.rank property}}" />
    {{/inline}} From fb711bc02451fdb5643bc8d16c90f8dd4ce3e00f Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 12:02:40 +0100 Subject: [PATCH 17/32] unified keys for localizations for headings - keys now start with 'DS4.Heading' - removed unused DS4.DescriptionAbbr --- src/lang/en.json | 11 +++++------ src/templates/actor/actor-sheet.hbs | 6 +++--- src/templates/actor/partials/items-overview.hbs | 2 +- src/templates/actor/partials/talents-overview.hbs | 2 +- src/templates/item/partials/body.hbs | 6 +++--- src/templates/item/partials/description.hbs | 2 +- src/templates/item/talent-sheet.hbs | 6 +++--- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/lang/en.json b/src/lang/en.json index 5227291e..c77f7b2b 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -1,12 +1,11 @@ { "DS4.UserInteractionAddItem": "Add item", "DS4.NotOwned": "No owner", - "DS4.Description": "Description", - "DS4.DescriptionAbbr": "Desc", - "DS4.Details": "Details", - "DS4.Effects": "Effects", - "DS4.Items": "Items", - "DS4.Talents": "Talents & Abilities", + "DS4.HeadingDescription": "Description", + "DS4.HeadingDetails": "Details", + "DS4.HeadingEffects": "Effects", + "DS4.HeadingItems": "Items", + "DS4.HeadingTalents": "Talents & Abilities", "DS4.AttackType": "Attack Type", "DS4.AttackTypeAbbr": "AT", "DS4.WeaponBonus": "Weapon Bonus", diff --git a/src/templates/actor/actor-sheet.hbs b/src/templates/actor/actor-sheet.hbs index b22aae3b..be40d1fd 100644 --- a/src/templates/actor/actor-sheet.hbs +++ b/src/templates/actor/actor-sheet.hbs @@ -90,9 +90,9 @@ {{!-- Sheet Tab Navigation --}} {{!-- Sheet Body --}} diff --git a/src/templates/actor/partials/items-overview.hbs b/src/templates/actor/partials/items-overview.hbs index 0cc57faf..f3e5415d 100644 --- a/src/templates/actor/partials/items-overview.hbs +++ b/src/templates/actor/partials/items-overview.hbs @@ -55,7 +55,7 @@ {{!-- item type specifics --}} {{> @partial-block }} {{!-- description --}} -
    {{localize 'DS4.Description'}}
    +
    {{localize 'DS4.HeadingDescription'}}
    {{!-- add button --}} {{> addItemButton dataType=dataType }} diff --git a/src/templates/actor/partials/talents-overview.hbs b/src/templates/actor/partials/talents-overview.hbs index f70421e3..af259410 100644 --- a/src/templates/actor/partials/talents-overview.hbs +++ b/src/templates/actor/partials/talents-overview.hbs @@ -86,7 +86,7 @@ {{!-- rank info --}}
    {{localize 'DS4.TalentRank'}}
    {{!-- description --}} -
    {{localize 'DS4.Description'}}
    +
    {{localize 'DS4.HeadingDescription'}}
    {{!-- add button --}} {{> addItemButton dataType='talent' }} diff --git a/src/templates/item/partials/body.hbs b/src/templates/item/partials/body.hbs index 9b5cde20..9770815b 100644 --- a/src/templates/item/partials/body.hbs +++ b/src/templates/item/partials/body.hbs @@ -2,9 +2,9 @@ {{!-- Sheet Tab Navigation --}} {{!-- Sheet Body --}} diff --git a/src/templates/item/partials/description.hbs b/src/templates/item/partials/description.hbs index c1c7ae26..db3253bc 100644 --- a/src/templates/item/partials/description.hbs +++ b/src/templates/item/partials/description.hbs @@ -23,7 +23,7 @@ {{localize "DS4.NotOwned"}} {{/if}}
    -
    +
    {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
    \ No newline at end of file diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs index 0c9dc198..44bd17b0 100644 --- a/src/templates/item/talent-sheet.hbs +++ b/src/templates/item/talent-sheet.hbs @@ -27,8 +27,8 @@ {{!-- Sheet Tab Navigation --}} {{!-- Sheet Body --}} @@ -57,7 +57,7 @@ {{> talentRankSideProperty data=data property='mod' localizeString='DS4.TalentRankMod'}} {{> talentRankSideProperty data=data property='total' localizeString='DS4.TalentRankTotal' disabled='disabled'}} -
    +
    {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
    From 3ba5efb8a7755a0b234489eb8c0cc4a9c0795aa6 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 14:19:18 +0100 Subject: [PATCH 18/32] fixed wrong positioning of effects tab content --- src/templates/item/talent-sheet.hbs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs index 44bd17b0..0c987467 100644 --- a/src/templates/item/talent-sheet.hbs +++ b/src/templates/item/talent-sheet.hbs @@ -62,9 +62,9 @@ + {{!-- Effects Tab --}} + {{> systems/ds4/templates/item/partials/effects.hbs }} + - {{!-- Effects Tab --}} - {{> systems/ds4/templates/item/partials/effects.hbs}} - From 6e363b3a02c5b9211f471063fd7e32f0bfe17120 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Wed, 6 Jan 2021 14:48:48 +0100 Subject: [PATCH 19/32] add bug report issue template and improve feature request --- .gitlab/issue_templates/Bug Report.md | 0 .gitlab/issue_templates/Feature Request.md | 12 ++++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .gitlab/issue_templates/Bug Report.md diff --git a/.gitlab/issue_templates/Bug Report.md b/.gitlab/issue_templates/Bug Report.md new file mode 100644 index 00000000..e69de29b diff --git a/.gitlab/issue_templates/Feature Request.md b/.gitlab/issue_templates/Feature Request.md index f60644d2..d6dbe30b 100644 --- a/.gitlab/issue_templates/Feature Request.md +++ b/.gitlab/issue_templates/Feature Request.md @@ -1,9 +1,13 @@ -# Description +# Story As a …, I want … so that … +# Description + +Please add a more detailed description of the feature here. + # Acceptance criteria -* Criterion 1 -* Criterion 2 -* … +1. Criterion 1 +2. Criterion 2 +3. … From f40efedcd376ef2fd24c34785f7924efb2d2bb88 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Wed, 6 Jan 2021 14:56:50 +0100 Subject: [PATCH 20/32] add bug report template --- .gitlab/issue_templates/Bug Report.md | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.gitlab/issue_templates/Bug Report.md b/.gitlab/issue_templates/Bug Report.md index e69de29b..c209b177 100644 --- a/.gitlab/issue_templates/Bug Report.md +++ b/.gitlab/issue_templates/Bug Report.md @@ -0,0 +1,29 @@ +# Description + +Please describe the issue. + +# Steps to Reproduce + +1. ... +2. ... +3. ... + +# Expected Behavior + +Please describe the expected behavior. + +# Actual Behavior + +Please describe the actual behavior. + +# Additional Details + +These are optional, please add them if it makes sense. + +- ![Screenshot]() +- [Logfile]() +- ... + +# Possible Solutions + +If you have any suggestions on how to solve the issue, please add them here. From 874692ed5ceb889e89646432b0f23cb65cecc431 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 15:25:55 +0100 Subject: [PATCH 21/32] moved basic talent properties in talent-sheet head - a little bit better gridding of side-properties (still needs a rewrite) - common SCSS mixin for input field marking --- src/scss/components/_basic_property.scss | 11 +++++++++-- src/scss/components/_description.scss | 11 ++++------- src/scss/components/_items.scss | 5 ++--- src/scss/utils/_mixins.scss | 9 +++++++++ src/templates/item/talent-sheet.hbs | 16 +++++++++------- 5 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/scss/components/_basic_property.scss b/src/scss/components/_basic_property.scss index 6f725dad..813bf9b7 100644 --- a/src/scss/components/_basic_property.scss +++ b/src/scss/components/_basic_property.scss @@ -1,13 +1,20 @@ .basic-properties { flex: 0 0 100%; .basic-property { - .basic-property-label { + display: grid; + align-content: end; + + .basic-property-label, + & > label { font-weight: bold; } - .basic-property-select { + .basic-property-select, + & > select { display: block; width: 100%; } + + @include mark-invalid-or-disabled-input; } } diff --git a/src/scss/components/_description.scss b/src/scss/components/_description.scss index 72080381..084b1796 100644 --- a/src/scss/components/_description.scss +++ b/src/scss/components/_description.scss @@ -9,7 +9,7 @@ .side-property { margin: 2px 0; display: grid; - grid-template-columns: 40% auto; + grid-template-columns: minmax(30%, auto) auto; justify-content: left; label { @@ -22,12 +22,9 @@ text-align: left; width: calc(100% - 2px); } - input:invalid { - background-color: $c-invalid-input; - } - input:disabled { - background-color: transparent; - } + + @include mark-invalid-or-disabled-input; + input[type="checkbox"] { width: auto; height: 100%; diff --git a/src/scss/components/_items.scss b/src/scss/components/_items.scss index fea61e0c..6382c587 100644 --- a/src/scss/components/_items.scss +++ b/src/scss/components/_items.scss @@ -39,9 +39,8 @@ height: 100%; margin: 0px; } - input:invalid { - background-color: $c-invalid-input; - } + + @include mark-invalid-or-disabled-input; } .item-name { diff --git a/src/scss/utils/_mixins.scss b/src/scss/utils/_mixins.scss index 7e028c29..adc2e69a 100644 --- a/src/scss/utils/_mixins.scss +++ b/src/scss/utils/_mixins.scss @@ -19,3 +19,12 @@ display: grid; place-items: center; } + +@mixin mark-invalid-or-disabled-input { + input:invalid { + background-color: $c-invalid-input; + } + input:disabled { + background-color: transparent; + } +} diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs index 0c987467..d68f66c2 100644 --- a/src/templates/item/talent-sheet.hbs +++ b/src/templates/item/talent-sheet.hbs @@ -3,9 +3,9 @@ {{!-- ======================================================================== --}} -{{#*inline "talentRankSideProperty" }} -
    - +{{#*inline "talentRankBasicProperty" }} +
    + @@ -22,6 +22,12 @@

    {{localize (lookup config.itemTypes item.type)}}

    +
    + {{> talentRankBasicProperty data=data property='base' localizeString='DS4.TalentRankBase' }} + {{> talentRankBasicProperty data=data property='max' localizeString='DS4.TalentRankMax'}} + {{> talentRankBasicProperty data=data property='mod' localizeString='DS4.TalentRankMod'}} + {{> talentRankBasicProperty data=data property='total' localizeString='DS4.TalentRankTotal' disabled='disabled'}} +
    @@ -52,10 +58,6 @@ {{else}} {{localize "DS4.NotOwned"}} {{/if}} - {{> talentRankSideProperty data=data property='base' localizeString='DS4.TalentRankBase' }} - {{> talentRankSideProperty data=data property='max' localizeString='DS4.TalentRankMax'}} - {{> talentRankSideProperty data=data property='mod' localizeString='DS4.TalentRankMod'}} - {{> talentRankSideProperty data=data property='total' localizeString='DS4.TalentRankTotal' disabled='disabled'}}
    {{editor content=data.description target="data.description" button=true owner=owner editable=editable}} From 5bdfdd410b3ac62deffafb97abca91d7d9dd8e72 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 15:30:20 +0100 Subject: [PATCH 22/32] replace basic-property-* css classes by selectors --- src/scss/components/_basic_property.scss | 2 -- src/templates/item/armor-sheet.hbs | 12 ++++++------ src/templates/item/shield-sheet.hbs | 4 ++-- src/templates/item/talent-sheet.hbs | 2 +- src/templates/item/weapon-sheet.hbs | 12 ++++++------ 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/scss/components/_basic_property.scss b/src/scss/components/_basic_property.scss index 813bf9b7..c253964e 100644 --- a/src/scss/components/_basic_property.scss +++ b/src/scss/components/_basic_property.scss @@ -4,12 +4,10 @@ display: grid; align-content: end; - .basic-property-label, & > label { font-weight: bold; } - .basic-property-select, & > select { display: block; width: 100%; diff --git a/src/templates/item/armor-sheet.hbs b/src/templates/item/armor-sheet.hbs index a0a671dc..b7887131 100644 --- a/src/templates/item/armor-sheet.hbs +++ b/src/templates/item/armor-sheet.hbs @@ -6,8 +6,8 @@

    {{localize (lookup config.itemTypes item.type)}}

    - - {{#select data.armorType}} {{#each config.armorTypes as |value key|}} @@ -16,8 +16,8 @@
    - - {{#select data.armorMaterialType}} {{#each config.armorMaterialTypes as |value key|}} @@ -26,8 +26,8 @@
    - - {{localize "DS4.ArmorValue"}} +
    diff --git a/src/templates/item/shield-sheet.hbs b/src/templates/item/shield-sheet.hbs index 1e893d2a..ede89655 100644 --- a/src/templates/item/shield-sheet.hbs +++ b/src/templates/item/shield-sheet.hbs @@ -6,8 +6,8 @@

    {{localize (lookup config.itemTypes item.type)}}

    - - {{localize "DS4.ArmorValue"}} +
    diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs index d68f66c2..69c24137 100644 --- a/src/templates/item/talent-sheet.hbs +++ b/src/templates/item/talent-sheet.hbs @@ -5,7 +5,7 @@ {{#*inline "talentRankBasicProperty" }}
    - + diff --git a/src/templates/item/weapon-sheet.hbs b/src/templates/item/weapon-sheet.hbs index 7a7efcfd..24a5f2d7 100644 --- a/src/templates/item/weapon-sheet.hbs +++ b/src/templates/item/weapon-sheet.hbs @@ -6,8 +6,8 @@

    {{localize (lookup config.itemTypes item.type)}}

    - - {{#select data.attackType}} {{#each config.attackTypes as |value key|}} @@ -16,13 +16,13 @@
    - - {{localize "DS4.WeaponBonus"}} +
    - - {{localize "DS4.OpponentDefense"}} +
    From e6b51c66a643a431766843f4b6f04aec47bd6bd8 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 16:10:56 +0100 Subject: [PATCH 23/32] removed code duplication of item body from talent - added isPhysical boolean to getData output of item-sheet.ts - added isPhysical checks for displays of physical-only information in templates --- src/module/item/item-data.ts | 4 ++ src/module/item/item-sheet.ts | 10 ++++- src/templates/item/partials/body.hbs | 10 +++-- src/templates/item/partials/description.hbs | 18 +++++---- src/templates/item/talent-sheet.hbs | 41 ++------------------- 5 files changed, 32 insertions(+), 51 deletions(-) diff --git a/src/module/item/item-data.ts b/src/module/item/item-data.ts index be1a0042..3af52fd2 100644 --- a/src/module/item/item-data.ts +++ b/src/module/item/item-data.ts @@ -39,6 +39,10 @@ interface DS4ItemPhysical { storageLocation: string; } +export function isDS4ItemDataTypePhysical(input: DS4ItemDataType): boolean { + return "quantity" in input && "price" in input && "availability" in input && "storageLocation" in input; +} + interface DS4ItemEquipable { equipped: boolean; } diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index ac8197aa..8670dc3e 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -1,5 +1,5 @@ import { DS4Item } from "./item"; -import { DS4ItemDataType } from "./item-data"; +import { DS4ItemDataType, isDS4ItemDataTypePhysical } from "./item-data"; /** * Extend the basic ItemSheet with some very simple modifications @@ -26,7 +26,13 @@ export class DS4ItemSheet extends ItemSheet { /** @override */ getData(): ItemSheetData { - const data = { ...super.getData(), config: CONFIG.DS4, isOwned: this.item.isOwned, actor: this.item.actor }; + const data = { + ...super.getData(), + config: CONFIG.DS4, + isOwned: this.item.isOwned, + actor: this.item.actor, + isPhysical: isDS4ItemDataTypePhysical(this.item.data.data), + }; console.log(data); return data; } diff --git a/src/templates/item/partials/body.hbs b/src/templates/item/partials/body.hbs index 9770815b..1f465d9f 100644 --- a/src/templates/item/partials/body.hbs +++ b/src/templates/item/partials/body.hbs @@ -4,7 +4,9 @@ {{!-- Sheet Body --}} @@ -13,10 +15,12 @@ {{!-- Description Tab --}} {{> systems/ds4/templates/item/partials/description.hbs}} - {{!-- Details Tab --}} - {{> systems/ds4/templates/item/partials/details.hbs}} - {{!-- Effects Tab --}} {{> systems/ds4/templates/item/partials/effects.hbs}} + {{#if isPhysical}} + {{!-- Details Tab --}} + {{> systems/ds4/templates/item/partials/details.hbs}} + {{/if}} + \ No newline at end of file diff --git a/src/templates/item/partials/description.hbs b/src/templates/item/partials/description.hbs index db3253bc..d7088a30 100644 --- a/src/templates/item/partials/description.hbs +++ b/src/templates/item/partials/description.hbs @@ -11,14 +11,16 @@ {{actor.name}}
    -
    - - -
    -
    - - -
    + {{#if isPhysical}} +
    + + +
    +
    + + +
    + {{/if}} {{else}} {{localize "DS4.NotOwned"}} {{/if}} diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs index 69c24137..a4be9b03 100644 --- a/src/templates/item/talent-sheet.hbs +++ b/src/templates/item/talent-sheet.hbs @@ -30,43 +30,8 @@
    - - {{!-- Sheet Tab Navigation --}} - - - {{!-- Sheet Body --}} -
    - {{!-- The item tab for details. --}} -
    - {{!-- As you add new fields, add them in here! --}} -
    - {{!-- TODO: remove duplication of isOwned section here and in description.hbs--}} - {{#if isOwned}} - {{#if (ne data.equipped undefined)}}
    - - -
    - {{/if}} -
    - - {{actor.name}} -
    - {{else}} - {{localize "DS4.NotOwned"}} - {{/if}} -
    -
    - {{editor content=data.description target="data.description" button=true owner=owner editable=editable}} -
    -
    - - {{!-- Effects Tab --}} - {{> systems/ds4/templates/item/partials/effects.hbs }} - -
    + + {{!-- Common Item body --}} + {{> systems/ds4/templates/item/partials/body.hbs}} From 177de1a486674157c402183fb38f395badddf8d8 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 16:29:02 +0100 Subject: [PATCH 24/32] extracted item control buttons to own templates - removed code duplication of inline button templates for item and talent overview --- src/module/ds4.ts | 2 ++ .../actor/partials/items-overview.hbs | 27 ++------------- .../actor/partials/overview-add-button.hbs | 11 ++++++ .../partials/overview-control-buttons.hbs | 8 +++++ .../actor/partials/talents-overview.hbs | 34 ++++++------------- 5 files changed, 33 insertions(+), 49 deletions(-) create mode 100644 src/templates/actor/partials/overview-add-button.hbs create mode 100644 src/templates/actor/partials/overview-control-buttons.hbs diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 4bcf2223..f8d88667 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -38,6 +38,8 @@ async function registerHandlebarsPartials() { "systems/ds4/templates/item/partials/body.hbs", "systems/ds4/templates/actor/partials/items-overview.hbs", "systems/ds4/templates/actor/partials/talents-overview.hbs", + "systems/ds4/templates/actor/partials/overview-add-button.hbs", + "systems/ds4/templates/actor/partials/overview-control-buttons.hbs", "systems/ds4/templates/actor/partials/attributes-traits.hbs", "systems/ds4/templates/actor/partials/combat-values.hbs", ]; diff --git a/src/templates/actor/partials/items-overview.hbs b/src/templates/actor/partials/items-overview.hbs index f3e5415d..da54d2e8 100644 --- a/src/templates/actor/partials/items-overview.hbs +++ b/src/templates/actor/partials/items-overview.hbs @@ -5,29 +5,6 @@ {{!-- INLINE PARTIAL DEFINITIONS --}} {{!-- ======================================================================== --}} -{{!-- -!-- Render an "add" button for a given data type. -!-- -!-- @param datType: hand over the dataType to the partial as hash parameter ---}} -{{#*inline "addItemButton"}} - -{{/inline}} -{{!-- -!-- Render a group of an "edit" and a "delete" button for the current item. -!-- The current item is defined by the data-item-id HTML property of the parent li element. ---}} -{{#*inline "itemControlButtons"}} -
    - - -
    -{{/inline}} - {{!-- !-- Render a header row for a given data type. @@ -57,7 +34,7 @@ {{!-- description --}}
    {{localize 'DS4.HeadingDescription'}}
    {{!-- add button --}} - {{> addItemButton dataType=dataType }} + {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }} {{/inline}} @@ -94,7 +71,7 @@ {{!-- description --}}
    {{{item.data.data.description}}}
    {{!-- control buttons --}} - {{> itemControlButtons}} + {{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }} {{/inline}} diff --git a/src/templates/actor/partials/overview-add-button.hbs b/src/templates/actor/partials/overview-add-button.hbs new file mode 100644 index 00000000..86e5d774 --- /dev/null +++ b/src/templates/actor/partials/overview-add-button.hbs @@ -0,0 +1,11 @@ +{{! +!-- Render an "add" button for adding an item of given data type. +!-- +!-- @param datType: hand over the dataType to the partial as hash parameter +}} + \ No newline at end of file diff --git a/src/templates/actor/partials/overview-control-buttons.hbs b/src/templates/actor/partials/overview-control-buttons.hbs new file mode 100644 index 00000000..d10dbc3f --- /dev/null +++ b/src/templates/actor/partials/overview-control-buttons.hbs @@ -0,0 +1,8 @@ +{{!-- +!-- Render a group of an "edit" and a "delete" button for the current item. +!-- The current item is defined by the data-item-id HTML property of the parent li element. +--}} +
    + + +
    diff --git a/src/templates/actor/partials/talents-overview.hbs b/src/templates/actor/partials/talents-overview.hbs index af259410..3c2cfeac 100644 --- a/src/templates/actor/partials/talents-overview.hbs +++ b/src/templates/actor/partials/talents-overview.hbs @@ -3,30 +3,15 @@ {{!-- ======================================================================== --}} {{!-- TODO: remove duplicate add and delete button definition --}} -{{!-- -!-- Render an "add" button for a given data type. + +{{!-- +!-- Render an input element for a rank value property of an item. !-- -!-- @param datType: hand over the dataType to the partial as hash parameter +!-- @param item: the item +!-- @param property: the key of the property in item.data.data (if 'base', the max value is set automatically) +!-- @param disabled: if given, is placed plainly into the input as HTML property; +!-- meant to be set to "disabled" to disable the input element --}} -{{#*inline "addItemButton"}} - -{{/inline}} -{{!-- -!-- Render a group of an "edit" and a "delete" button for the current item. -!-- The current item is defined by the data-item-id HTML property of the parent li element. ---}} -{{#*inline "itemControlButtons"}} -
    - - -
    -{{/inline}} - - {{#*inline "talentRankValue"}} {{/inline}} + {{!-- !-- Render a talent list row from a given item. !-- It is a flexbox with a child for each item value of interest. @@ -68,7 +54,7 @@ {{!-- description --}}
    {{{item.data.data.description}}}
    {{!-- control buttons --}} - {{> itemControlButtons}} + {{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }} {{/inline}} @@ -88,7 +74,7 @@ {{!-- description --}}
    {{localize 'DS4.HeadingDescription'}}
    {{!-- add button --}} - {{> addItemButton dataType='talent' }} + {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType='talent' }} {{#each itemsByType.talent as |item id|}} {{> talentListEntry item=item}} From e9533608c82f3ac7816cba0dc66f59b85bcfe348 Mon Sep 17 00:00:00 2001 From: Siegfried Krug Date: Wed, 6 Jan 2021 21:38:26 +0100 Subject: [PATCH 25/32] add mail to readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4222e363..9b502a47 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ npm test ## Contributing Code and content contributions are accepted. Please feel free to submit issues -to the issue tracker or submit merge requests for code changes. +to the issue tracker or submit merge requests for code changes. To create an issue send a mail to [git+dungeonslayers-ds4-155-issue-@git.f3l.de](mailto:git+dungeonslayers-ds4-155-issue-@git.f3l.de). ## Licensing From 1f6d8b798043c50447ad5b958e5a9f2fa856e922 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Wed, 6 Jan 2021 23:51:08 +0100 Subject: [PATCH 26/32] cleanup --- src/scss/components/_character_progression.scss | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/scss/components/_character_progression.scss b/src/scss/components/_character_progression.scss index 8e663cbb..c2b3fdcd 100644 --- a/src/scss/components/_character_progression.scss +++ b/src/scss/components/_character_progression.scss @@ -23,8 +23,6 @@ margin-left: 5px; flex: 0 0 40px; text-align: left; - border: none; - background-color: transparent; } } } From 18a475dd8fa6fc35e2f4f85b872bf262ea1991e6 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Thu, 7 Jan 2021 04:12:20 +0100 Subject: [PATCH 27/32] fix height of editor in item sheets --- package-lock.json | 2 +- src/scss/components/_description.scss | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index a5d6c7a6..ff2912b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2702,7 +2702,7 @@ } }, "foundry-pc-types": { - "version": "git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#4e20e5c9cb1b3cd2e44555d7acfa89a3cf63f6ce", + "version": "git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#f84074f63d1aeeb9229e441e8c3ccaa9cba64142", "from": "git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#f3l-fixes", "dev": true, "requires": { diff --git a/src/scss/components/_description.scss b/src/scss/components/_description.scss index 084b1796..cc4c1322 100644 --- a/src/scss/components/_description.scss +++ b/src/scss/components/_description.scss @@ -33,6 +33,10 @@ } } +.description { + height: 100%; +} + .sheet-body .tab .editor { height: 100%; } From 714efeb4ab315292e4f04adef4f9582e7fe979b0 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Thu, 7 Jan 2021 11:55:54 +0100 Subject: [PATCH 28/32] prevent error when trying to manage active effects on an owned item --- src/module/item/item-sheet.ts | 44 ++++++++++++++++--------- src/templates/item/partials/effects.hbs | 8 +++-- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index 8670dc3e..b9bc1272 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -52,6 +52,9 @@ export class DS4ItemSheet extends ItemSheet { return position; } + private readonly ownedItemActiveEffectWarning = + "Managing Active Effects within an Owned Item is not currently supported and will be added in a subsequent update."; + /* -------------------------------------------- */ /** @override */ @@ -60,29 +63,38 @@ export class DS4ItemSheet extends ItemSheet { if (!this.options.editable) return; - html.find(".effect-create").on("click", this._onEffectCreate.bind(this)); - - html.find(".effect-edit").on("click", (ev) => { - const li = $(ev.currentTarget).parents(".effect"); - console.log(li.data("effectId")); - const effect = this.item.effects.get(li.data("effectId")); - effect.sheet.render(true); - }); - - html.find(".effect-delete").on("click", async (ev) => { - const li = $(ev.currentTarget).parents(".effect"); - await this.item.deleteEmbeddedEntity("ActiveEffect", li.data("effectId")); - }); + html.find(".effect-control").on("click", this._onManageActiveEffect.bind(this)); } /** - * Handle creating a new ActiveEffect for the item using initial data defined in the HTML dataset + * Handle management of ActiveEffects. * @param {Event} event The originating click event - * @private */ - private async _onEffectCreate(event: JQuery.ClickEvent): Promise { + private async _onManageActiveEffect(event: JQuery.ClickEvent): Promise { event.preventDefault(); + if (this.item.isOwned) { + return ui.notifications.warn(this.ownedItemActiveEffectWarning); + } + const a = event.currentTarget; + const li = $(a).parents(".effect"); + + switch (a.dataset["action"]) { + case "create": + return this._createActiveEffect(); + case "edit": + const effect = this.item.effects.get(li.data("effectId")); + return effect.sheet.render(true); + case "delete": { + return this.item.deleteEmbeddedEntity("ActiveEffect", li.data("effectId")); + } + } + } + + /** + * Create a new ActiveEffect for the item using default data. + */ + private async _createActiveEffect(): Promise { const label = `New Effect`; const createData = { diff --git a/src/templates/item/partials/effects.hbs b/src/templates/item/partials/effects.hbs index 819290d6..b4cf02bc 100644 --- a/src/templates/item/partials/effects.hbs +++ b/src/templates/item/partials/effects.hbs @@ -5,7 +5,7 @@
    Name
    @@ -13,8 +13,10 @@
  • {{effect.label}}

    - - + +
  • {{/each}} From 7685efa8a6aa181f0fb314ae1767e63b4a316f27 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Thu, 7 Jan 2021 12:04:25 +0100 Subject: [PATCH 29/32] localize warning --- src/lang/en.json | 3 ++- src/module/item/item-sheet.ts | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lang/en.json b/src/lang/en.json index 84c7d542..7b449b34 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -101,5 +101,6 @@ "DS4.ProfilHairColor": "Hair Color", "DS4.ProfileWeight": "Weight", "DS4.ProfileEyeColor": "Eye Color", - "DS4.ProfileSpecialCharacteristics": "Special Characteristics" + "DS4.ProfileSpecialCharacteristics": "Special Characteristics", + "DS4.WarningManageActiveEffectOnOwnedItem": "Managing Active Effects within an Owned Item is not currently supported and will be added in a subsequent update." } diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index b9bc1272..8d8df70f 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -52,9 +52,6 @@ export class DS4ItemSheet extends ItemSheet { return position; } - private readonly ownedItemActiveEffectWarning = - "Managing Active Effects within an Owned Item is not currently supported and will be added in a subsequent update."; - /* -------------------------------------------- */ /** @override */ @@ -74,7 +71,7 @@ export class DS4ItemSheet extends ItemSheet { event.preventDefault(); if (this.item.isOwned) { - return ui.notifications.warn(this.ownedItemActiveEffectWarning); + return ui.notifications.warn(game.i18n.localize("DS4.WarningManageActiveEffectOnOwnedItem")); } const a = event.currentTarget; const li = $(a).parents(".effect"); From b361d2da04f89089d628f01279a0bdee3edbde16 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Thu, 7 Jan 2021 12:47:38 +0100 Subject: [PATCH 30/32] make hit points usable in resource bar --- src/module/actor/actor-data.ts | 7 ++++--- src/module/actor/actor.ts | 2 ++ src/system.json | 2 +- src/template.json | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/module/actor/actor-data.ts b/src/module/actor/actor-data.ts index 746ae439..4269bce0 100644 --- a/src/module/actor/actor-data.ts +++ b/src/module/actor/actor-data.ts @@ -25,8 +25,9 @@ interface UsableResource { used: T; } -interface CurrentData extends ModifiableData { - current: T; +interface ResourceData extends ModifiableData { + value: T; + max?: T; } // Blueprint in case we need more detailed differentiation @@ -42,7 +43,7 @@ interface DS4ActorDataTraits { } interface DS4ActorDataCombatValues { - hitPoints: CurrentData; + hitPoints: ResourceData; defense: ModifiableData; initiative: ModifiableData; movement: ModifiableData; diff --git a/src/module/actor/actor.ts b/src/module/actor/actor.ts index c17d6843..7f2f8209 100644 --- a/src/module/actor/actor.ts +++ b/src/module/actor/actor.ts @@ -18,5 +18,7 @@ export class DS4Actor extends Actor Object.values(combatValues).forEach( (combatValue: ModifiableData) => (combatValue.total = combatValue.base + combatValue.mod), ); + + combatValues.hitPoints.max = combatValues.hitPoints.total; } } diff --git a/src/system.json b/src/system.json index a57664c3..a64a1a8c 100644 --- a/src/system.json +++ b/src/system.json @@ -20,7 +20,7 @@ ], "gridDistance": 1, "gridUnits": "m", - "primaryTokenAttribute": "combatValues.hitPoints.current", + "primaryTokenAttribute": "combatValues.hitPoints", "url": "https://git.f3l.de/dungeonslayers/ds4", "manifest": "https://git.f3l.de/dungeonslayers/ds4/-/raw/master/src/system.json?inline=false", "download": "https://git.f3l.de/dungeonslayers/ds4/-/jobs/artifacts/0.1.0/download?job=build", diff --git a/src/template.json b/src/template.json index f4aef42d..fc61e8df 100644 --- a/src/template.json +++ b/src/template.json @@ -48,7 +48,7 @@ "hitPoints": { "base": 0, "mod": 0, - "current": 0 + "value": 0 }, "defense": { "base": 0, From 149096e98514c1e948fe58143239bbcb191ff55e Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Thu, 7 Jan 2021 20:20:40 +0100 Subject: [PATCH 31/32] add racial abilites as item type --- src/lang/en.json | 10 +- src/module/config.ts | 1 + src/module/item/item-data.ts | 10 +- src/scss/components/_forms.scss | 2 +- src/template.json | 5 +- src/templates/actor/actor-sheet.hbs | 2 +- .../actor/partials/items-overview.hbs | 12 +- .../actor/partials/talents-overview.hbs | 108 ++++++++++++------ src/templates/item/racialAbility-sheet.hbs | 13 +++ 9 files changed, 118 insertions(+), 45 deletions(-) create mode 100644 src/templates/item/racialAbility-sheet.hbs diff --git a/src/lang/en.json b/src/lang/en.json index 84c7d542..72f0455b 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -4,7 +4,7 @@ "DS4.HeadingDescription": "Description", "DS4.HeadingDetails": "Details", "DS4.HeadingEffects": "Effects", - "DS4.HeadingItems": "Items", + "DS4.HeadingInventory": "Inventory", "DS4.HeadingProfile": "Profile", "DS4.HeadingTalents": "Talents & Abilities", "DS4.AttackType": "Attack Type", @@ -31,11 +31,19 @@ "DS4.ItemAvailabilityNowhere": "Nowhere", "DS4.ItemName": "Name", "DS4.ItemTypeWeapon": "Weapon", + "DS4.ItemTypeWeaponPlural": "Weapons", "DS4.ItemTypeArmor": "Armor", + "DS4.ItemTypeArmorPlural": "Armor", "DS4.ItemTypeShield": "Shield", + "DS4.ItemTypeShieldPlural": "Shields", "DS4.ItemTypeTrinket": "Trinket", + "DS4.ItemTypeTrinketPlural": "Trinkets", "DS4.ItemTypeEquipment": "Equipment", + "DS4.ItemTypeEquipmentPlural": "Equipment", "DS4.ItemTypeTalent": "Talent", + "DS4.ItemTypeTalentPlural": "Talents", + "DS4.ItemTypeRacialAbility": "Racial Ability", + "DS4.ItemTypeRacialAbilityPlural": "Racial Abilities", "DS4.ArmorType": "Armor Type", "DS4.ArmorTypeAbbr": "AT", "DS4.ArmorMaterialType": "Material Type", diff --git a/src/module/config.ts b/src/module/config.ts index c98f3d41..28e0a655 100644 --- a/src/module/config.ts +++ b/src/module/config.ts @@ -49,6 +49,7 @@ export const DS4 = { trinket: "DS4.ItemTypeTrinket", equipment: "DS4.ItemTypeEquipment", talent: "DS4.ItemTypeTalent", + racialAbility: "DS4.ItemTypeRacialAbility", }, /** diff --git a/src/module/item/item-data.ts b/src/module/item/item-data.ts index 3af52fd2..76b90e78 100644 --- a/src/module/item/item-data.ts +++ b/src/module/item/item-data.ts @@ -1,6 +1,13 @@ import { ModifiableData } from "../actor/actor-data"; -export type DS4ItemDataType = DS4Weapon | DS4Armor | DS4Shield | DS4Trinket | DS4Equipment | DS4Talent; +export type DS4ItemDataType = + | DS4Weapon + | DS4Armor + | DS4Shield + | DS4Trinket + | DS4Equipment + | DS4Talent + | DS4RacialAbility; // types @@ -26,6 +33,7 @@ interface DS4TalentRank extends ModifiableData { interface DS4Shield extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable, DS4ItemProtective {} interface DS4Trinket extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable {} interface DS4Equipment extends DS4ItemBase, DS4ItemPhysical {} +type DS4RacialAbility = DS4ItemBase; // templates diff --git a/src/scss/components/_forms.scss b/src/scss/components/_forms.scss index 2a992d7b..4c99b156 100644 --- a/src/scss/components/_forms.scss +++ b/src/scss/components/_forms.scss @@ -43,7 +43,7 @@ header.sheet-header { display: block; height: 50px; padding: 0px; - flex: 0 0 0; + flex: 0 0 auto; color: $c-light-grey; border: none; line-height: 50px; diff --git a/src/template.json b/src/template.json index f4aef42d..f5a605ef 100644 --- a/src/template.json +++ b/src/template.json @@ -116,7 +116,7 @@ } }, "Item": { - "types": ["weapon", "armor", "shield", "trinket", "equipment", "talent"], + "types": ["weapon", "armor", "shield", "trinket", "equipment", "talent", "racialAbility"], "templates": { "base": { "description": "" @@ -161,6 +161,9 @@ "max": 0, "mod": 0 } + }, + "racialAbility": { + "templates": ["base"] } } } diff --git a/src/templates/actor/actor-sheet.hbs b/src/templates/actor/actor-sheet.hbs index 05a62038..8e3e5f54 100644 --- a/src/templates/actor/actor-sheet.hbs +++ b/src/templates/actor/actor-sheet.hbs @@ -61,7 +61,7 @@ {{localize 'DS4.HeadingDescription'}} {{localize 'DS4.HeadingTalents'}} {{localize "DS4.HeadingProfile"}} - {{localize 'DS4.HeadingItems'}} + {{localize 'DS4.HeadingInventory'}} {{!-- Sheet Body --}} diff --git a/src/templates/actor/partials/items-overview.hbs b/src/templates/actor/partials/items-overview.hbs index da54d2e8..e41d6f98 100644 --- a/src/templates/actor/partials/items-overview.hbs +++ b/src/templates/actor/partials/items-overview.hbs @@ -79,10 +79,10 @@ {{!-- ======================================================================== --}} -
    +
    {{!-- WEAPONS --}} -

    {{localize 'DS4.ItemTypeWeapon'}}

    +

    {{localize 'DS4.ItemTypeWeaponPlural'}}

      {{#> itemListHeader dataType='weapon'}}
      {{localize 'DS4.AttackTypeAbbr'}}
      @@ -106,7 +106,7 @@
    {{!-- ARMOR --}} -

    {{localize 'DS4.ItemTypeArmor'}}

    +

    {{localize 'DS4.ItemTypeArmorPlural'}}

      {{#> itemListHeader dataType='armor'}}
      {{localize 'DS4.ArmorMaterialTypeAbbr'}}
      @@ -130,7 +130,7 @@ {{!-- SHIELD --}} -

      {{localize 'DS4.ItemTypeShield'}}

      {{!-- SPECIFIC --}} +

      {{localize 'DS4.ItemTypeShieldPlural'}}

      {{!-- SPECIFIC --}}
        {{#> itemListHeader dataType='shield' }}
        @@ -145,7 +145,7 @@
      {{!-- TRINKET --}} -

      {{localize 'DS4.ItemTypeTrinket'}}

      +

      {{localize 'DS4.ItemTypeTrinketPlural'}}

        {{#> itemListHeader dataType='trinket'}}
        {{localize 'DS4.StorageLocation'}}
        @@ -159,7 +159,7 @@
      {{!-- EQUIPMENT --}} -

      {{localize 'DS4.ItemTypeEquipment'}}

      +

      {{localize 'DS4.ItemTypeEquipmentPlural'}}

        {{#> itemListHeader dataType='equipment'}}
        {{localize 'DS4.StorageLocation'}}
        diff --git a/src/templates/actor/partials/talents-overview.hbs b/src/templates/actor/partials/talents-overview.hbs index 3c2cfeac..179703e2 100644 --- a/src/templates/actor/partials/talents-overview.hbs +++ b/src/templates/actor/partials/talents-overview.hbs @@ -4,20 +4,18 @@ {{!-- TODO: remove duplicate add and delete button definition --}} -{{!-- +{{!-- !-- Render an input element for a rank value property of an item. !-- !-- @param item: the item !-- @param property: the key of the property in item.data.data (if 'base', the max value is set automatically) !-- @param disabled: if given, is placed plainly into the input as HTML property; -!-- meant to be set to "disabled" to disable the input element +!-- meant to be set to "disabled" to disable the input element --}} {{#*inline "talentRankValue"}} - + {{/inline}} @@ -30,39 +28,64 @@ !-- @param partial-block: hand over custom children of the flexbox in the partial block. --}} {{#*inline "talentListEntry"}} -
      1. - {{!-- image --}} -
        - -
        - {{!-- name --}} - -
        - {{!-- acquired rank --}} - {{> talentRankValue item=item property='base' localizeString='DS4.TalentRankBase'}} - ( of - {{!-- maximum acquirable rank --}} - {{> talentRankValue item=item property='max' localizeString='DS4.TalentRankMax'}} - ) + - {{!-- additional ranks --}} - {{> talentRankValue item=item property='mod' localizeString='DS4.TalentRankMod'}} - = - {{!-- derived total rank --}} - {{> talentRankValue item=item property='total' localizeString='DS4.TalentRankTotal' disabled='disabled'}} -
        - {{!-- description --}} -
        {{{item.data.data.description}}}
        - {{!-- control buttons --}} - {{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }} -
      2. +
      3. + {{!-- image --}} +
        + +
        + {{!-- name --}} + +
        + {{!-- acquired rank --}} + {{> talentRankValue item=item property='base' localizeString='DS4.TalentRankBase'}} + ( of + {{!-- maximum acquirable rank --}} + {{> talentRankValue item=item property='max' localizeString='DS4.TalentRankMax'}} + ) + + {{!-- additional ranks --}} + {{> talentRankValue item=item property='mod' localizeString='DS4.TalentRankMod'}} + = + {{!-- derived total rank --}} + {{> talentRankValue item=item property='total' localizeString='DS4.TalentRankTotal' disabled='disabled'}} +
        + {{!-- description --}} +
        {{{item.data.data.description}}}
        + {{!-- control buttons --}} + {{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }} +
      4. {{/inline}} +{{!-- +!-- Render a racial ability list row from a given item. +!-- It is a flexbox with a child for each item value of interest. +!-- The partial assumes a variable item to be given in the context. +!-- +!-- @param item: hand over the item to the partial as hash parameter +!-- @param partial-block: hand over custom children of the flexbox in the partial block. +--}} +{{#*inline "racialAbilityListEntry"}} +
      5. + {{!-- image --}} +
        + +
        + {{!-- name --}} + + {{!-- description --}} +
        {{{item.data.data.description}}}
        + {{!-- control buttons --}} + {{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }} +
      6. +{{/inline}} + {{!-- ======================================================================== --}}
        +

        {{localize 'DS4.ItemTypeTalentPlural'}}

        1. {{!-- image --}} @@ -77,7 +100,24 @@ {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType='talent' }}
        2. {{#each itemsByType.talent as |item id|}} - {{> talentListEntry item=item}} + {{> talentListEntry item=item}} + {{/each}} +
        + +

        {{localize 'DS4.ItemTypeRacialAbilityPlural'}}

        +
          +
        1. + {{!-- image --}} +
          + {{!-- name --}} +
          {{localize 'DS4.ItemName'}}
          + {{!-- description --}} +
          {{localize 'DS4.HeadingDescription'}}
          + {{!-- add button --}} + {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType='racialAbility' }} +
        2. + {{#each itemsByType.racialAbility as |item id|}} + {{> racialAbilityListEntry item=item}} {{/each}}
        \ No newline at end of file diff --git a/src/templates/item/racialAbility-sheet.hbs b/src/templates/item/racialAbility-sheet.hbs new file mode 100644 index 00000000..46dcf476 --- /dev/null +++ b/src/templates/item/racialAbility-sheet.hbs @@ -0,0 +1,13 @@ +
        +
        + +
        +

        +

        {{localize (lookup config.itemTypes item.type)}}

        +
        +
        + + {{!-- Common Item body --}} + {{> systems/ds4/templates/item/partials/body.hbs}} + +
        From 16ea39f81d06859cea3623ba92cc4901ce708e91 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Thu, 7 Jan 2021 23:59:50 +0100 Subject: [PATCH 32/32] remove redundant effect classes --- src/templates/item/partials/effects.hbs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/templates/item/partials/effects.hbs b/src/templates/item/partials/effects.hbs index b4cf02bc..b829bfac 100644 --- a/src/templates/item/partials/effects.hbs +++ b/src/templates/item/partials/effects.hbs @@ -5,18 +5,16 @@
        Name
        {{#each item.effects as |effect id|}}
      7. {{effect.label}}

        - - + +
      8. {{/each}}