feat(bunsik): MVP 전체 구현 — 맵, 요리·서빙, 손님 NPC, 업그레이드 20개, 세이브, 결제, 한/영 UI

- Shop.luau: 손님·주문·조리·서빙·구매 순수 로직(lune 단위 테스트, 시뮬레이터 공용)
- 서버: World(부지 6칸), PlotBuilder(파트 모형), PlotController, Npc(트윈 이동), Data(ProfileStore), Receipts(결제 1회 = 지급 1회), Game
- 클라이언트: Hud(돈·다음 업그레이드·목록·결제·언어·튜토리얼), 내 조리대 전용 버튼, 튜토리얼 화살표, 주인 전용 테스트 버튼
- 2단계 업그레이드 10개 추가, 파이썬 시뮬레이터를 실제 로직 기반 tools/sim.luau로 교체
- tools/cloud.py: 업로드, 원격 Luau 실행, 게임패스·개발자 상품 생성, 서버 인원 설정
- tests/cloud/integration.luau: 로블록스 서버 통합 테스트 514개 통과
- check.sh에 luau-lsp 타입 검사 추가, ProfileStore 고정 버전 포함

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-12 01:34:06 +09:00
parent 060974e277
commit 802ba10e1a
45 changed files with 6997 additions and 202 deletions

View File

