@kekkle/shared 2.0.1 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/constants/collections.d.ts +4 -0
- package/dist/cjs/constants/collections.d.ts.map +1 -1
- package/dist/cjs/constants/collections.js +5 -1
- package/dist/cjs/convertors/node/wordle6-game-state-document.converter.d.ts +4 -0
- package/dist/cjs/convertors/node/wordle6-game-state-document.converter.d.ts.map +1 -0
- package/dist/cjs/convertors/node/wordle6-game-state-document.converter.js +23 -0
- package/dist/cjs/convertors/web/wordle6-game-state-document.converter.d.ts +4 -0
- package/dist/cjs/convertors/web/wordle6-game-state-document.converter.d.ts.map +1 -0
- package/dist/cjs/convertors/web/wordle6-game-state-document.converter.js +23 -0
- package/dist/cjs/helpers/worlde/reconstruct-game-state.d.ts +3 -0
- package/dist/cjs/helpers/worlde/reconstruct-game-state.d.ts.map +1 -0
- package/dist/cjs/helpers/worlde/reconstruct-game-state.js +51 -0
- package/dist/cjs/types/documents/wordle6-game-state-document/node/wordle6-game-state-document-firestore.d.ts +6 -0
- package/dist/cjs/types/documents/wordle6-game-state-document/node/wordle6-game-state-document-firestore.d.ts.map +1 -0
- package/dist/cjs/types/documents/wordle6-game-state-document/node/wordle6-game-state-document-firestore.js +2 -0
- package/dist/cjs/types/documents/wordle6-game-state-document/web/wordle6-game-state-document-firestore.d.ts +6 -0
- package/dist/cjs/types/documents/wordle6-game-state-document/web/wordle6-game-state-document-firestore.d.ts.map +1 -0
- package/dist/cjs/types/documents/wordle6-game-state-document/web/wordle6-game-state-document-firestore.js +2 -0
- package/dist/cjs/types/documents/wordle6-game-state-document/wordle6-game-state-document-firestore-base.d.ts +9 -0
- package/dist/cjs/types/documents/wordle6-game-state-document/wordle6-game-state-document-firestore-base.d.ts.map +1 -0
- package/dist/cjs/types/documents/wordle6-game-state-document/wordle6-game-state-document-firestore-base.js +2 -0
- package/dist/cjs/types/documents/wordle6-game-state-document/wordle6-game-state-document.d.ts +11 -0
- package/dist/cjs/types/documents/wordle6-game-state-document/wordle6-game-state-document.d.ts.map +1 -0
- package/dist/cjs/types/documents/wordle6-game-state-document/wordle6-game-state-document.js +2 -0
- package/dist/esm/constants/collections.d.ts +4 -0
- package/dist/esm/constants/collections.d.ts.map +1 -1
- package/dist/esm/constants/collections.js +4 -0
- package/dist/esm/convertors/node/wordle6-game-state-document.converter.d.ts +4 -0
- package/dist/esm/convertors/node/wordle6-game-state-document.converter.d.ts.map +1 -0
- package/dist/esm/convertors/node/wordle6-game-state-document.converter.js +20 -0
- package/dist/esm/convertors/web/wordle6-game-state-document.converter.d.ts +4 -0
- package/dist/esm/convertors/web/wordle6-game-state-document.converter.d.ts.map +1 -0
- package/dist/esm/convertors/web/wordle6-game-state-document.converter.js +20 -0
- package/dist/esm/helpers/worlde/reconstruct-game-state.d.ts +3 -0
- package/dist/esm/helpers/worlde/reconstruct-game-state.d.ts.map +1 -0
- package/dist/esm/helpers/worlde/reconstruct-game-state.js +48 -0
- package/dist/esm/types/documents/wordle6-game-state-document/node/wordle6-game-state-document-firestore.d.ts +6 -0
- package/dist/esm/types/documents/wordle6-game-state-document/node/wordle6-game-state-document-firestore.d.ts.map +1 -0
- package/dist/esm/types/documents/wordle6-game-state-document/node/wordle6-game-state-document-firestore.js +1 -0
- package/dist/esm/types/documents/wordle6-game-state-document/web/wordle6-game-state-document-firestore.d.ts +6 -0
- package/dist/esm/types/documents/wordle6-game-state-document/web/wordle6-game-state-document-firestore.d.ts.map +1 -0
- package/dist/esm/types/documents/wordle6-game-state-document/web/wordle6-game-state-document-firestore.js +1 -0
- package/dist/esm/types/documents/wordle6-game-state-document/wordle6-game-state-document-firestore-base.d.ts +9 -0
- package/dist/esm/types/documents/wordle6-game-state-document/wordle6-game-state-document-firestore-base.d.ts.map +1 -0
- package/dist/esm/types/documents/wordle6-game-state-document/wordle6-game-state-document-firestore-base.js +1 -0
- package/dist/esm/types/documents/wordle6-game-state-document/wordle6-game-state-document.d.ts +11 -0
- package/dist/esm/types/documents/wordle6-game-state-document/wordle6-game-state-document.d.ts.map +1 -0
- package/dist/esm/types/documents/wordle6-game-state-document/wordle6-game-state-document.js +1 -0
- package/dist/node/constants/collections.d.ts +4 -0
- package/dist/node/constants/collections.d.ts.map +1 -1
- package/dist/node/constants/collections.js +4 -0
- package/dist/node/convertors/node/wordle6-game-state-document.converter.d.ts +4 -0
- package/dist/node/convertors/node/wordle6-game-state-document.converter.d.ts.map +1 -0
- package/dist/node/convertors/node/wordle6-game-state-document.converter.js +20 -0
- package/dist/node/convertors/web/wordle6-game-state-document.converter.d.ts +4 -0
- package/dist/node/convertors/web/wordle6-game-state-document.converter.d.ts.map +1 -0
- package/dist/node/convertors/web/wordle6-game-state-document.converter.js +20 -0
- package/dist/node/helpers/worlde/reconstruct-game-state.d.ts +3 -0
- package/dist/node/helpers/worlde/reconstruct-game-state.d.ts.map +1 -0
- package/dist/node/helpers/worlde/reconstruct-game-state.js +48 -0
- package/dist/node/types/documents/wordle6-game-state-document/node/wordle6-game-state-document-firestore.d.ts +6 -0
- package/dist/node/types/documents/wordle6-game-state-document/node/wordle6-game-state-document-firestore.d.ts.map +1 -0
- package/dist/node/types/documents/wordle6-game-state-document/node/wordle6-game-state-document-firestore.js +1 -0
- package/dist/node/types/documents/wordle6-game-state-document/web/wordle6-game-state-document-firestore.d.ts +6 -0
- package/dist/node/types/documents/wordle6-game-state-document/web/wordle6-game-state-document-firestore.d.ts.map +1 -0
- package/dist/node/types/documents/wordle6-game-state-document/web/wordle6-game-state-document-firestore.js +1 -0
- package/dist/node/types/documents/wordle6-game-state-document/wordle6-game-state-document-firestore-base.d.ts +9 -0
- package/dist/node/types/documents/wordle6-game-state-document/wordle6-game-state-document-firestore-base.d.ts.map +1 -0
- package/dist/node/types/documents/wordle6-game-state-document/wordle6-game-state-document-firestore-base.js +1 -0
- package/dist/node/types/documents/wordle6-game-state-document/wordle6-game-state-document.d.ts +11 -0
- package/dist/node/types/documents/wordle6-game-state-document/wordle6-game-state-document.d.ts.map +1 -0
- package/dist/node/types/documents/wordle6-game-state-document/wordle6-game-state-document.js +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.node.tsbuildinfo +1 -1
- package/package.json +9 -1
|
@@ -4,4 +4,8 @@ export declare const WORDLE_GAMES_COLLECTION_PATH = "wordle_games";
|
|
|
4
4
|
export declare const WORDLE_LEADERBOARD_COLLECTION_PATH = "wordle_leaderboard";
|
|
5
5
|
export declare const WORDLE_MONTHLY_SCORES_COLLECTION_PATH = "wordle_monthly_scores";
|
|
6
6
|
export declare const WORDLE_SCORES_COLLECTION_PATH = "wordle_scores";
|
|
7
|
+
export declare const WORDLE6_GAMES_COLLECTION_PATH = "wordle6_games";
|
|
8
|
+
export declare const WORDLE6_LEADERBOARD_COLLECTION_PATH = "wordle6_leaderboard";
|
|
9
|
+
export declare const WORDLE6_MONTHLY_SCORES_COLLECTION_PATH = "wordle6_monthly_scores";
|
|
10
|
+
export declare const WORDLE6_SCORES_COLLECTION_PATH = "wordle6_scores";
|
|
7
11
|
//# sourceMappingURL=collections.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../../src/constants/collections.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAC5C,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,4BAA4B,iBAAiB,CAAC;AAC3D,eAAO,MAAM,kCAAkC,uBAAuB,CAAC;AACvE,eAAO,MAAM,qCAAqC,0BAA0B,CAAC;AAC7E,eAAO,MAAM,6BAA6B,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../../src/constants/collections.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAC5C,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,4BAA4B,iBAAiB,CAAC;AAC3D,eAAO,MAAM,kCAAkC,uBAAuB,CAAC;AACvE,eAAO,MAAM,qCAAqC,0BAA0B,CAAC;AAC7E,eAAO,MAAM,6BAA6B,kBAAkB,CAAC;AAC7D,eAAO,MAAM,6BAA6B,kBAAkB,CAAC;AAC7D,eAAO,MAAM,mCAAmC,wBAAwB,CAAC;AACzE,eAAO,MAAM,sCAAsC,2BAA2B,CAAC;AAC/E,eAAO,MAAM,8BAA8B,mBAAmB,CAAC"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WORDLE_SCORES_COLLECTION_PATH = exports.WORDLE_MONTHLY_SCORES_COLLECTION_PATH = exports.WORDLE_LEADERBOARD_COLLECTION_PATH = exports.WORDLE_GAMES_COLLECTION_PATH = exports.GROUP_COLLECTION_PATH = exports.USER_COLLECTION_PATH = void 0;
|
|
3
|
+
exports.WORDLE6_SCORES_COLLECTION_PATH = exports.WORDLE6_MONTHLY_SCORES_COLLECTION_PATH = exports.WORDLE6_LEADERBOARD_COLLECTION_PATH = exports.WORDLE6_GAMES_COLLECTION_PATH = exports.WORDLE_SCORES_COLLECTION_PATH = exports.WORDLE_MONTHLY_SCORES_COLLECTION_PATH = exports.WORDLE_LEADERBOARD_COLLECTION_PATH = exports.WORDLE_GAMES_COLLECTION_PATH = exports.GROUP_COLLECTION_PATH = exports.USER_COLLECTION_PATH = void 0;
|
|
4
4
|
exports.USER_COLLECTION_PATH = "users";
|
|
5
5
|
exports.GROUP_COLLECTION_PATH = "groups";
|
|
6
6
|
exports.WORDLE_GAMES_COLLECTION_PATH = "wordle_games";
|
|
7
7
|
exports.WORDLE_LEADERBOARD_COLLECTION_PATH = "wordle_leaderboard";
|
|
8
8
|
exports.WORDLE_MONTHLY_SCORES_COLLECTION_PATH = "wordle_monthly_scores";
|
|
9
9
|
exports.WORDLE_SCORES_COLLECTION_PATH = "wordle_scores";
|
|
10
|
+
exports.WORDLE6_GAMES_COLLECTION_PATH = "wordle6_games";
|
|
11
|
+
exports.WORDLE6_LEADERBOARD_COLLECTION_PATH = "wordle6_leaderboard";
|
|
12
|
+
exports.WORDLE6_MONTHLY_SCORES_COLLECTION_PATH = "wordle6_monthly_scores";
|
|
13
|
+
exports.WORDLE6_SCORES_COLLECTION_PATH = "wordle6_scores";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Wordle6GameStateDocument } from "../../types/documents/wordle6-game-state-document/wordle6-game-state-document.js";
|
|
2
|
+
import { type FirestoreDataConverter } from "firebase-admin/firestore";
|
|
3
|
+
export declare const wordle6GameStateDocumentConverter: FirestoreDataConverter<Wordle6GameStateDocument>;
|
|
4
|
+
//# sourceMappingURL=wordle6-game-state-document.converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordle6-game-state-document.converter.d.ts","sourceRoot":"","sources":["../../../../src/convertors/node/wordle6-game-state-document.converter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8EAA8E,CAAC;AAC7H,OAAO,EAEL,KAAK,sBAAsB,EAI5B,MAAM,0BAA0B,CAAC;AAElC,eAAO,MAAM,iCAAiC,EAAE,sBAAsB,CAAC,wBAAwB,CAyB5F,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wordle6GameStateDocumentConverter = void 0;
|
|
4
|
+
const firestore_1 = require("firebase-admin/firestore");
|
|
5
|
+
exports.wordle6GameStateDocumentConverter = {
|
|
6
|
+
toFirestore: (doc) => {
|
|
7
|
+
const { _id, ...docWithoutId } = doc;
|
|
8
|
+
return {
|
|
9
|
+
...docWithoutId,
|
|
10
|
+
updated_at: docWithoutId.updated_at instanceof Date
|
|
11
|
+
? firestore_1.Timestamp.fromDate(docWithoutId.updated_at)
|
|
12
|
+
: docWithoutId.updated_at,
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
fromFirestore: (snapshot) => {
|
|
16
|
+
const data = snapshot.data();
|
|
17
|
+
return {
|
|
18
|
+
_id: snapshot.id,
|
|
19
|
+
...data,
|
|
20
|
+
updated_at: data.updated_at.toDate(),
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Wordle6GameStateDocument } from "../../types/documents/wordle6-game-state-document/wordle6-game-state-document.js";
|
|
2
|
+
import { type FirestoreDataConverter } from "firebase/firestore";
|
|
3
|
+
export declare const wordle6GameStateDocumentConverter: FirestoreDataConverter<Wordle6GameStateDocument>;
|
|
4
|
+
//# sourceMappingURL=wordle6-game-state-document.converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordle6-game-state-document.converter.d.ts","sourceRoot":"","sources":["../../../../src/convertors/web/wordle6-game-state-document.converter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8EAA8E,CAAC;AAC7H,OAAO,EAEL,KAAK,sBAAsB,EAI5B,MAAM,oBAAoB,CAAC;AAE5B,eAAO,MAAM,iCAAiC,EAAE,sBAAsB,CAAC,wBAAwB,CA2B5F,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wordle6GameStateDocumentConverter = void 0;
|
|
4
|
+
const firestore_1 = require("firebase/firestore");
|
|
5
|
+
exports.wordle6GameStateDocumentConverter = {
|
|
6
|
+
toFirestore: (doc) => {
|
|
7
|
+
const { _id, ...docWithoutId } = doc;
|
|
8
|
+
return {
|
|
9
|
+
...docWithoutId,
|
|
10
|
+
updated_at: docWithoutId.updated_at instanceof Date
|
|
11
|
+
? firestore_1.Timestamp.fromDate(docWithoutId.updated_at)
|
|
12
|
+
: docWithoutId.updated_at,
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
fromFirestore: (snapshot) => {
|
|
16
|
+
const data = snapshot.data();
|
|
17
|
+
return {
|
|
18
|
+
_id: snapshot.id,
|
|
19
|
+
...data,
|
|
20
|
+
updated_at: data.updated_at.toDate(),
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconstruct-game-state.d.ts","sourceRoot":"","sources":["../../../../src/helpers/worlde/reconstruct-game-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,uDAAuD,CAAC;AAE/D,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EAAE,EACjB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,eAAe,CAcjB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reconstructGameState = reconstructGameState;
|
|
4
|
+
function reconstructGameState(guesses, correctWord, maxRows) {
|
|
5
|
+
const wordLength = correctWord.length;
|
|
6
|
+
const rows = [];
|
|
7
|
+
for (const guess of guesses) {
|
|
8
|
+
const row = evaluateGuess(guess, correctWord);
|
|
9
|
+
rows.push(row);
|
|
10
|
+
}
|
|
11
|
+
while (rows.length < maxRows) {
|
|
12
|
+
rows.push(createEmptyRow(wordLength));
|
|
13
|
+
}
|
|
14
|
+
return rows;
|
|
15
|
+
}
|
|
16
|
+
function evaluateGuess(guess, correctWord) {
|
|
17
|
+
const row = Array.from({ length: guess.length }, () => ({
|
|
18
|
+
character: "",
|
|
19
|
+
isCorrect: false,
|
|
20
|
+
isLocked: true,
|
|
21
|
+
}));
|
|
22
|
+
const correctWordCounts = {};
|
|
23
|
+
for (const char of correctWord) {
|
|
24
|
+
correctWordCounts[char] = (correctWordCounts[char] || 0) + 1;
|
|
25
|
+
}
|
|
26
|
+
const markedCounts = {};
|
|
27
|
+
for (let i = 0; i < guess.length; i++) {
|
|
28
|
+
row[i].character = guess[i];
|
|
29
|
+
if (guess[i] === correctWord[i]) {
|
|
30
|
+
row[i].isCorrect = true;
|
|
31
|
+
markedCounts[guess[i]] = (markedCounts[guess[i]] || 0) + 1;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
for (let i = 0; i < guess.length; i++) {
|
|
35
|
+
if (!row[i].isCorrect && correctWord.includes(guess[i])) {
|
|
36
|
+
markedCounts[guess[i]] = (markedCounts[guess[i]] || 0) + 1;
|
|
37
|
+
if (markedCounts[guess[i]] <= correctWordCounts[guess[i]]) {
|
|
38
|
+
row[i].isPresent = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return row;
|
|
43
|
+
}
|
|
44
|
+
function createEmptyRow(wordLength) {
|
|
45
|
+
return Array.from({ length: wordLength }, () => ({
|
|
46
|
+
character: "",
|
|
47
|
+
isCorrect: false,
|
|
48
|
+
isPresent: false,
|
|
49
|
+
isLocked: false,
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Timestamp } from "firebase-admin/firestore";
|
|
2
|
+
import type { Wordle6GameStateDocumentFirestoreBase } from "../../../../types/documents/wordle6-game-state-document/wordle6-game-state-document-firestore-base.js";
|
|
3
|
+
export type Wordle6GameStateDocumentFirestore = Wordle6GameStateDocumentFirestoreBase & {
|
|
4
|
+
updated_at: Timestamp;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=wordle6-game-state-document-firestore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordle6-game-state-document-firestore.d.ts","sourceRoot":"","sources":["../../../../../../src/types/documents/wordle6-game-state-document/node/wordle6-game-state-document-firestore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,6FAA6F,CAAC;AAEzJ,MAAM,MAAM,iCAAiC,GAC3C,qCAAqC,GAAG;IACtC,UAAU,EAAE,SAAS,CAAC;CACvB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Timestamp } from "firebase/firestore";
|
|
2
|
+
import type { Wordle6GameStateDocumentFirestoreBase } from "../../../../types/documents/wordle6-game-state-document/wordle6-game-state-document-firestore-base.js";
|
|
3
|
+
export type Wordle6GameStateDocumentFirestore = Wordle6GameStateDocumentFirestoreBase & {
|
|
4
|
+
updated_at: Timestamp;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=wordle6-game-state-document-firestore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordle6-game-state-document-firestore.d.ts","sourceRoot":"","sources":["../../../../../../src/types/documents/wordle6-game-state-document/web/wordle6-game-state-document-firestore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,6FAA6F,CAAC;AAEzJ,MAAM,MAAM,iCAAiC,GAC3C,qCAAqC,GAAG;IACtC,UAAU,EAAE,SAAS,CAAC;CACvB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type Wordle6GameStateDocumentFirestoreBase = {
|
|
2
|
+
guesses: string[];
|
|
3
|
+
has_finished: boolean;
|
|
4
|
+
has_lost: boolean;
|
|
5
|
+
has_won: boolean;
|
|
6
|
+
number_of_tries_needed: number;
|
|
7
|
+
user_id: string;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=wordle6-game-state-document-firestore-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordle6-game-state-document-firestore-base.d.ts","sourceRoot":"","sources":["../../../../../src/types/documents/wordle6-game-state-document/wordle6-game-state-document-firestore-base.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qCAAqC,GAAG;IAClD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Wordle6GameStateDocument = {
|
|
2
|
+
_id: string;
|
|
3
|
+
guesses: string[];
|
|
4
|
+
has_finished: boolean;
|
|
5
|
+
has_lost: boolean;
|
|
6
|
+
has_won: boolean;
|
|
7
|
+
number_of_tries_needed: number;
|
|
8
|
+
updated_at: Date;
|
|
9
|
+
user_id: string;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=wordle6-game-state-document.d.ts.map
|
package/dist/cjs/types/documents/wordle6-game-state-document/wordle6-game-state-document.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordle6-game-state-document.d.ts","sourceRoot":"","sources":["../../../../../src/types/documents/wordle6-game-state-document/wordle6-game-state-document.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAAG;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,UAAU,EAAE,IAAI,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -4,4 +4,8 @@ export declare const WORDLE_GAMES_COLLECTION_PATH = "wordle_games";
|
|
|
4
4
|
export declare const WORDLE_LEADERBOARD_COLLECTION_PATH = "wordle_leaderboard";
|
|
5
5
|
export declare const WORDLE_MONTHLY_SCORES_COLLECTION_PATH = "wordle_monthly_scores";
|
|
6
6
|
export declare const WORDLE_SCORES_COLLECTION_PATH = "wordle_scores";
|
|
7
|
+
export declare const WORDLE6_GAMES_COLLECTION_PATH = "wordle6_games";
|
|
8
|
+
export declare const WORDLE6_LEADERBOARD_COLLECTION_PATH = "wordle6_leaderboard";
|
|
9
|
+
export declare const WORDLE6_MONTHLY_SCORES_COLLECTION_PATH = "wordle6_monthly_scores";
|
|
10
|
+
export declare const WORDLE6_SCORES_COLLECTION_PATH = "wordle6_scores";
|
|
7
11
|
//# sourceMappingURL=collections.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../../src/constants/collections.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAC5C,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,4BAA4B,iBAAiB,CAAC;AAC3D,eAAO,MAAM,kCAAkC,uBAAuB,CAAC;AACvE,eAAO,MAAM,qCAAqC,0BAA0B,CAAC;AAC7E,eAAO,MAAM,6BAA6B,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../../src/constants/collections.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAC5C,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,4BAA4B,iBAAiB,CAAC;AAC3D,eAAO,MAAM,kCAAkC,uBAAuB,CAAC;AACvE,eAAO,MAAM,qCAAqC,0BAA0B,CAAC;AAC7E,eAAO,MAAM,6BAA6B,kBAAkB,CAAC;AAC7D,eAAO,MAAM,6BAA6B,kBAAkB,CAAC;AAC7D,eAAO,MAAM,mCAAmC,wBAAwB,CAAC;AACzE,eAAO,MAAM,sCAAsC,2BAA2B,CAAC;AAC/E,eAAO,MAAM,8BAA8B,mBAAmB,CAAC"}
|
|
@@ -4,3 +4,7 @@ export const WORDLE_GAMES_COLLECTION_PATH = "wordle_games";
|
|
|
4
4
|
export const WORDLE_LEADERBOARD_COLLECTION_PATH = "wordle_leaderboard";
|
|
5
5
|
export const WORDLE_MONTHLY_SCORES_COLLECTION_PATH = "wordle_monthly_scores";
|
|
6
6
|
export const WORDLE_SCORES_COLLECTION_PATH = "wordle_scores";
|
|
7
|
+
export const WORDLE6_GAMES_COLLECTION_PATH = "wordle6_games";
|
|
8
|
+
export const WORDLE6_LEADERBOARD_COLLECTION_PATH = "wordle6_leaderboard";
|
|
9
|
+
export const WORDLE6_MONTHLY_SCORES_COLLECTION_PATH = "wordle6_monthly_scores";
|
|
10
|
+
export const WORDLE6_SCORES_COLLECTION_PATH = "wordle6_scores";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Wordle6GameStateDocument } from "../../types/documents/wordle6-game-state-document/wordle6-game-state-document.js";
|
|
2
|
+
import { type FirestoreDataConverter } from "firebase-admin/firestore";
|
|
3
|
+
export declare const wordle6GameStateDocumentConverter: FirestoreDataConverter<Wordle6GameStateDocument>;
|
|
4
|
+
//# sourceMappingURL=wordle6-game-state-document.converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordle6-game-state-document.converter.d.ts","sourceRoot":"","sources":["../../../../src/convertors/node/wordle6-game-state-document.converter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8EAA8E,CAAC;AAC7H,OAAO,EAEL,KAAK,sBAAsB,EAI5B,MAAM,0BAA0B,CAAC;AAElC,eAAO,MAAM,iCAAiC,EAAE,sBAAsB,CAAC,wBAAwB,CAyB5F,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Timestamp, } from "firebase-admin/firestore";
|
|
2
|
+
export const wordle6GameStateDocumentConverter = {
|
|
3
|
+
toFirestore: (doc) => {
|
|
4
|
+
const { _id, ...docWithoutId } = doc;
|
|
5
|
+
return {
|
|
6
|
+
...docWithoutId,
|
|
7
|
+
updated_at: docWithoutId.updated_at instanceof Date
|
|
8
|
+
? Timestamp.fromDate(docWithoutId.updated_at)
|
|
9
|
+
: docWithoutId.updated_at,
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
fromFirestore: (snapshot) => {
|
|
13
|
+
const data = snapshot.data();
|
|
14
|
+
return {
|
|
15
|
+
_id: snapshot.id,
|
|
16
|
+
...data,
|
|
17
|
+
updated_at: data.updated_at.toDate(),
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Wordle6GameStateDocument } from "../../types/documents/wordle6-game-state-document/wordle6-game-state-document.js";
|
|
2
|
+
import { type FirestoreDataConverter } from "firebase/firestore";
|
|
3
|
+
export declare const wordle6GameStateDocumentConverter: FirestoreDataConverter<Wordle6GameStateDocument>;
|
|
4
|
+
//# sourceMappingURL=wordle6-game-state-document.converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordle6-game-state-document.converter.d.ts","sourceRoot":"","sources":["../../../../src/convertors/web/wordle6-game-state-document.converter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8EAA8E,CAAC;AAC7H,OAAO,EAEL,KAAK,sBAAsB,EAI5B,MAAM,oBAAoB,CAAC;AAE5B,eAAO,MAAM,iCAAiC,EAAE,sBAAsB,CAAC,wBAAwB,CA2B5F,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Timestamp, } from "firebase/firestore";
|
|
2
|
+
export const wordle6GameStateDocumentConverter = {
|
|
3
|
+
toFirestore: (doc) => {
|
|
4
|
+
const { _id, ...docWithoutId } = doc;
|
|
5
|
+
return {
|
|
6
|
+
...docWithoutId,
|
|
7
|
+
updated_at: docWithoutId.updated_at instanceof Date
|
|
8
|
+
? Timestamp.fromDate(docWithoutId.updated_at)
|
|
9
|
+
: docWithoutId.updated_at,
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
fromFirestore: (snapshot) => {
|
|
13
|
+
const data = snapshot.data();
|
|
14
|
+
return {
|
|
15
|
+
_id: snapshot.id,
|
|
16
|
+
...data,
|
|
17
|
+
updated_at: data.updated_at.toDate(),
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconstruct-game-state.d.ts","sourceRoot":"","sources":["../../../../src/helpers/worlde/reconstruct-game-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,uDAAuD,CAAC;AAE/D,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EAAE,EACjB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,eAAe,CAcjB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export function reconstructGameState(guesses, correctWord, maxRows) {
|
|
2
|
+
const wordLength = correctWord.length;
|
|
3
|
+
const rows = [];
|
|
4
|
+
for (const guess of guesses) {
|
|
5
|
+
const row = evaluateGuess(guess, correctWord);
|
|
6
|
+
rows.push(row);
|
|
7
|
+
}
|
|
8
|
+
while (rows.length < maxRows) {
|
|
9
|
+
rows.push(createEmptyRow(wordLength));
|
|
10
|
+
}
|
|
11
|
+
return rows;
|
|
12
|
+
}
|
|
13
|
+
function evaluateGuess(guess, correctWord) {
|
|
14
|
+
const row = Array.from({ length: guess.length }, () => ({
|
|
15
|
+
character: "",
|
|
16
|
+
isCorrect: false,
|
|
17
|
+
isLocked: true,
|
|
18
|
+
}));
|
|
19
|
+
const correctWordCounts = {};
|
|
20
|
+
for (const char of correctWord) {
|
|
21
|
+
correctWordCounts[char] = (correctWordCounts[char] || 0) + 1;
|
|
22
|
+
}
|
|
23
|
+
const markedCounts = {};
|
|
24
|
+
for (let i = 0; i < guess.length; i++) {
|
|
25
|
+
row[i].character = guess[i];
|
|
26
|
+
if (guess[i] === correctWord[i]) {
|
|
27
|
+
row[i].isCorrect = true;
|
|
28
|
+
markedCounts[guess[i]] = (markedCounts[guess[i]] || 0) + 1;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (let i = 0; i < guess.length; i++) {
|
|
32
|
+
if (!row[i].isCorrect && correctWord.includes(guess[i])) {
|
|
33
|
+
markedCounts[guess[i]] = (markedCounts[guess[i]] || 0) + 1;
|
|
34
|
+
if (markedCounts[guess[i]] <= correctWordCounts[guess[i]]) {
|
|
35
|
+
row[i].isPresent = true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return row;
|
|
40
|
+
}
|
|
41
|
+
function createEmptyRow(wordLength) {
|
|
42
|
+
return Array.from({ length: wordLength }, () => ({
|
|
43
|
+
character: "",
|
|
44
|
+
isCorrect: false,
|
|
45
|
+
isPresent: false,
|
|
46
|
+
isLocked: false,
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Timestamp } from "firebase-admin/firestore";
|
|
2
|
+
import type { Wordle6GameStateDocumentFirestoreBase } from "../../../../types/documents/wordle6-game-state-document/wordle6-game-state-document-firestore-base.js";
|
|
3
|
+
export type Wordle6GameStateDocumentFirestore = Wordle6GameStateDocumentFirestoreBase & {
|
|
4
|
+
updated_at: Timestamp;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=wordle6-game-state-document-firestore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordle6-game-state-document-firestore.d.ts","sourceRoot":"","sources":["../../../../../../src/types/documents/wordle6-game-state-document/node/wordle6-game-state-document-firestore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,6FAA6F,CAAC;AAEzJ,MAAM,MAAM,iCAAiC,GAC3C,qCAAqC,GAAG;IACtC,UAAU,EAAE,SAAS,CAAC;CACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Timestamp } from "firebase/firestore";
|
|
2
|
+
import type { Wordle6GameStateDocumentFirestoreBase } from "../../../../types/documents/wordle6-game-state-document/wordle6-game-state-document-firestore-base.js";
|
|
3
|
+
export type Wordle6GameStateDocumentFirestore = Wordle6GameStateDocumentFirestoreBase & {
|
|
4
|
+
updated_at: Timestamp;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=wordle6-game-state-document-firestore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordle6-game-state-document-firestore.d.ts","sourceRoot":"","sources":["../../../../../../src/types/documents/wordle6-game-state-document/web/wordle6-game-state-document-firestore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,6FAA6F,CAAC;AAEzJ,MAAM,MAAM,iCAAiC,GAC3C,qCAAqC,GAAG;IACtC,UAAU,EAAE,SAAS,CAAC;CACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type Wordle6GameStateDocumentFirestoreBase = {
|
|
2
|
+
guesses: string[];
|
|
3
|
+
has_finished: boolean;
|
|
4
|
+
has_lost: boolean;
|
|
5
|
+
has_won: boolean;
|
|
6
|
+
number_of_tries_needed: number;
|
|
7
|
+
user_id: string;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=wordle6-game-state-document-firestore-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordle6-game-state-document-firestore-base.d.ts","sourceRoot":"","sources":["../../../../../src/types/documents/wordle6-game-state-document/wordle6-game-state-document-firestore-base.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qCAAqC,GAAG;IAClD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Wordle6GameStateDocument = {
|
|
2
|
+
_id: string;
|
|
3
|
+
guesses: string[];
|
|
4
|
+
has_finished: boolean;
|
|
5
|
+
has_lost: boolean;
|
|
6
|
+
has_won: boolean;
|
|
7
|
+
number_of_tries_needed: number;
|
|
8
|
+
updated_at: Date;
|
|
9
|
+
user_id: string;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=wordle6-game-state-document.d.ts.map
|
package/dist/esm/types/documents/wordle6-game-state-document/wordle6-game-state-document.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordle6-game-state-document.d.ts","sourceRoot":"","sources":["../../../../../src/types/documents/wordle6-game-state-document/wordle6-game-state-document.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAAG;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,UAAU,EAAE,IAAI,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,4 +4,8 @@ export declare const WORDLE_GAMES_COLLECTION_PATH = "wordle_games";
|
|
|
4
4
|
export declare const WORDLE_LEADERBOARD_COLLECTION_PATH = "wordle_leaderboard";
|
|
5
5
|
export declare const WORDLE_MONTHLY_SCORES_COLLECTION_PATH = "wordle_monthly_scores";
|
|
6
6
|
export declare const WORDLE_SCORES_COLLECTION_PATH = "wordle_scores";
|
|
7
|
+
export declare const WORDLE6_GAMES_COLLECTION_PATH = "wordle6_games";
|
|
8
|
+
export declare const WORDLE6_LEADERBOARD_COLLECTION_PATH = "wordle6_leaderboard";
|
|
9
|
+
export declare const WORDLE6_MONTHLY_SCORES_COLLECTION_PATH = "wordle6_monthly_scores";
|
|
10
|
+
export declare const WORDLE6_SCORES_COLLECTION_PATH = "wordle6_scores";
|
|
7
11
|
//# sourceMappingURL=collections.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../../src/constants/collections.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAC5C,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,4BAA4B,iBAAiB,CAAC;AAC3D,eAAO,MAAM,kCAAkC,uBAAuB,CAAC;AACvE,eAAO,MAAM,qCAAqC,0BAA0B,CAAC;AAC7E,eAAO,MAAM,6BAA6B,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../../src/constants/collections.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAC5C,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,4BAA4B,iBAAiB,CAAC;AAC3D,eAAO,MAAM,kCAAkC,uBAAuB,CAAC;AACvE,eAAO,MAAM,qCAAqC,0BAA0B,CAAC;AAC7E,eAAO,MAAM,6BAA6B,kBAAkB,CAAC;AAC7D,eAAO,MAAM,6BAA6B,kBAAkB,CAAC;AAC7D,eAAO,MAAM,mCAAmC,wBAAwB,CAAC;AACzE,eAAO,MAAM,sCAAsC,2BAA2B,CAAC;AAC/E,eAAO,MAAM,8BAA8B,mBAAmB,CAAC"}
|
|
@@ -4,3 +4,7 @@ export const WORDLE_GAMES_COLLECTION_PATH = "wordle_games";
|
|
|
4
4
|
export const WORDLE_LEADERBOARD_COLLECTION_PATH = "wordle_leaderboard";
|
|
5
5
|
export const WORDLE_MONTHLY_SCORES_COLLECTION_PATH = "wordle_monthly_scores";
|
|
6
6
|
export const WORDLE_SCORES_COLLECTION_PATH = "wordle_scores";
|
|
7
|
+
export const WORDLE6_GAMES_COLLECTION_PATH = "wordle6_games";
|
|
8
|
+
export const WORDLE6_LEADERBOARD_COLLECTION_PATH = "wordle6_leaderboard";
|
|
9
|
+
export const WORDLE6_MONTHLY_SCORES_COLLECTION_PATH = "wordle6_monthly_scores";
|
|
10
|
+
export const WORDLE6_SCORES_COLLECTION_PATH = "wordle6_scores";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Wordle6GameStateDocument } from "../../types/documents/wordle6-game-state-document/wordle6-game-state-document.js";
|
|
2
|
+
import { type FirestoreDataConverter } from "firebase-admin/firestore";
|
|
3
|
+
export declare const wordle6GameStateDocumentConverter: FirestoreDataConverter<Wordle6GameStateDocument>;
|
|
4
|
+
//# sourceMappingURL=wordle6-game-state-document.converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordle6-game-state-document.converter.d.ts","sourceRoot":"","sources":["../../../../src/convertors/node/wordle6-game-state-document.converter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8EAA8E,CAAC;AAC7H,OAAO,EAEL,KAAK,sBAAsB,EAI5B,MAAM,0BAA0B,CAAC;AAElC,eAAO,MAAM,iCAAiC,EAAE,sBAAsB,CAAC,wBAAwB,CAyB5F,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Timestamp, } from "firebase-admin/firestore";
|
|
2
|
+
export const wordle6GameStateDocumentConverter = {
|
|
3
|
+
toFirestore: (doc) => {
|
|
4
|
+
const { _id, ...docWithoutId } = doc;
|
|
5
|
+
return {
|
|
6
|
+
...docWithoutId,
|
|
7
|
+
updated_at: docWithoutId.updated_at instanceof Date
|
|
8
|
+
? Timestamp.fromDate(docWithoutId.updated_at)
|
|
9
|
+
: docWithoutId.updated_at,
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
fromFirestore: (snapshot) => {
|
|
13
|
+
const data = snapshot.data();
|
|
14
|
+
return {
|
|
15
|
+
_id: snapshot.id,
|
|
16
|
+
...data,
|
|
17
|
+
updated_at: data.updated_at.toDate(),
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Wordle6GameStateDocument } from "../../types/documents/wordle6-game-state-document/wordle6-game-state-document.js";
|
|
2
|
+
import { type FirestoreDataConverter } from "firebase/firestore";
|
|
3
|
+
export declare const wordle6GameStateDocumentConverter: FirestoreDataConverter<Wordle6GameStateDocument>;
|
|
4
|
+
//# sourceMappingURL=wordle6-game-state-document.converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordle6-game-state-document.converter.d.ts","sourceRoot":"","sources":["../../../../src/convertors/web/wordle6-game-state-document.converter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8EAA8E,CAAC;AAC7H,OAAO,EAEL,KAAK,sBAAsB,EAI5B,MAAM,oBAAoB,CAAC;AAE5B,eAAO,MAAM,iCAAiC,EAAE,sBAAsB,CAAC,wBAAwB,CA2B5F,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Timestamp, } from "firebase/firestore";
|
|
2
|
+
export const wordle6GameStateDocumentConverter = {
|
|
3
|
+
toFirestore: (doc) => {
|
|
4
|
+
const { _id, ...docWithoutId } = doc;
|
|
5
|
+
return {
|
|
6
|
+
...docWithoutId,
|
|
7
|
+
updated_at: docWithoutId.updated_at instanceof Date
|
|
8
|
+
? Timestamp.fromDate(docWithoutId.updated_at)
|
|
9
|
+
: docWithoutId.updated_at,
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
fromFirestore: (snapshot) => {
|
|
13
|
+
const data = snapshot.data();
|
|
14
|
+
return {
|
|
15
|
+
_id: snapshot.id,
|
|
16
|
+
...data,
|
|
17
|
+
updated_at: data.updated_at.toDate(),
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconstruct-game-state.d.ts","sourceRoot":"","sources":["../../../../src/helpers/worlde/reconstruct-game-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,uDAAuD,CAAC;AAE/D,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EAAE,EACjB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,eAAe,CAcjB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export function reconstructGameState(guesses, correctWord, maxRows) {
|
|
2
|
+
const wordLength = correctWord.length;
|
|
3
|
+
const rows = [];
|
|
4
|
+
for (const guess of guesses) {
|
|
5
|
+
const row = evaluateGuess(guess, correctWord);
|
|
6
|
+
rows.push(row);
|
|
7
|
+
}
|
|
8
|
+
while (rows.length < maxRows) {
|
|
9
|
+
rows.push(createEmptyRow(wordLength));
|
|
10
|
+
}
|
|
11
|
+
return rows;
|
|
12
|
+
}
|
|
13
|
+
function evaluateGuess(guess, correctWord) {
|
|
14
|
+
const row = Array.from({ length: guess.length }, () => ({
|
|
15
|
+
character: "",
|
|
16
|
+
isCorrect: false,
|
|
17
|
+
isLocked: true,
|
|
18
|
+
}));
|
|
19
|
+
const correctWordCounts = {};
|
|
20
|
+
for (const char of correctWord) {
|
|
21
|
+
correctWordCounts[char] = (correctWordCounts[char] || 0) + 1;
|
|
22
|
+
}
|
|
23
|
+
const markedCounts = {};
|
|
24
|
+
for (let i = 0; i < guess.length; i++) {
|
|
25
|
+
row[i].character = guess[i];
|
|
26
|
+
if (guess[i] === correctWord[i]) {
|
|
27
|
+
row[i].isCorrect = true;
|
|
28
|
+
markedCounts[guess[i]] = (markedCounts[guess[i]] || 0) + 1;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (let i = 0; i < guess.length; i++) {
|
|
32
|
+
if (!row[i].isCorrect && correctWord.includes(guess[i])) {
|
|
33
|
+
markedCounts[guess[i]] = (markedCounts[guess[i]] || 0) + 1;
|
|
34
|
+
if (markedCounts[guess[i]] <= correctWordCounts[guess[i]]) {
|
|
35
|
+
row[i].isPresent = true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return row;
|
|
40
|
+
}
|
|
41
|
+
function createEmptyRow(wordLength) {
|
|
42
|
+
return Array.from({ length: wordLength }, () => ({
|
|
43
|
+
character: "",
|
|
44
|
+
isCorrect: false,
|
|
45
|
+
isPresent: false,
|
|
46
|
+
isLocked: false,
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Timestamp } from "firebase-admin/firestore";
|
|
2
|
+
import type { Wordle6GameStateDocumentFirestoreBase } from "../../../../types/documents/wordle6-game-state-document/wordle6-game-state-document-firestore-base.js";
|
|
3
|
+
export type Wordle6GameStateDocumentFirestore = Wordle6GameStateDocumentFirestoreBase & {
|
|
4
|
+
updated_at: Timestamp;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=wordle6-game-state-document-firestore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordle6-game-state-document-firestore.d.ts","sourceRoot":"","sources":["../../../../../../src/types/documents/wordle6-game-state-document/node/wordle6-game-state-document-firestore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,6FAA6F,CAAC;AAEzJ,MAAM,MAAM,iCAAiC,GAC3C,qCAAqC,GAAG;IACtC,UAAU,EAAE,SAAS,CAAC;CACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|