feat(bunsik): 이웃 가게·손님 방문 멀티플레이, 4개 언어, 설정 창, 마우스 회전, 김밥 해금 효과

- 빈 부지에 NPC 사장님이 운영하는 이웃 가게(크기 제각각), 플레이어가 오면 그 자리를 넘겨줌
- 다른 가게 입구에서 손님으로 앉기: 주인은 2배 값, 손님은 시식 보너스(1분에 한 번)
- 한국어·영어·일본어·중국어(계정 언어 자동 선택), 이름판·메뉴판은 보는 사람 언어로
- 오른쪽 위 언어 버튼을 설정 창으로: 언어, 마우스로 화면 돌리기(PC 기본 켜짐), 효과음
- 메뉴 해금 시 진열대 모형이 생기고 다음 손님이 바로 새 메뉴를 주문
- 통합 테스트 600개 통과

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-12 05:37:46 +09:00
parent c7af87c646
commit 4d861b8fd3
21 changed files with 1464 additions and 135 deletions

View File

@@ -13,7 +13,6 @@ for i, p in Economy.PURCHASES do
prev = p.cost
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
T.check(Economy.MENUS[p.effect.menu] ~= nil, `#{i} 없는 메뉴 {p.effect.menu}`)
end

View File

@@ -1,15 +1,40 @@
-- 번역 검사: 한/영 키가 같고, 코드에서 쓰는 키가 모두 있는지. lune run tests/Locale.spec.luau
-- 번역 검사: 네 언어 키가 같고, 코드에서 쓰는 키와 메뉴·업그레이드 이름이 모두 있는지. lune run tests/Locale.spec.luau
local fs = require("@lune/fs")
local Economy = require("../src/shared/Economy")
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} 있음`)
for _, lang in Locale.LANGS do
local keys = Locale.keys(lang)
T.eq(#keys, #ko, `{lang} 키 개수`)
for _, k in ko do
T.check(table.find(keys, k) ~= nil, `{lang}에 {k} 있음`)
end
T.check(Locale.LANG_NAMES[lang] ~= nil, `{lang} 언어 이름`)
for i = 1, 6 do
T.check(Locale.t(lang, `npcShop{i}`) ~= `npcShop{i}`, `{lang} 이웃 가게 이름 {i}`)
end
for key in Economy.MENUS do
T.check(Locale.menuName(lang, key) ~= "menu_" .. key, `{lang} 메뉴 이름 {key}`)
end
for _, p in Economy.PURCHASES do
T.check(Locale.itemName(lang, p.id) ~= "item_" .. p.id, `{lang} 업그레이드 이름 {p.id}`)
end
-- 치환 자리({money} 등)가 한국어와 같아야 함
for _, k in ko do
local want, got = {}, {}
for v in string.gmatch(Locale.t("ko", k), "{(%w+)}") do
want[v] = true
end
for v in string.gmatch(Locale.t(lang, k), "{(%w+)}") do
got[v] = true
end
for v in want do
T.check(got[v], `{lang}.{k}에 {"{" .. v .. "}"} 있음`)
end
end
end
local function scan(dir: string)
@@ -31,8 +56,21 @@ 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.pick("ja-jp"), "ja", "ja-jp -> ja")
T.eq(Locale.pick("zh-cn"), "zh", "zh-cn -> zh")
T.eq(Locale.pick("zh-tw"), "zh", "zh-tw -> zh")
T.eq(Locale.pick("fr-fr"), "en", "그 외 -> en")
T.eq(Locale.resolve("", "ja-jp"), "ja", "자동이면 계정 언어")
T.eq(Locale.resolve("zh", "ko-kr"), "zh", "직접 고른 언어가 먼저")
T.eq(Locale.resolve("xx", "ko-kr"), "ko", "모르는 설정이면 계정 언어")
T.eq(Locale.t("ko", "money", { money = "1,000" }), "1,000원", "치환")
T.eq(
Locale.t("ja", "newMenu", { menuName = "キンパ" }),
"新メニュー「キンパ」!お客さんがキンパも注文するようになるよ",
"같은 자리 두 번 치환"
)
T.eq(Locale.menuName("zh", "Gimbap"), "紫菜包饭", "중국어 메뉴 이름")
T.eq(Locale.itemName("en", "Expand"), "Indoor Shop", "영어 업그레이드 이름")
T.eq(Locale.number(1234567), "1,234,567", "쉼표")
T.eq(Locale.number(999), "999", "쉼표 없음")
T.eq(Locale.number(0), "0", "0")

View File

@@ -109,4 +109,72 @@ T.eq(why, "max", "이유 max")
local weird = Shop.new(5, 999, 0)
T.eq(weird.bought, #Economy.PURCHASES, "산 개수는 최대값으로 자름")
-- 새 메뉴를 사면 다음 손님이 1초 안에 와서 그 메뉴를 주문
local nm = Shop.new(40, 1, 0) -- 테이블 2개, 다음 구매는 김밥 해금
Shop.tick(nm, 0) -- 첫 손님(떡볶이)
local bp = Shop.buyNext(nm)
T.eq(bp and bp.id, "UnlockGimbap", "김밥 해금 구매")
local nmEv = Shop.tick(nm, 1)
local newOrder = nil
for _, e in nmEv do
if e.kind == "spawn" then
newOrder = e.menu
end
end
T.eq(newOrder, "Gimbap", "사자마자 다음 손님이 김밥 주문")
-- 플레이어 손님: 빈자리에 바로 앉고, 2배 값을 내고, 다 먹으면 나감
local g = Shop.new(0, 1, 0) -- 테이블 2개
Shop.tick(g, 0) -- NPC 손님 1명(1번 자리)
local guest = Shop.addGuest(g, 777)
T.check(guest ~= nil, "플레이어 손님 앉음")
T.eq(guest and guest.seat, 2, "빈 2번 자리")
T.eq(guest and guest.state, "waiting", "걷지 않고 바로 주문")
T.eq(Shop.addGuest(g, 777), nil, "같은 플레이어는 한 번만")
T.eq(Shop.addGuest(g, 888), nil, "빈자리가 없으면 못 앉음")
local spawnedWhileFull = false
for _, e in Shop.tick(g, 6.5) do
if e.kind == "spawn" then
spawnedWhileFull = true
end
end
T.check(not spawnedWhileFull, "플레이어 손님 자리에는 NPC가 안 옴")
Shop.cook(g) -- 1번 손님 떡볶이
T.eq(Shop.serve(g, 1), 10, "NPC 손님은 1배")
local gid = (guest :: any).id
T.eq(Shop.nextCookMenu(g), (guest :: any).menu, "플레이어 손님 주문도 조리대에 뜸")
Shop.cook(g)
T.eq(Shop.serve(g, gid), 20, "플레이어 손님은 2배")
local guestLeave = nil
for _, e in Shop.tick(g, 6.5 + Economy.EAT + 0.1) do
if e.kind == "leave" and e.guest then
guestLeave = e
end
end
T.check(guestLeave ~= nil, "다 먹으면 플레이어 손님도 나감")
T.eq(guestLeave and guestLeave.guest, 777, "나간 손님 UserId")
T.eq(guestLeave and guestLeave.served, true, "먹고 나감")
-- 음식을 너무 오래 못 받으면 일어남
local w = Shop.new(0, 0, 0)
local wg = Shop.addGuest(w, 5)
T.check(wg ~= nil, "자리 1개에 플레이어 손님")
local hungry = nil
for _, e in Shop.tick(w, Economy.GUEST_WAIT + 0.1) do
if e.kind == "leave" then
hungry = e
end
end
T.eq(hungry and hungry.served, false, "못 먹고 나감")
T.check(w.seatTaken[1] ~= (wg :: any).id, "자리 비움(바로 NPC 손님이 앉을 수 있음)")
-- 먼저 일어나면 자리만 비움
local r = Shop.new(0, 0, 0)
local rg = Shop.addGuest(r, 9) :: any
T.eq(Shop.removeGuest(r, rg.id) and true, true, "일어남")
T.eq(r.seatTaken[1], nil, "자리 비움")
T.eq(Shop.removeGuest(r, rg.id), nil, "두 번은 안 됨")
Shop.tick(r, 0)
T.eq(Shop.removeGuest(r, 2), nil, "NPC 손님은 removeGuest로 못 뺌")
T.done("Shop.spec")

View File

@@ -26,6 +26,7 @@ local function section(name: string)
end
local Economy = require(ReplicatedStorage.Shared.Economy)
local Locale = require(ReplicatedStorage.Shared.Locale)
section("맵")
local World = require(Server.World)
@@ -80,14 +81,17 @@ local c = PlotController.new(slots[1], owner, {
displayName = "Tester",
data = data,
now = 0,
lang = "ko",
notify = function(k)
table.insert(notes, k)
end,
})
local Plots = require(StarterPlayer.StarterPlayerScripts.Client.Plots)
eq(owner:GetAttribute("Tut"), 1, "튜토리얼 1단계")
eq(owner:GetAttribute("Money"), 0, "돈 0")
eq(slots[1].refs.nameLabel.Text, "Tester의 분식집", "이름판")
eq(slots[1].model:GetAttribute("OwnerId"), 111, "부지 주인 속성")
eq(Plots.nameText(slots[1].model, "ko"), "Tester의 분식집", "이름판(한국어)")
eq(Plots.nameText(slots[1].model, "ja"), "Testerのブンシク店", "이름판(일본어)")
eq(Plots.nameText(slots[4].model, "en"), "Empty lot", "빈 자리 이름판")
c:update(0)
local dyn = slots[1].refs.dynamic
local customers = 0
@@ -119,12 +123,36 @@ eq(owner:GetAttribute("Tut"), 0, "튜토리얼 끝")
eq(data.TutorialDone, true, "튜토리얼 저장")
eq(data.Bought, 1, "세이브 데이터 구매 1")
check(table.find(notes, "tutDone") and table.find(notes, "purchased"), "알림")
section("가게 1: 김밥 해금이 바로 보임")
c:addMoney(40)
check(c:buy(), "김밥 해금 구매")
check(slots[1].refs.upgrades:FindFirstChild("UnlockGimbap") ~= nil, "김밥 진열대 모형")
check(
slots[1].refs.upgrades:FindFirstChild("UnlockGimbap"):FindFirstChild("Display") ~= nil,
"진열대에 김밥 접시"
)
check(table.find(notes, "newMenu") ~= nil, "새 메뉴 알림")
check(string.find(Plots.menuText(slots[1].model, "ko"), "김밥") ~= nil, "메뉴판에 김밥")
local gimbapOrder = false
for k = 1, 30 do
c:update(3 + Economy.EAT + 0.5 + k * 0.1)
for _, cust in c.shop.customers do
if cust.menu == "Gimbap" then
gimbapOrder = true
end
end
if gimbapOrder then
break
end
end
check(gimbapOrder, "산 직후 3초 안에 김밥 주문 손님")
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
for i = 3, #Economy.PURCHASES do
local okBuy, err = c:buy()
check(okBuy, `#{i} 구매 ({err})`)
end
@@ -137,7 +165,9 @@ 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, "메뉴판에 튀김")
check(string.find(Plots.menuText(slots[1].model, "ko"), "튀김") ~= nil, "메뉴판에 튀김")
check(string.find(Plots.menuText(slots[1].model, "zh"), "炸物") ~= nil, "중국어 메뉴판")
check(slots[1].refs.upgrades:FindFirstChild("UnlockTwigim") ~= nil, "튀김 진열대 모형")
section("가게 1: 가상 5분 영업(봇)")
local t = 20
@@ -221,6 +251,107 @@ eq(#slots[2].refs.dynamic:GetChildren(), 0, "나가면 가게 비움")
eq(slots[2].refs.stove:GetAttribute("OwnerId"), nil, "조리대 주인 해제")
charModel:Destroy()
section("다른 플레이어가 손님으로 방문")
local guestChar =
Players:CreateHumanoidModelFromDescription(Instance.new("HumanoidDescription"), Enum.HumanoidRigType.R15)
guestChar.Name = "GuestCharacter"
guestChar.Parent = workspace
local hostOwner = Instance.new("Folder")
hostOwner.Parent = ServerScriptService
local hostData = newData()
hostData.Bought = 5 -- 자리 3개
hostData.TutorialDone = true
local guestEvents = {}
local host = PlotController.new(slots[2], hostOwner, {
userId = 333,
displayName = "Host",
data = hostData,
now = 0,
guestEvent = function(kind, userId, info)
table.insert(guestEvents, { kind, userId, info })
end,
})
local gc = host:addGuest(444, guestChar)
check(gc ~= nil, "빈자리에 손님으로 앉음")
eq(host:addGuest(444, guestChar), nil, "같은 손님은 한 번만")
local guestSeat = slots[2].refs.dynamic:FindFirstChild("GuestSeat") :: Seat?
check(guestSeat ~= nil, "손님 의자")
print("손님 의자 Occupant", guestSeat and guestSeat.Occupant)
eq(slots[2].refs.stove:GetAttribute("CookMenu"), gc and gc.menu, "손님 주문이 조리대에 뜸")
host.shop.now = 0.5
eq(host:cook(), gc and gc.menu, "손님 메뉴 조리")
local hostBefore = host.shop.money
local guestEarn = host:serve(gc.id)
eq(guestEarn, Economy.dishPrice(gc.menu, host.shop.stats, 1) * Economy.GUEST_MULT, "손님 접시는 2배 값")
eq(host.shop.money - hostBefore, guestEarn, "주인 돈 증가")
eq(guestEvents[1] and guestEvents[1][1], "served", "손님에게 서빙 소식")
eq(guestEvents[1] and guestEvents[1][3].price, Economy.dishPrice(gc.menu, host.shop.stats, 1), "시식 보너스 값")
host:update(0.6 + Economy.EAT + 0.5)
eq(guestEvents[2] and guestEvents[2][1], "left", "다 먹고 일어남")
eq(guestEvents[2] and guestEvents[2][3].reason, "ate", "일어난 이유: 다 먹음")
eq(slots[2].refs.dynamic:FindFirstChild("GuestSeat"), nil, "손님 의자 치움")
-- 오래 기다리면 일어남
local gc2 = host:addGuest(444, guestChar)
check(gc2 ~= nil, "다시 손님으로 앉음")
host:update(0.6 + Economy.EAT + 1 + Economy.GUEST_WAIT + 0.5)
eq(guestEvents[#guestEvents][3].reason, "hungry", "너무 기다리면 일어남")
-- 주인이 나가면 손님도 일어남
check(host:addGuest(444, guestChar) ~= nil, "세 번째 앉음")
host:destroy()
eq(guestEvents[#guestEvents][3].reason, "closed", "가게가 닫히면 일어남")
guestChar:Destroy()
section("이웃 가게(NPC 가게)")
local Neighbor = require(Server.Neighbor)
local nb = Neighbor.open(slots[5], 0)
eq(slots[5].model:GetAttribute("Npc"), 5, "이웃 가게 속성")
eq(slots[5].model:GetAttribute("OwnerId"), nil, "이웃 가게엔 주인 없음")
eq(slots[5].model:GetAttribute("Level"), Neighbor.LEVELS[5], "이웃 가게 크기")
eq(slots[5].refs.stove:GetAttribute("OwnerId"), nil, "이웃 가게 조리대엔 버튼 없음")
check(slots[5].refs.dynamic:FindFirstChild("Keeper") ~= nil, "사장님 NPC")
eq(
Plots.nameText(slots[5].model, "ko"),
Locale.t("ko", "npcShop5") .. ` ⭐Lv.{Neighbor.LEVELS[5]}`,
"이웃 가게 이름판"
)
local nt = 0
while nt < 90 do
nt += 0.1
Neighbor.update(nb, nt)
end
print(`이웃 가게 90초: 서빙 {nb.controller.shop.served}회`)
check(nb.controller.shop.served >= 5, "이웃 가게가 스스로 서빙")
Neighbor.close(nb)
eq(slots[5].model:GetAttribute("Npc"), nil, "닫으면 속성 해제")
eq(#slots[5].refs.dynamic:GetChildren(), 0, "닫으면 가게 비움")
section("부지 글자·손님 버튼(클라이언트 모듈)")
local viewer = Instance.new("Folder")
viewer:SetAttribute("Lang", "en")
local nb2 = Neighbor.open(slots[6], 0)
local detach = Plots.attach(slots[6].model, viewer, 999, function() end)
local visitPrompt = slots[6].model.Base.VisitPoint:FindFirstChild("VisitPrompt") :: ProximityPrompt
check(visitPrompt ~= nil and visitPrompt.Enabled, "이웃 가게 입구에 손님 버튼")
eq(visitPrompt.ActionText, "Eat here as a customer", "손님 버튼 글자(영어)")
local boardLabel = slots[6].model.Base.NameBoard:FindFirstChildOfClass("SurfaceGui"):FindFirstChildOfClass("TextLabel")
check(string.find(boardLabel.Text, "Twigim King") ~= nil, `이름판 영어 ({boardLabel.Text})`)
viewer:SetAttribute("Lang", "ja")
check(string.find(boardLabel.Text, "天ぷら") ~= nil, `언어 바꾸면 이름판도 바뀜 ({boardLabel.Text})`)
Neighbor.close(nb2)
check(not visitPrompt.Enabled, "닫힌 가게엔 손님 버튼 없음")
slots[6].model:SetAttribute("OwnerId", 999)
check(not visitPrompt.Enabled, "내 가게엔 손님 버튼 없음")
slots[6].model:SetAttribute("OwnerId", nil)
detach()
section("마우스 회전 판단")
local MouseLook = require(StarterPlayer.StarterPlayerScripts.Client.MouseLook)
check(MouseLook.shouldLock(true, true, false, false), "켜짐 + 마우스 = 고정")
check(not MouseLook.shouldLock(false, true, false, false), "설정 끄면 안 고정")
check(not MouseLook.shouldLock(true, false, false, false), "마우스 없으면(모바일) 안 고정")
check(not MouseLook.shouldLock(true, true, true, false), "Ctrl 누르면 커서 풀림")
check(not MouseLook.shouldLock(true, true, false, true), "창 열리면 커서 풀림")
section("결제(ProfileStore Mock + Receipts)")
local ProfileStore = require(ServerScriptService.Vendor.ProfileStore)
local Receipts = require(Server.Receipts)
@@ -286,13 +417,32 @@ check((root:FindFirstChild("Hint") :: Frame).Visible, "튜토리얼 안내 보
state:SetAttribute("Lang", "en")
eq(moneyText.Text, "💰 ₩25", "영어 돈 표시")
eq(nextTitle.Text, "Next: Unlock Gimbap", "영어 다음 업그레이드")
state:SetAttribute("Lang", "zh")
eq(nextTitle.Text, "下一个: 解锁紫菜包饭", "중국어 다음 업그레이드")
state:SetAttribute("Lang", "en")
check(root:FindFirstChild("Lang") == nil, "언어 버튼 대신")
local settingsBtn = root:FindFirstChild("Settings") :: TextButton
check(settingsBtn ~= nil, "오른쪽 위 설정 버튼")
eq(settingsBtn and settingsBtn.Text, "⚙️ Settings", "설정 버튼 글자")
local settingsPanel = root:FindFirstChild("SettingsPanel") :: Frame
check(settingsPanel ~= nil and not settingsPanel.Visible, "설정 창은 처음엔 닫힘")
for _, l in { "auto", "ko", "en", "ja", "zh" } do
check(settingsPanel:FindFirstChild("Lang_" .. l) ~= nil, `설정 창 언어 버튼 {l}`)
end
eq((settingsPanel:FindFirstChild("Lang_ja") :: TextButton).Text, "日本語", "언어 이름은 그 나라 말")
eq((settingsPanel:FindFirstChild("MouseLook") :: TextButton).Text, "On", "마우스 회전 기본 켜짐")
state:SetAttribute("Sfx", false)
eq((settingsPanel:FindFirstChild("Sfx") :: TextButton).Text, "Off", "효과음 끔 표시")
check(not hud.menuOpen(), "창 닫힘")
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.notify("purchased", { item = "Table2" })
local toastText = root.Toasts:FindFirstChild("Toast"):FindFirstChild("Text") :: TextLabel
eq(toastText.Text, "Table 2 bought!", "구매 알림에 업그레이드 이름(내 언어)")
hud.setScale(Hud.scaleFor(Vector2.new(844, 390)))
hud.destroy()
@@ -345,6 +495,18 @@ local okStart, errStart = pcall(Game.start)
check(okStart, `Game.start 오류 없음 ({errStart})`)
task.wait(1)
eq(#workspace.BunsikWorld.Plots:GetChildren(), 6, "시작 후 부지 6칸")
for _, plot in workspace.BunsikWorld.Plots:GetChildren() do
check(plot:GetAttribute("Npc") ~= nil, `{plot.Name}: 빈 부지에 이웃 가게`)
end
task.wait(3)
local npcCustomers = 0
for _, d in workspace.BunsikWorld.Plots:GetDescendants() do
if d.Name == "Customer" then
npcCustomers += 1
end
end
print("이웃 가게 손님 수", npcCustomers)
check(npcCustomers > 0, "이웃 가게에 손님이 옴(실제 Heartbeat)")
print(`통합 테스트: {count - #failures}/{count} 통과`)
if #failures > 0 then