@gamepark/react-client 5.6.3 → 5.7.2

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.
Files changed (47) hide show
  1. package/dist/EjectPlayer/EjectPlayerDialog.js +2 -2
  2. package/dist/EjectPlayer/EjectPlayerDialog.js.map +1 -1
  3. package/dist/GameProvider/GameContext.d.ts +16 -2
  4. package/dist/GameProvider/GameContext.js +11 -3
  5. package/dist/GameProvider/GameContext.js.map +1 -1
  6. package/dist/GameProvider/GameProvider.js +9 -83
  7. package/dist/GameProvider/GameProvider.js.map +1 -1
  8. package/dist/GameProvider/index.js +1 -3
  9. package/dist/GameProvider/index.js.map +1 -1
  10. package/dist/Menu/Menu.js +2 -2
  11. package/dist/Menu/Menu.js.map +1 -1
  12. package/dist/Sound/SoundButton.js +2 -2
  13. package/dist/Sound/SoundButton.js.map +1 -1
  14. package/dist/Sound/useSound.js +5 -8
  15. package/dist/Sound/useSound.js.map +1 -1
  16. package/dist/Tutorial/RestartTutorialButton.js +2 -5
  17. package/dist/Tutorial/RestartTutorialButton.js.map +1 -1
  18. package/dist/Types/GameData.d.ts +1 -1
  19. package/dist/Undo/useUndo.js +2 -2
  20. package/dist/Undo/useUndo.js.map +1 -1
  21. package/dist/api/Client/GameClientAPI.d.ts +3 -4
  22. package/dist/api/Client/GameClientAPI.js +14 -84
  23. package/dist/api/Client/GameClientAPI.js.map +1 -1
  24. package/dist/api/Client/GameNotificationsListener.d.ts +4 -0
  25. package/dist/api/Client/GameNotificationsListener.js +97 -0
  26. package/dist/api/Client/GameNotificationsListener.js.map +1 -0
  27. package/dist/api/Client/RemoteGameLoader.d.ts +4 -0
  28. package/dist/api/Client/RemoteGameLoader.js +34 -0
  29. package/dist/api/Client/RemoteGameLoader.js.map +1 -0
  30. package/dist/api/Client/RemoteGameProvider.d.ts +4 -0
  31. package/dist/api/Client/RemoteGameProvider.js +60 -0
  32. package/dist/api/Client/RemoteGameProvider.js.map +1 -0
  33. package/dist/api/Client/apollo-client.d.ts +2 -0
  34. package/dist/api/Client/apollo-client.js +54 -0
  35. package/dist/api/Client/apollo-client.js.map +1 -0
  36. package/dist/api/Client/game-apollo-client.d.ts +2 -0
  37. package/dist/api/Client/game-apollo-client.js +30 -0
  38. package/dist/api/Client/game-apollo-client.js.map +1 -0
  39. package/dist/api/Local/GameLocalAPI.d.ts +6 -6
  40. package/dist/api/Local/GameLocalAPI.js +34 -28
  41. package/dist/api/Local/GameLocalAPI.js.map +1 -1
  42. package/dist/api/Local/LocalGameProvider.d.ts +2 -0
  43. package/dist/api/Local/LocalGameProvider.js +48 -0
  44. package/dist/api/Local/LocalGameProvider.js.map +1 -0
  45. package/dist/datadog/DatadogLogsInitializer.js +7 -0
  46. package/dist/datadog/DatadogLogsInitializer.js.map +1 -1
  47. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"GameClientAPI.js","sourceRoot":"","sources":["../../../src/api/Client/GameClientAPI.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAqF;AACrF,mDAAiD;AACjD,wDAAyC;AAGzC,2DAAuD;AACvD,qFAAiF;AACjF,mDAA+C;AAC/C,iEAA6D;AAC7D,0DAAmC;AACnC,qCAAwC;AAOxC,mBAAM,CAAC,OAAO,CAAC,SAAS,GAAG;IACzB,IAAM,GAAG,GAAG,IAAI,cAAc,EAAU,CAAA;IACxC,GAAG,CAAC,eAAe,GAAG,IAAI,CAAA;IAC1B,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAEY,QAAA,WAAW,OAAG,YAAG,mPAAA,+KAA+K,KAAA;AAC7M,IAAM,YAAY,OAAG,YAAG,kQAAA,8LAA8L,IAAA,CAAA;AACtN,IAAM,aAAa,OAAG,YAAG,0QAAA,sMAAsM,IAAA,CAAA;AAC/N,IAAM,QAAQ,OAAG,YAAG,4UAAA,+PAAgQ,EAAY,GAAI,EAAW,EAAE,KAA7B,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CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,EAAE;gBACjC,wJAAwJ;gBACxJ,KAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;aAClD;YACD,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAkC,CAAA;QAC9E,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,6BAAK,GAAL,UAAM,QAAkB;QAAxB,iBAGC;QAFC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAyC,EAAC,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,EAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,UAAA,EAAC,EAAC,CAAC;aACnI,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,MAAM,CAAC,IAAI,IAAI,KAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAApE,CAAoE,CAAC,CAAA;IACzF,CAAC;IAED,8BAAM,GAAN;QAAA,iBAGC;QAFC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAoC,EAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,EAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAC,EAAC,CAAC;aAC/G,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,MAAM,CAAC,IAAI,IAAI,KAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAA/D,CAA+D,CAAC,CAAA;IACpF,CAAC;IAYD,yCAAiB,GAAjB;QACE,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAA;IAChE,CAAC;IACH,oBAAC;AAAD,CAAC,AA3HD,IA2HC"}
@@ -0,0 +1,4 @@
1
+ export default function GameNotificationsListener({ gameId, channelName }: {
2
+ gameId: string;
3
+ channelName?: string;
4
+ }): any;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
13
+ });
14
+ };
15
+ var __generator = (this && this.__generator) || function (thisArg, body) {
16
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
17
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
18
+ function verb(n) { return function (v) { return step([n, v]); }; }
19
+ function step(op) {
20
+ if (f) throw new TypeError("Generator is already executing.");
21
+ while (_) try {
22
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
23
+ if (y = 0, t) op = [op[0] & 2, t.value];
24
+ switch (op[0]) {
25
+ case 0: case 1: t = op; break;
26
+ case 4: _.label++; return { value: op[1], done: false };
27
+ case 5: _.label++; y = op[1]; op = [0]; continue;
28
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
29
+ default:
30
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
31
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
32
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
33
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
34
+ if (t[2]) _.ops.pop();
35
+ _.trys.pop(); continue;
36
+ }
37
+ op = body.call(thisArg, _);
38
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
39
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
40
+ }
41
+ };
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ var client_1 = require("@apollo/client");
44
+ var use_pusher_1 = require("@harelpls/use-pusher");
45
+ var react_1 = require("react");
46
+ var react_redux_1 = require("react-redux");
47
+ var GameNotificationsReceived_1 = require("../../Actions/GameNotificationsReceived");
48
+ var GameOver_1 = require("../../Actions/GameOver");
49
+ var game_apollo_client_1 = require("./game-apollo-client");
50
+ var GameClientAPI_1 = require("./GameClientAPI");
51
+ var GET_NOTIFICATIONS = (0, client_1.gql)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n query GameNotifications($gameId: String!, $start: Int) {\n time\n gameNotifications(gameId: $gameId, start: $start) { ...Notifications }\n game(id: $gameId) {\n players { id ...PlayerTime }\n }\n } ", " ", "\n"], ["\n query GameNotifications($gameId: String!, $start: Int) {\n time\n gameNotifications(gameId: $gameId, start: $start) { ...Notifications }\n game(id: $gameId) {\n players { id ...PlayerTime }\n }\n } ", " ", "\n"])), GameClientAPI_1.NOTIFICATIONS, GameClientAPI_1.PLAYERS_TIME);
52
+ function GameNotificationsListener(_a) {
53
+ var _this = this;
54
+ var gameId = _a.gameId, _b = _a.channelName, channelName = _b === void 0 ? "game=" + gameId : _b;
55
+ var channel = (0, use_pusher_1.useChannel)(channelName);
56
+ var dispatch = (0, react_redux_1.useDispatch)();
57
+ var notification = (0, react_1.useRef)(0);
58
+ (0, use_pusher_1.useEvent)(channel, 'pusher:subscription_error', function (error) { return console.error('pusher subscription failed', error); });
59
+ (0, use_pusher_1.useEvent)(channel, 'pusher:subscription_succeeded', function () { return __awaiter(_this, void 0, void 0, function () {
60
+ var start, data;
61
+ return __generator(this, function (_a) {
62
+ switch (_a.label) {
63
+ case 0:
64
+ start = notification.current;
65
+ return [4 /*yield*/, (0, game_apollo_client_1.getGameApolloClient)().query({
66
+ query: GET_NOTIFICATIONS,
67
+ variables: { gameId: gameId, start: start }
68
+ })];
69
+ case 1:
70
+ data = (_a.sent()).data;
71
+ if (!data)
72
+ return [2 /*return*/, console.error('Failed to collect game data')];
73
+ dispatch((0, GameNotificationsReceived_1.gameNotificationsReceived)(data.gameNotifications, start, data.game.players, data.time));
74
+ if (data.gameNotifications.length > 0) {
75
+ notification.current = Math.max(notification.current, start + data.gameNotifications.length);
76
+ }
77
+ return [2 /*return*/];
78
+ }
79
+ });
80
+ }); });
81
+ (0, use_pusher_1.useEvent)(channel, 'moves-played', function (message) {
82
+ if (!message)
83
+ return;
84
+ var index = message.index, notifications = message.notifications, players = message.players, date = message.date;
85
+ dispatch((0, GameNotificationsReceived_1.gameNotificationsReceived)(notifications, index, players, Date.parse(date)));
86
+ notification.current = Math.max(notification.current, index + notifications.length);
87
+ });
88
+ (0, use_pusher_1.useEvent)(channel, 'game-over', function (players) {
89
+ if (players) {
90
+ dispatch((0, GameOver_1.gameOver)(players));
91
+ }
92
+ });
93
+ return null;
94
+ }
95
+ exports.default = GameNotificationsListener;
96
+ var templateObject_1;
97
+ //# sourceMappingURL=GameNotificationsListener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GameNotificationsListener.js","sourceRoot":"","sources":["../../../src/api/Client/GameNotificationsListener.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAkC;AAClC,mDAAyD;AACzD,+BAA4B;AAC5B,2CAAuC;AACvC,qFAAiF;AACjF,mDAA+C;AAI/C,2DAAwD;AACxD,iDAA2D;AAE3D,IAAM,iBAAiB,OAAG,YAAG,6SAAA,8NAOvB,EAAa,GAAI,EAAY,IAClC,KADK,6BAAa,EA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;;SACF,CAAC,CAAA;IAEF,IAAA,qBAAQ,EAAc,OAAO,EAAE,cAAc,EAAE,UAAC,OAAO;QACrD,IAAI,CAAC,OAAO;YAAE,OAAM;QACb,IAAA,KAAK,GAAkC,OAAO,MAAzC,EAAE,aAAa,GAAmB,OAAO,cAA1B,EAAE,OAAO,GAAU,OAAO,QAAjB,EAAE,IAAI,GAAI,OAAO,KAAX,CAAW;QACrD,QAAS,CAAC,IAAA,qDAAyB,EAAC,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACrF,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA;IACrF,CAAC,CAAC,CAAA;IAEF,IAAA,qBAAQ,EAAyC,OAAO,EAAE,WAAW,EAAE,UAAC,OAAO;QAC7E,IAAI,OAAO,EAAE;YACX,QAAS,CAAC,IAAA,mBAAQ,EAAC,OAAO,CAAC,CAAC,CAAA;SAC7B;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,IAAI,CAAA;AACb,CAAC;AAlCD,4CAkCC"}
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ export default function RemoteGameLoader({ gameId }: {
3
+ gameId: string;
4
+ }): JSX.Element;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ var jsx_runtime_1 = require("react/jsx-runtime");
11
+ var client_1 = require("@apollo/client");
12
+ var react_redux_1 = require("react-redux");
13
+ var GameStateLoaded_1 = require("../../Actions/GameStateLoaded");
14
+ var GameClientAPI_1 = require("./GameClientAPI");
15
+ var GameNotificationsListener_1 = __importDefault(require("./GameNotificationsListener"));
16
+ var GET_GAME = (0, client_1.gql)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n query Game($id: String!) {\n time\n game(id: $id) {\n players {\n id userId name avatar {...AvatarInfo} gamePointsDelta ...PlayerTime\n }\n options {\n speed maxSpareTime maxExceedTime\n }\n notificationsChannel notificationsCount mode setup state myPlayerId endDate\n }\n } ", " ", "\n"], ["\n query Game($id: String!) {\n time\n game(id: $id) {\n players {\n id userId name avatar {...AvatarInfo} gamePointsDelta ...PlayerTime\n }\n options {\n speed maxSpareTime maxExceedTime\n }\n notificationsChannel notificationsCount mode setup state myPlayerId endDate\n }\n } ", " ", "\n"])), GameClientAPI_1.PLAYERS_TIME, GameClientAPI_1.AVATAR_INFO);
17
+ function RemoteGameLoader(_a) {
18
+ var gameId = _a.gameId;
19
+ var dispatch = (0, react_redux_1.useDispatch)();
20
+ var data = (0, client_1.useQuery)(GET_GAME, {
21
+ variables: { id: gameId },
22
+ onCompleted: function (_a) {
23
+ var game = _a.game, time = _a.time;
24
+ return dispatch((0, GameStateLoaded_1.gameStateLoaded)(game, time));
25
+ }
26
+ }).data;
27
+ if (!data)
28
+ return null;
29
+ else
30
+ return (0, jsx_runtime_1.jsx)(GameNotificationsListener_1.default, { channelName: data.game.notificationsChannel, gameId: gameId }, void 0);
31
+ }
32
+ exports.default = RemoteGameLoader;
33
+ var templateObject_1;
34
+ //# sourceMappingURL=RemoteGameLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RemoteGameLoader.js","sourceRoot":"","sources":["../../../src/api/Client/RemoteGameLoader.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,yCAA4C;AAC5C,2CAAuC;AACvC,iEAA6D;AAE7D,iDAAyD;AACzD,0FAAmE;AAEnE,IAAM,QAAQ,OAAG,YAAG,yZAAA,0UAYd,EAAY,GAAI,EAAW,IAChC,KADK,4BAAY,EAAI,2BAAW,CAChC,CAAA;AAED,SAAwB,gBAAgB,CAAC,EAA4B;QAA3B,MAAM,YAAA;IAC9C,IAAM,QAAQ,GAAG,IAAA,yBAAW,GAAE,CAAA;IACvB,IAAA,IAAI,GAAI,IAAA,iBAAQ,EAAmC,QAAQ,EAAE;QAClE,SAAS,EAAE,EAAC,EAAE,EAAE,MAAM,EAAC;QACvB,WAAW,EAAE,UAAC,EAAY;gBAAX,IAAI,UAAA,EAAE,IAAI,UAAA;YAAM,OAAA,QAAQ,CAAC,IAAA,iCAAe,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAArC,CAAqC;KACrE,CAAC,KAHS,CAGT;IACF,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;;QACjB,OAAO,uBAAC,mCAAyB,IAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,MAAM,EAAE,MAAM,WAAG,CAAA;AACvG,CAAC;AARD,mCAQC"}
@@ -0,0 +1,4 @@
1
+ import { PropsWithChildren } from 'react';
2
+ export default function RemoteGameProvider({ children, gameId }: PropsWithChildren<{
3
+ gameId: string;
4
+ }>): JSX.Element;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ var _a, _b, _c;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ var jsx_runtime_1 = require("react/jsx-runtime");
19
+ var client_1 = require("@apollo/client");
20
+ var use_pusher_1 = require("@harelpls/use-pusher");
21
+ var pusher_js_1 = __importDefault(require("pusher-js"));
22
+ var react_1 = require("react");
23
+ var react_redux_1 = require("react-redux");
24
+ var redux_1 = require("redux");
25
+ var AnimationsListenerCreator_1 = require("../../animations/AnimationsListenerCreator");
26
+ var GameContext_1 = require("../../GameProvider/GameContext");
27
+ var index_1 = require("../../index");
28
+ var gameMiddleware_1 = __importDefault(require("../../Store/gameMiddleware"));
29
+ var gameReducer_1 = __importDefault(require("../../Store/gameReducer"));
30
+ var apollo_client_1 = require("./apollo-client");
31
+ var GameClientAPI_1 = __importDefault(require("./GameClientAPI"));
32
+ var RemoteGameLoader_1 = __importDefault(require("./RemoteGameLoader"));
33
+ pusher_js_1.default.logToConsole = true;
34
+ pusher_js_1.default.Runtime.createXHR = function () {
35
+ var xhr = new XMLHttpRequest();
36
+ xhr.withCredentials = true;
37
+ return xhr;
38
+ };
39
+ var authEndpoint = index_1.PLATFORM_URI + ((_a = process.env.REACT_APP_PUSHER_ENDPOINT) !== null && _a !== void 0 ? _a : '/api/pusher/auth');
40
+ var clientKey = (_b = process.env.REACT_APP_PUSHER_KEY) !== null && _b !== void 0 ? _b : '747557f1e8edf7fc2816';
41
+ var cluster = (_c = process.env.REACT_APP_PUSHER_CLUSTER) !== null && _c !== void 0 ? _c : 'eu';
42
+ function RemoteGameProvider(_a) {
43
+ var children = _a.children, gameId = _a.gameId;
44
+ var context = (0, react_1.useContext)(GameContext_1.gameContext);
45
+ var store = (0, react_1.useMemo)(function () { return createRemoteApiStore(context, gameId); }, []);
46
+ return ((0, jsx_runtime_1.jsx)(client_1.ApolloProvider, __assign({ client: (0, apollo_client_1.getApolloClient)() }, { children: (0, jsx_runtime_1.jsx)(use_pusher_1.PusherProvider, __assign({ authEndpoint: authEndpoint, clientKey: clientKey, cluster: cluster }, { children: (0, jsx_runtime_1.jsxs)(react_redux_1.Provider, __assign({ store: store }, { children: [(0, jsx_runtime_1.jsx)(RemoteGameLoader_1.default, { gameId: gameId }, void 0), children] }), void 0) }), void 0) }), void 0));
47
+ }
48
+ exports.default = RemoteGameProvider;
49
+ function createRemoteApiStore(context, gameId) {
50
+ var _a;
51
+ var api = new GameClientAPI_1.default(gameId);
52
+ var reducer = context.RulesView ?
53
+ (0, gameReducer_1.default)(context.game, (_a = context.RulesView) !== null && _a !== void 0 ? _a : context.Rules, context.animations)
54
+ : (0, gameReducer_1.default)(context.game, context.Rules, context.animations);
55
+ var store = (0, redux_1.createStore)(reducer, (0, redux_1.applyMiddleware)((0, gameMiddleware_1.default)(api)));
56
+ store.subscribe((0, AnimationsListenerCreator_1.createAnimationsListener)(store));
57
+ api.init(store.dispatch);
58
+ return store;
59
+ }
60
+ //# sourceMappingURL=RemoteGameProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RemoteGameProvider.js","sourceRoot":"","sources":["../../../src/api/Client/RemoteGameProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,yCAA6C;AAC7C,mDAAmD;AACnD,wDAA8B;AAE9B,+BAA4D;AAC5D,2CAAoC;AACpC,+BAA2D;AAC3D,wFAAmF;AACnF,8DAAuE;AACvE,qCAAwC;AACxC,8EAAuD;AACvD,wEAAiD;AACjD,iDAA+C;AAC/C,kEAA2C;AAC3C,wEAAiD;AAEjD,mBAAM,CAAC,YAAY,GAAG,IAAI,CAAA;AAE1B,mBAAM,CAAC,OAAO,CAAC,SAAS,GAAG;IACzB,IAAM,GAAG,GAAG,IAAI,cAAc,EAAU,CAAA;IACxC,GAAG,CAAC,eAAe,GAAG,IAAI,CAAA;IAC1B,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,IAAM,YAAY,GAAG,oBAAY,GAAG,CAAC,MAAA,OAAO,CAAC,GAAG,CAAC,yBAAyB,mCAAI,kBAAkB,CAAC,CAAA;AACjG,IAAM,SAAS,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,oBAAoB,mCAAI,sBAAsB,CAAA;AAC5E,IAAM,OAAO,GAAG,MAAA,OAAO,C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CAAC,CAAA;IAChD,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IACxB,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ApolloClient } from '@apollo/client';
2
+ export declare function getApolloClient(): ApolloClient<any>;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getApolloClient = void 0;
16
+ var client_1 = require("@apollo/client");
17
+ var moment_1 = __importDefault(require("moment"));
18
+ var index_1 = require("../../index");
19
+ var apolloClient;
20
+ function getApolloClient() {
21
+ if (!apolloClient) {
22
+ apolloClient = initApolloClient();
23
+ }
24
+ return apolloClient;
25
+ }
26
+ exports.getApolloClient = getApolloClient;
27
+ function initApolloClient() {
28
+ var _a;
29
+ return new client_1.ApolloClient({
30
+ link: client_1.ApolloLink.from([new client_1.HttpLink({ uri: index_1.PLATFORM_URI + ((_a = process.env.REACT_APP_GRAPHQL_ENDPOINT) !== null && _a !== void 0 ? _a : '/api/graphql'), fetch: fetch, credentials: 'include' })]),
31
+ cache: new client_1.InMemoryCache({
32
+ typePolicies: {
33
+ ChatChannel: {
34
+ keyFields: ['name'],
35
+ fields: {
36
+ messages: {
37
+ keyArgs: false,
38
+ merge: function (existing, incoming) {
39
+ if (existing === void 0) { existing = []; }
40
+ if (incoming === void 0) { incoming = []; }
41
+ return __spreadArray(__spreadArray([], incoming, true), existing, true).sort(function (m1, m2) { return (0, moment_1.default)(m1.date).unix() - (0, moment_1.default)(m2.date).unix(); })
42
+ .filter(function (message, index, messages) { return index === 0 || message.id !== messages[index - 1].id; });
43
+ }
44
+ }
45
+ }
46
+ },
47
+ Message: {
48
+ keyFields: false
49
+ }
50
+ }
51
+ })
52
+ });
53
+ }
54
+ //# sourceMappingURL=apollo-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apollo-client.js","sourceRoot":"","sources":["../../../src/api/Client/apollo-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAAgF;AAChF,kDAA2B;AAE3B,qCAAwC;AAExC,IAAI,YAA2C,CAAA;AAE/C,SAAgB,eAAe;IAC7B,IAAI,CAAC,YAAY,EAAE;QACjB,YAAY,GAAG,gBAAgB,EAAE,CAAA;KAClC;IACD,OAAO,YAAY,CAAA;AACrB,CAAC;AALD,0CAKC;AAED,SAAS,gBAAgB;;IACvB,OAAO,IAAI,qBAAY,CAAC;QACtB,IAAI,EAAE,mBAAU,CAAC,IAAI,CAAC,CAAC,IAAI,iBAAQ,CAAC,EAAC,GAAG,EAAE,oBAAY,GAAG,CAAC,MAAA,OAAO,CAAC,GAAG,CAAC,0BAA0B,mCAAI,cAAc,CAAC,EAAE,KAAK,OAAA,EAAE,WAAW,EAAE,SAAS,EAAC,CAAC,CAAC,CAAC;QACtJ,KAAK,EAAE,IAAI,sBAAa,CAAC;YACvB,YAAY,EAAE;gBACZ,WAAW,EAAE;oBACX,SAAS,EAAE,CAAC,MAAM,CAAC;oBACnB,MAAM,EAAE;wBACN,QAAQ,EAAE;4BACR,OAAO,EAAE,KAAK;4BACd,KAAK,EAAL,UAAM,QAAwB,EAAE,QAAwB;gCAAlD,yBAAA,EAAA,aAAwB;gCAAE,yBAAA,EAAA,aAAwB;gCACtD,OAAO,gCAAI,QAAQ,SAAK,QAAQ,QAC7B,IAAI,CAAC,UAAC,EAAE,EAAE,EAAE,IAAK,OAAA,IAAA,gBAAM,EAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,GAAG,IAAA,gBAAM,EAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAA/C,CAA+C,CAAC;qCACjE,MAAM,CAAC,UAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,IAAK,OAAA,KAAK,KAAK,CAAC,IAAI,OAAO,CAAC,EAAE,KAAK,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,EAApD,CAAoD,CAAC,CAAA;4BAC/F,CAAC;yBACF;qBACF;iBACF;gBACD,OAAO,EAAE;oBACP,SAAS,EAAE,KAAK;iBACjB;aACF;SACF,CAAC;KACH,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ApolloClient } from '@apollo/client';
2
+ export declare function getGameApolloClient(): ApolloClient<any>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGameApolloClient = void 0;
4
+ var client_1 = require("@apollo/client");
5
+ var index_1 = require("../../index");
6
+ var gameApolloClient;
7
+ function getGameApolloClient() {
8
+ if (!gameApolloClient) {
9
+ gameApolloClient = initGameApolloClient();
10
+ }
11
+ return gameApolloClient;
12
+ }
13
+ exports.getGameApolloClient = getGameApolloClient;
14
+ // Hotfix for GameNotification inheritance bug
15
+ function initGameApolloClient() {
16
+ var _a;
17
+ return new client_1.ApolloClient({
18
+ link: client_1.ApolloLink.from([new client_1.HttpLink({ uri: index_1.PLATFORM_URI + ((_a = process.env.REACT_APP_GRAPHQL_ENDPOINT) !== null && _a !== void 0 ? _a : '/api/graphql'), fetch: fetch, credentials: 'include' })]),
19
+ cache: new client_1.InMemoryCache(),
20
+ defaultOptions: {
21
+ watchQuery: {
22
+ fetchPolicy: 'no-cache'
23
+ },
24
+ query: {
25
+ fetchPolicy: 'no-cache' // TODO: configure fragment matchers for Interface types and re-enable caching
26
+ }
27
+ }
28
+ });
29
+ }
30
+ //# sourceMappingURL=game-apollo-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-apollo-client.js","sourceRoot":"","sources":["../../../src/api/Client/game-apollo-client.ts"],"names":[],"mappings":";;;AAAA,yCAAgF;AAChF,qCAAwC;AAExC,IAAI,gBAA+C,CAAA;AAEnD,SAAgB,mBAAmB;IACjC,IAAI,CAAC,gBAAgB,EAAE;QACrB,gBAAgB,GAAG,oBAAoB,EAAE,CAAA;KAC1C;IACD,OAAO,gBAAgB,CAAA;AACzB,CAAC;AALD,kDAKC;AAED,8CAA8C;AAC9C,SAAS,oBAAoB;;IAC3B,OAAO,IAAI,qBAAY,CAAC;QACtB,IAAI,EAAE,mBAAU,CAAC,IAAI,CAAC,CAAC,IAAI,iBAAQ,CAAC,EAAC,GAAG,EAAE,oBAAY,GAAG,CAAC,MAAA,OAAO,CAAC,GAAG,CAAC,0BAA0B,mCAAI,cAAc,CAAC,EAAE,KAAK,OAAA,EAAE,WAAW,EAAE,SAAS,EAAC,CAAC,CAAC,CAAC;QACtJ,KAAK,EAAE,IAAI,sBAAa,EAAE;QAC1B,cAAc,EAAE;YACd,UAAU,EAAE;gBACV,WAAW,EAAE,UAAU;aACxB;YACD,KAAK,EAAE;gBACL,WAAW,EAAE,UAAU,CAAC,8EAA8E;aACvG;SACF;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -1,16 +1,15 @@
1
1
  import { GameCreator, OptionsSpec, Robot, Rules, RulesCreator } from '@gamepark/rules-api';
2
2
  import { Dispatch } from 'redux';
3
- import { TutorialDescription } from '../../Tutorial';
4
- import GameAI from '../../Types/GameAI';
3
+ import { GameContext } from '../../GameProvider';
5
4
  import GameNotification from '../../Types/GameNotification';
6
5
  import ProxyGameData from '../../Types/ProxyGameData';
7
6
  import GameAPI from '../GameAPI';
8
7
  export default class GameLocalAPI<State, Move = string, PlayerId = number, View = State, MoveView = Move, Options extends {
9
8
  players: any;
10
9
  } | undefined = undefined> implements GameAPI<Move, PlayerId> {
11
- gameName: string;
12
- Game: RulesCreator<State, Move, PlayerId, Options>;
13
- GameView: GameCreator<View, MoveView>;
10
+ game: string;
11
+ Rules: RulesCreator<State, Move, PlayerId, Options>;
12
+ RulesView: GameCreator<View, MoveView>;
14
13
  dummy: Robot<State, Move, PlayerId>;
15
14
  optionsSpec?: OptionsSpec<Options>;
16
15
  private readonly ai;
@@ -20,7 +19,8 @@ export default class GameLocalAPI<State, Move = string, PlayerId = number, View
20
19
  private autoPlayersCounter;
21
20
  private aiProcessing;
22
21
  private tutorialMovesToPlay;
23
- constructor(gameName: string, rules: RulesCreator<State, Move, PlayerId, Options>, gameViewCreator: GameCreator<View, MoveView>, dummy: Robot<State, Move, PlayerId>, optionsSpec?: OptionsSpec<Options>, ai?: GameAI<State, Move, PlayerId>, tutorial?: TutorialDescription<State, Move, PlayerId>);
22
+ constructor(context: GameContext<State, View, Move, MoveView, PlayerId>);
23
+ createDummy<State, Move, PlayerId>(Rules: RulesCreator<State, Move, PlayerId>): Robot<State, Move, PlayerId>;
24
24
  init(dispatch: Dispatch): void;
25
25
  getNotifications(data: ProxyGameData<State, MoveView, PlayerId>): GameNotification<PlayerId>[];
26
26
  newTutorial(): ProxyGameData;
@@ -53,23 +53,29 @@ var MoveUndoneNotification_1 = require("../../Types/MoveUndoneNotification");
53
53
  var RematchNotification_1 = require("../../Types/RematchNotification");
54
54
  var ArrayUtil_1 = require("../../util/ArrayUtil");
55
55
  var GameLocalAPI = /** @class */ (function () {
56
- function GameLocalAPI(gameName, rules, gameViewCreator, dummy, optionsSpec, ai, tutorial) {
56
+ function GameLocalAPI(context) {
57
+ var _a, _b;
57
58
  this.notificationsCount = 0;
58
59
  this.autoPlayersCounter = 0;
59
60
  this.aiProcessing = false;
60
61
  this.tutorialMovesToPlay = 0;
61
- this.gameName = gameName;
62
- this.Game = rules;
63
- this.GameView = gameViewCreator;
64
- this.dummy = dummy;
65
- this.optionsSpec = optionsSpec;
66
- this.ai = ai || dummy;
67
- this.tutorial = tutorial;
62
+ Object.assign(context);
63
+ this.game = context.game;
64
+ this.Rules = context.Rules;
65
+ this.RulesView = (_a = context.RulesView) !== null && _a !== void 0 ? _a : context.Rules;
66
+ this.dummy = (_b = context.dummy) !== null && _b !== void 0 ? _b : this.createDummy(context.Rules);
67
+ this.optionsSpec = context.optionsSpec;
68
+ this.ai = context.ai || this.dummy;
69
+ this.tutorial = context.tutorial;
68
70
  }
71
+ GameLocalAPI.prototype.createDummy = function (Rules) {
72
+ var dummy = new rules_api_1.Dummy(Rules);
73
+ return function (state, playerId) { return dummy.getRandomMove(state, playerId); };
74
+ };
69
75
  GameLocalAPI.prototype.init = function (dispatch) {
70
76
  var _this = this;
71
77
  this.dispatch = dispatch;
72
- var localStore = localStorage.getItem(this.gameName);
78
+ var localStore = localStorage.getItem(this.game);
73
79
  var animationsSpeed = parseFloat(localStorage.getItem('animationsSpeed') || '1');
74
80
  this.dispatch((0, SetAnimationsSpeed_1.setAnimationsSpeed)(animationsSpeed));
75
81
  var data = localStore ? JSON.parse(localStore) : this.tutorial ? this.newTutorial() : this.newGame();
@@ -79,11 +85,11 @@ var GameLocalAPI = /** @class */ (function () {
79
85
  players: data.players, options: { speed: rules_api_1.GameSpeed.Disabled, maxSpareTime: 0, maxExceedTime: 0 },
80
86
  mode: data.tutorial ? GameMode_1.default.TUTORIAL : GameMode_1.default.FRIENDLY, notificationsChannel: ''
81
87
  };
82
- var initialGame = new this.Game(data.setup);
88
+ var initialGame = new this.Rules(data.setup);
83
89
  if ((0, rules_api_1.hasIncompleteInformation)(initialGame)) {
84
90
  dataToTransfer.setup = verifyNonMutation(function () { return (0, rules_api_1.getGameView)(initialGame, data.playerId); }, function () { return initialGame.state; }, 'getView must not change the game state');
85
91
  }
86
- var game = new this.Game(data.state);
92
+ var game = new this.Rules(data.state);
87
93
  if ((0, rules_api_1.hasIncompleteInformation)(game)) {
88
94
  dataToTransfer.state = verifyNonMutation(function () { return (0, rules_api_1.getGameView)(game, data.playerId); }, function () { return game.state; }, 'getView must not change the game state');
89
95
  }
@@ -93,9 +99,9 @@ var GameLocalAPI = /** @class */ (function () {
93
99
  });
94
100
  };
95
101
  GameLocalAPI.prototype.getNotifications = function (data) {
96
- var game = new this.Game(data.setup);
102
+ var game = new this.Rules(data.setup);
97
103
  if ((0, rules_api_1.hasIncompleteInformation)(game)) {
98
- var clientGame = new this.GameView(JSON.parse(JSON.stringify((0, rules_api_1.getGameView)(game, data.playerId))));
104
+ var clientGame = new this.RulesView(JSON.parse(JSON.stringify((0, rules_api_1.getGameView)(game, data.playerId))));
99
105
  var notifications = [];
100
106
  var _loop_1 = function (action) {
101
107
  var moveView = verifyNonMutation(function () { return (0, rules_api_1.getMoveView)(game, JSON.parse(JSON.stringify(action.move)), data.playerId); }, function () { return game.state; }, 'getMoveView must not change the state of the game');
@@ -136,7 +142,7 @@ var GameLocalAPI = /** @class */ (function () {
136
142
  throw new Error('Pass a Tutorial in the options of createGameStore first');
137
143
  }
138
144
  var _a = this.tutorial.setupTutorial(), state = _a[0], playerIds = _a[1];
139
- return this.initGameStore(new this.Game(state), playerIds, true); // TODO: tutorial extends Rules?
145
+ return this.initGameStore(new this.Rules(state), playerIds, true); // TODO: tutorial extends Rules?
140
146
  };
141
147
  GameLocalAPI.prototype.newGame = function (arg) {
142
148
  var _a;
@@ -144,7 +150,7 @@ var GameLocalAPI = /** @class */ (function () {
144
150
  if (typeof arg === 'number') {
145
151
  var playerIds = (0, rules_api_1.providePlayerIds)(arg, this.optionsSpec);
146
152
  var options = (this.optionsSpec && (0, rules_api_1.isWithPlayerIdOptions)(this.optionsSpec) ? { players: playerIds.map(function (id) { return ({ id: id }); }) } : { players: arg });
147
- return this.initGameStore(new this.Game(options), playerIds);
153
+ return this.initGameStore(new this.Rules(options), playerIds);
148
154
  }
149
155
  else {
150
156
  var playerIds = (0, rules_api_1.providePlayerIds)((_a = arg.players) !== null && _a !== void 0 ? _a : 2, this.optionsSpec);
@@ -156,7 +162,7 @@ var GameLocalAPI = /** @class */ (function () {
156
162
  else {
157
163
  arg.players = playerIds.map(function (id) { return ({ id: id }); });
158
164
  }
159
- return this.initGameStore(new this.Game(arg), playerIds);
165
+ return this.initGameStore(new this.Rules(arg), playerIds);
160
166
  }
161
167
  };
162
168
  GameLocalAPI.prototype.initGameStore = function (game, playerIds, tutorial) {
@@ -166,17 +172,17 @@ var GameLocalAPI = /** @class */ (function () {
166
172
  (0, rules_api_1.applyAutomaticMoves)(game);
167
173
  var setup = JSON.parse(JSON.stringify(game.state));
168
174
  var localStore = { players: players, setup: setup, state: game.state, actions: [], playerId: playerId, monkeyOpponents: tutorial, tutorial: tutorial };
169
- localStorage.setItem(this.gameName, JSON.stringify(localStore));
175
+ localStorage.setItem(this.game, JSON.stringify(localStore));
170
176
  return localStore;
171
177
  };
172
178
  GameLocalAPI.prototype.getLocalStore = function () {
173
- return JSON.parse(localStorage.getItem(this.gameName));
179
+ return JSON.parse(localStorage.getItem(this.game));
174
180
  };
175
181
  GameLocalAPI.prototype.play = function (move) {
176
182
  var _this = this;
177
183
  return mimicDataTransfer(move).then(function (move) {
178
184
  var localStore = _this.getLocalStore();
179
- var game = new _this.Game(localStore.state); // TODO: this.tutorial?
185
+ var game = new _this.Rules(localStore.state); // TODO: this.tutorial?
180
186
  if (!game.isLegalMove(localStore.playerId, move)) {
181
187
  console.error('This move is not authorized right now: ' + JSON.stringify(move));
182
188
  return;
@@ -202,7 +208,7 @@ var GameLocalAPI = /** @class */ (function () {
202
208
  var _a;
203
209
  var _this = this;
204
210
  var localStore = this.getLocalStore();
205
- var game = new this.Game(localStore.state); // TODO: this.tutorial?
211
+ var game = new this.Rules(localStore.state); // TODO: this.tutorial?
206
212
  var actions = [];
207
213
  var notifications = [];
208
214
  if ((0, rules_api_1.hasIncompleteInformation)(game)) {
@@ -228,7 +234,7 @@ var GameLocalAPI = /** @class */ (function () {
228
234
  return _this.dispatch((0, GameNotificationsReceived_1.gameNotificationsReceived)(data.notifications, data.index, localStore.players));
229
235
  });
230
236
  (_a = localStore.actions).push.apply(_a, actions);
231
- localStorage.setItem(this.gameName, JSON.stringify(localStore));
237
+ localStorage.setItem(this.game, JSON.stringify(localStore));
232
238
  setTimeout(function () { return _this.runAutoPlayers(); }, 100 + Math.random() * 100);
233
239
  };
234
240
  GameLocalAPI.prototype.incrementNotificationsCount = function (quantity) {
@@ -269,32 +275,32 @@ var GameLocalAPI = /** @class */ (function () {
269
275
  return Promise.reject(new Error('Trying to UNDO a move while it is forbidden'));
270
276
  }
271
277
  localStore.actions.splice(index, 1);
272
- var game = new this.Game(JSON.parse(JSON.stringify(localStore.setup)));
278
+ var game = new this.Rules(JSON.parse(JSON.stringify(localStore.setup)));
273
279
  (0, rules_api_1.replayActions)(game, localStore.actions);
274
280
  localStore.state = game.state;
275
281
  mimicDataTransfer({ notification: (0, MoveUndoneNotification_1.moveUndoneNotification)(action.playerId, index), index: this.incrementNotificationsCount() }).then(function (data) {
276
282
  return _this.dispatch((0, GameNotificationsReceived_1.gameNotificationsReceived)([data.notification], data.index, localStore.players));
277
283
  });
278
- localStorage.setItem(this.gameName, JSON.stringify(localStore));
284
+ localStorage.setItem(this.game, JSON.stringify(localStore));
279
285
  return Promise.resolve();
280
286
  };
281
287
  GameLocalAPI.prototype.canUndoAction = function (index) {
282
288
  var localStore = this.getLocalStore();
283
289
  var action = localStore.actions[index];
284
- var game = new this.Game(localStore.state);
290
+ var game = new this.Rules(localStore.state);
285
291
  return (0, rules_api_1.hasUndo)(game) && game.canUndo(action, localStore.actions.slice(index + 1));
286
292
  };
287
293
  GameLocalAPI.prototype.startMonkeyOpponents = function () {
288
294
  var localStore = this.getLocalStore();
289
295
  localStore.monkeyOpponents = true;
290
- localStorage.setItem(this.gameName, JSON.stringify(localStore));
296
+ localStorage.setItem(this.game, JSON.stringify(localStore));
291
297
  this.autoPlayersCounter = 0;
292
298
  this.runAutoPlayers();
293
299
  };
294
300
  GameLocalAPI.prototype.stopMonkeyOpponents = function () {
295
301
  var localStore = this.getLocalStore();
296
302
  localStore.monkeyOpponents = false;
297
- localStorage.setItem(this.gameName, JSON.stringify(localStore));
303
+ localStorage.setItem(this.game, JSON.stringify(localStore));
298
304
  };
299
305
  GameLocalAPI.prototype.runAutoPlayers = function () {
300
306
  return __awaiter(this, void 0, void 0, function () {
@@ -307,7 +313,7 @@ var GameLocalAPI = /** @class */ (function () {
307
313
  return [2 /*return*/];
308
314
  }
309
315
  localStore = this.getLocalStore();
310
- game = new this.Game(localStore.state);
316
+ game = new this.Rules(localStore.state);
311
317
  if (game.isOver()) {
312
318
  console.info('Game is over');
313
319
  return [2 /*return*/];
@@ -370,7 +376,7 @@ var GameLocalAPI = /** @class */ (function () {
370
376
  throw new Error('Player not found');
371
377
  }
372
378
  player.name = name;
373
- localStorage.setItem(this.gameName, JSON.stringify(localStore));
379
+ localStorage.setItem(this.game, JSON.stringify(localStore));
374
380
  };
375
381
  GameLocalAPI.prototype.setAnimationsSpeed = function (speed) {
376
382
  if (speed === void 0) { speed = 1; }