Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Katloo24 committed Nov 2, 2024
2 parents 68a4bd8 + e75fcf9 commit 5766304
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 4 deletions.
13 changes: 13 additions & 0 deletions app/(wiki)/perks/[item]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import GenericArticlePage from "@/components/generics/GenericArticlePage";
import PerkSidebar from "@/components/sidebars/PerkSidebar";
import { Perks } from "@/vendor/suroi/common/src/definitions/perks";

const toExport = GenericArticlePage({
items: Perks.definitions,
path: "perks",
Sidebar: PerkSidebar,
combinedArticles: []
});

export const { generateMetadata, generateStaticParams } = toExport;
export default toExport.default;
18 changes: 18 additions & 0 deletions app/(wiki)/perks/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import GenericListingPageFactory from "@/components/layouts/GenericListingPageFactory";
import { PerkCategories, PerkQualities, Perks } from "@/vendor/suroi/common/src/definitions/perks";

const perkDefs = Perks.definitions;
const normalPerks = perkDefs.filter(perk => perk.categories[0] === PerkCategories.Normal);
const halloweenPerks = perkDefs.filter(perk => perk.categories[0] === PerkCategories.Halloween);
const halloweenPerkCountOfType = (type: PerkQualities): number => halloweenPerks.filter(perk => perk.type === type).length;

