Skip to content

Commit

Permalink
feat: create lcars countdown panel
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosFdez committed Nov 18, 2023
1 parent a727321 commit a426cbd
Show file tree
Hide file tree
Showing 10 changed files with 952 additions and 81 deletions.
1 change: 0 additions & 1 deletion src/module/actor/army/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ interface ArmyDetailsSource extends Required<ActorDetailsSource> {
strongSave: string;
weakSave: string;
description: string;
blurb: string;
}

interface ArmySystemData extends Omit<ArmySystemSource, "attributes">, ActorSystemData {
Expand Down
37 changes: 37 additions & 0 deletions src/module/actor/army/sheet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { ActorSheetPF2e } from "@actor/sheet/base.ts";
import { ArmyPF2e } from "./document.ts";
import { ActorSheetDataPF2e } from "@actor/sheet/data-types.ts";
import { Alignment } from "./types.ts";
import { ALIGNMENTS, ARMY_TYPES } from "./values.ts";
import { kingmakerTraits } from "@scripts/config/traits.ts";
import * as R from "remeda";

class ArmySheetPF2e extends ActorSheetPF2e<ArmyPF2e> {
static override get defaultOptions(): ActorSheetOptions {
const options = super.defaultOptions;
return {
...options,
classes: [...options.classes, "army"],
template: "systems/pf2e/templates/actors/army/sheet.hbs",
};
}

override async getData(options?: Partial<ActorSheetOptions>): Promise<ArmySheetData> {
const data = await super.getData(options);

return {
...data,
alignments: ALIGNMENTS,
armyTypes: R.pick(kingmakerTraits, ARMY_TYPES),
rarityTraits: CONFIG.PF2E.rarityTraits,
};
}
}

interface ArmySheetData extends ActorSheetDataPF2e<ArmyPF2e> {
alignments: Iterable<Alignment>;
armyTypes: Record<string, string>;
rarityTraits: Record<string, string>;
}

export { ArmySheetPF2e };
20 changes: 14 additions & 6 deletions src/module/actor/army/values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,36 @@ function fetchArmyGearData(gearType: String): Object {
? "icons/weapons/axes/axe-battle-black.webp"
: "icons/weapons/crossbows/crossbow-simple-brown.webp",
name: game.i18n.localize("PF2E.Kingmaker.Army.Gear.Weapons.name"),
level: game.i18n.localize("PF2E.Kingmaker.Army.Gear.Weapons.level"),
description: game.i18n.localize("PF2E.Kingmaker.Army.Gear.Weapons.description"),
traits: ["army", "magical"],
ranks: 3,
level: game.i18n.localize("PF2E.Kingmaker.Army.Gear.Weapons.level"),
ranks: [
{ price: 20, level: 2 },
{ price: 40, level: 10 },
{ price: 60, level: 16 },
],
};
case "potions":
return {
img: "icons/consumables/potions/bottle-round-corked-orante-red.webp",
name: game.i18n.localize("PF2E.Kingmaker.Army.Gear.Potions.name"),
level: game.i18n.localize("PF2E.Kingmaker.Army.Gear.Potions.level"),
description: game.i18n.localize("PF2E.Kingmaker.Army.Gear.Potions.description"),
price: game.i18n.localize("PF2E.Kingmaker.Army.Gear.Potions.price"),
traits: ["army", "consumable", "healing", "magical", "potion"],
level: game.i18n.localize("PF2E.Kingmaker.Army.Gear.Potions.level"),
price: 15,
};
case "armor":
return {
img: "icons/equipment/shield/heater-wooden-brown-axe.webp",
name: game.i18n.localize("PF2E.Kingmaker.Army.Gear.Armor.name"),
level: game.i18n.localize("PF2E.Kingmaker.Army.Gear.Armor.level"),
description: game.i18n.localize("PF2E.Kingmaker.Army.Gear.Armor.description"),
traits: ["army", "magical"],
ranks: 3,
level: game.i18n.localize("PF2E.Kingmaker.Army.Gear.Armor.level"),
ranks: [
{ price: 25, level: 5 },
{ price: 50, level: 11 },
{ price: 75, level: 18 },
],
};
default:
return {};
Expand Down
4 changes: 3 additions & 1 deletion src/scripts/handlebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export function registerHandlebarsHelpers(): void {
});

Handlebars.registerHelper("times", (count: unknown, options: Handlebars.HelperOptions): string =>
[...Array(Number(count)).keys()].map((i) => options.fn(i, { data: options.data, blockParams: [i] })).join(""),
[...Array(Number(count) || 0).keys()]
.map((i) => options.fn(i, { data: options.data, blockParams: [i] }))
.join(""),
);

Handlebars.registerHelper("concat", (...params: unknown[]): string => {
Expand Down
8 changes: 8 additions & 0 deletions src/scripts/register-sheets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { UserConfigPF2e } from "@module/user/sheet.ts";
import { SceneConfigPF2e } from "@scene/sheet.ts";
import { TokenDocumentPF2e } from "@scene/token-document/document.ts";
import { TokenConfigPF2e } from "@scene/token-document/sheet.ts";
import { ArmySheetPF2e } from "@actor/army/sheet.ts";

export function registerSheets(): void {
const sheetLabel = game.i18n.localize("PF2E.SheetLabel");
Expand Down Expand Up @@ -101,6 +102,13 @@ export function registerSheets(): void {
makeDefault: true,
});

// Army
Actors.registerSheet("pf2e", ArmySheetPF2e, {
types: ["army"],
label: game.i18n.format(sheetLabel, { type: localizeType("army") }),
makeDefault: true,
});

// ITEM
Items.unregisterSheet("core", ItemSheet);

Expand Down
2 changes: 2 additions & 0 deletions src/styles/actor/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ $header-height: 89px; /* Adjust height of the header */

@import "party";

@import "army";

/* Mystification data revealed to GMs */
.gm-mystified-data {
opacity: 0.75;
Expand Down
Loading

0 comments on commit a426cbd

Please sign in to comment.