Skip to content

Commit

Permalink
fix: semi fix loot tables
Browse files Browse the repository at this point in the history
  • Loading branch information
hsanger committed Oct 28, 2024
1 parent 9eab5b2 commit 9e09169
Showing 1 changed file with 13 additions and 45 deletions.
58 changes: 13 additions & 45 deletions app/(wiki)/loot/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import LootCalc from "@/components/interactive/LootCalc";
import TableWithHeader from "@/components/tables/TableWithHeader";
import { Loots } from "@/vendor/suroi/common/src/definitions/loots";
import {
FullLootTable,
LootTables,
LootTiers
LootTiers,

Check failure on line 7 in app/(wiki)/loot/page.tsx

View workflow job for this annotation

GitHub Actions / Lint

'LootTiers' is defined but never used
SimpleLootTable
} from "@/vendor/suroi/server/src/data/lootTables";

export default function LootPage() {
Expand All @@ -16,32 +18,27 @@ export default function LootPage() {
features around the map. Loot tables also define the chances of
various items to drop.
</p>
<h2>Loot Tiers</h2>
<p>
Loot tables are divided into certain common loot tiers. These loot
tiers are reused throughout many different tables.
</p>
</div>
<div>
{Object.entries(LootTiers).map(([name, tiers]) => (
{Object.entries(LootTables.normal).map(([name, tables]) => (
<div key={name} id={name}>
<TableWithHeader
key={name}
title={`Tier ${name}`}
title={`Table ${name}`}
header={["Item", "Count", "Weight", "% Chance"]}
content={tiers.map(tier => [
"item" in tier
content={("loot" in tables ? (tables as FullLootTable).loot : tables as SimpleLootTable).map(table => [

Check failure on line 29 in app/(wiki)/loot/page.tsx

View workflow job for this annotation

GitHub Actions / Lint

This assertion is unnecessary since it does not change the type of the expression

Check failure on line 29 in app/(wiki)/loot/page.tsx

View workflow job for this annotation

GitHub Actions / Lint

This assertion is unnecessary since it does not change the type of the expression
"item" in table
? `Item ${
Loots.definitions.find(
loot => loot.idString === tier.item
loot => loot.idString === table.item
)?.name
}`
: `Tier ${tier.tier}`,
tier.count ? tier.count.toString() : "1",
tier.weight,
: `Table ${table.table}`,
table.count ? table.count.toString() : "1",
table.weight,
`${(
(tier.weight
/ tiers.reduce((acc, tier) => acc + tier.weight, 0))
(table.weight
/ ("loot" in tables ? (tables as FullLootTable).loot : tables as SimpleLootTable).reduce((acc, table) => acc + table.weight, 0))

Check failure on line 41 in app/(wiki)/loot/page.tsx

View workflow job for this annotation

GitHub Actions / Lint

Expected indentation of 20 spaces

Check failure on line 41 in app/(wiki)/loot/page.tsx

View workflow job for this annotation

GitHub Actions / Lint

This assertion is unnecessary since it does not change the type of the expression

Check failure on line 41 in app/(wiki)/loot/page.tsx

View workflow job for this annotation

GitHub Actions / Lint

This assertion is unnecessary since it does not change the type of the expression

Check failure on line 41 in app/(wiki)/loot/page.tsx

View workflow job for this annotation

GitHub Actions / Lint

Invalid operand for a '+' operation. Operands must each be a number or string. Got `any`
* 100
).toFixed(2)}%`
])}
Expand All @@ -57,35 +54,6 @@ export default function LootPage() {
</p>
</div>
</div>
{Object.entries(LootTables).map(([name, tables]) => (
<div key={name} id={name}>
<TableWithHeader
title={`Table ${name}`}
header={["Tier/Item", "Count", "Weight", "% Chance"]}
content={tables.loot
.flat()
.map(tier => [
"item" in tier
? `Item ${
Loots.definitions.find(
loot => loot.idString === tier.item
)?.name
}`
: `Tier ${tier.tier}`,
tier.count ? tier.count.toString() : "1",
tier.weight.toString(),

`${(
(tier.weight
/ tables.loot
.flat()
.reduce((acc, tier) => acc + tier.weight, 0))
* 100
).toFixed(2)}%`
])}
/>
</div>
))}
<div className="mt-8">
<div className="prose prose-invert" id="calc">
<h2>Calculator</h2>
Expand Down

0 comments on commit 9e09169

Please sign in to comment.