fix(gameplay): start campaigns in playable state
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -123,6 +123,12 @@ const { worldId } = await appRequest(`/api/v1/coauthor/sessions/${sessionId}/con
|
||||
const { campaignId } = await appRequest('/api/v1/campaigns', owner.token, {
|
||||
method: 'POST', body: JSON.stringify({ worldId, title: `Smoke Party ${suffix}` }),
|
||||
})
|
||||
const starterParty = await appRequest(`/api/v1/campaigns/${campaignId}`, owner.token)
|
||||
const ownerCharacter = starterParty.characters.find(character => character.user_id === owner.id && character.controller === 'human')
|
||||
const automaticCompanion = starterParty.characters.find(character => character.controller === 'ai')
|
||||
if (!ownerCharacter || !automaticCompanion || starterParty.round?.status !== 'open') {
|
||||
throw new Error('[smoke] A new campaign did not start with an actionable owner hero, an AI companion, and an open round.')
|
||||
}
|
||||
|
||||
console.log('[smoke] Joining the second player through an invite…')
|
||||
const { token: inviteToken } = await appRequest(`/api/v1/campaigns/${campaignId}/invites`, owner.token, {
|
||||
@@ -137,14 +143,11 @@ const characterBody = (name, concept) => JSON.stringify({
|
||||
name, concept, controller: 'human', abilities: { str: 10, dex: 10, con: 10, int: 12, wis: 11, cha: 9 },
|
||||
hp: 12, maxHp: 12, defense: 12, proficiency: 2, inventory: [], statuses: [], persona: {},
|
||||
})
|
||||
const ownerCharacter = await appRequest(`/api/v1/campaigns/${campaignId}/characters`, owner.token, {
|
||||
method: 'POST', body: characterBody('Iris Vale', 'A methodical station engineer.'),
|
||||
})
|
||||
const playerCharacter = await appRequest(`/api/v1/campaigns/${campaignId}/characters`, player.token, {
|
||||
method: 'POST', body: characterBody('Rowan Pike', 'A curious xenobotanist.'),
|
||||
})
|
||||
|
||||
console.log('[smoke] Drafting and adding a persistent AI companion…')
|
||||
console.log('[smoke] Verifying AI drafting while keeping the automatic companion…')
|
||||
const suggested = await appRequest(`/api/v1/campaigns/${campaignId}/characters/suggest`, owner.token, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ controller: 'ai', concept: 'A damaged garden caretaker who values living things over orders.' }),
|
||||
@@ -152,10 +155,6 @@ const suggested = await appRequest(`/api/v1/campaigns/${campaignId}/characters/s
|
||||
if (!suggested?.character?.name || !suggested.character?.persona?.motivation) {
|
||||
throw new Error('[smoke] Character coauthor returned an incomplete draft.')
|
||||
}
|
||||
await appRequest(`/api/v1/campaigns/${campaignId}/characters`, owner.token, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ ...suggested.character, controller: 'ai', statuses: [] }),
|
||||
})
|
||||
|
||||
const initial = await appRequest(`/api/v1/campaigns/${campaignId}`, owner.token)
|
||||
if (initial.members.length !== 2) throw new Error(`[smoke] Expected 2 members, received ${initial.members.length}.`)
|
||||
@@ -165,7 +164,7 @@ const roundId = initial.round.id
|
||||
console.log('[smoke] Verifying that the round waits for both humans…')
|
||||
await appRequest(`/api/v1/campaigns/${campaignId}/rounds/${roundId}/intent`, owner.token, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ characterId: ownerCharacter.character.id, action: 'Iris checks the airlock telemetry for a safe path.', ready: true }),
|
||||
body: JSON.stringify({ characterId: ownerCharacter.id, action: 'The owner checks the airlock telemetry for a safe path.', ready: true }),
|
||||
})
|
||||
await new Promise(resolve => setTimeout(resolve, 1_500))
|
||||
const waiting = await appRequest(`/api/v1/campaigns/${campaignId}`, player.token)
|
||||
|
||||
Reference in New Issue
Block a user