diff --git a/src/data/srd/races.json b/src/data/srd/races.json index cf95c20..b0cbb62 100644 --- a/src/data/srd/races.json +++ b/src/data/srd/races.json @@ -1 +1 @@ -[{"slug":"alseid","name":"Alseid","desc":"Alseid Traits","asi":"***Ability Score Increase.*** Your Dexterity score increases by 2, and your Wisdom score increases by 1.","speed":"***Speed.*** Alseid are fast for their size, with a base walking speed of 40 feet.","vision":"***Darkvision.*** Accustomed to the limited light beneath the forest canopy, you have superior vision in dark and dim conditions. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Alseid Weapon Training. You have proficiency with spears and shortbows."},{"slug":"catfolk","name":"Catfolk","desc":"Catfolk Traits","asi":"***Ability Score Increase.*** Your Dexterity score increases by 2.","speed":"***Speed.*** Your base walking speed is 30 feet.","vision":"***Darkvision.*** You have a cat's keen senses, especially in the dark. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Cat's Claws. Your sharp claws can cut with ease. Your claws are natural melee weapons, which you can use to make unarmed strikes. When you hit with a claw, your claw deals slashing damage equal to 1d4 + your Strength modifier, instead of the bludgeoning damage normal for an unarmed strike."},{"slug":"darakhul","name":"Darakhul","desc":"Darakhul Traits","asi":"***Ability Score Increase.*** Your Constitution score increases by 1.","speed":"***Speed.*** Your base walking speed is determined by your Heritage Subrace.","vision":"***Darkvision.*** You can see in dim light within 60 feet as though it were bright light and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Hunger for Flesh. You must consume 1 pound of raw meat each day or suffer the effects of starvation. If you go 24 hours without such a meal, you gain one level of exhaustion. While you have any levels of exhaustion from this trait, you can't regain hit points or remove levels of exhaustion until you spend at least 1 hour consuming 10 pounds of raw meat."},{"slug":"derro","name":"Derro","desc":"Derro Traits","asi":"***Ability Score Increase.*** Your Dexterity score increases by 2.","speed":"***Speed.*** Derro are fast for their size. Your base walking speed is 30 feet.","vision":"***Superior Darkvision.*** Accustomed to life underground, you can see in dim light within 120 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Eldritch Resilience. You have advantage on Constitution saving throws against spells."},{"slug":"dragonborn","name":"Dragonborn","desc":"Dragonborn Traits","asi":"**_Ability Score Increase._** Your Strength score increases by 2, and your Charisma score increases by 1.","speed":"**_Speed._** Your base walking speed is 30 feet.","vision":"","traits":"Draconic Ancestry"},{"slug":"drow","name":"Drow","desc":"Drow Traits","asi":"***Ability Score Increase.*** Your Intelligence score increases by 2.","speed":"***Speed.*** Your base walking speed is 30 feet.","vision":"***Superior Darkvision.*** Accustomed to life in the darkest depths of the world, you can see in dim light within 120 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Fey Ancestry. You have advantage on saving throws against being charmed, and magic can't put you to sleep."},{"slug":"dwarf","name":"Dwarf","desc":"Dwarf Traits","asi":"**_Ability Score Increase._** Your Constitution score increases by 2.","speed":"**_Speed._** Your base walking speed is 25 feet. Your speed is not reduced by wearing heavy armor.","vision":"**_Darkvision._** Accustomed to life underground, you have superior vision in dark and dim conditions. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Dwarven Resilience. You have advantage on saving throws against poison, and you have resistance against poison damage."},{"slug":"elf","name":"Elf","desc":"Elf Traits","asi":"**_Ability Score Increase._** Your Dexterity score increases by 2.","speed":"**_Speed._** Your base walking speed is 30 feet.","vision":"**_Darkvision._** Accustomed to twilit forests and the night sky, you have superior vision in dark and dim conditions. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Keen Senses. You have proficiency in the Perception skill."},{"slug":"erina","name":"Erina","desc":"Erina Traits","asi":"***Ability Score Increase.*** Your Dexterity score increases by 2, and you can choose to increase either your Wisdom or Charisma score by 1.","speed":"***Speed.*** Your base walking speed is 25 feet.","vision":"***Darkvision.*** Accustomed to life in the dark burrows of your people, you have superior vision in dark and dim conditions. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Hardy. The erina diet of snakes and venomous insects has made them hardy. You have advantage on saving throws against poison, and you have resistance against poison damage."},{"slug":"gearforged","name":"Gearforged","desc":"Gearforged Traits","asi":"***Ability Score Increase.*** Two different ability scores of your choice increase by 1.","speed":"***Speed.*** Your base walking speed is determined by your Race Chassis.","vision":"","traits":"Construct Resilience. Your body is constructed, which frees you from some of the limits of fleshand- blood creatures. You have resistance to poison damage, you are immune to disease, and you have advantage on saving throws against being poisoned."},{"slug":"gnome","name":"Gnome","desc":"Gnome Traits","asi":"**_Ability Score Increase._** Your Intelligence score increases by 2.","speed":"**_Speed._** Your base walking speed is 25 feet.","vision":"**_Darkvision._** Accustomed to life underground, you have superior vision in dark and dim conditions. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Gnome Cunning. You have advantage on all Intelligence, Wisdom, and Charisma saving throws against magic."},{"slug":"half-elf","name":"Half-Elf","desc":"Half-Elf Traits","asi":"**_Ability Score Increase._** Your Charisma score increases by 2, and two other ability scores of your choice increase by 1.","speed":"**_Speed._** Your base walking speed is 30 feet.","vision":"**_Darkvision._** Thanks to your elf blood, you have superior vision in dark and dim conditions. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Fey Ancestry. You have advantage on saving throws against being charmed, and magic can't put you to sleep."},{"slug":"half-orc","name":"Half-Orc","desc":"Half-Orc Traits","asi":"**_Ability Score Increase._** Your Strength score increases by 2, and your Constitution score increases by 1.","speed":"**_Speed._** Your base walking speed is 30 feet.","vision":"**_Darkvision._** Thanks to your orc blood, you have superior vision in dark and dim conditions. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Menacing. You gain proficiency in the Intimidation skill."},{"slug":"halfling","name":"Halfling","desc":"Halfling Traits","asi":"**_Ability Score Increase._** Your Dexterity score increases by 2.","speed":"**_Speed._** Your base walking speed is 25 feet.","vision":"","traits":"Lucky. When you roll a 1 on the d20 for an attack roll, ability check, or saving throw, you can reroll the die and must use the new roll."},{"slug":"human","name":"Human","desc":"Human Traits","asi":"**_Ability Score Increase._** Your ability scores each increase by 1.","speed":"**_Speed._** Your base walking speed is 30 feet.","vision":"","traits":""},{"slug":"minotaur","name":"Minotaur","desc":"Your minotaur character has certain characteristics in common with all other minotaurs.","asi":"***Ability Score Increase.*** Your Strength score increases by 2, and your Constitution score increases by 1.","speed":"***Speed.*** Your base walking speed is 30 feet.","vision":"***Darkvision.*** You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Natural Attacks. Your horns are sturdy and sharp. Your horns are a natural melee weapon, which you can use to make unarmed strikes. When you hit with your horns, they deal piercing damage equal to 1d6 + your Strength modifier, instead of the bludgeoning damage normal for an unarmed strike."},{"slug":"mushroomfolk","name":"Mushroomfolk","desc":"Your mushroomfolk character has characteristics in common with all other mushroomfolk.","asi":"***Ability Score Increase.*** Your Wisdom score increases by 2.","speed":"***Speed.*** Your base walking speed is 30 feet.","vision":"***Darkvision.*** Accustomed to life underground, you can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Fungoid Form. You are a humanoid, though the fungal nature of your body and your unique diet of decayed vegetable and animal matter marks you with some plant-like characteristics. You have advantage on saving throws against poison, and you have resistance to poison damage. In addition, you are immune to disease."},{"slug":"satarre","name":"Satarre","desc":"Your satarre heritage is apparent in a variety of traits you share with other satarre.","asi":"***Ability Score Increase.*** Your Constitution score increases by 2, and your Intelligence score increases by 1.","speed":"***Speed.*** Your base walking speed is 30 feet.","vision":"***Darkvision.*** Thanks to your dark planar parentage, you have superior vision in darkness. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"A Friend to Death. You have resistance to necrotic damage."},{"slug":"shade","name":"Shade","desc":"Your shade character has a number of traits that arise from being a shade as well as a few drawn from life.","asi":"***Ability Score Increase.*** Your Charisma score increases by 1, and one other ability score of your choice increases by 1. Choose one ability score that is increased by your Living Origin or by one of its subraces. That ability score increases by 1.","speed":"***Speed.*** Your speed is determined by your Living Origin.","vision":"***Darkvision.*** Your existence beyond death makes you at home in the dark. You can see in dim light within 60 feet of you as if it were bright light and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Ghostly Flesh. Starting at 3rd level, you can use your action to dissolve your physical body into the ephemeral stuff of spirits. You become translucent and devoid of color, and the air around you grows cold. Your transformation lasts for 1 minute or until you end it as a bonus action. During it, you have a flying speed of 30 feet with the ability to hover, and you have resistance to bludgeoning, piercing, and slashing damage from nonmagical attacks that aren't made with silvered weapons. In …"},{"slug":"tiefling","name":"Tiefling","desc":"Tiefling Traits","asi":"**_Ability Score Increase._** Your Intelligence score increases by 1, and your Charisma score increases by 2.","speed":"**_Speed._** Your base walking speed is 30 feet.","vision":"**_Darkvision._** Thanks to your infernal heritage, you have superior vision in dark and dim conditions. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Hellish Resistance. You have resistance to fire damage."}] \ No newline at end of file +[{"slug":"alseid","name":"Alseid","desc":"Alseid Traits","asi":"***Ability Score Increase.*** Your Dexterity score increases by 2, and your Wisdom score increases by 1.","speed":"***Speed.*** Alseid are fast for their size, with a base walking speed of 40 feet.","vision":"***Darkvision.*** Accustomed to the limited light beneath the forest canopy, you have superior vision in dark and dim conditions. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Alseid Weapon Training. You have proficiency with spears and shortbows."},{"slug":"catfolk","name":"Catfolk","desc":"Catfolk Traits","asi":"***Ability Score Increase.*** Your Dexterity score increases by 2.","speed":"***Speed.*** Your base walking speed is 30 feet.","vision":"***Darkvision.*** You have a cat's keen senses, especially in the dark. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Cat's Claws. Your sharp claws can cut with ease. Your claws are natural melee weapons, which you can use to make unarmed strikes. When you hit with a claw, your claw deals slashing damage equal to 1d4 + your Strength modifier, instead of the bludgeoning damage normal for an unarmed strike."},{"slug":"darakhul","name":"Darakhul","desc":"Darakhul Traits","asi":"***Ability Score Increase.*** Your Constitution score increases by 1.","speed":"***Speed.*** Your base walking speed is determined by your Heritage Subrace.","vision":"***Darkvision.*** You can see in dim light within 60 feet as though it were bright light and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Hunger for Flesh. You must consume 1 pound of raw meat each day or suffer the effects of starvation. If you go 24 hours without such a meal, you gain one level of exhaustion. While you have any levels of exhaustion from this trait, you can't regain hit points or remove levels of exhaustion until you spend at least 1 hour consuming 10 pounds of raw meat."},{"slug":"derro","name":"Derro","desc":"Derro Traits","asi":"***Ability Score Increase.*** Your Dexterity score increases by 2.","speed":"***Speed.*** Derro are fast for their size. Your base walking speed is 30 feet.","vision":"***Superior Darkvision.*** Accustomed to life underground, you can see in dim light within 120 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Eldritch Resilience. You have advantage on Constitution saving throws against spells."},{"slug":"dragonborn","name":"Dragonborn","desc":"Dragonborn Traits","asi":"**_Ability Score Increase._** Your Strength score increases by 2, and your Charisma score increases by 1.","speed":"**_Speed._** Your base walking speed is 30 feet.","vision":"","traits":"Draconic Ancestry"},{"slug":"drow","name":"Drow","desc":"Drow Traits","asi":"***Ability Score Increase.*** Your Dexterity score increases by 2, and your Charisma score increases by 1.","speed":"***Speed.*** Your base walking speed is 30 feet.","vision":"***Superior Darkvision.*** Accustomed to life in the darkest depths of the world, you can see in dim light within 120 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Fey Ancestry. You have advantage on saving throws against being charmed, and magic can't put you to sleep."},{"slug":"dwarf","name":"Dwarf","desc":"Dwarf Traits","asi":"**_Ability Score Increase._** Your Constitution score increases by 2.","speed":"**_Speed._** Your base walking speed is 25 feet. Your speed is not reduced by wearing heavy armor.","vision":"**_Darkvision._** Accustomed to life underground, you have superior vision in dark and dim conditions. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Dwarven Resilience. You have advantage on saving throws against poison, and you have resistance against poison damage."},{"slug":"elf","name":"Elf","desc":"Elf Traits","asi":"**_Ability Score Increase._** Your Dexterity score increases by 2.","speed":"**_Speed._** Your base walking speed is 30 feet.","vision":"**_Darkvision._** Accustomed to twilit forests and the night sky, you have superior vision in dark and dim conditions. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Keen Senses. You have proficiency in the Perception skill."},{"slug":"erina","name":"Erina","desc":"Erina Traits","asi":"***Ability Score Increase.*** Your Dexterity score increases by 2, and you can choose to increase either your Wisdom or Charisma score by 1.","speed":"***Speed.*** Your base walking speed is 25 feet.","vision":"***Darkvision.*** Accustomed to life in the dark burrows of your people, you have superior vision in dark and dim conditions. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Hardy. The erina diet of snakes and venomous insects has made them hardy. You have advantage on saving throws against poison, and you have resistance against poison damage."},{"slug":"gearforged","name":"Gearforged","desc":"Gearforged Traits","asi":"***Ability Score Increase.*** Two different ability scores of your choice increase by 1.","speed":"***Speed.*** Your base walking speed is determined by your Race Chassis.","vision":"","traits":"Construct Resilience. Your body is constructed, which frees you from some of the limits of fleshand- blood creatures. You have resistance to poison damage, you are immune to disease, and you have advantage on saving throws against being poisoned."},{"slug":"gnome","name":"Gnome","desc":"Gnome Traits","asi":"**_Ability Score Increase._** Your Intelligence score increases by 2.","speed":"**_Speed._** Your base walking speed is 25 feet.","vision":"**_Darkvision._** Accustomed to life underground, you have superior vision in dark and dim conditions. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Gnome Cunning. You have advantage on all Intelligence, Wisdom, and Charisma saving throws against magic."},{"slug":"half-elf","name":"Half-Elf","desc":"Half-Elf Traits","asi":"**_Ability Score Increase._** Your Charisma score increases by 2, and two other ability scores of your choice increase by 1.","speed":"**_Speed._** Your base walking speed is 30 feet.","vision":"**_Darkvision._** Thanks to your elf blood, you have superior vision in dark and dim conditions. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Fey Ancestry. You have advantage on saving throws against being charmed, and magic can't put you to sleep."},{"slug":"half-orc","name":"Half-Orc","desc":"Half-Orc Traits","asi":"**_Ability Score Increase._** Your Strength score increases by 2, and your Constitution score increases by 1.","speed":"**_Speed._** Your base walking speed is 30 feet.","vision":"**_Darkvision._** Thanks to your orc blood, you have superior vision in dark and dim conditions. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Menacing. You gain proficiency in the Intimidation skill."},{"slug":"halfling","name":"Halfling","desc":"Halfling Traits","asi":"**_Ability Score Increase._** Your Dexterity score increases by 2.","speed":"**_Speed._** Your base walking speed is 25 feet.","vision":"","traits":"Lucky. When you roll a 1 on the d20 for an attack roll, ability check, or saving throw, you can reroll the die and must use the new roll."},{"slug":"human","name":"Human","desc":"Human Traits","asi":"**_Ability Score Increase._** Your ability scores each increase by 1.","speed":"**_Speed._** Your base walking speed is 30 feet.","vision":"","traits":""},{"slug":"minotaur","name":"Minotaur","desc":"Your minotaur character has certain characteristics in common with all other minotaurs.","asi":"***Ability Score Increase.*** Your Strength score increases by 2, and your Constitution score increases by 1.","speed":"***Speed.*** Your base walking speed is 30 feet.","vision":"***Darkvision.*** You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Natural Attacks. Your horns are sturdy and sharp. Your horns are a natural melee weapon, which you can use to make unarmed strikes. When you hit with your horns, they deal piercing damage equal to 1d6 + your Strength modifier, instead of the bludgeoning damage normal for an unarmed strike."},{"slug":"mushroomfolk","name":"Mushroomfolk","desc":"Your mushroomfolk character has characteristics in common with all other mushroomfolk.","asi":"***Ability Score Increase.*** Your Wisdom score increases by 2.","speed":"***Speed.*** Your base walking speed is 30 feet.","vision":"***Darkvision.*** Accustomed to life underground, you can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Fungoid Form. You are a humanoid, though the fungal nature of your body and your unique diet of decayed vegetable and animal matter marks you with some plant-like characteristics. You have advantage on saving throws against poison, and you have resistance to poison damage. In addition, you are immune to disease."},{"slug":"satarre","name":"Satarre","desc":"Your satarre heritage is apparent in a variety of traits you share with other satarre.","asi":"***Ability Score Increase.*** Your Constitution score increases by 2, and your Intelligence score increases by 1.","speed":"***Speed.*** Your base walking speed is 30 feet.","vision":"***Darkvision.*** Thanks to your dark planar parentage, you have superior vision in darkness. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"A Friend to Death. You have resistance to necrotic damage."},{"slug":"shade","name":"Shade","desc":"Your shade character has a number of traits that arise from being a shade as well as a few drawn from life.","asi":"***Ability Score Increase.*** Your Charisma score increases by 1, and one other ability score of your choice increases by 1. Choose one ability score that is increased by your Living Origin or by one of its subraces. That ability score increases by 1.","speed":"***Speed.*** Your speed is determined by your Living Origin.","vision":"***Darkvision.*** Your existence beyond death makes you at home in the dark. You can see in dim light within 60 feet of you as if it were bright light and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Ghostly Flesh. Starting at 3rd level, you can use your action to dissolve your physical body into the ephemeral stuff of spirits. You become translucent and devoid of color, and the air around you grows cold. Your transformation lasts for 1 minute or until you end it as a bonus action. During it, you have a flying speed of 30 feet with the ability to hover, and you have resistance to bludgeoning, piercing, and slashing damage from nonmagical attacks that aren't made with silvered weapons. In …"},{"slug":"tiefling","name":"Tiefling","desc":"Tiefling Traits","asi":"**_Ability Score Increase._** Your Intelligence score increases by 1, and your Charisma score increases by 2.","speed":"**_Speed._** Your base walking speed is 30 feet.","vision":"**_Darkvision._** Thanks to your infernal heritage, you have superior vision in dark and dim conditions. You can see in dim light within 60 feet of you as if it were bright light, and in darkness as if it were dim light. You can't discern color in darkness, only shades of gray.","traits":"Hellish Resistance. You have resistance to fire damage."}] \ No newline at end of file diff --git a/src/features/compendium/MonsterDetail.tsx b/src/features/compendium/MonsterDetail.tsx index 06232d0..f377231 100644 --- a/src/features/compendium/MonsterDetail.tsx +++ b/src/features/compendium/MonsterDetail.tsx @@ -18,6 +18,21 @@ function StatLine({ label, children }: { label: string; children?: React.ReactNo ); } +/** Join all movement modes into a statblock Speed line, e.g. "40 ft., climb 40 ft., fly 80 ft." */ +function speedLine(speed: Monster['speed']): string { + if (!speed) return ''; + const entries = Object.entries(speed).filter(([, v]) => typeof v === 'number') as [string, number][]; + const walk = entries.find(([k]) => k === 'walk'); + const rest = entries.filter(([k]) => k !== 'walk'); + const parts = [...(walk ? [`${walk[1]} ft.`] : []), ...rest.map(([k, v]) => `${k} ${v} ft.`)]; + return parts.join(', '); +} + +const SAVE_LABELS: [keyof Monster, string][] = [ + ['strength_save', 'STR'], ['dexterity_save', 'DEX'], ['constitution_save', 'CON'], + ['intelligence_save', 'INT'], ['wisdom_save', 'WIS'], ['charisma_save', 'CHA'], +]; + export function MonsterDetail({ monster: m }: { monster: Monster }) { const abilities: [string, number | undefined][] = [ ['STR', m.strength], @@ -28,6 +43,25 @@ export function MonsterDetail({ monster: m }: { monster: Monster }) { ['CHA', m.charisma], ]; const subtitle = [m.size, m.type, m.alignment].filter(Boolean).join(', '); + + const saves = SAVE_LABELS + .map(([k, label]) => [label, m[k] as number | null | undefined] as const) + .filter(([, v]) => typeof v === 'number') + .map(([label, v]) => `${label} ${formatModifier(v as number)}`) + .join(', '); + const skills = m.skills + ? Object.entries(m.skills).map(([k, v]) => `${k[0]!.toUpperCase()}${k.slice(1)} ${formatModifier(v)}`).join(', ') + : ''; + + // Passive Perception, computed from the creature's own stats so it can never + // disagree with them (7 SRD monsters ship a wrong passive in their senses string). + const percMod = m.skills?.perception ?? (m.wisdom !== undefined ? abilityModifier(m.wisdom) : undefined); + const passivePerception = percMod !== undefined ? 10 + percMod : undefined; + const senses = m.senses && passivePerception !== undefined + ? /passive Perception\s+\d+/i.test(m.senses) + ? m.senses.replace(/passive Perception\s+\d+/i, `passive Perception ${passivePerception}`) + : `${m.senses}, passive Perception ${passivePerception}` + : m.senses; return (
@@ -40,7 +74,7 @@ export function MonsterDetail({ monster: m }: { monster: Monster }) {
{m.armor_class ?? '—'}{m.armor_desc ? ` (${m.armor_desc})` : ''} {m.hit_points ?? '—'}{m.hit_dice ? ` (${m.hit_dice})` : ''} - {m.speed?.walk !== undefined && {m.speed.walk} ft.} + {speedLine(m.speed) || null}

@@ -57,14 +91,17 @@ export function MonsterDetail({ monster: m }: { monster: Monster }) { ))}
- {(m.damage_resistances || m.damage_immunities || m.condition_immunities || m.senses || m.languages) && ( + {(saves || skills || m.damage_resistances || m.damage_immunities || m.condition_immunities || senses || m.languages) && ( <>
+ {saves || null} + {skills || null} + {m.damage_vulnerabilities} {m.damage_resistances} {m.damage_immunities} {m.condition_immunities} - {m.senses} + {senses} {m.languages}
diff --git a/src/lib/compendium/index.ts b/src/lib/compendium/index.ts index 58900d3..f9ea199 100644 --- a/src/lib/compendium/index.ts +++ b/src/lib/compendium/index.ts @@ -118,11 +118,30 @@ export async function loadPf2e(file: string): Promise { if (!pf2eCache.has(file)) { const res = await fetch(`${import.meta.env.BASE_URL}data/pf2e/${file}.json`); if (!res.ok) throw new Error(`Failed to load PF2e ${file} (${res.status})`); - pf2eCache.set(file, (await res.json()) as CompendiumEntry[]); + const raw = (await res.json()) as CompendiumEntry[]; + pf2eCache.set(file, dedupePf2e(raw)); } return pf2eCache.get(file)!; } +/** + * Archives of Nethys lists each reprinted element once per source (Remaster + + * legacy), so the raw datasets carry thousands of duplicate names. Collapse them + * by name (first occurrence wins) so the compendium shows one row per element. + */ +function dedupePf2e(entries: CompendiumEntry[]): CompendiumEntry[] { + const seen = new Set(); + const out: CompendiumEntry[] = []; + for (const e of entries) { + const key = String((e.name ?? e.slug) ?? '').trim().toLowerCase(); + if (!key) { out.push(e); continue; } + if (seen.has(key)) continue; + seen.add(key); + out.push(e); + } + return out; +} + /** Build a combat-ready stat block summary from a monster. */ export function monsterToCombatant(m: Monster): { name: string; diff --git a/src/lib/compendium/types.ts b/src/lib/compendium/types.ts index 464695f..ad1a914 100644 --- a/src/lib/compendium/types.ts +++ b/src/lib/compendium/types.ts @@ -29,6 +29,14 @@ export interface Monster { wisdom?: number; charisma?: number; perception?: number; + strength_save?: number | null; + dexterity_save?: number | null; + constitution_save?: number | null; + intelligence_save?: number | null; + wisdom_save?: number | null; + charisma_save?: number | null; + /** skill bonuses keyed by skill name, e.g. { perception: 10, stealth: 6 } */ + skills?: Record; senses?: string; languages?: string; /** numeric challenge rating (0.25 for "1/4") */