fix: perks now show human-readable descriptions instead of type-idx strings
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m31s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m31s
This commit is contained in:
@@ -45,6 +45,7 @@ export interface DisciplineCardDefinition {
|
||||
perkThresholds?: number[];
|
||||
perkValues?: number[];
|
||||
perkTypes?: string[];
|
||||
perkDescriptions?: string[];
|
||||
statBonus: string;
|
||||
statBonusLabel: string;
|
||||
requires?: string[];
|
||||
@@ -79,7 +80,7 @@ interface DisciplineCardProps {
|
||||
|
||||
const DisciplineCard: React.FC<DisciplineCardProps> = ({ definition, runtime, callbacks }) => {
|
||||
const {
|
||||
id, name, description, manaType, baseCost, perkThresholds, perkValues, perkTypes,
|
||||
id, name, description, manaType, baseCost, perkThresholds, perkValues, perkTypes, perkDescriptions,
|
||||
statBonusLabel, baseValue, drainBase, difficultyFactor, scalingFactor,
|
||||
} = definition;
|
||||
const { xp, paused: isPaused, concurrentLimit, isLocked, missingPrereqs, missingSourceMana } = runtime;
|
||||
@@ -101,12 +102,13 @@ const DisciplineCard: React.FC<DisciplineCardProps> = ({ definition, runtime, ca
|
||||
const unlockedPerks = perkTypes?.reduce<string[]>((acc, typ, idx) => {
|
||||
const threshold = perkThresholds?.[idx];
|
||||
if (threshold === undefined) return acc;
|
||||
const desc = perkDescriptions?.[idx];
|
||||
if (typ === 'once' || typ === 'infinite') {
|
||||
if (displayXp >= threshold) acc.push(`${typ}-${idx}`);
|
||||
if (displayXp >= threshold && desc) acc.push(desc);
|
||||
} else if (typ === 'capped') {
|
||||
const interval = perkValues?.[idx] ?? 1;
|
||||
const tier = Math.max(0, Math.floor((displayXp - threshold) / interval) + 1);
|
||||
if (tier > 0) acc.push(`${typ}-${idx}`);
|
||||
if (tier > 0 && desc) acc.push(desc);
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
@@ -171,7 +173,7 @@ const DisciplineCard: React.FC<DisciplineCardProps> = ({ definition, runtime, ca
|
||||
<ul className="mt-1 list-disc list-inside space-y-1 text-xs">
|
||||
{unlockedPerks && unlockedPerks.length > 0 ? (
|
||||
unlockedPerks.map((p) => (
|
||||
<li key={p} className="text-green-500">{p.replace(/-([0-9]+)$/, ' $1')}</li>
|
||||
<li key={p} className="text-green-500">{p}</li>
|
||||
))
|
||||
) : (
|
||||
<li className="text-gray-400">—locked—</li>
|
||||
@@ -265,6 +267,7 @@ export const DisciplinesTab: React.FC = () => {
|
||||
perkThresholds: disc.perks?.map((p) => p.threshold),
|
||||
perkValues: disc.perks?.map((p) => p.value),
|
||||
perkTypes: disc.perks?.map((p) => p.type),
|
||||
perkDescriptions: disc.perks?.map((p) => p.description),
|
||||
manaType: disc.manaType,
|
||||
baseCost: disc.baseCost,
|
||||
statBonus: disc.statBonus.stat,
|
||||
|
||||
Reference in New Issue
Block a user