Skip to content

Commit 7a31426

Browse files
committed
Reduce ally/npc settings duplication across encounter components
- Remove duplicate displayNPCField from DamageHealing.vue, use trackEncounter mixin instead - Replace manual ally/npc branch in Initiative.vue conditions check with displayNPCField - Fix EditEntity.vue npcSettings computed to read ally settings for friendly NPC entities
1 parent df8a996 commit 7a31426

3 files changed

Lines changed: 7 additions & 12 deletions

File tree

src/components/drawers/encounter/EditEntity.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,10 @@ export default {
433433
},
434434
},
435435
npcSettings() {
436-
return this.userSettings && this.userSettings.track ? this.userSettings.track.npc : undefined;
436+
if (!this.userSettings?.track) return undefined;
437+
return this.entity?.friendly
438+
? this.userSettings.track.ally
439+
: this.userSettings.track.npc;
437440
},
438441
},
439442
methods: {

src/components/drawers/trackCampaign/playerRequests/DamageHealing.vue

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@
105105
<script>
106106
import { db } from "src/firebase";
107107
import { mapActions, mapGetters } from "vuex";
108+
import { trackEncounter } from "src/mixins/trackEncounter";
108109
109110
export default {
110111
name: "damageHealing",
112+
mixins: [trackEncounter],
111113
props: ["targeted", "player", "encounter", "npcSettings", "allySettings"],
112114
data() {
113115
return {
@@ -192,17 +194,7 @@ export default {
192194
);
193195
this.setDrawer({ show: false });
194196
},
195-
displayNPCField(field, entity) {
196-
const defaults = { name: true, health: false, ac: false };
197-
if (entity.settings && entity.settings[field] !== undefined) return entity.settings[field];
198-
199-
// Select global settings based on friendly flag
200-
const globalSettings = entity.friendly ? this.allySettings : this.npcSettings;
201-
202-
if (!globalSettings || globalSettings[field] == undefined) return defaults[field]; // Default value
203-
return globalSettings[field];
204197
},
205-
},
206198
};
207199
</script>
208200

src/components/trackCampaign/live/Initiative.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
v-if="
189189
(playerSettings.conditions === undefined &&
190190
(entity.entityType === 'player' ||
191-
(entity.entityType == 'npc' && (entity.friendly ? (allySettings || {}).conditions : npcSettings.conditions) === undefined))) ||
191+
(entity.entityType == 'npc' && displayNPCField('conditions', entity) === undefined))) ||
192192
entity.entityType === 'companion'
193193
"
194194
>

0 commit comments

Comments
 (0)