feat: shell capacity

This commit is contained in:
tresabhi committed 2024-11-09 19:16:06 -06:00
1 parent c4fa6cebfa
commit 3da154b75d
9 files changed
+52 -1

No files matched your search

@@ -155,6 +155,7 @@ message GunDefinitionBase {
required float dispersion_shot = 12; required float dispersion_shot = 12;
required float dispersion_damaged = 13; required float dispersion_damaged = 13;
repeated Unlock unlocks = 14; repeated Unlock unlocks = 14;
required uint32 shell_capacity = 15;
} }
message ShellDefinition { message ShellDefinition {
@@ -484,6 +484,7 @@ export interface GunDefinitionBase {
dispersion_shot: number; dispersion_shot: number;
dispersion_damaged: number; dispersion_damaged: number;
unlocks: Unlock[]; unlocks: Unlock[];
shell_capacity: number;
} }
export interface ShellDefinition { export interface ShellDefinition {
@@ -2944,6 +2945,7 @@ function createBaseGunDefinitionBase(): GunDefinitionBase {
dispersion_shot: 0, dispersion_shot: 0,
dispersion_damaged: 0, dispersion_damaged: 0,
unlocks: [], unlocks: [],
shell_capacity: 0,
}; };
} }
@@ -2991,6 +2993,9 @@ export const GunDefinitionBase: MessageFns<GunDefinitionBase> = {
for (const v of message.unlocks) { for (const v of message.unlocks) {
Unlock.encode(v!, writer.uint32(114).fork()).join(); Unlock.encode(v!, writer.uint32(114).fork()).join();
} }
if (message.shell_capacity !== 0) {
writer.uint32(120).uint32(message.shell_capacity);
}
return writer; return writer;
}, },
@@ -3113,6 +3118,14 @@ export const GunDefinitionBase: MessageFns<GunDefinitionBase> = {
message.unlocks.push(Unlock.decode(reader, reader.uint32())); message.unlocks.push(Unlock.decode(reader, reader.uint32()));
continue; continue;
} }
case 15: {
if (tag !== 120) {
break;
}
message.shell_capacity = reader.uint32();
continue;
}
} }
if ((tag & 7) === 4 || tag === 0) { if ((tag & 7) === 4 || tag === 0) {
break; break;
@@ -3144,6 +3157,7 @@ export const GunDefinitionBase: MessageFns<GunDefinitionBase> = {
assertSet("GunDefinitionBase.dispersion_damaged", object.dispersion_damaged), assertSet("GunDefinitionBase.dispersion_damaged", object.dispersion_damaged),
), ),
unlocks: globalThis.Array.isArray(object?.unlocks) ? object.unlocks.map((e: any) => Unlock.fromJSON(e)) : [], unlocks: globalThis.Array.isArray(object?.unlocks) ? object.unlocks.map((e: any) => Unlock.fromJSON(e)) : [],
shell_capacity: globalThis.Number(assertSet("GunDefinitionBase.shell_capacity", object.shell_capacity)),
}; };
}, },
@@ -3191,6 +3205,9 @@ export const GunDefinitionBase: MessageFns<GunDefinitionBase> = {
if (message.unlocks?.length) { if (message.unlocks?.length) {
obj.unlocks = message.unlocks.map((e) => Unlock.toJSON(e)); obj.unlocks = message.unlocks.map((e) => Unlock.toJSON(e));
} }
if (message.shell_capacity !== 0) {
obj.shell_capacity = Math.round(message.shell_capacity);
}
return obj; return obj;
}, },
@@ -3215,6 +3232,7 @@ export const GunDefinitionBase: MessageFns<GunDefinitionBase> = {
message.dispersion_shot = object.dispersion_shot ?? 0; message.dispersion_shot = object.dispersion_shot ?? 0;
message.dispersion_damaged = object.dispersion_damaged ?? 0; message.dispersion_damaged = object.dispersion_damaged ?? 0;
message.unlocks = object.unlocks?.map((e) => Unlock.fromPartial(e)) || []; message.unlocks = object.unlocks?.map((e) => Unlock.fromPartial(e)) || [];
message.shell_capacity = object.shell_capacity ?? 0;
return message; return message;
}, },
}; };
@@ -311,6 +311,7 @@ interface GunDefinitionsList {
afterShot: number; afterShot: number;
whileGunDamaged: number; whileGunDamaged: number;
}; };
maxAmmo: number;
aimingTime: number; aimingTime: number;
shotDispersionRadius: number; shotDispersionRadius: number;
userString: string; userString: string;
@@ -1174,6 +1175,7 @@ export async function definitions() {
dispersion_shot: shotDispersionFactors.afterShot, dispersion_shot: shotDispersionFactors.afterShot,
dispersion_traverse: shotDispersionFactors.turretRotation, dispersion_traverse: shotDispersionFactors.turretRotation,
unlocks: resolveUnlocks(gun.unlocks), unlocks: resolveUnlocks(gun.unlocks),
shell_capacity: gun.maxAmmo ?? gunListEntry.maxAmmo,
} satisfies GunDefinitionBase; } satisfies GunDefinitionBase;
tankDefinitions.tanks[tankId].turrets[turretIndex].guns.push({ tankDefinitions.tanks[tankId].turrets[turretIndex].guns.push({
@@ -157,6 +157,12 @@ export function Body({ stats }: BodyProps) {
value="shellRange" value="shellRange"
decimals={0} decimals={0}
/> />
<CompareRow
stats={stats}
name="Shell capacity"
value="shellCapacity"
decimals={0}
/>
<CompareRow <CompareRow
stats={stats} stats={stats}
name="Aim time" name="Aim time"
@@ -124,6 +124,14 @@ export function Sort() {
> >
Shell range Shell range
</DropdownMenu.CheckboxItem> </DropdownMenu.CheckboxItem>
<DropdownMenu.CheckboxItem
checked={tankopediaSort.by === 'fire.shellCapacity'}
onClick={() => {
$tankopediaSort.setKey('by', 'fire.shellCapacity');
}}
>
Shell capacity
</DropdownMenu.CheckboxItem>
<DropdownMenu.CheckboxItem <DropdownMenu.CheckboxItem
checked={tankopediaSort.by === 'fire.aimTime'} checked={tankopediaSort.by === 'fire.aimTime'}
onClick={() => { onClick={() => {
@@ -275,6 +275,16 @@ export const TankSearch = memo<TankSearchProps>(
); );
break; break;
case 'fire.shellCapacity':
sorted = filtered.sort(
(a, b) =>
a.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base
.shell_capacity -
b.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base
.shell_capacity,
);
break;
case 'fire.aimTime': case 'fire.aimTime':
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => (a, b) =>
@@ -329,10 +329,12 @@ export function Characteristics() {
<InfoWithDelta name="Shell velocity" unit="m/s" decimals={0}> <InfoWithDelta name="Shell velocity" unit="m/s" decimals={0}>
{stats.shellVelocity} {stats.shellVelocity}
</InfoWithDelta> </InfoWithDelta>
<InfoWithDelta name="Shell range" unit="m/s" decimals={0}> <InfoWithDelta name="Shell range" unit="m/s" decimals={0}>
{stats.shellRange} {stats.shellRange}
</InfoWithDelta> </InfoWithDelta>
<InfoWithDelta name="Shell capacity" unit="m/s" decimals={0}>
{stats.shellCapacity}
</InfoWithDelta>
<InfoWithDelta <InfoWithDelta
decimals={2} decimals={2}
name="Aim time" name="Aim time"
@@ -506,6 +506,7 @@ export function tankCharacteristics(
const shellRicochet = isExplosive(shell.type) ? undefined : shell.ricochet; const shellRicochet = isExplosive(shell.type) ? undefined : shell.ricochet;
const crewCount = tank.crew.length; const crewCount = tank.crew.length;
const shellRange = shell.range; const shellRange = shell.range;
const shellCapacity = gun.gun_type!.value.base.shell_capacity;
return { return {
crewCount, crewCount,
@@ -570,5 +571,6 @@ export function tankCharacteristics(
length, length,
volume, volume,
shellRange, shellRange,
shellCapacity,
}; };
} }
@@ -16,6 +16,7 @@ export const SORT_UNITS: Record<TankopediaSortBy, string | undefined> = {
'fire.reload': 's', 'fire.reload': 's',
'fire.shellVelocity': 'm/s', 'fire.shellVelocity': 'm/s',
'fire.shellRange': 'm', 'fire.shellRange': 'm',
'fire.shellCapacity': undefined,
'fire.standardPenetration': 'mm', 'fire.standardPenetration': 'mm',
'maneuverability.backwardsSpeed': 'kph', 'maneuverability.backwardsSpeed': 'kph',
'maneuverability.forwardsSpeed': 'kph', 'maneuverability.forwardsSpeed': 'kph',
@@ -48,6 +49,7 @@ export const SORT_NAMES = {
'fire.damage': 'damage', 'fire.damage': 'damage',
'fire.shellVelocity': 'shell velocity', 'fire.shellVelocity': 'shell velocity',
'fire.shellRange': 'shell range', 'fire.shellRange': 'shell range',
'fire.shellCapacity': 'shell capacity',
'fire.aimTime': 'aim time', 'fire.aimTime': 'aim time',
'fire.dispersionStill': 'dispersion still', 'fire.dispersionStill': 'dispersion still',
'fire.dispersionMoving': 'dispersion moving', 'fire.dispersionMoving': 'dispersion moving',