local A=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local v=A:WaitForChild("\099\111\109\109\111\110")local Y=A:WaitForChild("\108\105\098")local i=script.Parent local C=require(Y:WaitForChild("\080\105\122\122\097\065\108\112\097\099\097"))local R=v:WaitForChild("\109\111\100\117\108\101")local M=i:WaitForChild("\109\111\100\117\108\101")local k=C.GameCore.new()k:registerChildrenAsModules(R)k:registerChildrenAsModules(M)k:load()_G.core=k;((k:getModule("\083\116\111\114\101\067\111\110\116\097\105\110\101\114")):getStore()):andThen(function(A)_G.store=A end)
-- local ServerScriptService = game:GetService("ServerScriptService")

-- local ReplicatedStorage = game:GetService("ReplicatedStorage")

-- local common = ReplicatedStorage:WaitForChild("common")
-- local commonUtil = common:WaitForChild("util")
-- local lib = ReplicatedStorage:WaitForChild("lib")
-- local moduleBin = ServerScriptService:WaitForChild("module")
-- local middleware = ServerScriptService:WaitForChild("middleware")

-- local Rodux = require(lib:WaitForChild("Rodux"))
-- local ServerApi = require(ServerScriptService:WaitForChild("ServerApi"))
-- local Dictionary = require(common.Dictionary)
-- local Actions = require(common:WaitForChild("Actions"))
-- local Thunks = require(common:WaitForChild("Thunks"))

-- local callOnAll = require(commonUtil:WaitForChild("callOnAll"))
-- local reducer = require(common:WaitForChild("commonReducer"))
-- local networkMiddleware = require(middleware:WaitForChild("networkMiddleware"))
-- local dataSaveMiddleware = require(middleware:WaitForChild("dataSaveMiddleware"))

-- local Server = {}

-- Server.modules = {
-- 	PlayerHandler = require(moduleBin:WaitForChild("PlayerHandler")),
-- 	Cashier = require(moduleBin:WaitForChild("Cashier")),
-- 	CharacterHandler = require(moduleBin:WaitForChild("CharacterHandler")),
-- 	Coins = require(moduleBin:WaitForChild("Coins")),
-- 	AchievementAwarder = require(moduleBin:WaitForChild("AchievementAwarder")),
-- 	PortalsListener = require(moduleBin:WaitForChild("PortalsListener")),
-- 	DayNight = require(moduleBin:WaitForChild("DayNight")),
-- 	PlayerEquipment = require(moduleBin:WaitForChild("PlayerEquipment")),
-- 	LoginBonus = require(moduleBin:WaitForChild("LoginBonus")),
-- }

-- Server.toLoad = {
-- 	Server.modules.Cashier,
-- 	Server.modules.PlayerEquipment,
-- 	Server.modules.DayNight,
-- 	Server.modules.PortalsListener,
-- 	Server.modules.AchievementAwarder,
-- 	Server.modules.Coins,
-- 	Server.modules.CharacterHandler,
-- 	Server.modules.LoginBonus,
-- 	Server.modules.PlayerHandler,
-- }

-- -- From Lucien Greathouses RDC 2018 project
-- -- https://github.com/LPGhatguy/rdc-project/blob/master/src/server/main.lua
-- local function replicate(action,beforeState,afterState)
-- 	-- Create a version of each action that's explicitly flagged as
-- 	-- replicated so that clients can handle them explicitly.
-- 	local replicatedAction = Dictionary.join(action, {
-- 		replicated = true,
-- 	})

-- 	-- This is an action that everyone should see!
-- 	if action.replicateBroadcast then
-- 		return Server.api:storeAction(ServerApi.AllPlayers, replicatedAction)
-- 	end

-- 	-- This is an action that we want a specific player to see.
-- 	if action.replicateTo ~= nil then
-- 		local player = action.replicateTo

-- 		if player == nil then
-- 			return
-- 		end

-- 		return Server.api:storeAction(player, replicatedAction)
-- 	end

-- 	return
-- end

-- function Server:getModule(name)
-- 	assert(self.modules[name],"No such module: "..name)
-- 	return self.modules[name]
-- end

-- function Server:load()
-- 	print("Starting server.")
-- 	self.store = Rodux.Store.new(reducer, nil, {
-- 		Rodux.thunkMiddleware,
-- 		networkMiddleware(replicate),
-- 		dataSaveMiddleware,
-- 		--Rodux.loggerMiddleware,
-- 	})

-- 	self.api = ServerApi.create({
-- 		requestCoinCollect = function(player,coinSpawn)
-- 			self:getModule("Coins"):requestCoinCollect(player,coinSpawn)
-- 		end,

-- 		portalActivate = function(player,portalName)
-- 			self.store:dispatch(Actions.PORTAL_ACTIVATE(player,portalName))
-- 			self:getModule("PortalsListener"):portalActivate(player,portalName)
-- 		end,

-- 		buyAsset = function(player,assetId)
-- 			self.store:dispatch(Thunks.ASSET_TRYBUY(player, assetId))
-- 		end,

-- 		buyDevproduct = function(player,devproductId)
-- 			self:getModule("Cashier"):PromptPurchase(player,devproductId)
-- 		end,

-- 		equipAsset = function(player,assetId)
-- 			self.store:dispatch(Thunks.ASSET_TRYEQUIP(player, assetId))
-- 		end,

-- 		unequipAsset = function(player,assetId)
-- 			self.store:dispatch(Actions.ASSET_UNEQUIP(player, assetId))
-- 		end,

-- 		equippedAction = function(player, assetid, payload)
-- 			print(("%s used %s"):format(player.Name,assetid))
-- 		end,
-- 	})
-- 	self.api:connect()

-- 	print("initializing modules")
-- 	-- init all modules
-- 	callOnAll(self.toLoad,"init")

-- 	print("starting modules")
-- 	-- start all modules
-- 	callOnAll(self.toLoad,"start",Server)
-- end

-- -- Load modules
-- Server:load()
-- print("server started!")

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local common = ReplicatedStorage:WaitForChild("common")
local lib = ReplicatedStorage:WaitForChild("lib")
local src = script.Parent

local PizzaAlpaca = require(lib:WaitForChild("PizzaAlpaca"))

local module = common:WaitForChild("module")

local sidedmodule = src:WaitForChild("module")

local gameCore = PizzaAlpaca.GameCore.new()

gameCore:registerChildrenAsModules(module)
gameCore:registerChildrenAsModules(sidedmodule)

gameCore:load()
_G.core = gameCore

gameCore:getModule("StoreContainer"):getStore():andThen(function(store)
    _G.store = store
end)