Skip to content

Commit

Permalink
Merge pull request #390 from fvtt-fria-ligan/12-28-refactor_Remove_co…
Browse files Browse the repository at this point in the history
…mbat_module_in_favour_of_yzec

refactor: ♻️ Remove combat module in favour of yzec
  • Loading branch information
aMediocreDad authored Dec 28, 2023
2 parents 0b18b20 + 33f76f7 commit ac89e2e
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 252 deletions.
19 changes: 19 additions & 0 deletions .changeset/clean-dolls-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
"forbidden-lands": patch
---

- Removes the combat module in favour of Year Zero Combat which is now required. Fixes to slow fast actions are being implemented in https://github.com/fvtt-fria-ligan/yearzero-combat-fvtt/pull/38
- Fixes an issue where roll modifiers were not applied to rolls
- Fixes an issue where the fast and slow actions had the wrong icons (#389)

If a token i stuck with old icons, it is possible to create a script macro that deletes all active effects on the current scene:

```js
canvas.scene.tokens.map((token) => {
const actor = token.actor;
actor.deleteEmbeddedDocuments(
"ActiveEffect",
actor.effects.map((e) => e.id)
);
});
```
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ As well as plenty of users who have come with great feedback, either on [the off
## :computer: Websites

- [Foundry VTT](https://foundryvtt.com/)
- [Fria Ligan: Forbidden Lands](https://frialigan.se/en/store/?collection_id=84541866032)
- [Fria Ligan: Forbidden Lands](https://freeleaguepublishing.com/games/forbidden-lands/)

## 📝 Licenses

- **Logo and Content:** The [Forbidden Lands](https://frialigan.se/en/store/?collection_id=84541866032) logo and content is Copyright © and Trademarked by Free League Publishing. The parts of this project protected under this copyright may not be distributed commercially or freely. This includes art, logo, and copyright text (like the character-generator.json) sourced from the [Forbidden Lands](https://frialigan.se/en/store/?collection_id=84541866032) tabletop RPG.
> Some content may be reused under [Free League's Open Gaming License](https://freeleaguepublishing.com/en/open-gaming-license/).
- **Logo and Content:** The [Forbidden Lands](https://freeleaguepublishing.com/games/forbidden-lands/) logo and content is Copyright © and Trademarked by Free League Publishing. The parts of this project protected under this copyright may not be distributed commercially or freely. This includes art, logo, and copyright text (like the character-generator.json) sourced from the [Forbidden Lands](https://freeleaguepublishing.com/games/forbidden-lands/) tabletop RPG.
> Some content may be reused under [Free League's Open Gaming License](https://freeleaguepublishing.com/community-content/free-tabletop-licenses/).
- **Source Code:** All source code _(javascript, hbs, scss, as well as system templates and the like)_, are Copyright © 2021 [Free League Developer Community](https://github.com/fvtt-fria-ligan), and licenced under the [GNU General Public License v3.0](https://github.com/fvtt-fria-ligan/forbidden-lands-foundry-vtt/blob/main/LICENSE).
- **Foundry VTT:** The project is created following the Foundry VTT [Limited License Agreement for module development](https://foundryvtt.com/article/license/).
- **Fonts:** The fonts used in this project carry their own licenses:
Expand Down
3 changes: 1 addition & 2 deletions src/actor/actor-document.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ export class ForbiddenLandsActor extends Actor {
if (!rollIdentifiers.length) return [];
const itemModifiers = this.items.reduce((array, item) => {
const modifiers = item.getRollModifier(...rollIdentifiers);
if (modifiers) array.concat(modifiers);
return array;
return modifiers ? array.concat(modifiers) : array;
}, []);
if (rollIdentifiers.includes("dodge")) {
itemModifiers.push({
Expand Down
17 changes: 6 additions & 11 deletions src/forbidden-lands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ import {
utilities,
} from "@journal/adventure-sites/adventure-site-generator.js";
import { ForbiddenLandsJournalEntry } from "@journal/journal-document.js";
import {
FBLCombat,
FBLCombatTracker,
FBLCombatant,
} from "@system/combat/combat.js";
import FBL, { modifyConfig } from "@system/core/config.js";
import { initializeEditorEnrichers } from "@system/core/editor.js";
import { registerFonts } from "@system/core/fonts.js";
Expand Down Expand Up @@ -51,15 +46,15 @@ Hooks.once("init", () => {
};

CONFIG.Actor.documentClass = ForbiddenLandsActor;
CONFIG.Combat.documentClass = FBLCombat;
// @ts-expect-error - PF2 types Internal Type Error
CONFIG.Combatant.documentClass = FBLCombatant;
CONFIG.Item.documentClass = ForbiddenLandsItem;
// @ts-expect-error - PF2 types Internal Type Error
CONFIG.JournalEntry.documentClass = ForbiddenLandsJournalEntry;
// @ts-expect-error - PF2 types Internal Type Error
CONFIG.ui.combat = FBLCombatTracker;
CONFIG.statusEffects = FBL.statusEffects;
CONFIG.statusEffects = [
...CONFIG.statusEffects.filter(
(effect) => !["sleep", "frozen", "curse"].includes(effect.id),
),
...FBL.statusEffects,
];
CONFIG.fbl = FBL;
CONFIG.fbl.adventureSites.utilities = utilities;
CONFIG.fbl.adventureSites.generate = (path: string, adventureSite: unknown) =>
Expand Down
164 changes: 0 additions & 164 deletions src/system/combat/combat.js

This file was deleted.

22 changes: 1 addition & 21 deletions src/system/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ const FBL = {
statusEffects: [
{
id: "sleepy",
icon: "icons/svg/unconscious.svg",
icon: "icons/svg/sleep.svg",
label: "CONDITION.SLEEPY",
changes: [
{
Expand Down Expand Up @@ -318,26 +318,6 @@ const FBL = {
],
statuses: ["cold"],
},
{
id: "fastAction",
icon: "modules/yze-combat/assets/icons/fast-action.svg",
label: "COMBAT.TOGGLE_FAST",
flags: {
"forbidden-lands": {
fast: true,
},
},
},
{
id: "slowAction",
icon: "modules/yze-combat/assets/icons/slow-action.svg",
label: "COMBAT.TOGGLE_SLOW",
flags: {
"forbidden-lands": {
slow: true,
},
},
},
],
weaponFeatures: [
"blunt",
Expand Down
38 changes: 18 additions & 20 deletions src/system/core/hooks.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Changelog } from "$changelog/changelog.js";
import { handleHotbarDrop } from "@components/macros/macros.js";
import { FBLRollHandler } from "@components/roll-engine/engine.js";
import localizeString from "@utils/localize-string.js";
import { registerDiceSoNice } from "../../external-api/dice-so-nice.js";

/**
Expand All @@ -18,6 +17,24 @@ export default function registerHooks() {
registerDiceSoNice(dice3d);
});

Hooks.on("yzeCombatReady", () => {
if (game.settings.get("forbidden-lands", "configuredYZEC")) return;
try {
game.settings.set("yze-combat", "resetEachRound", false);
game.settings.set("yze-combat", "slowAndFastActions", true);
game.settings.set("yze-combat", "initAutoDraw", true);
game.settings.set("yze-combat", "duplicateCombatantOnCombatStart", true);
game.settings.set(
"yze-combat",
"actorSpeedAttribute",
"system.movement.value",
);
game.settings.set("forbidden-lands", "configuredYZEC", true);
} catch (e) {
console.error("Could not configure YZE Combat", e);
}
});

Hooks.on("renderPause", (_app, html) => {
html.find("img").attr("src", "systems/forbidden-lands/assets/fbl-sun.webp");
});
Expand Down Expand Up @@ -210,25 +227,6 @@ export default function registerHooks() {
}
});

/**
* Registers a custom chat command that lets us listen for either "/fblroll" or "/fblr".
*/
Hooks.on("getCombatTrackerEntryContext", (_, options) => {
options.splice(1, -1, {
name: localizeString("COMBAT.DUPLICATE"),
icon: "<i class='fas fa-copy'></i>",
callback: (li) => {
const combatant = game.combats.viewed.combatants.get(
li.data("combatant-id"),
);
if (combatant)
return game.combats.viewed.createEmbeddedDocuments("Combatant", [
combatant.clone().data,
]);
},
});
});

/**
* GM screen module causes buttons in Actor sheets to disable.
* Undo this, so its possible to roll Attributes, Skills, etc. from GM Screen.
Expand Down
19 changes: 0 additions & 19 deletions src/system/core/hud.js

This file was deleted.

16 changes: 16 additions & 0 deletions src/system/core/hud.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export class ForbiddenLandsTokenHUD extends TokenHUD {
_getStatusEffectChoices() {
const actor = this.object.document.actor;

const data = super._getStatusEffectChoices();

if (actor?.type === "character") return data;

for (const [key, effect] of Object.entries(data)) {
if (effect && CONFIG.fbl.conditions.includes(effect?.id))
delete data[key];
}

return data;
}
}
9 changes: 9 additions & 0 deletions src/system/core/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ export default function registerSettings() {
type: Number,
});

game.settings.register("forbidden-lands", "configuredYZEC", {
name: "YZEC Configured",
hint: "Used to track if the YZEC has been configured.",
scope: "world",
config: false,
default: false,
type: Boolean,
});

game.settings.register("forbidden-lands", "messages", {
name: "Displayed Messages",
hint: "Used to track which messages have been displayed.",
Expand Down
Loading

0 comments on commit ac89e2e

Please sign in to comment.