+26
public/styles/kingdom-sheet.css
+26
public/styles/kingdom-sheet.css
···
179
179
.kmhb-checkbox {
180
180
display: inline;
181
181
float: right;
182
+
}
183
+
184
+
.kmhb-effects-container {
185
+
width: 75%;
186
+
margin: 0 auto;
187
+
}
188
+
189
+
.kmhb-effects-container h4 {
190
+
margin-top: 1rem;
191
+
}
192
+
193
+
.kmhb-effect-name {
194
+
display: inline;
195
+
margin: 0;
196
+
}
197
+
198
+
.kmhb-effect-control {
199
+
float: right;
200
+
position: relative;
201
+
right: 0;
202
+
border: 0;
203
+
top: -5px;
204
+
}
205
+
206
+
.kmhb-effect {
207
+
margin: 1em 0;
182
208
}
+2
-2
src/kingdom.ts
+2
-2
src/kingdom.ts
···
22
22
* @property {number} level - The level of the Kingdom
23
23
* @property {number} xp - The amount of experience points the Kingdom has
24
24
* @property {Record<string, boolean>} activities - Whether or not activities are enabled; if a value isn't found, it should default to `true`
25
-
* @property {any} effects - The effects in the Kingdom; I can't actively link to EffectPF2E, but that is what is stored in here
25
+
* @property {any[]} effects - The effects in the Kingdom
26
26
*/
27
27
export interface Kingdom {
28
28
name: string;
···
47
47
isFame: boolean;
48
48
activities: Record<string, boolean>;
49
49
atWar: boolean;
50
-
effects: any[]
50
+
effects: { name: string, slug: string, description: string, rules: any[] }[]
51
51
}
52
52
53
53
export function createKingdom(): Kingdom {
+49
-1
src/svelte/tabs/effects.svelte
+49
-1
src/svelte/tabs/effects.svelte
···
1
1
<script lang="ts">
2
2
import type { KingdomActor } from "../../global";
3
+
import { deleteArrayElement, enrichAndLocalize, enrichText, kmLocalize } from "../../utils";
4
+
import { socket } from "../../socket";
3
5
4
6
let { actor }: { actor: KingdomActor } = $props();
7
+
8
+
function effectDrop(event: DragEvent): void {
9
+
event.preventDefault();
10
+
const data: string | undefined = event.dataTransfer?.getData("text/plain");
11
+
12
+
if (data === undefined) {
13
+
return;
14
+
}
15
+
16
+
let dropped: { type: string, uuid: string };
17
+
18
+
try {
19
+
dropped = JSON.parse(data);
20
+
} catch {
21
+
return;
22
+
}
23
+
24
+
if (dropped.type !== "Item") {
25
+
return;
26
+
}
27
+
28
+
fromUuid(dropped.uuid).then((effect: any): void => {
29
+
console.log(effect);
30
+
const currentEffects = actor.getFlag("kingdom-homebrew", "effects") as any[];
31
+
currentEffects.push({ rules: effect.system.rules, name: effect.name, description: effect.system.description.value, slug: effect.system.slug });
32
+
socket!.executeAsGM("updateKingdomValue", "effects", actor, currentEffects);
33
+
});
34
+
}
35
+
36
+
function deleteEffect(event: Event): void {
37
+
const index: number = parseInt((event.target as HTMLButtonElement).dataset.index!);
38
+
const array = actor.getFlag("kingdom-homebrew", "effects") as any[];
39
+
deleteArrayElement(array, index);
40
+
socket!.executeAsGM("updateKingdomValue", "effects", actor, array);
41
+
}
5
42
</script>
6
43
7
-
<p>effects</p>
44
+
<div class="kmhb-effects-container" ondragover={(ev: Event): void => ev.preventDefault()} role="form" ondrop={effectDrop}>
45
+
<h4>{kmLocalize("sheet", "tab", "effects")}</h4>
46
+
{#each actor.getFlag("kingdom-homebrew", "effects") as effect, index}
47
+
<div class="kmhb-effect">
48
+
<h5 class="kmhb-effect-name" id={`kmhb-${effect.slug}`}>{effect.name}</h5>
49
+
<button class="kmhb-effect-control" data-tooltip="PF2E.DeleteItemTitle" aria-labelledby={`kmhb-${effect.slug}`} data-index={index} onclick={deleteEffect}>
50
+
<i class="fa-solid fa-fw fa-trash"></i>
51
+
</button>
52
+
{@html await enrichText(effect.description, false)}
53
+
</div>
54
+
{/each}
55
+
</div>