Get 95% of the way through the stats tab

This commit is contained in:
Oliver-Akins 2024-03-01 23:28:18 -07:00
parent 7516e7b42b
commit c1ee1a9ef8
7 changed files with 91 additions and 46 deletions

View file

@ -30,6 +30,12 @@
"explosives": "Explosives", "explosives": "Explosives",
"piloting": "Piloting" "piloting": "Piloting"
}, },
"trainingLevel": {
"untrained": "Untrained",
"trained": "Trained",
"expert": "Expert",
"locked": "Locked"
},
"die": { "die": {
"d4": "d4", "d4": "d4",
"d6": "d6", "d6": "d6",

View file

@ -1,11 +1,11 @@
export const statDice = [ `d4`, `d6`, `d8`, `d10`, `d12`, `d20` ]; export const statDice = [ `d4`, `d6`, `d8`, `d10`, `d12`, `d20` ];
export const trainingLevels = { export const trainingLevels = [
locked: -1, { key: "locked", label: "dotdungeon.trainingLevel.locked", value: -1 },
untrained: 0, { key: "untrained", label: "dotdungeon.trainingLevel.untrained", value: 0 },
trained: 2, { key: "trained", label: "dotdungeon.trainingLevel.trained", value: 2 },
expert: 4 { key: "expert", label: "dotdungeon.trainingLevel.expert", value: 4 },
} ];
export const damageTypes = [ `slashing`, `piercing`, `smashing`, `gun`, `neon`, `shadow`, `solar` ]; export const damageTypes = [ `slashing`, `piercing`, `smashing`, `gun`, `neon`, `shadow`, `solar` ];
@ -32,6 +32,7 @@ export const skills = {
hands: handsSkills, hands: handsSkills,
}; };
export const defaultItemTier = `simple`;
export const itemTiers = [ export const itemTiers = [
`simple`, `greater`, `simple`, `greater`,
`rare`, `legendary` `rare`, `legendary`
@ -64,6 +65,7 @@ export default {
handsSkills, handsSkills,
allSkills, allSkills,
skills, skills,
defaultItemTier,
itemTiers, itemTiers,
syncMilestones, syncMilestones,
syncDice, syncDice,

View file

@ -1,3 +1,5 @@
import { localizer } from "../utils/localizer.mjs";
/** /**
* @typedef {object} Option * @typedef {object} Option
* @property {string} [label] * @property {string} [label]
@ -9,7 +11,8 @@
* @param {string | number} selected * @param {string | number} selected
* @param {Array<Option | string>} opts * @param {Array<Option | string>} opts
*/ */
export function options(selected, opts) { export function options(selected, opts, meta) {
const { localize = false } = meta.hash;
selected = Handlebars.escapeExpression(selected); selected = Handlebars.escapeExpression(selected);
const htmlOptions = []; const htmlOptions = [];
@ -24,7 +27,7 @@ export function options(selected, opts) {
${selected === opt.value ? "selected" : ""} ${selected === opt.value ? "selected" : ""}
${opt.disabled ? "disabled" : ""} ${opt.disabled ? "disabled" : ""}
> >
${opt.label} ${localize ? localizer(opt.label) : opt.label}
</option>` </option>`
); );
}; };

View file

@ -64,13 +64,16 @@ export class PlayerSheetv2 extends GenericActorSheet {
selector. Disables all dice options that are selected, but not used selector. Disables all dice options that are selected, but not used
by this stat. by this stat.
*/ */
stat.dieOptions = DOTDUNGEON.statDice.map(die => { stat.dieOptions = [
{ label: `---`, value: `` },
...DOTDUNGEON.statDice.map(die => {
return { return {
value: die, value: die,
label: localizer(`dotdungeon.die.${die}`, { stat: statName }), label: localizer(`dotdungeon.die.${die}`, { stat: statName }),
disabled: usedDice.has(die) && this.actor.system.stats[statName] !== die, disabled: usedDice.has(die) && this.actor.system.stats[statName] !== die,
}; };
}); })
];
/* /*
Calculating the data needed in order to display all of the skills Calculating the data needed in order to display all of the skills
@ -81,10 +84,10 @@ export class PlayerSheetv2 extends GenericActorSheet {
const value = this.actor.system.skills[statName][skill]; const value = this.actor.system.skills[statName][skill];
stat.skills.push({ stat.skills.push({
key: skill, key: skill,
name: localizer(`dotdungeon.skills.${skill}`), name: game.i18n.format(`dotdungeon.skills.${skill}`),
value, value,
formula: `1` + stat.value + modifierToString(value), formula: `1` + stat.value + modifierToString(value, { spaces: true }),
rollDisabled: stat.value === `` || value === `locked`, rollDisabled: stat.value === `` || value === -1,
}); });
}; };

View file

@ -7,12 +7,12 @@
.stat { .stat {
border-radius: 8px; border-radius: 8px;
color: white;
select { select {
height: 100%; height: 100%;
outline: none; outline: none;
border: none; border: none;
text-align: center;
} }
&__header { &__header {
@ -22,9 +22,17 @@
flex-direction: row; flex-direction: row;
color: var(--stat-divider-text-color); color: var(--stat-divider-text-color);
gap: 8px; gap: 8px;
> :first-child { > h2 {
flex-grow: 1; flex-grow: 1;
color: var(--stat-header-text-color);
} }
.dice-select {
color: var(--stat-dice-select-text-color);
}
.roll-stat {
color: var(--stat-roll-button-text-color);
}
&:not(:only-child) { &:not(:only-child) {
border-bottom: 1px solid var(--stat-divider-color); border-bottom: 1px solid var(--stat-divider-color);
} }
@ -36,12 +44,23 @@
gap: 8px; gap: 8px;
margin: 8px; margin: 8px;
align-items: center; align-items: center;
label {
.skill {
&__label {
text-align: end; text-align: end;
justify-self: right; justify-self: right;
color: var(--skill-name-text-color);
} }
button { &__training {
color: var(--skill-training-select-text-color);
option {
background: var(--skill-training-select-bg);
}
}
&__roll {
margin-right: 25%; margin-right: 25%;
color: var(--skill-roll-button-text-color);
}
} }
} }
} }

View file

@ -5,7 +5,7 @@ $surface: #121212;
$primary: #005300; $primary: #005300;
$secondary: #6c056c; $secondary: #6c056c;
$on-background: $t; $on-background: $t;
$on-surface: $t; $on-surface: white;
$on-primary: $t; $on-primary: $t;
$on-secondary: $t; $on-secondary: $t;
@ -25,6 +25,12 @@ $on-secondary: $t;
--elevation-16dp-bg: color-mix(in lab, transparent, white 15%); --elevation-16dp-bg: color-mix(in lab, transparent, white 15%);
--elevation-24dp-bg: color-mix(in lab, transparent, white 16%); --elevation-24dp-bg: color-mix(in lab, transparent, white 16%);
--stat-header-text-color: #{$on-surface};
--stat-dice-select-text-color: #{$on-surface};
--stat-roll-button-text-color: #{$on-surface};
--stat-divider-color: #{$secondary}; --stat-divider-color: #{$secondary};
--stat-header-text-color: white; --skill-name-text-color: #{$on-surface};
--skill-training-select: #{$surface};
--skill-training-select-text-color: #{$on-surface};
--skill-roll-button-text-color: #{$on-surface};
} }

View file

@ -1,38 +1,44 @@
<div class="tab stats-panel" data-group="page" data-tab="stats"> <div class="tab stats-panel" data-group="page" data-tab="stats">
{{!--
Iterate over each stat in the display data
- header:
- localized stat name
- stat dice dropdown
- roll button
- body (if skills present):
- iterate over all of the skills
- localized skill name
- training dropdown
- roll button
--}}
{{#each computed.stats as | stat |}} {{#each computed.stats as | stat |}}
<div class="e-1dp stat"> <div class="e-1dp stat">
<div class="stat__header"> <div class="stat__header">
<h2>{{stat.name}}</h2> <h2>{{stat.name}}</h2>
<select <select
name="system.stats.{{stat.key}}" name="system.stats.{{stat.key}}"
class="e-2dp" class="e-2dp dice-select"
> >
{{{dd-options stat.value stat.dieOptions}}} {{{dd-options stat.value stat.dieOptions}}}
</select> </select>
<button type="button" class="e-2dp"> <button
type="button"
class="e-2dp roll-stat"
>
Roll Roll
</button> </button>
</div> </div>
{{#if stat.skills}} {{#if stat.skills}}
<div class="stat__skills"> <div class="stat__skills skill">
{{#each stat.skills as | skill |}} {{#each stat.skills as | skill |}}
<label for="">{{skill.name}}</label> <label
<select name="" id="" class="e-2dp"></select> for="{{meta.idp}}-{{skill.key}}-training"
class="skill__label"
>
{{skill.name}}
</label>
<select
name="system.skills.{{stat.key}}.{{skill.key}}"
id="{{meta.idp}}-{{skill.key}}-training"
class="e-2dp skill__training"
>
{{{dd-options
skill.value
@root.config.trainingLevels
localize=true
}}}
</select>
<button <button
type="button" type="button"
class="e-2dp" class="e-2dp skill__roll"
{{disabled skill.rollDisabled}} {{disabled skill.rollDisabled}}
> >
{{#if skill.rollDisabled}} {{#if skill.rollDisabled}}