Fixed spell descriptions

This commit is contained in:
Benjamin Sherriff
2023-10-08 18:16:03 -04:00
parent 6c3d29d705
commit 09925251dd
12 changed files with 106 additions and 51 deletions

View File

@@ -61,14 +61,21 @@ export interface Source {
}
export interface Description {
entries: EntryType[];
// entries: EntryType[];
entries: Entry[];
}
type EntryType = string | Entry;
// type EntryType = string | Entry;
export interface Entry {
type: string;
items: string[];
text?: string;
list?: string[];
table?: EntryTable;
}
export interface EntryTable {
headers: string[];
rows: string[][];
}
export interface GetSpellResponse {

View File

@@ -4,6 +4,7 @@ import {
getGuilds,
getTextChannels,
getVoiceChannels,
getVolume,
pauseTrack,
playTrack,
resumeTrack,
@@ -22,6 +23,7 @@ export default function Page() {
const [activeGuild, setActiveGuild] = useState<GuildInfo | null>(null);
const [textChannels, setTextChannels] = useState<GuildChannel[]>([]);
const [voiceChannels, setVoiceChannels] = useState<GuildChannel[]>([]);
const [guildVolume, setGuildVolume] = useState<number>(50.0);
useEffect(() => {
getGuilds().then((g) => {
@@ -36,6 +38,7 @@ export default function Page() {
if (activeGuild) {
getTextChannels(activeGuild.id).then((c) => setTextChannels(c));
getVoiceChannels(activeGuild.id).then((c) => setVoiceChannels(c));
getVolume(activeGuild.id).then((v) => setGuildVolume(v));
}
}, [activeGuild]);
@@ -117,7 +120,7 @@ export default function Page() {
onSubmit={playForm.onSubmit((values) => setVolume(activeGuild!.id, values.volume))}
>
<Slider
defaultValue={50}
defaultValue={guildVolume}
{...playForm.getInputProps('volume')}
marks={[
{ value: 25, label: '25%' },

View File

@@ -129,23 +129,53 @@ function SpellDescription({ spell }: { spell: Spell }) {
<>
{spell.description && (
<>
{spell.description.entries.map((e) =>
typeof e === 'string' ? (
<p>{parseText(e)}</p>
) : (
<>
{e.type == 'list' ? (
<ul>
{e.items.map((text) => (
<li>{parseText(text)}</li>
{spell.description.entries.map((e) => (
// typeof e === 'string' ? (
// <p>{parseText(e)}</p>
// ) : (
// <>
// {e.list ? (
// <ul>
// {e.list.map((text) => (
// <li>{parseText(text)}</li>
// ))}
// </ul>
// ) : (
// <></>
// )}
// </>
// )
<>
{e.text && <p>{parseText(e.text)}</p>}
{e.list && (
<ul>
{e.list.map((text) => (
<li>{parseText(text)}</li>
))}
</ul>
)}
{e.table && (
<table>
<thead>
<tr>
{e.table.headers.map((label) => (
<th>{label}</th>
))}
</tr>
</thead>
<tbody>
{e.table.rows.map((row) => (
<tr>
{row.map((cell) => (
<td>{parseText(cell)}</td>
))}
</tr>
))}
</ul>
) : (
<></>
)}
</>
)
)}
</tbody>
</table>
)}
</>
))}
</>
)}
</>

View File

@@ -18,6 +18,5 @@ export function rollDice(dice: string): number[] {
for (let i = 0; i < parseInt(count); i++) {
rolls.push(Math.floor(Math.random() * parseInt(sides)) + 1);
}
console.log(rolls);
return rolls;
}