Fix Turret chnage not affecting DPM

This commit is contained in:
Mark Greene committed 2025-12-27 15:35:16 +13:00
1 parent de8d3396b1
commit 9d4e1a66a1
1 file changed
+12 -6
@@ -176,11 +176,17 @@ export function Modules() {
(turret) => turret.id === unlock.id (turret) => turret.id === unlock.id
)!; )!;
if ( // Check if current gun exists in new turret
!draft.protagonist.turret.guns.some( const gunInNewTurret = draft.protagonist.turret.guns.find(
(gun) => gun.id === draft.protagonist.gun.id (gun) => gun.id === draft.protagonist.gun.id
) );
) {
if (gunInNewTurret) {
// Gun exists - get it FROM this turret (this fixes the bug!)
draft.protagonist.gun = gunInNewTurret;
draft.protagonist.shell = gunInNewTurret.shells[0];
} else {
// Gun doesn't exist - select top gun from new turret
draft.protagonist.gun = draft.protagonist.turret.guns.at(-1)!; draft.protagonist.gun = draft.protagonist.turret.guns.at(-1)!;
draft.protagonist.shell = draft.protagonist.gun.shells[0]; draft.protagonist.shell = draft.protagonist.gun.shells[0];
} }
@@ -422,4 +428,4 @@ export function Modules() {
</Flex> </Flex>
</ConfigurationChildWrapper> </ConfigurationChildWrapper>
); );
} }