local Z=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local I=Z:WaitForChild("\077\111\100\117\108\101\115")local S=require(I.src.utils.Logger)local C=require(I.src.utils.Dict)local f=require(I.src.utils.None)local L=game:GetService("\080\108\097\121\101\114\115")local n=require(I.src.AudioPlayer)local y=L.LocalPlayer local function i(Z,I)Z=Z or{isPlaying=false}if I.type=="\099\108\105\101\110\116\070\105\110\105\115\104\071\097\109\101"then S:d("\099\108\105\101\110\116\070\105\110\105\115\104\071\097\109\101\058",I.playerId,I.roomId)n.playAudio("\070\105\110\105\115\104")return C.join(Z,{isPlaying=false;roomId=f,lastFinishedRoomId=I.roomId;isFinishScreenOpen=true})elseif I.type=="\099\108\105\101\110\116\083\116\097\114\116\071\097\109\101"then S:d("\099\108\105\101\110\116\083\116\097\114\116\071\097\109\101\058",I.playerId,y.UserId)return C.join(Z,{isPlaying=true})elseif I.type=="\099\108\105\101\110\116\083\101\116\082\111\111\109"then return C.join(Z,{roomId=I.roomId;lastFinishedRoomId=f;isFinishScreenOpen=false})elseif I.type=="\099\108\105\101\110\116\083\101\116\071\104\111\115\116\105\110\103"then S:w("\099\108\105\101\110\116\083\101\116\071\104\111\115\116\105\110\103")return C.join(Z,{isGhosting=true})elseif I.type=="\099\108\105\101\110\116\082\101\115\101\116"then S:w("\099\108\105\101\110\116\082\101\115\101\116\046")return C.join(Z,{roomId=f,isGhosting=false;isPlaying=false})elseif I.type=="\099\108\105\101\110\116\069\113\117\105\112\112\101\100"then return C.join(Z,{equippedItems=I.itemIds})elseif I.type=="\099\108\105\101\110\116\083\108\111\116\115\067\111\117\110\116"then return C.join(Z,{playerSlotsCount=I.slotsCount})end return Z end return i
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Modules = ReplicatedStorage:WaitForChild('Modules')
local logger = require(Modules.src.utils.Logger)
local Dict = require(Modules.src.utils.Dict)
local None = require(Modules.src.utils.None)
local Players = game:GetService('Players')
local AudioPlayer = require(Modules.src.AudioPlayer)

local LocalPlayer = Players.LocalPlayer

local function player(state, action)
	state = state or { isPlaying = false }

	if action.type == 'clientFinishGame' then
		logger:d('clientFinishGame:', action.playerId, action.roomId)

		AudioPlayer.playAudio('Finish')

		return Dict.join(state, {
			isPlaying = false,
			roomId = None,
			lastFinishedRoomId = action.roomId,
			isFinishScreenOpen = true,
		})
	elseif action.type == 'clientStartGame' then
		logger:d('clientStartGame:', action.playerId, LocalPlayer.UserId)

		return Dict.join(state, { isPlaying = true })
	elseif action.type == 'clientSetRoom' then
		return Dict.join(state, {
			roomId = action.roomId,
			lastFinishedRoomId = None,
			isFinishScreenOpen = false,
		})
	elseif action.type == 'clientSetGhosting' then
		logger:w('clientSetGhosting')
		return Dict.join(state, { isGhosting = true })
	elseif action.type == 'clientReset' then
		logger:w('clientReset.')
		return Dict.join(state, {
			roomId = None,
			isGhosting = false,
			isPlaying = false,
		})
	elseif action.type == 'clientEquipped' then
		return Dict.join(state, { equippedItems = action.itemIds })
	elseif action.type == 'clientSlotsCount' then
		return Dict.join(state, { playerSlotsCount = action.slotsCount })
	end

	return state
end

return player