wip(bunsik): 서버 개편 — 갈래 업그레이드, 배치형 테이블·의자·조리대, 실내·2층 건물과 디자인 5종, 알바생 역할·시급, 홍보·쫓아내기·손님 러시, 가게 이름 필터·무지개, 세이브 버전 2 이전

로블록스 서버 통합 테스트 tests/cloud/server.luau 1003개 통과(저장 버전 25). 화면 UI는 다음 커밋.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-14 01:34:37 +09:00
parent 52668f219a
commit 51298fcfa1
15 changed files with 2701 additions and 596 deletions

View File

@@ -48,6 +48,13 @@
| Rainbow | 무지개 이름(게임패스 + 켜짐) |
| Design | 건물 디자인 |
| ShieldUntil | 손님 쫓아내기 보호가 끝나는 서버 시각 |
| Origin | 부지 기준 CFrame. 배치 좌표 (x, z, 층 f) → 월드: `Origin * CFrame.new(x, Floor.BASE_Y + (f == 2 and Floor.FLOOR2_Y or 0), z)` |
## 배치 물건 모델
부지 안 `Upgrades/Furniture` 폴더에 서버가 짓습니다. 꾸미기 화면이 눌러서 고를 수 있게 모델마다 속성을 붙입니다.
- `ItemKind` = "table" | "chair" | "decor" | "stove", `ItemIndex` = Layout 목록 번호(조리대는 1)
- 조리대(포장마차 수레)는 `Plot.Base.Stall` 모델 그대로 옮깁니다(인스턴스가 바뀌지 않아서 조리대 버튼이 계속 붙어 있음).
## 요청 (Action kind, arg)

View File

