import * as React from "react";
import { ICharacter } from "../../interfaces/i-character";
import { ISpellSlot } from "../../interfaces/i-spell-slot";
import { IGenericItem } from "../../interfaces/i-generic-item";
import { IClass } from "../../interfaces/i-class";
import { IProficiencyInfo } from "../../interfaces/i-proficiency-info";
import { ISpellCollection } from "../../interfaces/i-spell-collection";
export const CharacterSheet = ({
ac,
armorProficiencies,
abilities,
actions,
background,
bonusActions,
classes,
description,
hp,
image,
initiative,
features,
languages,
passiveInsight,
passiveInvestigation,
passivePerception,
proficiencyBonus,
race,
reactions,
savingThrows,
senses,
speed,
spells,
spellSlots,
stats,
toolProficiencies,
weaponProficiencies
}: ICharacter) => {
const getProficiencyString = (
proficiencyInfo: IProficiencyInfo
): string => {
if (proficiencyInfo.hasExpertise) {
return "E";
}
if (proficiencyInfo.hasProficiency) {
return "P";
}
if (proficiencyInfo.hasOther) {
return "H";
}
return "/";
};
const getCharacterLevel = () => {
return (
{classes
.map((item: IClass) => {
return `${item.name} ${item.level}`;
})
.join(" / ")}
);
};
const getCharacterTraitList = (collection: string[]) => {
return (
{collection.map((item: string, index: number) => {
return - {item}
;
})}
);
};
const getGenericItemsMarkup = (collection: IGenericItem[]) => {
return collection.map((item: IGenericItem, index: number) => {
return (
{item.title}:
{item.description}
);
});
};
const getSpells = () => {
return spells.map(
(spellCollection: ISpellCollection, index: number) => {
return (
Level: {spellCollection.level}
{spellCollection.list.map(
(item: string, index: number) => {
return - {item}
;
}
)}
);
}
);
};
const hasSpellSlots = () => {
if (spellSlots.length <= 0) {
return false;
}
const count = spellSlots
.map((slot: ISpellSlot) => {
return slot.count;
})
.reduce(
(a: number, b: number): number => {
return a + b;
}
);
return count > 0;
};
const getSpellSlots = () => {
return (
hasSpellSlots() && (
{spellSlots
.filter((item: ISpellSlot) => {
return item.count > 0;
})
.map((item: ISpellSlot, index: number) => {
return (
-
Level {item.level}:
{item.count}
);
})}
)
);
};
const getSkillRow = (key: string) => {
return (
| {getProficiencyString(abilities[key].proficiencyInfo)} |
{abilities[key].type} |
{abilities[key].name} |
{abilities[key].modifier} |
);
};
return (
Character Name
{getCharacterLevel()}
Race:
{race}
Background:
{background}
Alignment:
{description.alignment}
Faith:
{description.faith}
Gender:
{description.gender}
Age:
{description.age}
Size:
{description.size}
Height:
{description.height}
Weight:
{description.weight}
Skin:
{description.eyes}
Eyes:
{description.eyes}
Hair:
{description.hair}
Stats
| Current Hp |
Temp Hp |
Max Hp |
Prof |
Init |
AC |
| {hp.currentHp} |
{hp.tempHp} |
{hp.maxHp} |
{proficiencyBonus} |
{initiative} |
{ac} |
Proficiencies and Languages
Armor
{getCharacterTraitList(armorProficiencies)}
Weapons
{getCharacterTraitList(weaponProficiencies)}
Tools
{getCharacterTraitList(toolProficiencies)}
Languages
{getCharacterTraitList(languages)}
Speed
{getGenericItemsMarkup(speed)}
Senses
{passivePerception.name} ({passivePerception.type}):{" "}
{passivePerception.value}
{passiveInsight.name} ({passiveInsight.type}):{" "}
{passiveInsight.value}
{passiveInvestigation.name} ({passiveInvestigation.type}):{" "}
{passiveInvestigation.value}
{getGenericItemsMarkup(senses)}
Stats
| STR |
DEX |
CON |
INT |
WIS |
CHA |
| {stats.str.score} |
{stats.dex.score} |
{stats.con.score} |
{stats.int.score} |
{stats.wis.score} |
{stats.cha.score} |
| {stats.str.modifier} |
{stats.dex.modifier} |
{stats.con.modifier} |
{stats.int.modifier} |
{stats.wis.modifier} |
{stats.cha.modifier} |
Saving Throws
| STR |
DEX |
CON |
INT |
WIS |
CHA |
| {savingThrows.str.modifier} |
{savingThrows.dex.modifier} |
{savingThrows.con.modifier} |
{savingThrows.int.modifier} |
{savingThrows.wis.modifier} |
{savingThrows.cha.modifier} |
Abilities
| Prof |
Mod |
Skill |
Bonus |
{getSkillRow("acrobatics")}
{getSkillRow("animalHandling")}
{getSkillRow("arcana")}
{getSkillRow("athletics")}
{getSkillRow("deception")}
{getSkillRow("history")}
{getSkillRow("insight")}
{getSkillRow("intimidation")}
{getSkillRow("investigation")}
{getSkillRow("medicine")}
{getSkillRow("nature")}
{getSkillRow("perception")}
{getSkillRow("performance")}
{getSkillRow("persuasion")}
{getSkillRow("religion")}
{getSkillRow("slightOfHand")}
{getSkillRow("stealth")}
{getSkillRow("survival")}
Actions
{getGenericItemsMarkup(actions)}
Bonus Actions
{getGenericItemsMarkup(bonusActions)}
Reactions
{getGenericItemsMarkup(reactions)}
Features
{getGenericItemsMarkup(features)}
Spells
Spell Slots
{getSpellSlots()}
List
{getSpells()}
Description
Personality Traits
{getCharacterTraitList(description.personalityTraits)}
Ideals
{getCharacterTraitList(description.ideals)}
Bonds
{getCharacterTraitList(description.bonds)}
Flaws
{getCharacterTraitList(description.flaws)}
Alies and Organizations
{description.notes}
Appearance
{description.appearance}
Notes
{description.notes}
);
};