NEO-129: fix Bruno gather interact check (allowed not success).
Tolerate craft-spine partial progress and node_depleted when the quest is already completed in the shared CI collection run.pull/168/head
parent
9ab3a70796
commit
5126e82c4a
|
|
@ -5,7 +5,8 @@ meta {
|
|||
}
|
||||
|
||||
docs {
|
||||
NEO-129: accept gather intro, complete via three alpha gathers, GET quest-progress asserts completionRewardSummary; second GET unchanged.
|
||||
NEO-129: accept gather intro, complete via alpha gathers, GET quest-progress asserts completionRewardSummary; second GET unchanged.
|
||||
Tolerates craft spine (seq 5) partial progress and node_depleted on alpha when quest already completed.
|
||||
}
|
||||
|
||||
script:pre-request {
|
||||
|
|
@ -13,13 +14,54 @@ script:pre-request {
|
|||
const baseUrl = bru.getEnvVar("baseUrl") || bru.getVar("baseUrl");
|
||||
const playerId = bru.getEnvVar("playerId") || bru.getVar("playerId");
|
||||
const headers = { "Content-Type": "application/json" };
|
||||
const gatherQuestId = "prototype_quest_gather_intro";
|
||||
const alphaNodeId = "prototype_resource_node_alpha";
|
||||
|
||||
function gatherRow(body) {
|
||||
return body.quests.find((x) => x.questId === gatherQuestId);
|
||||
}
|
||||
|
||||
async function getQuestProgress() {
|
||||
const response = await axios.get(
|
||||
`${baseUrl}/game/players/${playerId}/quest-progress`,
|
||||
{ validateStatus: () => true },
|
||||
);
|
||||
if (response.status !== 200) {
|
||||
throw new Error(`quest-progress GET failed: ${response.status}`);
|
||||
}
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function tryGatherAlpha() {
|
||||
const interact = await axios.post(
|
||||
`${baseUrl}/game/players/${playerId}/interact`,
|
||||
{
|
||||
schemaVersion: 1,
|
||||
interactableId: alphaNodeId,
|
||||
},
|
||||
{ headers, validateStatus: () => true },
|
||||
);
|
||||
if (interact.status !== 200) {
|
||||
throw new Error(`gather interact HTTP ${interact.status}: ${JSON.stringify(interact.data)}`);
|
||||
}
|
||||
if (interact.data?.allowed === true) {
|
||||
return;
|
||||
}
|
||||
if (interact.data?.reasonCode === "node_depleted") {
|
||||
return;
|
||||
}
|
||||
throw new Error(`gather interact denied: ${JSON.stringify(interact.data)}`);
|
||||
}
|
||||
|
||||
await axios.post(
|
||||
`${baseUrl}/game/players/${playerId}/quests/prototype_quest_gather_intro/accept`,
|
||||
`${baseUrl}/game/players/${playerId}/quests/${gatherQuestId}/accept`,
|
||||
{ schemaVersion: 1 },
|
||||
{ headers, validateStatus: () => true },
|
||||
);
|
||||
|
||||
let progress = await getQuestProgress();
|
||||
let row = gatherRow(progress);
|
||||
if (!row || row.status === "not_started") {
|
||||
await axios.post(
|
||||
`${baseUrl}/game/players/${playerId}/move`,
|
||||
{
|
||||
|
|
@ -28,39 +70,28 @@ script:pre-request {
|
|||
},
|
||||
{ headers },
|
||||
);
|
||||
|
||||
for (let i = 0; i < 3; i += 1) {
|
||||
const interact = await axios.post(
|
||||
`${baseUrl}/game/players/${playerId}/interact`,
|
||||
{
|
||||
schemaVersion: 1,
|
||||
interactableId: "prototype_resource_node_alpha",
|
||||
},
|
||||
{ headers, validateStatus: () => true },
|
||||
);
|
||||
if (interact.status !== 200 || !interact.data?.success) {
|
||||
throw new Error(`expected gather interact to succeed, got ${JSON.stringify(interact.data)}`);
|
||||
}
|
||||
}
|
||||
|
||||
const firstGet = await axios.get(
|
||||
`${baseUrl}/game/players/${playerId}/quest-progress`,
|
||||
{ validateStatus: () => true },
|
||||
);
|
||||
if (firstGet.status !== 200) {
|
||||
throw new Error(`expected first GET quest-progress to return 200, got ${firstGet.status}`);
|
||||
for (let attempt = 0; attempt < 8; attempt += 1) {
|
||||
progress = await getQuestProgress();
|
||||
row = gatherRow(progress);
|
||||
if (row?.status === "completed" && row.completionRewardSummary) {
|
||||
break;
|
||||
}
|
||||
const firstRow = firstGet.data.quests.find(
|
||||
(x) => x.questId === "prototype_quest_gather_intro",
|
||||
);
|
||||
if (!firstRow || firstRow.status !== "completed" || !firstRow.completionRewardSummary) {
|
||||
await tryGatherAlpha();
|
||||
}
|
||||
|
||||
progress = await getQuestProgress();
|
||||
row = gatherRow(progress);
|
||||
if (!row || row.status !== "completed" || !row.completionRewardSummary) {
|
||||
throw new Error(
|
||||
`expected first GET gather intro completed with summary, got ${JSON.stringify(firstRow)}`,
|
||||
`expected gather intro completed with summary, got ${JSON.stringify(row)}`,
|
||||
);
|
||||
}
|
||||
|
||||
bru.setVar(
|
||||
"firstGatherCompletionRewardSummary",
|
||||
JSON.stringify(firstRow.completionRewardSummary),
|
||||
JSON.stringify(row.completionRewardSummary),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue