Skip to content

Commit

Permalink
Fix browser not loading
Browse files Browse the repository at this point in the history
  • Loading branch information
cswendrowski committed Oct 10, 2021
1 parent a2e0785 commit effd6d9
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 24 deletions.
11 changes: 9 additions & 2 deletions scripts/dnd5e.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ export default class Dnd5e {

constructor() {
this.environments = [];
this.creatureTypes = Object.keys(CONFIG.DND5E.creatureTypes).map((x) => ({
label: game.i18n.localize(CONFIG.DND5E.creatureTypes[x]),
value: x,
}));
this.actorSizes = Object.values(CONFIG.DND5E.actorSizes).reverse();
this.damageResistanceTypes = Object.values(CONFIG.DND5E.damageResistanceTypes);
this.movementTypes = Object.keys(CONFIG.DND5E.movementTypes);
}

initValuesFromAllActors(allActors) {
Expand Down Expand Up @@ -232,12 +239,12 @@ export default class Dnd5e {
getSafeLevel(actor) {
if (actor.data.type == "character") {
if (actor.data?.data?.details?.level) {
return actor.data.data.details.level;
return Number(actor.data.data.details.level);
}
}
else {
if (actor.data?.data?.details?.cr) {
return actor.data.data.details.cr;
return Number(actor.data.data.details.cr);
}
}
return 0;
Expand Down
2 changes: 2 additions & 0 deletions vue/EncounterBuilder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
:group="t[0]"
:actor="t[1][0]"
:groupSize="t[1].length"
:system="system"
v-on:add-actor="addActor(t[1][0])"
v-on:remove-actor="removeActor(t[1][0])"
v-on:actor-info="openActorSheet(t[1][0])"
Expand Down Expand Up @@ -169,6 +170,7 @@
v-for="t of availableActors"
:key="system.getUniqueKey(t, partyInfo, encounterSettings)"
:actor="t"
:system="system"
v-on:add-actor="addActor(t)"
v-on:remove-actor="removeActor(t)"
v-on:actor-info="openActorSheet(t)"
Expand Down
20 changes: 14 additions & 6 deletions vue/components/dnd5e/dnd5e-actor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</h4>

<em class="trait-value">
{{CONFIG.DND5E.actorSizes[actor.data.data.traits.size]}} {{ actor.labels.creatureType }}
{{actorSizes[actor.data.data.traits.size]}} {{ actor.labels.creatureType }}
</em>

<hr />
Expand All @@ -16,7 +16,7 @@
<div
is="actor-trait"
:label="'Challenge'"
:value="`${window.dungeonMoon.dnd5e.histogramLabelPrettify(actor.data.data.details.cr)} (${actor.encounterScore} XP)`"></div>
:value="`${system.histogramLabelPrettify(actor.data.data.details.cr)} (${actor.encounterScore} XP)`"></div>
</dl>

<ul class="tags">
Expand All @@ -43,7 +43,15 @@
<script>
export default {
name: "dnd5e-actor",
props: ["actor"],
props: ["actor", "system"],
data: () => ({
actorSizes: [],
movementTypes: []
}),
created() {
this.actorSizes = window.dungeonMoon.dnd5e.actorSizes;
this.movementTypes = window.dungeonMoon.dnd5e.movementTypes;
},
computed: {
tags() {
const {attributes, details, resources} = this.actor.data.data;
Expand All @@ -53,10 +61,10 @@ export default {
const environments = !!details.environment && details.environment?.split(',').map(env => env.trim());
environments && ret.push(...environments);
const movements = Object.keys(CONFIG.DND5E.movementTypes)
const movements = this.movementTypes
.filter(movementType => movementType !== 'walk')
.filter(movementType => attributes.movement[movementType] > 0)
.map(movementType => CONFIG.DND5E.movementTypes[movementType]);
.map(movementType => this.movementTypes[movementType]);
movements.length && ret.push(...movements);
Expand All @@ -74,7 +82,7 @@ export default {
ret.push(details.alignment);
ret.filter(tag => !!tag.trim());
ret.filter(tag => tag && !!tag.trim());
return ret;
}
Expand Down
28 changes: 14 additions & 14 deletions vue/components/dnd5e/dnd5e-filters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
<v-select
multiple
v-model="selectedTypes"
:options="
Object.keys(CONFIG.DND5E.creatureTypes).map((x) => ({
label: game.i18n.localize(CONFIG.DND5E.creatureTypes[x]),
value: x,
}))
"
:options="creatureTypes"
:reduce="(x) => x.value"
></v-select>
</div>
Expand All @@ -30,7 +25,7 @@
<v-select
multiple
v-model="selectedSizes"
:options="Object.values(CONFIG.DND5E.actorSizes).reverse()"
:options="actorSizes"
></v-select>
</div>

Expand Down Expand Up @@ -80,7 +75,7 @@
<v-select
multiple
v-model="selectedResistances"
:options="Object.values(CONFIG.DND5E.damageResistanceTypes)"
:options="damageResistanceTypes"
:reduce="(x) => x.toLowerCase()"
></v-select>
</div>
Expand All @@ -89,7 +84,7 @@
<v-select
multiple
v-model="selectedImmunities"
:options="Object.values(CONFIG.DND5E.damageResistanceTypes)"
:options="damageResistanceTypes"
:reduce="(x) => x.toLowerCase()"
></v-select>
</div>
Expand All @@ -98,7 +93,7 @@
<v-select
multiple
v-model="selectedVulnerabilities"
:options="Object.values(CONFIG.DND5E.damageResistanceTypes)"
:options="damageResistanceTypes"
:reduce="(x) => x.toLowerCase()"
></v-select>
</div>
Expand All @@ -108,22 +103,27 @@
export default {
name: 'dnd5e-filters',
data: () => ({
environments: [],
selectedEnvironments: [],
creatureTypes: [],
selectedTypes: [],
actorSizes: [],
selectedSizes: [],
selectedAlignmentsLaw: [],
selectedAlignmentsGood: [],
selectedMovements: [],
selectedTraits: [],
damageResistanceTypes: [],
selectedResistances: [],
selectedImmunities: [],
selectedVulnerabilities: [],
}),
props: ['value'],
computed: {
environments() {
return window.dungeonMoon.dnd5e.environments;
},
created() {
this.environments = window.dungeonMoon.dnd5e.environments;
this.creatureTypes = window.dungeonMoon.dnd5e.creatureTypes;
this.actorSizes = window.dungeonMoon.dnd5e.actorSizes;
this.damageResistanceTypes = window.dungeonMoon.dnd5e.damageResistanceTypes;
},
methods: {
dataBundle: function () {
Expand Down
4 changes: 2 additions & 2 deletions vue/components/dnd5e/dnd5e-selected-actor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="member-details">
<strong class="name">{{ group }}</strong>
<div>
{{window.dungeonMoon.dnd5e.levelName()}} {{window.dungeonMoon.dnd5e.histogramLabelPrettify(actor.data.data.details.cr)}}
{{system.levelName()}} {{system.histogramLabelPrettify(actor.data.data.details.cr)}}
</div>
<div>
<strong>{{ groupsize }}</strong> x {{ actor.encounterScore }} = {{ (actor.encounterScore * groupsize) }} XP
Expand All @@ -31,6 +31,6 @@
<script>
export default {
name: "dnd5e-selected-actor",
props: ["group", "actor", "groupsize"],
props: ["group", "actor", "groupsize", "system"],
};
</script>

0 comments on commit effd6d9

Please sign in to comment.