Skip to content

Commit

Permalink
Merge pull request #221 from gvorbeck/refactor-selector
Browse files Browse the repository at this point in the history
Refactor selector
  • Loading branch information
gvorbeck authored Jan 20, 2024
2 parents 7aec658 + b0b0972 commit 5408169
Show file tree
Hide file tree
Showing 22 changed files with 659 additions and 210 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"bfrpgEdition": "4th",
"bfrpgRelease": "137",
"license": "CC BY-SA 4.0",
"version": "2.0.0.0",
"version": "2.0.1",
"private": true,
"type": "module",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/components/CardCharacter/CardCharacter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useNavigate } from "react-router-dom";
import { User } from "firebase/auth";
import { avatarClassNames } from "@/support/cssSupport";
import { deleteDocument } from "@/support/accountSupport";
import { classSplit } from "@/support/classSupport";

interface CardCharacterProps {
item: CharData;
Expand Down Expand Up @@ -49,7 +50,7 @@ const CardCharacter: React.FC<
const descriptionItems: DescriptionsProps["items"] = [
{ key: "1", label: "Level", children: item.level },
{ key: "2", label: "Race", children: item.race },
{ key: "3", label: "Class", children: item.class },
{ key: "3", label: "Class", children: classSplit(item.class).join(" | ") },
];
return (
item &&
Expand Down
1 change: 1 addition & 0 deletions src/components/ModalLevelUp/ModalLevelUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const ModalLevelUp: React.FC<
React.useEffect(() => {
// Set magicClass when character changes
const classArr = classSplit(character.class);
// NOTE: do this with some() instead:
for (const cls of classArr) {
const key = cls as keyof typeof classes;
if (classes[key]?.spellBudget) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ const SpellOptionsContainer: React.FC<
<div className={className}>
{spellBudget.map((max, index) => {
const spellLevel = index + 1;
const spellsAtLevel = getSpellsAtLevel(character).filter(
const spellsAtLevel = getSpellsAtLevel(
character.class,
character.level,
).filter(
(spell) => spell.level[magicClass.toLowerCase()] === spellLevel,
);
return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/PageCharacterSheet/PageCharacterSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const PageCharacterSheet: React.FC<
const abilitiesTableHelpText = useMarkdown(
`A player must roll their percentile dice with a result less than or equal to the numbers shown below. Click the rows to automatically roll for each special ability.`,
);
const customClassAlertMessage = useMarkdown(customClassString);
const customClassAlertMessage = customClassString;
const { isMobile, isTablet, isDesktop } = useDeviceType();
const { isSpellCaster } = useSpellData();
const classArr = character ? classSplit(character.class) : [];
Expand Down
9 changes: 7 additions & 2 deletions src/components/PageNewCharacter/PageNewCharacter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ const PageNewCharacter: React.FC<
xp: 0,
} as CharData);
const [comboClass, setComboClass] = React.useState(false);
const [comboClassSwitch, setComboClassSwitch] = React.useState(false);
const [comboClassSwitch, setComboClassSwitch] = React.useState(
character.class?.length > 1,
);
const [messageApi, contextHolder] = message.useMessage();
// VARS
const next = () => setCurrentStep(currentStep + 1);
const next = () => {
console.log(character);
setCurrentStep(currentStep + 1);
};
const prev = () => setCurrentStep(currentStep - 1);
const stepsItems = getStepsItems(
character,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ const StepAbilities: React.FC<
return (
<Flex vertical className={className} gap={16}>
{!hideRollAll && (
<Button type="primary" onClick={rollAllAbilities}>
<Button
type="primary"
onClick={rollAllAbilities}
className="self-start"
>
Roll All Abilities
</Button>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const SpellOptions: React.FC<
const selectedSpell =
spells.find((spell: Spell) => spell.name === startingSpells[0]) ||
({ description: "", duration: "", range: "" } as Spell);
const levelOneSpells = getSpellsAtLevel(character);
const levelOneSpells = getSpellsAtLevel(character.class, character.level);
const spellImage = getSpellImage(toSlugCase(startingSpells[0] || ""));
const descriptionClassNames = classNames({ "flex-col": isMobile });
const selectOptions: SelectProps["options"] = levelOneSpells
Expand Down
Loading

0 comments on commit 5408169

Please sign in to comment.