- tools/sfx.py: 동전·구매·확장·조리음 합성, 오디오 에셋으로 업로드(Sounds.luau) - 구매·확장 소리는 클라이언트에서 2D로, 동전 소리는 손님 자리에서 재생 - tools/art.py: 게임 아이콘(512)과 썸네일(1920x1080) 그림 추가 - cloud.py: 오디오 업로드·에셋 상태 조회 명령, 통합 테스트에 효과음 소유 확인(526개 통과) - DECISIONS: 에셋은 없으면 직접 만든다는 원칙과 현황 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
354 lines
13 KiB
Lua
354 lines
13 KiB
Lua
-- 로블록스 서버(Open Cloud Luau Execution)에서 돌리는 통합 테스트.
|
|
-- python3 tools/cloud.py run tests/cloud/integration.luau --version <저장 버전>
|
|
-- 이 환경에서는 플레이어가 없고 물리가 돌지 않으며 Script가 자동 실행되지 않으므로,
|
|
-- 모듈을 직접 불러 가짜 플레이어(Folder)와 가상 시계로 가게를 돌립니다.
|
|
|
|
local Players = game:GetService("Players")
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
local ServerScriptService = game:GetService("ServerScriptService")
|
|
local StarterPlayer = game:GetService("StarterPlayer")
|
|
|
|
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)
|
|
|
|
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} 조리대`)
|
|
for j, o in slots do
|
|
if i < j then
|
|
local d = (s.cf.Position - o.cf.Position).Magnitude
|
|
check(d >= 76, `부지 {i},{j} 겹치지 않음 (거리 {d})`)
|
|
end
|
|
end
|
|
-- 입구(+Z)가 길(z=0) 쪽을 봐야 함
|
|
local front = s.cf:PointToWorldSpace(Vector3.new(0, 0, 40))
|
|
check(math.abs(front.Z) < math.abs(s.cf.Position.Z), `부지 {i} 입구가 길 쪽`)
|
|
end
|
|
check(workspace.BunsikWorld:FindFirstChild("Spawn") ~= nil, "스폰 지점")
|
|
local partCount = 0
|
|
for _, d in workspace.BunsikWorld:GetDescendants() do
|
|
if d:IsA("BasePart") then
|
|
partCount += 1
|
|
check(not d:IsA("PartOperation"), "Union 없음(업로드 제한)")
|
|
end
|
|
end
|
|
print("맵 파트 수", partCount)
|
|
check(partCount < 6000, "맵 파트 6000개 미만")
|
|
|
|
section("NPC")
|
|
local Npc = require(Server.Npc)
|
|
Npc.preload()
|
|
local npc = Npc.spawn(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()
|
|
|
|
section("가게 1: 튜토리얼 흐름")
|
|
local PlotController = require(Server.PlotController)
|
|
local Data = require(Server.Data)
|
|
local function newData()
|
|
local d = table.clone(Data.TEMPLATE)
|
|
d.PurchaseIdCache = {}
|
|
return d
|
|
end
|
|
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,
|
|
lang = "ko",
|
|
notify = function(k)
|
|
table.insert(notes, k)
|
|
end,
|
|
})
|
|
eq(owner:GetAttribute("Tut"), 1, "튜토리얼 1단계")
|
|
eq(owner:GetAttribute("Money"), 0, "돈 0")
|
|
eq(slots[1].refs.nameLabel.Text, "Tester의 분식집", "이름판")
|
|
c:update(0)
|
|
local dyn = slots[1].refs.dynamic
|
|
local customers = 0
|
|
for _, ch in dyn:GetChildren() do
|
|
if ch.Name == "Customer" then
|
|
customers += 1
|
|
check(ch:FindFirstChild("Order", true) ~= nil, "손님 주문 말풍선")
|
|
end
|
|
end
|
|
eq(customers, 1, "첫 손님 NPC 1명")
|
|
eq(slots[1].refs.stove:GetAttribute("CookMenu"), "Tteokbokki", "조리대에 떡볶이 주문 표시")
|
|
eq(slots[1].refs.stove:GetAttribute("OwnerId"), 111, "조리대 주인")
|
|
check((owner:FindFirstChild("Guide") :: ObjectValue).Value ~= nil, "튜토리얼 화살표 목표(조리대)")
|
|
c:update(3)
|
|
eq(c.shop.customers[1].state, "waiting", "손님이 앉음")
|
|
eq(c:cook(), "Tteokbokki", "조리")
|
|
eq(owner:GetAttribute("Tut"), 2, "튜토리얼 2단계")
|
|
eq(owner:GetAttribute("Carry"), 1, "접시 1개 듦")
|
|
eq(slots[1].refs.stove:GetAttribute("CookMenu"), "", "더 만들 것 없음")
|
|
eq(c:serve(1), 10, "서빙 10원")
|
|
eq(owner:GetAttribute("Money"), 10, "돈 10")
|
|
eq(data.Money, 10, "세이브 데이터 돈 10")
|
|
eq(owner:GetAttribute("Tut"), 3, "튜토리얼 3단계")
|
|
check(dyn:FindFirstChild("Dish_Tteokbokki") ~= nil, "테이블에 접시")
|
|
local ok = c:buy()
|
|
check(ok, "테이블 2 구매")
|
|
check(slots[1].refs.upgrades:FindFirstChild("Table2") ~= nil, "테이블 2 모형")
|
|
eq(owner:GetAttribute("Tut"), 0, "튜토리얼 끝")
|
|
eq(data.TutorialDone, true, "튜토리얼 저장")
|
|
eq(data.Bought, 1, "세이브 데이터 구매 1")
|
|
check(table.find(notes, "tutDone") and table.find(notes, "purchased"), "알림")
|
|
c:update(3 + Economy.EAT + 0.5)
|
|
eq(dyn:FindFirstChild("Dish_Tteokbokki"), nil, "다 먹은 접시 치움")
|
|
|
|
section("가게 1: 전부 구매")
|
|
c:addMoney(10_000_000)
|
|
for i = 2, #Economy.PURCHASES do
|
|
local okBuy, err = c:buy()
|
|
check(okBuy, `#{i} 구매 ({err})`)
|
|
end
|
|
eq(owner:GetAttribute("Bought"), #Economy.PURCHASES, "20개 구매")
|
|
eq(owner:GetAttribute("Stage"), 2, "2단계")
|
|
for _, id in { "Expand", "Sign1", "Sign2", "Stove1", "Stove2", "Sauce1", "Sauce2", "Tray1", "Tray2", "Table8" } do
|
|
check(slots[1].refs.upgrades:FindFirstChild(id) ~= nil, `업그레이드 모형 {id}`)
|
|
end
|
|
check(dyn:FindFirstChild("Helper") ~= nil, "알바생 NPC")
|
|
check(table.find(notes, "expanded") ~= nil, "확장 알림")
|
|
local okMax, errMax = c:buy()
|
|
check(not okMax and errMax == "max", "더 살 것 없음")
|
|
check(string.find(slots[1].refs.menuLabel.Text, "튀김") ~= nil, "메뉴판에 튀김")
|
|
|
|
section("가게 1: 가상 5분 영업(봇)")
|
|
local t = 20
|
|
local servedBefore = c.shop.served
|
|
local t0 = os.clock()
|
|
while t < 320 do
|
|
t += 0.1
|
|
c:update(t)
|
|
c:pickup()
|
|
if not c.shop.stats.helper then
|
|
c:cook()
|
|
end
|
|
for id, cust in c.shop.customers do
|
|
if cust.state == "waiting" then
|
|
c:serve(id)
|
|
end
|
|
end
|
|
end
|
|
local elapsed = os.clock() - t0
|
|
local served = c.shop.served - servedBefore
|
|
print(`5분 영업: 서빙 {served}회, 계산 시간 {math.floor(elapsed * 1000)}ms`)
|
|
check(served > 60, "5분 동안 60회 넘게 서빙")
|
|
-- 나가는 손님은 실제 시간으로 몇 초 뒤 지워지므로 잠깐 기다립니다.
|
|
task.wait(Economy.WALK_IN + 1.5)
|
|
local alive = 0
|
|
for _, ch in dyn:GetChildren() do
|
|
if ch.Name == "Customer" then
|
|
alive += 1
|
|
end
|
|
end
|
|
check(alive <= Economy.MAX_SEATS + 6, `손님 NPC가 쌓이지 않음 ({alive})`)
|
|
|
|
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 data2 = newData()
|
|
data2.Bought = 8 -- 알바생까지 산 상태
|
|
data2.Money = 5
|
|
local c2 = PlotController.new(slots[2], owner2, {
|
|
userId = 222,
|
|
displayName = "Tester2",
|
|
data = data2,
|
|
now = 0,
|
|
getCharacter = function()
|
|
return charModel
|
|
end,
|
|
})
|
|
eq(owner2:GetAttribute("Money"), 5, "저장된 돈 불러옴")
|
|
eq(owner2:GetAttribute("Tut"), 1, "튜토리얼 안 끝났으면 1")
|
|
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, "카운터 근처에서 자동으로 집음")
|
|
local held = 0
|
|
for _, ch in charModel:GetChildren() do
|
|
if string.sub(ch.Name, 1, 5) == "Dish_" then
|
|
held += 1
|
|
end
|
|
end
|
|
eq(held, 1, "손에 접시 모형")
|
|
c2:update(3)
|
|
local seat = c2.shop.customers[1].seat
|
|
local PlotBuilder = require(Server.PlotBuilder)
|
|
hrp.CFrame = PlotBuilder.seatCFrame(slots[2].cf, seat) + Vector3.new(0, 2, 2)
|
|
local before = c2.shop.money
|
|
c2:update(3.2)
|
|
check(c2.shop.money > before, "손님 근처에서 자동 서빙")
|
|
-- 리스폰: 손에 든 접시 모형 다시 만들기
|
|
c2:update(4)
|
|
c2:update(4.1)
|
|
c2:rebuildHand()
|
|
c2:destroy()
|
|
eq(#slots[2].refs.dynamic:GetChildren(), 0, "나가면 가게 비움")
|
|
eq(slots[2].refs.stove:GetAttribute("OwnerId"), nil, "조리대 주인 해제")
|
|
charModel:Destroy()
|
|
|
|
section("결제(ProfileStore Mock + Receipts)")
|
|
local ProfileStore = require(ServerScriptService.Vendor.ProfileStore)
|
|
local Receipts = require(Server.Receipts)
|
|
local store = ProfileStore.New("CloudTest", Data.TEMPLATE)
|
|
local prof = store.Mock:StartSessionAsync("Player_1")
|
|
check(prof ~= nil, "Mock 세션")
|
|
local grants = 0
|
|
local decision = Receipts.process(prof, "purchase-1", function()
|
|
grants += 1
|
|
prof.Data.Money += 100
|
|
return true
|
|
end)
|
|
eq(decision, "Granted", "첫 결제 지급")
|
|
local decision2 = Receipts.process(prof, "purchase-1", function()
|
|
grants += 1
|
|
return true
|
|
end)
|
|
eq(decision2, "Granted", "재시도 완료 응답")
|
|
eq(grants, 1, "한 번만 지급")
|
|
eq(prof.Data.Money, 100, "Mock 돈")
|
|
prof:EndSession()
|
|
|
|
section("실제 DataStore 세션")
|
|
local live = ProfileStore.New("CloudTest_v1", Data.TEMPLATE)
|
|
local lp = live:StartSessionAsync("Player_test", {
|
|
Cancel = function()
|
|
return false
|
|
end,
|
|
})
|
|
check(lp ~= nil, "실제 저장소 세션 시작")
|
|
if lp then
|
|
lp.Data.Money += 1
|
|
lp:Save()
|
|
lp:EndSession()
|
|
end
|
|
|
|
section("Game.processReceipt(플레이어 없음)")
|
|
local Game = require(Server.Game)
|
|
eq(
|
|
Game.processReceipt({ PlayerId = 1, PurchaseId = "x", ProductId = 1 }),
|
|
Enum.ProductPurchaseDecision.NotProcessedYet,
|
|
"플레이어가 없으면 나중에"
|
|
)
|
|
|
|
section("화면 UI(서버에서 생성)")
|
|
local Hud = require(StarterPlayer.StarterPlayerScripts.Client.Hud)
|
|
local state = Instance.new("Folder")
|
|
state:SetAttribute("Lang", "ko")
|
|
state:SetAttribute("Money", 25)
|
|
state:SetAttribute("Bought", 1)
|
|
state:SetAttribute("Tut", 3)
|
|
local sent = {}
|
|
local holder = Instance.new("Folder")
|
|
local hud = Hud.build(holder, state, function(kind, arg)
|
|
table.insert(sent, { kind, arg })
|
|
end)
|
|
local root = hud.gui:FindFirstChild("Root") :: Frame
|
|
local moneyText = root:FindFirstChild("Money"):FindFirstChild("Text") :: TextLabel
|
|
eq(moneyText.Text, "💰 25원", "돈 표시")
|
|
local nextTitle = root:FindFirstChild("Next"):FindFirstChild("Title") :: TextLabel
|
|
eq(nextTitle.Text, "다음: 김밥 해금", "다음 업그레이드")
|
|
check((root:FindFirstChild("Hint") :: Frame).Visible, "튜토리얼 안내 보임")
|
|
state:SetAttribute("Lang", "en")
|
|
eq(moneyText.Text, "💰 ₩25", "영어 돈 표시")
|
|
eq(nextTitle.Text, "Next: Unlock Gimbap", "영어 다음 업그레이드")
|
|
state:SetAttribute("Bought", #Economy.PURCHASES)
|
|
check(not (root:FindFirstChild("Next"):FindFirstChild("Buy") :: TextButton).Visible, "다 사면 사기 버튼 숨김")
|
|
check(not (root:FindFirstChild("Dev") :: Frame).Visible, "개발자 버튼은 기본으로 숨김")
|
|
state:SetAttribute("Dev", true)
|
|
check((root:FindFirstChild("Dev") :: Frame).Visible, "게임 주인에게 개발자 버튼")
|
|
check((root:FindFirstChild("Double") :: TextButton).Visible, "2배 수익 버튼(상품 ID 설정됨)")
|
|
hud.notify("purchased", { name = "X" })
|
|
hud.setScale(Hud.scaleFor(Vector2.new(844, 390)))
|
|
hud.destroy()
|
|
|
|
section("조리 버튼(클라이언트 모듈)")
|
|
local Stove = require(StarterPlayer.StarterPlayerScripts.Client.Stove)
|
|
local stove = slots[3].refs.stove
|
|
local pstate = Instance.new("Folder")
|
|
pstate:SetAttribute("Lang", "ko")
|
|
local prompt = Stove.attach(stove, pstate, function() end)
|
|
check(not prompt.Enabled, "주문 없으면 버튼 꺼짐")
|
|
stove:SetAttribute("CookMenu", "Gimbap")
|
|
stove:SetAttribute("CookTime", 1.5)
|
|
check(prompt.Enabled, "주문 있으면 버튼 켜짐")
|
|
eq(prompt.ActionText, "🍙 김밥 만들기", "버튼 글자")
|
|
eq(prompt.HoldDuration, 1.5, "누르는 시간")
|
|
prompt:Destroy()
|
|
|
|
section("효과음(직접 만든 오디오 에셋)")
|
|
local Sounds = require(ReplicatedStorage.Shared.Sounds)
|
|
for name, id in Sounds do
|
|
local num = tonumber(string.match(id, "%d+"))
|
|
local okInfo, info = pcall(function()
|
|
return game:GetService("MarketplaceService"):GetProductInfoAsync(num :: number, Enum.InfoType.Asset)
|
|
end)
|
|
check(okInfo, `효과음 {name} 정보 조회`)
|
|
if okInfo then
|
|
eq(info.AssetTypeId, 3, `효과음 {name}은 오디오`)
|
|
eq(info.Creator.CreatorTargetId, game.CreatorId, `효과음 {name}은 게임 주인 소유`)
|
|
end
|
|
end
|
|
|
|
section("Products")
|
|
local Products = require(ReplicatedStorage.Shared.Products)
|
|
local MarketplaceService = game:GetService("MarketplaceService")
|
|
if Products.DOUBLE_MONEY_PASS ~= 0 then
|
|
local info = MarketplaceService:GetProductInfoAsync(Products.DOUBLE_MONEY_PASS, Enum.InfoType.GamePass)
|
|
print("게임패스", info.Name, info.PriceInRobux, info.IsForSale)
|
|
check(info.IsForSale, "2배 수익 판매 중")
|
|
end
|
|
if Products.MONEY_BOOST_PRODUCT ~= 0 then
|
|
local info = MarketplaceService:GetProductInfoAsync(Products.MONEY_BOOST_PRODUCT, Enum.InfoType.Product)
|
|
print("개발자 상품", info.Name, info.PriceInRobux)
|
|
check(info.PriceInRobux ~= nil, "돈 부스트 가격")
|
|
end
|
|
|
|
c:destroy()
|
|
|
|
section("Game.start(실제 서버 시작 순서)")
|
|
local okStart, errStart = pcall(Game.start)
|
|
check(okStart, `Game.start 오류 없음 ({errStart})`)
|
|
task.wait(1)
|
|
eq(#workspace.BunsikWorld.Plots:GetChildren(), 6, "시작 후 부지 6칸")
|
|
|
|
print(`통합 테스트: {count - #failures}/{count} 통과`)
|
|
if #failures > 0 then
|
|
error(`{#failures} failed: ` .. table.concat(failures, " | "))
|
|
end
|
|
return { passed = count }
|