Skip to content

Commit

Permalink
Merge pull request #267 from scottbenton/fix/planet-class
Browse files Browse the repository at this point in the history
fix(planets): Fixed planet class not being set properly
  • Loading branch information
scottbenton authored Oct 29, 2023
2 parents 2ca32d5 + c38252c commit 06cae5f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 2.1.0

### New Features

### Changes

### Accessibility

### Bug Fixes

- Fixed Planet Class not being properly set when creating new planets

## 2.0.0

### New Features
Expand Down
6 changes: 5 additions & 1 deletion src/components/features/worlds/SectorSection/OpenSector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ export function OpenSector(props: OpenSectorProps) {
`starforged/oracles/planets/${convertedClass}/sample_names`,
false
);
const planetClassName =
convertedClass.charAt(0).toUpperCase() +
convertedClass.slice(1) +
" World";

const description = convertedClass
? planetDescriptions[convertedClass] ?? ""
Expand All @@ -115,7 +119,7 @@ export function OpenSector(props: OpenSectorProps) {
name: name ?? "New Planet",
type: SECTOR_HEX_TYPES.PLANET,
subType: convertedClass,
planetClassName: planetClass,
planetClassName,
description,
});
} else if (hexType === SECTOR_HEX_TYPES.SETTLEMENT) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Alert, Grid, MenuItem, TextField } from "@mui/material";
import { Grid, MenuItem, TextField } from "@mui/material";
import { DebouncedOracleInput } from "components/shared/DebouncedOracleInput";
import { SectionHeading } from "components/shared/SectionHeading";
import { useStore } from "stores/store";
import { StarforgedLocationPlanet } from "types/LocationStarforged.type";
import { GMSectionHeader } from "../../GMSectionHeader";
Expand Down
6 changes: 5 additions & 1 deletion src/providers/DieRollProvider/DieRollProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ export function DieRollProvider(props: PropsWithChildren) {
const roll = getRoll(100);
const entry =
oracle.Table.find(
(entry) => (entry.Floor ?? 0) <= roll && roll <= (entry.Ceiling ?? 100)
(entry) =>
entry.Floor !== null &&
entry.Ceiling !== null &&
entry.Floor <= roll &&
roll <= entry.Ceiling
)?.Result ?? "Failed to get oracle entry.";

const oracleRoll: OracleTableRoll = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export function OracleDialogContent(props: OracleDialogContentProps) {
{table.map((entry, index) => {
const { Floor, Ceiling, Result } = entry;

if (Floor === null || Ceiling === null) {
return null;
}

const diff = (Ceiling ?? 100) - (Floor ?? 1);

return (
Expand Down

0 comments on commit 06cae5f

Please sign in to comment.