Skip to content

Commit dd98983

Browse files
committed
duckguessr: WIP
1 parent 2544387 commit dd98983

15 files changed

+202
-173
lines changed

apps/duckguessr/.eslintrc-auto-import.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,26 @@
106106
"defineAsyncComponent": true,
107107
"defineComponent": true,
108108
"defineStore": true,
109+
"duckguessrSocketInjectionKey": true,
109110
"eagerComputed": true,
110111
"effectScope": true,
111112
"extendRef": true,
112113
"getActivePinia": true,
113114
"getCurrentInstance": true,
114115
"getCurrentLocaleShortKey": true,
115116
"getCurrentScope": true,
117+
"getDuckguessrId": true,
118+
"getDuckguessrUsername": true,
119+
"getShownUsername": true,
120+
"getUrl": true,
116121
"h": true,
117122
"ignorableWatch": true,
118123
"images": true,
119124
"inject": true,
120125
"injectLocal": true,
126+
"isBot": true,
121127
"isDefined": true,
128+
"isPotentialBot": true,
122129
"isProxy": true,
123130
"isReactive": true,
124131
"isReadonly": true,
@@ -171,11 +178,14 @@
171178
"refDefault": true,
172179
"refThrottled": true,
173180
"refWithControl": true,
181+
"removeCookie": true,
174182
"resolveComponent": true,
175183
"resolveRef": true,
176184
"resolveUnref": true,
177185
"setActivePinia": true,
186+
"setDuckguessrUserData": true,
178187
"setMapStoreSuffix": true,
188+
"setUserCookieIfNotExists": true,
179189
"shallowReactive": true,
180190
"shallowReadonly": true,
181191
"shallowRef": true,
@@ -253,6 +263,7 @@
253263
"useDocumentVisibility": true,
254264
"useDraggable": true,
255265
"useDropZone": true,
266+
"useDuckguessrSocket": true,
256267
"useElementBounding": true,
257268
"useElementByPoint": true,
258269
"useElementHover": true,
@@ -324,6 +335,7 @@
324335
"useRoute": true,
325336
"useRouter": true,
326337
"useSSRWidth": true,
338+
"useScoreToVariant": true,
327339
"useScreenOrientation": true,
328340
"useScreenSafeArea": true,
329341
"useScriptTag": true,
@@ -373,6 +385,7 @@
373385
"useWindowFocus": true,
374386
"useWindowScroll": true,
375387
"useWindowSize": true,
388+
"user": true,
376389
"users": true,
377390
"watch": true,
378391
"watchArray": true,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<style>
2+
#storybook-root {
3+
position: relative;
4+
min-width: 20%;
5+
}
6+
</style>

apps/duckguessr/.storybook/preview.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@ import { createPinia } from "pinia";
77
import i18n from "~web/src/i18n";
88
import de from "../locales/de.json";
99
import fr from "../locales/fr-FR.json";
10-
import en from "../locales/en-US";
1110
import es from "../locales/es.json";
1211

1312
const head = createHead();
1413

1514
const store = createPinia();
1615

17-
setup(async (app) => {
16+
setup((app) => {
1817
app
1918
.use(
2019
i18n("fr", localStorage.getItem("locale") || "fr", {
2120
de,
22-
en: await en(),
2321
fr,
2422
es,
2523
}).instance,

apps/duckguessr/api/prisma/schema.prisma

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,28 +118,28 @@ model entryurlDetails {
118118
}
119119

120120
view gameScores {
121-
gameId Int @map("game_id")
122-
playerId Int @map("player_id")
123-
gameScore BigInt @default(0) @map("game_score")
121+
gameId Int @map("game_id")
122+
playerId Int @map("player_id")
123+
gameScore Int @default(0) @map("game_score")
124124
125125
@@unique([gameId, playerId])
126126
@@map("game_scores")
127127
}
128128

129129
view userGameMedalPoints {
130-
medalType String @db.VarChar(30)
130+
medalType String @db.VarChar(30)
131131
gameId Int
132132
playerId Int
133-
playerPoints BigInt?
133+
playerPoints Int?
134134
135135
@@unique([medalType, playerId, gameId])
136136
@@map("user_medals_game")
137137
}
138138

139139
view userMedalPoints {
140-
medalType String @db.VarChar(30)
140+
medalType String @db.VarChar(30)
141141
playerId Int
142-
playerPoints BigInt?
142+
playerPoints Int?
143143
144144
@@unique([medalType, playerId])
145145
@@map("user_medals")

apps/duckguessr/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"lint": "eslint --fix .",
1616
"test": "npx codeceptjs run -f start",
1717
"storybook": "storybook dev -p 6006",
18-
"prod:deploy": "DIR=apps/duckguessr SERVICES='duckguessr-storybook' pnpm -F '~ci' prod:docker-compose-up",
18+
"prod:deploy": "DIR=apps/duckguessr SERVICES='storybook' pnpm -F '~ci' prod:docker-compose-up",
1919
"prod:build-docker": "REPO_NAME=ghcr.io/bperel/duckguessr-storybook pnpm -F '~ci' prod:build-docker --target storybook -f apps/duckguessr/Dockerfile",
2020
"prod:transfer-files-pre": "pnpm -F '~ci' prod:transfer-files @apps/duckguessr/.env:apps/duckguessr/.env",
2121
"prod:transfer-files-post": "pnpm -F '~ci' prod:transfer-files apps/duckguessr/docker-compose.yml:@apps/duckguessr/docker-compose.yml apps/duckguessr/Caddyfile:@apps/duckguessr/Caddyfile"

apps/duckguessr/src/components/DefaultLayout.stories.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 116 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Meta, StoryObj } from "@storybook/vue3-vite";
22
import { useCookies } from "@vueuse/integrations/useCookies";
33
import GameScores from "~/components/GameScores.vue";
4+
import type { player } from "~duckguessr-prisma-client";
45

56
const meta: Meta<typeof GameScores> = {
67
title: "GameScores",
@@ -9,95 +10,131 @@ const meta: Meta<typeof GameScores> = {
910
layout: "centered",
1011
},
1112
tags: ["autodocs"],
12-
argTypes: {
13-
gameId: {
14-
control: "number",
15-
},
16-
},
13+
argTypes: {},
1714
};
1815

1916
export default meta;
2017
type Story = StoryObj<typeof meta>;
2118

19+
const players: player[] = [
20+
{
21+
id: 1,
22+
username: "player 1",
23+
ducksmanagerId: 1,
24+
avatar: "https://example.com/avatar.png",
25+
},
26+
{
27+
id: 2,
28+
username: "player 2",
29+
ducksmanagerId: 2,
30+
avatar: "https://example.com/avatar.png",
31+
},
32+
];
33+
2234
export const Default: Story = {
2335
args: {
24-
gameId: 100,
25-
players: [
26-
{
27-
player_id: 1,
28-
player: {
36+
game: {
37+
datasetId: 1,
38+
dataset: {
39+
id: 1,
40+
name: "dataset",
41+
title: "dataset",
42+
description: "dataset",
43+
active: true,
44+
},
45+
rounds: [
46+
{
2947
id: 1,
30-
username: "player 1",
48+
startedAt: new Date(),
49+
finishedAt: new Date(),
50+
gameId: 100,
51+
roundNumber: 1,
52+
sitecodeUrl: "thumbnails3/webusers/2014/04/hu_mm1992_07e_001.jpg",
53+
roundScores: [
54+
{
55+
id: 1,
56+
roundId: 1,
57+
playerId: 1,
58+
scoreTypeName: "Correct author",
59+
score: 10,
60+
timeSpentGuessing: 10,
61+
speedBonus: 10,
62+
},
63+
],
3164
},
32-
},
33-
{
34-
player_id: 2,
35-
player: {
65+
{
3666
id: 2,
37-
username: "player 2",
67+
startedAt: new Date(),
68+
finishedAt: new Date(),
69+
gameId: 100,
70+
roundNumber: 2,
71+
sitecodeUrl: "thumbnails3/webusers/2017/03/it_om_1341g_001.jpg",
72+
roundScores: [
73+
{
74+
id: 1,
75+
roundId: 2,
76+
playerId: 1,
77+
scoreTypeName: "Correct author",
78+
score: 10,
79+
timeSpentGuessing: 10,
80+
speedBonus: 10,
81+
},
82+
{
83+
id: 2,
84+
roundId: 2,
85+
playerId: 2,
86+
scoreTypeName: "Correct author",
87+
score: 10,
88+
timeSpentGuessing: 10,
89+
speedBonus: 10,
90+
},
91+
],
3892
},
39-
},
40-
],
41-
authors: [
42-
{
43-
personcode: "DR",
44-
personnationality: "us",
45-
personfullname: "Don Rosa",
46-
},
47-
{
48-
personcode: "CB",
49-
personnationality: "us",
50-
personfullname: "Carl Barks",
51-
},
52-
{
53-
personcode: "RSc",
54-
personnationality: "it",
55-
personfullname: "Romano Scarpa",
56-
},
57-
],
58-
rounds: [
59-
{
60-
personcode: "DR",
61-
round_number: 1,
62-
sitecode_url: "thumbnails3/webusers/2014/04/hu_mm1992_07e_001.jpg",
63-
round_scores: [
64-
{
65-
player_id: 1,
66-
score_type_name: "Correct author",
67-
score: 10,
68-
},
69-
],
70-
},
71-
{
72-
personcode: "CB",
73-
round_number: 2,
74-
sitecode_url: "thumbnails3/webusers/2017/03/it_om_1341g_001.jpg",
75-
round_scores: [
76-
{
77-
player_id: 1,
78-
score_type_name: "Correct author",
79-
score: 10,
80-
},
81-
{
82-
player_id: 2,
83-
score_type_name: "Correct author",
84-
score: 10,
85-
},
86-
],
87-
},
88-
{
89-
personcode: "RSc",
90-
round_number: 3,
91-
sitecode_url: "webusers/webusers-auth/rsc_ommi0o.png",
92-
round_scores: [],
93-
},
94-
],
93+
{
94+
id: 3,
95+
startedAt: new Date(),
96+
finishedAt: new Date(),
97+
gameId: 100,
98+
roundNumber: 3,
99+
sitecodeUrl: "webusers/webusers-auth/rsc_ommi0o.png",
100+
roundScores: [],
101+
},
102+
],
103+
createdAt: new Date(),
104+
startedAt: new Date(),
105+
finishedAt: new Date(),
106+
id: 100,
107+
gamePlayers: [
108+
{
109+
id: 1,
110+
gameId: 100,
111+
playerId: 1,
112+
player: players[0],
113+
},
114+
{
115+
id: 2,
116+
gameId: 100,
117+
playerId: 2,
118+
player: players[1],
119+
},
120+
],
121+
authors: [
122+
{
123+
personcode: "DR",
124+
nationalitycountrycode: "us",
125+
fullname: "Don Rosa",
126+
},
127+
{
128+
personcode: "CB",
129+
nationalitycountrycode: "us",
130+
fullname: "Carl Barks",
131+
},
132+
{
133+
personcode: "RSc",
134+
nationalitycountrycode: "it",
135+
fullname: "Romano Scarpa",
136+
},
137+
],
138+
},
95139
},
96-
decorators: [
97-
() => ({
98-
setup() {
99-
useCookies().set("duckguessr-id", 1);
100-
},
101-
}),
102-
],
103140
};

apps/duckguessr/src/components/GameScores.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@
103103
import { getDuckguessrId, getShownUsername } from "~/composables/user";
104104
105105
import { userStore } from "~/stores/user";
106-
import type { GameFullNoPersoncode } from "~duckguessr-types/game";
106+
import type { GameFull } from "~duckguessr-types/game";
107107
import type { ColorVariant } from "bootstrap-vue-next";
108108
import type { player, roundScore } from "~duckguessr-prisma-client";
109109
110110
const { game } = defineProps<{
111-
game: GameFullNoPersoncode;
111+
game: GameFull;
112112
}>();
113113
114114
const duckguessrId = getDuckguessrId();

0 commit comments

Comments
 (0)