Skip to content

Commit

Permalink
Merge pull request #480 from scottbenton/feat/add-world-type-upon-cre…
Browse files Browse the repository at this point in the history
…ation

feat(world type): Add world type upon creation
  • Loading branch information
scottbenton authored Jun 28, 2024
2 parents 59d863b + c9cdabc commit acd035a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
9 changes: 3 additions & 6 deletions src/api-calls/world/_world.type.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { Bytes } from "firebase/firestore";

export interface WorldDocument {
name: string;
export interface WorldDocument extends Omit<World, "worldDescription"> {
worldDescription?: Bytes;
newTruths?: Record<string, Truth>;
ownerIds: string[];
campaignGuides?: string[];
}

export interface World {
settingKey: string;
name: string;
worldDescription?: Uint8Array;
newTruths?: Record<string, Truth>;
ownerIds: string[];
worldDescription?: Uint8Array;
campaignGuides?: string[];
}

Expand Down
11 changes: 10 additions & 1 deletion src/stores/world/world.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { createWorld } from "api-calls/world/createWorld";
import { createCurrentWorldSlice } from "./currentWorld/currentWorld.slice";
import { deleteWorld } from "api-calls/world/deleteWorld";
import { updateWorldGuide } from "api-calls/world/updateWorldGuide";
import { getSystem } from "hooks/useGameSystem";
import { GAME_SYSTEMS } from "types/GameSystems.type";

export const createWorldSlice: CreateSliceType<WorldSlice> = (...params) => {
const [set, getState] = params;
Expand Down Expand Up @@ -86,7 +88,14 @@ export const createWorldSlice: CreateSliceType<WorldSlice> = (...params) => {
},
createWorld: () => {
const uid = getState().auth.uid;
return createWorld({ name: "New World", ownerIds: [uid] });
const system = getSystem();
const defaultSettingKey =
system === GAME_SYSTEMS.IRONSWORN ? "ironlands" : "the_forge";
return createWorld({
name: "New World",
ownerIds: [uid],
settingKey: defaultSettingKey,
});
},
deleteWorld: (worldId) => {
return deleteWorld(worldId);
Expand Down

0 comments on commit acd035a

Please sign in to comment.