@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/nexus.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
|
));
|
|
@@ -54,7 +58,7 @@ __export(nexus_exports, {
|
|
|
54
58
|
generateBaseSubscriptions: () => generateBaseSubscriptions
|
|
55
59
|
});
|
|
56
60
|
module.exports = __toCommonJS(nexus_exports);
|
|
57
|
-
var
|
|
61
|
+
var DB9 = __toESM(require("@prisma/client"));
|
|
58
62
|
var import_graphql_scalars = require("graphql-scalars");
|
|
59
63
|
var import_nexus10 = require("nexus");
|
|
60
64
|
|
|
@@ -382,33 +386,9 @@ var PeriodSegment = (0, import_nexus5.objectType)({
|
|
|
382
386
|
});
|
|
383
387
|
|
|
384
388
|
// src/types/Mutation.ts
|
|
389
|
+
var DB8 = __toESM(require("@prisma/client"));
|
|
385
390
|
var import_nexus6 = require("nexus");
|
|
386
391
|
|
|
387
|
-
// src/generated/ops.ts
|
|
388
|
-
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" } }] } }] };
|
|
389
|
-
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" } }] } }] };
|
|
390
|
-
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" } }] } }] } }] };
|
|
391
|
-
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] };
|
|
392
|
-
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" } }] } }] };
|
|
393
|
-
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" } }] } }] } }] };
|
|
394
|
-
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" } }] } }] } }] };
|
|
395
|
-
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] };
|
|
396
|
-
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] };
|
|
397
|
-
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] };
|
|
398
|
-
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] };
|
|
399
|
-
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] };
|
|
400
|
-
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] };
|
|
401
|
-
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] };
|
|
402
|
-
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] };
|
|
403
|
-
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] };
|
|
404
|
-
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] };
|
|
405
|
-
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] };
|
|
406
|
-
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] };
|
|
407
|
-
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] };
|
|
408
|
-
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] };
|
|
409
|
-
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] };
|
|
410
|
-
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] };
|
|
411
|
-
|
|
412
392
|
// src/services/AccountService.ts
|
|
413
393
|
var import_jsonwebtoken = __toESM(require("jsonwebtoken"));
|
|
414
394
|
var import_node_assert = require("assert");
|
|
@@ -463,6 +443,9 @@ async function loginAsTeam({ token }, ctx) {
|
|
|
463
443
|
return matchingPlayer;
|
|
464
444
|
}
|
|
465
445
|
|
|
446
|
+
// src/services/GameService.ts
|
|
447
|
+
var DB6 = __toESM(require("@prisma/client"));
|
|
448
|
+
|
|
466
449
|
// ../../node_modules/nanoid/index.js
|
|
467
450
|
var import_crypto = __toESM(require("crypto"), 1);
|
|
468
451
|
|
|
@@ -497,6 +480,22 @@ var nanoid = (size = 21) => {
|
|
|
497
480
|
var import_ramda = require("ramda");
|
|
498
481
|
var yup = __toESM(require("yup"));
|
|
499
482
|
|
|
483
|
+
// src/lib/logger.ts
|
|
484
|
+
var import_winston = __toESM(require("winston"));
|
|
485
|
+
var logger = import_winston.default.createLogger({
|
|
486
|
+
level: process.env.NODE_ENV === "development" ? "debug" : "info",
|
|
487
|
+
format: import_winston.default.format.combine(
|
|
488
|
+
import_winston.default.format.timestamp(),
|
|
489
|
+
import_winston.default.format.json()
|
|
490
|
+
),
|
|
491
|
+
defaultMeta: { service: "@gbl-uzh/platform" },
|
|
492
|
+
transports: [new import_winston.default.transports.Console()]
|
|
493
|
+
});
|
|
494
|
+
var logger_default = logger;
|
|
495
|
+
|
|
496
|
+
// src/services/EventService.ts
|
|
497
|
+
var DB5 = __toESM(require("@prisma/client"));
|
|
498
|
+
|
|
500
499
|
// src/lib/pubsub.ts
|
|
501
500
|
var import_graphql_yoga = require("graphql-yoga");
|
|
502
501
|
var pubSub = (0, import_graphql_yoga.createPubSub)();
|
|
@@ -539,7 +538,7 @@ async function receiveEvent(event, definedEvents, definedLevels, prisma) {
|
|
|
539
538
|
if (matchingEvent && matchingEvent.achievements?.length > 0) {
|
|
540
539
|
const awardedAchievements = await matchingEvent.achievements.reduce(
|
|
541
540
|
async (acc, achievement) => {
|
|
542
|
-
if (achievement.when ===
|
|
541
|
+
if (achievement.when === DB5.AchievementFrequency.FIRST && event.ctx.achievements.includes(achievement.id)) {
|
|
543
542
|
return acc;
|
|
544
543
|
}
|
|
545
544
|
const existingInstance = await prisma.achievementInstance.findFirst({
|
|
@@ -724,6 +723,7 @@ async function createGame({ name, playerCount }, ctx, { roleAssigner }) {
|
|
|
724
723
|
}
|
|
725
724
|
async function addGamePeriod({ gameId, facts }, ctx, { schema, reducers }) {
|
|
726
725
|
const validatedFacts = schema.validateSync(facts);
|
|
726
|
+
console.log(gameId);
|
|
727
727
|
const game = await ctx.prisma.game.findUnique({
|
|
728
728
|
where: {
|
|
729
729
|
id: gameId
|
|
@@ -747,6 +747,7 @@ async function addGamePeriod({ gameId, facts }, ctx, { schema, reducers }) {
|
|
|
747
747
|
});
|
|
748
748
|
if (!game)
|
|
749
749
|
return null;
|
|
750
|
+
console.log(game);
|
|
750
751
|
const index = game.periods[0]?.index + 1 || 0;
|
|
751
752
|
const { result: initializedFacts } = reducers.Period.apply(validatedFacts, {
|
|
752
753
|
type: reducers.Period.ActionTypes.PERIOD_INITIALIZE,
|
|
@@ -888,6 +889,7 @@ async function addPeriodSegment({
|
|
|
888
889
|
});
|
|
889
890
|
}
|
|
890
891
|
async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
892
|
+
logger_default.info("activating next period");
|
|
891
893
|
const game = await ctx.prisma.game.findUnique({
|
|
892
894
|
where: {
|
|
893
895
|
id: gameId
|
|
@@ -932,11 +934,12 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
932
934
|
});
|
|
933
935
|
if (!game)
|
|
934
936
|
return null;
|
|
937
|
+
logger_default.info(`game found, status ${game.status}`);
|
|
935
938
|
const currentPeriodIx = game.activePeriodIx;
|
|
936
939
|
const currentSegmentIx = game.activePeriod?.activeSegmentIx;
|
|
937
940
|
const nextPeriodIx = currentPeriodIx + 1;
|
|
938
941
|
switch (game.status) {
|
|
939
|
-
case
|
|
942
|
+
case DB6.GameStatus.SCHEDULED: {
|
|
940
943
|
const { results, extras } = computePeriodStartResults(
|
|
941
944
|
{
|
|
942
945
|
results: void 0,
|
|
@@ -961,7 +964,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
961
964
|
}
|
|
962
965
|
},
|
|
963
966
|
data: {
|
|
964
|
-
status:
|
|
967
|
+
status: DB6.GameStatus.PREPARATION,
|
|
965
968
|
activePeriodIx: nextPeriodIx,
|
|
966
969
|
activePeriod: {
|
|
967
970
|
connect: {
|
|
@@ -990,7 +993,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
990
993
|
]);
|
|
991
994
|
return result;
|
|
992
995
|
}
|
|
993
|
-
case
|
|
996
|
+
case DB6.GameStatus.RUNNING: {
|
|
994
997
|
if (!game.activePeriod?.activeSegment || !currentSegmentIx)
|
|
995
998
|
return null;
|
|
996
999
|
const { results, extras } = computeSegmentEndResults(game, ctx, {
|
|
@@ -1009,7 +1012,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
1009
1012
|
const result = await ctx.prisma.$transaction([
|
|
1010
1013
|
ctx.prisma.game.update({
|
|
1011
1014
|
data: {
|
|
1012
|
-
status:
|
|
1015
|
+
status: DB6.GameStatus.CONSOLIDATION
|
|
1013
1016
|
},
|
|
1014
1017
|
include: {
|
|
1015
1018
|
periods: {
|
|
@@ -1043,6 +1046,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
1043
1046
|
},
|
|
1044
1047
|
data: {
|
|
1045
1048
|
results: {
|
|
1049
|
+
// compute SEGMENT_END results using model
|
|
1046
1050
|
update: results
|
|
1047
1051
|
}
|
|
1048
1052
|
},
|
|
@@ -1058,7 +1062,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
1058
1062
|
]);
|
|
1059
1063
|
return result;
|
|
1060
1064
|
}
|
|
1061
|
-
case
|
|
1065
|
+
case DB6.GameStatus.CONSOLIDATION: {
|
|
1062
1066
|
if (!game.activePeriod?.activeSegment)
|
|
1063
1067
|
return null;
|
|
1064
1068
|
const { results, extras, promises } = await computePeriodEndResults(
|
|
@@ -1068,6 +1072,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
1068
1072
|
periodFacts: game.activePeriod.facts,
|
|
1069
1073
|
periodDecisions: game.activePeriod.decisions,
|
|
1070
1074
|
activePeriodIx: currentPeriodIx,
|
|
1075
|
+
activeSegmentIx: currentSegmentIx,
|
|
1071
1076
|
gameId: game.id
|
|
1072
1077
|
},
|
|
1073
1078
|
ctx,
|
|
@@ -1075,6 +1080,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
1075
1080
|
);
|
|
1076
1081
|
await Promise.all(promises);
|
|
1077
1082
|
const result = await ctx.prisma.$transaction([
|
|
1083
|
+
// update the status and active period of the current game
|
|
1078
1084
|
ctx.prisma.game.update({
|
|
1079
1085
|
where: {
|
|
1080
1086
|
id: gameId
|
|
@@ -1087,7 +1093,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
1087
1093
|
}
|
|
1088
1094
|
},
|
|
1089
1095
|
data: {
|
|
1090
|
-
status:
|
|
1096
|
+
status: DB6.GameStatus.RESULTS,
|
|
1091
1097
|
activePeriodIx: nextPeriodIx,
|
|
1092
1098
|
activePeriod: {
|
|
1093
1099
|
connect: {
|
|
@@ -1099,6 +1105,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
1099
1105
|
}
|
|
1100
1106
|
}
|
|
1101
1107
|
}),
|
|
1108
|
+
// create PERIOD_END results based on the previous SEGMENT_END results
|
|
1102
1109
|
ctx.prisma.period.update({
|
|
1103
1110
|
where: {
|
|
1104
1111
|
gameId_index: {
|
|
@@ -1119,8 +1126,9 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
1119
1126
|
]);
|
|
1120
1127
|
return result;
|
|
1121
1128
|
}
|
|
1122
|
-
case
|
|
1123
|
-
if (!game.activePeriod
|
|
1129
|
+
case DB6.GameStatus.RESULTS: {
|
|
1130
|
+
if (!game.activePeriod) {
|
|
1131
|
+
logger_default.warn("no next period available");
|
|
1124
1132
|
return null;
|
|
1125
1133
|
}
|
|
1126
1134
|
const { results, extras } = computePeriodStartResults(
|
|
@@ -1135,6 +1143,7 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
1135
1143
|
{ reducers }
|
|
1136
1144
|
);
|
|
1137
1145
|
const result = await ctx.prisma.$transaction([
|
|
1146
|
+
// update the status and active period of the current game
|
|
1138
1147
|
ctx.prisma.game.update({
|
|
1139
1148
|
where: {
|
|
1140
1149
|
id: gameId
|
|
@@ -1147,9 +1156,10 @@ async function activateNextPeriod({ gameId }, ctx, { reducers }) {
|
|
|
1147
1156
|
}
|
|
1148
1157
|
},
|
|
1149
1158
|
data: {
|
|
1150
|
-
status:
|
|
1159
|
+
status: DB6.GameStatus.PREPARATION
|
|
1151
1160
|
}
|
|
1152
1161
|
}),
|
|
1162
|
+
// create PERIOD_START results based on the previous PERIOD_END results
|
|
1153
1163
|
ctx.prisma.period.update({
|
|
1154
1164
|
where: {
|
|
1155
1165
|
gameId_index: {
|
|
@@ -1207,8 +1217,8 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
1207
1217
|
const currentSegmentIx = game.activePeriod.activeSegmentIx;
|
|
1208
1218
|
const nextSegmentIx = currentSegmentIx + 1;
|
|
1209
1219
|
switch (game.status) {
|
|
1210
|
-
case
|
|
1211
|
-
case
|
|
1220
|
+
case DB6.GameStatus.PREPARATION:
|
|
1221
|
+
case DB6.GameStatus.PAUSED: {
|
|
1212
1222
|
const { results, extras } = computeSegmentStartResults(game, ctx, {
|
|
1213
1223
|
reducers
|
|
1214
1224
|
});
|
|
@@ -1226,9 +1236,10 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
1226
1236
|
players: true
|
|
1227
1237
|
},
|
|
1228
1238
|
data: {
|
|
1229
|
-
status:
|
|
1239
|
+
status: DB6.GameStatus.RUNNING
|
|
1230
1240
|
}
|
|
1231
1241
|
}),
|
|
1242
|
+
// update the active segment of the current period
|
|
1232
1243
|
ctx.prisma.period.update({
|
|
1233
1244
|
where: {
|
|
1234
1245
|
gameId_index: {
|
|
@@ -1249,6 +1260,7 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
1249
1260
|
}
|
|
1250
1261
|
}
|
|
1251
1262
|
}),
|
|
1263
|
+
// SEGMENT INITIALIZATION
|
|
1252
1264
|
ctx.prisma.periodSegment.update({
|
|
1253
1265
|
where: {
|
|
1254
1266
|
gameId_periodIx_index: {
|
|
@@ -1265,23 +1277,9 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
1265
1277
|
}),
|
|
1266
1278
|
...extras
|
|
1267
1279
|
]);
|
|
1268
|
-
try {
|
|
1269
|
-
await ctx.prisma.player.updateMany({
|
|
1270
|
-
where: {
|
|
1271
|
-
game: {
|
|
1272
|
-
id: gameId
|
|
1273
|
-
}
|
|
1274
|
-
},
|
|
1275
|
-
data: {
|
|
1276
|
-
isReady: false
|
|
1277
|
-
}
|
|
1278
|
-
});
|
|
1279
|
-
} catch (e) {
|
|
1280
|
-
console.error(e);
|
|
1281
|
-
}
|
|
1282
1280
|
return result;
|
|
1283
1281
|
}
|
|
1284
|
-
case
|
|
1282
|
+
case DB6.GameStatus.RUNNING: {
|
|
1285
1283
|
if (!game.activePeriod?.activeSegment?.nextSegment) {
|
|
1286
1284
|
return null;
|
|
1287
1285
|
}
|
|
@@ -1300,7 +1298,7 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
1300
1298
|
players: true
|
|
1301
1299
|
},
|
|
1302
1300
|
data: {
|
|
1303
|
-
status:
|
|
1301
|
+
status: DB6.GameStatus.PAUSED
|
|
1304
1302
|
}
|
|
1305
1303
|
}),
|
|
1306
1304
|
ctx.prisma.periodSegment.update({
|
|
@@ -1320,6 +1318,17 @@ async function activateNextSegment({ gameId }, ctx, { reducers }) {
|
|
|
1320
1318
|
results: true
|
|
1321
1319
|
}
|
|
1322
1320
|
}),
|
|
1321
|
+
// reset player readiness
|
|
1322
|
+
ctx.prisma.player.updateMany({
|
|
1323
|
+
where: {
|
|
1324
|
+
game: {
|
|
1325
|
+
id: gameId
|
|
1326
|
+
}
|
|
1327
|
+
},
|
|
1328
|
+
data: {
|
|
1329
|
+
isReady: false
|
|
1330
|
+
}
|
|
1331
|
+
}),
|
|
1323
1332
|
...extras
|
|
1324
1333
|
]);
|
|
1325
1334
|
return result;
|
|
@@ -1465,7 +1474,7 @@ function computePeriodStartResults({ results, players, activePeriodIx, gameId, p
|
|
|
1465
1474
|
const nextPeriodIx = currentPeriodIx + 1;
|
|
1466
1475
|
let extras = [];
|
|
1467
1476
|
if (currentPeriodIx >= 0) {
|
|
1468
|
-
const result2 = results.filter((result3) => result3.type ===
|
|
1477
|
+
const result2 = results.filter((result3) => result3.type === DB6.PlayerResultType.PERIOD_END).map((result3, ix, allResults) => {
|
|
1469
1478
|
const { result: facts, actions } = reducers.PeriodResult.apply(result3, {
|
|
1470
1479
|
type: reducers.PeriodResult.ActionTypes.PERIOD_RESULTS_START,
|
|
1471
1480
|
payload: {
|
|
@@ -1483,7 +1492,7 @@ function computePeriodStartResults({ results, players, activePeriodIx, gameId, p
|
|
|
1483
1492
|
extras = [...extras, ...actions.map(mapper)];
|
|
1484
1493
|
}
|
|
1485
1494
|
return {
|
|
1486
|
-
type:
|
|
1495
|
+
type: DB6.PlayerResultType.PERIOD_START,
|
|
1487
1496
|
periodIx: currentPeriodIx,
|
|
1488
1497
|
facts,
|
|
1489
1498
|
player: {
|
|
@@ -1524,7 +1533,7 @@ function computePeriodStartResults({ results, players, activePeriodIx, gameId, p
|
|
|
1524
1533
|
extras = [...extras, ...actions.map(mapper)];
|
|
1525
1534
|
}
|
|
1526
1535
|
return {
|
|
1527
|
-
type:
|
|
1536
|
+
type: DB6.PlayerResultType.PERIOD_START,
|
|
1528
1537
|
periodIx: nextPeriodIx,
|
|
1529
1538
|
facts,
|
|
1530
1539
|
player: {
|
|
@@ -1550,11 +1559,12 @@ async function computePeriodEndResults({
|
|
|
1550
1559
|
periodDecisions,
|
|
1551
1560
|
segmentFacts,
|
|
1552
1561
|
activePeriodIx,
|
|
1562
|
+
activeSegmentIx,
|
|
1553
1563
|
gameId
|
|
1554
1564
|
}, ctx, { reducers }) {
|
|
1555
1565
|
let extras = [];
|
|
1556
1566
|
let promises = [];
|
|
1557
|
-
const results = segmentResults.filter((result) => result.type ===
|
|
1567
|
+
const results = segmentResults.filter((result) => result.type === DB6.PlayerResultType.SEGMENT_END).map((result, ix, allResults) => {
|
|
1558
1568
|
const consolidationDecisions = periodDecisions.find(
|
|
1559
1569
|
(decision) => decision.playerId === result.playerId
|
|
1560
1570
|
);
|
|
@@ -1571,9 +1581,11 @@ async function computePeriodEndResults({
|
|
|
1571
1581
|
playerLevel: result.player.levelIx + 1,
|
|
1572
1582
|
playerExperience: result.player.experience,
|
|
1573
1583
|
consolidationDecisions,
|
|
1574
|
-
periodIx: activePeriodIx
|
|
1584
|
+
periodIx: activePeriodIx,
|
|
1585
|
+
segmentIx: activeSegmentIx
|
|
1575
1586
|
}
|
|
1576
1587
|
});
|
|
1588
|
+
logger_default.debug(actions);
|
|
1577
1589
|
const mapper = mapAction({
|
|
1578
1590
|
ctx,
|
|
1579
1591
|
gameId,
|
|
@@ -1602,7 +1614,7 @@ async function computePeriodEndResults({
|
|
|
1602
1614
|
})
|
|
1603
1615
|
];
|
|
1604
1616
|
return {
|
|
1605
|
-
type:
|
|
1617
|
+
type: DB6.PlayerResultType.PERIOD_END,
|
|
1606
1618
|
periodIx: activePeriodIx,
|
|
1607
1619
|
facts,
|
|
1608
1620
|
player: {
|
|
@@ -1628,7 +1640,7 @@ function computeSegmentStartResults(game, ctx, { reducers }) {
|
|
|
1628
1640
|
const nextSegmentIx = currentSegmentIx + 1;
|
|
1629
1641
|
let extras = [];
|
|
1630
1642
|
if (currentSegmentIx >= 0) {
|
|
1631
|
-
const results2 = game.activePeriod.activeSegment.results.filter((result) => result.type ===
|
|
1643
|
+
const results2 = game.activePeriod.activeSegment.results.filter((result) => result.type === DB6.PlayerResultType.SEGMENT_END).reduce((acc, result, ix, allResults) => {
|
|
1632
1644
|
const { result: facts, actions } = reducers.SegmentResult.apply(
|
|
1633
1645
|
result.facts,
|
|
1634
1646
|
{
|
|
@@ -1675,11 +1687,11 @@ function computeSegmentStartResults(game, ctx, { reducers }) {
|
|
|
1675
1687
|
...acc,
|
|
1676
1688
|
{
|
|
1677
1689
|
...common,
|
|
1678
|
-
type:
|
|
1690
|
+
type: DB6.PlayerResultType.SEGMENT_START
|
|
1679
1691
|
},
|
|
1680
1692
|
{
|
|
1681
1693
|
...common,
|
|
1682
|
-
type:
|
|
1694
|
+
type: DB6.PlayerResultType.SEGMENT_END
|
|
1683
1695
|
}
|
|
1684
1696
|
];
|
|
1685
1697
|
}, []);
|
|
@@ -1688,7 +1700,7 @@ function computeSegmentStartResults(game, ctx, { reducers }) {
|
|
|
1688
1700
|
extras
|
|
1689
1701
|
};
|
|
1690
1702
|
}
|
|
1691
|
-
const results = game.activePeriod.results.filter((result) => result.type ===
|
|
1703
|
+
const results = game.activePeriod.results.filter((result) => result.type === DB6.PlayerResultType.PERIOD_START).reduce((acc, result, ix, allResults) => {
|
|
1692
1704
|
const { result: facts } = reducers.SegmentResult.apply(result.facts, {
|
|
1693
1705
|
type: reducers.SegmentResult.ActionTypes.SEGMENT_RESULTS_INITIALIZE,
|
|
1694
1706
|
payload: {
|
|
@@ -1723,11 +1735,11 @@ function computeSegmentStartResults(game, ctx, { reducers }) {
|
|
|
1723
1735
|
...acc,
|
|
1724
1736
|
{
|
|
1725
1737
|
...common,
|
|
1726
|
-
type:
|
|
1738
|
+
type: DB6.PlayerResultType.SEGMENT_START
|
|
1727
1739
|
},
|
|
1728
1740
|
{
|
|
1729
1741
|
...common,
|
|
1730
|
-
type:
|
|
1742
|
+
type: DB6.PlayerResultType.SEGMENT_END
|
|
1731
1743
|
}
|
|
1732
1744
|
];
|
|
1733
1745
|
}, []);
|
|
@@ -1738,7 +1750,7 @@ function computeSegmentStartResults(game, ctx, { reducers }) {
|
|
|
1738
1750
|
}
|
|
1739
1751
|
function computeSegmentEndResults(game, ctx, { reducers }) {
|
|
1740
1752
|
let extras = [];
|
|
1741
|
-
const results = game.activePeriod.activeSegment.results.filter((result) => result.type ===
|
|
1753
|
+
const results = game.activePeriod.activeSegment.results.filter((result) => result.type === DB6.PlayerResultType.SEGMENT_END).map((result, ix, allResults) => {
|
|
1742
1754
|
const { result: facts, actions } = reducers.SegmentResult.apply(
|
|
1743
1755
|
result.facts,
|
|
1744
1756
|
{
|
|
@@ -1766,7 +1778,7 @@ function computeSegmentEndResults(game, ctx, { reducers }) {
|
|
|
1766
1778
|
periodIx: game.activePeriodIx,
|
|
1767
1779
|
segmentIx: game.activePeriod.activeSegmentIx,
|
|
1768
1780
|
playerId: result.playerId,
|
|
1769
|
-
type:
|
|
1781
|
+
type: DB6.PlayerResultType.SEGMENT_END
|
|
1770
1782
|
}
|
|
1771
1783
|
},
|
|
1772
1784
|
data: {
|
|
@@ -1786,12 +1798,13 @@ function computeSegmentEndResults(game, ctx, { reducers }) {
|
|
|
1786
1798
|
}
|
|
1787
1799
|
|
|
1788
1800
|
// src/services/PlayService.ts
|
|
1801
|
+
var DB7 = __toESM(require("@prisma/client"));
|
|
1789
1802
|
async function performAction(args, ctx, { reducers }) {
|
|
1790
1803
|
const periodIx_segmentIx_playerId_type = {
|
|
1791
1804
|
periodIx: args.periodIx,
|
|
1792
1805
|
segmentIx: args.segmentIx,
|
|
1793
1806
|
playerId: args.playerId,
|
|
1794
|
-
type:
|
|
1807
|
+
type: DB7.PlayerResultType.SEGMENT_END
|
|
1795
1808
|
};
|
|
1796
1809
|
const previousResult = await ctx.prisma.playerResult.findUnique({
|
|
1797
1810
|
where: {
|
|
@@ -1806,7 +1819,7 @@ async function performAction(args, ctx, { reducers }) {
|
|
|
1806
1819
|
});
|
|
1807
1820
|
if (!previousResult)
|
|
1808
1821
|
return null;
|
|
1809
|
-
if (previousResult.game.status !==
|
|
1822
|
+
if (previousResult.game.status !== DB7.GameStatus.RUNNING) {
|
|
1810
1823
|
throw new Error("ACTIONS_NOT_ALLOWED");
|
|
1811
1824
|
}
|
|
1812
1825
|
const { result, events, notifications, isDirty, extras } = reducers.Actions.apply(previousResult.facts, {
|
|
@@ -1994,7 +2007,7 @@ async function getPlayerResult(args, ctx) {
|
|
|
1994
2007
|
periodIx: currentGame.activePeriodIx,
|
|
1995
2008
|
segmentIx: currentGame.activePeriod.activeSegmentIx,
|
|
1996
2009
|
playerId: args.playerId,
|
|
1997
|
-
type:
|
|
2010
|
+
type: DB7.PlayerResultType.SEGMENT_END
|
|
1998
2011
|
}
|
|
1999
2012
|
},
|
|
2000
2013
|
include: {
|
|
@@ -2206,7 +2219,11 @@ async function getPastResults(args, ctx) {
|
|
|
2206
2219
|
},
|
|
2207
2220
|
include: {
|
|
2208
2221
|
period: true,
|
|
2209
|
-
player:
|
|
2222
|
+
player: {
|
|
2223
|
+
include: {
|
|
2224
|
+
level: true
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2210
2227
|
}
|
|
2211
2228
|
});
|
|
2212
2229
|
return playerResults;
|
|
@@ -2393,7 +2410,7 @@ function generateBaseMutations({
|
|
|
2393
2410
|
const facts = JSON.parse(args.payload);
|
|
2394
2411
|
return saveDecisions(
|
|
2395
2412
|
{
|
|
2396
|
-
decisionType:
|
|
2413
|
+
decisionType: DB8.PlayerDecisionType.CONSOLIDATION,
|
|
2397
2414
|
facts
|
|
2398
2415
|
},
|
|
2399
2416
|
ctx
|
|
@@ -2506,7 +2523,7 @@ var JsonScalar = (0, import_nexus10.asNexusMethod)(import_graphql_scalars.JSONOb
|
|
|
2506
2523
|
var DateScalar = (0, import_nexus10.asNexusMethod)(import_graphql_scalars.DateTimeResolver, "date");
|
|
2507
2524
|
var UserRole3 = (0, import_nexus10.enumType)({
|
|
2508
2525
|
name: "UserRole",
|
|
2509
|
-
members: Object.values(
|
|
2526
|
+
members: Object.values(DB9.UserRole)
|
|
2510
2527
|
});
|
|
2511
2528
|
var Event = (0, import_nexus10.objectType)({
|
|
2512
2529
|
name: "Event",
|