Skip to content

Commit

Permalink
battles: reimagined boss battles, reward loot on strike, better ui
Browse files Browse the repository at this point in the history
  • Loading branch information
GGonryun committed Aug 15, 2024
1 parent c7c4bd8 commit aa37106
Show file tree
Hide file tree
Showing 108 changed files with 2,919 additions and 2,308 deletions.
93 changes: 0 additions & 93 deletions apps/charity/pages/api/cron/find-expired-battles.ts

This file was deleted.

8 changes: 7 additions & 1 deletion apps/charity/pages/api/cron/spawn-raffle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ const prizes = {
numWinners: [5, 7, 10],
imageUrl: undefined,
},
'1000': {
itemId: '1000',
premium: false,
numWinners: [5, 10],
imageUrl: undefined,
},
'4': {
itemId: '4',
premium: true,
Expand Down Expand Up @@ -98,7 +104,7 @@ const generateRaffle = (): Prisma.RaffleUncheckedCreateInput => {

const maxEntries = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100];

const dropChance: PrizeId[] = ['5', '5', '8', '4', '4', '4', '4', '4'];
const dropChance: PrizeId[] = ['5', '8', '1000', '4', '4', '4', '4'];

const prizeId = randomArrayElement(dropChance);
const prize = prizes[prizeId];
Expand Down
34 changes: 32 additions & 2 deletions apps/charity/pages/api/jobs/[...path].tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { TRPCError } from '@trpc/server';
import { prisma } from '@worksheets/prisma';
import { routes } from '@worksheets/routes';
import { MobsService } from '@worksheets/services/mobs';
import { NotificationsService } from '@worksheets/services/notifications';
import { TasksService } from '@worksheets/services/tasks';
import { createBackgroundJob } from '@worksheets/util/jobs';
import { retryTransaction } from '@worksheets/util/prisma';

export default createBackgroundJob(async (path, body) => {
export default createBackgroundJob(async (path, body, _req, res) => {
console.info('Executing job', path, body);

const job = path.join('/');
Expand Down Expand Up @@ -39,8 +43,34 @@ export default createBackgroundJob(async (path, body) => {
return true;
} else if (job === 'leaderboard/score') {
const tasks = new TasksService(prisma);

await tasks.trackLeaderboardAction(body);
} else if (job === 'battle/completed') {
const { mvp, battle, loot, spawned } = await retryTransaction(
prisma,
async (tx) => {
const mobs = new MobsService(tx);
return mobs.processCompletedBattle(body.battleId);
}
);
const notifications = new NotificationsService(prisma);
await notifications.send('battle-mvp-awarded', {
userId: mvp.participant.user.id,
battle,
loot,
});
await notifications.send('battle-completed', {
userIds: battle.participation
.map((p) => p.user.id)
.filter((id) => id !== mvp.participant.user.id),
battle,
});
await res.revalidate(
routes.battle.path({
params: {
battleId: spawned.battleId,
},
})
);
} else {
throw new TRPCError({
code: 'NOT_FOUND',
Expand Down
7 changes: 2 additions & 5 deletions apps/charity/pages/help/accounts.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { helpAccounts } from '@worksheets/ui/components/help';
import { AppLayoutContainer } from '@worksheets/ui/layout';
import {
helpAccounts,
helpPageJson,
HelpScreen,
} from '@worksheets/ui/pages/help';
import { helpPageJson, HelpScreen } from '@worksheets/ui/pages/help';
import { NextPageWithLayout } from '@worksheets/util-next';
import { FAQPageJsonLd, NextSeo } from 'next-seo';

Expand Down
7 changes: 2 additions & 5 deletions apps/charity/pages/help/contributions.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { helpContributions } from '@worksheets/ui/components/help';
import { AppLayoutContainer } from '@worksheets/ui/layout';
import {
helpContributions,
helpPageJson,
HelpScreen,
} from '@worksheets/ui/pages/help';
import { helpPageJson, HelpScreen } from '@worksheets/ui/pages/help';
import { NextPageWithLayout } from '@worksheets/util-next';
import { FAQPageJsonLd, NextSeo } from 'next-seo';

Expand Down
7 changes: 2 additions & 5 deletions apps/charity/pages/help/emails.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { helpEmails } from '@worksheets/ui/components/help';
import { AppLayoutContainer } from '@worksheets/ui/layout';
import {
helpEmails,
helpPageJson,
HelpScreen,
} from '@worksheets/ui/pages/help';
import { helpPageJson, HelpScreen } from '@worksheets/ui/pages/help';
import { NextPageWithLayout } from '@worksheets/util-next';
import { FAQPageJsonLd, NextSeo } from 'next-seo';

Expand Down
7 changes: 2 additions & 5 deletions apps/charity/pages/help/friends.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { helpFriends } from '@worksheets/ui/components/help';
import { AppLayoutContainer } from '@worksheets/ui/layout';
import {
helpFriends,
helpPageJson,
HelpScreen,
} from '@worksheets/ui/pages/help';
import { helpPageJson, HelpScreen } from '@worksheets/ui/pages/help';
import { NextPageWithLayout } from '@worksheets/util-next';
import { FAQPageJsonLd, NextSeo } from 'next-seo';

Expand Down
7 changes: 2 additions & 5 deletions apps/charity/pages/help/integrations.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { helpIntegrations } from '@worksheets/ui/components/help';
import { AppLayoutContainer } from '@worksheets/ui/layout';
import {
helpIntegrations,
helpPageJson,
HelpScreen,
} from '@worksheets/ui/pages/help';
import { helpPageJson, HelpScreen } from '@worksheets/ui/pages/help';
import { NextPageWithLayout } from '@worksheets/util-next';
import { FAQPageJsonLd, NextSeo } from 'next-seo';

Expand Down
7 changes: 2 additions & 5 deletions apps/charity/pages/help/inventory.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { helpInventory } from '@worksheets/ui/components/help';
import { AppLayoutContainer } from '@worksheets/ui/layout';
import {
helpInventory,
helpPageJson,
HelpScreen,
} from '@worksheets/ui/pages/help';
import { helpPageJson, HelpScreen } from '@worksheets/ui/pages/help';
import { NextPageWithLayout } from '@worksheets/util-next';
import { FAQPageJsonLd, NextSeo } from 'next-seo';

Expand Down
3 changes: 2 additions & 1 deletion apps/charity/pages/help/mobs.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { helpMobs } from '@worksheets/ui/components/help';
import { AppLayoutContainer } from '@worksheets/ui/layout';
import { helpMobs, helpPageJson, HelpScreen } from '@worksheets/ui/pages/help';
import { helpPageJson, HelpScreen } from '@worksheets/ui/pages/help';
import { NextPageWithLayout } from '@worksheets/util-next';
import { FAQPageJsonLd, NextSeo } from 'next-seo';

Expand Down
7 changes: 2 additions & 5 deletions apps/charity/pages/help/notifications.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { helpNotifications } from '@worksheets/ui/components/help';
import { AppLayoutContainer } from '@worksheets/ui/layout';
import {
helpNotifications,
helpPageJson,
HelpScreen,
} from '@worksheets/ui/pages/help';
import { helpPageJson, HelpScreen } from '@worksheets/ui/pages/help';
import { NextPageWithLayout } from '@worksheets/util-next';
import { FAQPageJsonLd, NextSeo } from 'next-seo';

Expand Down
7 changes: 2 additions & 5 deletions apps/charity/pages/help/playing-games.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { helpPlayingGames } from '@worksheets/ui/components/help';
import { AppLayoutContainer } from '@worksheets/ui/layout';
import {
helpPageJson,
helpPlayingGames,
HelpScreen,
} from '@worksheets/ui/pages/help';
import { helpPageJson, HelpScreen } from '@worksheets/ui/pages/help';
import { NextPageWithLayout } from '@worksheets/util-next';
import { FAQPageJsonLd, NextSeo } from 'next-seo';

Expand Down
7 changes: 2 additions & 5 deletions apps/charity/pages/help/prizes.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { helpPrizes } from '@worksheets/ui/components/help';
import { AppLayoutContainer } from '@worksheets/ui/layout';
import {
helpPageJson,
helpPrizes,
HelpScreen,
} from '@worksheets/ui/pages/help';
import { helpPageJson, HelpScreen } from '@worksheets/ui/pages/help';
import { NextPageWithLayout } from '@worksheets/util-next';
import { FAQPageJsonLd, NextSeo } from 'next-seo';

Expand Down
7 changes: 2 additions & 5 deletions apps/charity/pages/help/quests.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { helpQuests } from '@worksheets/ui/components/help';
import { AppLayoutContainer } from '@worksheets/ui/layout';
import {
helpPageJson,
helpQuests,
HelpScreen,
} from '@worksheets/ui/pages/help';
import { helpPageJson, HelpScreen } from '@worksheets/ui/pages/help';
import { NextPageWithLayout } from '@worksheets/util-next';
import { FAQPageJsonLd, NextSeo } from 'next-seo';

Expand Down
7 changes: 2 additions & 5 deletions apps/charity/pages/help/referrals.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { helpReferrals } from '@worksheets/ui/components/help';
import { AppLayoutContainer } from '@worksheets/ui/layout';
import {
helpPageJson,
helpReferrals,
HelpScreen,
} from '@worksheets/ui/pages/help';
import { helpPageJson, HelpScreen } from '@worksheets/ui/pages/help';
import { NextPageWithLayout } from '@worksheets/util-next';
import { FAQPageJsonLd, NextSeo } from 'next-seo';

Expand Down
7 changes: 2 additions & 5 deletions apps/charity/pages/help/tokens.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { helpTokens } from '@worksheets/ui/components/help';
import { AppLayoutContainer } from '@worksheets/ui/layout';
import {
helpPageJson,
HelpScreen,
helpTokens,
} from '@worksheets/ui/pages/help';
import { helpPageJson, HelpScreen } from '@worksheets/ui/pages/help';
import { NextPageWithLayout } from '@worksheets/util-next';
import { FAQPageJsonLd, NextSeo } from 'next-seo';

Expand Down
3 changes: 2 additions & 1 deletion apps/charity/pages/help/vip.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { helpVip } from '@worksheets/ui/components/help';
import { AppLayoutContainer } from '@worksheets/ui/layout';
import { helpPageJson, HelpScreen, helpVip } from '@worksheets/ui/pages/help';
import { helpPageJson, HelpScreen } from '@worksheets/ui/pages/help';
import { NextPageWithLayout } from '@worksheets/util-next';
import { FAQPageJsonLd, NextSeo } from 'next-seo';

Expand Down
Loading

0 comments on commit aa37106

Please sign in to comment.