@@ -6,12 +6,22 @@ local RunService = game:GetService("RunService")
local ServerScriptService = game:GetService("ServerScriptService")
local ProfileStore = require(ServerScriptService.Vendor.ProfileStore)
local Economy = require(game:GetService("ReplicatedStorage").Shared.Economy)
local Floor = require(game:GetService("ReplicatedStorage").Shared.Floor)
local Data = {}
Data.TEMPLATE = {
Money = 0,
Bought = 0,
Bought = 0, -- 예전(버전 1) 한 줄 업그레이드 수. 버전 2로 옮긴 뒤에는 쓰지 않음
Levels = {} :: { [string]: number }, -- 업그레이드 갈래 레벨(Economy.TRACKS)
Layout = {} :: any, -- 배치(Floor.Layout). 빈 표면 기본 배치
Staff = {} :: { [string]: number }, -- 고용한 알바 수
ShopName = "", -- 가게 이름 원문("" = 기본 이름)
Rainbow = true, -- 무지개 이름 켜기(게임패스가 있을 때만 보임)
Design = "Basic",
RushLeft = 0, -- 손님 러시 남은 초
KickCredits = 0, -- 산 "손님 쫓아내기" 남은 횟수
PurchaseIdCache = {} :: { string },
TutorialDone = false,
Lang = "", -- "" = 계정 언어 자동
@@ -19,7 +29,7 @@ Data.TEMPLATE = {
Sfx = true, -- 효과음
Served = 0,
Earned = 0,
Version = 1,
Version = 2,
}
export type SaveData = typeof(Data.TEMPLATE)
@@ -48,7 +58,10 @@ function Data.load(player: Player): any
return nil
end
profile:AddUserId(player.UserId)
-- Reconcile 전에 버전을 봐야 합니다(빠진 Version은 템플릿 값 2로 채워지므로).
local version = profile.Data.Version
profile:Reconcile()
Data.migrate(profile.Data, if typeof(version) == "number" then version else 1)
profile.OnSessionEnd:Connect(function()
profiles[player] = nil
if player.Parent == Players then
@@ -65,6 +78,26 @@ function Data.load(player: Player): any
return profile
end
-- 버전 1(한 줄 업그레이드 Bought) -> 버전 2(갈래 레벨, 배치, 알바생)
function Data.migrate(data: any, version: number)
if version >= 2 then
return
end
local levels, seats, tables, cooks = Economy.migrate(data.Bought or 0)
data.Levels = levels
data.Staff = { Cook = cooks }
local stage = Economy.stats(levels, seats).stage
local layout = Floor.default()
for _ = 2, tables do
Floor.addTable(layout, stage)
end
for _ = #layout.chairs + 1, seats do
Floor.addChair(layout, stage)
end
data.Layout = layout
data.Version = 2
end
function Data.get(player: Player): any
return profiles[player]
end

View File

@@ -1,13 +1,16 @@
--!strict
-- 서버 시작: 맵, 플레이어 입장·퇴장, 부지 배정, 이웃 가게, 손님 방문, 설정, 리모트, 결제를 연결합니다.
local AdService = game:GetService("AdService")
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local TextService = game:GetService("TextService")
local Shared = ReplicatedStorage.Shared
local Economy = require(Shared.Economy)
local Floor = require(Shared.Floor)
local Locale = require(Shared.Locale)
local Products = require(Shared.Products)
@@ -16,8 +19,8 @@ local Neighbor = require(script.Parent.Neighbor)
local Npc = require(script.Parent.Npc)
local PlotBuilder = require(script.Parent.PlotBuilder)
local PlotController = require(script.Parent.PlotController)
local PlotLayout = require(script.Parent.PlotLayout)
local Receipts = require(script.Parent.Receipts)
local Transfers = require(script.Parent.Transfers)
local World = require(script.Parent.World)
local Game = {}
@@ -29,9 +32,12 @@ local actionTimes: { [Player]: { number } } = {}
local neighbors: { [number]: Neighbor.Neighbor } = {} -- 플레이어가 없는 부지의 이웃 가게
local guestAt: { [Player]: PlotController.PlotController } = {} -- 손님으로 앉아 있는 가게
local bonusAt: { [Player]: number } = {} -- 다음 시식 보너스를 받을 수 있는 시각
local kickTarget: { [Player]: { index: number, expires: number } } = {} -- 결제 창을 띄운 쫓아내기 대상
local adBusy: { [Player]: boolean } = {}
local COOK_RANGE = 20 -- 요리 화면에서 만든 접시는 조리대에서 이만큼 안에 있어야 받습니다
local VISIT_RANGE = 16 -- 입구에서 이만큼 안에 있어야 손님으로 들어갈 수 있습니다
local VISIT_RANGE = 16 -- 입구에서 이만큼 안에 있어야 손님으로 들어가거나 쫓아낼 수 있습니다
local KICK_TARGET_TTL = 120 -- 결제 창을 띄운 뒤 이 시간 안에 결제되면 그 부지에 씁니다
local Remotes = ReplicatedStorage:WaitForChild("Remotes")
local ActionRemote = Remotes:WaitForChild("Action") :: RemoteEvent
@@ -56,6 +62,17 @@ local function controllerAt(index: number): PlotController.PlotController?
return n and n.controller
end
local function allControllers(): { PlotController.PlotController }
local out = {}
for _, s in slots do
local c = controllerAt(s.index)
if c then
table.insert(out, c)
end
end
return out
end
local function notifyPlayer(player: Player, key: string, args: { [string]: any }?)
NotifyRemote:FireClient(player, key, args)
end
@@ -106,7 +123,8 @@ local function applySettings(player: Player, data: any)
player:SetAttribute("Sfx", data.Sfx ~= false)
end
local function placeCharacter(player: Player, slot: World.Slot)
-- 조리대 앞에 세웁니다.
local function placeCharacter(player: Player, controller: PlotController.PlotController)
local char = player.Character
if not char then
return
@@ -115,21 +133,86 @@ local function placeCharacter(player: Player, slot: World.Slot)
if not root then
return
end
local pos = PlotBuilder.world(slot.cf, PlotLayout.PLAYER_SPAWN) + Vector3.new(0, 4, 0)
local look = PlotBuilder.world(slot.cf, PlotLayout.STOVE)
local refs = controller.slot.refs
local pos = PlotBuilder.stallPoint(refs, { x = Floor.STOVE_FRONT.x, z = Floor.STOVE_FRONT.z + 4 })
+ Vector3.new(0, 4, 0)
local look = PlotBuilder.stallPoint(refs, Floor.STOVE_COOK)
char:PivotTo(CFrame.lookAt(pos, Vector3.new(look.X, pos.Y, look.Z)))
end
local function checkPass(player: Player, controller: PlotController.PlotController)
if Products.DOUBLE_MONEY_PASS == 0 then
return
local function ownsPass(player: Player, passId: number): boolean
if passId == 0 then
return false
end
local ok, owns = pcall(function()
return MarketplaceService:UserOwnsGamePassAsync(player.UserId, Products.DOUBLE_MONEY_PASS)
return MarketplaceService:UserOwnsGamePassAsync(player.UserId, passId)
end)
if ok and owns then
return ok and owns == true
end
-- 게임패스: 2배 수익, 무지개 이름, 유료 디자인
local function checkPasses(player: Player, controller: PlotController.PlotController)
if ownsPass(player, Products.DOUBLE_MONEY_PASS) then
controller:setDouble(true)
end
if ownsPass(player, Products.RAINBOW_NAME_PASS) then
controller:setRainbowOwned(true)
end
for _, d in Economy.DESIGNS do
if d.pass and ownsPass(player, (Products :: any)[d.pass] or 0) then
controller:setDesignOwned(d.id, true)
end
end
end
-- 가게 이름을 필터에 거쳐 모두에게 보이게 합니다. 필터가 실패하면 기본 이름을 씁니다.
local function filterName(player: Player, raw: string): string?
if raw == "" then
return ""
end
local ok, shown = pcall(function()
local result = TextService:FilterStringAsync(raw, player.UserId, Enum.TextFilterContext.PublicChat)
return result:GetNonChatStringForBroadcastAsync()
end)
if not ok or typeof(shown) ~= "string" then
return nil
end
return shown
end
-- 이름 정리: 앞뒤 공백·줄바꿈 제거, 글자 수(UTF-8 글자 기준) 자르기
local function cleanName(raw: any): string?
if typeof(raw) ~= "string" then
return nil
end
local s = string.gsub(raw, "[%c]", " ")
s = string.match(s, "^%s*(.-)%s*$") or ""
if utf8.len(s) == nil then
return nil
end
if (utf8.len(s) :: number) > Economy.NAME_MAX then
local cut = utf8.offset(s, Economy.NAME_MAX + 1)
s = string.sub(s, 1, (cut or #s + 1) - 1)
end
return s
end
local function rename(player: Player, controller: PlotController.PlotController, raw: any)
local name = cleanName(raw)
if name == nil then
controller:notify("nameRejected")
return
end
local shown = filterName(player, name)
if shown == nil or (name ~= "" and string.match(shown, "^[#%s]*$")) then
controller:notify("nameRejected")
return
end
if controllers[player] ~= controller then
return
end
controller:setShopName(name, shown)
controller:notify("renamed")
end
-- 게임 주인(개발자)만 쓰는 테스트 버튼. 결제 없이 기능을 확인할 수 있게 합니다.
@@ -150,6 +233,12 @@ local function makeController(player: Player, slot: World.Slot, data: any): Plot
})
end
local function nearVisit(player: Player, target: PlotController.PlotController): boolean
local char = player.Character
local root = char and char:FindFirstChild("HumanoidRootPart") :: BasePart?
return root ~= nil and (root.Position - target.slot.refs.visit.Position).Magnitude <= VISIT_RANGE
end
-- 다른 가게 입구에서 "손님으로 들어가기"를 눌렀을 때
local function visit(player: Player, index: any)
if typeof(index) ~= "number" then
@@ -157,12 +246,8 @@ local function visit(player: Player, index: any)
end
local own = controllers[player]
local target = controllerAt(index)
if not own or not target or target == own then
return
end
local char = player.Character
local root = char and char:FindFirstChild("HumanoidRootPart") :: BasePart?
if not char or not root or (root.Position - target.slot.refs.visit.Position).Magnitude > VISIT_RANGE then
if not own or not target or target == own or not char or not nearVisit(player, target) then
return
end
local prev = guestAt[player]
@@ -178,6 +263,137 @@ local function visit(player: Player, index: any)
target:notify("guestArrived", { name = player.DisplayName })
end
-- 홍보 실행(광고 보상 또는 무료). 데려온 수를 돌려줍니다.
local function doPromote(controller: PlotController.PlotController): number
local sources = {}
for _, c in allControllers() do
if c ~= controller then
table.insert(sources, c)
end
end
local got, why = Transfers.promote(controller, sources)
if got > 0 then
controller:notify("promoted", { n = got })
else
controller:notify(if why == "full" then "promoteFull" else "promoteNone")
end
return got
end
local function promote(player: Player, controller: PlotController.PlotController, arg: any)
local now = workspace:GetServerTimeNow()
local wantAd = typeof(arg) == "table" and arg.ad == true
if wantAd then
if Products.PROMOTE_AD_PRODUCT == 0 or adBusy[player] then
controller:notify("adUnavailable")
return
end
if now < controller.promoteAdAt then
controller:notify("promoteWait", { sec = math.ceil(controller.promoteAdAt - now) })
return
end
-- 광고를 보기 전에 데려올 손님이 있는지 먼저 봅니다(보상을 못 주는 광고를 보여 주지 않게).
local any = false
for _, c in allControllers() do
if c ~= controller then
for _, cust in c.shop.customers do
if cust.state ~= "eating" and not cust.guest then
any = true
end
end
end
end
if not any then
controller:notify("promoteNone")
return
end
adBusy[player] = true
task.spawn(function()
local ok, result = pcall(function()
local reward = AdService:CreateAdRewardFromDevProductId(Products.PROMOTE_AD_PRODUCT)
return AdService:ShowRewardedVideoAdAsync(player, reward)
end)
adBusy[player] = nil
-- 보상은 ProcessReceipt(광고 보상 채널)로 옵니다. 광고가 안 나왔으면 알립니다.
if not ok or result ~= Enum.ShowAdResult.ShowCompleted then
controller:notify("adUnavailable")
end
end)
return
end
if now < controller.promoteAt then
controller:notify("promoteWait", { sec = math.ceil(controller.promoteAt - now) })
return
end
if doPromote(controller) > 0 then
controller.promoteAt = now + Economy.PROMOTE_COOLDOWN
controller:sync()
end
end
-- 손님 쫓아내기 실행(산 횟수 1개 사용). 성공하면 true
local function doKick(player: Player, controller: PlotController.PlotController, index: number): boolean
local victim = controllerAt(index)
if not victim or victim == controller then
controller:notify("kickOwn")
return false
end
local now = workspace:GetServerTimeNow()
if now < victim.shieldUntil then
controller:notify("shielded")
return false
end
local kicked, got = Transfers.kick(controller, victim)
if kicked == 0 then
controller:notify("promoteNone")
return false
end
controller.data.KickCredits = math.max(0, (controller.data.KickCredits or 0) - 1)
victim.shieldUntil = now + Economy.KICK_SHIELD
victim.slot.model:SetAttribute("ShieldUntil", victim.shieldUntil)
controller:notify("kicked", { n = got })
victim:notify("kickedBy", { name = player.DisplayName })
controller:sync()
return true
end
local function kick(player: Player, controller: PlotController.PlotController, index: any)
if typeof(index) ~= "number" then
return
end
local victim = controllerAt(index)
if not victim or victim == controller then
controller:notify("kickOwn")
return
end
if not nearVisit(player, victim) then
return
end
if workspace:GetServerTimeNow() < victim.shieldUntil then
controller:notify("shielded")
return
end
if (controller.data.KickCredits or 0) > 0 then
doKick(player, controller, index)
elseif Products.KICK_PRODUCT ~= 0 then
kickTarget[player] = { index = index, expires = os.clock() + KICK_TARGET_TTL }
MarketplaceService:PromptProductPurchase(player, Products.KICK_PRODUCT)
end
end
local function resetData(data: any)
data.Money = 0
data.Bought = 0
data.Levels = Economy.emptyLevels()
data.Layout = Floor.default()
data.Staff = {}
data.TutorialDone = false
data.Served = 0
data.Earned = 0
data.RushLeft = 0
data.Design = "Basic"
end
local function onPlayerAdded(player: Player)
local profile = Data.load(player)
if not profile then
@@ -203,17 +419,26 @@ local function onPlayerAdded(player: Player)
player.CharacterAdded:Connect(function()
task.defer(function()
placeCharacter(player, slot)
local current = controllers[player]
if current then
placeCharacter(player, current)
current:rebuildHand()
end
end)
end)
if player.Character then
task.defer(placeCharacter, player, slot)
task.defer(placeCharacter, player, controller)
end
task.spawn(checkPass, player, controller)
task.spawn(checkPasses, player, controller)
task.spawn(function()
local raw = data.ShopName or ""
if raw ~= "" then
local shown = filterName(player, raw)
if shown and controllers[player] == controller then
controller:setShopName(raw, shown)
end
end
end)
end
local function onPlayerRemoving(player: Player)
@@ -221,12 +446,15 @@ local function onPlayerRemoving(player: Player)
controllers[player] = nil
actionTimes[player] = nil
bonusAt[player] = nil
kickTarget[player] = nil
adBusy[player] = nil
local host = guestAt[player]
if host then
host:releaseGuestByUser(player.UserId)
end
guestAt[player] = nil
if controller then
controller.data.RushLeft = controller.shop.rushLeft
slotOwner[controller.slot.index] = nil
controller:destroy()
-- 빈 부지에는 다시 이웃 가게를 엽니다.
@@ -250,6 +478,13 @@ local function allowAction(player: Player): boolean
return true
end
local function num(v: any): number?
if typeof(v) == "number" and v == v and math.abs(v) < 1e6 then
return v
end
return nil
end
local function onAction(player: Player, kind: any, arg: any)
if typeof(kind) ~= "string" or not allowAction(player) then
return
@@ -273,14 +508,66 @@ local function onAction(player: Player, kind: any, arg: any)
else
controller:finishCook(menu, now)
end
elseif kind == "buy" then
local ok, err = controller:buy()
if not ok and err == "money" then
local p = Economy.PURCHASES[controller.shop.bought + 1]
if p then
controller:notify("notEnough", { need = Locale.number(p.cost - controller.shop.money) })
elseif kind == "upgrade" then
if typeof(arg) == "string" and Economy.track(arg) then
controller:upgrade(arg)
end
elseif kind == "buyOffer" then
if typeof(arg) == "string" and (arg == "Seat" or arg == "Table" or Economy.track(arg)) then
controller:buyOffer(arg)
end
elseif kind == "buySeat" then
controller:buySeat(num(arg))
elseif kind == "buyTable" then
controller:buyTable()
elseif kind == "buyDecor" then
if typeof(arg) == "string" and Economy.decor(arg) then
controller:buyDecor(arg)
end
elseif kind == "move" then
if typeof(arg) == "table" and typeof(arg.kind) == "string" then
local i, x, z = num(arg.i), num(arg.x), num(arg.z)
if i and x and z then
controller:move({ kind = arg.kind, i = i, x = x, z = z, f = num(arg.f), r = num(arg.r) })
end
end
elseif kind == "hire" or kind == "fire" then
if typeof(arg) == "string" and Economy.role(arg) then
if kind == "hire" then
controller:hire(arg)
else
controller:fire(arg)
end
end
elseif kind == "rename" then
task.spawn(rename, player, controller, arg)
elseif kind == "rainbow" then
if typeof(arg) == "boolean" then
if controller.rainbowOwned then
controller:setRainbow(arg)
elseif Products.RAINBOW_NAME_PASS ~= 0 then
MarketplaceService:PromptGamePassPurchase(player, Products.RAINBOW_NAME_PASS)
end
end
elseif kind == "design" then
if typeof(arg) == "string" then
local d = Economy.design(arg)
local ok, why = controller:setDesign(arg)
if not ok and why == "locked" and d and d.pass then
local passId = (Products :: any)[d.pass] or 0
if passId ~= 0 then
MarketplaceService:PromptGamePassPurchase(player, passId)
end
end
end
elseif kind == "promote" then
promote(player, controller, arg)
elseif kind == "kick" then
kick(player, controller, arg)
elseif kind == "rush" then
if Products.RUSH_PRODUCT ~= 0 then
MarketplaceService:PromptProductPurchase(player, Products.RUSH_PRODUCT)
end
elseif kind == "visit" then
visit(player, arg)
elseif kind == "lang" then
@@ -303,38 +590,69 @@ local function onAction(player: Player, kind: any, arg: any)
elseif kind == "dev_double" and isDev(player) then
controller:setDouble(controller.shop.moneyMult == 1)
elseif kind == "dev_reset" and isDev(player) then
local data = controller.data
data.Money = 0
data.Bought = 0
data.TutorialDone = false
data.Served = 0
data.Earned = 0
resetData(controller.data)
local slot = controller.slot
local passes = { rainbow = controller.rainbowOwned, designs = controller.designsOwned }
controller:destroy()
local fresh = makeController(player, slot, data)
local fresh = makeController(player, slot, controller.data)
fresh.rainbowOwned = passes.rainbow
fresh.designsOwned = passes.designs
controllers[player] = fresh
placeCharacter(player, slot)
placeCharacter(player, fresh)
fresh:sync()
fresh:notify("devResetDone")
elseif kind == "boost" then
if Products.MONEY_BOOST_PRODUCT ~= 0 and Economy.PURCHASES[controller.shop.bought + 1] then
if Products.MONEY_BOOST_PRODUCT ~= 0 then
MarketplaceService:PromptProductPurchase(player, Products.MONEY_BOOST_PRODUCT)
end
end
end
-- 개발자 상품 지급(결제 1회 = 지급 1회)
-- 개발자 상품 지급(결제 1회 = 지급 1회). 광고 보상도 여기로 옵니다.
function Game.processReceipt(info: { [string]: any }): Enum.ProductPurchaseDecision
local player = Players:GetPlayerByUserId(info.PlayerId)
local profile = player and Data.get(player)
local controller = player and controllers[player]
local decision = Receipts.process(profile, tostring(info.PurchaseId), function()
if info.ProductId ~= Products.MONEY_BOOST_PRODUCT or not controller then
if not controller or not player then
return false
end
local amount = Economy.boostAmount(controller.shop.stats)
controller:addMoney(amount)
controller:notify("boostGot", { amount = Locale.number(amount) })
return true
local id = info.ProductId
if id == Products.MONEY_BOOST_PRODUCT then
local amount = Economy.boostAmount(controller.shop.stats)
controller:addMoney(amount)
controller:notify("boostGot", { amount = Locale.number(amount) })
return true
elseif id == Products.RUSH_PRODUCT and id ~= 0 then
controller:addRush(Economy.RUSH_SECONDS)
controller:notify("rushOn", { min = math.floor(Economy.RUSH_SECONDS / 60) })
return true
elseif id == Products.KICK_PRODUCT and id ~= 0 then
-- 횟수를 먼저 주고, 결제 창을 띄운 대상이 있으면 바로 씁니다.
controller.data.KickCredits = (controller.data.KickCredits or 0) + 1
local t = kickTarget[player]
kickTarget[player] = nil
if t and os.clock() <= t.expires then
local target = player
task.defer(function()
local c = controllers[target]
if c then
doKick(target, c, t.index)
end
end)
end
controller:sync()
return true
elseif id == Products.PROMOTE_AD_PRODUCT and id ~= 0 then
-- 광고 보상: 데려올 손님이 없으면 짧은 손님 러시로 대신 줍니다.
if doPromote(controller) == 0 then
controller:addRush(60)
end
controller.promoteAdAt = workspace:GetServerTimeNow() + Economy.PROMOTE_AD_COOLDOWN
controller:sync()
return true
end
return false
end)
if decision == "Granted" then
return Enum.ProductPurchaseDecision.PurchaseGranted
@@ -342,6 +660,26 @@ function Game.processReceipt(info: { [string]: any }): Enum.ProductPurchaseDecis
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local function onPassBought(player: Player, passId: number, purchased: boolean)
local controller = controllers[player]
if not purchased or not controller or passId == 0 then
return
end
if passId == Products.DOUBLE_MONEY_PASS then
controller:setDouble(true)
elseif passId == Products.RAINBOW_NAME_PASS then
controller:setRainbowOwned(true)
controller:setRainbow(true)
else
for _, d in Economy.DESIGNS do
if d.pass and (Products :: any)[d.pass] == passId then
controller:setDesignOwned(d.id, true)
controller:setDesign(d.id)
end
end
end
end
function Game.start()
slots = World.build()
task.spawn(Npc.preload)
@@ -357,12 +695,7 @@ function Game.start()
ActionRemote.OnServerEvent:Connect(onAction)
MarketplaceService.ProcessReceipt = Game.processReceipt
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, passId, purchased)
local controller = controllers[player]
if purchased and passId == Products.DOUBLE_MONEY_PASS and controller then
controller:setDouble(true)
end
end)
MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPassBought)
local acc = 0
RunService.Heartbeat:Connect(function(dt)
@@ -379,7 +712,11 @@ function Game.start()
Neighbor.update(n, now)
end
end)
print(`[Bunsik] server ready, {#Economy.PURCHASES} purchases, {#slots} plots`)
print(`[Bunsik] server ready, {#Economy.TRACKS} upgrade tracks, {#slots} plots`)
end
-- 테스트용: 홍보·쫓아내기 실행을 바로 부릅니다(원격 테스트에서 가짜 플레이어로).
Game._doPromote = doPromote
Game._cleanName = cleanName
return Game

