1
mirror of https://github.com/thepeacockproject/Peacock synced 2025-02-23 03:35:25 +01:00

Fix all broken challenges in ()

* Using state machine parser 5.2.0

* Correctly store and load challenge contexts

* Update THIRDPARTYNOTICES
This commit is contained in:
moonysolari 2023-01-16 13:30:06 -05:00 committed by GitHub
parent bfe82fe1e2
commit d78d5bf3ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 97 additions and 23 deletions

@ -2262,10 +2262,45 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---
Name: safer-buffer
Version: 2.1.2
License: MIT
Private: false
Description: Modern Buffer API polyfill without footguns
Repository: git+https://github.com/ChALkeR/safer-buffer.git
Author: Nikita Skovoroda <chalkerx@gmail.com> (https://github.com/ChALkeR)
License Copyright:
===
MIT License
Copyright (c) 2018 Nikita Skovoroda <chalkerx@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Name: iconv-lite
Version: 0.6.3
Version: 0.4.24
License: MIT
Private: false
Description: Convert character encodings in pure javascript.
@ -2401,7 +2436,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
---
Name: @peacockproject/statemachine-parser
Version: 5.1.0
Version: 5.2.0
License: Apache-2.0
Private: false
Description: IOI state machine conditional parser.

@ -335,7 +335,7 @@ export class ChallengeService extends ChallengeRegistry {
contractId,
gameVersion,
)
const profile = getUserData(session.userId, session.gameVersion)
for (const group of Object.keys(challengeGroups)) {
for (const challenge of challengeGroups[group]) {
const progression = this.getPersistentChallengeProgression(
@ -343,12 +343,17 @@ export class ChallengeService extends ChallengeRegistry {
challenge.Id,
gameVersion,
)
// For challenges with scopes being "profile" or "hit",
// update challenge progression with the user's progression data
const ctx =
fastClone(
(<ChallengeDefinitionLike>challenge.Definition)
?.Context || {},
) || {}
challenge.Definition.Scope === "profile" ||
challenge.Definition.Scope === "hit"
? profile.Extensions.ChallengeProgression[challenge.Id]
.State
: fastClone(
(<ChallengeDefinitionLike>challenge.Definition)
?.Context || {},
) || {}
challengeContexts[challenge.Id] = {
context: ctx,
@ -406,8 +411,12 @@ export class ChallengeService extends ChallengeRegistry {
event.Value,
options,
)
if (challenge.Definition.Scope === "profile") {
// For challenges with scopes being "profile" or "hit",
// save challenge progression to the user's progression data
if (
challenge.Definition.Scope === "profile" ||
challenge.Definition.Scope === "hit"
) {
const profile = getUserData(
session.userId,
session.gameVersion,
@ -417,11 +426,12 @@ export class ChallengeService extends ChallengeRegistry {
result.context
writeUserData(session.userId, session.gameVersion)
} else {
session.challengeContexts[challengeId].state = result.state
session.challengeContexts[challengeId].context =
result.context || challenge.Definition?.Context || {}
}
// Need to update session context for all challenges
// to correctly determine challenge completion
session.challengeContexts[challengeId].state = result.state
session.challengeContexts[challengeId].context =
result.context || challenge.Definition?.Context || {}
if (previousState !== "Success" && result.state === "Success") {
this.onChallengeCompleted(session, challenge)
@ -482,7 +492,18 @@ export class ChallengeService extends ChallengeRegistry {
gameVersion: GameVersion,
compiler: Compiler,
): CompiledChallengeTreeData[] {
const progression = getUserData(userId, gameVersion).Extensions
.ChallengeProgression
return challenges.map((challengeData) => {
// Update challenge progression with the user's latest progression data
if (
!progression[challengeData.Id].Completed &&
(challengeData.Definition.Scope === "profile" ||
challengeData.Definition.Scope === "hit")
) {
challengeData.Definition.Context =
progression[challengeData.Id].State
}
const compiled = compiler(
challengeData,
this.getPersistentChallengeProgression(

@ -747,6 +747,7 @@ profileRouter.post(
"/ContractSessionsService/Load",
jsonMiddleware(),
async (req: RequestWithJwt<never, LoadSaveBody>, res) => {
const userData = getUserData(req.jwt.unique_name, req.gameVersion)
if (
!req.body.contractSessionId ||
!req.body.saveToken ||
@ -757,7 +758,11 @@ profileRouter.post(
}
try {
await loadSession(req.body.contractSessionId, req.body.saveToken)
await loadSession(
req.body.contractSessionId,
req.body.saveToken,
userData,
)
} catch (e) {
log(
LogLevel.DEBUG,
@ -797,11 +802,24 @@ profileRouter.post(
async function loadSession(
sessionId: string,
token: string,
userData: UserProfile,
sessionData?: ContractSession,
): Promise<void> {
if (!sessionData) {
sessionData = await getContractSession(token + "_" + sessionId)
}
// Update challenge progression with the user's latest progression data
for (const cid in sessionData.challengeContexts) {
const scope =
controller.challengeService.getChallengeById(cid).Definition.Scope
if (
!userData.Extensions.ChallengeProgression[cid].Completed &&
(scope === "hit" || scope === "profile")
) {
sessionData.challengeContexts[cid].context =
userData.Extensions.ChallengeProgression[cid].State
}
}
contractSessions.set(sessionId, sessionData)
log(

@ -34,7 +34,7 @@
"send": "patch:send@npm:0.18.0#.yarn/patches/send-npm-0.18.0-faadf6353f.patch"
},
"dependencies": {
"@peacockproject/statemachine-parser": "^5.1.0",
"@peacockproject/statemachine-parser": "^5.2.0",
"@yarnpkg/fslib": "^3.0.0-rc.33",
"@yarnpkg/libzip": "^3.0.0-rc.33",
"atomically": "^1.7.0",

@ -14,7 +14,7 @@
"reversion": "node ../versionTypedefsPackageJson.mjs"
},
"dependencies": {
"@peacockproject/statemachine-parser": "^5.1.0",
"@peacockproject/statemachine-parser": "^5.2.0",
"@types/express": "^4.17.14",
"@types/node": "^18.8.5",
"atomically": "^1.7.0",

@ -388,7 +388,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@peacockproject/core@workspace:packaging/typedefs"
dependencies:
"@peacockproject/statemachine-parser": "npm:^5.1.0"
"@peacockproject/statemachine-parser": "npm:^5.2.0"
"@types/express": "npm:^4.17.14"
"@types/node": "npm:^18.8.5"
atomically: "npm:^1.7.0"
@ -406,7 +406,7 @@ __metadata:
resolution: "@peacockproject/monorepo@workspace:."
dependencies:
"@mixer/parallel-prettier": "npm:^2.0.3"
"@peacockproject/statemachine-parser": "npm:^5.1.0"
"@peacockproject/statemachine-parser": "npm:^5.2.0"
"@types/body-parser": "npm:1.19.2"
"@types/express": "npm:^4.17.15"
"@types/jsonwebtoken": "npm:^8.5.9"
@ -459,10 +459,10 @@ __metadata:
languageName: unknown
linkType: soft
"@peacockproject/statemachine-parser@npm:^5.1.0":
version: 5.1.0
resolution: "@peacockproject/statemachine-parser@npm:5.1.0"
checksum: 4c4c90e6259ad7d3836638cc51fe13179467960b57d8b67af0282244779ad113b12fd86365b726babd0a96fdc13b02b8fb0d9e7082cd4b56f6967f90b69f3f12
"@peacockproject/statemachine-parser@npm:^5.2.0":
version: 5.2.0
resolution: "@peacockproject/statemachine-parser@npm:5.2.0"
checksum: 753dacef0c447f39ab41d037b6de7446631c70e77b17d6670e52d5381685421213fd91bc2d5415acdcc6e1d6a93674f34ab3aed21427e23c5bcfdabf3649a08e
languageName: node
linkType: hard