Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 11.6.1 #281

Merged
merged 3 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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