65 lines
2.6 KiB
TypeScript
65 lines
2.6 KiB
TypeScript
import type {Character, CharacterChatTurn, Encounter} from '../types';
|
||
|
||
export function buildOfflineNpcChatDialogue(encounter: Encounter, topic: string) {
|
||
return [
|
||
`你:${topic}。我想先听听你的看法。`,
|
||
`${encounter.npcName}:你问得并不随意,看来是真想弄清这里的底细。`,
|
||
'你:前面的局势我还没看透。你若知道什么,就别只说一半。',
|
||
`${encounter.npcName}:我能告诉你的,是这里近来一直不太平。接下来多留神些。`,
|
||
].join('\n');
|
||
}
|
||
|
||
export function buildOfflineNpcRecruitDialogue(encounter: Encounter) {
|
||
return [
|
||
'你:这不是客套。我是真心希望你能加入队伍,和我一起走下去。',
|
||
`${encounter.npcName}:你这番话够坦诚,我听得出你不是随口一提。`,
|
||
'你:前路不会轻松,但我还是希望你能与我并肩同行。',
|
||
`${encounter.npcName}:好,我答应你。从现在起,我便与你结伴同行。`,
|
||
].join('\n');
|
||
}
|
||
|
||
export function buildOfflineCharacterPanelChatReply(
|
||
targetCharacter: Character,
|
||
playerMessage: string,
|
||
conversationSummary: string,
|
||
) {
|
||
const personalityCue = targetCharacter.personality
|
||
.split(/[,。!?,.!?]/u)
|
||
.find(Boolean)?.trim() ?? '我会按自己的方式回答你';
|
||
const focus = playerMessage.trim() || '我听见你刚才的话了。';
|
||
|
||
return `${focus}${focus.endsWith('。') ? '' : '。'}${personalityCue}${personalityCue.endsWith('。') ? '' : '。'}${
|
||
conversationSummary
|
||
? '我还记得我们之前谈过的那些事。'
|
||
: '既然你愿意直接来问,我也会认真回答。'
|
||
}前路不会轻松,但如果你还想继续说下去,我会陪着你。`;
|
||
}
|
||
|
||
export function buildOfflineCharacterPanelChatSuggestions(targetCharacter: Character) {
|
||
return [
|
||
'把你的意思再说清楚一些。',
|
||
`${targetCharacter.name},你真正担心的到底是什么?`,
|
||
'先别管外面的局势,我想多了解你一点。',
|
||
];
|
||
}
|
||
|
||
export function buildOfflineCharacterPanelChatSummary(
|
||
targetCharacter: Character,
|
||
history: CharacterChatTurn[],
|
||
previousSummary: string,
|
||
) {
|
||
const latestTurns = history.slice(-4)
|
||
.map(turn => `${turn.speaker === 'player' ? '玩家' : targetCharacter.name}:${turn.text}`)
|
||
.join(' ');
|
||
|
||
const currentSummary = latestTurns
|
||
? `${targetCharacter.name}在私下交谈中更愿意坦率回应。最近交流:${latestTurns}`
|
||
: `${targetCharacter.name}愿意继续私下交谈,对玩家的态度也在逐渐变得更温和。`;
|
||
|
||
if (!previousSummary) {
|
||
return currentSummary.slice(0, 118);
|
||
}
|
||
|
||
return `${previousSummary} ${currentSummary}`.slice(0, 118);
|
||
}
|