View File

@@ -7,16 +7,17 @@ local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Shop = require(ReplicatedStorage.Shared.Shop)
local Data = require(script.Parent.Data)
local Npc = require(script.Parent.Npc)
local PlotBuilder = require(script.Parent.PlotBuilder)
local PlotController = require(script.Parent.PlotController)
local PlotLayout = require(script.Parent.PlotLayout)
local Neighbor = {}
-- 부지 번호별 이웃 가게 크기(산 업그레이드 수). 처음 온 플레이어보다 큰 가게가 많아서 "나도 저렇게 키우고 싶다"를 노립니다.
Neighbor.LEVELS = { 14, 7, 20, 10, 17, 4 }
Neighbor.SERVE_GAP = 1 -- 사장님이 접시를 내려놓는 간격(초)
Neighbor.DESIGNS = { "Mint", "Basic", "Brick", "Basic", "Mint", "Basic" } -- 무료 디자인만
export type Neighbor = {
controller: PlotController.PlotController,
@@ -28,13 +29,16 @@ export type Slot = PlotController.Slot
function Neighbor.open(slot: Slot, now: number, guestEvent: PlotController.GuestEvent?): Neighbor
local owner = Instance.new("Folder")
owner.Name = "Neighbor" .. slot.index
local data = {
Money = 0,
-- 예전 한 줄 업그레이드 수로 크기를 정하고 새 구조(갈래·배치·알바)로 옮깁니다.
local data: any = {
Money = 1e12, -- 시급을 못 내서 쉬는 일이 없게
Bought = Neighbor.LEVELS[slot.index] or 10,
TutorialDone = true,
Served = 0,
Earned = 0,
Design = Neighbor.DESIGNS[slot.index] or "Basic",
}
Data.migrate(data, 1)
local controller = PlotController.new(slot, owner, {
userId = -slot.index,
displayName = "",
@@ -44,8 +48,8 @@ function Neighbor.open(slot: Slot, now: number, guestEvent: PlotController.Guest
guestEvent = guestEvent,
})
-- 포장마차 뒤에 서 있는 사장님
local pos = PlotBuilder.world(slot.cf, PlotLayout.HELPER + Vector3.new(6, 0, 0))
local look = PlotBuilder.world(slot.cf, PlotLayout.PLAYER_SPAWN)
local pos = PlotBuilder.stallPoint(slot.refs, { x = 3, z = -4 })
local look = PlotBuilder.stallPoint(slot.refs, { x = 3, z = 10 })
local keeper = Npc.spawn(slot.refs.dynamic, CFrame.new(pos), controller.rng, Color3.fromRGB(240, 110, 40))
keeper.model.Name = "Keeper"
keeper.root.CFrame = Npc.standCFrame(keeper, pos, look)
@@ -60,7 +64,7 @@ function Neighbor.update(n: Neighbor, now: number)
return
end
local shop = c.shop
if shop.stats.helper then
if (shop.staff.Cook or 0) > 0 then
c:pickup()
elseif not Shop.handFull(shop) and Shop.nextCookMenu(shop) then
c:cook()

View File

@@ -174,6 +174,11 @@ function Npc.spawn(parent: Instance, cf: CFrame, rng: Random, shirt: Color3?): H
return h
end
-- 손님 NPC(외형을 여러 가지로). 지금은 색만 바꾼 기본 아바타.
function Npc.spawnCustomer(parent: Instance, cf: CFrame, rng: Random): Handle
return Npc.spawn(parent, cf, rng)
end
function Npc.play(h: Handle, name: string)
for n, t in h.tracks do
if n ~= name and t.IsPlaying then

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,52 +0,0 @@
--!strict
-- 부지 한 칸의 배치 좌표(부지 기준 상대 좌표, 단위 stud).
-- 부지 원점은 바닥 가운데, +Z가 길(입구) 쪽입니다. 포장마차는 -Z 쪽 끝에 있습니다.
local PlotLayout = {}
PlotLayout.SIZE = Vector3.new(72, 0, 80)
PlotLayout.FLOOR_Y = 0.2 -- 부지 바닥 윗면 높이
-- 조리대(플레이어가 서서 누르는 곳은 조리대 앞 +Z 쪽)
PlotLayout.STALL_Z = -26
PlotLayout.STOVE = Vector3.new(-3, 0, -26)
PlotLayout.COUNTER = Vector3.new(5.5, 0, -26)
PlotLayout.HELPER = Vector3.new(-3, 0, -30)
-- 손님 입구와 통로
PlotLayout.ENTRANCE = Vector3.new(0, 0, 32)
PlotLayout.PLAYER_SPAWN = Vector3.new(0, 0, -16)
-- 테이블 위치(1~4: 포장마차 앞, 5~8: 실내 확장 뒤 양옆)
PlotLayout.TABLES = {
Vector3.new(-9, 0, -10),
Vector3.new(9, 0, -10),
Vector3.new(-9, 0, 4),
Vector3.new(9, 0, 4),
Vector3.new(-25, 0, -10),
Vector3.new(25, 0, -10),
Vector3.new(-25, 0, 4),
Vector3.new(25, 0, 4),
}
PlotLayout.STOOL_OFFSET = 3.5 -- 의자는 테이블에서 +Z 쪽으로
PlotLayout.LANE_OFFSET = 3 -- 걷는 통로는 의자 뒤로
function PlotLayout.stool(seat: number): Vector3
local t = PlotLayout.TABLES[seat]
return t + Vector3.new(0, 0, PlotLayout.STOOL_OFFSET)
end
-- 입구 -> 가운데 통로 -> 줄 통로 -> 의자 순서로 걷는 길(상대 좌표)
function PlotLayout.pathTo(seat: number): { Vector3 }
local stool = PlotLayout.stool(seat)
local laneZ = stool.Z + PlotLayout.LANE_OFFSET
return {
PlotLayout.ENTRANCE,
Vector3.new(0, 0, laneZ),
Vector3.new(stool.X, 0, laneZ),
stool,
}
end
return PlotLayout

View File

@@ -0,0 +1,61 @@
--!strict
-- 옆 가게 손님 주고받기(홍보, 손님 쫓아내기). 손님 NPC는 원래 가게에서 일어나 길을 따라 걸어옵니다.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Economy = require(ReplicatedStorage.Shared.Economy)
local Shop = require(ReplicatedStorage.Shared.Shop)
local PlotController = require(script.Parent.PlotController)
type Controller = PlotController.PlotController
local Transfers = {}
-- 홍보: 옆 가게들에서 아직 음식을 못 받은 손님을 빈자리만큼(최대 PROMOTE_MAX) 데려옵니다.
-- NPC 이웃 가게 손님부터 데려와서 다른 플레이어 가게는 되도록 건드리지 않습니다.
-- 돌려주는 값: 데려온 수, 실패 이유("full" | "none")
function Transfers.promote(target: Controller, sources: { Controller }): (number, string?)
local free = Shop.freeSeatCount(target.shop)
if free <= 0 then
return 0, "full"
end
local want = math.min(Economy.PROMOTE_MAX, free)
local ordered = table.clone(sources)
table.sort(ordered, function(a, b)
local an = if a.opts.npc then 0 else 1
local bn = if b.opts.npc then 0 else 1
if an ~= bn then
return an < bn
end
-- 가까운 가게부터
local ta = (a.slot.cf.Position - target.slot.cf.Position).Magnitude
local tb = (b.slot.cf.Position - target.slot.cf.Position).Magnitude
return ta < tb
end)
local got = 0
for _, src in ordered do
if got >= want then
break
end
if src ~= target and not src.destroyed then
local list = src:giveCustomers(want - got)
got += target:receiveCustomers(list)
end
end
if got == 0 then
return 0, "none"
end
return got, nil
end
-- 손님 쫓아내기: 그 가게의 아직 음식을 못 받은 NPC 손님이 모두 일어납니다.
-- 우리 가게 빈자리만큼은 우리 가게로 오고, 나머지는 길로 나갑니다.
-- 돌려주는 값: 쫓아낸 수, 우리 가게로 온 수
function Transfers.kick(kicker: Controller, victim: Controller): (number, number)
local list = victim:giveCustomers(math.huge)
local got = kicker:receiveCustomers(list)
return #list, got
end
return Transfers

View File

@@ -32,6 +32,7 @@ Floor.X0 = -33
Floor.X1 = 33
Floor.Z0 = -37
Floor.Z1 = 19
Floor.BASE_Y = 0.2 -- 부지 바닥 윗면 높이(부지 원점 기준)
Floor.FLOOR2_Y = 15 -- 2층 바닥 높이(1층 바닥 기준)
Floor.CELL = 1
@@ -468,7 +469,19 @@ end
-- 새 테이블(+의자 1개)을 놓을 곳을 찾아 layout에 넣습니다. 놓으면 테이블 번호를 돌려줍니다.
function Floor.addTable(layout: Layout, stage: number): number?
local floors = if stage >= 3 then { 1, 2 } else { 1 }
local floors: { number } = { 1 }
if stage >= 3 then
-- 2층 건물이면 테이블이 적은 층부터 채웁니다(2층이 바로 쓰이게).
local n1, n2 = 0, 0
for _, t in layout.tables do
if t.f == 2 then
n2 += 1
else
n1 += 1
end
end
floors = if n2 < n1 then { 2, 1 } else { 1, 2 }
end
for _, f in floors do
for _, c in candidates(f) do
local test = Floor.clone(layout)
@@ -515,7 +528,7 @@ function Floor.addDecor(layout: Layout, stage: number, kind: string): number?
if not Floor.FOOTPRINT[kind] or kind == "Stove" then
return nil
end
local floors = if stage >= 3 then { 1, 2 } else { 1 }
local floors: { number } = if stage >= 3 then { 1, 2 } else { 1 }
for _, f in floors do
-- 소품은 벽 쪽부터 찾습니다.
local list = {}
@@ -636,7 +649,7 @@ function Floor.repair(layout: Layout, stage: number): Layout
end
end
local placed = false
local floors = if stage >= 3 then { 2, 1 } else { 1 }
local floors: { number } = if stage >= 3 then { 2, 1 } else { 1 }
for _, f in floors do
if placed then
break

View File

@@ -4,4 +4,10 @@
return {
DOUBLE_MONEY_PASS = 2026574937,
MONEY_BOOST_PRODUCT = 3717970589,
RAINBOW_NAME_PASS = 0, -- 가게 이름 무지개
CANDY_DESIGN_PASS = 0, -- 건물 디자인: 사탕 궁전
HANOK_DESIGN_PASS = 0, -- 건물 디자인: 한옥 분식집
RUSH_PRODUCT = 0, -- 손님 러시 10분(소모성)
KICK_PRODUCT = 0, -- 옆 가게 손님 쫓아내기 1회(소모성)
PROMOTE_AD_PRODUCT = 0, -- 보상형 광고 보상(홍보 1회). 광고 보상은 개발자 상품으로 받습니다
}

View File

@@ -22,7 +22,7 @@ export type Recipe = {
steps: { Step },
}
Recipes.BASE_COOK = 2.5 -- Economy.START.cook과 같음
Recipes.BASE_COOK = 2.5 -- Economy.START_COOK과 같음
Recipes.RUB_UNIT = 260 -- 문지르기 1번 = 기준 단위 260만큼 움직이기
Recipes.LIST = {

View File

@@ -9,8 +9,10 @@ local Economy: typeof(require(script.Parent.Economy)) = if script
then require(script.Parent.Economy)
else (require :: any)("./Economy")
type Stats = Economy.Stats
type Levels = Economy.Levels
type Stats = typeof(Economy.stats({}, 1))
type Levels = { [string]: number }
type Staff = { [string]: number }
type Level = typeof(Economy.TRACKS[1].levels[1])
export type CustomerState = "walking" | "waiting" | "eating"
@@ -54,7 +56,7 @@ export type Shop = {
hand: { string },
counter: { string },
trips: { [number]: Trip }, -- 서빙 알바 번호 -> 나르는 중
staff: Economy.Staff,
staff: Staff,
strike: boolean, -- 시급이 모자라 알바생이 쉬는 중
wageDue: number, -- 다음 시급 주는 시각
cookNext: { [number]: number }, -- 요리 알바 번호 -> 다음에 만들 수 있는 시각
@@ -71,7 +73,7 @@ export type Options = {
money: number,
levels: Levels?,
seats: number?,
staff: Economy.Staff?,
staff: Staff?,
now: number,
rushLeft: number?,
}
@@ -81,7 +83,7 @@ local Shop = {}
function Shop.new(opts: Options): Shop
local levels = Economy.cleanLevels(opts.levels)
local seats = math.max(1, opts.seats or 1)
local staff: Economy.Staff = {}
local staff: Staff = {}
for _, r in Economy.ROLES do
local n = if opts.staff then opts.staff[r.id] else nil
staff[r.id] = if typeof(n) == "number" then math.clamp(math.floor(n), 0, r.max) else 0
@@ -461,7 +463,7 @@ end
-- 업그레이드 갈래의 다음 단계를 삽니다. 성공하면 산 단계(Level)를 돌려줍니다.
-- 실패 이유: "max"(다 삼), "stage"(건물 단계 부족), "money"
function Shop.buyLevel(self: Shop, trackId: string): (Economy.Level?, string?)
function Shop.buyLevel(self: Shop, trackId: string): (Level?, string?)
local nl = Economy.nextLevel(self.levels, trackId)
if not nl then
return nil, "max"

View File

@@ -3,7 +3,7 @@ local Economy = require("../src/shared/Economy")
local Recipes = require("../src/shared/Recipes")
local T = require("./check")
T.eq(Recipes.BASE_COOK, Economy.START.cook, "기준 화구 수준 = 처음 조리 시간")
T.eq(Recipes.BASE_COOK, Economy.START_COOK, "기준 화구 수준 = 처음 조리 시간")
for _, menu in Economy.MENU_ORDER do
local r = Recipes.LIST[menu]
T.check(r ~= nil, `{menu} 요리 과정 있음`)

View File

@@ -0,0 +1,512 @@
-- 로블록스 서버(Open Cloud Luau Execution)에서 돌리는 서버 통합 테스트(2026-10-14 개편 구조).
-- python3 tools/cloud.py run tests/cloud/server.luau --version <저장 버전>
-- 플레이어가 없고 물리가 돌지 않으며 Script가 자동 실행되지 않으므로,
-- 모듈을 직접 불러 가짜 플레이어(Folder)와 가상 시계로 가게를 돌립니다.
local HttpService = game:GetService("HttpService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local Server = ServerScriptService.Server
local failures = {}
local count = 0
local function check(cond: any, msg: string)
count += 1
if not cond then
table.insert(failures, msg)
print("FAIL " .. msg)
end
end
local function eq(a: any, b: any, msg: string)
check(a == b, `{msg} (기대 {tostring(b)}, 실제 {tostring(a)})`)
end
local function section(name: string)
print("== " .. name)
end
local Economy = require(ReplicatedStorage.Shared.Economy)
local Floor = require(ReplicatedStorage.Shared.Floor)
local Icons = require(ReplicatedStorage.Shared.Icons)
local Recipes = require(ReplicatedStorage.Shared.Recipes)
local Shop = require(ReplicatedStorage.Shared.Shop)
section("맵")
local World = require(Server.World)
local slots = World.build()
eq(#slots, 6, "부지 6칸")
for i, s in slots do
check(s.refs.stove and s.refs.stove:IsDescendantOf(workspace), `부지 {i} 조리대`)
check(typeof(s.model:GetAttribute("Origin")) == "CFrame", `부지 {i} Origin 속성`)
for j, o in slots do
if i < j then
check((s.cf.Position - o.cf.Position).Magnitude >= 76, `부지 {i},{j} 겹치지 않음`)
end
end
local front = s.cf:PointToWorldSpace(Vector3.new(0, 0, 40))
check(math.abs(front.Z) < math.abs(s.cf.Position.Z), `부지 {i} 입구가 길 쪽`)
end
section("NPC")
local Npc = require(Server.Npc)
Npc.preload()
local npc = Npc.spawnCustomer(workspace, CFrame.new(0, 5, 0), Random.new(1))
check(npc.model:FindFirstChild("HumanoidRootPart") ~= nil, "손님 NPC 몸")
check(npc.tracks.walk ~= nil and npc.tracks.sit ~= nil and npc.tracks.idle ~= nil, "NPC 애니메이션 3종 로드")
npc.model:Destroy()
local PlotController = require(Server.PlotController)
local PlotBuilder = require(Server.PlotBuilder)
local Data = require(Server.Data)
local function newData()
local d = table.clone(Data.TEMPLATE)
d.PurchaseIdCache = {}
d.Levels = {}
d.Staff = {}
d.Layout = {}
return d
end
local function count_(folder: Instance, prefix: string): number
local n = 0
for _, ch in folder:GetChildren() do
if string.sub(ch.Name, 1, #prefix) == prefix then
n += 1
end
end
return n
end
section("가게 1: 튜토리얼 흐름")
local owner = Instance.new("Folder")
owner.Name = "FakePlayer"
owner.Parent = ServerScriptService
local notes = {}
local data = newData()
local c = PlotController.new(slots[1], owner, {
userId = 111,
displayName = "Tester",
data = data,
now = 0,
notify = function(k, args)
table.insert(notes, { k, args })
end,
})
local function noted(key: string): boolean
for _, n in notes do
if n[1] == key then
return true
end
end
return false
end
eq(owner:GetAttribute("Tut"), 1, "튜토리얼 1단계")
eq(owner:GetAttribute("Money"), 0, "돈 0")
eq(owner:GetAttribute("Stage"), 1, "포장마차")
eq(owner:GetAttribute("Seats"), 1, "의자 1")
eq(owner:GetAttribute("Tables"), 1, "테이블 1")
eq(owner:GetAttribute("Levels"), "Stage=0,Menu=0,Price=0,Speed=0,Stove=0,Tray=0,Staff=0", "갈래 레벨 속성")
check(typeof(owner:GetAttribute("Layout")) == "string", "배치 JSON 속성")
local decoded = Floor.clean(HttpService:JSONDecode(owner:GetAttribute("Layout")))
eq(#decoded.chairs, 1, "배치 JSON 읽기")
eq(slots[1].model:GetAttribute("OwnerId"), 111, "부지 주인 속성")
eq(slots[1].model:GetAttribute("Menus"), "Tteokbokki", "메뉴판 속성")
local furniture = slots[1].refs.furniture
check(
furniture:FindFirstChild("Table1") ~= nil and furniture:FindFirstChild("Chair1") ~= nil,
"테이블·의자 모형"
)
eq(furniture.Table1:GetAttribute("ItemKind"), "table", "꾸미기 선택 속성")
eq(#slots[1].refs.building:GetChildren(), 0, "포장마차 단계엔 건물 없음")
c:update(0)
local dyn = slots[1].refs.dynamic
eq(count_(dyn, "Customer"), 1, "첫 손님 NPC 1명")
local bubble = dyn:FindFirstChild("Customer"):FindFirstChild("Order", true)
local icon = bubble and bubble:FindFirstChild("Icon", true) :: ImageLabel?
eq(icon and icon.ImageRectOffset, Icons.OFFSET.Tteokbokki, "말풍선에 떡볶이 그림")
eq(slots[1].refs.stove:GetAttribute("CookMenu"), "Tteokbokki", "조리대에 떡볶이 주문")
local walk = c.shop.seatWalk[1]
check(walk and walk >= 1.5 and walk <= 9, `자리까지 걷는 시간 ({walk})`)
c:update(walk + 0.1)
eq(c.shop.customers[1].state, "waiting", "손님이 앉음")
eq(c:finishCook("Tteokbokki", 10), nil, "메뉴를 고르지 않고 완성만 보내면 거절")
check(c:startCook("Tteokbokki", 10), "주문 있는 메뉴로 시작")
local minT = Recipes.minTime("Tteokbokki", c.shop.stats.cook)
eq(c:finishCook("Tteokbokki", 10 + minT * 0.5), nil, "조리 과정 최소 시간보다 빠르면 거절")
local t = walk + 0.1
check(c:startCook("Tteokbokki", t - Recipes.expectedTime("Tteokbokki", c.shop.stats.cook)), "다시 시작")
eq(c:finishCook("Tteokbokki", t), "Tteokbokki", "정상 시간이면 조리")
eq(owner:GetAttribute("Tut"), 2, "튜토리얼 2단계")
-- 접시가 똑바로 놓이는지(예전에 세로로 서던 문제)
local held = dyn:FindFirstChild("Dish_Tteokbokki") :: Model
check(held ~= nil, "접시 모형")
eq(c:serve(1), 15, "서빙 15원")
local onTable = dyn:FindFirstChild("Dish_Tteokbokki") :: Model
local up = onTable and onTable:GetPivot().UpVector
check(up and up.Y > 0.99, `테이블 위 접시가 똑바로 놓임 (UpVector.Y {up and up.Y})`)
local plate = onTable and onTable:FindFirstChild("Plate") :: BasePart?
check(plate and math.abs(plate.CFrame.RightVector.Y) > 0.99, "접시 원기둥 축이 세로(평평한 접시)")
eq(owner:GetAttribute("Tut"), 3, "튜토리얼 3단계")
-- 첫 추천 구매: 의자(10원)
local offers = Economy.offers(c.shop.levels, #c.layout.tables, #c.layout.chairs)
eq(offers[1].id, "Seat", "처음 추천은 의자")
check(c:buyOffer("Seat"), "의자 구매")
eq(owner:GetAttribute("Seats"), 2, "의자 2")
eq(c.shop.stats.seats, 2, "손님 자리 2")
check(furniture:FindFirstChild("Chair2") ~= nil, "의자 모형")
eq(owner:GetAttribute("Tut"), 0, "튜토리얼 끝")
eq(data.TutorialDone, true, "튜토리얼 저장")
eq(#data.Layout.chairs, 2, "세이브에 배치")
section("가게 1: 갈래 업그레이드")
c:addMoney(40)
check(c:upgrade("Menu"), "김밥 해금")
check(slots[1].refs.stall.Extras:FindFirstChild("Menu_Gimbap") ~= nil, "김밥 진열대 모형")
check(noted("newMenu"), "새 메뉴 알림")
eq(slots[1].model:GetAttribute("Menus"), "Tteokbokki,Gimbap", "메뉴판 속성에 김밥")
local ok, why = c:upgrade("Tray")
check(not ok and why == "stage", "쟁반은 실내 분식집부터")
check(noted("needStage"), "건물 단계 알림")
c:addMoney(1_000_000)
check(c:upgrade("Speed"), "손님 속도")
check(c:upgrade("Speed"), "손님 속도 2")
check(slots[1].refs.stall.Extras:FindFirstChild("Part") ~= nil, "수레 장식")
check(c:upgrade("Stage"), "실내 분식집 확장")
eq(owner:GetAttribute("Stage"), 2, "2단계")
check(noted("expanded"), "확장 알림")
check(slots[1].refs.building:FindFirstChild("Roof") ~= nil, "실내 건물 지붕")
check(slots[1].refs.building:FindFirstChild("Ceiling") ~= nil, "실내 건물 천장")
check(slots[1].refs.building:FindFirstChild("RoofSign") ~= nil, "지붕 간판")
section("가게 1: 꾸미기(테이블·의자·소품·옮기기)")
for _ = 1, 4 do
check(c:buyTable(), "테이블 구매")
end
eq(#c.layout.tables, 5, "테이블 5")
for _ = 1, 5 do
check(c:buySeat(nil), "의자 구매")
end
eq(owner:GetAttribute("Seats"), 11, "의자 11")
eq(Floor.validate(c.layout, 2), nil, "배치 검사 통과")
check(c:buyDecor("Plant"), "화분 구매")
check(c:buyDecor("Balloons"), "풍선 구매")
check(furniture:FindFirstChild("Decor1") ~= nil, "소품 모형")
-- 옮기기
local t1 = c.layout.tables[1]
check(
c:move({ kind = "table", i = 1, x = 25, z = 10 }) or c:move({ kind = "table", i = 1, x = 26, z = 12 }),
"테이블 옮기기"
)
check(c.layout.tables[1].x ~= t1.x, "옮긴 자리 저장")
check(not c:move({ kind = "table", i = 1, x = 0, z = 17 }), "문 앞에는 못 놓음")
check(noted("placeFail"), "못 놓는 이유 알림")
local stallBefore = slots[1].refs.stall:GetPivot().Position
check(c:move({ kind = "stove", i = 1, x = 4, z = -28, r = 0 }), "조리대 옮기기")
check((slots[1].refs.stall:GetPivot().Position - stallBefore).Magnitude > 3, "수레 모형이 옮겨짐")
check(slots[1].refs.stove:IsDescendantOf(slots[1].refs.stall), "조리대 인스턴스는 그대로(버튼 유지)")
-- 의자 1을 빈 쪽이 있는 다른 테이블로 옮기기(테이블 1은 네 쪽이 다 찼을 수 있음)
local sideMoved = false
for ti in c.layout.tables do
for side = 1, 4 do
if not sideMoved and ti ~= c.layout.chairs[1].t then
sideMoved = c:move({ kind = "chair", i = 1, x = side, z = ti })
end
end
end
check(sideMoved, "의자를 다른 테이블·다른 쪽으로 옮기기")
c.shop.money = 0
check(not c:buyTable(), "돈 모자라면 테이블 못 삼")
check(noted("notEnough"), "모자란 돈 알림")
c:addMoney(1_000_000)
section("가게 1: 디자인")
check(c:setDesign("Mint"), "무료 디자인")
eq(slots[1].model:GetAttribute("Design"), "Mint", "디자인 속성")
local okCandy, whyCandy = c:setDesign("Candy")
check(not okCandy and whyCandy == "locked", "유료 디자인은 게임패스가 있어야")
c:setDesignOwned("Candy", true)
check(c:setDesign("Candy"), "게임패스 있으면 유료 디자인")
check(slots[1].refs.building:FindFirstChild("Roof") ~= nil, "디자인 바꾼 건물")
c:setDesignOwned("Hanok", true)
check(c:setDesign("Hanok"), "한옥 디자인")
section("가게 1: 이름·무지개")
c:setShopName("떡볶이 천국", "떡볶이 천국")
eq(slots[1].model:GetAttribute("ShopName"), "떡볶이 천국", "모두에게 보이는 이름")
eq(data.ShopName, "떡볶이 천국", "세이브에 이름")
eq(slots[1].model:GetAttribute("Rainbow"), false, "게임패스 없으면 무지개 아님")
c:setRainbowOwned(true)
eq(slots[1].model:GetAttribute("Rainbow"), true, "게임패스 있으면 무지개")
c:setRainbow(false)
eq(slots[1].model:GetAttribute("Rainbow"), false, "무지개 끄기")
local Game = require(Server.Game)
eq(Game._cleanName(" 가나다\n라 "), "가나다 라", "이름 공백 정리")
eq(utf8.len(Game._cleanName(string.rep("가", 30)) :: string), Economy.NAME_MAX, "이름 길이 자르기")
section("가게 1: 2층")
check(c:upgrade("Stage"), "2층 확장")
eq(owner:GetAttribute("Stage"), 3, "3단계")
check(noted("floor2"), "2층 알림")
check(slots[1].refs.building:FindFirstChild("Floor2") ~= nil, "2층 바닥")
eq(Floor.validate(c.layout, 3), nil, "2층 건물에 맞게 배치 정리")
local before2 = #c.layout.tables
local placed2 = false
for _ = 1, 7 do
if c:buyTable() then
placed2 = true
end
end
check(placed2, "2층 건물에서 테이블 추가")
local on2 = nil
for i, tb in c.layout.tables do
if tb.f == 2 then
on2 = i
end
end
check(#c.layout.tables > before2, "테이블 늘어남")
check(on2 ~= nil, "2층에 테이블")
if on2 then
local chair2 = nil
for ci, ch in c.layout.chairs do
if ch.t == on2 then
chair2 = ci
end
end
local seatCf = PlotBuilder.seatCFrame(slots[1].cf, c.layout, chair2)
check(seatCf.Position.Y > slots[1].cf.Position.Y + Floor.FLOOR2_Y, "2층 의자 높이")
local path = c:entryPath(chair2)
local top = 0
for _, p in path do
top = math.max(top, p.Y)
end
check(top > slots[1].cf.Position.Y + Floor.FLOOR2_Y - 1, "2층 손님 길이 계단을 올라감")
end
section("가게 1: 알바생")
check(not c:hire("Cook"), "알바생 기능 전에는 고용 못 함")
check(noted("staffLocked"), "잠김 알림")
check(c:upgrade("Staff"), "알바생 기능")
check(c:hire("Cook"), "요리 알바")
check(c:hire("Server"), "서빙 알바")
check(c:hire("Promoter"), "홍보 알바")
eq(owner:GetAttribute("Staff"), "Cook=1,Server=1,Promoter=1", "알바 속성")
check(owner:GetAttribute("Wage") > 0, "시급 합계")
check(dyn:FindFirstChild("Staff_Cook1") ~= nil, "요리 알바 NPC")
check(dyn:FindFirstChild("Staff_Server1") ~= nil, "서빙 알바 NPC")
check(dyn:FindFirstChild("Staff_Promoter1") ~= nil, "홍보 알바 NPC")
check(c:fire("Promoter"), "해고")
eq(dyn:FindFirstChild("Staff_Promoter1"), nil, "해고하면 NPC 사라짐")
section("가게 1: 가상 5분 영업(서빙 알바가 나름)")
local now = 100
c.shop.now = now
c.shop.nextSpawn = now
local served0 = c.shop.served
local money0 = c.shop.money
local delivered = false
while now < 400 do
now += 0.1
c:update(now)
if c.tripDish[1] then
delivered = true
end
end
local served = c.shop.served - served0
print(`5분 영업(알바만): 서빙 {served}회, 돈 {c.shop.money - money0}`)
check(delivered, "서빙 알바가 접시를 들고 감")
check(served > 20, "알바만으로 5분 동안 20회 넘게 서빙")
check(c.shop.money > money0, "시급을 내고도 돈이 늘어남")
task.wait(Economy.WALK_IN + 2)
check(count_(dyn, "Customer") <= Economy.seatCap(3) + 6, "손님 NPC가 쌓이지 않음")
section("가게 2: 예전 세이브 옮기기 + 캐릭터 자동 서빙")
local charModel =
Players:CreateHumanoidModelFromDescription(Instance.new("HumanoidDescription"), Enum.HumanoidRigType.R15)
charModel.Name = "FakeCharacter"
charModel.Parent = workspace
local hrp = charModel:FindFirstChild("HumanoidRootPart") :: BasePart
hrp.Anchored = true
local owner2 = Instance.new("Folder")
owner2.Parent = ServerScriptService
local old = newData()
old.Bought = 8 -- 예전 구조: 알바생까지 산 상태
old.Money = 5
old.Version = nil
Data.migrate(old, 1)
eq(old.Version, 2, "버전 2로 옮김")
eq(old.Levels.Staff, 1, "알바생 기능")
eq(old.Staff.Cook, 1, "요리 알바 1명")
eq(#old.Layout.chairs, 3, "자리 3")
local c2 = PlotController.new(slots[2], owner2, {
userId = 222,
displayName = "Tester2",
data = old,
now = 0,
getCharacter = function()
return charModel
end,
})
eq(owner2:GetAttribute("Money"), 5, "저장된 돈 불러옴")
c2:update(0)
eq(#c2.shop.counter, 1, "요리 알바가 카운터에 접시")
hrp.CFrame = slots[2].refs.counter.CFrame + Vector3.new(0, 3, 4)
c2:update(0.2)
eq(#c2.shop.hand, 1, "카운터 근처에서 자동으로 집음")
eq(count_(charModel, "Dish_"), 1, "손에 접시 모형")
local held2 = charModel:FindFirstChild("Dish_Tteokbokki") :: Model?
check(held2 and held2:GetPivot().UpVector.Y > 0.99, "손에 든 접시도 똑바로")
c2:update(5)
local seat = c2.shop.customers[1].seat
hrp.CFrame = PlotBuilder.seatCFrame(slots[2].cf, c2.layout, seat) + Vector3.new(0, 2, 2)
local before = c2.shop.money
c2:update(5.2)
check(c2.shop.money > before, "손님 근처에서 자동 서빙")
c2:rebuildHand()
section("홍보·쫓아내기(옆 가게 손님 데려오기)")
local Neighbor = require(Server.Neighbor)
local Transfers = require(Server.Transfers)
local nb = Neighbor.open(slots[5], 0)
eq(slots[5].model:GetAttribute("Npc"), 5, "이웃 가게 속성")
check(slots[5].refs.dynamic:FindFirstChild("Keeper") ~= nil, "사장님 NPC")
-- 이웃 가게에 손님이 찰 때까지
local nt = 0
while nt < 15 do
nt += 0.1
nb.controller:update(nt)
end
local waiting = 0
for _, cust in nb.controller.shop.customers do
if cust.state ~= "eating" then
waiting += 1
end
end
check(waiting >= 1, `이웃 가게 손님 ({waiting})`)
-- 가게 2 자리를 비워 둡니다.
for id in c2.shop.customers do
c2.shop.customers[id] = nil
end
table.clear(c2.shop.seatTaken)
c2.shop.now = 20
local got = Transfers.promote(c2, { nb.controller })
check(got >= 1, `홍보로 손님이 옴 ({got})`)
local transferred = 0
for _, cust in c2.shop.customers do
if cust.transfer then
transferred += 1
check(c2.views[cust.id] and c2.views[cust.id].npc ~= nil, "데려온 손님 NPC")
check(
c2.views[cust.id].npc.model:IsDescendantOf(slots[2].refs.dynamic),
"NPC가 우리 가게 폴더로 옮겨짐"
)
end
end
eq(transferred, got, "데려온 손님 수")
-- 데려온 손님도 걸어와서 앉음
local tt = 20
while tt < 40 do
tt += 0.2
c2:update(tt)
end
for _, cust in c2.shop.customers do
if cust.transfer then
check(cust.state ~= "walking", "데려온 손님이 자리에 도착")
end
end
-- 자리가 꽉 차면 홍보 실패
local full = Shop.freeSeatCount(c2.shop)
for _ = 1, full do
Shop.addTransfer(c2.shop, "Tteokbokki", 1)
end
local got2, why2 = Transfers.promote(c2, { nb.controller })
eq(got2, 0, "빈자리 없으면 못 데려옴")
eq(why2, "full", "이유 full")
-- 쫓아내기: 가게 1(빈자리 많음)이 이웃 가게 손님을 쫓아냄
while nt < 60 do
nt += 0.1
nb.controller:update(nt)
end
c.shop.now = now
local kicked, came = Transfers.kick(c, nb.controller)
print(`쫓아내기: {kicked}명 쫓아냄, {came}명 옴`)
check(kicked >= 0 and came <= kicked, "쫓아낸 수 >= 온 수")
for _, cust in nb.controller.shop.customers do
check(cust.state == "eating", "이웃 가게에는 먹는 손님만 남음")
end
task.wait(5)
c2:destroy()
charModel:Destroy()
Neighbor.close(nb)
section("다른 플레이어가 손님으로 방문")
local guestChar =
Players:CreateHumanoidModelFromDescription(Instance.new("HumanoidDescription"), Enum.HumanoidRigType.R15)
guestChar.Parent = workspace
local hostOwner = Instance.new("Folder")
hostOwner.Parent = ServerScriptService
local hostData = newData()
hostData.TutorialDone = true
hostData.Layout = Floor.default()
Floor.addChair(hostData.Layout, 1)
Floor.addChair(hostData.Layout, 1)
local guestEvents = {}
local host = PlotController.new(slots[3], hostOwner, {
userId = 333,
displayName = "Host",
data = hostData,
now = 0,
guestEvent = function(kind, userId, info)
table.insert(guestEvents, { kind, userId, info })
end,
})
eq(host.shop.stats.seats, 3, "자리 3")
local gc = host:addGuest(444, guestChar)
check(gc ~= nil, "빈자리에 손님으로 앉음")
host.shop.now = 0.5
eq(host:cook(), gc and gc.menu, "손님 메뉴 조리")
local guestEarn = host:serve(gc.id)
eq(guestEarn, Economy.dishPrice(gc.menu, host.shop.stats, 1) * Economy.GUEST_MULT, "손님 접시는 2배 값")
eq(guestEvents[1] and guestEvents[1][1], "served", "손님에게 서빙 소식")
host:update(0.6 + Economy.EAT + 0.5)
eq(guestEvents[2] and guestEvents[2][3].reason, "ate", "다 먹고 일어남")
check(host:addGuest(444, guestChar) ~= nil, "다시 앉음")
host:destroy()
eq(guestEvents[#guestEvents][3].reason, "closed", "가게가 닫히면 일어남")
guestChar:Destroy()
section("이웃 가게 스스로 영업")
local nb2 = Neighbor.open(slots[6], 0)
local n2 = 0
while n2 < 90 do
n2 += 0.1
Neighbor.update(nb2, n2)
end
print(`이웃 가게 90초: 서빙 {nb2.controller.shop.served}회`)
check(nb2.controller.shop.served >= 5, "이웃 가게가 스스로 서빙")
Neighbor.close(nb2)
eq(slots[6].model:GetAttribute("Npc"), nil, "닫으면 속성 해제")
eq(#slots[6].refs.dynamic:GetChildren(), 0, "닫으면 가게 비움")
eq(#slots[6].refs.furniture:GetChildren(), 0, "닫으면 배치 물건 비움")
section("파트 수·Union")
local parts = 0
for _, d in workspace.BunsikWorld:GetDescendants() do
if d:IsA("BasePart") then
parts += 1
check(not d:IsA("PartOperation"), "Union 없음(업로드 제한)")
end
end
print("맵 파트 수(가게 1 2층·한옥 포함)", parts)
check(parts < 12000, "파트 12000개 미만")
section("결제(Game.processReceipt, 플레이어 없음)")
eq(
Game.processReceipt({ PlayerId = 1, PurchaseId = "x", ProductId = 1 }),
Enum.ProductPurchaseDecision.NotProcessedYet,
"플레이어가 없으면 나중에"
)
c:destroy()
print(`checks: {count}, failures: {#failures}`)
if #failures > 0 then
error(`{#failures} failures:\n` .. table.concat(failures, "\n"))
end