mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-21 18:09:54 +02:00
Compare commits
3 commits
81e264a477
...
3a5529f1dc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a5529f1dc | ||
|
|
02a73d774a | ||
|
|
450287e4d0 |
6 changed files with 56 additions and 38 deletions
|
|
@ -256,7 +256,8 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
|
|
||||||
if (Hooks.call(`${CONFIG.DH.id}.postUseAction`, this, config) === false) return;
|
if (Hooks.call(`${CONFIG.DH.id}.postUseAction`, this, config) === false) return;
|
||||||
|
|
||||||
if (this.chatDisplay && !config.skips.createMessage && !config.actionChatMessageHandled) await this.toChat();
|
if (this.chatDisplay && !config.skips.createMessage && !config.actionChatMessageHandled)
|
||||||
|
await this.toChat(null, config);
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ export default class DHSummonField extends fields.ArrayField {
|
||||||
super(summonFields, options, context);
|
super(summonFields, options, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async execute() {
|
static async execute(config) {
|
||||||
if (!canvas.scene) {
|
if (!canvas.scene) {
|
||||||
ui.notifications.warn(game.i18n.localize('DAGGERHEART.ACTIONS.TYPES.summon.error'));
|
ui.notifications.warn(game.i18n.localize('DAGGERHEART.ACTIONS.TYPES.summon.error'));
|
||||||
return;
|
return;
|
||||||
|
|
@ -36,6 +36,7 @@ export default class DHSummonField extends fields.ArrayField {
|
||||||
|
|
||||||
const rolls = [];
|
const rolls = [];
|
||||||
const summonData = [];
|
const summonData = [];
|
||||||
|
const chatMessageData = [];
|
||||||
for (const summon of this.summon) {
|
for (const summon of this.summon) {
|
||||||
const roll = new Roll(itemAbleRollParse(summon.count, this.actor, this.item));
|
const roll = new Roll(itemAbleRollParse(summon.count, this.actor, this.item));
|
||||||
await roll.evaluate();
|
await roll.evaluate();
|
||||||
|
|
@ -54,17 +55,18 @@ export default class DHSummonField extends fields.ArrayField {
|
||||||
tokenPreviewName: `${actor.prototypeToken.name}${remaining > 1 ? ` (${remaining}x)` : ''}`
|
tokenPreviewName: `${actor.prototypeToken.name}${remaining > 1 ? ` (${remaining}x)` : ''}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chatMessageData.push({
|
||||||
|
data: actor,
|
||||||
|
quantity: countNumber
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rolls.length) await triggerChatRollFx(rolls);
|
if (rolls.length) await triggerChatRollFx(rolls);
|
||||||
|
|
||||||
this.actor.sheet?.minimize();
|
this.actor.sheet?.minimize();
|
||||||
DHSummonField.handleSummon(summonData, this.actor);
|
await CONFIG.ux.TokenManager.createTokensWithPreview(summonData, { elevation: this.actor.token?.elevation });
|
||||||
}
|
this.actor.sheet?.maximize();
|
||||||
|
config.summonData = chatMessageData;
|
||||||
static async handleSummon(summonData, actionActor) {
|
|
||||||
await CONFIG.ux.TokenManager.createTokensWithPreview(summonData, { elevation: actionActor.token?.elevation });
|
|
||||||
|
|
||||||
return actionActor.sheet?.maximize();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,7 @@ export function ActionMixin(Base) {
|
||||||
return this.delete();
|
return this.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
async toChat(origin) {
|
async toChat(origin, config) {
|
||||||
const autoExpandDescription = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance)
|
const autoExpandDescription = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance)
|
||||||
.expandRollMessage?.desc;
|
.expandRollMessage?.desc;
|
||||||
|
|
||||||
|
|
@ -282,7 +282,7 @@ export function ActionMixin(Base) {
|
||||||
img: this.baseAction ? this.parent.parent.img : this.img,
|
img: this.baseAction ? this.parent.parent.img : this.img,
|
||||||
tags: this.tags ? this.tags : ['Spell', 'Arcana', 'Lv 10'],
|
tags: this.tags ? this.tags : ['Spell', 'Arcana', 'Lv 10'],
|
||||||
areas: this.areas,
|
areas: this.areas,
|
||||||
summon: this.summon
|
summon: config?.summonData
|
||||||
},
|
},
|
||||||
source: {
|
source: {
|
||||||
actor: this.actor.uuid,
|
actor: this.actor.uuid,
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@ export default class DhTokenManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return await canvas.tokens.placeTokens(
|
const placedData = await canvas.tokens.placeTokens(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
...actor.prototypeToken.toObject(),
|
...(await actor.getTokenDocument()).toObject(),
|
||||||
actorId: actor.id,
|
actorId: actor.id,
|
||||||
displayName: 50,
|
displayName: 50,
|
||||||
...tokenData
|
...tokenData
|
||||||
|
|
@ -30,6 +30,8 @@ export default class DhTokenManager {
|
||||||
],
|
],
|
||||||
{ create: false }
|
{ create: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return placedData?.[0] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -46,22 +48,24 @@ export default class DhTokenManager {
|
||||||
|
|
||||||
const createElevation = elevation ?? level.elevation.bottom;
|
const createElevation = elevation ?? level.elevation.bottom;
|
||||||
for (const tokenData of tokensData) {
|
for (const tokenData of tokensData) {
|
||||||
const previewTokens = await this.createPreview(tokenData.actor, {
|
const previewToken = await this.createPreview(tokenData.actor, {
|
||||||
name: tokenData.tokenPreviewName,
|
name: tokenData.tokenPreviewName,
|
||||||
level: game.user.viewedLevel,
|
level: game.user.viewedLevel,
|
||||||
elevation: createElevation,
|
elevation: createElevation,
|
||||||
flags: { daggerheart: { createPlacement: true } }
|
flags: { daggerheart: { createPlacement: true } }
|
||||||
});
|
});
|
||||||
if (!previewTokens?.length) return null;
|
if (!previewToken) return null;
|
||||||
|
|
||||||
|
const finalTokenData = {
|
||||||
|
...previewToken.toObject(),
|
||||||
|
name: tokenData.actor.prototypeToken.name,
|
||||||
|
displayName: tokenData.actor.prototypeToken.displayName,
|
||||||
|
flags: tokenData.actor.prototypeToken.flags
|
||||||
|
};
|
||||||
|
|
||||||
await canvas.scene.createEmbeddedDocuments(
|
await canvas.scene.createEmbeddedDocuments(
|
||||||
'Token',
|
'Token',
|
||||||
previewTokens.map(x => ({
|
[finalTokenData],
|
||||||
...x.toObject(),
|
|
||||||
name: tokenData.actor.prototypeToken.name,
|
|
||||||
displayName: tokenData.actor.prototypeToken.displayName,
|
|
||||||
flags: tokenData.actor.prototypeToken.flags
|
|
||||||
})),
|
|
||||||
{ controlObject: true, parent: canvas.scene }
|
{ controlObject: true, parent: canvas.scene }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -599,27 +599,23 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
secret-block {
|
secret-block {
|
||||||
position: relative;
|
display: block;
|
||||||
section.secret {
|
|
||||||
background-color: @red-10;
|
/** A buffer to make the hover behavior work a bit better. The bottom in the button needs to compensate */
|
||||||
padding: 0;
|
@buffer: 8px;
|
||||||
margin-top: 0.375rem;
|
margin-top: -@buffer;
|
||||||
&.revealed {
|
padding-top: @buffer;
|
||||||
background-color: @green-10;
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 0.5rem 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
button.reveal {
|
button.reveal {
|
||||||
--button-size: 0.875rem;
|
--button-size: 1rem;
|
||||||
|
height: var(--button-size);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
width: min-content;
|
width: min-content;
|
||||||
padding: 1px 8px 0 8px;
|
padding: 1px 8px 0 8px;
|
||||||
bottom: calc(100% - 0.4375rem - 2px);
|
bottom: calc(100% - 0.4375rem - 1px);
|
||||||
|
|
||||||
background-color: var(--dh-window-button-color-bg); // todo: find a better var name
|
background-color: var(--dh-window-button-color-bg); // todo: find a better var name
|
||||||
border-color: var(--color-secret-border);
|
border-color: var(--color-secret-border);
|
||||||
|
|
@ -627,6 +623,7 @@
|
||||||
font-size: var(--font-size-10);
|
font-size: var(--font-size-10);
|
||||||
user-select: none;
|
user-select: none;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
@ -635,6 +632,20 @@
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The element inside a secret-block.
|
||||||
|
* This is separate since during prosemirror editing, the secret-block container does not exist.
|
||||||
|
*/
|
||||||
|
section.secret {
|
||||||
|
--color-secret-bg: @red-10;
|
||||||
|
--color-revealed-bg: @green-10;
|
||||||
|
position: relative;
|
||||||
|
padding: 0;
|
||||||
|
p {
|
||||||
|
margin: 0.5rem 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.system-daggerheart {
|
.system-daggerheart {
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@
|
||||||
{{#each action.summon}}
|
{{#each action.summon}}
|
||||||
<div class="summon-container">
|
<div class="summon-container">
|
||||||
<div class="summon-label-container">
|
<div class="summon-label-container">
|
||||||
<img src="{{this.actor.img}}" />
|
<img src="{{this.data.img}}" />
|
||||||
<label>{{this.actor.name}}</label>
|
<label>{{this.data.name}}</label>
|
||||||
</div>
|
</div>
|
||||||
<span># {{this.rolledCount}}</span>
|
<span># {{this.quantity}}</span>
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue