Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Commit

Permalink
Game => DataModel
Browse files Browse the repository at this point in the history
  • Loading branch information
Kampfkarren committed Oct 19, 2018
1 parent b71a0f6 commit 9719f83
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions lib/Habitat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local Instance = import("./Instance")
local TaskScheduler = import("./TaskScheduler")
local createEnvironment = import("./createEnvironment")
local fs = import("./fs")
local Game = import("./instances/Game")
local DataModel = import("./instances/DataModel")
local validateType = import("./validateType")
local assign = import("./assign")

Expand All @@ -21,7 +21,7 @@ Habitat.__index = Habitat

function Habitat.new(settings)
local habitat = {
game = Game:new(),
game = DataModel:new(),
taskScheduler = TaskScheduler.new(),
settings = settings or {},
environment = nil,
Expand Down
4 changes: 2 additions & 2 deletions lib/instances/BaseInstance_spec.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local Game = import("./Game")
local DataModel = import("./DataModel")
local Folder = import("./Folder")
local typeof = import("../functions/typeof")

Expand Down Expand Up @@ -367,7 +367,7 @@ describe("instances.BaseInstance", function()
it("should exclude game", function()
local instance = BaseInstance:new()
instance.Name = "Test"
local other = Game:new()
local other = DataModel:new()
other.Name = "Parent"

instance.Parent = other
Expand Down
24 changes: 12 additions & 12 deletions lib/instances/Game.lua → lib/instances/DataModel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ local UserInputService = import("./UserInputService")
local VirtualInputManager = import("./VirtualInputManager")
local Workspace = import("./Workspace")

local Game = BaseInstance:extend("DataModel")
local DataModel = BaseInstance:extend("DataModel")

function Game:init(instance)
function DataModel:init(instance)
AnalyticsService:new().Parent = instance
ContentProvider:new().Parent = instance
CoreGui:new().Parent = instance
Expand All @@ -56,7 +56,7 @@ function Game:init(instance)
Workspace:new().Parent = instance
end

function Game.prototype:GetService(serviceName)
function DataModel.prototype:GetService(serviceName)
local service = self:FindFirstChildOfClass(serviceName)

if service then
Expand All @@ -68,52 +68,52 @@ function Game.prototype:GetService(serviceName)
error(string.format("Cannot get service %q", tostring(serviceName)), 2)
end

Game.properties.CreatorId = InstanceProperty.readOnly({
DataModel.properties.CreatorId = InstanceProperty.readOnly({
getDefault = function()
return 0
end,
})

Game.properties.CreatorType = InstanceProperty.readOnly({
DataModel.properties.CreatorType = InstanceProperty.readOnly({
getDefault = function()
return CreatorType.User
end,
})

Game.properties.GameId = InstanceProperty.readOnly({
DataModel.properties.GameId = InstanceProperty.readOnly({
getDefault = function()
return 0
end,
})

Game.properties.JobId = InstanceProperty.readOnly({
DataModel.properties.JobId = InstanceProperty.readOnly({
getDefault = function()
return ""
end,
})

Game.properties.PlaceId = InstanceProperty.readOnly({
DataModel.properties.PlaceId = InstanceProperty.readOnly({
getDefault = function()
return 0
end,
})

Game.properties.PlaceVersion = InstanceProperty.readOnly({
DataModel.properties.PlaceVersion = InstanceProperty.readOnly({
getDefault = function()
return 0
end,
})

Game.properties.VIPServerId = InstanceProperty.readOnly({
DataModel.properties.VIPServerId = InstanceProperty.readOnly({
getDefault = function()
return ""
end,
})

Game.properties.VIPServerOwnerId = InstanceProperty.readOnly({
DataModel.properties.VIPServerOwnerId = InstanceProperty.readOnly({
getDefault = function()
return 0
end,
})

return Game
return DataModel
12 changes: 6 additions & 6 deletions lib/instances/Game_spec.lua → lib/instances/DataModel_spec.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
local Game = import("./Game")
local DataModel = import("./DataModel")
local typeof = import("../functions/typeof")

describe("instances.Game", function()
describe("instances.DataModel", function()
it("should instantiate", function()
local instance = Game:new()
local instance = DataModel:new()

assert.not_nil(instance)
end)

describe("GetService", function()
it("should have GetService", function()
local instance = Game:new()
local instance = DataModel:new()

local ReplicatedStorage = instance:GetService("ReplicatedStorage")

Expand All @@ -19,7 +19,7 @@ describe("instances.Game", function()
end)

it("should throw when given invalid service names", function()
local instance = Game:new()
local instance = DataModel:new()

assert.has.errors(function()
instance:GetService("SOMETHING THAT WILL NEVER EXIST")
Expand All @@ -28,7 +28,7 @@ describe("instances.Game", function()
end)

it("should have properties defined", function()
local instance = Game:new()
local instance = DataModel:new()

assert.equal(typeof(instance.CreatorId), "number")
assert.equal(typeof(instance.CreatorType), "EnumItem")
Expand Down
2 changes: 1 addition & 1 deletion lib/instances/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ local names = {
"ContentProvider",
"CoreGui",
"CorePackages",
"DataModel",
"Folder",
"Frame",
"Game",
"GuiButton",
"GuiObject",
"GuiService",
Expand Down

0 comments on commit 9719f83

Please sign in to comment.