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
|
@ -10,8 +10,8 @@ import { DS4Item } from "../item/item";
|
|||
import { DS4ArmorDataProperties, DS4ShieldDataProperties } from "../item/item-data-properties";
|
||||
import { ItemType } from "../item/item-data-source";
|
||||
import { createCheckRoll } from "../rolls/check-factory";
|
||||
import { Check } from "./actor-data-properties";
|
||||
import { isAttribute, isTrait } from "./actor-data-source";
|
||||
import { Check } from "./actor-data-properties-base";
|
||||
import { isAttribute, isTrait } from "./actor-data-source-base";
|
||||
|
||||
declare global {
|
||||
interface DocumentClassConfig {
|
||||
|
@ -157,9 +157,6 @@ export class DS4Actor extends Actor {
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -167,32 +164,14 @@ export class DS4Actor extends Actor {
|
|||
* given in dot notation.
|
||||
*/
|
||||
get finalDerivedDataProperties(): string[] {
|
||||
return ["data.combatValues.hitPoints.max", "data.checks.defend"].concat(
|
||||
this.data.type === "character" ? ["data.slayerPoints.max"] : [],
|
||||
);
|
||||
return ["data.combatValues.hitPoints.max", "data.checks.defend"];
|
||||
}
|
||||
|
||||
/**
|
||||
* The list of item types that can be owned by this actor.
|
||||
*/
|
||||
get ownableItemTypes(): Array<ItemType> {
|
||||
switch (this.data.type) {
|
||||
case "character":
|
||||
return [
|
||||
"weapon",
|
||||
"armor",
|
||||
"shield",
|
||||
"equipment",
|
||||
"loot",
|
||||
"spell",
|
||||
"talent",
|
||||
"racialAbility",
|
||||
"language",
|
||||
"alphabet",
|
||||
];
|
||||
case "creature":
|
||||
return ["weapon", "armor", "shield", "equipment", "loot", "spell", "specialCreatureAbility"];
|
||||
}
|
||||
return ["weapon", "armor", "shield", "equipment", "loot", "spell"];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue