mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Merge fae7efd023 into 0b343c9f52
This commit is contained in:
commit
54b0cda45a
20 changed files with 647 additions and 155 deletions
|
|
@ -1,6 +1,10 @@
|
|||
import { enrichedFateRoll } from '../../enrichers/FateRollEnricher.mjs';
|
||||
import { enrichedDualityRoll } from '../../enrichers/DualityRollEnricher.mjs';
|
||||
|
||||
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||
|
||||
export default class DhpDeathMove extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor(actor) {
|
||||
super({});
|
||||
|
||||
|
|
@ -38,6 +42,99 @@ export default class DhpDeathMove extends HandlebarsApplicationMixin(Application
|
|||
return context;
|
||||
}
|
||||
|
||||
async handleAvoidDeath() {
|
||||
const target = this.actor.uuid;
|
||||
const config = await enrichedFateRoll({
|
||||
target,
|
||||
title: "Avoid Death Hope Fate Roll",
|
||||
label: 'test',
|
||||
fateType: "Hope"
|
||||
});
|
||||
if (config.roll.fate.value <= this.actor.system.levelData.level.current) {
|
||||
// apply scarring - for now directly apply - later add a button.
|
||||
const newScarAmount = this.actor.system.scars + 1;
|
||||
|
||||
await this.actor.update(
|
||||
{
|
||||
system: {
|
||||
scars: newScarAmount
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async clearAllStressAndHitpoints() {
|
||||
await this.actor.update(
|
||||
{
|
||||
system: {
|
||||
resources: {
|
||||
hitPoints: {
|
||||
value: 0
|
||||
},
|
||||
stress: {
|
||||
value: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async handleRiskItAll() {
|
||||
const config = await enrichedDualityRoll({
|
||||
reaction: true,
|
||||
traitValue: null,
|
||||
target: null,
|
||||
difficulty: null,
|
||||
title: "Risk It All",
|
||||
label: 'test',
|
||||
actionType: null,
|
||||
advantage: null
|
||||
});
|
||||
|
||||
if (config.roll.isCritical) {
|
||||
console.log("Clear all stress and HP");
|
||||
this.clearAllStressAndHitpoints();
|
||||
return;
|
||||
}
|
||||
|
||||
// Hope
|
||||
if (config.roll.result.duality == 1) {
|
||||
console.log("Need to clear up Stress and HP up to hope value");
|
||||
console.log("Hope rolled", config.roll.hope.value);
|
||||
if (config.roll.hope.value >= (this.actor.system.resources.hitPoints.value + this.actor.system.resources.stress.value)) {
|
||||
console.log("Hope roll value is more than the HP + Stress, auto- remove");
|
||||
this.clearAllStressAndHitpoints();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//Fear
|
||||
if (config.roll.result.duality == -1) {
|
||||
console.log("You have died...");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async handleBlazeOfGlory() {
|
||||
this.actor.createEmbeddedDocuments('ActiveEffect', [
|
||||
{
|
||||
name: game.i18n.localize('DAGGERHEART.CONFIG.DeathMoves.blazeOfGlory.name'),
|
||||
description: game.i18n.localize('DAGGERHEART.CONFIG.DeathMoves.blazeOfGlory.description'),
|
||||
img: CONFIG.DH.GENERAL.deathMoves.blazeOfGlory.img,
|
||||
changes: [
|
||||
{
|
||||
key: 'system.rules.roll.guaranteedCritical',
|
||||
mode: 2,
|
||||
value: "true"
|
||||
}
|
||||
]
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
static selectMove(_, button) {
|
||||
const move = button.dataset.move;
|
||||
this.selectedMove = CONFIG.DH.GENERAL.deathMoves[move];
|
||||
|
|
@ -46,6 +143,10 @@ export default class DhpDeathMove extends HandlebarsApplicationMixin(Application
|
|||
}
|
||||
|
||||
static async takeMove() {
|
||||
const autoExpandDescription = game.settings.get(
|
||||
CONFIG.DH.id,
|
||||
CONFIG.DH.SETTINGS.gameSettings.appearance
|
||||
).expandRollMessage?.desc;
|
||||
const cls = getDocumentClass('ChatMessage');
|
||||
const msg = {
|
||||
user: game.user.id,
|
||||
|
|
@ -57,7 +158,9 @@ export default class DhpDeathMove extends HandlebarsApplicationMixin(Application
|
|||
author: game.users.get(game.user.id),
|
||||
title: game.i18n.localize(this.selectedMove.name),
|
||||
img: this.selectedMove.img,
|
||||
description: game.i18n.localize(this.selectedMove.description)
|
||||
description: game.i18n.localize(this.selectedMove.description),
|
||||
open: autoExpandDescription ? 'open' : '',
|
||||
chevron: autoExpandDescription ? 'fa-chevron-up' : 'fa-chevron-down'
|
||||
}
|
||||
),
|
||||
title: game.i18n.localize(
|
||||
|
|
@ -74,5 +177,21 @@ export default class DhpDeathMove extends HandlebarsApplicationMixin(Application
|
|||
cls.create(msg);
|
||||
|
||||
this.close();
|
||||
|
||||
if (CONFIG.DH.GENERAL.deathMoves.avoidDeath === this.selectedMove) {
|
||||
this.handleAvoidDeath();
|
||||
return;
|
||||
}
|
||||
|
||||
if (CONFIG.DH.GENERAL.deathMoves.riskItAll === this.selectedMove) {
|
||||
this.handleRiskItAll();
|
||||
return;
|
||||
}
|
||||
|
||||
if (CONFIG.DH.GENERAL.deathMoves.blazeOfGlory === this.selectedMove) {
|
||||
this.handleBlazeOfGlory();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import DHBaseActorSheet from '../api/base-actor.mjs';
|
||||
import DhpDeathMove from '../../dialogs/deathMove.mjs';
|
||||
import DhDeathMove from '../../dialogs/deathMove.mjs';
|
||||
import { abilities } from '../../../config/actorConfig.mjs';
|
||||
import { CharacterLevelup, LevelupViewMode } from '../../levelup/_module.mjs';
|
||||
import DhCharacterCreation from '../../characterCreation/characterCreation.mjs';
|
||||
|
|
@ -666,7 +666,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #makeDeathMove() {
|
||||
await new DhpDeathMove(this.document).render({ force: true });
|
||||
await new DhDeathMove(this.document).render({ force: true });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue