diff --git a/src/components/creature/CreatureStats.js b/src/components/creature/CreatureStats.js index dd46bcbb..ad27d818 100644 --- a/src/components/creature/CreatureStats.js +++ b/src/components/creature/CreatureStats.js @@ -19,8 +19,6 @@ export default function CreatureStats({ const savingThrows = creature.proficiencies ? creature.proficiencies.filter((ability) => ability.proficiency?.index.includes('saving-throw')) : []; const skills = creature.proficiencies ? creature.proficiencies.filter((ability) => ability.proficiency?.index.includes('skill')) : []; - console.log(`creature ${creature.name}`, creature); - const toggleCreatureStats = () => { setCreatureStats((prevValue) => !prevValue); }; diff --git a/src/components/creature/CreatureWrapper.js b/src/components/creature/CreatureWrapper.js index e8366d76..ab25a80c 100644 --- a/src/components/creature/CreatureWrapper.js +++ b/src/components/creature/CreatureWrapper.js @@ -39,7 +39,7 @@ class CreatureWrapper extends Component { super(props); this.state = { - expanded: true, + expanded: false, showSpellCreator: false, }; @@ -185,8 +185,6 @@ class CreatureWrapper extends Component { rightPercentage, ] = getHitPointsBar(creatureHealthPoints, maxHealthPoints, alive, showHitPoints); - console.log('current creature state', creature, showSpellCreator); - return ( <>
{ ariaAnnouncements: ['creatures added'], }; - const newState = addCreature(defaultState, creature); + const newState = addCreature(defaultState, { ...creature, syncMultipleInitiatives: true }); expect(newState).toEqual(expectedState); expect(createCreature.mock.calls.length).toBe(2); @@ -437,7 +437,7 @@ describe('addCreature', () => { ariaAnnouncements: ['creatures added'], }; - const newState = addCreature(initialState, creature); + const newState = addCreature(initialState, { ...creature, syncMultipleInitiatives: true }); expect(newState).toEqual(expectedState); expect(createCreature.mock.calls.length).toBe(2); diff --git a/src/state/CreatureManager.js b/src/state/CreatureManager.js index e8b9592a..6373bd6c 100644 --- a/src/state/CreatureManager.js +++ b/src/state/CreatureManager.js @@ -242,8 +242,7 @@ export function createCreature(creatureId, { armorClass, name, number, initiative, healthPoints, apiData, spellData, }) { const groupedName = number ? `${name} #${number}` : name; - return { - armorClass, + const finalCreature = { name: groupedName, initiative, healthPoints, @@ -256,9 +255,18 @@ export function createCreature(creatureId, { locked: false, shared: true, hitPointsShared: true, - apiData, - spellData, }; + + if (armorClass) { + finalCreature.armorClass = armorClass; + } + if (apiData) { + finalCreature.apiData = apiData; + } + if (spellData) { + finalCreature.spellData = spellData; + } + return finalCreature; } export function validateCreature(name, initiative, healthPoints, multiplier) { diff --git a/test-integration/page-object-models/dmApp.js b/test-integration/page-object-models/dmApp.js index 62912bde..174cd84e 100644 --- a/test-integration/page-object-models/dmApp.js +++ b/test-integration/page-object-models/dmApp.js @@ -32,7 +32,6 @@ export default class DmApp extends DndBattleTracker { async addCreature(name, initiative, hp, multiply) { await this.enterCreatureName(name); - if (initiative) { const initiativeField = await screen.findByText('Initiative (optional)'); await this.user.type(initiativeField, initiative);