f8ad3a6f0c
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import { relationshipConfig } from '../config/relationshipConfig.js';
|
|
import type { BondRegistry } from './bondRegistry.js';
|
|
import { hasBond } from './bondRegistry.js';
|
|
|
|
export function classify(value: number): string {
|
|
for (const tier of relationshipConfig.tiers) {
|
|
if (value >= tier.min) return tier.label;
|
|
}
|
|
return 'Nemesis';
|
|
}
|
|
|
|
export function getPartnerCap(sociability: number, empathy: number): number {
|
|
if (
|
|
sociability >= relationshipConfig.polySociabilityThreshold &&
|
|
empathy >= relationshipConfig.polyEmpathyThreshold
|
|
) {
|
|
return relationshipConfig.polyPartnerCap;
|
|
}
|
|
return relationshipConfig.defaultPartnerCap;
|
|
}
|
|
|
|
export function getFriendCap(sociability: number): number {
|
|
return relationshipConfig.baseFriendCap +
|
|
Math.floor((sociability - 10) * relationshipConfig.friendCapPerSociability);
|
|
}
|
|
|
|
export function getEffectiveClassification(
|
|
entityId: number,
|
|
value: number,
|
|
allRelationships: Map<number, { value: number }>,
|
|
sociability: number,
|
|
empathy: number,
|
|
registry?: BondRegistry,
|
|
selfEntityId?: number,
|
|
): string {
|
|
// Bond-based override: if active partner bond exists, return Partner
|
|
if (registry && selfEntityId !== undefined && hasBond(registry, selfEntityId, entityId, 'partner')) {
|
|
return 'Partner';
|
|
}
|
|
|
|
const raw = classify(value);
|
|
|
|
if (raw === 'Friend') {
|
|
const cap = getFriendCap(sociability);
|
|
let friendCount = 0;
|
|
for (const [otherId, rel] of allRelationships) {
|
|
if (otherId !== entityId && rel.value >= 20 && rel.value < 80 && rel.value > value) {
|
|
friendCount++;
|
|
}
|
|
}
|
|
if (friendCount >= cap) return 'Acquaintance';
|
|
}
|
|
|
|
return raw;
|
|
}
|