Skip to content

Commit

Permalink
show material breathability
Browse files Browse the repository at this point in the history
Ref #174
  • Loading branch information
nornagon committed Jun 19, 2024
1 parent f4466c3 commit 2946e2b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
21 changes: 20 additions & 1 deletion src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ import type {
ComestibleSlot,
OvermapSpecial,
ArmorSlot,
BreathabilityRating,
} from "./types";
import type { ItemChance, Loot } from "./types/item/spawnLocations";
import type { Loot } from "./types/item/spawnLocations";

const typeMappings = new Map<string, keyof SupportedTypesWithMapped>([
["AMMO", "item"],
Expand Down Expand Up @@ -1733,6 +1734,24 @@ export function normalizeUseAction(action: Item["use_action"]): UseFunction[] {
}
}

export function breathabilityFromRating(br: BreathabilityRating): number {
switch (br) {
case "IMPERMEABLE":
return 0;
case "POOR":
return 30;
case "AVERAGE":
return 50;
case "GOOD":
return 80;
case "MOISTURE_WICKING":
return 110;
case "SECOND_SKIN":
return 140;
}
return 0;
}

const fetchJsonWithProgress = (
url: string,
progress: (receivedBytes: number, totalBytes: number) => void
Expand Down
18 changes: 11 additions & 7 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,14 @@ export type AddictionType = {
builtin?: string;
};

export type BreathabilityRating =
| "IMPERMEABLE"
| "POOR"
| "AVERAGE"
| "GOOD"
| "MOISTURE_WICKING"
| "SECOND_SKIN";

export type ArmorPortionData = {
encumbrance?: integer | [integer, integer];
encumbrance_modifiers?: (
Expand All @@ -439,13 +447,7 @@ export type ArmorPortionData = {
| "NONE"
)[];
coverage?: integer;
breathability?:
| "IMPERMEABLE"
| "POOR"
| "AVERAGE"
| "GOOD"
| "MOISTURE_WICKING"
| "SECOND_SKIN";
breathability?: BreathabilityRating;
cover_melee?: integer; // default = coverage
cover_ranged?: integer; // default = coverage
cover_vitals?: integer; // default 0
Expand Down Expand Up @@ -1685,6 +1687,8 @@ export type Material = {
repaired_with?: string; // item_id

vitamins?: [string, number][];

breathability?: BreathabilityRating;
};

export type MartialArtBuff = {
Expand Down
9 changes: 8 additions & 1 deletion src/types/Material.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { t } from "@transifex/native";
import { getContext } from "svelte";
import { byName, CddaData, singularName } from "../data";
import {
breathabilityFromRating,
byName,
CddaData,
singularName,
} from "../data";
import LimitedList from "../LimitedList.svelte";
import type { Material } from "../types";
import ItemSymbol from "./item/ItemSymbol.svelte";
Expand Down Expand Up @@ -50,6 +55,8 @@ let itemsWithMaterial = data
</dd>
<dt>{t("Latent Heat", { _context })}</dt>
<dd>{item.latent_heat ?? 334}</dd>
<dt>{t("Breathability", { _context })}</dt>
<dd>{breathabilityFromRating(item.breathability ?? "IMPERMEABLE")}%</dd>
<dt>{t("Resistance", { _context })}</dt>
<dd>
<dl>
Expand Down

0 comments on commit 2946e2b

Please sign in to comment.