From eb49c15d5f7ff61acb07b99c7b1ae80acf3b3982 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Thu, 13 May 2021 15:41:00 +0200 Subject: [PATCH] Add optional tracking of slayer points --- src/lang/de.json | 6 ++++- src/lang/en.json | 6 ++++- src/module/actor/actor-data.ts | 5 ++++ src/module/actor/actor-prepared-data.ts | 6 +++++ src/module/actor/actor.ts | 7 +++++- src/module/actor/sheets/actor-sheet.ts | 2 ++ src/module/global.d.ts | 1 + src/module/settings.ts | 23 +++++++++++++++++++ .../components/_character_progression.scss | 14 +++++++++++ src/system.json | 2 +- src/template.json | 3 +++ .../components/character-progression.hbs | 14 +++++++++-- 12 files changed, 83 insertions(+), 6 deletions(-) diff --git a/src/lang/de.json b/src/lang/de.json index 2e988076..28d765d0 100644 --- a/src/lang/de.json +++ b/src/lang/de.json @@ -140,11 +140,13 @@ "DS4.CharacterBaseInfoHeroClass": "Heldenklasse", "DS4.CharacterBaseInfoCulture": "Kultur", "DS4.CharacterProgressionLevel": "Stufe", - "DS4.CharacterProgressionLevelAbbr": "Stufe", + "DS4.CharacterProgressionLevelAbbr": "ST", "DS4.CharacterProgressionExperiencePoints": "Erfahrungspunkte", "DS4.CharacterProgressionExperiencePointsAbbr": "EP", "DS4.CharacterProgressionTalentPoints": "Talentpunkte", "DS4.CharacterProgressionProgressPoints": "Lernpunkte", + "DS4.CharacterSlayerPoints": "Slayerpunkte", + "DS4.CharacterSlayerPointsAbbr": "SP", "DS4.TalentRank": "Rang", "DS4.TalentRankBase": "Erworbener Rang", "DS4.TalentRankMax": "Maximaler Rang", @@ -240,6 +242,8 @@ "DS4.TooltipEffects": "Effekte", "DS4.SettingUseSlayingDiceForAutomatedChecksName": "Slayende Würfel", "DS4.SettingUseSlayingDiceForAutomatedChecksHint": "Benutze Slayende Würfel bei automatisierten Proben.", + "DS4.SettingShowSlayerPointsName": "Slayerpunkte", + "DS4.SettingShowSlayerPointsHint": "Zeige Slayerpunkte im Charakterbogen an.", "DS4.ChecksAppraise": "Schätzen", "DS4.ChecksChangeSpell": "Zauber Wechseln", "DS4.ChecksClimb": "Klettern", diff --git a/src/lang/en.json b/src/lang/en.json index e19f88e3..02598f84 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -140,11 +140,13 @@ "DS4.CharacterBaseInfoHeroClass": "Hero Class", "DS4.CharacterBaseInfoCulture": "Culture", "DS4.CharacterProgressionLevel": "Level", - "DS4.CharacterProgressionLevelAbbr": "Level", + "DS4.CharacterProgressionLevelAbbr": "LVL", "DS4.CharacterProgressionExperiencePoints": "Experience Points", "DS4.CharacterProgressionExperiencePointsAbbr": "XP", "DS4.CharacterProgressionTalentPoints": "Talent Points", "DS4.CharacterProgressionProgressPoints": "Progress Points", + "DS4.CharacterSlayerPoints": "Slayer Points", + "DS4.CharacterSlayerPointsAbbr": "SP", "DS4.TalentRank": "Rank", "DS4.TalentRankBase": "Acquired Ranks", "DS4.TalentRankMax": "Maximum Ranks", @@ -240,6 +242,8 @@ "DS4.TooltipEffects": "Effects", "DS4.SettingUseSlayingDiceForAutomatedChecksName": "Slaying Dice", "DS4.SettingUseSlayingDiceForAutomatedChecksHint": "Use Slaying Dice for automated checks.", + "DS4.SettingShowSlayerPointsName": "Slayer Points", + "DS4.SettingShowSlayerPointsHint": "Show Slayer Points in the character sheet.", "DS4.ChecksAppraise": "Appraise", "DS4.ChecksChangeSpell": "Change Spell", "DS4.ChecksClimb": "Climb", diff --git a/src/module/actor/actor-data.ts b/src/module/actor/actor-data.ts index dffd84d9..ef8ead13 100644 --- a/src/module/actor/actor-data.ts +++ b/src/module/actor/actor-data.ts @@ -55,6 +55,7 @@ interface DS4CharacterDataData extends DS4ActorDataDataBase { language: DS4CharacterDataDataLanguage; profile: DS4CharacterDataDataProfile; currency: DS4CharacterDataDataCurrency; + slayerPoints: DS4CharacterDataDataSlayerPoints; } export interface DS4CharacterDataDataBaseInfo { race: string; @@ -93,6 +94,10 @@ export interface DS4CharacterDataDataCurrency { copper: number; } +export interface DS4CharacterDataDataSlayerPoints { + value: number; +} + interface DS4CreatureDataData extends DS4ActorDataDataBase { baseInfo: DS4CreatureDataDataBaseInfo; } diff --git a/src/module/actor/actor-prepared-data.ts b/src/module/actor/actor-prepared-data.ts index ab231637..653d023d 100644 --- a/src/module/actor/actor-prepared-data.ts +++ b/src/module/actor/actor-prepared-data.ts @@ -7,6 +7,7 @@ import { DS4CharacterDataDataLanguage, DS4CharacterDataDataProfile, DS4CharacterDataDataProgression, + DS4CharacterDataDataSlayerPoints, DS4CreatureDataDataBaseInfo, } from "./actor-data"; @@ -74,6 +75,11 @@ interface DS4CharacterPreparedDataData extends DS4ActorPreparedDataDataBase { language: DS4CharacterDataDataLanguage; profile: DS4CharacterDataDataProfile; currency: DS4CharacterDataDataCurrency; + slayerPoints: DS4CharacterPreparedDataDataSlayerPoints; +} + +export interface DS4CharacterPreparedDataDataSlayerPoints extends DS4CharacterDataDataSlayerPoints { + max: number; } interface DS4CreaturePreparedDataData extends DS4ActorPreparedDataDataBase { diff --git a/src/module/actor/actor.ts b/src/module/actor/actor.ts index 1bb05a07..f7e4120d 100644 --- a/src/module/actor/actor.ts +++ b/src/module/actor/actor.ts @@ -131,6 +131,9 @@ export class DS4Actor extends Actor prepareFinalDerivedData(): void { this.data.data.combatValues.hitPoints.max = this.data.data.combatValues.hitPoints.total; this.data.data.checks.defend = this.data.data.combatValues.defense.total; + if (this.data.type === "character") { + this.data.data.slayerPoints.max = 3; + } } /** @@ -138,7 +141,9 @@ export class DS4Actor extends Actor * given in dot notation. */ get finalDerivedDataProperties(): string[] { - return ["data.combatValues.hitPoints.max", "data.checks.defend"]; + return ["data.combatValues.hitPoints.max", "data.checks.defend"].concat( + this.data.type === "character" ? ["data.slayerPoints.max"] : [], + ); } /** diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index 34a8d777..7a2e3299 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -3,6 +3,7 @@ import { DS4 } from "../../config"; import { getCanvas } from "../../helpers"; import { DS4Item } from "../../item/item"; import { DS4ItemData } from "../../item/item-data"; +import { getDS4Settings } from "../../settings"; import notifications from "../../ui/notifications"; import { DS4Actor } from "../actor"; import { isCheck } from "../actor-prepared-data"; @@ -61,6 +62,7 @@ export class DS4ActorSheet extends ActorSheet> { config: DS4, // Add the items explicitly sorted by type to the data: itemsByType, + settings: getDS4Settings(), }; return data; } diff --git a/src/module/global.d.ts b/src/module/global.d.ts index c560d623..360668e0 100644 --- a/src/module/global.d.ts +++ b/src/module/global.d.ts @@ -2,5 +2,6 @@ declare namespace ClientSettings { interface Values { "ds4.systemMigrationVersion": number; "ds4.useSlayingDiceForAutomatedChecks": boolean; + "ds4.showSlayerPoints": boolean; } } diff --git a/src/module/settings.ts b/src/module/settings.ts index 938be7c0..bd7b1884 100644 --- a/src/module/settings.ts +++ b/src/module/settings.ts @@ -18,4 +18,27 @@ export function registerSystemSettings(): void { type: Boolean, default: false, }); + + game.settings.register("ds4", "showSlayerPoints", { + name: "DS4.SettingShowSlayerPointsName", + hint: "DS4.SettingShowSlayerPointsHint", + scope: "world", + config: true, + type: Boolean, + default: false, + }); +} + +interface DS4Settings { + systemMigrationVersion: number; + useSlayingDiceForAutomatedChecks: boolean; + showSlayerPoints: boolean; +} + +export function getDS4Settings(): DS4Settings { + return { + systemMigrationVersion: game.settings.get("ds4", "systemMigrationVersion"), + useSlayingDiceForAutomatedChecks: game.settings.get("ds4", "useSlayingDiceForAutomatedChecks"), + showSlayerPoints: game.settings.get("ds4", "showSlayerPoints"), + }; } diff --git a/src/scss/components/_character_progression.scss b/src/scss/components/_character_progression.scss index 1f9f3642..d3c19094 100644 --- a/src/scss/components/_character_progression.scss +++ b/src/scss/components/_character_progression.scss @@ -1,9 +1,12 @@ @use "../utils/colors"; @use "../utils/typography"; @use "../utils/variables"; +@use "../utils/mixins"; .progression { .progression-entry { + @include mixins.mark-invalid-or-disabled-input; + display: flex; flex-direction: row; flex-wrap: wrap; @@ -26,6 +29,17 @@ margin-left: 5px; flex: 0 0 40px; text-align: left; + + &--slayer-points { + &::-webkit-inner-spin-button, + &::-webkit-outer-spin-button { + -webkit-appearance: auto; + } + &:hover, + &:focus { + -moz-appearance: auto; + } + } } } } diff --git a/src/system.json b/src/system.json index 67a06ce7..b02807e8 100644 --- a/src/system.json +++ b/src/system.json @@ -5,7 +5,7 @@ "version": "0.6.0", "minimumCoreVersion": "0.7.9", "compatibleCoreVersion": "0.7.9", - "templateVersion": 3, + "templateVersion": 4, "author": "Johannes Loher, Gesina Schwalbe, Oliver Rümpelein, Siegfried Krug", "authors": [ { diff --git a/src/template.json b/src/template.json index 3ee98118..29e9ca6c 100644 --- a/src/template.json +++ b/src/template.json @@ -119,6 +119,9 @@ "gold": 0, "silver": 0, "copper": 0 + }, + "slayerPoints": { + "value": 0 } } }, diff --git a/src/templates/sheets/actor/components/character-progression.hbs b/src/templates/sheets/actor/components/character-progression.hbs index 4bd06898..446142e9 100644 --- a/src/templates/sheets/actor/components/character-progression.hbs +++ b/src/templates/sheets/actor/components/character-progression.hbs @@ -8,12 +8,22 @@ id="data.combatValues.hitPoints.value" value="{{data.combatValues.hitPoints.value}}" data-dtype="Number" /> {{#if (eq actor.type "character")}} + {{#if settings.showSlayerPoints}} +
+

+

+ +
+ {{/if}}

-
@@ -21,7 +31,7 @@ title="{{localize 'DS4.CharacterProgressionExperiencePoints'}}">{{localize "DS4.CharacterProgressionExperiencePointsAbbr"}} -
{{/if}}