Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.11.4 Bugfixes & v2 Imports #647

Merged
merged 21 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
611b620
Bump requirejs from 2.3.6 to 2.3.7
dependabot[bot] Jul 26, 2024
c4a333a
Bump ws, socket.io-adapter, engine.io and engine.io-client
dependabot[bot] Jul 26, 2024
4e37edd
3.11.4
actions-user Jul 27, 2024
30d7174
Merge branch 'development' of https://github.com/cynicaloptimist/impr…
cynicaloptimist Aug 2, 2024
a8ed559
Display rendering error for a bad statblock
cynicaloptimist Aug 2, 2024
3eff99a
Use courier for statblock json editor
cynicaloptimist Aug 2, 2024
a762bbf
Red monospace JSON error
cynicaloptimist Aug 2, 2024
b4c3748
Use theme red
cynicaloptimist Aug 2, 2024
1dc8459
Use toString() for error
cynicaloptimist Aug 2, 2024
c326775
remove empty ruleset
cynicaloptimist Aug 2, 2024
a351090
rename locals
cynicaloptimist Aug 15, 2024
6002bff
use async/await for decompression
cynicaloptimist Aug 21, 2024
664600f
Accept v2 lz-string encoded import payloads
cynicaloptimist Aug 22, 2024
0aaeda8
Bump axios from 1.6.0 to 1.7.4
dependabot[bot] Aug 22, 2024
de450e3
Bump qs from 6.5.2 to 6.11.0
dependabot[bot] Aug 22, 2024
3bb7a98
Bump fast-xml-parser and @aws-sdk/credential-providers
dependabot[bot] Aug 22, 2024
009720e
Merge pull request #641 from cynicaloptimist/dependabot/npm_and_yarn/…
cynicaloptimist Aug 22, 2024
ce2544c
Merge pull request #642 from cynicaloptimist/dependabot/npm_and_yarn/…
cynicaloptimist Aug 22, 2024
0d0d1d8
Merge pull request #644 from cynicaloptimist/dependabot/npm_and_yarn/…
cynicaloptimist Aug 22, 2024
2463dea
Merge pull request #645 from cynicaloptimist/dependabot/npm_and_yarn/…
cynicaloptimist Aug 22, 2024
50c07c2
Merge pull request #646 from cynicaloptimist/dependabot/npm_and_yarn/…
cynicaloptimist Aug 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
362 changes: 187 additions & 175 deletions client/Components/StatBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,201 +19,213 @@ export function StatBlockComponent(props: StatBlockProps) {
const textEnricher = useContext(TextEnricherContext);
const statBlock = props.statBlock;

const modifierTypes = [
{ name: "Saves", data: statBlock.Saves },
{ name: "Skills", data: statBlock.Skills }
];

const keywordSetTypes = [
{ name: "Senses", data: statBlock.Senses },
{ name: "Damage Vulnerabilities", data: statBlock.DamageVulnerabilities },
{ name: "Damage Resistances", data: statBlock.DamageResistances },
{ name: "Damage Immunities", data: statBlock.DamageImmunities },
{ name: "Condition Immunities", data: statBlock.ConditionImmunities },
{ name: "Languages", data: statBlock.Languages }
];

const powerTypes = [
{ name: "Traits", data: statBlock.Traits },
{ name: "Actions", data: statBlock.Actions },
{ name: "Bonus Actions", data: statBlock.BonusActions },
{ name: "Reactions", data: statBlock.Reactions },
{ name: "Legendary Actions", data: statBlock.LegendaryActions },
{ name: "Mythic Actions", data: statBlock.MythicActions }
];

const headerEntries = (
<>
{props.hideName || (
<StatBlockHeader
name={statBlock.Name}
imageUrl={statBlock.ImageURL}
source={statBlock.Source}
type={statBlock.Type}
/>
)}

<hr />
</>
);

const statEntries = (
<>
<div className="AC">
<span className="stat-label">Armor Class</span>
<span className="stat-value">{statBlock.AC.Value}</span>
<span className="notes">
{textEnricher.EnrichText(statBlock.AC.Notes)}
</span>
</div>
try {
const modifierTypes = [
{ name: "Saves", data: statBlock.Saves },
{ name: "Skills", data: statBlock.Skills }
];

const keywordSetTypes = [
{ name: "Senses", data: statBlock.Senses },
{ name: "Damage Vulnerabilities", data: statBlock.DamageVulnerabilities },
{ name: "Damage Resistances", data: statBlock.DamageResistances },
{ name: "Damage Immunities", data: statBlock.DamageImmunities },
{ name: "Condition Immunities", data: statBlock.ConditionImmunities },
{ name: "Languages", data: statBlock.Languages }
];

const powerTypes = [
{ name: "Traits", data: statBlock.Traits },
{ name: "Actions", data: statBlock.Actions },
{ name: "Bonus Actions", data: statBlock.BonusActions },
{ name: "Reactions", data: statBlock.Reactions },
{ name: "Legendary Actions", data: statBlock.LegendaryActions },
{ name: "Mythic Actions", data: statBlock.MythicActions }
];

const headerEntries = (
<>
{props.hideName || (
<StatBlockHeader
name={statBlock.Name}
imageUrl={statBlock.ImageURL}
source={statBlock.Source}
type={statBlock.Type}
/>
)}

<div className="HP">
<span className="stat-label">Hit Points</span>
<span className="stat-value">{statBlock.HP.Value}</span>
<span className="notes">
{textEnricher.EnrichText(statBlock.HP.Notes)}
</span>
</div>
<hr />
</>
);

<div className="speed">
<span className="stat-label">Speed</span>
<span className="stat-value">
{statBlock.Speed.map((speed, i) => (
<span className="stat-value__item" key={"stat-value__speed-" + i}>
{speed}
</span>
))}
</span>
</div>
const statEntries = (
<>
<div className="AC">
<span className="stat-label">Armor Class</span>
<span className="stat-value">{statBlock.AC.Value}</span>
<span className="notes">
{textEnricher.EnrichText(statBlock.AC.Notes)}
</span>
</div>

<div className="HP">
<span className="stat-label">Hit Points</span>
<span className="stat-value">{statBlock.HP.Value}</span>
<span className="notes">
{textEnricher.EnrichText(statBlock.HP.Notes)}
</span>
</div>

<div className="Abilities">
{Object.keys(StatBlock.Default().Abilities).map(abilityName => {
const abilityScore = statBlock.Abilities[abilityName];
const abilityModifier =
textEnricher.GetEnrichedModifierFromAbilityScore(abilityScore);
return (
<div className="Ability" key={abilityName}>
<div className="stat-label">{abilityName}</div>
<span className={"score " + abilityName}>{abilityScore}</span>
<span className={"modifier " + abilityName}>
{abilityModifier}
<div className="speed">
<span className="stat-label">Speed</span>
<span className="stat-value">
{statBlock.Speed.map((speed, i) => (
<span className="stat-value__item" key={"stat-value__speed-" + i}>
{speed}
</span>
</div>
);
})}
</div>
))}
</span>
</div>

<hr />

<div className="modifiers">
{modifierTypes
.filter(modifierType => modifierType.data.length > 0)
.map(modifierType => (
<div key={modifierType.name} className={modifierType.name}>
<span className="stat-label">{modifierType.name}</span>
{modifierType.data.map((modifier, i) => (
<span className="stat-value" key={i + modifier.Name}>
{modifier.Name}
{textEnricher.EnrichModifier(modifier.Modifier)}{" "}
<div className="Abilities">
{Object.keys(StatBlock.Default().Abilities).map(abilityName => {
const abilityScore = statBlock.Abilities[abilityName];
const abilityModifier =
textEnricher.GetEnrichedModifierFromAbilityScore(abilityScore);
return (
<div className="Ability" key={abilityName}>
<div className="stat-label">{abilityName}</div>
<span className={"score " + abilityName}>{abilityScore}</span>
<span className={"modifier " + abilityName}>
{abilityModifier}
</span>
))}
</div>
))}
</div>
</div>
);
})}
</div>

<div className="keyword-sets">
{keywordSetTypes
.filter(keywordSetType => keywordSetType.data.length > 0)
.map(keywordSetType => (
<div key={keywordSetType.name} className={keywordSetType.name}>
<span className="stat-label">{keywordSetType.name}</span>
<span className="stat-value">
<span className="stat-value__item">
{keywordSetType.data.map((keyword, index) => {
return (
<span
className="stat-value__item"
key={`stat-value__${keywordSetType.name}-${index}`}
>
{keyword}
</span>
);
})}
</span>
</span>
</div>
))}
</div>
<hr />

{statBlock.Challenge && (
<div className="Challenge">
<span className="stat-label">
{statBlock.Player == "player" ? "Level" : "Challenge"}
</span>
<span className="stat-value">{statBlock.Challenge}</span>
<div className="modifiers">
{modifierTypes
.filter(modifierType => modifierType.data.length > 0)
.map(modifierType => (
<div key={modifierType.name} className={modifierType.name}>
<span className="stat-label">{modifierType.name}</span>
{modifierType.data.map((modifier, i) => (
<span className="stat-value" key={i + modifier.Name}>
{modifier.Name}
{textEnricher.EnrichModifier(modifier.Modifier)}{" "}
</span>
))}
</div>
))}
</div>
)}

<hr />
</>
);

const actionEntries = powerTypes
.filter(powerType => powerType?.data?.length > 0)
.map(powerType => (
<div key={powerType.name} className={powerType.name}>
<h4 className="stat-label">{powerType.name}</h4>
{powerType.data.map((power, j) => (
<div key={j + power.Name}>
{power.Name?.length ? (
<span className="stat-label">{power.Name}</span>
) : null}
{power.Usage && <span className="stat-label">{power.Usage}</span>}
<span className="power-content">
{textEnricher.EnrichText(power.Content)}

<div className="keyword-sets">
{keywordSetTypes
.filter(keywordSetType => keywordSetType.data.length > 0)
.map(keywordSetType => (
<div key={keywordSetType.name} className={keywordSetType.name}>
<span className="stat-label">{keywordSetType.name}</span>
<span className="stat-value">
<span className="stat-value__item">
{keywordSetType.data.map((keyword, index) => {
return (
<span
className="stat-value__item"
key={`stat-value__${keywordSetType.name}-${index}`}
>
{keyword}
</span>
);
})}
</span>
</span>
</div>
))}
</div>

{statBlock.Challenge && (
<div className="Challenge">
<span className="stat-label">
{statBlock.Player == "player" ? "Level" : "Challenge"}
</span>
<span className="stat-value">{statBlock.Challenge}</span>
</div>
))}
)}

<hr />
</div>
));
</>
);

const actionEntries = powerTypes
.filter(powerType => powerType?.data?.length > 0)
.map(powerType => (
<div key={powerType.name} className={powerType.name}>
<h4 className="stat-label">{powerType.name}</h4>
{powerType.data.map((power, j) => (
<div key={j + power.Name}>
{power.Name?.length ? (
<span className="stat-label">{power.Name}</span>
) : null}
{power.Usage && <span className="stat-label">{power.Usage}</span>}
<span className="power-content">
{textEnricher.EnrichText(power.Content)}
</span>
</div>
))}
<hr />
</div>
));

const description = statBlock.Description && (
<div className="Description">
{textEnricher.EnrichText(statBlock.Description)}
</div>
);
const description = statBlock.Description && (
<div className="Description">
{textEnricher.EnrichText(statBlock.Description)}
</div>
);

let innerEntries;
let innerEntries;

if (props.isLoading) {
if (props.isLoading) {
return (
<div className="c-statblock">
{headerEntries}
<LoadingIndicator />
</div>
);
}
if (props.displayMode == "active") {
innerEntries = (
<>
{actionEntries}
{statEntries}
</>
);
} else {
innerEntries = (
<>
{statEntries}
{actionEntries}
</>
);
}
return (
<div className="c-statblock">
{headerEntries}
<LoadingIndicator />
{innerEntries}
{description}
</div>
);
}
if (props.displayMode == "active") {
innerEntries = (
<>
{actionEntries}
{statEntries}
</>
);
} else {
innerEntries = (
<>
{statEntries}
{actionEntries}
</>
} catch (error) {
return (
<div className="c-statblock">
<div>
<p>There was a problem with this StatBlock:</p>
<pre className="c-statblock__error">{error.toString()}</pre>
<p>Please open it in the StatBlock Editor to check your JSON</p>
</div>
</div>
);
}
return (
<div className="c-statblock">
{headerEntries}
{innerEntries}
{description}
</div>
);
}
Loading
Loading