Skip to content

Commit

Permalink
tasks: restore play game actions and base quests
Browse files Browse the repository at this point in the history
  • Loading branch information
GGonryun committed Sep 28, 2024
1 parent 67bf1b4 commit 19d34f2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 45 deletions.
22 changes: 1 addition & 21 deletions libs/data/quests/src/index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions libs/ui/components/help/src/lib/help-tokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -63,7 +62,7 @@ export const helpTokens: QuestionAnswer[] = [
<OrderedList>
<ListItem>
<Link href={routes.help.playingGames.path()}>Playing Games</Link> -
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.
</ListItem>
Expand Down
42 changes: 21 additions & 21 deletions libs/ui/pages/game/src/lib/containers/game-screen-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -52,7 +55,7 @@ const GameScreenContainerInner: React.FC<GameScreenContainerProps> = ({
const session = useSession();
const authenticated = session.status === 'authenticated';

// const notifications = useGameNotifications();
const notifications = useGameNotifications();

const [showShare, setShowShare] = useState(false);
const [showReport, setShowReport] = useState(false);
Expand All @@ -63,7 +66,7 @@ const GameScreenContainerInner: React.FC<GameScreenContainerProps> = ({
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(
{
Expand All @@ -76,19 +79,19 @@ const GameScreenContainerInner: React.FC<GameScreenContainerProps> = ({

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 });
Expand All @@ -103,18 +106,15 @@ const GameScreenContainerInner: React.FC<GameScreenContainerProps> = ({
playedLast: new Date().getTime(),
});

await Promise.all([
// handleRewardPlay(),
handleIncrementPlayCount(),
]);
await Promise.all([handleRewardPlay(), handleIncrementPlayCount()]);
}, [
addRecentlyPlayed,
game.iconUrl,
game.id,
game.name,
game.plays,
handleIncrementPlayCount,
// handleRewardPlay,
handleRewardPlay,
]);

const handleReportGame = useCallback(
Expand Down
1 change: 0 additions & 1 deletion libs/util/settings/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 19d34f2

Please sign in to comment.