Merkmale und Eigenschaften im Chat
This commit is contained in:
1 parent
bbb92445c6
commit
00473d3afc
11 files changed
+158
-62
No files matched your search
@@ -1,5 +1,6 @@
|
||||
export const loadPartials = async function () {
|
||||
await foundry.applications.handlebars.loadTemplates([
|
||||
"systems/midgard6-lvd/src/templates/chat/chat-message-header.hbs"
|
||||
"systems/midgard6-lvd/src/templates/chat/chat-message-header.hbs",
|
||||
"systems/midgard6-lvd/src/templates/chat/secret-roll.hbs"
|
||||
]);
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
export const loadSettings = async function () {
|
||||
game.settings.register("midgard6-lvd", "zauberAlsTag", {
|
||||
name: game.i18n.localize("Midgard6.Settings.zauberAlsTag.name"),
|
||||
hint: game.i18n.localize("Midgard6.Settings.zauberAlsTag.hint"),
|
||||
scope: "user",
|
||||
config: true,
|
||||
default: false,
|
||||
type: Boolean,
|
||||
requiresReload: true
|
||||
});
|
||||
|
||||
// Automatically collapse chat message descriptions
|
||||
game.settings.register("midgard6-lvd", "beschreibungChatActive", {
|
||||
name: game.i18n.localize("Midgard6.Settings.beschreibungChatActive.name"),
|
||||
hint: game.i18n.localize("Midgard6.Settings.beschreibungChatActive.hint"),
|
||||
scope: "client",
|
||||
config: true,
|
||||
default: false,
|
||||
type: Boolean
|
||||
});
|
||||
};
|
||||
@@ -32,7 +32,7 @@ export async function rollSpell(event, target) {
|
||||
}
|
||||
|
||||
let rollTerm = "@die + @skill";
|
||||
let rollFlavor = dataset.name;
|
||||
let rollFlavor = game.i18n.localize("Midgard6.Zaubern") + ": " + item.name;
|
||||
let roll;
|
||||
|
||||
if (dialogResult.spezLevel) {
|
||||
@@ -41,7 +41,7 @@ export async function rollSpell(event, target) {
|
||||
}
|
||||
|
||||
if (dialogResult.customRoll) {
|
||||
roll = new Roll(dialogResult.customRoll);
|
||||
roll = new Roll(dialogResult.customRoll, {}, { title: rollFlavor });
|
||||
} else {
|
||||
roll = new Roll(
|
||||
rollTerm,
|
||||
@@ -54,19 +54,31 @@ export async function rollSpell(event, target) {
|
||||
);
|
||||
}
|
||||
|
||||
if (item.system.eigenschaften.schaden) {
|
||||
const attackRoll = await roll.evaluate();
|
||||
roll = [
|
||||
attackRoll,
|
||||
await new Roll(
|
||||
"@die",
|
||||
{ die: item.system.eigenschaften.schaden },
|
||||
{ title: game.i18n.localize("Midgard6.Schaden") }
|
||||
).evaluate()
|
||||
];
|
||||
} else {
|
||||
// Execute the roll
|
||||
await roll.evaluate();
|
||||
}
|
||||
|
||||
// The parsed terms of the roll formula
|
||||
console.log("Roll:", roll); // [Die, OperatorTerm, NumericTerm, OperatorTerm, NumericTerm]
|
||||
|
||||
// Execute the roll
|
||||
await roll.evaluate();
|
||||
|
||||
const chatData = {
|
||||
rolls: roll,
|
||||
speaker: ChatMessage.getSpeaker(),
|
||||
flags: {
|
||||
"midgard6-lvd": {
|
||||
title: rollFlavor,
|
||||
eigenschaften: item.eigenschaften,
|
||||
eigenschaften: item.system.eigenschaften,
|
||||
isSpell: true,
|
||||
beschreibung: await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
item.system.beschreibung,
|
||||
@@ -102,7 +114,7 @@ export async function rollSkill(event, target) {
|
||||
return;
|
||||
}
|
||||
// Construct the Roll instance
|
||||
const skillValue = skill.value;
|
||||
const skillValue = skill.value || skill;
|
||||
let die = "";
|
||||
switch (dialogResult.vorteil) {
|
||||
case -1:
|
||||
@@ -126,7 +138,7 @@ export async function rollSkill(event, target) {
|
||||
}
|
||||
|
||||
if (dialogResult.customRoll) {
|
||||
roll = new Roll(dialogResult.customRoll);
|
||||
roll = new Roll(dialogResult.customRoll, {}, { title: rollFlavor });
|
||||
} else {
|
||||
roll = new Roll(
|
||||
rollTerm,
|
||||
@@ -154,7 +166,6 @@ export async function rollSkill(event, target) {
|
||||
}
|
||||
}
|
||||
};
|
||||
console.warn(dialogResult);
|
||||
|
||||
// Nutze applyRollMode, um Sichtbarkeiten (Whisper, Blind) korrekt zu setzen
|
||||
ChatMessage.applyMode(chatData, dialogResult.rollMode);
|
||||
@@ -206,7 +217,7 @@ export async function rollWeapon(event, target) {
|
||||
rollFlavor += ": " + weapon.name;
|
||||
|
||||
if (dialogResult.customRoll) {
|
||||
attackRoll = await new Roll(dialogResult.customRoll).evaluate();
|
||||
attackRoll = await new Roll(dialogResult.customRoll, {}, { title: rollFlavor }).evaluate();
|
||||
} else {
|
||||
attackRoll = await new Roll(
|
||||
rollTerm,
|
||||
@@ -215,7 +226,9 @@ export async function rollWeapon(event, target) {
|
||||
skill: skillValue,
|
||||
spezBonus: dialogResult.spezLevel + 1
|
||||
},
|
||||
{ title: rollFlavor }
|
||||
{
|
||||
title: rollFlavor
|
||||
}
|
||||
).evaluate();
|
||||
}
|
||||
|
||||
@@ -226,7 +239,6 @@ export async function rollWeapon(event, target) {
|
||||
).evaluate();
|
||||
|
||||
// The parsed terms of the roll formula
|
||||
console.warn(dialogResult);
|
||||
const chatData = {
|
||||
rolls: [attackRoll, damageRoll],
|
||||
speaker: ChatMessage.getSpeaker(),
|
||||
@@ -234,6 +246,7 @@ export async function rollWeapon(event, target) {
|
||||
"midgard6-lvd": {
|
||||
title: rollFlavor,
|
||||
eigenschaften: weapon.eigenschaften,
|
||||
merkmale: weapon.system.merkmale,
|
||||
beschreibung: await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
weapon.system.beschreibung,
|
||||
{
|
||||
|
||||
@@ -88,9 +88,8 @@ export class M6ItemSheet extends api.HandlebarsApplicationMixin(sheets.ItemSheet
|
||||
event.preventDefault();
|
||||
const currentInput = event.currentTarget;
|
||||
const value = currentInput.value;
|
||||
|
||||
console.log("Feld verlassen! Aktueller Wert:", value);
|
||||
this.item.update({ [`${currentInput.id}`]: value.split(/[\s,]+/) });
|
||||
this.item.update({ [`${currentInput.name}`]: value.split(/[\s,]+/) });
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
@@ -57,5 +57,36 @@
|
||||
margin: 8px 4px;
|
||||
margin-top: 0;
|
||||
}
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.tags {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.125rem;
|
||||
list-style-type: none;
|
||||
padding-left: 0;
|
||||
margin-bottom: 0.125rem;
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
.tag {
|
||||
background-color: var(--M6-background-brown);
|
||||
color: black;
|
||||
font-family: var(--sans-serif);
|
||||
font-size: var(--font-size-10);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
text-rendering: optimizeLegibility;
|
||||
align-items: center;
|
||||
border-radius: 2px;
|
||||
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5);
|
||||
display: inline-flex;
|
||||
font-weight: 500;
|
||||
padding: 0.3em;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { systemPath } from "./constants.mjs";
|
||||
import { loadHelpers } from "./helpers/handlebar-helpers.mjs";
|
||||
import { loadPartials } from "./helpers/partials.mjs";
|
||||
import { loadSettings } from "./helpers/settings.mjs";
|
||||
|
||||
import { CharacterData } from "./data/character-data.mjs";
|
||||
import { WeaponData } from "./data/weapon-data.mjs";
|
||||
@@ -92,6 +93,8 @@ Hooks.once("init", () => {
|
||||
}
|
||||
);
|
||||
|
||||
loadSettings();
|
||||
|
||||
loadHelpers();
|
||||
|
||||
loadPartials();
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
<span class="message-sender">
|
||||
{{alias}}
|
||||
</span>
|
||||
<span class="whisper-to">
|
||||
{{author.name}}
|
||||
</span>
|
||||
{{#if isWhisper}}
|
||||
<span class="whisper-to">{{localize "CHAT.To"}}: {{whisperTo}}</span>
|
||||
{{/if}}
|
||||
|
||||
@@ -3,11 +3,42 @@
|
||||
|
||||
{{!-- <hr> --}}
|
||||
{{#if isContentVisible}}
|
||||
|
||||
{{#if isSpell}}
|
||||
<div class="tags {{#unless zeigeZauberAlsTag}}hidden{{/unless}}">
|
||||
{{#each eigenschaften as |eigenschaft|}}
|
||||
<div class="tag">{{eigenschaft}}</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
<div
|
||||
class="collapsible {{#if zeigeZauberAlsTag}}hidden{{/if}}"
|
||||
data-action="collapsible"
|
||||
>{{localize "Midgard6.Item.merkmale"}}
|
||||
<div>
|
||||
<i class="fas fa-expand"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
{{#each eigenschaften as |eigenschaft|}}
|
||||
{{#if eigenschaft}}
|
||||
<p>{{localizeConcat "Midgard6.Zauber." @key}}: {{eigenschaft}}</p>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if merkmale}}
|
||||
<div class="tags">
|
||||
{{#each merkmale as |merkmal|}}
|
||||
<div class="tag">{{merkmal}}</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if isRoll}}
|
||||
{{#each message.content as |roll|}}
|
||||
<fieldset>
|
||||
{{#if roll.options.title}}<legend>{{roll.options.title}}</legend>{{/if}}
|
||||
{{{roll.html}}}
|
||||
|
||||
</fieldset>
|
||||
{{/each}}
|
||||
{{else}}
|
||||
@@ -19,7 +50,7 @@
|
||||
|
||||
{{#if beschreibung}}
|
||||
<div
|
||||
class="collapsible"
|
||||
class="collapsible beschreibung"
|
||||
data-action="collapsible"
|
||||
>{{localize "Midgard6.Item.Description"}}
|
||||
<div>
|
||||
@@ -31,18 +62,6 @@
|
||||
</div>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
<fieldset>
|
||||
{{#if isRoll}}
|
||||
<legend>???</legend>
|
||||
<div class="dice-roll">
|
||||
<div class="dice-result">
|
||||
<div class="dice-formula">???</div>
|
||||
<h4 class="dice-total">?</h4>
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<p>???</p>
|
||||
{{/if}}
|
||||
</fieldset>
|
||||
{{> "systems/midgard6-lvd/src/templates/chat/secret-roll.hbs"}}
|
||||
{{/if}}
|
||||
</li>
|
||||
@@ -0,0 +1,13 @@
|
||||
<fieldset>
|
||||
{{#if isRoll}}
|
||||
<legend>???</legend>
|
||||
<div class="dice-roll">
|
||||
<div class="dice-result">
|
||||
<div class="dice-formula">???</div>
|
||||
<h4 class="dice-total">?</h4>
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<p>???</p>
|
||||
{{/if}}
|
||||
</fieldset>
|
||||
+15
-33
@@ -4,31 +4,6 @@ export class M6ChatMessage extends ChatMessage {
|
||||
// Default avatar for the chat message
|
||||
static DEFAULT_AVATAR = "icons/svg/mystery-man.svg";
|
||||
|
||||
_attachPartListeners(partId, html, bubble) {
|
||||
super._attachPartListeners(partId, html, bubble);
|
||||
console.warn("Here");
|
||||
|
||||
switch (partId) {
|
||||
case "hintergrund":
|
||||
const collapsible = html.querySelectorAll("div[data-action=collapsible]");
|
||||
if (collapsible) {
|
||||
collapsible.forEach((node) => {
|
||||
node.addEventListener(
|
||||
"click",
|
||||
function () {
|
||||
node.classList.toggle("active");
|
||||
var content = node.nextElementSibling;
|
||||
content.classList.toggle("active");
|
||||
node.getElementsByTagName("i")[0].classList.toggle("fa-compress");
|
||||
},
|
||||
{ capture: true }
|
||||
);
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the HTML for the ChatMessage which should be added to the log
|
||||
* @param {object} [options] Additional options passed to the Handlebars template.
|
||||
@@ -41,7 +16,7 @@ export class M6ChatMessage extends ChatMessage {
|
||||
this.template = CONFIG.ChatMessage.template;
|
||||
|
||||
// By default, GM users have the trash-bin icon in the chat log itself
|
||||
canDelete ??= game.user.isGM;
|
||||
canDelete ??= game.user.isGM || game.user === this.author;
|
||||
|
||||
if (typeof this.system.renderHTML === "function") {
|
||||
const html = await this.system.renderHTML({ canDelete, canClose, ...rest });
|
||||
@@ -101,7 +76,10 @@ export class M6ChatMessage extends ChatMessage {
|
||||
].filterJoin(" "),
|
||||
|
||||
// System-specific flags
|
||||
eigenschaften: this.isContentVisible ? this.getFlag("midgard6-lvd", "eigenschaften") : "",
|
||||
merkmale: this.isContentVisible ? this.getFlag("midgard6-lvd", "merkmale") : "",
|
||||
beschreibung: this.isContentVisible ? this.getFlag("midgard6-lvd", "beschreibung") : "",
|
||||
zeigeZauberAlsTag: game.settings.get("midgard6-lvd", "zauberAlsTag"),
|
||||
isSpell: this.getFlag("midgard6-lvd", "isSpell"),
|
||||
isRoll: this?.isRoll || false
|
||||
};
|
||||
@@ -114,7 +92,6 @@ export class M6ChatMessage extends ChatMessage {
|
||||
// if (this.messageData?.message?.content) {
|
||||
// this.messageData.description = this.messageData?.message?.content;
|
||||
// }
|
||||
console.warn(this.messageData);
|
||||
// Render the chat message
|
||||
let html = await foundry.applications.handlebars.renderTemplate(
|
||||
this.template,
|
||||
@@ -124,12 +101,17 @@ export class M6ChatMessage extends ChatMessage {
|
||||
// Flag expanded state of dice rolls
|
||||
Hooks.callAll("renderChatMessageHTML", this, html, this.messageData);
|
||||
|
||||
// Get whether descriptions should auto-collapse for this user or not and apply the styling
|
||||
// const autoCollapse = game.settings.get("midgard6-lvd", "autoCollapseDescriptions");
|
||||
// if (!autoCollapse) {
|
||||
// const collapsibleContent = html.querySelector(".collapsible-content");
|
||||
// if (collapsibleContent) collapsibleContent.style.maxHeight = "unset";
|
||||
// }
|
||||
// Get whether descriptions should auto-expand for this user or not and apply the styling
|
||||
const autoExpand = game.settings.get("midgard6-lvd", "beschreibungChatActive");
|
||||
if (autoExpand) {
|
||||
const collapsibleContent = html.querySelector(".collapsible.beschreibung");
|
||||
if (collapsibleContent) {
|
||||
collapsibleContent.classList.toggle("active");
|
||||
var content = collapsibleContent.nextElementSibling;
|
||||
content.classList.toggle("active");
|
||||
collapsibleContent.getElementsByTagName("i")[0].classList.toggle("fa-compress");
|
||||
}
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user