Add danger-aware companion selection and native survival assistance
Core tests / core (push) Successful in 39s

This commit is contained in:
Codex
2026-09-22 21:41:51 -04:00
parent 290926f33f
commit a533c7b28a
10 changed files with 167 additions and 17 deletions
+11
View File
@@ -37,3 +37,14 @@ test('offline party members are protected when their identity cannot be checked
assert.match(compileCommunityAction('party',bot('A'),bot('B')),/Party has offline members/);
assert.match(compileCommunityAction('leave',bot('A')),/Party has offline members/);
});
test('recent danger encourages shy companions without overriding hostility or human control',()=>{
const {partyDecision}=require('../.test-build/community.js');const a=bot('A'),b=bot('B');a.personality.sociability=0;b.personality.sociability=0;
assert.equal(partyDecision(a,b).accepted,false);a.world.dangerAt=now();assert.equal(partyDecision(a,b).accepted,true);
b.relationships=[{targetId:'A',affinity:-1}];assert.equal(partyDecision(a,b).accepted,false);b.relationships=[];
b.world.humanControlled=true;assert.equal(partyDecision(a,b).accepted,false);b.world.humanControlled=false;
a.world.dangerAt=now()-601;assert.equal(partyDecision(a,b).accepted,false);
});
test('companion ranking prefers complementary native roles and shared active quests',()=>{
const {companionScore}=require('../.test-build/community.js');const a=bot('A'),b=bot('B'),c=bot('C');a.world.combatRole='tank';b.world.combatRole='healer';c.world.combatRole='damage';assert.ok(companionScore(a,b)>companionScore(a,c));
b.world.combatRole='damage';a.world.quests=[1,2];c.world.quests=[1,2];assert.ok(companionScore(a,c)>companionScore(a,b));
});