Skip to content

Commit 050bb91

Browse files
committed
format
1 parent 9460370 commit 050bb91

File tree

2 files changed

+110
-110
lines changed

2 files changed

+110
-110
lines changed

rr/app/lib/db/schema.ts

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,121 @@
11
import { sql } from "drizzle-orm";
22
import {
3-
boolean,
4-
check,
5-
index,
6-
integer,
7-
pgEnum,
8-
pgTable,
9-
primaryKey,
10-
serial,
11-
text,
12-
timestamp,
3+
boolean,
4+
check,
5+
index,
6+
integer,
7+
pgEnum,
8+
pgTable,
9+
primaryKey,
10+
serial,
11+
text,
12+
timestamp,
1313
} from "drizzle-orm/pg-core";
1414

1515
export const haiyama = pgTable("haiyama", {
16-
id: text("id").primaryKey(),
16+
id: text("id").primaryKey(),
1717
});
1818

1919
export const haiKindEnum = pgEnum("hai_kind", [
20-
"manzu",
21-
"pinzu",
22-
"souzu",
23-
"jihai",
20+
"manzu",
21+
"pinzu",
22+
"souzu",
23+
"jihai",
2424
]);
2525

2626
export const hai = pgTable("hai", {
27-
id: serial("id").primaryKey(),
28-
haiyamaId: text("haiyama_id")
29-
.notNull()
30-
.references(() => haiyama.id, { onDelete: "cascade" }),
31-
kind: haiKindEnum("kind").notNull(), // "manzu" | "pinzu" | "souzu" | "jihai"
32-
value: text("value").notNull(), // 1~9 or "ton" ~ "tyun"
33-
order: integer("order").notNull(), // 0~17
34-
index: integer("index").notNull(), // haiToIndex
27+
id: serial("id").primaryKey(),
28+
haiyamaId: text("haiyama_id")
29+
.notNull()
30+
.references(() => haiyama.id, { onDelete: "cascade" }),
31+
kind: haiKindEnum("kind").notNull(), // "manzu" | "pinzu" | "souzu" | "jihai"
32+
value: text("value").notNull(), // 1~9 or "ton" ~ "tyun"
33+
order: integer("order").notNull(), // 0~17
34+
index: integer("index").notNull(), // haiToIndex
3535
});
3636

3737
// relation between user and haiyama
3838
export const kyoku = pgTable(
39-
"kyoku",
40-
{
41-
userId: text("user_id")
42-
.notNull()
43-
.references(() => user.id, { onDelete: "cascade" }),
44-
haiyamaId: text("haiyama_id")
45-
.notNull()
46-
.references(() => haiyama.id, { onDelete: "cascade" }),
47-
didAgari: boolean("did_agari").notNull(),
48-
agariJunme: integer("agari_junme"),
49-
},
50-
(table) => [
51-
primaryKey({ columns: [table.userId, table.haiyamaId] }),
52-
index("kyoku_user_id_idx").on(table.userId),
53-
index("kyoku_haiyama_id_idx").on(table.haiyamaId),
54-
check(
55-
"agari_consistency",
56-
sql`(${table.didAgari} = false) OR (${table.didAgari} = true AND ${table.agariJunme} IS NOT NULL)`,
57-
),
58-
],
39+
"kyoku",
40+
{
41+
userId: text("user_id")
42+
.notNull()
43+
.references(() => user.id, { onDelete: "cascade" }),
44+
haiyamaId: text("haiyama_id")
45+
.notNull()
46+
.references(() => haiyama.id, { onDelete: "cascade" }),
47+
didAgari: boolean("did_agari").notNull(),
48+
agariJunme: integer("agari_junme"),
49+
},
50+
(table) => [
51+
primaryKey({ columns: [table.userId, table.haiyamaId] }),
52+
index("kyoku_user_id_idx").on(table.userId),
53+
index("kyoku_haiyama_id_idx").on(table.haiyamaId),
54+
check(
55+
"agari_consistency",
56+
sql`(${table.didAgari} = false) OR (${table.didAgari} = true AND ${table.agariJunme} IS NOT NULL)`,
57+
),
58+
],
5959
);
6060

6161
// better-auth
6262
export const user = pgTable("user", {
63-
id: text("id").primaryKey(),
64-
name: text("name").notNull(),
65-
email: text("email").notNull().unique(),
66-
emailVerified: boolean("email_verified").default(false).notNull(),
67-
image: text("image"),
68-
createdAt: timestamp("created_at").defaultNow().notNull(),
69-
updatedAt: timestamp("updated_at")
70-
.defaultNow()
71-
.$onUpdate(() => /* @__PURE__ */ new Date())
72-
.notNull(),
73-
isAnonymous: boolean("is_anonymous"),
63+
id: text("id").primaryKey(),
64+
name: text("name").notNull(),
65+
email: text("email").notNull().unique(),
66+
emailVerified: boolean("email_verified").default(false).notNull(),
67+
image: text("image"),
68+
createdAt: timestamp("created_at").defaultNow().notNull(),
69+
updatedAt: timestamp("updated_at")
70+
.defaultNow()
71+
.$onUpdate(() => /* @__PURE__ */ new Date())
72+
.notNull(),
73+
isAnonymous: boolean("is_anonymous"),
7474
});
7575

7676
export const session = pgTable("session", {
77-
id: text("id").primaryKey(),
78-
expiresAt: timestamp("expires_at").notNull(),
79-
token: text("token").notNull().unique(),
80-
createdAt: timestamp("created_at").defaultNow().notNull(),
81-
updatedAt: timestamp("updated_at")
82-
.$onUpdate(() => /* @__PURE__ */ new Date())
83-
.notNull(),
84-
ipAddress: text("ip_address"),
85-
userAgent: text("user_agent"),
86-
userId: text("user_id")
87-
.notNull()
88-
.references(() => user.id, { onDelete: "cascade" }),
77+
id: text("id").primaryKey(),
78+
expiresAt: timestamp("expires_at").notNull(),
79+
token: text("token").notNull().unique(),
80+
createdAt: timestamp("created_at").defaultNow().notNull(),
81+
updatedAt: timestamp("updated_at")
82+
.$onUpdate(() => /* @__PURE__ */ new Date())
83+
.notNull(),
84+
ipAddress: text("ip_address"),
85+
userAgent: text("user_agent"),
86+
userId: text("user_id")
87+
.notNull()
88+
.references(() => user.id, { onDelete: "cascade" }),
8989
});
9090

9191
export const account = pgTable("account", {
92-
id: text("id").primaryKey(),
93-
accountId: text("account_id").notNull(),
94-
providerId: text("provider_id").notNull(),
95-
userId: text("user_id")
96-
.notNull()
97-
.references(() => user.id, { onDelete: "cascade" }),
98-
accessToken: text("access_token"),
99-
refreshToken: text("refresh_token"),
100-
idToken: text("id_token"),
101-
accessTokenExpiresAt: timestamp("access_token_expires_at"),
102-
refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
103-
scope: text("scope"),
104-
password: text("password"),
105-
createdAt: timestamp("created_at").defaultNow().notNull(),
106-
updatedAt: timestamp("updated_at")
107-
.$onUpdate(() => /* @__PURE__ */ new Date())
108-
.notNull(),
92+
id: text("id").primaryKey(),
93+
accountId: text("account_id").notNull(),
94+
providerId: text("provider_id").notNull(),
95+
userId: text("user_id")
96+
.notNull()
97+
.references(() => user.id, { onDelete: "cascade" }),
98+
accessToken: text("access_token"),
99+
refreshToken: text("refresh_token"),
100+
idToken: text("id_token"),
101+
accessTokenExpiresAt: timestamp("access_token_expires_at"),
102+
refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
103+
scope: text("scope"),
104+
password: text("password"),
105+
createdAt: timestamp("created_at").defaultNow().notNull(),
106+
updatedAt: timestamp("updated_at")
107+
.$onUpdate(() => /* @__PURE__ */ new Date())
108+
.notNull(),
109109
});
110110

111111
export const verification = pgTable("verification", {
112-
id: text("id").primaryKey(),
113-
identifier: text("identifier").notNull(),
114-
value: text("value").notNull(),
115-
expiresAt: timestamp("expires_at").notNull(),
116-
createdAt: timestamp("created_at").defaultNow().notNull(),
117-
updatedAt: timestamp("updated_at")
118-
.defaultNow()
119-
.$onUpdate(() => /* @__PURE__ */ new Date())
120-
.notNull(),
112+
id: text("id").primaryKey(),
113+
identifier: text("identifier").notNull(),
114+
value: text("value").notNull(),
115+
expiresAt: timestamp("expires_at").notNull(),
116+
createdAt: timestamp("created_at").defaultNow().notNull(),
117+
updatedAt: timestamp("updated_at")
118+
.defaultNow()
119+
.$onUpdate(() => /* @__PURE__ */ new Date())
120+
.notNull(),
121121
});

rr/app/lib/store.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1+
import { create } from "zustand";
12
import { persist } from "zustand/middleware";
23
import type { Hai } from "./hai";
3-
import { create } from "zustand";
44

55
interface GameState {
6-
kyoku: number;
7-
junme: number;
8-
haiyama: Hai[];
9-
sutehai: Hai[];
10-
tehai: Hai[];
6+
kyoku: number;
7+
junme: number;
8+
haiyama: Hai[];
9+
sutehai: Hai[];
10+
tehai: Hai[];
1111
}
1212

1313
const useGameState = create<GameState>()(
14-
persist(
15-
(set) => ({
16-
kyoku: 1,
17-
junme: 1,
18-
haiyama: [],
19-
sutehai: [],
20-
tehai: [],
21-
}),
22-
{
23-
name: "game-state-storage",
24-
},
25-
),
14+
persist(
15+
(set) => ({
16+
kyoku: 1,
17+
junme: 1,
18+
haiyama: [],
19+
sutehai: [],
20+
tehai: [],
21+
}),
22+
{
23+
name: "game-state-storage",
24+
},
25+
),
2626
);

0 commit comments

Comments
 (0)