Skip to content

Commit

Permalink
feat(explore): add holiday zones that are only active during specific…
Browse files Browse the repository at this point in the history
… months. closes #208
  • Loading branch information
seiyria committed Sep 24, 2023
1 parent bc60576 commit e31cc16
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
42 changes: 42 additions & 0 deletions server/src/modules/aggregator/aggregator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,48 @@ export class AggregatorService {
}
}),
);

this.assessLocations(user);
}

private assessLocations(user: IFullUser): void {
const allLocations = this.contentService.allLocations();
allLocations.forEach((location) => {
if (!location.limited) return;

const { activeMonth } = location.limited;

const currentMonth = new Date().getMonth() + 1;

let shouldDiscover = false;

if (activeMonth) {
shouldDiscover = activeMonth === currentMonth;
}

if (shouldDiscover) {
this.discoveriesService.discoverLocation(
user.discoveries,
location.name,
);
}

if (!shouldDiscover) {
if (user.player.location.current === location.name) {
user.player.location = {
...user.player.location,
current: 'Mork',
goingTo: '',
arrivesAt: 0,
};
}

this.discoveriesService.undiscoverLocation(
user.discoveries,
location.name,
);
}
});
}

@OnEvent('player.gaincoins')
Expand Down
6 changes: 6 additions & 0 deletions server/src/modules/discoveries/discoveries.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ export class DiscoveriesService {
return true;
}

undiscoverLocation(discoveries: Discoveries, locationName: string): boolean {
discoveries.locations = { ...discoveries.locations, [locationName]: false };
this.syncDiscoveriesForLeaderboard(discoveries);
return true;
}

async discoverCollectible(
userId: string,
instanceId: string,
Expand Down
5 changes: 5 additions & 0 deletions shared/interfaces/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export interface ILocationConnection {
name: string;
}

export interface ILocationLimitedAccess {
activeMonth: number;
}

export interface ILocation {
name: string;
description: string;
Expand All @@ -49,6 +53,7 @@ export interface ILocation {
baseStats: Record<LocationStat, number>;
connections: ILocationConnection[];
npcs: Array<{ name: string }>;
limited?: ILocationLimitedAccess;
}

export interface ILocationNPC {
Expand Down

0 comments on commit e31cc16

Please sign in to comment.