Skip to content

Commit

Permalink
Merge pull request #281 from Muttley/develop
Browse files Browse the repository at this point in the history
Release 11.6.1
  • Loading branch information
Muttley authored Mar 28, 2024
2 parents 75118d6 + 9909156 commit c3144fc
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v11.6.1

# Enhancements
- [#280] Cache available Ammo items in compendiums at startup to improve performance on slow systems with large amounts of compendium items
* This will mean that if you add a new ammo item type it won't be available on Weapon item sheets until the system is reloaded.

---

# v11.6.0

# Enhancements
Expand Down
14 changes: 14 additions & 0 deletions system/src/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,20 @@ FALLOUT.WEAPON_TYPES = {
unarmed: "FALLOUT.WEAPONS.weaponType.unarmed",
};

export async function discoverAvailableAmmoTypes() {
const ammo = await fallout.compendiums.ammo();

CONFIG.FALLOUT.AMMO_BY_UUID = {};
let ammoTypes = [];
for (const ammoType of ammo) {
ammoTypes.push(ammoType.name);
CONFIG.FALLOUT.AMMO_BY_UUID[ammoType.uuid] = ammoType.name;
}
ammoTypes = [...new Set(ammoTypes)]; // de-dupe

CONFIG.FALLOUT.AMMO_TYPES = ammoTypes.sort((a, b) => a.localeCompare(b));
}

export async function generateEnrichedTooltips() {
CONFIG.FALLOUT.WEAPON_QUALITY_TOOLTIPS = {};
CONFIG.FALLOUT.WEAPON_QUALITY_HAS_RANK = {};
Expand Down
6 changes: 5 additions & 1 deletion system/src/hooks/setupHook.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { generateEnrichedTooltips } from "../config.mjs";
import {
discoverAvailableAmmoTypes,
generateEnrichedTooltips,
} from "../config.mjs";

export const setupHook = {
attach: () => {
Expand All @@ -20,6 +23,7 @@ export const setupHook = {
}

generateEnrichedTooltips();
discoverAvailableAmmoTypes();
});
},
};
19 changes: 6 additions & 13 deletions system/src/sheets/FalloutItemSheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,13 @@ export default class FalloutItemSheet extends ItemSheet {
}

if (item.type === "weapon") {
const ammo = await fallout.compendiums.ammo();

context.ammoUuid = ammo.find(
a => a.name === this.item.system.ammo
)?.uuid ?? "";


let ammoTypes = [];
for (const ammoType of ammo) {
ammoTypes.push(ammoType.name);
for (const [uuid, name] of Object.entries(CONFIG.FALLOUT.AMMO_BY_UUID)) {
if (name === this.item.system.ammo) {
context.ammoUuid = uuid;
break;
}
}
ammoTypes = [...new Set(ammoTypes)]; // de-dupe

context.ammoTypes = ammoTypes.sort((a, b) => a.localeCompare(b));
context.ammoTypes = CONFIG.FALLOUT.AMMO_TYPES;

context.damageTypes = [];
for (const key in CONFIG.FALLOUT.DAMAGE_TYPES) {
Expand Down
2 changes: 1 addition & 1 deletion system/system.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "fallout",
"title": "Fallout: The Roleplaying Game",
"description": "An unofficial system for playing the Fallout RPG from Modiphius Entertainment Ltd.",
"version": "11.6.0",
"version": "11.6.1",
"compatibility": {
"minimum": "11",
"verified": "11"
Expand Down

0 comments on commit c3144fc

Please sign in to comment.