@gbl-uzh/platform 0.3.0 → 0.4.0
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/index.d.ts +97 -95
- package/dist/index.js +88 -74
- package/dist/lib/apollo.js +4 -0
- package/dist/lib/util.d.ts +12 -1
- package/dist/lib/util.js +43 -0
- package/dist/nexus.d.ts +1 -1
- package/dist/nexus.js +92 -75
- package/package.json +18 -24
package/dist/index.js
CHANGED
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -33,10 +37,24 @@ __export(src_exports, {
|
|
|
33
37
|
GameService: () => GameService_exports,
|
|
34
38
|
LearningElementState: () => LearningElementState,
|
|
35
39
|
PlayService: () => PlayService_exports,
|
|
36
|
-
UserRole: () => UserRole
|
|
40
|
+
UserRole: () => UserRole,
|
|
41
|
+
log: () => logger_default
|
|
37
42
|
});
|
|
38
43
|
module.exports = __toCommonJS(src_exports);
|
|
39
44
|
|
|
45
|
+
// src/lib/logger.ts
|
|
46
|
+
var import_winston = __toESM(require("winston"));
|
|
47
|
+
var logger = import_winston.default.createLogger({
|
|
48
|
+
level: process.env.NODE_ENV === "development" ? "debug" : "info",
|
|
49
|
+
format: import_winston.default.format.combine(
|
|
50
|
+
import_winston.default.format.timestamp(),
|
|
51
|
+
import_winston.default.format.json()
|
|
52
|
+
),
|
|
53
|
+
defaultMeta: { service: "@gbl-uzh/platform" },
|
|
54
|
+
transports: [new import_winston.default.transports.Console()]
|
|
55
|
+
});
|
|
56
|
+
var logger_default = logger;
|
|
57
|
+
|
|
40
58
|
// src/services/AccountService.ts
|
|
41
59
|
var AccountService_exports = {};
|
|
42
60
|
__export(AccountService_exports, {
|
|
@@ -131,31 +149,7 @@ __export(EventService_exports, {
|
|
|
131
149
|
receiveEvent: () => receiveEvent,
|
|
132
150
|
receiveEvents: () => receiveEvents
|
|
133
151
|
});
|
|
134
|
-
|
|
135
|
-
// src/generated/ops.ts
|
|
136
|
-
var GameDataFragmentDoc = { "kind": "Document", "definitions": [{ "kind": "FragmentDefinition", "name": { "kind": "Name", "value": "GameData" }, "typeCondition": { "kind": "NamedType", "name": { "kind": "Name", "value": "Game" } }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "status" } }, { "kind": "Field", "name": { "kind": "Name", "value": "name" } }, { "kind": "Field", "name": { "kind": "Name", "value": "activePeriodIx" } }] } }] };
|
|
137
|
-
var LearningElementDataFragmentDoc = { "kind": "Document", "definitions": [{ "kind": "FragmentDefinition", "name": { "kind": "Name", "value": "LearningElementData" }, "typeCondition": { "kind": "NamedType", "name": { "kind": "Name", "value": "LearningElement" } }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "title" } }, { "kind": "Field", "name": { "kind": "Name", "value": "question" } }, { "kind": "Field", "name": { "kind": "Name", "value": "reward" } }, { "kind": "Field", "name": { "kind": "Name", "value": "motivation" } }, { "kind": "Field", "name": { "kind": "Name", "value": "feedback" } }] } }] };
|
|
138
|
-
var SegmentDataFragmentDoc = { "kind": "Document", "definitions": [{ "kind": "FragmentDefinition", "name": { "kind": "Name", "value": "SegmentData" }, "typeCondition": { "kind": "NamedType", "name": { "kind": "Name", "value": "PeriodSegment" } }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "index" } }, { "kind": "Field", "name": { "kind": "Name", "value": "facts" } }, { "kind": "Field", "name": { "kind": "Name", "value": "learningElements" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "storyElements" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }] } }] } }] };
|
|
139
|
-
var PeriodDataFragmentDoc = { "kind": "Document", "definitions": [{ "kind": "FragmentDefinition", "name": { "kind": "Name", "value": "PeriodData" }, "typeCondition": { "kind": "NamedType", "name": { "kind": "Name", "value": "Period" } }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "index" } }, { "kind": "Field", "name": { "kind": "Name", "value": "activeSegmentIx" } }, { "kind": "Field", "name": { "kind": "Name", "value": "facts" } }, { "kind": "Field", "name": { "kind": "Name", "value": "segments" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "SegmentData" } }] } }] } }, ...SegmentDataFragmentDoc.definitions] };
|
|
140
|
-
var PlayerActionDataFragmentDoc = { "kind": "Document", "definitions": [{ "kind": "FragmentDefinition", "name": { "kind": "Name", "value": "PlayerActionData" }, "typeCondition": { "kind": "NamedType", "name": { "kind": "Name", "value": "PlayerAction" } }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "periodIx" } }, { "kind": "Field", "name": { "kind": "Name", "value": "segmentIx" } }, { "kind": "Field", "name": { "kind": "Name", "value": "type" } }, { "kind": "Field", "name": { "kind": "Name", "value": "facts" } }] } }] };
|
|
141
|
-
var PlayerDataFragmentDoc = { "kind": "Document", "definitions": [{ "kind": "FragmentDefinition", "name": { "kind": "Name", "value": "PlayerData" }, "typeCondition": { "kind": "NamedType", "name": { "kind": "Name", "value": "Player" } }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "isReady" } }, { "kind": "Field", "name": { "kind": "Name", "value": "role" } }, { "kind": "Field", "name": { "kind": "Name", "value": "name" } }, { "kind": "Field", "name": { "kind": "Name", "value": "avatar" } }, { "kind": "Field", "name": { "kind": "Name", "value": "location" } }, { "kind": "Field", "name": { "kind": "Name", "value": "color" } }, { "kind": "Field", "name": { "kind": "Name", "value": "facts" } }, { "kind": "Field", "name": { "kind": "Name", "value": "experience" } }, { "kind": "Field", "name": { "kind": "Name", "value": "experienceToNext" } }, { "kind": "Field", "name": { "kind": "Name", "value": "achievementKeys" } }, { "kind": "Field", "name": { "kind": "Name", "value": "achievements" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "count" } }, { "kind": "Field", "name": { "kind": "Name", "value": "achievement" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "name" } }, { "kind": "Field", "name": { "kind": "Name", "value": "description" } }, { "kind": "Field", "name": { "kind": "Name", "value": "image" } }, { "kind": "Field", "name": { "kind": "Name", "value": "reward" } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "level" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "index" } }] } }] } }] };
|
|
142
|
-
var ResultDataFragmentDoc = { "kind": "Document", "definitions": [{ "kind": "FragmentDefinition", "name": { "kind": "Name", "value": "ResultData" }, "typeCondition": { "kind": "NamedType", "name": { "kind": "Name", "value": "PlayerResult" } }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "type" } }, { "kind": "Field", "name": { "kind": "Name", "value": "facts" } }, { "kind": "Field", "name": { "kind": "Name", "value": "period" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "index" } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "segment" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "index" } }] } }] } }] };
|
|
143
|
-
var ActivateNextPeriodDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "ActivateNextPeriod" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "gameId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "Int" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "activateNextPeriod" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "gameId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "gameId" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "GameData" } }, { "kind": "Field", "name": { "kind": "Name", "value": "periods" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "PeriodData" } }] } }] } }] } }, ...GameDataFragmentDoc.definitions, ...PeriodDataFragmentDoc.definitions] };
|
|
144
|
-
var ActivateNextSegmentDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "ActivateNextSegment" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "gameId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "Int" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "activateNextSegment" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "gameId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "gameId" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "GameData" } }, { "kind": "Field", "name": { "kind": "Name", "value": "periods" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "PeriodData" } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "players" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "PlayerData" } }] } }] } }] } }, ...GameDataFragmentDoc.definitions, ...PeriodDataFragmentDoc.definitions, ...PlayerDataFragmentDoc.definitions] };
|
|
145
|
-
var AddGamePeriodDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "AddGamePeriod" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "gameId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "Int" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "facts" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "PeriodFactsInput" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "addGamePeriod" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "gameId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "gameId" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "facts" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "facts" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "PeriodData" } }] } }] } }, ...PeriodDataFragmentDoc.definitions] };
|
|
146
|
-
var AddPeriodSegmentDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "AddPeriodSegment" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "gameId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "Int" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "periodIx" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "Int" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "facts" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "PeriodSegmentFactsInput" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "storyElements" } }, "type": { "kind": "ListType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "learningElements" } }, "type": { "kind": "ListType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "addPeriodSegment" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "gameId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "gameId" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "periodIx" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "periodIx" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "facts" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "facts" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "storyElements" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "storyElements" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "learningElements" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "learningElements" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "SegmentData" } }] } }] } }, ...SegmentDataFragmentDoc.definitions] };
|
|
147
|
-
var CreateGameDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "CreateGame" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "name" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "playerCount" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "Int" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "createGame" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "name" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "name" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "playerCount" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "playerCount" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "GameData" } }] } }] } }, ...GameDataFragmentDoc.definitions] };
|
|
148
|
-
var LoginAsTeamDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "LoginAsTeam" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "token" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "loginAsTeam" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "token" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "token" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "PlayerData" } }] } }] } }, ...PlayerDataFragmentDoc.definitions] };
|
|
149
|
-
var PerformActionDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "PerformAction" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "type" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "payload" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "performAction" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "type" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "type" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "payload" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "payload" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "ResultData" } }] } }] } }, ...ResultDataFragmentDoc.definitions] };
|
|
150
|
-
var UpdatePlayerDataDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "UpdatePlayerData" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "name" } }, "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "avatar" } }, "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "color" } }, "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "facts" } }, "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "updatePlayerData" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "name" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "name" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "avatar" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "avatar" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "color" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "color" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "facts" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "facts" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "PlayerData" } }] } }] } }, ...PlayerDataFragmentDoc.definitions] };
|
|
151
|
-
var GameDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "Game" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } }, "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "Int" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "game" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "GameData" } }, { "kind": "Field", "name": { "kind": "Name", "value": "activePeriod" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "activeSegmentIx" } }, { "kind": "Field", "name": { "kind": "Name", "value": "segments" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "periods" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "PeriodData" } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "players" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "isReady" } }, { "kind": "Field", "name": { "kind": "Name", "value": "role" } }, { "kind": "Field", "name": { "kind": "Name", "value": "name" } }, { "kind": "Field", "name": { "kind": "Name", "value": "avatar" } }, { "kind": "Field", "name": { "kind": "Name", "value": "location" } }, { "kind": "Field", "name": { "kind": "Name", "value": "color" } }, { "kind": "Field", "name": { "kind": "Name", "value": "facts" } }, { "kind": "Field", "name": { "kind": "Name", "value": "experience" } }, { "kind": "Field", "name": { "kind": "Name", "value": "experienceToNext" } }, { "kind": "Field", "name": { "kind": "Name", "value": "token" } }] } }] } }] } }, ...GameDataFragmentDoc.definitions, ...PeriodDataFragmentDoc.definitions] };
|
|
152
|
-
var GamesDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "Games" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "games" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "GameData" } }] } }] } }, ...GameDataFragmentDoc.definitions] };
|
|
153
|
-
var LearningElementDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "LearningElement" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "ID" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "learningElement" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "id" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "element" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "LearningElementData" } }, { "kind": "Field", "name": { "kind": "Name", "value": "options" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "content" } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "state" } }, { "kind": "Field", "name": { "kind": "Name", "value": "solution" } }] } }] } }, ...LearningElementDataFragmentDoc.definitions] };
|
|
154
|
-
var LearningElementsDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "LearningElements" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "learningElements" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "LearningElementData" } }] } }] } }, ...LearningElementDataFragmentDoc.definitions] };
|
|
155
|
-
var PastResultsDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "PastResults" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "result" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "currentGame" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "status" } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "pastResults" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "ResultData" } }, { "kind": "Field", "name": { "kind": "Name", "value": "player" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "role" } }, { "kind": "Field", "name": { "kind": "Name", "value": "name" } }, { "kind": "Field", "name": { "kind": "Name", "value": "avatar" } }, { "kind": "Field", "name": { "kind": "Name", "value": "color" } }, { "kind": "Field", "name": { "kind": "Name", "value": "facts" } }, { "kind": "Field", "name": { "kind": "Name", "value": "experience" } }, { "kind": "Field", "name": { "kind": "Name", "value": "experienceToNext" } }, { "kind": "Field", "name": { "kind": "Name", "value": "level" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "index" } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "completedLearningElementIds" } }, { "kind": "Field", "name": { "kind": "Name", "value": "visitedStoryElementIds" } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "period" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "index" } }, { "kind": "Field", "name": { "kind": "Name", "value": "facts" } }] } }] } }] } }, ...ResultDataFragmentDoc.definitions] };
|
|
156
|
-
var ResultDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "Result" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "result" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "playerResult" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "ResultData" } }, { "kind": "Field", "name": { "kind": "Name", "value": "player" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "completedLearningElementIds" } }, { "kind": "Field", "name": { "kind": "Name", "value": "visitedStoryElementIds" } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "previousResults" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "ResultData" } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "currentGame" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "status" } }, { "kind": "Field", "name": { "kind": "Name", "value": "periods" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "PeriodData" } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "activePeriod" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "PeriodData" } }, { "kind": "Field", "name": { "kind": "Name", "value": "activeSegment" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "index" } }, { "kind": "Field", "name": { "kind": "Name", "value": "facts" } }, { "kind": "Field", "name": { "kind": "Name", "value": "learningElements" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "title" } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "storyElements" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "type" } }, { "kind": "Field", "name": { "kind": "Name", "value": "title" } }, { "kind": "Field", "name": { "kind": "Name", "value": "content" } }, { "kind": "Field", "name": { "kind": "Name", "value": "contentRole" } }] } }] } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "transactions" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "PlayerActionData" } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "self" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "PlayerData" } }] } }] } }, ...ResultDataFragmentDoc.definitions, ...PeriodDataFragmentDoc.definitions, ...PlayerActionDataFragmentDoc.definitions, ...PlayerDataFragmentDoc.definitions] };
|
|
157
|
-
var ResultsDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "Results" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "results" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "ResultData" } }, { "kind": "Field", "name": { "kind": "Name", "value": "player" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "name" } }] } }] } }] } }, ...ResultDataFragmentDoc.definitions] };
|
|
158
|
-
var SelfDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "Self" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "self" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "FragmentSpread", "name": { "kind": "Name", "value": "PlayerData" } }] } }] } }, ...PlayerDataFragmentDoc.definitions] };
|
|
152
|
+
var DB = __toESM(require("@prisma/client"));
|
|
159
153
|
|
|
160
154
|
// src/lib/pubsub.ts
|
|
161
155
|
var import_graphql_yoga = require("graphql-yoga");
|
|
@@ -199,7 +193,7 @@ async function receiveEvent(event, definedEvents, definedLevels, prisma) {
|
|
|
199
193
|
if (matchingEvent && matchingEvent.achievements?.length > 0) {
|
|
200
194
|
const awardedAchievements = await matchingEvent.achievements.reduce(
|
|
201
195
|
async (acc, achievement) => {
|
|
202
|
-
if (achievement.when ===
|
|
196
|
+
if (achievement.when === DB.AchievementFrequency.FIRST && event.ctx.achievements.includes(achievement.id)) {
|
|
203
197
|
return acc;
|
|
204
198
|
}
|
|
205
199
|
const existingInstance = await prisma.achievementInstance.findFirst({
|
|
@@ -372,6 +366,7 @@ __export(GameService_exports, {
|
|
|
372
366
|
getLearningElements: () => getLearningElements,
|
|
373
367
|
updatePlayerData: () => updatePlayerData
|
|
374
368
|
});
|
|
369
|
+
var DB2 = __toESM(require("@prisma/client"));
|
|
375
370
|
|
|
376
371
|
// ../../node_modules/nanoid/index.js
|
|
377
372
|
var import_crypto = __toESM(require("crypto"), 1);
|
|
@@ -438,6 +433,7 @@ async function createGame({ name, playerCount }, ctx, { roleAssigner }) {
|
|
|
438
433
|
}
|
|
439
434
|
async function addGamePeriod({ gameId, facts }, ctx, { schema, reducers }) {
|
|
440
435
|
const validatedFacts = schema.validateSync(facts);
|
|
436
|
+
console.log(gameId);
|
|
441
437
|
const game = await ctx.prisma.game.findUnique({
|
|
442
438
|
where: {
|
|
443
439
|
id: gameId
|
|
@@ -461,6 +457,7 @@ async function addGamePeriod({ gameId, facts }, ctx, { schema, reducers }) {
|
|
|
461
457
|
});
|
|
462
458
|
if (!game)
|
|
463
459
|
return null;
|
|
460
|
+
console.log(game);
|
|
464
461
|
const index = game.periods[0]?.index + 1 || 0;
|
|
465
462
|
const { result: initializedFacts } = reducers.Period.apply(validatedFacts, {
|
|
466
463
|
type: reducers.Period.ActionTypes.PERIOD_INITIALIZE,
|
|
@@ -602,6 +599,7 @@ async function addPeriodSegment({
|
|
|
602
599
|
});
|
|
603
600
|
}
|
|
604
601
|
async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
602
|
+
logger_default.info("activating next period");
|
|
605
603
|
const game = await ctx.prisma.game.findUnique({
|
|
606
604
|
where: {
|
|
607
605
|
id: gameId
|
|
@@ -646,11 +644,12 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
646
644
|
});
|
|
647
645
|
if (!game)
|
|
648
646
|
return null;
|
|
647
|
+
logger_default.info(`game found, status ${game.status}`);
|
|
649
648
|
const currentPeriodIx = game.activePeriodIx;
|
|
650
649
|
const currentSegmentIx = game.activePeriod?.activeSegmentIx;
|
|
651
650
|
const nextPeriodIx = currentPeriodIx + 1;
|
|
652
651
|
switch (game.status) {
|
|
653
|
-
case
|
|
652
|
+
case DB2.GameStatus.SCHEDULED: {
|
|
654
653
|
const { results, extras } = computePeriodStartResults(
|
|
655
654
|
{
|
|
656
655
|
results: void 0,
|
|
@@ -675,7 +674,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
675
674
|
}
|
|
676
675
|
},
|
|
677
676
|
data: {
|
|
678
|
-
status:
|
|
677
|
+
status: DB2.GameStatus.PREPARATION,
|
|
679
678
|
activePeriodIx: nextPeriodIx,
|
|
680
679
|
activePeriod: {
|
|
681
680
|
connect: {
|
|
@@ -704,7 +703,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
704
703
|
]);
|
|
705
704
|
return result;
|
|
706
705
|
}
|
|
707
|
-
case
|
|
706
|
+
case DB2.GameStatus.RUNNING: {
|
|
708
707
|
if (!game.activePeriod?.activeSegment || !currentSegmentIx)
|
|
709
708
|
return null;
|
|
710
709
|
const { results, extras } = computeSegmentEndResults(game, ctx, {
|
|
@@ -723,7 +722,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
723
722
|
const result = await ctx.prisma.$transaction([
|
|
724
723
|
ctx.prisma.game.update({
|
|
725
724
|
data: {
|
|
726
|
-
status:
|
|
725
|
+
status: DB2.GameStatus.CONSOLIDATION
|
|
727
726
|
},
|
|
728
727
|
include: {
|
|
729
728
|
periods: {
|
|
@@ -757,6 +756,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
757
756
|
},
|
|
758
757
|
data: {
|
|
759
758
|
results: {
|
|
759
|
+
// compute SEGMENT_END results using model
|
|
760
760
|
update: results
|
|
761
761
|
}
|
|
762
762
|
},
|
|
@@ -772,7 +772,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
772
772
|
]);
|
|
773
773
|
return result;
|
|
774
774
|
}
|
|
775
|
-
case
|
|
775
|
+
case DB2.GameStatus.CONSOLIDATION: {
|
|
776
776
|
if (!game.activePeriod?.activeSegment)
|
|
777
777
|
return null;
|
|
778
778
|
const { results, extras, promises } = await computePeriodEndResults(
|
|
@@ -782,6 +782,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
782
782
|
periodFacts: game.activePeriod.facts,
|
|
783
783
|
periodDecisions: game.activePeriod.decisions,
|
|
784
784
|
activePeriodIx: currentPeriodIx,
|
|
785
|
+
activeSegmentIx: currentSegmentIx,
|
|
785
786
|
gameId: game.id
|
|
786
787
|
},
|
|
787
788
|
ctx,
|
|
@@ -789,6 +790,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
789
790
|
);
|
|
790
791
|
await Promise.all(promises);
|
|
791
792
|
const result = await ctx.prisma.$transaction([
|
|
793
|
+
// update the status and active period of the current game
|
|
792
794
|
ctx.prisma.game.update({
|
|
793
795
|
where: {
|
|
794
796
|
id: gameId
|
|
@@ -801,7 +803,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
801
803
|
}
|
|
802
804
|
},
|
|
803
805
|
data: {
|
|
804
|
-
status:
|
|
806
|
+
status: DB2.GameStatus.RESULTS,
|
|
805
807
|
activePeriodIx: nextPeriodIx,
|
|
806
808
|
activePeriod: {
|
|
807
809
|
connect: {
|
|
@@ -813,6 +815,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
813
815
|
}
|
|
814
816
|
}
|
|
815
817
|
}),
|
|
818
|
+
// create PERIOD_END results based on the previous SEGMENT_END results
|
|
816
819
|
ctx.prisma.period.update({
|
|
817
820
|
where: {
|
|
818
821
|
gameId_index: {
|
|
@@ -833,8 +836,9 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
833
836
|
]);
|
|
834
837
|
return result;
|
|
835
838
|
}
|
|
836
|
-
case
|
|
837
|
-
if (!game.activePeriod
|
|
839
|
+
case DB2.GameStatus.RESULTS: {
|
|
840
|
+
if (!game.activePeriod) {
|
|
841
|
+
logger_default.warn("no next period available");
|
|
838
842
|
return null;
|
|
839
843
|
}
|
|
840
844
|
const { results, extras } = computePeriodStartResults(
|
|
@@ -849,6 +853,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
849
853
|
{ reducers }
|
|
850
854
|
);
|
|
851
855
|
const result = await ctx.prisma.$transaction([
|
|
856
|
+
// update the status and active period of the current game
|
|
852
857
|
ctx.prisma.game.update({
|
|
853
858
|
where: {
|
|
854
859
|
id: gameId
|
|
@@ -861,9 +866,10 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
861
866
|
}
|
|
862
867
|
},
|
|
863
868
|
data: {
|
|
864
|
-
status:
|
|
869
|
+
status: DB2.GameStatus.PREPARATION
|
|
865
870
|
}
|
|
866
871
|
}),
|
|
872
|
+
// create PERIOD_START results based on the previous PERIOD_END results
|
|
867
873
|
ctx.prisma.period.update({
|
|
868
874
|
where: {
|
|
869
875
|
gameId_index: {
|
|
@@ -921,8 +927,8 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
921
927
|
const currentSegmentIx = game.activePeriod.activeSegmentIx;
|
|
922
928
|
const nextSegmentIx = currentSegmentIx + 1;
|
|
923
929
|
switch (game.status) {
|
|
924
|
-
case
|
|
925
|
-
case
|
|
930
|
+
case DB2.GameStatus.PREPARATION:
|
|
931
|
+
case DB2.GameStatus.PAUSED: {
|
|
926
932
|
const { results, extras } = computeSegmentStartResults(game, ctx, {
|
|
927
933
|
reducers
|
|
928
934
|
});
|
|
@@ -940,9 +946,10 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
940
946
|
players: true
|
|
941
947
|
},
|
|
942
948
|
data: {
|
|
943
|
-
status:
|
|
949
|
+
status: DB2.GameStatus.RUNNING
|
|
944
950
|
}
|
|
945
951
|
}),
|
|
952
|
+
// update the active segment of the current period
|
|
946
953
|
ctx.prisma.period.update({
|
|
947
954
|
where: {
|
|
948
955
|
gameId_index: {
|
|
@@ -963,6 +970,7 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
963
970
|
}
|
|
964
971
|
}
|
|
965
972
|
}),
|
|
973
|
+
// SEGMENT INITIALIZATION
|
|
966
974
|
ctx.prisma.periodSegment.update({
|
|
967
975
|
where: {
|
|
968
976
|
gameId_periodIx_index: {
|
|
@@ -979,23 +987,9 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
979
987
|
}),
|
|
980
988
|
...extras
|
|
981
989
|
]);
|
|
982
|
-
try {
|
|
983
|
-
await ctx.prisma.player.updateMany({
|
|
984
|
-
where: {
|
|
985
|
-
game: {
|
|
986
|
-
id: gameId
|
|
987
|
-
}
|
|
988
|
-
},
|
|
989
|
-
data: {
|
|
990
|
-
isReady: false
|
|
991
|
-
}
|
|
992
|
-
});
|
|
993
|
-
} catch (e) {
|
|
994
|
-
console.error(e);
|
|
995
|
-
}
|
|
996
990
|
return result;
|
|
997
991
|
}
|
|
998
|
-
case
|
|
992
|
+
case DB2.GameStatus.RUNNING: {
|
|
999
993
|
if (!game.activePeriod?.activeSegment?.nextSegment) {
|
|
1000
994
|
return null;
|
|
1001
995
|
}
|
|
@@ -1014,7 +1008,7 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
1014
1008
|
players: true
|
|
1015
1009
|
},
|
|
1016
1010
|
data: {
|
|
1017
|
-
status:
|
|
1011
|
+
status: DB2.GameStatus.PAUSED
|
|
1018
1012
|
}
|
|
1019
1013
|
}),
|
|
1020
1014
|
ctx.prisma.periodSegment.update({
|
|
@@ -1034,6 +1028,17 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
1034
1028
|
results: true
|
|
1035
1029
|
}
|
|
1036
1030
|
}),
|
|
1031
|
+
// reset player readiness
|
|
1032
|
+
ctx.prisma.player.updateMany({
|
|
1033
|
+
where: {
|
|
1034
|
+
game: {
|
|
1035
|
+
id: gameId
|
|
1036
|
+
}
|
|
1037
|
+
},
|
|
1038
|
+
data: {
|
|
1039
|
+
isReady: false
|
|
1040
|
+
}
|
|
1041
|
+
}),
|
|
1037
1042
|
...extras
|
|
1038
1043
|
]);
|
|
1039
1044
|
return result;
|
|
@@ -1179,7 +1184,7 @@ function computePeriodStartResults({ results, players, activePeriodIx, gameId, p
|
|
|
1179
1184
|
const nextPeriodIx = currentPeriodIx + 1;
|
|
1180
1185
|
let extras = [];
|
|
1181
1186
|
if (currentPeriodIx >= 0) {
|
|
1182
|
-
const result2 = results.filter((result3) => result3.type ===
|
|
1187
|
+
const result2 = results.filter((result3) => result3.type === DB2.PlayerResultType.PERIOD_END).map((result3, ix, allResults) => {
|
|
1183
1188
|
const { result: facts, actions } = reducers.PeriodResult.apply(result3, {
|
|
1184
1189
|
type: reducers.PeriodResult.ActionTypes.PERIOD_RESULTS_START,
|
|
1185
1190
|
payload: {
|
|
@@ -1197,7 +1202,7 @@ function computePeriodStartResults({ results, players, activePeriodIx, gameId, p
|
|
|
1197
1202
|
extras = [...extras, ...actions.map(mapper)];
|
|
1198
1203
|
}
|
|
1199
1204
|
return {
|
|
1200
|
-
type:
|
|
1205
|
+
type: DB2.PlayerResultType.PERIOD_START,
|
|
1201
1206
|
periodIx: currentPeriodIx,
|
|
1202
1207
|
facts,
|
|
1203
1208
|
player: {
|
|
@@ -1238,7 +1243,7 @@ function computePeriodStartResults({ results, players, activePeriodIx, gameId, p
|
|
|
1238
1243
|
extras = [...extras, ...actions.map(mapper)];
|
|
1239
1244
|
}
|
|
1240
1245
|
return {
|
|
1241
|
-
type:
|
|
1246
|
+
type: DB2.PlayerResultType.PERIOD_START,
|
|
1242
1247
|
periodIx: nextPeriodIx,
|
|
1243
1248
|
facts,
|
|
1244
1249
|
player: {
|
|
@@ -1264,11 +1269,12 @@ async function computePeriodEndResults({
|
|
|
1264
1269
|
periodDecisions,
|
|
1265
1270
|
segmentFacts,
|
|
1266
1271
|
activePeriodIx,
|
|
1272
|
+
activeSegmentIx,
|
|
1267
1273
|
gameId
|
|
1268
1274
|
}, ctx, { reducers }) {
|
|
1269
1275
|
let extras = [];
|
|
1270
1276
|
let promises = [];
|
|
1271
|
-
const results = segmentResults.filter((result) => result.type ===
|
|
1277
|
+
const results = segmentResults.filter((result) => result.type === DB2.PlayerResultType.SEGMENT_END).map((result, ix, allResults) => {
|
|
1272
1278
|
const consolidationDecisions = periodDecisions.find(
|
|
1273
1279
|
(decision) => decision.playerId === result.playerId
|
|
1274
1280
|
);
|
|
@@ -1285,9 +1291,11 @@ async function computePeriodEndResults({
|
|
|
1285
1291
|
playerLevel: result.player.levelIx + 1,
|
|
1286
1292
|
playerExperience: result.player.experience,
|
|
1287
1293
|
consolidationDecisions,
|
|
1288
|
-
periodIx: activePeriodIx
|
|
1294
|
+
periodIx: activePeriodIx,
|
|
1295
|
+
segmentIx: activeSegmentIx
|
|
1289
1296
|
}
|
|
1290
1297
|
});
|
|
1298
|
+
logger_default.debug(actions);
|
|
1291
1299
|
const mapper = mapAction({
|
|
1292
1300
|
ctx,
|
|
1293
1301
|
gameId,
|
|
@@ -1316,7 +1324,7 @@ async function computePeriodEndResults({
|
|
|
1316
1324
|
})
|
|
1317
1325
|
];
|
|
1318
1326
|
return {
|
|
1319
|
-
type:
|
|
1327
|
+
type: DB2.PlayerResultType.PERIOD_END,
|
|
1320
1328
|
periodIx: activePeriodIx,
|
|
1321
1329
|
facts,
|
|
1322
1330
|
player: {
|
|
@@ -1342,7 +1350,7 @@ function computeSegmentStartResults(game, ctx, { reducers }) {
|
|
|
1342
1350
|
const nextSegmentIx = currentSegmentIx + 1;
|
|
1343
1351
|
let extras = [];
|
|
1344
1352
|
if (currentSegmentIx >= 0) {
|
|
1345
|
-
const results2 = game.activePeriod.activeSegment.results.filter((result) => result.type ===
|
|
1353
|
+
const results2 = game.activePeriod.activeSegment.results.filter((result) => result.type === DB2.PlayerResultType.SEGMENT_END).reduce((acc, result, ix, allResults) => {
|
|
1346
1354
|
const { result: facts, actions } = reducers.SegmentResult.apply(
|
|
1347
1355
|
result.facts,
|
|
1348
1356
|
{
|
|
@@ -1389,11 +1397,11 @@ function computeSegmentStartResults(game, ctx, { reducers }) {
|
|
|
1389
1397
|
...acc,
|
|
1390
1398
|
{
|
|
1391
1399
|
...common,
|
|
1392
|
-
type:
|
|
1400
|
+
type: DB2.PlayerResultType.SEGMENT_START
|
|
1393
1401
|
},
|
|
1394
1402
|
{
|
|
1395
1403
|
...common,
|
|
1396
|
-
type:
|
|
1404
|
+
type: DB2.PlayerResultType.SEGMENT_END
|
|
1397
1405
|
}
|
|
1398
1406
|
];
|
|
1399
1407
|
}, []);
|
|
@@ -1402,7 +1410,7 @@ function computeSegmentStartResults(game, ctx, { reducers }) {
|
|
|
1402
1410
|
extras
|
|
1403
1411
|
};
|
|
1404
1412
|
}
|
|
1405
|
-
const results = game.activePeriod.results.filter((result) => result.type ===
|
|
1413
|
+
const results = game.activePeriod.results.filter((result) => result.type === DB2.PlayerResultType.PERIOD_START).reduce((acc, result, ix, allResults) => {
|
|
1406
1414
|
const { result: facts } = reducers.SegmentResult.apply(result.facts, {
|
|
1407
1415
|
type: reducers.SegmentResult.ActionTypes.SEGMENT_RESULTS_INITIALIZE,
|
|
1408
1416
|
payload: {
|
|
@@ -1437,11 +1445,11 @@ function computeSegmentStartResults(game, ctx, { reducers }) {
|
|
|
1437
1445
|
...acc,
|
|
1438
1446
|
{
|
|
1439
1447
|
...common,
|
|
1440
|
-
type:
|
|
1448
|
+
type: DB2.PlayerResultType.SEGMENT_START
|
|
1441
1449
|
},
|
|
1442
1450
|
{
|
|
1443
1451
|
...common,
|
|
1444
|
-
type:
|
|
1452
|
+
type: DB2.PlayerResultType.SEGMENT_END
|
|
1445
1453
|
}
|
|
1446
1454
|
];
|
|
1447
1455
|
}, []);
|
|
@@ -1452,7 +1460,7 @@ function computeSegmentStartResults(game, ctx, { reducers }) {
|
|
|
1452
1460
|
}
|
|
1453
1461
|
function computeSegmentEndResults(game, ctx, { reducers }) {
|
|
1454
1462
|
let extras = [];
|
|
1455
|
-
const results = game.activePeriod.activeSegment.results.filter((result) => result.type ===
|
|
1463
|
+
const results = game.activePeriod.activeSegment.results.filter((result) => result.type === DB2.PlayerResultType.SEGMENT_END).map((result, ix, allResults) => {
|
|
1456
1464
|
const { result: facts, actions } = reducers.SegmentResult.apply(
|
|
1457
1465
|
result.facts,
|
|
1458
1466
|
{
|
|
@@ -1480,7 +1488,7 @@ function computeSegmentEndResults(game, ctx, { reducers }) {
|
|
|
1480
1488
|
periodIx: game.activePeriodIx,
|
|
1481
1489
|
segmentIx: game.activePeriod.activeSegmentIx,
|
|
1482
1490
|
playerId: result.playerId,
|
|
1483
|
-
type:
|
|
1491
|
+
type: DB2.PlayerResultType.SEGMENT_END
|
|
1484
1492
|
}
|
|
1485
1493
|
},
|
|
1486
1494
|
data: {
|
|
@@ -1514,12 +1522,13 @@ __export(PlayService_exports, {
|
|
|
1514
1522
|
saveDecisions: () => saveDecisions,
|
|
1515
1523
|
updateReadyState: () => updateReadyState
|
|
1516
1524
|
});
|
|
1525
|
+
var DB3 = __toESM(require("@prisma/client"));
|
|
1517
1526
|
async function performAction(args, ctx, { reducers }) {
|
|
1518
1527
|
const periodIx_segmentIx_playerId_type = {
|
|
1519
1528
|
periodIx: args.periodIx,
|
|
1520
1529
|
segmentIx: args.segmentIx,
|
|
1521
1530
|
playerId: args.playerId,
|
|
1522
|
-
type:
|
|
1531
|
+
type: DB3.PlayerResultType.SEGMENT_END
|
|
1523
1532
|
};
|
|
1524
1533
|
const previousResult = await ctx.prisma.playerResult.findUnique({
|
|
1525
1534
|
where: {
|
|
@@ -1534,7 +1543,7 @@ async function performAction(args, ctx, { reducers }) {
|
|
|
1534
1543
|
});
|
|
1535
1544
|
if (!previousResult)
|
|
1536
1545
|
return null;
|
|
1537
|
-
if (previousResult.game.status !==
|
|
1546
|
+
if (previousResult.game.status !== DB3.GameStatus.RUNNING) {
|
|
1538
1547
|
throw new Error("ACTIONS_NOT_ALLOWED");
|
|
1539
1548
|
}
|
|
1540
1549
|
const { result, events, notifications, isDirty, extras } = reducers.Actions.apply(previousResult.facts, {
|
|
@@ -1722,7 +1731,7 @@ async function getPlayerResult(args, ctx) {
|
|
|
1722
1731
|
periodIx: currentGame.activePeriodIx,
|
|
1723
1732
|
segmentIx: currentGame.activePeriod.activeSegmentIx,
|
|
1724
1733
|
playerId: args.playerId,
|
|
1725
|
-
type:
|
|
1734
|
+
type: DB3.PlayerResultType.SEGMENT_END
|
|
1726
1735
|
}
|
|
1727
1736
|
},
|
|
1728
1737
|
include: {
|
|
@@ -1944,7 +1953,11 @@ async function getPastResults(args, ctx) {
|
|
|
1944
1953
|
},
|
|
1945
1954
|
include: {
|
|
1946
1955
|
period: true,
|
|
1947
|
-
player:
|
|
1956
|
+
player: {
|
|
1957
|
+
include: {
|
|
1958
|
+
level: true
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1948
1961
|
}
|
|
1949
1962
|
});
|
|
1950
1963
|
return playerResults;
|
|
@@ -1968,5 +1981,6 @@ async function updateReadyState(args, ctx) {
|
|
|
1968
1981
|
GameService,
|
|
1969
1982
|
LearningElementState,
|
|
1970
1983
|
PlayService,
|
|
1971
|
-
UserRole
|
|
1984
|
+
UserRole,
|
|
1985
|
+
log
|
|
1972
1986
|
});
|
package/dist/lib/apollo.js
CHANGED
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
package/dist/lib/util.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as DB from '@prisma/client';
|
|
2
|
+
|
|
1
3
|
declare function setDifference(a: any, b: any, filterNoId?: boolean): any;
|
|
2
4
|
declare function setIntersection(a: any, b: any): any;
|
|
3
5
|
declare function debugLog(...args: any[]): void;
|
|
@@ -5,5 +7,14 @@ declare function diceRoll(seeds?: number[]): number;
|
|
|
5
7
|
declare function computeScenarioOutcome(trend: any, gap: any, diceRoll: any): any;
|
|
6
8
|
declare function computePercentChange(newValue: any, oldValue: any): number;
|
|
7
9
|
declare function withPercentChange(value: any, percentChange: any): number;
|
|
10
|
+
declare enum STATUS {
|
|
11
|
+
ACTIVE = "ACTIVE",
|
|
12
|
+
PAUSED = "PAUSED",
|
|
13
|
+
SCHEDULED = "SCHEDULED",
|
|
14
|
+
COMPLETED = "COMPLETED",
|
|
15
|
+
RESULTS = "RESULTS"
|
|
16
|
+
}
|
|
17
|
+
declare function computePeriodStatus(game: DB.Game, periodIndex: number): string;
|
|
18
|
+
declare function computeSegmentStatus(game: DB.Game, period: DB.Period, segmentIndex: number): string;
|
|
8
19
|
|
|
9
|
-
export { computePercentChange, computeScenarioOutcome, debugLog, diceRoll, setDifference, setIntersection, withPercentChange };
|
|
20
|
+
export { STATUS, computePercentChange, computePeriodStatus, computeScenarioOutcome, computeSegmentStatus, debugLog, diceRoll, setDifference, setIntersection, withPercentChange };
|