Added check that automatically sets the picked challenges of the new lvl 10 default items to completed so that they don't show up in game.

This commit is contained in:
Vari
2024-12-19 22:30:33 +01:00
parent 869f84832e
commit 9d1bf68f28
3 changed files with 26 additions and 4 deletions

View File

@@ -140,6 +140,17 @@ private function handleUpdateCharacterMetadata(UpdateMetadataGroupRequest &$requ
$convertedIds = UuidHelper::convertFromHexToUuidCollecton($request->metadata['equippedWeapons'], true);
$characterData->equippedWeapons()->sync($convertedIds);
$characterConfig = $characterData->character->getCharacter()->getItemConfigClass();
$defaultCompletedIds = [
...$characterConfig::getDefaultEquippedBonuses(),
...$characterConfig::getDefaultEquippedWeapons(),
...$characterConfig::getDefaultEquipment(),
...$characterConfig::getDefaultPowers(),
...$characterConfig::getDefaultEquippedPerks(),
];
$defaultCompletedIds = UuidHelper::convertFromHexToUuidCollecton($defaultCompletedIds, true);
foreach ($request->metadata['pickedChallenges'] as $picked) {
$itemId = Uuid::fromHexadecimal(new Hexadecimal($picked['itemId']));
$pickedChallenge = $characterData->getPicketChallengeForItem($itemId);
@@ -153,11 +164,16 @@ private function handleUpdateCharacterMetadata(UpdateMetadataGroupRequest &$requ
$assetPath = $challenge['challengeAsset'];
$completionValue = static::reducePickedChallengeCompletionValue($assetPath, $challenge['challengeCompletionValue']);
$newPicked = new PickedChallenge([
$attributes = [
'id' => $challengeId->toString(),
'completion_value' => $completionValue,
'asset_path' => $assetPath,
]);
];
if($defaultCompletedIds->has($itemId->toString()))
$attributes['progress'] = $completionValue;
$newPicked = new PickedChallenge($attributes);
$newPicked->characterData()->associate($characterData);
$newPicked->catalogItem()->associate($itemId->toString());