mirror of
https://github.com/Deathgarden-Rebirth/Deathgarden_Rebirth-Rewrite.git
synced 2026-04-25 16:15:23 -05:00
Added handling of the "playerId" parameter to InitOrGetGroups.
This commit is contained in:
parent
80e736d878
commit
d1b8e65624
|
|
@ -14,6 +14,7 @@
|
|||
use App\Http\Responses\Api\Player\InitOrGetGroupsResponse;
|
||||
use App\Http\Responses\Api\Player\UpdateMetadataResponse;
|
||||
use App\Models\Game\PickedChallenge;
|
||||
use App\Models\User\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
|
@ -23,7 +24,15 @@ class MetadataController extends Controller
|
|||
public function initOrGetGroups(InitOrGetGroupsRequest $request)
|
||||
{
|
||||
$response = new InitOrGetGroupsResponse();
|
||||
$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 = User::find($request->playerId);
|
||||
else
|
||||
$user = Auth::user();
|
||||
|
||||
foreach (ItemGroupType::cases() as $group) {
|
||||
if ($group == ItemGroupType::None)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ class InitOrGetGroupsRequest extends FormRequest
|
|||
|
||||
public bool $skipMetadataGroups;
|
||||
|
||||
public ?string $playerId;
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
|
|
@ -30,6 +32,7 @@ public function rules(): array
|
|||
return [
|
||||
'data.skipProgressionGroups' => 'bool|required',
|
||||
'data.skipMetadataGroups' => 'bool|required',
|
||||
'data.playerId' => 'string'
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -37,5 +40,6 @@ protected function passedValidation()
|
|||
{
|
||||
$this->skipProgressionGroups = $this->input('data.skipProgressionGroups');
|
||||
$this->skipMetadataGroups = $this->input('data.skipMetadataGroups');
|
||||
$this->playerId = $this->input('data.playerId');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user