Populate campaign players array in combat replay and scenario
Both combat.js replay and Combat.scenario.test.js built character participants inline via buildCharacterParticipant without persisting to campaign doc. Real app stores chars in campaign doc players array; encounter participants built from that. Replay/scenario diverged from real flow — campaign had zero chars. Fix: - replay.js: roster chars now have id, persisted to campaign doc players array at setup_campaign step - Combat.scenario.test.js: addCharacterViaUI writes char to campaign doc players array (mirrors app), CAMPAIGN_PATH const added
This commit is contained in:
@@ -7,6 +7,7 @@ Backlog of bugs + long-term items. Milestones live in REWORK_PLAN.md.
|
|||||||
|
|
||||||
|
|
||||||
### dm list - keep active particpant in view (scroll)
|
### dm list - keep active particpant in view (scroll)
|
||||||
|
not sure good way to do this
|
||||||
|
|
||||||
### combat.js doesnt seem to actually exercise the add characters. there are no characters in the campaign. only in the encounter..
|
### combat.js doesnt seem to actually exercise the add characters. there are no characters in the campaign. only in the encounter..
|
||||||
|
|
||||||
@@ -99,6 +100,9 @@ Backlog of bugs + long-term items. Milestones live in REWORK_PLAN.md.
|
|||||||
- Migration: keep old log entries readable; new format for new writes.
|
- Migration: keep old log entries readable; new format for new writes.
|
||||||
|
|
||||||
|
|
||||||
|
### quality of life fix: 2. UI says "Campaign Characters", field is players --- naming mismatch (separate concern, flag for later)
|
||||||
|
|
||||||
|
|
||||||
## FEAT - parallel campaigns
|
## FEAT - parallel campaigns
|
||||||
|
|
||||||
## FEAT - multi user
|
## FEAT - multi user
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ const pick = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
|||||||
|
|
||||||
function buildRoster() {
|
function buildRoster() {
|
||||||
return [
|
return [
|
||||||
{ name: 'Fighter', defaultMaxHp: 200, defaultInitMod: 2 },
|
{ id: 'char-fighter', name: 'Fighter', defaultMaxHp: 200, defaultInitMod: 2 },
|
||||||
{ name: 'Cleric', defaultMaxHp: 180, defaultInitMod: 1 },
|
{ id: 'char-cleric', name: 'Cleric', defaultMaxHp: 180, defaultInitMod: 1 },
|
||||||
{ name: 'Rogue', defaultMaxHp: 160, defaultInitMod: 3 },
|
{ id: 'char-rogue', name: 'Rogue', defaultMaxHp: 160, defaultInitMod: 3 },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
function buildMonsters() {
|
function buildMonsters() {
|
||||||
@@ -239,6 +239,7 @@ module.exports = async function replay(args) {
|
|||||||
await callStep('setup_campaign', { campaignId }, async () =>
|
await callStep('setup_campaign', { campaignId }, async () =>
|
||||||
storage.setDoc(getPath.campaign(campaignId), {
|
storage.setDoc(getPath.campaign(campaignId), {
|
||||||
id: campaignId, name: `Replay Campaign ${runStamp}`, createdAt: Date.now(),
|
id: campaignId, name: `Replay Campaign ${runStamp}`, createdAt: Date.now(),
|
||||||
|
players: buildRoster(),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
await callStep('setup_encounter', { encounterId }, async () =>
|
await callStep('setup_encounter', { encounterId }, async () =>
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ let display = {
|
|||||||
hideNpcHp: false,
|
hideNpcHp: false,
|
||||||
};
|
};
|
||||||
const CAMPAIGN_ID = 'camp-1';
|
const CAMPAIGN_ID = 'camp-1';
|
||||||
const roster = [];
|
const CAMPAIGN_PATH = `campaigns/${CAMPAIGN_ID}`;const roster = [];
|
||||||
|
|
||||||
let storage, ctx;
|
let storage, ctx;
|
||||||
const DISPLAY_PATH = 'activeDisplay/status';
|
const DISPLAY_PATH = 'activeDisplay/status';
|
||||||
@@ -74,7 +74,16 @@ const any = (name) => enc.participants.find(p => p.name === name);
|
|||||||
const anyById = (id) => enc.participants.find(p => p.id === id);
|
const anyById = (id) => enc.participants.find(p => p.id === id);
|
||||||
|
|
||||||
function addCharacterViaUI(name, maxHp, initMod) {
|
function addCharacterViaUI(name, maxHp, initMod) {
|
||||||
roster.push({ id: `char-${name}`, name, defaultMaxHp: maxHp, defaultInitMod: initMod });
|
const character = { id: `char-${name}`, name, defaultMaxHp: maxHp, defaultInitMod: initMod };
|
||||||
|
roster.push(character);
|
||||||
|
// persist to campaign doc (mirrors app: players array)
|
||||||
|
if (storage) {
|
||||||
|
const existing = (storage.docs.get(CAMPAIGN_PATH) || {}).players || [];
|
||||||
|
storage.setDoc(CAMPAIGN_PATH, {
|
||||||
|
id: CAMPAIGN_ID, name: 'Scenario Campaign', createdAt: Date.now(),
|
||||||
|
players: [...existing, character],
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addMonsterParticipant(name, maxHp, initMod, asNpc = false) {
|
async function addMonsterParticipant(name, maxHp, initMod, asNpc = false) {
|
||||||
|
|||||||
Reference in New Issue
Block a user