mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
Feature/200 beastform (#255)
* Temp * Dialog setup * Fixed basic beastform * Reworked beastform to hold it's data entirely in the beastformEffect * UpdateActorTokens fix * Removed hardcoded tierlimit on beastform * PR fixes
This commit is contained in:
parent
c4448226e0
commit
d071fadf7d
41 changed files with 1102 additions and 298 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import {
|
||||
DHAttackAction,
|
||||
DHBaseAction,
|
||||
DhBeastformAction,
|
||||
DHDamageAction,
|
||||
DHEffectAction,
|
||||
DHHealingAction,
|
||||
|
|
@ -19,5 +20,6 @@ export const actionsTypes = {
|
|||
healing: DHHealingAction,
|
||||
summon: DHSummonAction,
|
||||
effect: DHEffectAction,
|
||||
macro: DHMacroAction
|
||||
macro: DHMacroAction,
|
||||
beastform: DhBeastformAction
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { DHActionDiceData, DHActionRollData, DHDamageData, DHDamageField } from './actionDice.mjs';
|
||||
import DhpActor from '../../documents/actor.mjs';
|
||||
import D20RollDialog from '../../dialogs/d20RollDialog.mjs';
|
||||
import BeastformDialog from '../../dialogs/beastformDialog.mjs';
|
||||
|
||||
const fields = foundry.data.fields;
|
||||
|
||||
|
|
@ -106,6 +107,11 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
|||
}),
|
||||
value: new fields.EmbeddedDataField(DHActionDiceData),
|
||||
valueAlt: new fields.EmbeddedDataField(DHActionDiceData)
|
||||
}),
|
||||
beastform: new fields.SchemaField({
|
||||
tierAccess: new fields.SchemaField({
|
||||
exact: new fields.NumberField({ integer: true, nullable: true, initial: null })
|
||||
})
|
||||
})
|
||||
},
|
||||
extraSchemas = {};
|
||||
|
|
@ -757,3 +763,50 @@ export class DHMacroAction extends DHBaseAction {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class DhBeastformAction extends DHBaseAction {
|
||||
static extraSchemas = ['beastform'];
|
||||
|
||||
async use(event, ...args) {
|
||||
const beastformConfig = this.prepareBeastformConfig();
|
||||
|
||||
const abort = await this.handleActiveTransformations();
|
||||
if (abort) return;
|
||||
|
||||
const beastformUuid = await BeastformDialog.configure(beastformConfig);
|
||||
if (!beastformUuid) return;
|
||||
|
||||
await this.transform(beastformUuid);
|
||||
}
|
||||
|
||||
prepareBeastformConfig(config) {
|
||||
const settingsTiers = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.LevelTiers).tiers;
|
||||
const actorLevel = this.actor.system.levelData.level.current;
|
||||
const actorTier =
|
||||
Object.values(settingsTiers).find(
|
||||
tier => actorLevel >= tier.levels.start && actorLevel <= tier.levels.end
|
||||
) ?? 1;
|
||||
|
||||
return {
|
||||
tierLimit: this.beastform.tierAccess.exact ?? actorTier
|
||||
};
|
||||
}
|
||||
|
||||
async transform(beastformUuid) {
|
||||
const beastform = await foundry.utils.fromUuid(beastformUuid);
|
||||
this.actor.createEmbeddedDocuments('Item', [beastform.toObject()]);
|
||||
}
|
||||
|
||||
async handleActiveTransformations() {
|
||||
const beastformEffects = this.actor.effects.filter(x => x.type === 'beastform');
|
||||
if (beastformEffects.length > 0) {
|
||||
for (let effect of beastformEffects) {
|
||||
await effect.delete();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue