@gamepark/react-client 5.7.2 → 5.8.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.
- package/dist/Actions/MoveLegacyUndone.d.ts +7 -0
- package/dist/Actions/MoveLegacyUndone.js +10 -0
- package/dist/Actions/MoveLegacyUndone.js.map +1 -0
- package/dist/Actions/MoveUndone.d.ts +2 -2
- package/dist/Actions/MoveUndone.js +2 -2
- package/dist/Actions/MoveUndone.js.map +1 -1
- package/dist/EjectPlayer/EjectPlayer.d.ts +1 -1
- package/dist/Store/gameMiddleware.js +4 -0
- package/dist/Store/gameMiddleware.js.map +1 -1
- package/dist/Store/gameReducer.d.ts +2 -2
- package/dist/Store/gameReducer.js +39 -13
- package/dist/Store/gameReducer.js.map +1 -1
- package/dist/Types/GameData.d.ts +2 -2
- package/dist/Types/MovePlayedNotification.d.ts +3 -1
- package/dist/Types/MovePlayedNotification.js +3 -2
- package/dist/Types/MovePlayedNotification.js.map +1 -1
- package/dist/Types/MoveUndoneNotification.d.ts +3 -4
- package/dist/Types/MoveUndoneNotification.js +3 -2
- package/dist/Types/MoveUndoneNotification.js.map +1 -1
- package/dist/Undo/index.d.ts +1 -0
- package/dist/Undo/index.js +11 -0
- package/dist/Undo/index.js.map +1 -1
- package/dist/Undo/useUndo.d.ts +5 -4
- package/dist/Undo/useUndo.js +39 -46
- package/dist/Undo/useUndo.js.map +1 -1
- package/dist/api/Client/GameClientAPI.d.ts +4 -3
- package/dist/api/Client/GameClientAPI.js +59 -56
- package/dist/api/Client/GameClientAPI.js.map +1 -1
- package/dist/api/Client/GameNotificationsListener.d.ts +1 -1
- package/dist/api/Client/GameNotificationsListener.js +3 -3
- package/dist/api/Client/GameNotificationsListener.js.map +1 -1
- package/dist/api/Client/RemoteGameLoader.js +3 -2
- package/dist/api/Client/RemoteGameLoader.js.map +1 -1
- package/dist/api/Client/apollo-client.js +6 -1
- package/dist/api/Client/apollo-client.js.map +1 -1
- package/dist/api/GameAPI.d.ts +1 -0
- package/dist/api/Local/ConsoleTools.d.ts +1 -1
- package/dist/api/Local/ConsoleTools.js +3 -8
- package/dist/api/Local/ConsoleTools.js.map +1 -1
- package/dist/api/Local/GameLocalAPI.d.ts +2 -8
- package/dist/api/Local/GameLocalAPI.js +62 -51
- package/dist/api/Local/GameLocalAPI.js.map +1 -1
- package/package.json +3 -3
|
@@ -39,59 +39,27 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
39
39
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
43
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
44
|
-
};
|
|
45
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
43
|
exports.GET_MESSAGE_AUTHOR = exports.NOTIFICATIONS = exports.PLAYERS_TIME = exports.AVATAR_INFO = void 0;
|
|
47
44
|
var client_1 = require("@apollo/client");
|
|
48
|
-
var error_1 = require("@apollo/client/link/error");
|
|
49
45
|
var ActionFailed_1 = require("../../Actions/ActionFailed");
|
|
50
46
|
var GameNotificationsReceived_1 = require("../../Actions/GameNotificationsReceived");
|
|
51
|
-
var Failure_1 = __importDefault(require("../../Failure"));
|
|
52
47
|
var index_1 = require("../../index");
|
|
48
|
+
var apollo_client_1 = require("./apollo-client");
|
|
53
49
|
exports.AVATAR_INFO = (0, client_1.gql)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["fragment AvatarInfo on Avataaar {accessoriesType clotheColor clotheType eyeType eyebrowType facialHairType facialHairColor graphicType hairColor mouthType skinColor topType}"], ["fragment AvatarInfo on Avataaar {accessoriesType clotheColor clotheType eyeType eyebrowType facialHairType facialHairColor graphicType hairColor mouthType skinColor topType}"])));
|
|
54
50
|
exports.PLAYERS_TIME = (0, client_1.gql)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["fragment PlayerTime on Player { time { availableTime cumulatedDownTime cumulatedPlayTime cumulatedWaitForMeTime highestDownTime highestPlayTime lastChange playing weightedWaitForMeTime } }"], ["fragment PlayerTime on Player { time { availableTime cumulatedDownTime cumulatedPlayTime cumulatedWaitForMeTime highestDownTime highestPlayTime lastChange playing weightedWaitForMeTime } }"])));
|
|
55
|
-
exports.NOTIFICATIONS = (0, client_1.gql)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["fragment Notifications on GameNotification { playerId ... on MovePlayedNotification { moveView consequences } ... on MoveUndoneNotification { moveUndone } ...on RematchNotification { rematchId } }"], ["fragment Notifications on GameNotification { playerId ... on MovePlayedNotification { moveView consequences } ... on MoveUndoneNotification { moveUndone } ...on RematchNotification { rematchId } }"])));
|
|
51
|
+
exports.NOTIFICATIONS = (0, client_1.gql)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["fragment Notifications on GameNotification { playerId ... on MovePlayedNotification { actionId moveView consequences } ... on MoveUndoneNotification { actionId moveUndone } ...on RematchNotification { rematchId } }"], ["fragment Notifications on GameNotification { playerId ... on MovePlayedNotification { actionId moveView consequences } ... on MoveUndoneNotification { actionId moveUndone } ...on RematchNotification { rematchId } }"])));
|
|
56
52
|
var PLAY = (0, client_1.gql)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["mutation PlayMoves($gameId: String!, $moves: [JSON!]!) { playMoves(gameId: $gameId, moves: $moves) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""], ["mutation PlayMoves($gameId: String!, $moves: [JSON!]!) { playMoves(gameId: $gameId, moves: $moves) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""])), exports.NOTIFICATIONS, exports.PLAYERS_TIME);
|
|
57
|
-
var UNDO = (0, client_1.gql)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["mutation
|
|
58
|
-
var
|
|
59
|
-
var
|
|
60
|
-
var
|
|
61
|
-
|
|
53
|
+
var UNDO = (0, client_1.gql)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["mutation UndoMoves($gameId: String!, $actions: [String!]!) { undoMoves(gameId: $gameId, actions: $actions) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""], ["mutation UndoMoves($gameId: String!, $actions: [String!]!) { undoMoves(gameId: $gameId, actions: $actions) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""])), exports.NOTIFICATIONS, exports.PLAYERS_TIME);
|
|
54
|
+
var LEGACY_UNDO = (0, client_1.gql)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["mutation UndoMovesLegacy($gameId: String!, $playerActionsIndexes: [Int!]!) { undoMoves(gameId: $gameId, playerActionsIndexes: $playerActionsIndexes) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""], ["mutation UndoMovesLegacy($gameId: String!, $playerActionsIndexes: [Int!]!) { undoMoves(gameId: $gameId, playerActionsIndexes: $playerActionsIndexes) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""])), exports.NOTIFICATIONS, exports.PLAYERS_TIME);
|
|
55
|
+
var REMATCH = (0, client_1.gql)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["mutation Rematch($gameId: String!) { rematch(gameId: $gameId) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""], ["mutation Rematch($gameId: String!) { rematch(gameId: $gameId) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""])), exports.NOTIFICATIONS, exports.PLAYERS_TIME);
|
|
56
|
+
var EJECT_PLAYER = (0, client_1.gql)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["mutation EjectPlayer($gameId: String!, $playerId: JSON!) { ejectPlayer(gameId: $gameId, playerId: $playerId) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""], ["mutation EjectPlayer($gameId: String!, $playerId: JSON!) { ejectPlayer(gameId: $gameId, playerId: $playerId) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""])), exports.NOTIFICATIONS, exports.PLAYERS_TIME);
|
|
57
|
+
var GIVE_UP = (0, client_1.gql)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["mutation GiveUp($gameId: String!) { giveUp(gameId: $gameId) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""], ["mutation GiveUp($gameId: String!) { giveUp(gameId: $gameId) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""])), exports.NOTIFICATIONS, exports.PLAYERS_TIME);
|
|
58
|
+
exports.GET_MESSAGE_AUTHOR = (0, client_1.gql)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n query GetMessageAuthor($id: String!) {\n user(id: $id) {\n id name avatar {...AvatarInfo}\n }\n } ", "\n"], ["\n query GetMessageAuthor($id: String!) {\n user(id: $id) {\n id name avatar {...AvatarInfo}\n }\n } ", "\n"])), exports.AVATAR_INFO);
|
|
62
59
|
var GameClientAPI = /** @class */ (function () {
|
|
63
60
|
function GameClientAPI(gameId) {
|
|
64
|
-
var _this = this;
|
|
65
|
-
var _a;
|
|
66
61
|
this.pendingActions = [];
|
|
67
|
-
this.errorLink = (0, error_1.onError)(function (_a) {
|
|
68
|
-
var graphQLErrors = _a.graphQLErrors, networkError = _a.networkError;
|
|
69
|
-
if (graphQLErrors) {
|
|
70
|
-
graphQLErrors.map(function (_a) {
|
|
71
|
-
var message = _a.message;
|
|
72
|
-
return _this.dispatch((0, ActionFailed_1.actionFailed)(message));
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
if (networkError) {
|
|
76
|
-
console.error(networkError);
|
|
77
|
-
_this.dispatch((0, ActionFailed_1.actionFailed)(Failure_1.default.NETWORK));
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
62
|
this.gameId = gameId;
|
|
81
|
-
var uri = index_1.PLATFORM_URI + ((_a = process.env.REACT_APP_GRAPHQL_ENDPOINT) !== null && _a !== void 0 ? _a : '/api/graphql');
|
|
82
|
-
var httpLink = new client_1.HttpLink({ uri: uri, fetch: fetch, credentials: 'include' });
|
|
83
|
-
this.apolloClient = new client_1.ApolloClient({
|
|
84
|
-
link: client_1.ApolloLink.from([this.errorLink, httpLink]),
|
|
85
|
-
cache: new client_1.InMemoryCache(),
|
|
86
|
-
defaultOptions: {
|
|
87
|
-
watchQuery: {
|
|
88
|
-
fetchPolicy: 'no-cache'
|
|
89
|
-
},
|
|
90
|
-
query: {
|
|
91
|
-
fetchPolicy: 'no-cache' // TODO: configure fragment matchers for Interface types and re-enable caching
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
63
|
}
|
|
96
64
|
GameClientAPI.prototype.init = function (dispatch) {
|
|
97
65
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -120,17 +88,36 @@ var GameClientAPI = /** @class */ (function () {
|
|
|
120
88
|
this.ongoingAction = new Promise(function (resolve) { return setTimeout(resolve, 50); }).then(function () { return _this.executePendingActions(); });
|
|
121
89
|
}
|
|
122
90
|
};
|
|
123
|
-
GameClientAPI.prototype.undo = function (
|
|
91
|
+
GameClientAPI.prototype.undo = function (action) {
|
|
92
|
+
if (typeof action === 'number')
|
|
93
|
+
return this.legacyUndo(action);
|
|
124
94
|
if (this.pendingActions.length === 0) {
|
|
125
|
-
this.pendingActions.push({ type: 'UNDO',
|
|
95
|
+
this.pendingActions.push({ type: 'UNDO', actions: [action] });
|
|
126
96
|
}
|
|
127
97
|
else {
|
|
128
98
|
var lastPendingAction = this.pendingActions[this.pendingActions.length - 1];
|
|
129
99
|
if (lastPendingAction.type === 'UNDO') {
|
|
100
|
+
lastPendingAction.actions.push(action);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.pendingActions.push({ type: 'UNDO', actions: [action] });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (!this.ongoingAction) {
|
|
107
|
+
this.executePendingActions();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
GameClientAPI.prototype.legacyUndo = function (playerActionIndex) {
|
|
111
|
+
if (this.pendingActions.length === 0) {
|
|
112
|
+
this.pendingActions.push({ type: 'LEGACY_UNDO', playerActionsIndexes: [playerActionIndex] });
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
var lastPendingAction = this.pendingActions[this.pendingActions.length - 1];
|
|
116
|
+
if (lastPendingAction.type === 'LEGACY_UNDO') {
|
|
130
117
|
lastPendingAction.playerActionsIndexes.push(playerActionIndex);
|
|
131
118
|
}
|
|
132
119
|
else {
|
|
133
|
-
this.pendingActions.push({ type: '
|
|
120
|
+
this.pendingActions.push({ type: 'LEGACY_UNDO', playerActionsIndexes: [playerActionIndex] });
|
|
134
121
|
}
|
|
135
122
|
}
|
|
136
123
|
if (!this.ongoingAction) {
|
|
@@ -142,19 +129,21 @@ var GameClientAPI = /** @class */ (function () {
|
|
|
142
129
|
if (this.pendingActions.length > 0) {
|
|
143
130
|
var pendingAction = this.pendingActions.shift();
|
|
144
131
|
if (pendingAction.type == 'PLAY') {
|
|
145
|
-
this.ongoingAction =
|
|
132
|
+
this.ongoingAction = (0, apollo_client_1.getApolloClient)().mutate({
|
|
146
133
|
mutation: PLAY, variables: { gameId: this.gameId, moves: pendingAction.moves }
|
|
147
|
-
})
|
|
148
|
-
|
|
134
|
+
}).then(function (result) { return result.data && _this.handleGameMessageResult(result.data.playMoves); });
|
|
135
|
+
}
|
|
136
|
+
else if (pendingAction.type === 'UNDO') {
|
|
137
|
+
this.ongoingAction = (0, apollo_client_1.getApolloClient)().mutate({
|
|
138
|
+
mutation: UNDO, variables: { gameId: this.gameId, actions: pendingAction.actions }
|
|
139
|
+
}).then(function (result) { return result.data && _this.handleGameMessageResult(result.data.undoMoves); });
|
|
149
140
|
}
|
|
150
141
|
else {
|
|
151
|
-
this.ongoingAction =
|
|
152
|
-
mutation:
|
|
153
|
-
})
|
|
154
|
-
.then(function (result) { return result.data && _this.handleGameMessageResult(result.data.undoMoves); });
|
|
142
|
+
this.ongoingAction = (0, apollo_client_1.getApolloClient)().mutate({
|
|
143
|
+
mutation: LEGACY_UNDO, variables: { gameId: this.gameId, playerActionsIndexes: pendingAction.playerActionsIndexes }
|
|
144
|
+
}).then(function (result) { return result.data && _this.handleGameMessageResult(result.data.undoMoves); });
|
|
155
145
|
}
|
|
156
|
-
this.ongoingAction = this.ongoingAction.catch(function () {
|
|
157
|
-
}).finally(function () { return _this.executePendingActions(); });
|
|
146
|
+
this.ongoingAction = this.ongoingAction.catch(function (error) { return _this.onError(error); }).finally(function () { return _this.executePendingActions(); });
|
|
158
147
|
}
|
|
159
148
|
else {
|
|
160
149
|
delete this.ongoingAction;
|
|
@@ -166,7 +155,7 @@ var GameClientAPI = /** @class */ (function () {
|
|
|
166
155
|
};
|
|
167
156
|
GameClientAPI.prototype.rematch = function () {
|
|
168
157
|
var _this = this;
|
|
169
|
-
return
|
|
158
|
+
return (0, apollo_client_1.getApolloClient)().mutate({ mutation: REMATCH, variables: { gameId: this.gameId } }).then(function (result) {
|
|
170
159
|
if (!result.data) {
|
|
171
160
|
throw new Error('Rematch request failed');
|
|
172
161
|
}
|
|
@@ -179,19 +168,33 @@ var GameClientAPI = /** @class */ (function () {
|
|
|
179
168
|
};
|
|
180
169
|
GameClientAPI.prototype.eject = function (playerId) {
|
|
181
170
|
var _this = this;
|
|
182
|
-
|
|
171
|
+
(0, apollo_client_1.getApolloClient)().mutate({ mutation: EJECT_PLAYER, variables: { gameId: this.gameId, playerId: playerId } })
|
|
183
172
|
.then(function (result) { return result.data && _this.handleGameMessageResult(result.data.ejectPlayer); });
|
|
184
173
|
};
|
|
185
174
|
GameClientAPI.prototype.giveUp = function () {
|
|
186
175
|
var _this = this;
|
|
187
|
-
|
|
176
|
+
(0, apollo_client_1.getApolloClient)().mutate({ mutation: GIVE_UP, variables: { gameId: this.gameId } })
|
|
188
177
|
.then(function (result) { return result.data && _this.handleGameMessageResult(result.data.giveUp); });
|
|
189
178
|
};
|
|
179
|
+
GameClientAPI.prototype.onError = function (_a) {
|
|
180
|
+
var _this = this;
|
|
181
|
+
var graphQLErrors = _a.graphQLErrors, networkError = _a.networkError;
|
|
182
|
+
if (graphQLErrors) {
|
|
183
|
+
graphQLErrors.map(function (_a) {
|
|
184
|
+
var message = _a.message;
|
|
185
|
+
return _this.dispatch((0, ActionFailed_1.actionFailed)(message));
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
if (networkError) {
|
|
189
|
+
console.error(networkError);
|
|
190
|
+
this.dispatch((0, ActionFailed_1.actionFailed)(index_1.Failure.NETWORK));
|
|
191
|
+
}
|
|
192
|
+
};
|
|
190
193
|
GameClientAPI.prototype.playTutorialMoves = function () {
|
|
191
194
|
console.error('Tutorial should only be played with local API');
|
|
192
195
|
};
|
|
193
196
|
return GameClientAPI;
|
|
194
197
|
}());
|
|
195
198
|
exports.default = GameClientAPI;
|
|
196
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9;
|
|
199
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
|
|
197
200
|
//# sourceMappingURL=GameClientAPI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GameClientAPI.js","sourceRoot":"","sources":["../../../src/api/Client/GameClientAPI.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GameClientAPI.js","sourceRoot":"","sources":["../../../src/api/Client/GameClientAPI.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA+C;AAE/C,2DAAuD;AACvD,qFAAiF;AACjF,qCAAmC;AAInC,iDAA+C;AAElC,QAAA,WAAW,OAAG,YAAG,mPAAA,+KAA+K,KAAA;AAChM,QAAA,YAAY,OAAG,YAAG,kQAAA,8LAA8L,KAAA;AAChN,QAAA,aAAa,OAAG,YAAG,4RAAA,wNAAwN,KAAA;AACxP,IAAM,IAAI,OAAG,YAAG,mQAAA,sLAAuL,EAAa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,CAAC;IAED,8BAAM,GAAN;QAAA,iBAGC;QAFC,IAAA,+BAAe,GAAE,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;IAED,+BAAO,GAAP,UAAQ,EAA0C;QAAlD,iBAQC;YARQ,aAAa,mBAAA,EAAE,YAAY,kBAAA;QAClC,IAAI,aAAa,EAAE;YACjB,aAAa,CAAC,GAAG,CAAC,UAAC,EAAS;oBAAR,OAAO,aAAA;gBAAM,OAAA,KAAI,CAAC,QAAS,CAAC,IAAA,2BAAY,EAAC,OAAO,CAAC,CAAC;YAArC,CAAqC,CAAC,CAAA;SACxE;QACD,IAAI,YAAY,EAAE;YAChB,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;YAC3B,IAAI,CAAC,QAAS,CAAC,IAAA,2BAAY,EAAC,eAAO,CAAC,OAAO,CAAC,CAAC,CAAA;SAC9C;IACH,CAAC;IAED,yCAAiB,GAAjB;QACE,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAA;IAChE,CAAC;IACH,oBAAC;AAAD,CAAC,AA9HD,IA8HC"}
|
|
@@ -46,13 +46,13 @@ var react_1 = require("react");
|
|
|
46
46
|
var react_redux_1 = require("react-redux");
|
|
47
47
|
var GameNotificationsReceived_1 = require("../../Actions/GameNotificationsReceived");
|
|
48
48
|
var GameOver_1 = require("../../Actions/GameOver");
|
|
49
|
-
var game_apollo_client_1 = require("./game-apollo-client");
|
|
50
49
|
var GameClientAPI_1 = require("./GameClientAPI");
|
|
51
50
|
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
51
|
function GameNotificationsListener(_a) {
|
|
53
52
|
var _this = this;
|
|
54
|
-
var gameId = _a.gameId,
|
|
53
|
+
var gameId = _a.gameId, channelName = _a.channelName;
|
|
55
54
|
var channel = (0, use_pusher_1.useChannel)(channelName);
|
|
55
|
+
var client = (0, client_1.useApolloClient)();
|
|
56
56
|
var dispatch = (0, react_redux_1.useDispatch)();
|
|
57
57
|
var notification = (0, react_1.useRef)(0);
|
|
58
58
|
(0, use_pusher_1.useEvent)(channel, 'pusher:subscription_error', function (error) { return console.error('pusher subscription failed', error); });
|
|
@@ -62,7 +62,7 @@ function GameNotificationsListener(_a) {
|
|
|
62
62
|
switch (_a.label) {
|
|
63
63
|
case 0:
|
|
64
64
|
start = notification.current;
|
|
65
|
-
return [4 /*yield*/,
|
|
65
|
+
return [4 /*yield*/, client.query({
|
|
66
66
|
query: GET_NOTIFICATIONS,
|
|
67
67
|
variables: { gameId: gameId, start: start }
|
|
68
68
|
})];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GameNotificationsListener.js","sourceRoot":"","sources":["../../../src/api/Client/GameNotificationsListener.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"GameNotificationsListener.js","sourceRoot":"","sources":["../../../src/api/Client/GameNotificationsListener.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAI,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE;wBACrC,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAA;qBAC7F;;;;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;AAnCD,4CAmCC"}
|
|
@@ -13,8 +13,9 @@ var react_redux_1 = require("react-redux");
|
|
|
13
13
|
var GameStateLoaded_1 = require("../../Actions/GameStateLoaded");
|
|
14
14
|
var GameClientAPI_1 = require("./GameClientAPI");
|
|
15
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);
|
|
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 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 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
17
|
function RemoteGameLoader(_a) {
|
|
18
|
+
var _b;
|
|
18
19
|
var gameId = _a.gameId;
|
|
19
20
|
var dispatch = (0, react_redux_1.useDispatch)();
|
|
20
21
|
var data = (0, client_1.useQuery)(GET_GAME, {
|
|
@@ -27,7 +28,7 @@ function RemoteGameLoader(_a) {
|
|
|
27
28
|
if (!data)
|
|
28
29
|
return null;
|
|
29
30
|
else
|
|
30
|
-
return (0, jsx_runtime_1.jsx)(GameNotificationsListener_1.default, { channelName: data.game.notificationsChannel, gameId: gameId }, void 0);
|
|
31
|
+
return (0, jsx_runtime_1.jsx)(GameNotificationsListener_1.default, { channelName: (_b = data.game.notificationsChannel) !== null && _b !== void 0 ? _b : "game=" + gameId, gameId: gameId }, void 0);
|
|
31
32
|
}
|
|
32
33
|
exports.default = RemoteGameLoader;
|
|
33
34
|
var templateObject_1;
|
|
@@ -1 +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,
|
|
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,maAAA,oVAad,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,MAAA,IAAI,CAAC,IAAI,CAAC,oBAAoB,mCAAI,UAAQ,MAAQ,EAAE,MAAM,EAAE,MAAM,WAAG,CAAA;AAC3H,CAAC;AARD,mCAQC"}
|
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.getApolloClient = void 0;
|
|
16
16
|
var client_1 = require("@apollo/client");
|
|
17
|
+
var retry_1 = require("@apollo/client/link/retry");
|
|
17
18
|
var moment_1 = __importDefault(require("moment"));
|
|
18
19
|
var index_1 = require("../../index");
|
|
19
20
|
var apolloClient;
|
|
@@ -26,8 +27,9 @@ function getApolloClient() {
|
|
|
26
27
|
exports.getApolloClient = getApolloClient;
|
|
27
28
|
function initApolloClient() {
|
|
28
29
|
var _a;
|
|
30
|
+
var httpLink = 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' });
|
|
29
31
|
return new client_1.ApolloClient({
|
|
30
|
-
link: client_1.ApolloLink.from([new
|
|
32
|
+
link: client_1.ApolloLink.from([new retry_1.RetryLink(), httpLink]),
|
|
31
33
|
cache: new client_1.InMemoryCache({
|
|
32
34
|
typePolicies: {
|
|
33
35
|
ChatChannel: {
|
|
@@ -47,6 +49,9 @@ function initApolloClient() {
|
|
|
47
49
|
Message: {
|
|
48
50
|
keyFields: false
|
|
49
51
|
}
|
|
52
|
+
},
|
|
53
|
+
possibleTypes: {
|
|
54
|
+
GameNotification: ['MovePlayedNotification', 'MoveUndoneNotification', 'RematchNotification']
|
|
50
55
|
}
|
|
51
56
|
})
|
|
52
57
|
});
|
|
@@ -1 +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,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AC,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;YACD,aAAa,EAAE;gBACb,gBAAgB,EAAE,CAAC,wBAAwB,EAAE,wBAAwB,EAAE,qBAAqB,CAAC;aAC9F;SACF,CAAC;KACH,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/api/GameAPI.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export default interface GameAPI<Move = string, PlayerId = number> {
|
|
|
4
4
|
init(dispatch: Dispatch): void;
|
|
5
5
|
play(move: Move): void;
|
|
6
6
|
undo(playerActionIndex: number): void;
|
|
7
|
+
undo(actionId: string): void;
|
|
7
8
|
rematch(): Promise<RematchNotification<PlayerId>>;
|
|
8
9
|
eject(playerId: PlayerId): void;
|
|
9
10
|
giveUp(): void;
|
|
@@ -12,7 +12,7 @@ declare type ConsoleTools<State = any, Move = any, PlayerId = any> = {
|
|
|
12
12
|
store: GamePageState<State>;
|
|
13
13
|
moves: Action<Move, PlayerId>[];
|
|
14
14
|
new: (options?: any) => void;
|
|
15
|
-
undo: (
|
|
15
|
+
undo: (quantity?: number) => void;
|
|
16
16
|
monkeyOpponents: (start?: boolean) => void;
|
|
17
17
|
setPlayerName: (name: string, playerId?: PlayerId) => void;
|
|
18
18
|
setAnimationsSpeed: (speed?: number) => void;
|
|
@@ -15,14 +15,9 @@ function consoleTools(gameServerProxy, store) {
|
|
|
15
15
|
gameServerProxy.newGame(options);
|
|
16
16
|
window.location.reload();
|
|
17
17
|
},
|
|
18
|
-
undo: function (
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
var actions = gameServerProxy.getLocalStore().actions;
|
|
24
|
-
gameServerProxy.undoPlayerAction(actions[actions.length - 1].playerId, { force: true });
|
|
25
|
-
}
|
|
18
|
+
undo: function (quantity) {
|
|
19
|
+
if (quantity === void 0) { quantity = 1; }
|
|
20
|
+
gameServerProxy.undo(quantity);
|
|
26
21
|
},
|
|
27
22
|
monkeyOpponents: function (start) {
|
|
28
23
|
if (start === void 0) { start = true; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConsoleTools.js","sourceRoot":"","sources":["../../../src/api/Local/ConsoleTools.ts"],"names":[],"mappings":";;AAwBA,SAAwB,YAAY,CAAwC,eAAoE,EAAE,KAAY;IAC5J,OAAO;QACL,IAAI,KAAK;YACP,OAAO,eAAe,CAAC,aAAa,EAAE,CAAC,KAAK,CAAA;QAC9C,CAAC;QAED,IAAI,KAAK;YACP,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAA;QACzB,CAAC;QAED,IAAI,KAAK;YACP,OAAO,eAAe,CAAC,aAAa,EAAE,CAAC,OAAO,CAAA;QAChD,CAAC;QAED,GAAG,EAAE,UAAC,OAAO;YACX,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;YAChC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAA;QAC1B,CAAC;QAED,IAAI,EAAE,UAAC,
|
|
1
|
+
{"version":3,"file":"ConsoleTools.js","sourceRoot":"","sources":["../../../src/api/Local/ConsoleTools.ts"],"names":[],"mappings":";;AAwBA,SAAwB,YAAY,CAAwC,eAAoE,EAAE,KAAY;IAC5J,OAAO;QACL,IAAI,KAAK;YACP,OAAO,eAAe,CAAC,aAAa,EAAE,CAAC,KAAK,CAAA;QAC9C,CAAC;QAED,IAAI,KAAK;YACP,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAA;QACzB,CAAC;QAED,IAAI,KAAK;YACP,OAAO,eAAe,CAAC,aAAa,EAAE,CAAC,OAAO,CAAA;QAChD,CAAC;QAED,GAAG,EAAE,UAAC,OAAO;YACX,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;YAChC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAA;QAC1B,CAAC;QAED,IAAI,EAAE,UAAC,QAAoB;YAApB,yBAAA,EAAA,YAAoB;YACzB,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAChC,CAAC;QAED,eAAe,EAAE,UAAC,KAAY;YAAZ,sBAAA,EAAA,YAAY;YAC5B,IAAI,KAAK,EAAE;gBACT,eAAe,CAAC,oBAAoB,EAAE,CAAA;aACvC;iBAAM;gBACL,eAAe,CAAC,mBAAmB,EAAE,CAAA;aACtC;QACH,CAAC;QAED,aAAa,EAAE,UAAC,IAAY,EAAE,QAAmB;YAC/C,eAAe,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;YAC7C,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAA;QAC1B,CAAC;QAED,kBAAkB,EAAE,UAAC,KAAS;YAAT,sBAAA,EAAA,SAAS;YAC5B,eAAe,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAA;QAC3C,CAAC;QAED,QAAQ,EAAE;YACR,eAAe,CAAC,WAAW,EAAE,CAAA;YAC7B,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAA;QAC1B,CAAC;KACF,CAAA;AACH,CAAC;AA7CD,+BA6CC"}
|
|
@@ -22,6 +22,7 @@ export default class GameLocalAPI<State, Move = string, PlayerId = number, View
|
|
|
22
22
|
constructor(context: GameContext<State, View, Move, MoveView, PlayerId>);
|
|
23
23
|
createDummy<State, Move, PlayerId>(Rules: RulesCreator<State, Move, PlayerId>): Robot<State, Move, PlayerId>;
|
|
24
24
|
init(dispatch: Dispatch): void;
|
|
25
|
+
initLocalStore(): ProxyGameData<any, any, any>;
|
|
25
26
|
getNotifications(data: ProxyGameData<State, MoveView, PlayerId>): GameNotification<PlayerId>[];
|
|
26
27
|
newTutorial(): ProxyGameData;
|
|
27
28
|
newGame(arg?: Options | number): ProxyGameData;
|
|
@@ -30,14 +31,7 @@ export default class GameLocalAPI<State, Move = string, PlayerId = number, View
|
|
|
30
31
|
play(move: Move): Promise<void>;
|
|
31
32
|
playActions(playerId: PlayerId, moves: Move[]): void;
|
|
32
33
|
private incrementNotificationsCount;
|
|
33
|
-
undo(
|
|
34
|
-
undoPlayerAction(playerId: PlayerId, { force }?: {
|
|
35
|
-
force: boolean;
|
|
36
|
-
}): Promise<any>;
|
|
37
|
-
undoAction(index: number, { force }?: {
|
|
38
|
-
force: boolean;
|
|
39
|
-
}): Promise<void>;
|
|
40
|
-
canUndoAction(index: number): boolean;
|
|
34
|
+
undo(arg?: string | number, ignoreRules?: boolean): void;
|
|
41
35
|
startMonkeyOpponents(): void;
|
|
42
36
|
stopMonkeyOpponents(): void;
|
|
43
37
|
private runAutoPlayers;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
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
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -75,15 +86,14 @@ var GameLocalAPI = /** @class */ (function () {
|
|
|
75
86
|
GameLocalAPI.prototype.init = function (dispatch) {
|
|
76
87
|
var _this = this;
|
|
77
88
|
this.dispatch = dispatch;
|
|
78
|
-
var localStore = localStorage.getItem(this.game);
|
|
79
89
|
var animationsSpeed = parseFloat(localStorage.getItem('animationsSpeed') || '1');
|
|
80
90
|
this.dispatch((0, SetAnimationsSpeed_1.setAnimationsSpeed)(animationsSpeed));
|
|
81
|
-
var data =
|
|
91
|
+
var data = this.initLocalStore();
|
|
82
92
|
this.notificationsCount = data.actions.length;
|
|
83
93
|
var dataToTransfer = {
|
|
84
94
|
myPlayerId: data.playerId, setup: data.setup, state: data.state, notificationsCount: this.notificationsCount,
|
|
85
95
|
players: data.players, options: { speed: rules_api_1.GameSpeed.Disabled, maxSpareTime: 0, maxExceedTime: 0 },
|
|
86
|
-
mode: data.tutorial ? GameMode_1.default.TUTORIAL : GameMode_1.default.FRIENDLY, notificationsChannel: ''
|
|
96
|
+
mode: data.tutorial ? GameMode_1.default.TUTORIAL : GameMode_1.default.FRIENDLY, notificationsChannel: '', endDate: null
|
|
87
97
|
};
|
|
88
98
|
var initialGame = new this.Rules(data.setup);
|
|
89
99
|
if ((0, rules_api_1.hasIncompleteInformation)(initialGame)) {
|
|
@@ -98,6 +108,23 @@ var GameLocalAPI = /** @class */ (function () {
|
|
|
98
108
|
mimicDataTransfer(_this.getNotifications(data)).then(function (notifications) { return dispatch((0, GameNotificationsReceived_1.gameNotificationsReceived)(notifications, 0, data.players)); });
|
|
99
109
|
});
|
|
100
110
|
};
|
|
111
|
+
GameLocalAPI.prototype.initLocalStore = function () {
|
|
112
|
+
var localStore = localStorage.getItem(this.game);
|
|
113
|
+
if (localStore) {
|
|
114
|
+
var data = JSON.parse(localStore);
|
|
115
|
+
if (data.actions.length > 0 && !data.actions[0].id) {
|
|
116
|
+
data.actions.forEach(function (action, index) {
|
|
117
|
+
if (!action.id)
|
|
118
|
+
action.id = index.toString();
|
|
119
|
+
});
|
|
120
|
+
localStorage.setItem(this.game, JSON.stringify(data));
|
|
121
|
+
}
|
|
122
|
+
return data;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
return this.tutorial ? this.newTutorial() : this.newGame();
|
|
126
|
+
}
|
|
127
|
+
};
|
|
101
128
|
GameLocalAPI.prototype.getNotifications = function (data) {
|
|
102
129
|
var game = new this.Rules(data.setup);
|
|
103
130
|
if ((0, rules_api_1.hasIncompleteInformation)(game)) {
|
|
@@ -118,7 +145,7 @@ var GameLocalAPI = /** @class */ (function () {
|
|
|
118
145
|
var move = _c[_b];
|
|
119
146
|
_loop_2(move);
|
|
120
147
|
}
|
|
121
|
-
notifications.push((0, MovePlayedNotification_1.movePlayedNotification)(action
|
|
148
|
+
notifications.push((0, MovePlayedNotification_1.movePlayedNotification)(__assign(__assign({}, action), { move: moveView, consequences: consequences })));
|
|
122
149
|
};
|
|
123
150
|
for (var _i = 0, _a = data.actions; _i < _a.length; _i++) {
|
|
124
151
|
var action = _a[_i];
|
|
@@ -134,7 +161,7 @@ var GameLocalAPI = /** @class */ (function () {
|
|
|
134
161
|
return notifications;
|
|
135
162
|
}
|
|
136
163
|
else {
|
|
137
|
-
return data.actions.map(function (action) { return (0, MovePlayedNotification_1.movePlayedNotification)(action
|
|
164
|
+
return data.actions.map(function (action) { return (0, MovePlayedNotification_1.movePlayedNotification)(action); });
|
|
138
165
|
}
|
|
139
166
|
};
|
|
140
167
|
GameLocalAPI.prototype.newTutorial = function () {
|
|
@@ -211,23 +238,24 @@ var GameLocalAPI = /** @class */ (function () {
|
|
|
211
238
|
var game = new this.Rules(localStore.state); // TODO: this.tutorial?
|
|
212
239
|
var actions = [];
|
|
213
240
|
var notifications = [];
|
|
241
|
+
var id = this.notificationsCount.toString();
|
|
214
242
|
if ((0, rules_api_1.hasIncompleteInformation)(game)) {
|
|
215
243
|
for (var _i = 0, moves_1 = moves; _i < moves_1.length; _i++) {
|
|
216
244
|
var move = moves_1[_i];
|
|
217
|
-
var _b = (0, rules_api_1.playActionWithViews)(game, move, playerId, [localStore.playerId]), action = _b.action, views = _b.views;
|
|
245
|
+
var _b = (0, rules_api_1.playActionWithViews)(game, move, playerId, [localStore.playerId], id), action = _b.action, views = _b.views;
|
|
218
246
|
actions.push(action);
|
|
219
247
|
var view = views.find(function (view) { return view.recipient === localStore.playerId; });
|
|
220
248
|
if (view) {
|
|
221
|
-
notifications.push((0, MovePlayedNotification_1.movePlayedNotification)(view.action
|
|
249
|
+
notifications.push((0, MovePlayedNotification_1.movePlayedNotification)(view.action)); // TODO: MovePlayedNotification = Action
|
|
222
250
|
}
|
|
223
251
|
}
|
|
224
252
|
}
|
|
225
253
|
else {
|
|
226
254
|
for (var _c = 0, moves_2 = moves; _c < moves_2.length; _c++) {
|
|
227
255
|
var move = moves_2[_c];
|
|
228
|
-
var action = (0, rules_api_1.playAction)(game, move, playerId);
|
|
256
|
+
var action = (0, rules_api_1.playAction)(game, move, playerId, id);
|
|
229
257
|
actions.push(action);
|
|
230
|
-
notifications.push((0, MovePlayedNotification_1.movePlayedNotification)(action
|
|
258
|
+
notifications.push((0, MovePlayedNotification_1.movePlayedNotification)(action));
|
|
231
259
|
}
|
|
232
260
|
}
|
|
233
261
|
mimicDataTransfer({ notifications: notifications, index: this.incrementNotificationsCount(notifications.length) }).then(function (data) {
|
|
@@ -243,52 +271,35 @@ var GameLocalAPI = /** @class */ (function () {
|
|
|
243
271
|
this.notificationsCount += quantity;
|
|
244
272
|
return previousValue;
|
|
245
273
|
};
|
|
246
|
-
GameLocalAPI.prototype.undo = function (
|
|
274
|
+
GameLocalAPI.prototype.undo = function (arg, ignoreRules) {
|
|
247
275
|
var _this = this;
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
var
|
|
251
|
-
|
|
252
|
-
|
|
276
|
+
if (arg === void 0) { arg = 1; }
|
|
277
|
+
if (typeof arg === 'string') {
|
|
278
|
+
var localStore_1 = this.getLocalStore();
|
|
279
|
+
var index = (0, ArrayUtil_1.findLastIndex)(localStore_1.actions, function (action) { return action.id === arg; });
|
|
280
|
+
var action = localStore_1.actions[index];
|
|
281
|
+
if (!ignoreRules) {
|
|
282
|
+
var game_1 = new this.Rules(localStore_1.state);
|
|
283
|
+
if (!(0, rules_api_1.hasUndo)(game_1))
|
|
284
|
+
return console.error('This game does not have UNDO feature');
|
|
285
|
+
if (!game_1.canUndo(action, localStore_1.actions.slice(index + 1)))
|
|
286
|
+
return console.error('Trying to UNDO a move while it is forbidden');
|
|
253
287
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
if (index === -1) {
|
|
263
|
-
console.error('This player did not play any move yet: ' + JSON.stringify(playerId));
|
|
264
|
-
return Promise.reject(new Error('This player did not play any move yet: ' + JSON.stringify(playerId)));
|
|
288
|
+
localStore_1.actions.splice(index, 1);
|
|
289
|
+
var game = new this.Rules(JSON.parse(JSON.stringify(localStore_1.setup)));
|
|
290
|
+
(0, rules_api_1.replayActions)(game, localStore_1.actions);
|
|
291
|
+
localStore_1.state = game.state;
|
|
292
|
+
localStorage.setItem(this.game, JSON.stringify(localStore_1));
|
|
293
|
+
mimicDataTransfer({ notification: (0, MoveUndoneNotification_1.moveUndoneNotification)(action, index), index: this.incrementNotificationsCount() }).then(function (data) {
|
|
294
|
+
return _this.dispatch((0, GameNotificationsReceived_1.gameNotificationsReceived)([data.notification], data.index, localStore_1.players));
|
|
295
|
+
});
|
|
265
296
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
var localStore = this.getLocalStore();
|
|
272
|
-
var action = localStore.actions[index];
|
|
273
|
-
if (!force && !this.canUndoAction(index)) {
|
|
274
|
-
console.error('Trying to UNDO a move while it is forbidden');
|
|
275
|
-
return Promise.reject(new Error('Trying to UNDO a move while it is forbidden'));
|
|
297
|
+
else if (arg > 0) {
|
|
298
|
+
var actions = this.getLocalStore().actions;
|
|
299
|
+
if (!actions.length)
|
|
300
|
+
return console.warn('Cannot undo, no actions were played yet');
|
|
301
|
+
this.undo(actions[actions.length - 1].id, true);
|
|
276
302
|
}
|
|
277
|
-
localStore.actions.splice(index, 1);
|
|
278
|
-
var game = new this.Rules(JSON.parse(JSON.stringify(localStore.setup)));
|
|
279
|
-
(0, rules_api_1.replayActions)(game, localStore.actions);
|
|
280
|
-
localStore.state = game.state;
|
|
281
|
-
mimicDataTransfer({ notification: (0, MoveUndoneNotification_1.moveUndoneNotification)(action.playerId, index), index: this.incrementNotificationsCount() }).then(function (data) {
|
|
282
|
-
return _this.dispatch((0, GameNotificationsReceived_1.gameNotificationsReceived)([data.notification], data.index, localStore.players));
|
|
283
|
-
});
|
|
284
|
-
localStorage.setItem(this.game, JSON.stringify(localStore));
|
|
285
|
-
return Promise.resolve();
|
|
286
|
-
};
|
|
287
|
-
GameLocalAPI.prototype.canUndoAction = function (index) {
|
|
288
|
-
var localStore = this.getLocalStore();
|
|
289
|
-
var action = localStore.actions[index];
|
|
290
|
-
var game = new this.Rules(localStore.state);
|
|
291
|
-
return (0, rules_api_1.hasUndo)(game) && game.canUndo(action, localStore.actions.slice(index + 1));
|
|
292
303
|
};
|
|
293
304
|
GameLocalAPI.prototype.startMonkeyOpponents = function () {
|
|
294
305
|
var localStore = this.getLocalStore();
|