@@ -1,34 +1,65 @@
-- 로블록스 없이 서버에서 돌리는 단위 테스트: lune run tests/Economy.spec.luau
-- 경제 수치표 검사: lune run tests/Economy.spec.luau
local Economy = require("../src/shared/Economy")
local T = require("./check")
local failures = 0
local function check(cond: boolean, msg: string)
if not cond then
failures += 1
print("FAIL " .. msg)
end
end
check(#Economy.PURCHASES == 10, "구매 항목은 10개")
T.eq(#Economy.PURCHASES, 20, "구매 항목은 20개(1단계 10 + 2단계 10)")
T.eq(Economy.PURCHASES[10].id, "Expand", "10번째는 실내 확장")
T.eq(Economy.PURCHASES[10].effect.stage, 2, "확장하면 2단계")
local seen = {}
local prev = 0
for i, p in Economy.PURCHASES do
check(p.cost > prev, `#{i} {p.id} 비용이 앞 단계보다 커야 함`)
T.check(p.cost > prev, `#{i} {p.id} 비용이 앞 단계보다 커야 함`)
prev = p.cost
check(seen[p.id] == nil, `#{i} {p.id} id 중복`)
T.check(seen[p.id] == nil, `#{i} {p.id} id 중복`)
seen[p.id] = true
T.check(p.name ~= "" and p.nameEn ~= "", `#{i} 이름(한/영)`)
if p.effect.menu then
check(Economy.MENUS[p.effect.menu] ~= nil, `#{i} 없는 메뉴 {p.effect.menu}`)
T.check(Economy.MENUS[p.effect.menu] ~= nil, `#{i} 없는 메뉴 {p.effect.menu}`)
end
end
check(Economy.PURCHASES[#Economy.PURCHASES].id == "Expand", "마지막 구매는 확장")
for _, m in Economy.START.menus do
check(Economy.MENUS[m] ~= nil, `시작 메뉴 {m} 없음`)
for _, key in Economy.MENU_ORDER do
T.check(Economy.MENUS[key] ~= nil, `메뉴 순서의 {key}`)
end
if failures > 0 then
error(`{failures} test(s) failed`)
end
print("Economy.spec: all passed")
local s0 = Economy.statsAt(0)
T.eq(s0.seats, 1, "처음 테이블 1")
T.eq(s0.spawn, 6, "처음 손님 간격 6초")
T.eq(s0.cook, 2.5, "처음 조리 2.5초")
T.eq(#s0.menus, 1, "처음 메뉴 1개")
T.eq(s0.carry, 1, "처음 접시 1개")
local s10 = Economy.statsAt(10)
T.eq(s10.seats, 4, "10개 산 뒤 테이블 4")
T.eq(s10.spawn, 4, "10개 산 뒤 손님 간격 4초")
T.eq(s10.helper, true, "10개 산 뒤 알바생")
T.eq(s10.stage, 2, "10개 산 뒤 2단계")
T.eq(#s10.menus, 3, "10개 산 뒤 메뉴 3개")
local s20 = Economy.statsAt(20)
T.eq(s20.seats, Economy.MAX_SEATS, "전부 산 뒤 테이블 8")
T.eq(s20.carry, 3, "전부 산 뒤 접시 3개")
T.eq(#s20.menus, 5, "전부 산 뒤 메뉴 5개")
T.eq(Economy.statsAt(99).seats, 8, "범위를 넘어도 안전")
-- statsAt은 START를 바꾸면 안 됨
Economy.statsAt(20)
T.eq(#Economy.START.menus, 1, "START.menus 불변")
T.eq(Economy.dishPrice("Tteokbokki", s0, 1), 10, "떡볶이 10")
T.eq(Economy.dishPrice("Sundae", Economy.statsAt(7), 1), 52, "순대 35 x 1.5 = 52(내림)")
T.eq(Economy.dishPrice("Tteokbokki", s0, 2), 20, "2배 수익")
T.eq(
Economy.boostAmount(s0),
math.max(Economy.BOOST_MIN, Economy.incomePerMinute(s0) * 10),
"부스트 = 1분 매출 x 10분"
)
T.check(
Economy.incomePerMinute(s0) >= 30 and Economy.incomePerMinute(s0) <= 60,
"처음 1분 매출 30~60원(시뮬레이터와 비슷)"
)
T.check(Economy.boostAmount(s20) > Economy.boostAmount(s10), "후반일수록 부스트가 큼")
T.done("Economy.spec")

View File

@@ -0,0 +1,40 @@
-- 번역 검사: 한/영 키가 같고, 코드에서 쓰는 키가 모두 있는지. lune run tests/Locale.spec.luau
local fs = require("@lune/fs")
local Locale = require("../src/shared/Locale")
local T = require("./check")
local ko = Locale.keys("ko")
local en = Locale.keys("en")
table.sort(ko)
table.sort(en)
T.eq(#ko, #en, "한/영 키 개수")
for _, k in ko do
T.check(table.find(en, k) ~= nil, `영어에 {k} 있음`)
end
local function scan(dir: string)
for _, name in fs.readDir(dir) do
local path = dir .. "/" .. name
if fs.isDir(path) then
scan(path)
elseif string.match(name, "%.luau$") then
local src = fs.readFile(path)
for _, pat in { 'Locale%.t%([^,]+,%s*"([%w]+)"', '[%s%(:]L%("([%w]+)"[,%)]', 'notify%("([%w]+)"' } do
for key in string.gmatch(src, pat) do
T.check(table.find(ko, key) ~= nil, `{path}: 키 {key}`)
end
end
end
end
end
scan("src")
T.eq(Locale.pick("ko-kr"), "ko", "ko-kr -> ko")
T.eq(Locale.pick("en-us"), "en", "en-us -> en")
T.eq(Locale.pick("ja-jp"), "en", "그 외 -> en")
T.eq(Locale.t("ko", "money", { money = "1,000" }), "1,000원", "치환")
T.eq(Locale.number(1234567), "1,234,567", "쉼표")
T.eq(Locale.number(999), "999", "쉼표 없음")
T.eq(Locale.number(0), "0", "0")
T.done("Locale.spec")

View File

@@ -0,0 +1,90 @@
-- 결제 1회 = 지급 1회 검사(가짜 프로필): lune run tests/Receipts.spec.luau
local Receipts = require("../src/server/Receipts")
local T = require("./check")
local function deepcopy(t)
local out = {}
for k, v in t do
out[k] = if type(v) == "table" then deepcopy(v) else v
end
return out
end
local function fakeProfile(saveWorks: boolean)
local p = {
Data = { PurchaseIdCache = {}, Money = 0 },
LastSavedData = { PurchaseIdCache = {} },
active = true,
saves = 0,
}
function p:IsActive()
return self.active
end
function p:Save()
self.saves += 1
if saveWorks then
self.LastSavedData = deepcopy(self.Data)
else
self.active = false -- 저장 실패 끝에 세션이 끝난 상황
end
end
p.OnAfterSave = { Wait = function() end }
return p
end
local p = fakeProfile(true)
local grants = 0
local function grant()
grants += 1
p.Data.Money += 100
return true
end
T.eq(Receipts.process(p, "A", grant), "Granted", "첫 결제 지급")
T.eq(grants, 1, "지급 1회")
T.eq(p.Data.Money, 100, "돈 들어옴")
T.check(table.find(p.LastSavedData.PurchaseIdCache, "A") ~= nil, "저장된 데이터에 PurchaseId 기록")
T.eq(Receipts.process(p, "A", grant), "Granted", "같은 결제 재시도도 완료로 답함")
T.eq(grants, 1, "같은 결제는 다시 지급하지 않음")
T.eq(Receipts.process(p, "B", grant), "Granted", "다른 결제는 지급")
T.eq(grants, 2, "지급 2회")
T.eq(Receipts.process(nil, "C", grant), "NotProcessedYet", "프로필 없으면 나중에")
T.eq(grants, 2, "프로필 없으면 지급 안 함")
local q = fakeProfile(true)
T.eq(
Receipts.process(q, "X", function()
return false
end),
"NotProcessedYet",
"지급 실패면 나중에"
)
T.eq(#q.Data.PurchaseIdCache, 0, "실패한 결제는 기록 안 함")
T.eq(
Receipts.process(q, "Y", function()
error("boom")
end),
"NotProcessedYet",
"지급 중 오류면 나중에"
)
local r = fakeProfile(false)
local rg = 0
T.eq(
Receipts.process(r, "Z", function()
rg += 1
return true
end),
"NotProcessedYet",
"저장 확인 못 하면 완료로 답하지 않음"
)
local c = fakeProfile(true)
for i = 1, Receipts.CACHE_SIZE + 5 do
Receipts.process(c, "P" .. i, function()
return true
end)
end
T.eq(#c.Data.PurchaseIdCache, Receipts.CACHE_SIZE, "기록은 최근 100개까지")
T.done("Receipts.spec")

View File

@@ -0,0 +1,112 @@
-- 가게 로직 검사: lune run tests/Shop.spec.luau
local Economy = require("../src/shared/Economy")
local Shop = require("../src/shared/Shop")
local T = require("./check")
-- 첫 손님은 바로 오고, 걸어서 자리에 앉습니다.
local s = Shop.new(0, 0, 100)
local ev = Shop.tick(s, 100)
T.eq(#ev, 1, "접속하자마자 손님 1명")
T.eq(ev[1].kind, "spawn", "spawn 이벤트")
T.eq(ev[1].menu, "Tteokbokki", "첫 주문은 떡볶이")
T.eq(Shop.nextCookMenu(s), "Tteokbokki", "걷는 중인 손님 주문도 미리 만들 수 있음")
T.eq(Shop.serve(s, 1), nil, "앉기 전에는 서빙 불가")
-- 자리가 1개면 두 번째 손님은 못 들어옴
local ev2 = Shop.tick(s, 106)
local spawned = 0
for _, e in ev2 do
if e.kind == "spawn" then
spawned += 1
end
end
T.eq(spawned, 0, "빈자리 없으면 손님이 지나감")
T.eq(s.customers[1].state, "waiting", "2.5초 뒤 자리에 앉음")
-- 조리 -> 서빙 -> 돈
T.eq(Shop.cook(s), "Tteokbokki", "조리하면 떡볶이")
T.eq(Shop.cook(s), nil, "손이 꽉 차면 더 못 만듦")
T.eq(Shop.nextCookMenu(s), nil, "열린 주문 없음")
local earn = Shop.serve(s, 1)
T.eq(earn, 10, "떡볶이 10원")
T.eq(s.money, 10, "돈 10")
T.eq(#s.hand, 0, "접시를 내려놓음")
T.eq(Shop.serve(s, 1), nil, "같은 손님에게 두 번 못 줌")
T.eq(s.customers[1].state, "eating", "먹는 중")
-- 다 먹으면 나가고 자리가 빔
local ev3 = Shop.tick(s, 106 + Economy.EAT + 0.1)
local left = false
for _, e in ev3 do
if e.kind == "leave" then
left = true
end
end
T.check(left, "다 먹으면 나감")
T.eq(s.customers[1], nil, "손님 목록에서 빠짐")
-- 구매
local p, err = Shop.buyNext(s)
T.eq(p and p.id, "Table2", "첫 구매는 테이블 2")
T.eq(err, nil, "구매 성공")
T.eq(s.money, 0, "돈 차감")
T.eq(s.stats.seats, 2, "테이블 2개")
local p2, err2 = Shop.buyNext(s)
T.eq(p2, nil, "돈이 모자라면 실패")
T.eq(err2, "money", "실패 이유 money")
-- 2배 수익
local d = Shop.new(0, 0, 0)
d.moneyMult = 2
Shop.tick(d, 0)
Shop.tick(d, 3)
Shop.cook(d)
T.eq(Shop.serve(d, 1), 20, "2배 수익이면 20원")
-- 메뉴는 해금된 것을 돌아가며 주문
local m = Shop.new(0, 2, 0) -- 테이블2, 김밥 해금
Shop.tick(m, 0)
Shop.tick(m, 6)
T.eq(m.customers[1].menu, "Tteokbokki", "첫 손님 떡볶이")
T.eq(m.customers[2].menu, "Gimbap", "두 번째 손님 김밥")
-- 다른 메뉴 접시는 다른 손님에게 못 줌
Shop.tick(m, 9)
T.eq(Shop.cook(m), "Tteokbokki", "먼저 온 손님 메뉴부터")
T.eq(Shop.serve(m, 2), nil, "김밥 손님에게 떡볶이 불가")
T.eq(Shop.serve(m, 1), 10, "떡볶이 손님에게 성공")
-- 알바생: 카운터에 접시를 만들어 두고, 플레이어는 집어서 나름
local h = Shop.new(0, 8, 0)
T.eq(h.stats.helper, true, "알바생 있음")
local evs = Shop.tick(h, 0)
local counter = 0
for _, e in evs do
if e.kind == "counter" then
counter += 1
end
end
T.eq(counter, 1, "알바생이 첫 주문을 바로 만듦")
T.eq(#h.counter, 1, "카운터에 접시 1")
T.eq(Shop.nextCookMenu(h), nil, "만들어 둔 접시가 주문을 덮음")
T.eq(Shop.pickup(h), 1, "접시를 집음")
T.eq(#h.counter, 0, "카운터 비움")
Shop.tick(h, 3)
T.check(Shop.serve(h, 1) ~= nil, "알바생 접시로 서빙")
-- 쟁반: 여러 접시
local t = Shop.new(0, 11, 0)
T.eq(t.stats.carry, 2, "쟁반이면 2개")
T.eq(t.stats.seats, 4, "11번째까지 테이블 4")
-- 전부 산 뒤
local full = Shop.new(1e9, #Economy.PURCHASES, 0)
local none, why = Shop.buyNext(full)
T.eq(none, nil, "더 살 것 없음")
T.eq(why, "max", "이유 max")
-- 세이브 값이 이상해도 안전
local weird = Shop.new(5, 999, 0)
T.eq(weird.bought, #Economy.PURCHASES, "산 개수는 최대값으로 자름")
T.done("Shop.spec")

View File

@@ -0,0 +1,31 @@
-- 봇 플레이로 구매 시점 목표를 검사: lune run tests/Sim.spec.luau
local Sim = require("../tools/simlib")
local T = require("./check")
local function at(log, id)
for _, e in log do
if e.id == id then
return e.t
end
end
return math.huge
end
local base = Sim.run(1, 3600)
T.eq(#base, 20, "봇이 1시간 안에 20개 모두 삼")
T.check(at(base, "Table2") <= 10, "첫 구매 10초 안")
T.check(at(base, "Expand") >= 8 * 60 and at(base, "Expand") <= 12 * 60, "실내 확장 8~12분")
local prev = 0
for i, e in base do
if i > 1 and i <= 10 then
T.check(e.t - prev <= 100, `1단계 #{i} 구매 간격 100초 이하`)
elseif i > 10 then
T.check(e.t - prev <= 180, `2단계 #{i} 구매 간격 180초 이하`)
end
prev = e.t
end
local x2 = Sim.run(2, 3600)
T.check(at(x2, "Expand") < at(base, "Expand") * 0.65, "2배 수익이면 확장이 훨씬 빠름")
T.done("Sim.spec")

View File

@@ -0,0 +1,25 @@
-- 아주 작은 테스트 도우미: check(조건, 메시지) 후 done(이름)
local failures = 0
local count = 0
local M = {}
function M.check(cond: any, msg: string)
count += 1
if not cond then
failures += 1
print("FAIL " .. msg)
end
end
function M.eq(a: any, b: any, msg: string)
M.check(a == b, `{msg} (기대 {tostring(b)}, 실제 {tostring(a)})`)
end
function M.done(name: string)
if failures > 0 then
error(`{name}: {failures}/{count} failed`)
end
print(`{name}: {count} checks passed`)
end
return M

View File

@@ -0,0 +1,339 @@
-- 로블록스 서버(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("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 }