refactor: use subclasses for different actor types
This commit is contained in:
parent
21f849b464
commit
be616e3be8
23 changed files with 321 additions and 240 deletions
29
src/actor/character/character-data-properties.ts
Normal file
29
src/actor/character/character-data-properties.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
// SPDX-FileCopyrightText: 2022 Johannes Loher
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { DS4ActorDataPropertiesDataBase } from "../actor-data-properties-base";
|
||||
import {
|
||||
DS4CharacterDataSourceDataBaseInfo,
|
||||
DS4CharacterDataSourceDataCurrency,
|
||||
DS4CharacterDataSourceDataProfile,
|
||||
DS4CharacterDataSourceDataProgression,
|
||||
DS4CharacterDataSourceDataSlayerPoints,
|
||||
} from "./character-data-source";
|
||||
|
||||
export interface DS4CharacterDataProperties {
|
||||
type: "character";
|
||||
data: DS4CharacterDataPropertiesData;
|
||||
}
|
||||
|
||||
interface DS4CharacterDataPropertiesData extends DS4ActorDataPropertiesDataBase {
|
||||
baseInfo: DS4CharacterDataSourceDataBaseInfo;
|
||||
progression: DS4CharacterDataSourceDataProgression;
|
||||
profile: DS4CharacterDataSourceDataProfile;
|
||||
currency: DS4CharacterDataSourceDataCurrency;
|
||||
slayerPoints: DS4CharacterDataPropertiesDataSlayerPoints;
|
||||
}
|
||||
|
||||
export interface DS4CharacterDataPropertiesDataSlayerPoints extends DS4CharacterDataSourceDataSlayerPoints {
|
||||
max: number;
|
||||
}
|
56
src/actor/character/character-data-source.ts
Normal file
56
src/actor/character/character-data-source.ts
Normal file
|
@ -0,0 +1,56 @@
|
|||
// SPDX-FileCopyrightText: 2022 Johannes Loher
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { UsableResource } from "../../common/common-data";
|
||||
import { DS4ActorDataSourceDataBase } from "../actor-data-source-base";
|
||||
|
||||
export interface DS4CharacterDataSource {
|
||||
type: "character";
|
||||
data: DS4CharacterDataSourceData;
|
||||
}
|
||||
|
||||
interface DS4CharacterDataSourceData extends DS4ActorDataSourceDataBase {
|
||||
baseInfo: DS4CharacterDataSourceDataBaseInfo;
|
||||
progression: DS4CharacterDataSourceDataProgression;
|
||||
profile: DS4CharacterDataSourceDataProfile;
|
||||
currency: DS4CharacterDataSourceDataCurrency;
|
||||
slayerPoints: DS4CharacterDataSourceDataSlayerPoints;
|
||||
}
|
||||
|
||||
export interface DS4CharacterDataSourceDataBaseInfo {
|
||||
race: string;
|
||||
class: string;
|
||||
heroClass: string;
|
||||
culture: string;
|
||||
}
|
||||
|
||||
export interface DS4CharacterDataSourceDataProgression {
|
||||
level: number;
|
||||
experiencePoints: number;
|
||||
talentPoints: UsableResource<number>;
|
||||
progressPoints: UsableResource<number>;
|
||||
}
|
||||
|
||||
export interface DS4CharacterDataSourceDataProfile {
|
||||
biography: string;
|
||||
gender: string;
|
||||
birthday: string;
|
||||
birthplace: string;
|
||||
age: number;
|
||||
height: number;
|
||||
hairColor: string;
|
||||
weight: number;
|
||||
eyeColor: string;
|
||||
specialCharacteristics: string;
|
||||
}
|
||||
|
||||
export interface DS4CharacterDataSourceDataCurrency {
|
||||
gold: number;
|
||||
silver: number;
|
||||
copper: number;
|
||||
}
|
||||
|
||||
export interface DS4CharacterDataSourceDataSlayerPoints {
|
||||
value: number;
|
||||
}
|
17
src/actor/character/character-sheet.ts
Normal file
17
src/actor/character/character-sheet.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { DS4ActorSheet } from "../actor-sheet";
|
||||
|
||||
/**
|
||||
* The Sheet class for DS4 Character Actors
|
||||
*/
|
||||
export class DS4CharacterActorSheet extends DS4ActorSheet {
|
||||
/** @override */
|
||||
static get defaultOptions(): ActorSheet.Options {
|
||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
||||
classes: ["sheet", "ds4-actor-sheet", "ds4-character-sheet"],
|
||||
});
|
||||
}
|
||||
}
|
28
src/actor/character/character.ts
Normal file
28
src/actor/character/character.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
// SPDX-FileCopyrightText: 2022 Johannes Loher
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { ItemType } from "../../item/item-data-source";
|
||||
import { DS4Actor } from "../actor";
|
||||
|
||||
export class DS4Character extends DS4Actor {
|
||||
/** @override */
|
||||
prepareFinalDerivedData(): void {
|
||||
super.prepareFinalDerivedData();
|
||||
this.data.data.slayerPoints.max = 3;
|
||||
}
|
||||
|
||||
/** @override */
|
||||
get finalDerivedDataProperties(): string[] {
|
||||
return [...super.finalDerivedDataProperties, "data.slayerPoints.max"];
|
||||
}
|
||||
|
||||
/** @override */
|
||||
get ownableItemTypes(): Array<ItemType> {
|
||||
return [...super.ownableItemTypes, "talent", "racialAbility", "language", "alphabet"];
|
||||
}
|
||||
}
|
||||
|
||||
export interface DS4Character {
|
||||
data: foundry.data.ActorData & { type: "character"; _source: { type: "character" } };
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue