fix: use non-compounding percentages

This commit is contained in:
TrèsAbhi committed 2024-02-16 23:08:20 -06:00
1 parent 2c8c04387b
commit 9174f3c9d0
11 files changed
+279 -215

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
export function coefficient(...effects: [boolean, number][]) {
return effects.reduce((accumulator, b) => accumulator + (b[0] ? b[1] : 0), 1);
}
+3 -1
View File
@@ -5,9 +5,9 @@ import { fetchCdonLz4 } from './fetchCdonLz4';
export interface ProvisionEntry {
id: number;
name: string;
effects?: Record<string, number>;
include: TankFilterDefinition[];
exclude?: TankFilterDefinition[];
crew?: number;
}
export interface ProvisionDefinitions {
@@ -17,3 +17,5 @@ export interface ProvisionDefinitions {
export const provisionDefinitions = fetchCdonLz4<ProvisionDefinitions>(
asset('definitions/provisions.cdon.lz4'),
);
provisionDefinitions.then(console.log);
+6 -12
View File
@@ -3,24 +3,18 @@ import { GunDefinition, ShellDefinition } from './tankDefinitions';
export function resolveDpm(
gun: GunDefinition,
shell: ShellDefinition,
hasRammer = false,
hasShellReloadBoost = false,
hasAdrenaline = false,
hasTungsten = false,
damageCoefficient = 1,
reloadCoefficient = 1,
interClipCoefficient = 1,
) {
const alpha = shell.damage.armor * (hasTungsten ? 1.15 : 1);
const alpha = shell.damage.armor * damageCoefficient;
if (gun.type === 'regular') {
return (
(alpha /
((hasRammer ? 0.93 : 1) * (hasAdrenaline ? 0.8 : 1) * gun.reload)) *
60
);
return (alpha / (reloadCoefficient * gun.reload)) * 60;
} else if (gun.type === 'autoLoader') {
return (
((alpha * gun.count) /
(gun.reload +
(gun.count - 1) * gun.interClip * (hasShellReloadBoost ? 0.7 : 1))) *
(gun.reload + (gun.count - 1) * gun.interClip * interClipCoefficient)) *
60
);
} else {
+3
View File
@@ -0,0 +1,3 @@
export function sum(...effects: [boolean, number][]) {
return effects.reduce((accumulator, b) => accumulator + (b[0] ? b[1] : 0), 0);
}
-7
View File
@@ -27,13 +27,6 @@ export const CREW_MEMBER_NAMES: Record<CrewMember, string> = {
driver: 'Driver',
loader: 'Loader',
};
export const CREW_MEMBER_NAMES_PLURAL: Record<CrewMember, string> = {
commander: 'Commanders',
radioman: 'Radiomen',
gunner: 'Gunners',
driver: 'Drivers',
loader: 'Loaders',
};
export interface Crew {
type: CrewMember;
count?: number;
+6
View File
@@ -0,0 +1,6 @@
import { useTankopediaTemporary } from '../../stores/tankopedia';
export function useProvision(id: number) {
const provisions = useTankopediaTemporary((state) => state.provisions);
return provisions.includes(id);
}
+9
View File
@@ -0,0 +1,9 @@
import { use } from 'react';
import { useTankopediaTemporary } from '../../stores/tankopedia';
import { provisionDefinitions } from './provisionDefinitions';
export function useProvisions() {
const provisions = useTankopediaTemporary((state) => state.provisions);
const awaitedProvisionDefinitions = use(provisionDefinitions);
return provisions.map((id) => awaitedProvisionDefinitions[id]);
}