diff --git a/libs/data/quests/src/index.ts b/libs/data/quests/src/index.ts index 8ffa24d5..34ab3cb1 100644 --- a/libs/data/quests/src/index.ts +++ b/libs/data/quests/src/index.ts @@ -1,8 +1,5 @@ import { Prisma } from '@worksheets/prisma'; -import { - PER_GAME_PLAY_REWARD, - TOKENS_PER_REFERRAL_ACCOUNT, -} from '@worksheets/util/settings'; +import { TOKENS_PER_REFERRAL_ACCOUNT } from '@worksheets/util/settings'; export const QUESTS: Prisma.PlatformQuestUncheckedCreateInput[] = [ // prize wheels @@ -373,23 +370,6 @@ export const QUESTS: Prisma.PlatformQuestUncheckedCreateInput[] = [ taskId: 'PLAY_MINUTES_INFINITE', loot: {}, }, - { - id: 'PLAY_GAME_INFINITE', - order: 1001, - version: 0, - taskId: 'PLAY_GAME_INFINITE', - loot: { - createMany: { - data: [ - { - itemId: '1', - quantity: PER_GAME_PLAY_REWARD, - chance: 1, - }, - ], - }, - }, - }, { id: 'ADD_FRIEND_INFINITE', order: 1002, diff --git a/libs/ui/components/help/src/lib/help-tokens.tsx b/libs/ui/components/help/src/lib/help-tokens.tsx index 1bd0fcbb..e86bf65f 100644 --- a/libs/ui/components/help/src/lib/help-tokens.tsx +++ b/libs/ui/components/help/src/lib/help-tokens.tsx @@ -7,7 +7,6 @@ import { } from '@worksheets/util/enums'; import { toPercentage } from '@worksheets/util/numbers'; import { - PER_GAME_PLAY_REWARD, PLAY_MINUTE_DROP_CHANCE, TOKENS_PER_REFERRAL_ACCOUNT, } from '@worksheets/util/settings'; @@ -63,7 +62,7 @@ export const helpTokens: QuestionAnswer[] = [ Playing Games - - Earn a minimum of {PER_GAME_PLAY_REWARD} token per game and a{' '} + Earn tokens when you play games and a{' '} {toPercentage(PLAY_MINUTE_DROP_CHANCE)} chance to earn a random item every minute you play. diff --git a/libs/ui/pages/game/src/lib/containers/game-screen-container.tsx b/libs/ui/pages/game/src/lib/containers/game-screen-container.tsx index bab532c4..0911cb19 100644 --- a/libs/ui/pages/game/src/lib/containers/game-screen-container.tsx +++ b/libs/ui/pages/game/src/lib/containers/game-screen-container.tsx @@ -19,7 +19,10 @@ import { ReportIssueModal, ShareGameModal, } from '../components'; -import { GameNotificationContextProvider } from '../hooks/use-game-notifications'; +import { + GameNotificationContextProvider, + useGameNotifications, +} from '../hooks/use-game-notifications'; type GameScreenContainerProps = { game: SerializableGameSchema; @@ -52,7 +55,7 @@ const GameScreenContainerInner: React.FC = ({ const session = useSession(); const authenticated = session.status === 'authenticated'; - // const notifications = useGameNotifications(); + const notifications = useGameNotifications(); const [showShare, setShowShare] = useState(false); const [showReport, setShowReport] = useState(false); @@ -63,7 +66,7 @@ const GameScreenContainerInner: React.FC = ({ const record = trpc.maybe.games.record.useMutation(); const reportGame = trpc.public.games.report.useMutation(); - // const trackGamePlay = trpc.user.gamePlay.track.useMutation(); + const trackGamePlay = trpc.user.gamePlay.track.useMutation(); const { data: suggestions } = trpc.public.games.suggestions.useQuery( { @@ -76,19 +79,19 @@ const GameScreenContainerInner: React.FC = ({ const [showVoteWarning, setShowVoteWarning] = useState(false); - // const handleRewardPlay = useCallback(async () => { - // if (authenticated) { - // await trackGamePlay.mutateAsync({ - // gameId: game.id, - // }); - // notifications.add('You earned 1 token for starting the game!'); - // } else { - // notifications.add('Login to earn tokens!', { - // color: 'warning', - // unique: true, - // }); - // } - // }, [authenticated, game.id, notifications, trackGamePlay]); + const handleRewardPlay = useCallback(async () => { + if (authenticated) { + await trackGamePlay.mutateAsync({ + gameId: game.id, + }); + notifications.add('You earned 1 token for starting the game!'); + } else { + notifications.add('Login to earn tokens!', { + color: 'warning', + unique: true, + }); + } + }, [authenticated, game.id, notifications, trackGamePlay]); const handleIncrementPlayCount = useCallback(async () => { await record.mutateAsync({ gameId: game.id }); @@ -103,10 +106,7 @@ const GameScreenContainerInner: React.FC = ({ playedLast: new Date().getTime(), }); - await Promise.all([ - // handleRewardPlay(), - handleIncrementPlayCount(), - ]); + await Promise.all([handleRewardPlay(), handleIncrementPlayCount()]); }, [ addRecentlyPlayed, game.iconUrl, @@ -114,7 +114,7 @@ const GameScreenContainerInner: React.FC = ({ game.name, game.plays, handleIncrementPlayCount, - // handleRewardPlay, + handleRewardPlay, ]); const handleReportGame = useCallback( diff --git a/libs/util/settings/src/index.ts b/libs/util/settings/src/index.ts index 55cd8cbb..d7da0432 100644 --- a/libs/util/settings/src/index.ts +++ b/libs/util/settings/src/index.ts @@ -22,7 +22,6 @@ export const MAX_REFERRALS = 100; export const MAX_BEST_FRIENDS = 5; export const TOKENS_PER_REFERRAL_ACCOUNT = 500; -export const PER_GAME_PLAY_REWARD = 1; export const PLAY_MINUTE_DROP_CHANCE = 0.06;