diff --git a/dist/app/Http/Controllers/Api/Player/MetadataController.php b/dist/app/Http/Controllers/Api/Player/MetadataController.php index b849d49..fad709d 100644 --- a/dist/app/Http/Controllers/Api/Player/MetadataController.php +++ b/dist/app/Http/Controllers/Api/Player/MetadataController.php @@ -29,10 +29,10 @@ public function initOrGetGroups(InitOrGetGroupsRequest $request) // if not use the current authenticated user from this session. // This is important because the hosts requests the progression and metadata groups for the other players // for tracking challenges and so on. - if($request->playerId !== null) - $user = User::find($request->playerId); - else + if($request->playerId === null) $user = Auth::user(); + else + $user = User::find($request->playerId); foreach (ItemGroupType::cases() as $group) { if ($group == ItemGroupType::None) @@ -75,7 +75,16 @@ public function updateMetadataGroup(UpdateMetadataGroupRequest $request) private function handleUpdateCharacterMetadata(UpdateMetadataGroupRequest &$request): string|bool { - $user = Auth::user(); + // If the request has set a player Id, use it. + // if not use the current authenticated user from this session. + // This is important because the hosts requests the progression and metadata groups for the other players + // for tracking challenges and so on. + if($request->playerId === null) + $user = Auth::user(); + else + $user = User::find($request->playerId); + + $characterData = $user->playerData()->characterDataForCharacter($request->group->getCharacter()); $convertedIds = UuidHelper::convertFromHexToUuidCollecton($request->metadata['equipment'], true); @@ -127,7 +136,14 @@ private function handleUpdateCharacterMetadata(UpdateMetadataGroupRequest &$requ private function handleUpdatePlayerMetadata(UpdateMetadataGroupRequest &$request): string|bool { - $user = Auth::user(); + // If the request has set a player Id, use it. + // if not use the current authenticated user from this session. + // This is important because the hosts requests the progression and metadata groups for the other players + // for tracking challenges and so on. + if($request->playerId === null) + $user = Auth::user(); + else + $user = User::find($request->playerId); $playerData = $user->playerData(); $playerData->last_faction = Faction::tryFrom($request->metadata['lastPlayedFaction']); diff --git a/dist/app/Http/Requests/Api/Player/UpdateMetadataGroupRequest.php b/dist/app/Http/Requests/Api/Player/UpdateMetadataGroupRequest.php index 0fd3c5a..67c2742 100644 --- a/dist/app/Http/Requests/Api/Player/UpdateMetadataGroupRequest.php +++ b/dist/app/Http/Requests/Api/Player/UpdateMetadataGroupRequest.php @@ -21,6 +21,8 @@ class UpdateMetadataGroupRequest extends FormRequest public array $metadata; + public ?string $playerId; + /** * Determine if the user is authorized to make this request. */ @@ -49,6 +51,7 @@ protected function passedValidation() $this->group = MetadataGroup::tryFrom($this->input('data.objectId')); $this->version = $this->input('data.version'); $this->metadata = $this->input('data.metadata'); + $this->playerId = $this->input('data.playerId'); $this->reason = UpdateMetadataReason::tryFrom($this->input('data.reason')); if ($this->reason === null) { diff --git a/dist/app/Models/User/PlayerData.php b/dist/app/Models/User/PlayerData.php index 12dc0d2..d699373 100644 --- a/dist/app/Models/User/PlayerData.php +++ b/dist/app/Models/User/PlayerData.php @@ -147,7 +147,7 @@ public function addFactionExperience(Faction $faction): PlayerData if($faction === Faction::Runner) { ++$this->runner_faction_experience; - if($this->runner_faction_level >= static::getRemainingFactionExperience($this->runner_faction_level)) { + if($this->runner_faction_experience >= static::getRemainingFactionExperience($this->runner_faction_level)) { ++$this->runner_faction_level; $this->runner_faction_experience = 0; } @@ -155,7 +155,7 @@ public function addFactionExperience(Faction $faction): PlayerData else if($faction === Faction::Hunter) { ++$this->hunter_faction_experience; - if($this->hunter_faction_level >= static::getRemainingFactionExperience($this->hunter_faction_level)) { + if($this->hunter_faction_experience >= static::getRemainingFactionExperience($this->hunter_faction_level)) { ++$this->hunter_faction_level; $this->hunter_faction_experience = 0; }