Merge branch '082-tracking-of-slayer-points' into 'master'

Add optional tracking of slayer points

Closes #82

See merge request dungeonslayers/ds4!104
This commit is contained in:
Johannes Loher 2021-05-13 14:38:08 +00:00
commit db77d38560
12 changed files with 83 additions and 6 deletions

View file

@ -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",

View file

@ -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",

View file

@ -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;
}

View file

@ -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 {

View file

@ -131,6 +131,9 @@ export class DS4Actor extends Actor<DS4ActorData, DS4Item, DS4ActorPreparedData>
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<DS4ActorData, DS4Item, DS4ActorPreparedData>
* 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"] : [],
);
}
/**

View file

@ -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<ActorSheet.Data<DS4Actor>> {
config: DS4,
// Add the items explicitly sorted by type to the data:
itemsByType,
settings: getDS4Settings(),
};
return data;
}

View file

@ -2,5 +2,6 @@ declare namespace ClientSettings {
interface Values {
"ds4.systemMigrationVersion": number;
"ds4.useSlayingDiceForAutomatedChecks": boolean;
"ds4.showSlayerPoints": boolean;
}
}

View file

@ -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"),
};
}

View file

@ -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;
}
}
}
}
}

View file

@ -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": [
{

View file

@ -119,6 +119,9 @@
"gold": 0,
"silver": 0,
"copper": 0
},
"slayerPoints": {
"value": 0
}
}
},

View file

@ -8,12 +8,22 @@
id="data.combatValues.hitPoints.value" value="{{data.combatValues.hitPoints.value}}" data-dtype="Number" />
</div>
{{#if (eq actor.type "character")}}
{{#if settings.showSlayerPoints}}
<div class="progression-entry">
<h2 class="progression-label"><label for="data.slayersPoints.value"
title="{{localize 'DS4.CharacterSlayerPoints'}}">{{localize "DS4.CharacterSlayerPointsAbbr"}}</label>
</h2>
<input class="progression-value progression-value--slayer-points" type="number" max="{{data.slayerPoints.max}}"
min="0" step="1" name="data.slayerPoints.value" id="data.slayersPoints.value"
value="{{data.slayerPoints.value}}" data-dtype="Number" />
</div>
{{/if}}
<div class="progression-entry">
<h2 class="progression-label"><label for="data.progression.level"
title="{{localize 'DS4.CharacterProgressionLevel'}}">{{localize
"DS4.CharacterProgressionLevelAbbr"}}</label>
</h2>
<input class="progression-value" type="number" name="data.progression.level" id="data.progression.level"
<input class="progression-value" type="number" min="0" name="data.progression.level" id="data.progression.level"
value="{{data.progression.level}}" data-dtype="Number" />
</div>
<div class="progression-entry">
@ -21,7 +31,7 @@
title="{{localize 'DS4.CharacterProgressionExperiencePoints'}}">{{localize
"DS4.CharacterProgressionExperiencePointsAbbr"}}</label>
</h2>
<input class="progression-value" type="number" name="data.progression.experiencePoints"
<input class="progression-value" type="number" min="0" name="data.progression.experiencePoints"
id="data.progression.experiencePoints" value="{{data.progression.experiencePoints}}" data-dtype="Number" />
</div>
{{/if}}