Skip to content

Commit

Permalink
Merge branch 'release/2.18.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Lakeyzer committed Jul 14, 2023
2 parents 03d2160 + f65b454 commit 7dda187
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 60 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.17.0",
"version": "2.18.0",
"name": "harmless_key",
"description": "A Dungeons and Dragons Combat Tracker",
"productName": "Harmless Key",
Expand Down
34 changes: 16 additions & 18 deletions src/components/combat/actions/Roll.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- eslint-disable vue/no-parsing-error -->
<template>
<div v-if="current">
<h3 v-if="targeted.length === 0" class="red text-center">Select one or more targets</h3>
Expand Down Expand Up @@ -120,6 +121,14 @@
"
>
<!-- Rolls -->
<span v-if="!isNil(action.action_list[0].attack_bonus)">
{{
action.action_list[0].attack_bonus < 0
? `-${Math.abs(action.action_list[0].attack_bonus)}`
: `+${action.action_list[0].attack_bonus}`
}}
to hit
</span>
<span v-if="action.action_list[0].rolls">
<span
v-for="(roll, roll_index) in action.action_list[0].rolls"
Expand All @@ -136,26 +145,13 @@
/>
{{ roll.dice_count || "" }}{{ roll.dice_type ? `d${roll.dice_type}` : ``
}}<template v-if="roll.fixed_val && roll.dice_count">
{{ (roll.fixed_val &lt; 0) ? `- ${Math.abs(roll.fixed_val)}` : `+ ${roll.fixed_val}`
















{{
roll.fixed_val < 0
? `- ${Math.abs(roll.fixed_val)}`
: `+ ${roll.fixed_val}`
}}) </template
><template v-else>{{ roll.fixed_val }})</template>
{{ roll_index+1 &lt; action.action_list[0].rolls.length ? "+" : "" }}
{{ roll_index + 1 < action.action_list[0].rolls.length ? "+" : "" }}
<q-tooltip anchor="top middle" self="center middle">
{{
action.action_list[0].type === "healing"
Expand Down Expand Up @@ -310,6 +306,7 @@ import { setHP } from "src/mixins/HpManipulations.js";
import { damage_type_icons } from "src/utils/generalConstants";
import { runEncounter } from "src/mixins/runEncounter.js";
import Projectiles from "./Projectiles";
import { isNil } from "lodash";

export default {
name: "Roll",
Expand All @@ -333,6 +330,7 @@ export default {
],
rollObject: {},
projectile_dialog: false,
isNil: isNil,
};
},
computed: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,21 @@
{{ calcAverage(data.row.dice_type, data.row.dice_count, data.row.fixed_val) }}
({{ data.row.dice_count || "" }}{{ data.row.dice_type ? `d${data.row.dice_type}` : `` }}
<template v-if="data.row.fixed_val && data.row.dice_count">
{{
(data.row.fixed_val &lt; 0) ? `- ${Math.abs(data.row.fixed_val)}` : `+ ${data.row.fixed_val}`





{{
// eslint-disable-next-line vue/no-parsing-error
data.row.fixed_val < 0
? `- ${Math.abs(data.row.fixed_val)}`
: `+ ${data.row.fixed_val}`
}})
</template>
<template v-else>{{ data.row.fixed_val }})</template>
<q-tooltip v-if="versatile" anchor="top middle" self="bottom middle">
{{ versatileOptions[0] || "Enter versatile option" }}
</q-tooltip>
</span>
<span v-if="versatile && versatileRoll(data.row)">
|
{{
calcAverage(
data.row.versatile_dice_type || data.row.dice_type,
data.row.versatile_dice_count || data.row.dice_count,
data.row.versatile_fixed_val || data.row.fixed_val
)
}}
({{ versatileRoll(data.row) }})
<q-tooltip anchor="top middle" self="bottom middle">
{{ versatileOptions[1] || "Enter versatile option" }}
</q-tooltip>
<span v-if="data.row.options && versatileRoll(data.row)">
| {{ versatileRoll(data.row) }}
</span>
<span v-if="Object.values(data.row.options).length > 1">
<span>| ...</span>
<q-tooltip anchor="top middle" self="bottom middle">More than two Options</q-tooltip>
</span>
</div>

Expand Down Expand Up @@ -179,27 +167,33 @@ export default {
: parseInt(modifier);
},
versatileRoll(roll) {
if (!roll.versatile_dice_count && !roll.versatile_dice_type && !roll.versatile_fixed_val) {
if (!roll.options) {
return undefined;
} else {
let returnRoll = {};
}
returnRoll.dice_count = roll.versatile_dice_count
? roll.versatile_dice_count
: roll.dice_count;
returnRoll.dice_type = roll.versatile_dice_type ? roll.versatile_dice_type : roll.dice_type;
returnRoll.fixed_val = roll.versatile_fixed_val ? roll.versatile_fixed_val : roll.fixed_val;
const firstOption = Object.values(roll.options)[0];
const returnRoll = {};
let fixed;
if (returnRoll.fixed_val !== undefined) {
fixed =
returnRoll.fixed_val < 0
? ` - ${Math.abs(returnRoll.fixed_val)}`
: ` + ${returnRoll.fixed_val}`;
}
returnRoll.dice_count = firstOption.dice_count ? firstOption.dice_count : roll.dice_count;
returnRoll.dice_type = firstOption.dice_type ? firstOption.dice_type : roll.dice_type;
returnRoll.fixed_val =
firstOption.fixed_val !== undefined ? firstOption.fixed_val : roll.fixed_val;
return `${returnRoll.dice_count}d${returnRoll.dice_type}${fixed}`;
let fixed;
if (returnRoll.fixed_val !== undefined) {
fixed =
returnRoll.fixed_val < 0
? ` - ${Math.abs(returnRoll.fixed_val)}`
: ` + ${returnRoll.fixed_val}`;
}
const average = this.calcAverage(
returnRoll.dice_type,
returnRoll.dice_count,
returnRoll.fixed_val
);
return `${average} (${returnRoll.dice_count}d${returnRoll.dice_type}${fixed})`;
},
scalingDesc(tiers, scaling, level) {
return spellScalingDescription(tiers, scaling, level);
Expand Down
1 change: 1 addition & 0 deletions src/components/npcs/Actions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@
class="mb-4"
@new-value="addOption"
@remove="removeOption($event, category, ability_index)"
@input="$forceUpdate()"
>
<hk-popover slot="append" header="Action options">
<i class="fas fa-info-circle" aria-hidden="true" />
Expand Down
1 change: 1 addition & 0 deletions src/mixins/dice.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ export const dice = {
const option = roll.options[config.option];
if (option.ignore) {
editableRoll = {};
continue;
} else {
editableRoll.damage_type = option.damage_type || editableRoll.damage_type;
editableRoll.dice_type = option.dice_type || editableRoll.dice_type;
Expand Down
32 changes: 32 additions & 0 deletions src/views/UserContent/Npcs/EditNpc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export default {
copy({ result }) {
this.copy_dialog = false;
this.npc = { ...result };
this.npc = this.convertVersatileToOptions(this.npc);
},
reset() {
this.npc = {};
Expand All @@ -177,6 +178,37 @@ export default {
this.npc_copy = JSON.parse(JSON.stringify(this.npc));
this.unsaved_changes = false;
},
convertVersatileToOptions(npc) {
if (npc.actions.length > 0) {
for (const action of npc.actions) {
if (action.versatile === true) {
const versTwoName = action.versatile_two;
action.options = [action.versatile_one, action.versatile_two];
delete action.versatile;
delete action.versatile_one;
delete action.versatile_two;
for (const sub_action of action.action_list) {
for (const roll of sub_action.rolls) {
roll.options = {
[versTwoName]: {
damage_type: roll.versatile_damage_type,
dice_count: roll.versatile_dice_count,
dice_type: roll.versatile_dice_type,
fixed_val: roll.versatile_fixed_val,
},
};
delete roll.versatile_damage_type;
delete roll.versatile_dice_count;
delete roll.versatile_dice_type;
delete roll.versatile_fixed_val;
}
}
}
}
}
return npc;
},
/**
* Checks if a new NPC must be added, or an existing NPC must be saved.
**/
Expand Down

0 comments on commit 7dda187

Please sign in to comment.