Skip to content

Commit 03e8b76

Browse files
authored
Feat/issue 331 npc distinction (#337)
2 parents 2b82f3d + c2eab04 commit 03e8b76

13 files changed

Lines changed: 125 additions & 257 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: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@
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",
111-
props: ["targeted", "player", "encounter"],
112+
mixins: [trackEncounter],
113+
props: ["targeted", "player", "encounter", "npcSettings", "allySettings"],
112114
data() {
113115
return {
114116
userId: this.$store.getters.user.uid,
@@ -192,13 +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-
else if (this.npcSettings[field] == undefined) return defaults[field]; // Default value
199-
else return this.npcSettings[field];
200197
},
201-
},
202198
};
203199
</script>
204200

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@
6161
:players="players"
6262
:npcs="npcs"
6363
:npcSettings="npcSettings"
64+
:allySettings="allySettings"
6465
/>
6566
</div>
6667
</li>
6768
</ul>
68-
<DamageHealing :targeted="targeted" :player="player" :encounter="encounter" />
69+
<DamageHealing :targeted="targeted" :player="player" :encounter="encounter" :npcSettings="npcSettings" :allySettings="allySettings" />
6970
</div>
7071
</template>
7172

@@ -95,6 +96,7 @@
9596
players: this.data.players,
9697
campPlayers: this.data.campPlayers,
9798
npcSettings: this.data.npcSettings,
99+
allySettings: this.data.allySettings,
98100
npcs: this.data.npcs,
99101
player: this.data.characters[0]
100102
}

src/components/settings/TrackEncounter.vue

Lines changed: 47 additions & 212 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,42 @@
9595
<script>
9696
import { mapGetters, mapActions } from "vuex";
9797
98+
const SHOW_HIDE = [
99+
{ value: false, name: "Hidden", action: "Hide", icon: "fas fa-eye-slash", color: "red" },
100+
{ value: undefined, name: "Shown", action: "Show", icon: "fas fa-eye", color: "green" },
101+
];
102+
103+
const NPC_HEALTH = [
104+
{ value: undefined, name: "Hidden", action: "Hide", icon: "fas fa-eye-slash", color: "red" },
105+
{ value: "obscured", name: "Obsc", action: "Obsc", icon: "fas fa-question-circle", color: "orange" },
106+
{ value: true, name: "Shown", action: "Show", icon: "fas fa-eye", color: "green" },
107+
];
108+
109+
const NPC_AC = [
110+
{ value: undefined, name: "Hidden", action: "Hide", icon: "fas fa-eye-slash", color: "red" },
111+
{ value: true, name: "Shown", action: "Show", icon: "fas fa-eye", color: "green" },
112+
];
113+
114+
const PLAYER_HEALTH = [
115+
{ value: false, name: "Hidden", action: "Hide", icon: "fas fa-eye-slash", color: "red" },
116+
{ value: "obscured", name: "Obsc", action: "Obsc", icon: "fas fa-question-circle", color: "orange" },
117+
{ value: undefined, name: "Shown", action: "Show", icon: "fas fa-eye", color: "green" },
118+
];
119+
120+
const DEATH_SAVES = [
121+
{ value: true, name: "Hidden", action: "Hide", icon: "fas fa-eye-slash", color: "red" },
122+
{ value: undefined, name: "Shown", action: "Show", icon: "fas fa-eye", color: "green" },
123+
];
124+
125+
function npcTypeSettings(entity, label) {
126+
return [
127+
{ key: "name", entity, name: "Name", icon: "fas fa-helmet-battle", info: `Players can see the names of ${label}.`, options: SHOW_HIDE },
128+
{ key: "health", entity, name: "Health", icon: "fas fa-heart", info: `Players can see the health of ${label}.`, options: NPC_HEALTH },
129+
{ key: "ac", entity, name: "Armor Class", icon: "fas fa-shield", info: `Players can see the armor class of ${label}.`, options: NPC_AC },
130+
{ key: "conditions", entity, name: "Conditions", icon: "fas fa-flame", info: `Players can see the conditions on ${label}.`, options: SHOW_HIDE },
131+
];
132+
}
133+
98134
export default {
99135
name: "TrackEncounterSettings",
100136
data() {
@@ -103,225 +139,24 @@ export default {
103139
types: {
104140
general: {
105141
type_settings: [
106-
{
107-
key: "meters",
108-
entity: "player",
109-
name: "Damage Meters",
110-
icon: "fas fa-swords",
111-
info: "Players can see the damage meters.",
112-
options: [
113-
{
114-
value: false,
115-
name: "Hidden",
116-
action: "Hide",
117-
icon: "fas fa-eye-slash",
118-
color: "red",
119-
},
120-
{
121-
value: undefined,
122-
name: "Shown",
123-
action: "Show",
124-
icon: "fas fa-eye",
125-
color: "green",
126-
},
127-
],
128-
},
142+
{ key: "meters", entity: "player", name: "Damage Meters", icon: "fas fa-swords", info: "Players can see the damage meters.", options: SHOW_HIDE },
129143
],
130144
},
131145
npcs: {
132-
name: "NPC's",
133-
type_settings: [
134-
{
135-
key: "name",
136-
entity: "npc",
137-
name: "Name",
138-
icon: "fas fa-helmet-battle",
139-
info: "Players can see the names of NPC's.",
140-
options: [
141-
{
142-
value: false,
143-
name: "Hidden",
144-
action: "Hide",
145-
icon: "fas fa-eye-slash",
146-
color: "red",
147-
},
148-
{
149-
value: undefined,
150-
name: "Shown",
151-
action: "Show",
152-
icon: "fas fa-eye",
153-
color: "green",
154-
},
155-
],
156-
},
157-
{
158-
key: "health",
159-
entity: "npc",
160-
name: "Health",
161-
icon: "fas fa-heart",
162-
info: "Players can see the health of NPC's.",
163-
options: [
164-
{
165-
value: undefined,
166-
name: "Hidden",
167-
action: "Hide",
168-
icon: "fas fa-eye-slash",
169-
color: "red",
170-
},
171-
{
172-
value: "obscured",
173-
name: "Obsc",
174-
action: "Obsc",
175-
icon: "fas fa-question-circle",
176-
color: "orange",
177-
},
178-
{ value: true, name: "Shown", action: "Show", icon: "fas fa-eye", color: "green" },
179-
],
180-
},
181-
{
182-
key: "ac",
183-
entity: "npc",
184-
name: "Armor Class",
185-
icon: "fas fa-shield",
186-
info: "Players can see the armor class of NPC's.",
187-
options: [
188-
{
189-
value: undefined,
190-
name: "Hidden",
191-
action: "Hide",
192-
icon: "fas fa-eye-slash",
193-
color: "red",
194-
},
195-
{ value: true, name: "Shown", action: "Show", icon: "fas fa-eye", color: "green" },
196-
],
197-
},
198-
{
199-
key: "conditions",
200-
entity: "npc",
201-
name: "Conditions",
202-
icon: "fas fa-flame",
203-
info: "Players can see the conditions on NPC's.",
204-
options: [
205-
{
206-
value: false,
207-
name: "Hidden",
208-
action: "Hide",
209-
icon: "fas fa-eye-slash",
210-
color: "red",
211-
},
212-
{
213-
value: undefined,
214-
name: "Shown",
215-
action: "Show",
216-
icon: "fas fa-eye",
217-
color: "green",
218-
},
219-
],
220-
},
221-
],
146+
name: "Enemies",
147+
type_settings: npcTypeSettings("npc", "NPC's"),
148+
},
149+
allies: {
150+
name: "Allies",
151+
type_settings: npcTypeSettings("ally", "allied NPC's"),
222152
},
223153
players: {
224154
name: "Players",
225155
type_settings: [
226-
{
227-
key: "health",
228-
entity: "player",
229-
name: "Health",
230-
icon: "fas fa-heart",
231-
info: "Players can see the health of players.",
232-
options: [
233-
{
234-
value: false,
235-
name: "Hidden",
236-
action: "Hide",
237-
icon: "fas fa-eye-slash",
238-
color: "red",
239-
},
240-
{
241-
value: "obscured",
242-
name: "Obsc",
243-
action: "Obsc",
244-
icon: "fas fa-question-circle",
245-
color: "orange",
246-
},
247-
{
248-
value: undefined,
249-
name: "Shown",
250-
action: "Show",
251-
icon: "fas fa-eye",
252-
color: "green",
253-
},
254-
],
255-
},
256-
{
257-
key: "ac",
258-
entity: "player",
259-
name: "Armor Class",
260-
icon: "fas fa-shield",
261-
info: "Players can see the armor class of players.",
262-
options: [
263-
{
264-
value: false,
265-
name: "Hidden",
266-
action: "Hide",
267-
icon: "fas fa-eye-slash",
268-
color: "red",
269-
},
270-
{
271-
value: undefined,
272-
name: "Shown",
273-
action: "Show",
274-
icon: "fas fa-eye",
275-
color: "green",
276-
},
277-
],
278-
},
279-
{
280-
condition: "conditions",
281-
entity: "player",
282-
name: "Conditions",
283-
icon: "fas fa-flame",
284-
info: "Players can see the conditions of players.",
285-
options: [
286-
{
287-
value: false,
288-
name: "Hidden",
289-
action: "Hide",
290-
icon: "fas fa-eye-slash",
291-
color: "red",
292-
},
293-
{
294-
value: undefined,
295-
name: "Shown",
296-
action: "Show",
297-
icon: "fas fa-eye",
298-
color: "green",
299-
},
300-
],
301-
},
302-
{
303-
key: "hide_death_saves",
304-
entity: "player",
305-
name: "Death Saves",
306-
icon: "fas fa-skull-crossbones",
307-
info: "Players can see the death saves/fails of other players.",
308-
options: [
309-
{
310-
value: true,
311-
name: "Hidden",
312-
action: "Hide",
313-
icon: "fas fa-eye-slash",
314-
color: "red",
315-
},
316-
{
317-
value: undefined,
318-
name: "Shown",
319-
action: "Show",
320-
icon: "fas fa-eye",
321-
color: "green",
322-
},
323-
],
324-
},
156+
{ key: "health", entity: "player", name: "Health", icon: "fas fa-heart", info: "Players can see the health of players.", options: PLAYER_HEALTH },
157+
{ key: "ac", entity: "player", name: "Armor Class", icon: "fas fa-shield", info: "Players can see the armor class of players.", options: SHOW_HIDE },
158+
{ key: "conditions", entity: "player", name: "Conditions", icon: "fas fa-flame", info: "Players can see the conditions of players.", options: SHOW_HIDE },
159+
{ key: "hide_death_saves", entity: "player", name: "Death Saves", icon: "fas fa-skull-crossbones", info: "Players can see the death saves/fails of other players.", options: DEATH_SAVES },
325160
],
326161
},
327162
},

src/components/trackCampaign/Meters.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
>
3636
<div class="info">
3737
<span class="name">
38-
<Name :entity="entity" :players="players" :npcs="npcs" :npcSettings="npcSettings || {}" />
38+
<Name :entity="entity" :players="players" :npcs="npcs" :displaySettings="displaySettings" />
3939
</span>
4040
<span class="numbers">
4141
<span :class="{
@@ -79,8 +79,12 @@
7979
'campaign',
8080
'players',
8181
'npcs',
82-
'npcSettings'
82+
'displaySettings'
8383
],
84+
computed: {
85+
npcSettings() { return this.displaySettings?.npc; },
86+
allySettings() { return this.displaySettings?.ally; },
87+
},
8488
data() {
8589
return {
8690
userId: this.$route.params.userid,

src/components/trackCampaign/Shares.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<div class="header">
2020
<!-- NAME -->
2121
<div class="name truncate" v-if="entity_key && entities && Object.keys(entities).includes(entity_key)">
22-
<Name :entity="entities[entity_key]" :players="players" :npcs="npcs" :npcSettings="npcSettings" />
22+
<Name :entity="entities[entity_key]" :players="players" :npcs="npcs" :displaySettings="displaySettings" />
2323
</div>
2424

2525

@@ -47,7 +47,7 @@
4747
<div v-if="entities && Object.keys(entities).includes(target)" :key="target" class="img">
4848
<Avatar :entity="entities[target]" :players="players" :npcs="npcs" />
4949
<q-tooltip anchor="top middle" self="center middle">
50-
<Name :entity="entities[target]" :players="players" :npcs="npcs" :npcSettings="npcSettings" />
50+
<Name :entity="entities[target]" :players="players" :npcs="npcs" :displaySettings="displaySettings" />
5151
</q-tooltip>
5252
</div>
5353
</template>
@@ -138,11 +138,15 @@
138138
type: Object,
139139
default: undefined
140140
},
141-
npcSettings: {
141+
displaySettings: {
142142
type: Object,
143143
default: undefined
144144
}
145145
},
146+
computed: {
147+
npcSettings() { return this.displaySettings?.npc; },
148+
allySettings() { return this.displaySettings?.ally; },
149+
},
146150
data() {
147151
return {
148152
damage_types: damage_types,

0 commit comments

Comments
 (0)