-- 로블록스 서버(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