Skip to content

Commit

Permalink
fix: Actors not initializing correctly (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
aMediocreDad authored Feb 28, 2024
1 parent 6a2253a commit d62508b
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 43 deletions.
3 changes: 2 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"challenge-prompt": "Click to add an image of a challenge card (as found in the tinderbox), right-click to rename.",
"confirm-delete-content": "Are you sure you want to delete this?",
"confirm-delete-title": "Confirm Delete",
"dblclick-open": "Double-click to edit",
"error-burning-tag": "There was an error trying to burn your tag. Please see the console for more information.",
"error-validating-actor": "There was an error validating the actor. Please see the console for more information.",
"import-actor": "Import Actor from JSON",
Expand All @@ -139,4 +140,4 @@
"failure": "Miss",
"consequence": "Mixed Hit",
"success": "Strong Hit"
}
}
2 changes: 1 addition & 1 deletion scripts/actor/character/character-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class CharacterData extends foundry.abstract.DataModel {

get powerTags() {
return this.allTags.filter(
(tag) => tag.type === "powerTag" || tag.type === "themeTag",
(tag) => tag.type === "powerTag" || tag.type === "themeTag" || tag.type === "backpack",
);
}

Expand Down
25 changes: 1 addition & 24 deletions scripts/item/theme-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,9 @@ export class ThemeData extends foundry.abstract.DataModel {
isBurnt: new fields.BooleanField(),
powerTags: new fields.ArrayField(
new fields.EmbeddedDataField(abstract.TagData),
{
initial: Array(5)
.fill()
.map((_, i) => ({
name: "Name your tag",
type: "powerTag",
isActive: i < 2,
id: randomID(),
})),
validate: (tags) => Object.keys(tags).length === 5,
},
),
weaknessTags: new fields.ArrayField(
new fields.EmbeddedDataField(abstract.TagData),
{
initial: [
{
name: "Name your Weakness",
type: "weaknessTag",
isActive: true,
isBurnt: false,
id: randomID(),
},
],
validate: (tags) => Object.keys(tags).length === 1,
},
new fields.EmbeddedDataField(abstract.TagData)
),
experience: new fields.NumberField({
integer: true,
Expand Down
56 changes: 42 additions & 14 deletions scripts/system/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,15 @@ export class LitmHooks {
Hooks.on("createActor", async (actor) => {
if (actor.type !== "character") return;

await Item.createDocuments(
Array(4)
.fill()
.map(() => ({
for (const item of Array(4).fill()) {
console.log("Creating theme", item)
await actor.createEmbeddedDocuments("Item", [
{
name: "New Theme",
type: "theme",
})),
{ parent: actor },
);
},
]);
}
});
}

Expand All @@ -223,7 +223,25 @@ export class LitmHooks {
if (data.type !== "theme") return;

const img = "systems/litm/assets/media/note.webp";
item.updateSource({ img });
const powerTags = Array(5)
.fill()
.map((_, i) => ({
name: "Name your tag",
type: "powerTag",
isActive: i < 2,
isBurnt: false,
id: randomID(),
}));
const weaknessTags = [
{
name: "Name your Weakness",
type: "weaknessTag",
isActive: true,
isBurnt: false,
id: randomID(),
}
];
item.updateSource({ img, system: { powerTags, weaknessTags } });
});
}

Expand Down Expand Up @@ -264,11 +282,11 @@ export class LitmHooks {
name: "Legend in the Mist",
permission: { default: 2 },
content: `
<h1 style="text-align: center;"><span style="font-family: PackardAntique">Welcome!</span></h1>
<h1 style="text-align:center"><span style="font-family: PackardAntique">Welcome!</span></h1>
<p></p>
<p style="text-align: center;"><span style="font-family: AlchemyItalic"><em><strong>I am thrilled to have you try out
<p style="text-align: center"><span style="font-family: AlchemyItalic"><em><strong>I am thrilled to have you try out
this system!</strong></em></span></p>
<blockquote style="padding: 0.5em 10px;background: var(--litm-color-primary-bg);color: var(--litm-color-weakness);">
<blockquote style="padding:0.5em 10px;background:var(--litm-color-primary-bg);color:var(--litm-color-weakness)">
<p><span style="font-family: CaslonAntique"><strong>Please be aware that both the system—and game—is under heavy
development. And that there might be breaking bugs or major changes down the road.</strong></span></p>
<p><br><span style="font-family: PackardAntique">PLEASE MAKE FREQUENT BACKUPS</span></p>
Expand Down Expand Up @@ -315,8 +333,9 @@ export class LitmHooks {
<ul>
<li>
<p><span style="font-family: Modesto Condensed"><strong>Right-clicking</strong></span> a <strong>Tag </strong>in
the <strong>Bacpack</strong> will prompt you for deleting the tag. The same goes for <strong>Themes</strong>
in a <strong>Character</strong>-sheet.</p>
the <strong>Backpack</strong> will prompt you for deleting the tag. The same goes for
<strong>Themes</strong> in a <strong>Character</strong>-sheet. <strong>Right-clicking </strong>a tag in the
<strong>Backpack</strong>, will delete it.</p>
</li>
<li>
<p>If your <strong>Character</strong><em><strong> </strong></em>is missing <strong>Theme</strong>s you can
Expand All @@ -326,7 +345,7 @@ export class LitmHooks {
<li>
<p><strong>Theme</strong>s can be <span
style="font-family: Modesto Condensed"><strong>rearranged</strong></span> on a sheet.
<strong>Tag</strong>s in the Backpack and on <strong>Theme</strong>s cannot.</p>
<strong>Tag</strong>s in the <strong>Backpack</strong> and on <strong>Theme</strong>s cannot.</p>
</li>
<li>
<p><span style="font-family: Modesto Condensed"><strong>Double-clicking </strong></span>a <strong>Theme</strong>
Expand All @@ -345,6 +364,15 @@ export class LitmHooks {
`,
});

ChatMessage.create({
title: "Welcome to Legend in the Mist",
content: `
<p><strong>Welcome to Legend in the Mist</strong></p>
<p>Before you start playing, you might want to read the <a class="content-link" draggable="true" data-uuid="JournalEntry.QVA4cPjUWlDPMR8F.JournalEntryPage.5AWCygW0BCFdk4sd" data-id="5AWCygW0BCFdk4sd" data-type="JournalEntryPage" data-tooltip="Text Page"><i class="fas fa-file-lines"></i>Legend in the Mist</a> journal entry. It contains some important information about the system and what to expect.</p>
<p>Good luck and have fun!</p>
`,
});

await sleep(300);
await scene.activate();
await sleep(300);
Expand Down
1 change: 1 addition & 0 deletions styles/item/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@
color: var(--litm-color-accent);
font-family: var(--litm-font-accent);
font-size: var(--font-size-20);
text-align: center;

& [role="textbox"] {
background: transparent;
Expand Down
2 changes: 1 addition & 1 deletion styles/root.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ button,
border-color: var(--litm-color-accent-bg);
}

.chat-message {
.chat-message:has(.litm.dice-roll) {
background-color: var(--litm-color-weakness);
background-blend-mode: color-burn;
color: var(--litm-color-primary-bg);
Expand Down
2 changes: 1 addition & 1 deletion system.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/foundryvtt-system-manifest.json",
"id": "litm",
"version": 0,
"version": 1,
"license": "LICENSE",
"title": "Legend in the Mist",
"description": "A Rustic Fantasy Game for Foundry VTT",
Expand Down
2 changes: 1 addition & 1 deletion templates/item/theme-ro.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- Readonly version of the Theme template -->
<!-- Intended for use embedded on a character sheet -->
<input type="hidden" name="items.{{data._id}}.type" value="{{data.type}}" />
<div class="litm--theme-background">
<div class="litm--theme-background" data-tooltip="{{localize 'Litm.ui.dblclick-open'}}" data-tooltip-direction="LEFT">
<div class="litm--theme-meta litm--accent-bg">
<span class="litm--theme-meta-part">{{data.system.themebook}}</span>
<span class="litm--theme-meta-part">{{data.system.level}} THEME</span>
Expand Down

0 comments on commit d62508b

Please sign in to comment.