- [가게 꾸미기]를 누르면 창 없이 바로 꾸미기 모드: 아래 물건 줄(테이블·의자·소품 6가지, 값·개수)에서 고르면 투명 미리보기를 들고 걸어가 [배치]. [이동]은 고른 가구를 들고 옮기기, [삭제]는 고른 가구를 빨갛게 표시한 뒤 한 번 더 눌러 지우고 산 값 돌려받기(조리대·마지막 테이블/의자·의자가 보는 테이블·손님 앉은 의자는 막음) - 새 요청 remove, Floor.remove, Shop.removeSeat(뒤 자리 손님·걷는 시간 번호 당김) - 내 가게 탭: 이름 색 무료 10색 + 무지개(게임패스) 칸. 부지 속성 NameColor로 모두에게 보임 - 개발자 테스트 [결제 테스트 켜기/끄기]: 켜면 2배·부스트·러시·쫓아내기·광고 홍보·무지개·유료 디자인이 결제 창 없이 바로 지급(이번 접속만), 게임패스는 안 가진 상태로 바꿔 사는 흐름을 볼 수 있고 끄면 실제 보유로 복구 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
646 lines
26 KiB
Lua
646 lines
26 KiB
Lua
-- 로블록스 서버(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 tLooks = os.clock()
|
|
Npc.preloadCustomers()
|
|
local nHuman, nAnimal = Npc.lookCount()
|
|
print(`손님 외형: 사람 {nHuman}벌, 동물 {nAnimal}종, {math.floor((os.clock() - tLooks) * 1000)}ms`)
|
|
check(nHuman >= 10, `사람 외형 10벌 이상 ({nHuman})`)
|
|
check(nAnimal >= 8, `동물 외형 8종 이상 ({nAnimal})`)
|
|
local rngLook = Random.new(5)
|
|
local animals, humans, accessories = 0, 0, 0
|
|
local shown = {}
|
|
for _ = 1, 200 do
|
|
local h = Npc.spawnCustomer(workspace, CFrame.new(0, 300, 0), rngLook)
|
|
local kind = h.model:GetAttribute("Animal")
|
|
if kind then
|
|
animals += 1
|
|
shown[kind] = true
|
|
else
|
|
humans += 1
|
|
end
|
|
for _, d in h.model:GetChildren() do
|
|
if d:IsA("Accessory") then
|
|
accessories += 1
|
|
end
|
|
end
|
|
check(h.tracks.walk ~= nil and h.tracks.sit ~= nil, "손님 애니메이션")
|
|
check(h.model:FindFirstChildWhichIsA("Script", true) == nil, "손님 모형에 스크립트 없음")
|
|
h.model:Destroy()
|
|
end
|
|
print(`손님 200명: 사람 {humans}, 동물 {animals}, 장신구 {accessories}`)
|
|
check(humans > animals * 2, "사람 손님이 가장 많음")
|
|
check(animals >= 25 and animals <= 75, `동물 손님은 가끔(약 25%) ({animals})`)
|
|
check(accessories > 200, "머리·모자 장신구가 붙음")
|
|
local kinds = 0
|
|
for _ in shown do
|
|
kinds += 1
|
|
end
|
|
check(kinds >= 6, `동물 종류 여러 가지 ({kinds})`)
|
|
|
|
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), 30, "서빙 30원")
|
|
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")
|
|
eq(owner:GetAttribute("Seats"), 2, "테이블만 사면 의자는 그대로")
|
|
for _ = 1, 9 do
|
|
check(c:buySeat(nil), "의자 구매")
|
|
end
|
|
eq(owner:GetAttribute("Seats"), 11, "의자 11")
|
|
eq(Floor.validate(c.layout, 2), nil, "배치 검사 통과")
|
|
-- 꾸미기 화면처럼 정한 자리에 새 물건 놓기(투명 미리보기 → 놓기)
|
|
local tableAt = nil
|
|
for _, spotXZ in { { 22, -20 }, { -22, -20 }, { 22, 0 }, { -22, 0 } } do
|
|
if not tableAt and c:buyItem("table", nil, { kind = "table", x = spotXZ[1], z = spotXZ[2], f = 1 }) then
|
|
tableAt = spotXZ
|
|
end
|
|
end
|
|
check(tableAt ~= nil, "정한 자리에 테이블 놓기")
|
|
if tableAt then
|
|
local tn = #c.layout.tables
|
|
eq(c.layout.tables[tn].x, tableAt[1], "테이블 x 그대로")
|
|
check(
|
|
c:buyItem("chair", nil, { kind = "chair", x = tableAt[1], z = tableAt[2] - 3.5, f = 1, r = 0 }),
|
|
"테이블 뒤에 의자 놓기"
|
|
)
|
|
local cn = #c.layout.chairs
|
|
eq(c.layout.chairs[cn].r, 0, "의자 방향 저장")
|
|
eq(Floor.chairTable(c.layout, cn), tn, "새 의자는 새 테이블을 봄")
|
|
check(furniture:FindFirstChild("Chair" .. cn) ~= nil, "새 의자 모형")
|
|
local seatCf = PlotBuilder.seatCFrame(slots[1].cf, c.layout, cn)
|
|
local tablePos = PlotBuilder.floorCFrame(slots[1].cf, tableAt[1], tableAt[2], 1).Position
|
|
local toTable = (Vector3.new(tablePos.X, seatCf.Position.Y, tablePos.Z) - seatCf.Position).Unit
|
|
check(seatCf.LookVector:Dot(toTable) > 0.9, "앉은 손님은 테이블을 봄")
|
|
local dish = PlotBuilder.dishCFrame(slots[1].cf, c.layout, cn)
|
|
local local_ = slots[1].cf:PointToObjectSpace(dish.Position)
|
|
check(math.abs(local_.X - tableAt[1]) <= 2.5 and math.abs(local_.Z - tableAt[2]) <= 2.5, "접시는 테이블 위")
|
|
end
|
|
local seatsBefore = #c.layout.chairs
|
|
local moneyBefore = c.shop.money
|
|
check(
|
|
not c:buyItem("chair", nil, { kind = "chair", x = 0, z = 5, f = 1, r = 0 }),
|
|
"테이블 없는 곳에 의자 못 놓음"
|
|
)
|
|
eq(#c.layout.chairs, seatsBefore, "실패하면 의자 그대로")
|
|
eq(c.shop.money, moneyBefore, "실패하면 돈 안 나감")
|
|
check(noted("placeFail"), "못 놓는 이유 알림")
|
|
local teddy = false
|
|
for _, spotXZ in { { 0, 8 }, { 16, 12 }, { -16, 12 }, { 30, -20 }, { -30, -20 } } do
|
|
teddy = teddy
|
|
or c:buyItem("decor", "Teddy", { kind = "decor", k = "Teddy", x = spotXZ[1], z = spotXZ[2], f = 1, r = 2 })
|
|
end
|
|
check(teddy, "정한 자리에 곰인형")
|
|
eq(c.layout.decor[#c.layout.decor].r, 2, "소품 방향 저장")
|
|
local templates = PlotBuilder.buildTemplates()
|
|
for _, name in { "Table", "Chair", "Decor_Plant", "Decor_Fridge" } do
|
|
local tm = templates:FindFirstChild(name) :: Model?
|
|
check(tm ~= nil and tm:GetPivot().Position.Magnitude < 1e-3, `미리보기 모형 {name}(기준점 원점)`)
|
|
end
|
|
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을 다른 테이블의 빈 쪽으로 옮기기
|
|
local sideMoved = false
|
|
local from = Floor.chairTable(c.layout, 1)
|
|
for ti, tb in c.layout.tables do
|
|
for side = 1, 4 do
|
|
if not sideMoved and ti ~= from then
|
|
local at = Floor.chairAt(tb, side)
|
|
sideMoved = c:move({ kind = "chair", i = 1, x = at.x, z = at.z, f = at.f, r = at.r })
|
|
end
|
|
end
|
|
end
|
|
check(sideMoved, "의자를 다른 테이블·다른 쪽으로 옮기기")
|
|
-- 테이블을 옮기면 그 테이블을 보는 의자도 같이
|
|
local tIndex = Floor.chairTable(c.layout, 1) :: number
|
|
local tb0 = c.layout.tables[tIndex]
|
|
local ch0 = c.layout.chairs[1]
|
|
local movedWith = false
|
|
for _, d in { { 0, -4 }, { 0, 4 }, { 4, 0 }, { -4, 0 }, { 6, 6 }, { -6, -6 } } do
|
|
if not movedWith and c:move({ kind = "table", i = tIndex, x = tb0.x + d[1], z = tb0.z + d[2], f = tb0.f }) then
|
|
movedWith = true
|
|
eq(c.layout.chairs[1].x, ch0.x + d[1], "의자도 같이 옮겨짐")
|
|
end
|
|
end
|
|
check(movedWith, "의자 붙은 테이블 옮기기")
|
|
-- 지우기(산 값 돌려받기)
|
|
local decorN = #c.layout.decor
|
|
local m0 = c.shop.money
|
|
check(c:removeItem("decor", 1), "소품 지우기")
|
|
eq(#c.layout.decor, decorN - 1, "소품 하나 줄어듦")
|
|
check(c.shop.money > m0, "소품 값 돌려받음")
|
|
check(noted("removed"), "지운 알림")
|
|
check(not c:removeItem("stove", 1), "조리대는 못 지움")
|
|
check(noted("removeFail"), "못 지우는 이유 알림")
|
|
local freeChair = nil
|
|
for ci in c.layout.chairs do
|
|
if c.shop.seatTaken[ci] == nil then
|
|
freeChair = ci
|
|
end
|
|
end
|
|
local seatsN = #c.layout.chairs
|
|
check(freeChair ~= nil and c:removeItem("chair", freeChair), "빈 의자 지우기")
|
|
eq(owner:GetAttribute("Seats"), seatsN - 1, "자리 수 줄어듦")
|
|
eq(c.shop.stats.seats, seatsN - 1, "손님 자리 수도 줄어듦")
|
|
check(furniture:FindFirstChild("Chair" .. seatsN) == nil, "의자 모형도 줄어듦")
|
|
local busy = next(c.shop.seatTaken)
|
|
if busy then
|
|
check(not c:removeItem("chair", busy), "손님이 앉은 의자는 못 지움")
|
|
end
|
|
c.shop.money = 0
|
|
check(not c:buyTable(), "돈 모자라면 테이블 못 삼")
|
|
check(not c:buyItem("chair", nil, { kind = "chair", x = 0, z = 0, f = 1, r = 0 }), "돈 모자라면 의자 못 놓음")
|
|
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, "무지개 끄기")
|
|
c:setRainbow(true)
|
|
c:setNameColor(3)
|
|
eq(slots[1].model:GetAttribute("NameColor"), 3, "이름 색 속성(모두에게)")
|
|
eq(owner:GetAttribute("NameColor"), 3, "이름 색 속성(내 화면)")
|
|
eq(slots[1].model:GetAttribute("Rainbow"), false, "색을 고르면 무지개는 꺼짐")
|
|
eq(data.NameColor, 3, "세이브에 이름 색")
|
|
c:setNameColor(99)
|
|
eq(owner:GetAttribute("NameColor"), 0, "없는 색은 기본색")
|
|
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
|
|
check(c:buySeat(on2), "2층 테이블에 의자")
|
|
local chair2 = nil
|
|
for ci in c.layout.chairs do
|
|
if Floor.chairTable(c.layout, ci) == 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 > 12, "알바만으로 5분 동안 12회 넘게 서빙(손님 간격 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
|