export default GenericListingPageFactory(
perkDefs,
"Perks",
"/perks",
`There are currently ${perkDefs.length} perks in the game.
${normalPerks.length} of these are normal perks, and ${halloweenPerks.length} are Halloween perks.
All normal perks are positive.
Of the Halloween perks, ${halloweenPerkCountOfType(PerkQualities.Positive)} are positive, ${halloweenPerkCountOfType(PerkQualities.Neutral)} are neutral, and ${halloweenPerkCountOfType(PerkQualities.Negative)} are negative.
`
);
2 changes: 1 addition & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default async function Home() {
<div>
<h1 className="text-xl font-bold text-center mb-4">Wiki Pages</h1>
<GridTable>
{wikiPages.map(page => (
{wikiPages.filter(page => page.name !== "Home").map(page => (
<PageCard
key={page.url}
title={page.name}
Expand Down
103 changes: 103 additions & 0 deletions components/sidebars/PerkSidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import {
getSuroiImageLink
} from "@/lib/util/suroi";
import GenericSidebar from "./utils/GenericSidebar";
import InfoboxColumn from "./utils/InfoboxColumn";
import InfoboxHeader from "./utils/InfoboxHeader";
import InfoboxRow from "./utils/InfoboxRow";
import { PerkCategories, PerkDefinition, PerkQualities } from "@/vendor/suroi/common/src/definitions/perks";

export default function PerkSidebar({
item
}: {
item: PerkDefinition
}) {
let category;
switch (item.categories[0]) {
case PerkCategories.Normal:
category = "Normal";
break;
case PerkCategories.Halloween:
category = "Halloween";
break;
}

let type;
switch (item.type) {
case PerkQualities.Positive:
type = "Positive";
break;
case PerkQualities.Neutral:
type = "Neutral";
break;
case PerkQualities.Negative:
type = "Negative";
break;
}

const modifiers = Object.entries({
updateInterval: "Update Interval",
cutoff: "Cutoff",
split: "Split",
deviation: "Deviation",
damageMod: "Damage Modifier",
rangeMod: "Range Modifier",
speedMod: "Speed Modifier",
spreadMod: "Spread Modifier",
reloadMod: "Reload Speed Modifier",
usageMod: "Usage Speed Modifier",
explosionMod: "Explosion Modifier",
sizeMod: "Size Modifier",
healthMod: "Health Modifier",
hpMod: "Health Modifier",
tracerLengthMod: "Tracer Length Modifier",
waterSpeedMod: "Water Speed Modifier",
smokeSpeedMod: "Smoke Speed Modifier",
airdropCallerLimit: "Radio Use Limit",
regenRate: "Regen Rate",
speedBoostDuration: "Speed Boost Duration",
healthLoss: "Health Loss",
adrenLoss: "Adrenaline Loss",
healBonus: "Heal Bonus",
adrenalineBonus: "Adrenaline Bonus",
adrenDecay: "Adrenaline Decay Modifier",
adrenSet: "Adrenaline Value",
killsLimit: "Kills Limit",
dropCount: "Drop Count",
healDmgRate: "Heal Damage Rate",
lowerHpLimit: "Minimum Health"
});

return (
<GenericSidebar
title={item.name}
image={getSuroiImageLink(item)}
>
<InfoboxHeader>Basic Info</InfoboxHeader>
<InfoboxRow>
<InfoboxColumn title="Category">{category}</InfoboxColumn>
<InfoboxColumn title="Type">{type}</InfoboxColumn>
</InfoboxRow>
<InfoboxRow>
<InfoboxColumn title="Droppable?">{item.noDrop ? "No" : "Yes"}</InfoboxColumn>
<InfoboxColumn title="Swappable?">{item.noSwap ? "No" : "Yes"}</InfoboxColumn>
</InfoboxRow>

{modifiers.some(([prop]) => prop in item) && (
<>
<InfoboxHeader>Stats & Modifiers</InfoboxHeader>
<InfoboxRow>
{modifiers.map(([prop, name]) => prop in item && <InfoboxColumn title={name}>{Math.round(item[prop as keyof PerkDefinition] as number * 100) / 100}{prop === "updateInterval" || prop === "speedBoostDuration" ? "ms" : ""}</InfoboxColumn>)}
</InfoboxRow>
</>
)}

<InfoboxHeader>Advanced Stats</InfoboxHeader>
<InfoboxRow>
<InfoboxColumn title="Internal ID">
<span className="font-mono">{item.idString}</span>
</InfoboxColumn>
</InfoboxRow>
</GenericSidebar>
);
}
16 changes: 14 additions & 2 deletions lib/util/search.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Armors, Backpacks, Buildings, HealingItems } from "@/vendor/suroi/common/src/definitions";
import { Guns } from "@/vendor/suroi/common/src/definitions/guns";
import { Melees } from "@/vendor/suroi/common/src/definitions/melees";
import { Obstacles } from "@/vendor/suroi/common/src/definitions/obstacles";
import { Perks } from "@/vendor/suroi/common/src/definitions/perks";
import {
ObjectDefinition,
ObjectDefinitions
} from "@/vendor/suroi/common/src/utils/objectDefinitions";
import {
LootTables,
LootTiers
LootTables
} from "@/vendor/suroi/server/src/data/lootTables";
import {
IMAGE_BASE_URL,
Expand Down Expand Up @@ -73,6 +74,12 @@ export const wikiPages: SearchItem[] = [
description: "List of buildings",
image: getSuroiImageLink(getSuroiBuilding("red_house"))
},
{
name: "Perks",
url: "/perks",
description: "List of perks",
image: getSuroiImageLink(getSuroiItem("advanced_athletics"))
},
{
name: "Skins",
url: "/skins",
Expand Down Expand Up @@ -113,7 +120,12 @@ export const SearchItems: SearchItem[] = [
...wikiPages,
...generateItemsFromDefinitions(Guns, "/weapons/guns/"),
...generateItemsFromDefinitions(Melees, "/weapons/melee/"),
...generateItemsFromDefinitions(HealingItems, "/healing/"),
...generateItemsFromDefinitions(Armors, "/equipment/armor/"),
...generateItemsFromDefinitions(Backpacks, "/equipment/backpacks/"),
...generateItemsFromDefinitions(Obstacles, "/obstacles/"),
...generateItemsFromDefinitions(Buildings, "/buildings/"),
...generateItemsFromDefinitions(Perks, "/perks/"),
...Object.entries(LootTables).map(([k]) => ({
name: `Loot Table ${k}`,
url: `/loot#${k}`
Expand Down
1 change: 1 addition & 0 deletions lib/util/suroi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const IMAGE_BASE_URLS = {
Scope: "game/loot",
Skin: "game/skins",
ThrowableProjectile: "game/projectiles/throwables",
Perk: "game/perks",

// Objects
Player: "",
Expand Down
2 changes: 1 addition & 1 deletion vendor/suroi
Submodule suroi updated 253 files

0 comments on commit 5766304

Please sign in to comment.