Skip to content

Commit

Permalink
Merge pull request #428 from cohstats/cleanup-unit-section
Browse files Browse the repository at this point in the history
Cleanup Unit Stats Section
  • Loading branch information
KingDarBoja authored Apr 19, 2024
2 parents ac2674b + 8faefea commit 8e5cf5c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 37 deletions.
4 changes: 2 additions & 2 deletions components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const Header: React.FC<HeaderProps> = () => {
className={classes.hiddenDesktop}
zIndex={1000000}
>
<ScrollArea sx={{ height: "calc(100vh - 60px)" }} mx="-md">
<ScrollArea sx={{ height: "calc(100vh - 100px)" }} mx="-md">
<Divider my="sm" />
<Stack px="md">
<Group grow>
Expand Down Expand Up @@ -214,7 +214,7 @@ export const Header: React.FC<HeaderProps> = () => {

return (
<>
<MantineHeader height={60} className={classes.root} style={{ position: "sticky" }}>
<MantineHeader height={100} className={classes.root} style={{ position: "sticky" }}>
<Container className={classes.container} fluid>
<Anchor component={Link} href={"/"} className={cx(classes.link)}>
<Group spacing="xs">
Expand Down
10 changes: 5 additions & 5 deletions components/unit-cards/unit-upgrade-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,19 @@ const UnitUpgradeCardHeader = ({ desc, cfg }: Pick<UnitUpgrade, "desc" | "cfg">)
</Grid.Col>

<Grid.Col span={12}>
<Tooltip multiline style={{ whiteSpace: "pre-line" }} label={briefText}>
<Text fz="sm" lineClamp={6} style={{ whiteSpace: "pre-line" }}>
<Tooltip.Floating multiline style={{ whiteSpace: "pre-line" }} label={briefText}>
<Text fz="sm" lineClamp={7} style={{ whiteSpace: "pre-line" }}>
{briefText}
</Text>
</Tooltip>
</Tooltip.Floating>
</Grid.Col>

<Grid.Col span={12}>
<Tooltip multiline label={desc.extra_text || desc.extra_text_formatter}>
<Tooltip.Floating multiline label={desc.extra_text || desc.extra_text_formatter}>
<Text fz="sm" lineClamp={3}>
{desc.extra_text || desc.extra_text_formatter}
</Text>
</Tooltip>
</Tooltip.Floating>
</Grid.Col>
</Grid>
</>
Expand Down
20 changes: 0 additions & 20 deletions pages/explorer/races/[raceId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,26 +182,6 @@ const BuildingMapping = (
);
};

// function getBuildingTrainableUnits(
// building: EbpsType,
// sbpsData: SbpsType[],
// ebpsData: EbpsType[],
// ): BuildingSchema["units"] {
// return Object.entries(getResolvedSquads(building.spawnItems, sbpsData, ebpsData)).map(
// ([id, { ui, time_cost }]) => ({
// id,
// desc: {
// screen_name: ui.screenName,
// help_text: ui.helpText,
// brief_text: ui.briefText,
// symbol_icon_name: ui.symbolIconName,
// icon_name: ui.iconName,
// },
// time_cost,
// }),
// );
// }

function getBuildingUpgrades(
building: EbpsType,
upgradesData: UpgradesType[],
Expand Down
9 changes: 5 additions & 4 deletions screens/news/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ const SingleNewsItem = ({ item }: { item: NewsItem }) => {
<Card shadow="sm" padding="md" pt={"xs"} radius="md" mb={"lg"} withBorder>
<span
style={{
display: "block",
height: "300px",
marginTop: "-300px",
visibility: "hidden",
position: "absolute",
top: "-120px",
left: "0",
right: "0",
height: "1px",
}}
id={item.gid}
/>
Expand Down
9 changes: 5 additions & 4 deletions src/unitStats/dpsCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export const getSbpsWeapons = (sbps: SbpsType, ebpsList: EbpsType[], weapons: We
if (!unit_ebps) continue;

let num = loadout.num;
if (crew_demand > 0) num = num - crew_demand;
if (crew_demand > 0) num -= crew_demand;

crew_demand = unit_ebps.crew_size;

Expand All @@ -262,9 +262,10 @@ export const getSbpsWeapons = (sbps: SbpsType, ebpsList: EbpsType[], weapons: We
// ignore loadout when no damage dealing weapon found
if (
!weapon ||
(weapon as WeaponType).weapon_bag.damage_max == 0 ||
(weapon.weapon_bag.damage_damage_type == "explosive" &&
weapon.weapon_bag.aoe_outer_radius == 0)
((weapon as WeaponType).weapon_bag.damage_max == 0 &&
weapon.weapon_bag.damage_damage_type !== "explosive") ||
(weapon.weapon_bag.damage_damage_type === "explosive" &&
weapon.weapon_bag.aoe_outer_radius === 0)
)
continue;

Expand Down
12 changes: 10 additions & 2 deletions src/unitStats/locstring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ type LocstringObjectSchema = {
type TextFormatterSchema = {
// template_reference: { name: string; value: string };
formatter: LocstringObjectSchema;
formatter_arguments: Array<{ int_value: number }>;
formatter_arguments: Array<{
int_value?: number;
float_value?: number;
locstring_value?: LocstringObjectSchema;
}>;
};

// The input comes from the weapon / ebps / sbps / upgrade json.
Expand All @@ -37,7 +41,11 @@ const resolveTextFormatterLocstring = (inFormatter: TextFormatterSchema) => {
if (!foundFormatterLoc) return null;

const valRegex = /(\%\d+\%)/g;
const replacements = inFormatter.formatter_arguments.map((x) => `${x.int_value}`);
const replacements = inFormatter.formatter_arguments.map((x) => {
if (x.int_value) return `${x.int_value}`;
if (x.float_value) return `${x.float_value}`;
if (x.locstring_value) return resolveLocstring(x.locstring_value);
});
const formattedLoc = foundFormatterLoc.replace(valRegex, () => replacements.shift() ?? "0");

// Now replace the double % symbol via regex to preserve a single percentage symbol.
Expand Down
1 change: 1 addition & 0 deletions src/unitStats/workarounds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ function setBattlegroupsWorkarounds() {
item.branches.RIGHT.upgrades.forEach((upg) => {
switch (upg.ability.id) {
case "australian_defense_australian_light_infantry_uk":
upg.ability.cost.manpower = 280;
upg.spawnItems = ["australian_light_infantry_africa_uk"];
break;
case "australian_defense_2pdr_at_gun_uk":
Expand Down

0 comments on commit 8e5cf5c

Please sign in to comment.