Skip to content

Commit

Permalink
Merge pull request #444 from scottbenton/feat/add-scene-challenges
Browse files Browse the repository at this point in the history
feat(scene challenges): Added scene challenges
  • Loading branch information
scottbenton authored May 25, 2024
2 parents aefa331 + e5510b9 commit 5610ab6
Show file tree
Hide file tree
Showing 25 changed files with 369 additions and 265 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@

- Added a match reminder to the roll display for oracle rolls that care about dice matching (ask the oracle moves)
- Added asset clock and counter controls working for assets that use them (ex: Snub Fighter Ability #3, or Marked Ability #2).
- Added scene challenges to Crew Link

### Changes

- Re-added missing roll buttons for assets in the move dialog
- Made tensions clocks available in Iron Fellowship

### Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion src/api-calls/tracks/_getRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function convertToDatabase(track: Track): TrackDocument {
return {
...rest,
createdTimestamp: Timestamp.fromDate(createdDate),
};
} as TrackDocument;
}

export function convertFromDatabase(track: TrackDocument): Track {
Expand Down
7 changes: 6 additions & 1 deletion src/api-calls/tracks/_track.type.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Timestamp } from "firebase/firestore";
import { Clock, ProgressTrack } from "types/Track.type";
import { Clock, ProgressTrack, SceneChallenge } from "types/Track.type";

export interface ProgressTrackDocument
extends Omit<ProgressTrack, "createdDate"> {
Expand All @@ -9,4 +9,9 @@ export interface ClockDocument extends Omit<Clock, "createdDate"> {
createdTimestamp: Timestamp;
}

export interface SceneChallengeDocument
extends Omit<SceneChallenge, "createdDate"> {
createdTimestamp: Timestamp;
}

export type TrackDocument = ProgressTrackDocument | ClockDocument;
15 changes: 3 additions & 12 deletions src/api-calls/tracks/listenToProgressTracks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ import {
getCampaignTracksCollection,
getCharacterTracksCollection,
} from "./_getRef";
import { Track, TrackTypes } from "types/Track.type";
import { Track, TrackSectionTracks } from "types/Track.type";

export function listenToProgressTracks(
campaignId: string | undefined,
characterId: string | undefined,
status: string,
addOrUpdateTracks: (tracks: { [trackId: string]: Track }) => void,
removeTrack: (
trackId: string,
trackType: TrackTypes.Fray | TrackTypes.Journey | TrackTypes.Vow
) => void,
removeTrack: (trackId: string, trackType: TrackSectionTracks) => void,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onError: (error: any) => void
): Unsubscribe | undefined {
Expand All @@ -36,13 +33,7 @@ export function listenToProgressTracks(

snapshot.docChanges().forEach((change) => {
if (change.type === "removed") {
removeTrack(
change.doc.id,
change.doc.data().type as
| TrackTypes.Fray
| TrackTypes.Journey
| TrackTypes.Vow
);
removeTrack(change.doc.id, change.doc.data().type);
} else {
addOrUpdateChanges[change.doc.id] = convertFromDatabase(
change.doc.data()
Expand Down
43 changes: 30 additions & 13 deletions src/components/features/ProgressTrack/EditOrCreateTrackDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ import {
Difficulty,
TrackStatus,
TrackSectionProgressTracks,
TrackTypes,
SceneChallenge,
} from "types/Track.type";

export interface EditOrCreateTrackDialogProps {
open: boolean;
handleClose: () => void;
initialTrack?: ProgressTrack;
trackType: TrackSectionProgressTracks;
initialTrack?: ProgressTrack | SceneChallenge;
trackType: TrackSectionProgressTracks | TrackTypes.SceneChallenge;
trackTypeName: string;
handleTrack: (track: ProgressTrack) => Promise<boolean | void>;
handleTrack: (
track: ProgressTrack | SceneChallenge
) => Promise<boolean | void>;
}

export function EditOrCreateTrackDialog(props: EditOrCreateTrackDialogProps) {
Expand Down Expand Up @@ -69,16 +73,29 @@ export function EditOrCreateTrackDialog(props: EditOrCreateTrackDialogProps) {
return;
}

const track: ProgressTrack = {
createdDate: new Date(),
status: TrackStatus.Active,
type: trackType,
...(initialTrack ?? {}),
label: title,
description,
difficulty: difficulty,
value: initialTrack && !resetProgress ? initialTrack.value : 0,
};
const track: ProgressTrack | SceneChallenge =
trackType === TrackTypes.SceneChallenge
? {
createdDate: new Date(),
status: TrackStatus.Active,
type: trackType,
...((initialTrack as SceneChallenge | undefined) ?? {}),
label: title,
description,
difficulty: difficulty,
value: initialTrack && !resetProgress ? initialTrack.value : 0,
segmentsFilled: 0,
}
: {
createdDate: new Date(),
status: TrackStatus.Active,
type: trackType,
...((initialTrack as ProgressTrack | undefined) ?? {}),
label: title,
description,
difficulty: difficulty,
value: initialTrack && !resetProgress ? initialTrack.value : 0,
};

setLoading(true);
handleTrack(track)
Expand Down
Loading

0 comments on commit 5610ab6

Please sign in to comment.