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

@@ -12,8 +12,15 @@
2. 돈이 생기면 아래 가운데 카드의 [사기] 버튼으로 다음 업그레이드를 삽니다. 오른쪽 [📋 업그레이드]에서 전체 목록을 봅니다.
3. 8번째 구매(알바생)부터는 알바생이 카운터(조리대 오른쪽)에 접시를 만들어 둡니다. 카운터 근처에 가면 접시를 자동으로 집습니다.
4. 10번째 구매(실내 분식집 확장)를 하면 건물이 생기고 2단계 업그레이드 10개가 열립니다.
5. 오른쪽 위 언어 버튼으로 한국어·영어를 바꿔 봅니다.
6. 나갔다가 다시 들어와서 돈과 업그레이드가 그대로인지 봅니다.
5. 오른쪽 위 `⚙️ 설정` 버튼을 눌러 봅니다.
- 언어: 자동(계정 언어)·한국어·English·日本語·中文 중에서 고릅니다. 이름판·메뉴판·버튼 글자가 모두 바뀝니다.
- 마우스로 화면 돌리기(PC, 기본 켜짐): 우클릭 없이 마우스만 움직여도 화면이 돕니다. 버튼을 누를 땐 Ctrl을 누르고 있거나, 업그레이드·설정 창을 열면 커서가 나옵니다.
- 효과음 켜기/끄기.
6. 김밥 해금을 사면: 포장마차 왼쪽에 김밥 진열대(김발·김밥 접시)가 반짝이며 생기고, 1초쯤 뒤 오는 손님이 김밥을 주문합니다. 메뉴판에도 김밥이 추가됩니다.
7. 옆 가게: 다른 부지에는 이웃 가게(NPC 사장님이 운영, 크기가 제각각)가 열려 있습니다. 다른 플레이어가 들어오면 그 자리는 그 사람 가게로 바뀝니다.
- 다른 가게 입구(이름판 아래)에서 E(휴대폰은 버튼)를 누르면 손님으로 빈자리에 앉습니다. 음식이 나오면 처음 한 번은 시식 보너스(접시 값)를 내 가게 돈으로 받습니다(1분에 한 번). 점프하면 일어납니다.
- 내 가게에 다른 플레이어가 손님으로 오면 알림이 뜨고, 그 손님 접시는 2배 값을 받습니다.
8. 나갔다가 다시 들어와서 돈·업그레이드·설정이 그대로인지 봅니다.
## 개발자 테스트 버튼(주인 계정에만 보임)

View File

@@ -38,6 +38,14 @@
"CameraMaxZoomDistance": 80
}
},
"SoundService": {
"Sfx": {
"$className": "SoundGroup",
"$properties": {
"Volume": 1
}
}
},
"Workspace": {
"$properties": {
"FilteringEnabled": true

View File

@@ -1,5 +1,5 @@
--!strict
-- 화면 UI: 돈, 다음 업그레이드, 업그레이드 목록, 2배 수익·돈 부스트 버튼, 언어 전환, 안내 문구, 알림.
-- 화면 UI: 돈, 다음 업그레이드, 업그레이드 목록, 2배 수익·돈 부스트 버튼, 설정(언어·마우스 회전·효과음), 안내 문구, 알림.
-- 상태는 `state` 인스턴스(실제 게임에서는 Player)의 속성에서 읽습니다. 서버에서도 만들 수 있어서 원격 테스트로 검사합니다.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
@@ -17,6 +17,7 @@ export type HudHandle = {
refresh: () -> (),
notify: (key: string, args: { [string]: any }?) -> (),
setScale: (number) -> (),
menuOpen: () -> boolean, -- 업그레이드·설정 창이 열려 있으면 true(마우스 커서를 풀어 줌)
destroy: () -> (),
}
@@ -250,15 +251,70 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> ()
devButtons[key] = b
end
-- 오른쪽 위: 언어
local langBtn = button(
-- 오른쪽 위: 설정 버튼과 설정 창(언어, 마우스로 화면 돌리기, 효과음)
local settingsBtn = button(
root,
"Lang",
UDim2.fromOffset(120, 44),
"Settings",
UDim2.fromOffset(130, 44),
UDim2.new(1, -10, 0, 6),
Vector2.new(1, 0),
Color3.fromRGB(80, 140, 230)
)
local settings = frame(
root,
"SettingsPanel",
UDim2.fromOffset(520, 330),
UDim2.fromScale(0.5, 0.48),
Vector2.new(0.5, 0.5),
CREAM
)
settings.Visible = false
corner(settings, 20)
stroke(settings, Color3.fromRGB(80, 140, 230), 4)
local settingsTitle = text(settings, "Title", UDim2.new(1, -120, 0, 44), UDim2.fromOffset(16, 10))
settingsTitle.TextXAlignment = Enum.TextXAlignment.Left
local settingsClose = button(
settings,
"Close",
UDim2.fromOffset(90, 42),
UDim2.new(1, -12, 0, 10),
Vector2.new(1, 0),
Color3.fromRGB(220, 80, 70)
)
local function rowLabel(name: string, y: number): TextLabel
local t = text(settings, name, UDim2.new(1, -32, 0, 30), UDim2.fromOffset(16, y))
t.TextXAlignment = Enum.TextXAlignment.Left
return t
end
local langLabel = rowLabel("LangLabel", 64)
-- 언어 버튼: 자동("") + 네 언어
local langChoices = { "" }
for _, l in Locale.LANGS do
table.insert(langChoices, l)
end
local langButtons: { [string]: TextButton } = {}
for i, l in langChoices do
local b = button(
settings,
"Lang_" .. (if l == "" then "auto" else l),
UDim2.fromOffset(92, 44),
UDim2.fromOffset(16 + (i - 1) * 98, 100),
Vector2.zero,
GRAY
)
langButtons[l] = b
end
local mouseLabel = rowLabel("MouseLabel", 160)
local mouseBtn =
button(settings, "MouseLook", UDim2.fromOffset(110, 40), UDim2.new(1, -16, 0, 156), Vector2.new(1, 0), GRAY)
mouseLabel.Size = UDim2.new(1, -150, 0, 30)
local mouseHint =
text(settings, "MouseHint", UDim2.new(1, -32, 0, 22), UDim2.fromOffset(16, 200), Color3.fromRGB(120, 90, 60))
mouseHint.TextXAlignment = Enum.TextXAlignment.Left
local sfxLabel = rowLabel("SfxLabel", 246)
sfxLabel.Size = UDim2.new(1, -150, 0, 30)
local sfxBtn =
button(settings, "Sfx", UDim2.fromOffset(110, 40), UDim2.new(1, -16, 0, 242), Vector2.new(1, 0), GRAY)
local function lang(): string
return attr(state, "Lang", "ko")
@@ -267,7 +323,11 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> ()
return Locale.t(lang(), key, args)
end
local function pname(p: Economy.Purchase): string
return if lang() == "ko" then p.name else p.nameEn
return Locale.itemName(lang(), p.id)
end
local function toggle(b: TextButton, on: boolean)
b.Text = L(if on then "on" else "off")
b.BackgroundColor3 = if on then GREEN else GRAY
end
local pulse: Tween? = nil
@@ -328,9 +388,23 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> ()
end
listBtn.Text = "📋 " .. L("shop")
langBtn.Text = L("language")
settingsBtn.Text = "⚙️ " .. L("settings")
closeBtn.Text = L("close")
settingsTitle.Text = "⚙️ " .. L("settings")
settingsClose.Text = L("close")
langLabel.Text = "🌐 " .. L("language")
local current = attr(state, "LangSetting", "")
for l, b in langButtons do
b.Text = if l == "" then L("langAuto") else Locale.LANG_NAMES[l]
b.BackgroundColor3 = if l == current then Color3.fromRGB(80, 140, 230) else GRAY
end
mouseLabel.Text = "🖱️ " .. L("mouseLook")
mouseHint.Text = L("mouseHint")
toggle(mouseBtn, attr(state, "MouseLook", true) == true)
sfxLabel.Text = "🔊 " .. L("sfx")
toggle(sfxBtn, attr(state, "Sfx", true) == true)
local double = attr(state, "Double", false)
passBtn.Visible = Products.DOUBLE_MONEY_PASS ~= 0
passBtn.Text = if double then "✅ " .. L("doubleOwned") else "💰x2 " .. L("double")
@@ -378,6 +452,16 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> ()
end
local function notify(key: string, args: { [string]: any }?)
-- 서버는 메뉴·업그레이드를 키(menu, item)로 보내고, 이름은 내 언어로 바꿔 씁니다.
if args then
args = table.clone(args)
if typeof(args.menu) == "string" then
args.menuName = Locale.menuName(lang(), args.menu)
end
if typeof(args.item) == "string" then
args.name = Locale.itemName(lang(), args.item)
end
end
local toast =
frame(toasts, "Toast", UDim2.fromOffset(540, 46), UDim2.new(), Vector2.zero, Color3.fromRGB(45, 45, 60))
corner(toast, 12)
@@ -402,6 +486,7 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> ()
conns,
listBtn.Activated:Connect(function()
panel.Visible = not panel.Visible
settings.Visible = false
end)
)
table.insert(
@@ -412,8 +497,35 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> ()
)
table.insert(
conns,
langBtn.Activated:Connect(function()
send("lang", if lang() == "ko" then "en" else "ko")
settingsBtn.Activated:Connect(function()
settings.Visible = not settings.Visible
panel.Visible = false
end)
)
table.insert(
conns,
settingsClose.Activated:Connect(function()
settings.Visible = false
end)
)
for l, b in langButtons do
table.insert(
conns,
b.Activated:Connect(function()
send("lang", l)
end)
)
end
table.insert(
conns,
mouseBtn.Activated:Connect(function()
send("mouseLook", attr(state, "MouseLook", true) ~= true)
end)
)
table.insert(
conns,
sfxBtn.Activated:Connect(function()
send("sfx", attr(state, "Sfx", true) ~= true)
end)
)
table.insert(
@@ -449,6 +561,9 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> ()
setScale = function(s: number)
scale.Scale = s
end,
menuOpen = function(): boolean
return panel.Visible or settings.Visible
end,
destroy = function()
for _, c in conns do
c:Disconnect()

View File

@@ -1,4 +1,4 @@
-- 클라이언트 진입점: 화면 UI, 내 조리대 버튼, 튜토리얼 화살표.
-- 클라이언트 진입점: 화면 UI, 내 조리대 버튼, 튜토리얼 화살표, 부지 글자·손님 방문 버튼, 마우스 회전, 효과음 설정.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
@@ -6,6 +6,8 @@ local SoundService = game:GetService("SoundService")
local Guide = require(script.Parent.Guide)
local Hud = require(script.Parent.Hud)
local MouseLook = require(script.Parent.MouseLook)
local Plots = require(script.Parent.Plots)
local Stove = require(script.Parent.Stove)
local player = Players.LocalPlayer
@@ -31,10 +33,17 @@ camera:GetPropertyChangedSignal("ViewportSize"):Connect(rescale)
rescale()
-- 구매·확장 효과음은 내 화면에서만 크게(위치 없이) 들립니다.
local Sounds = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("Sounds"))
local sfxGroup = SoundService:WaitForChild("Sfx") :: SoundGroup
local function applySfx()
sfxGroup.Volume = if player:GetAttribute("Sfx") == false then 0 else 1
end
player:GetAttributeChangedSignal("Sfx"):Connect(applySfx)
applySfx()
local function uiSound(id: string, volume: number): Sound
local s = Instance.new("Sound")
s.SoundId = id
s.Volume = volume
s.SoundGroup = sfxGroup
s.Parent = SoundService
return s
end
@@ -42,7 +51,9 @@ local buySound = uiSound(Sounds.BUY, 0.7)
local levelSound = uiSound(Sounds.LEVELUP, 0.8)
local NOTIFY_SOUND: { [string]: Sound } = {
purchased = buySound,
newMenu = buySound,
boostGot = buySound,
guestBonus = buySound,
expanded = levelSound,
}
@@ -61,5 +72,11 @@ local world = workspace:WaitForChild("BunsikWorld")
local plot = world:WaitForChild("Plots"):WaitForChild("Plot" .. tostring(plotIndex))
local stove = plot:WaitForChild("Base"):WaitForChild("Stall"):WaitForChild("Stove") :: BasePart
Stove.attach(stove, player, send)
Plots.start(world:WaitForChild("Plots"), player, player.UserId, send)
Guide.start(player)
MouseLook.start(player, hud.menuOpen)
local UserInputService = game:GetService("UserInputService")
if player:GetAttribute("MouseLook") == true and UserInputService.MouseEnabled and UserInputService.KeyboardEnabled then
hud.notify("mouseHint")
end

View File

@@ -0,0 +1,37 @@
--!strict
-- PC에서 우클릭 없이 마우스만 움직여도 화면이 돌아가게 합니다(마우스를 화면 가운데에 고정).
-- 설정에서 끌 수 있고, Ctrl을 누르고 있거나 업그레이드·설정 창이 열려 있으면 커서를 풀어 버튼을 누를 수 있습니다.
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local MouseLook = {}
-- 지금 마우스를 가운데에 고정할지
function MouseLook.shouldLock(setting: boolean, mouse: boolean, ctrl: boolean, menuOpen: boolean): boolean
return setting and mouse and not ctrl and not menuOpen
end
function MouseLook.start(state: Instance, menuOpen: () -> boolean)
local locked = false
RunService:BindToRenderStep("BunsikMouseLook", Enum.RenderPriority.Camera.Value + 1, function()
local ctrl = UserInputService:IsKeyDown(Enum.KeyCode.LeftControl)
or UserInputService:IsKeyDown(Enum.KeyCode.RightControl)
local want = MouseLook.shouldLock(
state:GetAttribute("MouseLook") == true,
UserInputService.MouseEnabled and UserInputService.KeyboardEnabled,
ctrl,
menuOpen()
)
if want then
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
locked = true
elseif locked then
-- 우리가 고정했던 것만 풉니다(우클릭 회전 등 기본 동작은 건드리지 않음).
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
locked = false
end
end)
end
return MouseLook

View File

@@ -0,0 +1,120 @@
--!strict
-- 부지 이름판·메뉴판 글자를 보는 사람 언어로 쓰고, 다른 가게 입구에 "손님으로 들어가기" 버튼을 붙입니다.
-- 서버는 부지 모델 속성(OwnerId, OwnerName, Npc, Level)만 바꾸고, 글자는 각 클라이언트가 만듭니다.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Shared = ReplicatedStorage:WaitForChild("Shared")
local Economy = require(Shared:WaitForChild("Economy"))
local Locale = require(Shared:WaitForChild("Locale"))
local Plots = {}
local function labels(part: Instance): { TextLabel }
local out = {}
for _, gui in part:GetChildren() do
if gui:IsA("SurfaceGui") then
local t = gui:FindFirstChildOfClass("TextLabel")
if t then
table.insert(out, t)
end
end
end
return out
end
-- 이름판 글자: 플레이어 가게, 이웃 가게, 빈 자리
function Plots.nameText(plot: Instance, lang: string): string
local level = plot:GetAttribute("Level")
local tail = if typeof(level) == "number" and level > 0 then ` ⭐Lv.{level}` else ""
local ownerName = plot:GetAttribute("OwnerName")
if typeof(ownerName) == "string" then
return Locale.t(lang, "plotOwner", { name = ownerName }) .. tail
end
local npc = plot:GetAttribute("Npc")
if typeof(npc) == "number" then
local key = `npcShop{npc}`
return Locale.t(lang, key) .. tail
end
return Locale.t(lang, "plotEmpty")
end
-- 메뉴판 글자: 파는 메뉴와 지금 값
function Plots.menuText(plot: Instance, lang: string): string
local level = plot:GetAttribute("Level")
if typeof(level) ~= "number" then
return ""
end
local stats = Economy.statsAt(level)
local lines = {}
for _, key in Economy.MENU_ORDER do
if table.find(stats.menus, key) then
local price = Locale.t(lang, "money", { money = Locale.number(Economy.dishPrice(key, stats, 1)) })
table.insert(lines, `{Economy.MENUS[key].icon} {Locale.menuName(lang, key)} {price}`)
end
end
return table.concat(lines, "\n")
end
-- 부지 하나에 연결합니다. state는 Lang 속성을 가진 인스턴스(실제로는 Player).
function Plots.attach(plot: Model, state: Instance, myId: number, send: (string, any?) -> ()): () -> ()
local base = plot:WaitForChild("Base")
local nameBoard = base:WaitForChild("NameBoard")
local menuBoard = base:WaitForChild("Stall"):WaitForChild("MenuBoard")
local visitPoint = base:WaitForChild("VisitPoint") :: BasePart
local index = tonumber(string.match(plot.Name, "%d+"))
local prompt = Instance.new("ProximityPrompt")
prompt.Name = "VisitPrompt"
prompt.KeyboardKeyCode = Enum.KeyCode.E
prompt.MaxActivationDistance = 12
prompt.RequiresLineOfSight = false
prompt.HoldDuration = 0
prompt.Parent = visitPoint
local function refresh()
local lang = (state:GetAttribute("Lang") :: string?) or "ko"
local nameText = Plots.nameText(plot, lang)
for _, t in labels(nameBoard) do
t.Text = nameText
end
local menuText = Plots.menuText(plot, lang)
for _, t in labels(menuBoard) do
t.Text = menuText
end
local ownerId = plot:GetAttribute("OwnerId")
local open = ownerId ~= nil or plot:GetAttribute("Npc") ~= nil
prompt.Enabled = open and ownerId ~= myId
prompt.ActionText = Locale.t(lang, "visitAction")
prompt.ObjectText = if ownerId ~= nil then Locale.t(lang, "visitor") else Locale.t(lang, "neighbor")
end
local conns = {
plot.AttributeChanged:Connect(refresh),
state:GetAttributeChangedSignal("Lang"):Connect(refresh),
prompt.Triggered:Connect(function()
send("visit", index)
end),
}
refresh()
return function()
for _, c in conns do
c:Disconnect()
end
prompt:Destroy()
end
end
function Plots.start(folder: Instance, state: Instance, myId: number, send: (string, any?) -> ())
local function add(plot: Instance)
if plot:IsA("Model") then
task.spawn(Plots.attach, plot, state, myId, send)
end
end
folder.ChildAdded:Connect(add)
for _, plot in folder:GetChildren() do
add(plot)
end
end
return Plots

View File

@@ -23,6 +23,7 @@ function Stove.attach(stove: BasePart, state: Instance, send: (string, any?) ->
sizzle.SoundId = Sounds.SIZZLE
sizzle.Volume = 0.6
sizzle.Looped = true
sizzle.SoundGroup = game:GetService("SoundService"):FindFirstChild("Sfx") :: SoundGroup?
sizzle.Parent = stove
local function refresh()
@@ -32,8 +33,7 @@ function Stove.attach(stove: BasePart, state: Instance, send: (string, any?) ->
prompt.ObjectText = Locale.t(lang, "stoveObject")
if typeof(menu) == "string" and Economy.MENUS[menu] then
local m = Economy.MENUS[menu]
local name = if lang == "ko" then m.name else m.nameEn
prompt.ActionText = `{m.icon} ` .. Locale.t(lang, "cookAction", { menu = name })
prompt.ActionText = `{m.icon} ` .. Locale.t(lang, "cookAction", { menu = Locale.menuName(lang, menu) })
prompt.Enabled = true
else
prompt.Enabled = false

View File

@@ -14,7 +14,9 @@ Data.TEMPLATE = {
Bought = 0,
PurchaseIdCache = {} :: { string },
TutorialDone = false,
Lang = "",
Lang = "", -- "" = 계정 언어 자동
MouseLook = true, -- PC: 우클릭 없이 마우스 이동으로 화면 돌리기
Sfx = true, -- 효과음
Served = 0,
Earned = 0,
Version = 1,

View File

@@ -1,5 +1,5 @@
--!strict
-- 서버 시작: 맵, 플레이어 입장·퇴장, 부지 배정, 리모트, 결제를 연결합니다.
-- 서버 시작: 맵, 플레이어 입장·퇴장, 부지 배정, 이웃 가게, 손님 방문, 설정, 리모트, 결제를 연결합니다.
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
@@ -12,6 +12,7 @@ local Locale = require(Shared.Locale)
local Products = require(Shared.Products)
local Data = require(script.Parent.Data)
local Neighbor = require(script.Parent.Neighbor)
local Npc = require(script.Parent.Npc)
local PlotBuilder = require(script.Parent.PlotBuilder)
local PlotController = require(script.Parent.PlotController)
@@ -25,6 +26,11 @@ local slots: { World.Slot } = {}
local slotOwner: { [number]: Player } = {}
local controllers: { [Player]: PlotController.PlotController } = {}
local actionTimes: { [Player]: { number } } = {}
local neighbors: { [number]: Neighbor.Neighbor } = {} -- 플레이어가 없는 부지의 이웃 가게
local guestAt: { [Player]: PlotController.PlotController } = {} -- 손님으로 앉아 있는 가게
local bonusAt: { [Player]: number } = {} -- 다음 시식 보너스를 받을 수 있는 시각
local VISIT_RANGE = 16 -- 입구에서 이만큼 안에 있어야 손님으로 들어갈 수 있습니다
local Remotes = ReplicatedStorage:WaitForChild("Remotes")
local ActionRemote = Remotes:WaitForChild("Action") :: RemoteEvent
@@ -39,6 +45,66 @@ local function freeSlot(): World.Slot?
return nil
end
-- 그 부지에서 열려 있는 가게(플레이어 가게 또는 이웃 가게)
local function controllerAt(index: number): PlotController.PlotController?
local p = slotOwner[index]
if p then
return controllers[p]
end
local n = neighbors[index]
return n and n.controller
end
local function notifyPlayer(player: Player, key: string, args: { [string]: any }?)
NotifyRemote:FireClient(player, key, args)
end
-- 다른 가게에 손님으로 간 플레이어 소식. 처음 먹으면 시식 보너스(접시 값)를 내 가게 돈으로 받습니다(1분에 한 번).
local function onGuestEvent(kind: string, userId: number, info: { [string]: any })
local visitor = Players:GetPlayerByUserId(userId)
if not visitor then
return
end
if kind == "served" then
local own = controllers[visitor]
local now = os.clock()
if own and now >= (bonusAt[visitor] or 0) then
bonusAt[visitor] = now + Economy.GUEST_BONUS_COOLDOWN
own:addMoney(info.price)
notifyPlayer(visitor, "guestBonus", { amount = Locale.number(info.price) })
else
notifyPlayer(visitor, "guestAte")
end
elseif kind == "left" then
guestAt[visitor] = nil
if info.reason == "hungry" then
notifyPlayer(visitor, "guestHungry")
end
end
end
local function openNeighbor(slot: World.Slot)
if not slotOwner[slot.index] and not neighbors[slot.index] then
neighbors[slot.index] = Neighbor.open(slot, os.clock(), onGuestEvent)
end
end
local function closeNeighbor(index: number)
local n = neighbors[index]
neighbors[index] = nil
if n then
Neighbor.close(n)
end
end
-- 언어·마우스 회전·효과음 설정을 Player 속성으로 내보냅니다. Lang은 실제 화면 언어, LangSetting은 저장된 설정("" = 자동).
local function applySettings(player: Player, data: any)
player:SetAttribute("LangSetting", data.Lang)
player:SetAttribute("Lang", Locale.resolve(data.Lang, player.LocaleId))
player:SetAttribute("MouseLook", data.MouseLook ~= false)
player:SetAttribute("Sfx", data.Sfx ~= false)
end
local function placeCharacter(player: Player, slot: World.Slot)
local char = player.Character
if not char then
@@ -70,19 +136,47 @@ local function isDev(player: Player): boolean
return game.CreatorType == Enum.CreatorType.User and player.UserId == game.CreatorId
end
local function makeController(player: Player, slot: World.Slot, data: any, lang: string): PlotController.PlotController
local function makeController(player: Player, slot: World.Slot, data: any): PlotController.PlotController
return PlotController.new(slot, player, {
userId = player.UserId,
displayName = player.DisplayName,
data = data,
now = os.clock(),
lang = lang,
notify = function(key, args)
NotifyRemote:FireClient(player, key, args)
notifyPlayer(player, key, args)
end,
guestEvent = onGuestEvent,
})
end
-- 다른 가게 입구에서 "손님으로 들어가기"를 눌렀을 때
local function visit(player: Player, index: any)
if typeof(index) ~= "number" then
return
end
local own = controllers[player]
local target = controllerAt(index)
if not own or not target or target == own then
return
end
local char = player.Character
local root = char and char:FindFirstChild("HumanoidRootPart") :: BasePart?
if not char or not root or (root.Position - target.slot.refs.visit.Position).Magnitude > VISIT_RANGE then
return
end
local prev = guestAt[player]
if prev then
prev:releaseGuestByUser(player.UserId)
end
if not target:addGuest(player.UserId, char) then
own:notify("visitFull")
return
end
guestAt[player] = target
own:notify("guestSeated")
target:notify("guestArrived", { name = player.DisplayName })
end
local function onPlayerAdded(player: Player)
local profile = Data.load(player)
if not profile then
@@ -97,11 +191,11 @@ local function onPlayerAdded(player: Player)
player:Kick("서버가 꽉 찼어요 / Server is full")
return
end
closeNeighbor(slot.index)
slotOwner[slot.index] = player
local data = profile.Data
local lang = if data.Lang ~= "" then data.Lang else Locale.pick(player.LocaleId)
player:SetAttribute("Lang", lang)
local controller = makeController(player, slot, data, lang)
applySettings(player, data)
local controller = makeController(player, slot, data)
controllers[player] = controller
player:SetAttribute("Dev", isDev(player))
player:SetAttribute("Ready", true)
@@ -125,9 +219,17 @@ local function onPlayerRemoving(player: Player)
local controller = controllers[player]
controllers[player] = nil
actionTimes[player] = nil
bonusAt[player] = nil
local host = guestAt[player]
if host then
host:releaseGuestByUser(player.UserId)
end
guestAt[player] = nil
if controller then
slotOwner[controller.slot.index] = nil
controller:destroy()
-- 빈 부지에는 다시 이웃 가게를 엽니다.
openNeighbor(controller.slot)
end
Data.release(player)
end
@@ -170,11 +272,18 @@ local function onAction(player: Player, kind: any, arg: any)
controller:notify("notEnough", { need = Locale.number(p.cost - controller.shop.money) })
end
end
elseif kind == "visit" then
visit(player, arg)
elseif kind == "lang" then
if typeof(arg) == "string" and table.find(Locale.LANGS, arg) then
-- "" = 계정 언어 자동
if typeof(arg) == "string" and (arg == "" or table.find(Locale.LANGS, arg)) then
controller.data.Lang = arg
player:SetAttribute("Lang", arg)
controller:setLang(arg)
applySettings(player, controller.data)
end
elseif kind == "mouseLook" or kind == "sfx" then
if typeof(arg) == "boolean" then
controller.data[if kind == "sfx" then "Sfx" else "MouseLook"] = arg
applySettings(player, controller.data)
end
elseif kind == "pass" then
if Products.DOUBLE_MONEY_PASS ~= 0 and controller.shop.moneyMult == 1 then
@@ -193,7 +302,7 @@ local function onAction(player: Player, kind: any, arg: any)
data.Earned = 0
local slot = controller.slot
controller:destroy()
local fresh = makeController(player, slot, data, controller.lang)
local fresh = makeController(player, slot, data)
controllers[player] = fresh
placeCharacter(player, slot)
fresh:notify("devResetDone")
@@ -227,6 +336,9 @@ end
function Game.start()
slots = World.build()
task.spawn(Npc.preload)
for _, slot in slots do
openNeighbor(slot)
end
Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(onPlayerRemoving)
@@ -254,6 +366,9 @@ function Game.start()
for _, c in controllers do
c:update(now)
end
for _, n in neighbors do
Neighbor.update(n, now)
end
end)
print(`[Bunsik] server ready, {#Economy.PURCHASES} purchases, {#slots} plots`)
end

View File

@@ -0,0 +1,83 @@
--!strict
-- 이웃 가게(NPC 가게): 플레이어가 없는 부지에 미리 키워 둔 가게를 열어 거리가 비어 보이지 않게 합니다.
-- 사장님 NPC가 알아서 요리하고 서빙합니다. 플레이어는 손님으로 들어가 먹어 볼 수 있습니다(돈 보상은 없음).
-- 진짜 플레이어가 들어오면 그 부지의 이웃 가게는 닫힙니다.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Shop = require(ReplicatedStorage.Shared.Shop)
local Npc = require(script.Parent.Npc)
local PlotBuilder = require(script.Parent.PlotBuilder)
local PlotController = require(script.Parent.PlotController)
local PlotLayout = require(script.Parent.PlotLayout)
local Neighbor = {}
-- 부지 번호별 이웃 가게 크기(산 업그레이드 수). 처음 온 플레이어보다 큰 가게가 많아서 "나도 저렇게 키우고 싶다"를 노립니다.
Neighbor.LEVELS = { 14, 7, 20, 10, 17, 4 }
Neighbor.SERVE_GAP = 1 -- 사장님이 접시를 내려놓는 간격(초)
export type Neighbor = {
controller: PlotController.PlotController,
busyUntil: number,
}
export type Slot = PlotController.Slot
function Neighbor.open(slot: Slot, now: number, guestEvent: PlotController.GuestEvent?): Neighbor
local owner = Instance.new("Folder")
owner.Name = "Neighbor" .. slot.index
local data = {
Money = 0,
Bought = Neighbor.LEVELS[slot.index] or 10,
TutorialDone = true,
Served = 0,
Earned = 0,
}
local controller = PlotController.new(slot, owner, {
userId = -slot.index,
displayName = "",
data = data,
now = now,
npc = slot.index,
guestEvent = guestEvent,
})
-- 포장마차 뒤에 서 있는 사장님
local pos = PlotBuilder.world(slot.cf, PlotLayout.HELPER + Vector3.new(6, 0, 0))
local look = PlotBuilder.world(slot.cf, PlotLayout.PLAYER_SPAWN)
local keeper = Npc.spawn(slot.refs.dynamic, CFrame.new(pos), controller.rng, Color3.fromRGB(240, 110, 40))
keeper.model.Name = "Keeper"
keeper.root.CFrame = Npc.standCFrame(keeper, pos, look)
return { controller = controller, busyUntil = now }
end
-- 0.1초마다 부릅니다. 손님 처리 + 사장님 봇(만들기 → 내려놓기)
function Neighbor.update(n: Neighbor, now: number)
local c = n.controller
c:update(now)
if c.destroyed or now < n.busyUntil then
return
end
local shop = c.shop
if shop.stats.helper then
c:pickup()
elseif not Shop.handFull(shop) and Shop.nextCookMenu(shop) then
c:cook()
n.busyUntil = now + shop.stats.cook
return
end
for id, cust in shop.customers do
if cust.state == "waiting" and table.find(shop.hand, cust.menu) then
c:serve(id)
n.busyUntil = now + Neighbor.SERVE_GAP
return
end
end
end
function Neighbor.close(n: Neighbor)
n.controller:destroy()
end
return Neighbor

View File

@@ -2,16 +2,19 @@
-- 부지 모형: 기본(바닥·포장마차·조리대)과 업그레이드(테이블·간판·화구·실내 확장 등)를 파트로 짓습니다.
local Build = require(script.Parent.Build)
local Food = require(script.Parent.Food)
local PlotLayout = require(script.Parent.PlotLayout)
local Economy = require(game:GetService("ReplicatedStorage").Shared.Economy)
local PlotBuilder = {}
-- 이름판·메뉴판 글자는 보는 사람 언어에 맞춰 클라이언트(PlotSigns)가 씁니다. 서버는 부지 모델 속성만 바꿉니다.
export type BaseRefs = {
stove: BasePart,
counter: BasePart,
nameLabel: TextLabel,
menuLabel: TextLabel,
nameBoard: BasePart,
menuBoard: BasePart,
visit: BasePart, -- "손님으로 들어가기" 버튼이 붙는 입구 지점
upgrades: Model,
dynamic: Folder,
}
@@ -67,12 +70,18 @@ function PlotBuilder.buildBase(plot: Model, cf: CFrame): BaseRefs
color = rgb(255, 245, 225),
material = Enum.Material.Wood,
})
local nameLabel = Build.label(board, Enum.NormalId.Front, "", rgb(160, 50, 30))
-- 앞뒤 둘 다 보이게: 앞면(+Z)은 길에서, 뒷면은 가게 안에서
local backLabel = Build.label(board, Enum.NormalId.Back, "", rgb(160, 50, 30))
nameLabel:GetPropertyChangedSignal("Text"):Connect(function()
backLabel.Text = nameLabel.Text
end)
Build.label(board, Enum.NormalId.Front, "", rgb(160, 50, 30))
Build.label(board, Enum.NormalId.Back, "", rgb(160, 50, 30))
local visit = Build.part(base, {
name = "VisitPoint",
size = Vector3.new(4, 4, 1),
cf = at(0, Y + 3, 35),
transparency = 1,
collide = false,
})
visit.CanQuery = false
visit.CanTouch = false
-- 포장마차: 수레 몸통, 조리대 상판
local stall = Build.model(base, "Stall")
@@ -217,8 +226,9 @@ function PlotBuilder.buildBase(plot: Model, cf: CFrame): BaseRefs
return {
stove = stove,
counter = counter,
nameLabel = nameLabel,
menuLabel = menuLabel,
nameBoard = board,
menuBoard = menuBoard,
visit = visit,
upgrades = upgrades,
dynamic = dynamic,
}
@@ -337,6 +347,120 @@ local function buildIndoor(parent: Instance, cf: CFrame)
end
end
-- 메뉴 해금 업그레이드 id(모형 이름으로 써서 산 직후 반짝이게 합니다)
local function unlockId(menu: string): string
for _, p in Economy.PURCHASES do
if p.effect.menu == menu then
return p.id
end
end
return "Menu_" .. menu
end
-- 진열대 한 칸: 나무 받침, 메뉴별 조리 도구(뒤), 완성 접시(앞), 머리 위 메뉴 그림
local function buildMenuStand(parent: Instance, cf: CFrame, menu: string, slot: number)
local m = Build.model(parent, unlockId(menu))
local z = -31 + (slot - 1) * 3.6
local x = -15.5
local function at(dx: number, y: number, dz: number): CFrame
return cf * CFrame.new(x + dx, Y + y, z + dz)
end
local stand = Build.part(m, {
name = "Stand",
size = Vector3.new(4, 3, 3.2),
cf = at(0, 1.5, 0),
color = rgb(170, 115, 70),
material = Enum.Material.Wood,
})
Build.part(m, {
size = Vector3.new(4.2, 0.2, 3.4),
cf = at(0, 3.1, 0),
color = rgb(240, 235, 225),
material = Enum.Material.Marble,
})
local metal = rgb(195, 195, 200)
if menu == "Gimbap" then
-- 김발 위에 통김밥 한 줄
Build.part(
m,
{ size = Vector3.new(1.6, 0.06, 2.6), cf = at(-1, 3.23, 0), color = rgb(120, 150, 70), collide = false }
)
Build.part(m, {
size = Vector3.new(2.2, 0.7, 0.7),
cf = at(-1, 3.6, 0) * CFrame.Angles(0, math.rad(90), 0),
color = rgb(25, 35, 25),
shape = Enum.PartType.Cylinder,
collide = false,
})
elseif menu == "Sundae" then
-- 찜기와 뚜껑
Build.cylinder(m, at(-1, 3.8, 0), 1.2, 1.8, metal, { material = Enum.Material.Metal, collide = false })
Build.cylinder(
m,
at(-1, 4.5, 0),
0.25,
1.9,
rgb(225, 225, 230),
{ material = Enum.Material.Metal, collide = false }
)
local steam = Instance.new("Smoke")
steam.Color = Color3.new(1, 1, 1)
steam.Opacity = 0.06
steam.RiseVelocity = 2
steam.Size = 1
steam.Parent = stand
elseif menu == "Eomuk" then
-- 국물 통과 꼬치
Build.part(m, {
size = Vector3.new(1.6, 0.9, 2.6),
cf = at(-1, 3.65, 0),
color = metal,
material = Enum.Material.Metal,
collide = false,
})
Build.part(
m,
{ size = Vector3.new(1.4, 0.05, 2.4), cf = at(-1, 4.1, 0), color = rgb(190, 140, 80), collide = false }
)
for k = -1, 1 do
Build.part(m, {
size = Vector3.new(0.08, 1.6, 0.08),
cf = at(-1, 4.6, k * 0.7) * CFrame.Angles(0, 0, math.rad(15)),
color = rgb(190, 150, 100),
collide = false,
})
Build.part(m, {
size = Vector3.new(0.12, 0.5, 0.4),
cf = at(-1, 4.3, k * 0.7),
color = rgb(225, 185, 120),
collide = false,
})
end
elseif menu == "Twigim" then
-- 튀김기(기름)와 튀김 바구니 손잡이
Build.part(m, {
size = Vector3.new(1.6, 1, 2.6),
cf = at(-1, 3.7, 0),
color = metal,
material = Enum.Material.Metal,
collide = false,
})
Build.part(
m,
{ size = Vector3.new(1.4, 0.05, 2.4), cf = at(-1, 4.2, 0), color = rgb(230, 180, 60), collide = false }
)
Build.part(
m,
{ size = Vector3.new(1.2, 0.12, 0.12), cf = at(-0.2, 4.5, 0), color = rgb(40, 40, 40), collide = false }
)
end
local dish = Food.dish(menu, at(0.9, 3.2, 0), m)
dish.Name = "Display"
local icon = Build.billboard(stand, Economy.MENUS[menu].icon, UDim2.fromOffset(56, 56), Vector3.new(0, 4.6, 0))
icon.Name = "MenuIcon"
icon.MaxDistance = 70
end
-- 산 업그레이드에 맞게 Upgrades 모형을 다시 짓습니다.
function PlotBuilder.buildUpgrades(refs: BaseRefs, cf: CFrame, bought: number)
local up = refs.upgrades
@@ -484,16 +608,12 @@ function PlotBuilder.buildUpgrades(refs: BaseRefs, cf: CFrame, bought: number)
end
end
-- 메뉴판 글자
local lines = {}
for _, key in Economy.MENU_ORDER do
if table.find(stats.menus, key) then
local m = Economy.MENUS[key]
table.insert(lines, `{m.icon} {m.name} {Economy.dishPrice(key, stats, 1)}원`)
-- 새 메뉴 진열대(포장마차 왼쪽). 산 메뉴마다 조리 도구와 완성 접시가 생깁니다.
for i, key in Economy.MENU_ORDER do
if i > 1 and table.find(stats.menus, key) then
buildMenuStand(up, cf, key, i - 1)
end
end
refs.menuLabel.Text = table.concat(lines, "\n")
refs.menuLabel.TextScaled = true
end
-- 손님 의자 위(앉는 위치)와 테이블 위 접시 위치(월드 좌표)

View File

@@ -3,6 +3,7 @@
-- 조리대 버튼·자동 서빙·구매를 처리합니다. 실제 Player 대신 Folder를 넣어도 돌아가서 원격 테스트에 씁니다.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SoundService = game:GetService("SoundService")
local TweenService = game:GetService("TweenService")
local Shared = ReplicatedStorage.Shared
@@ -27,12 +28,17 @@ export type Slot = {
refs: PlotBuilder.BaseRefs,
}
-- 손님 한 명의 화면. NPC 손님은 npc, 다른 플레이어 손님은 seat(앉힌 의자)가 있습니다.
type CustomerView = {
npc: Npc.Handle,
npc: Npc.Handle?,
seat: Seat?,
bubble: BillboardGui,
dish: Model?,
}
-- 플레이어 손님 소식: "served"(info.price = 손님이 받을 시식 보너스), "left"(info.reason = ate|hungry|stood|closed)
export type GuestEvent = (kind: string, userId: number, info: { [string]: any }) -> ()
export type Options = {
userId: number,
displayName: string,
@@ -40,7 +46,8 @@ export type Options = {
now: number,
getCharacter: (() -> Model?)?,
notify: ((key: string, args: { [string]: any }?) -> ())?,
lang: string?,
npc: number?, -- 이웃 가게(NPC 가게)면 이름 번호. 이때 OwnerId 대신 Npc 속성을 씁니다.
guestEvent: GuestEvent?,
}
local PlotController = {}
@@ -61,7 +68,6 @@ export type PlotController = typeof(setmetatable(
guide: BasePart,
guideValue: ObjectValue,
rng: Random,
lang: string,
tut: number,
destroyed: boolean,
connections: { RBXScriptConnection },
@@ -75,6 +81,7 @@ local function makeSound(parent: Instance, id: string, volume: number, looped: b
s.Volume = volume
s.Looped = looped == true
s.RollOffMaxDistance = 80
s.SoundGroup = SoundService:FindFirstChild("Sfx") :: SoundGroup?
s.Parent = parent
return s
end
@@ -95,14 +102,18 @@ function PlotController.new(slot: Slot, owner: Instance, opts: Options): PlotCon
guide = Instance.new("Part") :: BasePart,
guideValue = Instance.new("ObjectValue"),
rng = Random.new(opts.userId + slot.index),
lang = opts.lang or "ko",
tut = if data.TutorialDone then 0 else 1,
destroyed = false,
connections = {},
}, PlotController)
slot.model:SetAttribute("OwnerId", opts.userId)
slot.refs.nameLabel.Text = Locale.t("ko", "plotOwner", { name = opts.displayName })
-- 이름판은 클라이언트가 이 속성으로 보는 사람 언어에 맞게 씁니다(PlotSigns).
if opts.npc then
slot.model:SetAttribute("Npc", opts.npc)
else
slot.model:SetAttribute("OwnerId", opts.userId)
slot.model:SetAttribute("OwnerName", opts.displayName)
end
-- 튜토리얼 화살표가 가리킬 보이지 않는 표시
local guide = self.guide
@@ -118,7 +129,9 @@ function PlotController.new(slot: Slot, owner: Instance, opts: Options): PlotCon
self.guideValue.Parent = owner
-- 조리 버튼(ProximityPrompt)은 주인 화면에만 클라이언트가 만듭니다. 서버는 조리대 속성으로 상태만 알려 줍니다.
slot.refs.stove:SetAttribute("OwnerId", opts.userId)
if not opts.npc then
slot.refs.stove:SetAttribute("OwnerId", opts.userId)
end
PlotBuilder.buildUpgrades(slot.refs, slot.cf, self.shop.bought)
self:refreshHelper()
@@ -147,11 +160,6 @@ function PlotController.notify(self: PlotController, key: string, args: { [strin
end
end
function PlotController.setLang(self: PlotController, lang: string)
self.lang = lang
self:refreshPrompt()
end
-- 화면에 필요한 값을 Player 속성으로 내보내고 세이브 데이터에 적습니다.
function PlotController.sync(self: PlotController)
local shop = self.shop
@@ -167,6 +175,8 @@ function PlotController.sync(self: PlotController)
o:SetAttribute("Tut", self.tut)
o:SetAttribute("Plot", self.slot.index)
o:SetAttribute("Carry", #shop.hand)
o:SetAttribute("Earned", self.data.Earned or 0)
self.slot.model:SetAttribute("Level", shop.bought)
end
-- 조리대 속성: CookMenu(만들 메뉴, 없으면 ""), CookTime(누르는 시간), HandFull
@@ -379,13 +389,19 @@ function PlotController.serve(self: PlotController, id: number): number?
if label then
label.Text = "😋"
end
floatText(view.npc.root, "+" .. Locale.number(earn))
-- 동전 소리는 손님 자리에서 납니다(근처 사람도 들림).
local coin = makeSound(view.npc.root, Sounds.COIN, 0.7)
coin:Play()
task.delay(2, function()
coin:Destroy()
end)
local anchor = if view.npc then view.npc.root else view.seat
if anchor then
floatText(anchor, "+" .. Locale.number(earn))
-- 동전 소리는 손님 자리에서 납니다(근처 사람도 들림).
local coin = makeSound(anchor, Sounds.COIN, 0.7)
coin:Play()
task.delay(2, function()
coin:Destroy()
end)
end
end
if c.guest and self.opts.guestEvent then
self.opts.guestEvent("served", c.guest, { price = Economy.dishPrice(c.menu, self.shop.stats, 1) })
end
self.data.Served = (self.data.Served or 0) + 1
self.data.Earned = (self.data.Earned or 0) + earn
@@ -409,18 +425,23 @@ function PlotController.onEvent(self: PlotController, e: Shop.Event)
local icon = Economy.MENUS[e.menu].icon
local bubble = Build.billboard(npc.root, icon, UDim2.fromOffset(70, 70), Vector3.new(0, 4, 0))
bubble.Name = "Order"
self.views[e.id] = { npc = npc, bubble = bubble, dish = nil }
self.views[e.id] = { npc = npc, seat = nil, bubble = bubble, dish = nil }
Npc.walk(npc, path, Economy.WALK_IN)
elseif e.kind == "seated" then
local c = self.shop.customers[e.id]
local v = self.views[e.id]
if c and v then
if c and v and v.npc then
Npc.sit(v.npc, PlotBuilder.seatCFrame(cf, c.seat))
end
elseif e.kind == "leave" then
if e.guest then
self:releaseGuest(e.id, e.guest, if e.served then "ate" else "hungry")
return
end
local v = self.views[e.id]
self.views[e.id] = nil
if v then
if v and v.npc then
local npc = v.npc
if v.dish then
v.dish:Destroy()
end
@@ -430,12 +451,12 @@ function PlotController.onEvent(self: PlotController, e: Shop.Event)
for i = #path, 1, -1 do
table.insert(back, PlotBuilder.world(cf, path[i]))
end
Npc.walk(v.npc, back, Economy.WALK_IN, function()
v.npc.model:Destroy()
Npc.walk(npc, back, Economy.WALK_IN, function()
npc.model:Destroy()
end)
task.delay(Economy.WALK_IN + 1, function()
if v.npc.model.Parent then
v.npc.model:Destroy()
if npc.model.Parent then
npc.model:Destroy()
end
end)
end
@@ -506,16 +527,85 @@ function PlotController.buy(self: PlotController): (boolean, string?)
if self.tut == 3 then
self:setTut(0)
end
local name = if self.lang == "ko" then p.name else p.nameEn
-- 이름은 클라이언트가 자기 언어로 바꿔 씁니다(item, menu 키).
if self.shop.stats.stage > before.stage then
self:notify("expanded")
elseif p.effect.menu then
self:notify("newMenu", { menu = p.effect.menu })
else
self:notify("purchased", { name = name })
self:notify("purchased", { item = p.id })
end
self:sync()
return true, nil
end
-- 다른 플레이어를 빈자리에 앉힙니다. 앉힌 손님(Shop.Customer)을 돌려주고, 자리가 없으면 nil.
function PlotController.addGuest(self: PlotController, userId: number, character: Model): any
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid or humanoid.Health <= 0 then
return nil
end
local c = Shop.addGuest(self.shop, userId)
if not c then
return nil
end
local seat = Instance.new("Seat")
seat.Name = "GuestSeat"
seat.Anchored = true
seat.CanCollide = false
seat.CanTouch = false -- 지나가다 밟아서 앉지 않게
seat.Transparency = 1
seat.Size = Vector3.new(2, 0.4, 2)
seat.CFrame = PlotBuilder.seatCFrame(self.slot.cf, c.seat) * CFrame.new(0, 0.2, 0)
seat.Parent = self.slot.refs.dynamic
local bubble = Build.billboard(seat, Economy.MENUS[c.menu].icon, UDim2.fromOffset(70, 70), Vector3.new(0, 5, 0))
bubble.Name = "Order"
self.views[c.id] = { npc = nil, seat = seat, bubble = bubble, dish = nil }
seat:Sit(humanoid)
-- 점프해서 일어나면 손님 자리를 비웁니다.
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if seat.Occupant == nil and self.views[c.id] and self.shop.customers[c.id] then
self:releaseGuest(c.id, userId, "stood")
end
end)
self:refreshPrompt()
return c
end
-- 플레이어 손님을 내보냅니다(다 먹음, 너무 기다림, 일어남, 가게 닫음).
function PlotController.releaseGuest(self: PlotController, id: number, userId: number, reason: string)
Shop.removeGuest(self.shop, id)
local v = self.views[id]
self.views[id] = nil
if v then
if v.dish then
v.dish:Destroy()
end
v.bubble:Destroy()
if v.seat then
local weld = v.seat:FindFirstChild("SeatWeld")
if weld then
weld:Destroy()
end
v.seat:Destroy()
end
end
self:refreshPrompt()
if self.opts.guestEvent then
self.opts.guestEvent("left", userId, { reason = reason })
end
end
-- 이 가게에 앉아 있는 플레이어 손님을 UserId로 내보냅니다(그 플레이어가 나갔을 때).
function PlotController.releaseGuestByUser(self: PlotController, userId: number)
for id, c in self.shop.customers do
if c.guest == userId then
self:releaseGuest(id, userId, "stood")
return
end
end
end
function PlotController.addMoney(self: PlotController, amount: number)
Shop.addMoney(self.shop, amount)
self:sync()
@@ -528,6 +618,11 @@ end
function PlotController.destroy(self: PlotController)
self.destroyed = true
for id, c in self.shop.customers do
if c.guest then
self:releaseGuest(id, c.guest, "closed")
end
end
for _, c in self.connections do
c:Disconnect()
end
@@ -539,9 +634,9 @@ function PlotController.destroy(self: PlotController)
end
self.slot.refs.dynamic:ClearAllChildren()
self.slot.refs.upgrades:ClearAllChildren()
self.slot.refs.nameLabel.Text = Locale.t("ko", "plotEmpty") .. " / " .. Locale.t("en", "plotEmpty")
self.slot.refs.menuLabel.Text = ""
self.slot.model:SetAttribute("OwnerId", nil)
for _, key in { "OwnerId", "OwnerName", "Npc", "Level" } do
self.slot.model:SetAttribute(key, nil)
end
end
return PlotController

View File

@@ -5,7 +5,6 @@ local Lighting = game:GetService("Lighting")
local Build = require(script.Parent.Build)
local PlotBuilder = require(script.Parent.PlotBuilder)
local Locale = require(game:GetService("ReplicatedStorage").Shared.Locale)
local World = {}
@@ -170,7 +169,6 @@ function World.build(): { Slot }
model.Name = "Plot" .. i
model.Parent = plots
local refs = PlotBuilder.buildBase(model, cf)
refs.nameLabel.Text = Locale.t("ko", "plotEmpty") .. " / " .. Locale.t("en", "plotEmpty")
table.insert(slots, { index = i, cf = cf, model = model, refs = refs })
end
return slots

View File

@@ -15,15 +15,11 @@ export type Effect = {
export type Purchase = {
id: string,
name: string,
nameEn: string,
cost: number,
effect: Effect,
}
export type Menu = {
name: string,
nameEn: string,
price: number,
icon: string,
}
@@ -47,6 +43,9 @@ Economy.WALK_IN = 2.5 -- 손님이 입구에서 자리까지 걷는 시간(초)
Economy.COUNTER_MAX = 3 -- 알바생이 미리 만들어 두는 접시 최대 수
Economy.BOOST_MINUTES = 10 -- 돈 부스트 팩: 현재 1분 매출 x 10분
Economy.BOOST_MIN = 100 -- 돈 부스트 팩 최소 지급액
Economy.GUEST_MULT = 2 -- 다른 플레이어가 손님으로 오면 주인은 접시 값의 2배를 받습니다
Economy.GUEST_WAIT = 60 -- 손님으로 온 플레이어가 음식을 기다리는 최대 시간(초)
Economy.GUEST_BONUS_COOLDOWN = 60 -- 손님으로 먹었을 때 시식 보너스는 1분에 한 번
Economy.START = {
money = 0,
@@ -61,11 +60,11 @@ Economy.START = {
}
Economy.MENUS = {
Tteokbokki = { name = "떡볶이", nameEn = "Tteokbokki", price = 10, icon = "🌶️" },
Gimbap = { name = "김밥", nameEn = "Gimbap", price = 20, icon = "🍙" },
Sundae = { name = "순대", nameEn = "Sundae", price = 35, icon = "🌭" },
Eomuk = { name = "어묵", nameEn = "Fish Cake", price = 50, icon = "🍢" },
Twigim = { name = "튀김", nameEn = "Twigim", price = 70, icon = "🍤" },
Tteokbokki = { price = 10, icon = "🌶️" },
Gimbap = { price = 20, icon = "🍙" },
Sundae = { price = 35, icon = "🌭" },
Eomuk = { price = 50, icon = "🍢" },
Twigim = { price = 70, icon = "🍤" },
} :: { [string]: Menu }
-- 메뉴 표시 순서
@@ -73,39 +72,35 @@ Economy.MENU_ORDER = { "Tteokbokki", "Gimbap", "Sundae", "Eomuk", "Twigim" }
-- 1~10: 첫 10분(1단계 포장마차). 11~20: 2단계 실내 분식집.
Economy.PURCHASES = {
{ id = "Table2", name = "테이블 2", nameEn = "Table 2", cost = 10, effect = { seats = 2 } },
{ id = "UnlockGimbap", name = "김밥 해금", nameEn = "Unlock Gimbap", cost = 40, effect = { menu = "Gimbap" } },
{ id = "Sign1", name = "간판 Lv1", nameEn = "Sign Lv1", cost = 70, effect = { spawn = 5 } },
{ id = "Stove1", name = "화구 Lv1", nameEn = "Stove Lv1", cost = 90, effect = { cook = 1.5 } },
{ id = "Table3", name = "테이블 3", nameEn = "Table 3", cost = 120, effect = { seats = 3 } },
{ id = "UnlockSundae", name = "순대 해금", nameEn = "Unlock Sundae", cost = 160, effect = { menu = "Sundae" } },
{ id = "Sauce1", name = "양념 비법 Lv1", nameEn = "Secret Sauce Lv1", cost = 240, effect = { price = 1.5 } },
{ id = "Helper", name = "알바생 고용", nameEn = "Hire Helper", cost = 360, effect = { helper = true } },
{ id = "Table4", name = "테이블 4", nameEn = "Table 4", cost = 480, effect = { seats = 4, spawn = 4 } },
{ id = "Expand", name = "실내 분식집 확장", nameEn = "Indoor Shop", cost = 600, effect = { stage = 2 } },
{ id = "Table2", cost = 10, effect = { seats = 2 } },
{ id = "UnlockGimbap", cost = 40, effect = { menu = "Gimbap" } },
{ id = "Sign1", cost = 70, effect = { spawn = 5 } },
{ id = "Stove1", cost = 90, effect = { cook = 1.5 } },
{ id = "Table3", cost = 120, effect = { seats = 3 } },
{ id = "UnlockSundae", cost = 160, effect = { menu = "Sundae" } },
{ id = "Sauce1", cost = 240, effect = { price = 1.5 } },
{ id = "Helper", cost = 360, effect = { helper = true } },
{ id = "Table4", cost = 480, effect = { seats = 4, spawn = 4 } },
{ id = "Expand", cost = 600, effect = { stage = 2 } },
{ id = "Tray1", name = "쟁반", nameEn = "Tray", cost = 700, effect = { carry = 2 } },
{ id = "Table5", name = "테이블 5", nameEn = "Table 5", cost = 800, effect = { seats = 5 } },
{ id = "Tray1", cost = 700, effect = { carry = 2 } },
{ id = "Table5", cost = 800, effect = { seats = 5 } },
{
id = "UnlockEomuk",
name = "어묵 해금",
nameEn = "Unlock Fish Cake",
cost = 950,
effect = { menu = "Eomuk" },
},
{ id = "Sign2", name = "간판 Lv2", nameEn = "Sign Lv2", cost = 1150, effect = { spawn = 3 } },
{ id = "Table6", name = "테이블 6", nameEn = "Table 6", cost = 1400, effect = { seats = 6 } },
{ id = "Stove2", name = "화구 Lv2", nameEn = "Stove Lv2", cost = 1700, effect = { cook = 1 } },
{ id = "Sign2", cost = 1150, effect = { spawn = 3 } },
{ id = "Table6", cost = 1400, effect = { seats = 6 } },
{ id = "Stove2", cost = 1700, effect = { cook = 1 } },
{
id = "UnlockTwigim",
name = "튀김 해금",
nameEn = "Unlock Twigim",
cost = 2000,
effect = { menu = "Twigim" },
},
{ id = "Sauce2", name = "양념 비법 Lv2", nameEn = "Secret Sauce Lv2", cost = 2500, effect = { price = 2 } },
{ id = "Tray2", name = "큰 쟁반", nameEn = "Big Tray", cost = 3000, effect = { carry = 3 } },
{ id = "Table8", name = "테이블 7·8", nameEn = "Tables 7-8", cost = 3600, effect = { seats = 8, spawn = 2.5 } },
{ id = "Sauce2", cost = 2500, effect = { price = 2 } },
{ id = "Tray2", cost = 3000, effect = { carry = 3 } },
{ id = "Table8", cost = 3600, effect = { seats = 8, spawn = 2.5 } },
} :: { Purchase }
Economy.MAX_SEATS = 8

View File

@@ -1,5 +1,6 @@
--!strict
-- 화면 글자(한국어·영어). 키가 없으면 키 이름을 그대로 보여 줘서 빠진 번역이 바로 보입니다.
-- 화면 글자(한국어·영어·일본어·중국어 간체). 키가 없으면 영어, 그것도 없으면 키 이름을 그대로 보여 줘서 빠진 번역이 바로 보입니다.
-- 메뉴 이름은 "menu_<메뉴 키>", 업그레이드 이름은 "item_<구매 id>" 키에 있습니다.
local Locale = {}
@@ -17,7 +18,6 @@ local STRINGS: { [string]: { [string]: string } } = {
stage2 = "2단계 · 실내 분식집",
next = "다음",
close = "닫기",
language = "English",
cookAction = "{menu} 만들기",
cookWait = "손님 기다리는 중",
cookHandFull = "손이 꽉 찼어요",
@@ -33,17 +33,66 @@ local STRINGS: { [string]: { [string]: string } } = {
boostDesc = "지금 매출 10분치 {amount}원 즉시 받기",
boostGot = "돈 부스트 {amount}원을 받았어요!",
purchased = "{name} 구매 완료!",
newMenu = "새 메뉴 {menuName}! 이제 손님이 {menuName}도 주문해요",
expanded = "실내 분식집으로 확장했어요! 새 업그레이드가 열렸어요",
plotOwner = "{name}의 분식집",
plotEmpty = "빈 가게 자리",
neighbor = "이웃 가게",
helperNote = "알바생이 요리 중! 카운터에서 접시를 가져가세요",
saveFail = "저장된 데이터를 불러오지 못했어요. 다시 접속해 주세요",
serverFull = "서버가 꽉 찼어요",
visitor = "다른 친구의 가게예요",
devTitle = "개발자 테스트",
devMoney = "+1,000원",
devDouble = "2배 켜기/끄기",
devReset = "처음부터",
devResetDone = "진행을 처음으로 되돌렸어요",
settings = "설정",
language = "언어",
langAuto = "자동",
mouseLook = "마우스로 화면 돌리기",
mouseHint = "Ctrl을 누르고 있으면 마우스 커서가 나와요",
sfx = "효과음",
on = "켜짐",
off = "꺼짐",
visitAction = "손님으로 들어가기",
visitFull = "빈자리가 없어요. 조금 뒤에 다시 와 주세요",
guestSeated = "자리에 앉았어요! 음식을 기다려요 (점프하면 일어나요)",
guestBonus = "냠냠! 시식 보너스 {amount}원을 받았어요",
guestAte = "냠냠! 맛있게 먹었어요",
guestHungry = "음식이 너무 늦게 나와서 일어났어요",
guestArrived = "{name}님이 손님으로 왔어요! 이 손님은 2배 값을 내요",
npcShop1 = "떡순이네 분식",
npcShop2 = "할머니 분식",
npcShop3 = "꼬마 분식",
npcShop4 = "맛나 분식",
npcShop5 = "골목 분식",
npcShop6 = "튀김왕 분식",
menu_Tteokbokki = "떡볶이",
menu_Gimbap = "김밥",
menu_Sundae = "순대",
menu_Eomuk = "어묵",
menu_Twigim = "튀김",
item_Table2 = "테이블 2",
item_UnlockGimbap = "김밥 해금",
item_Sign1 = "간판 Lv1",
item_Stove1 = "화구 Lv1",
item_Table3 = "테이블 3",
item_UnlockSundae = "순대 해금",
item_Sauce1 = "양념 비법 Lv1",
item_Helper = "알바생 고용",
item_Table4 = "테이블 4",
item_Expand = "실내 분식집 확장",
item_Tray1 = "쟁반",
item_Table5 = "테이블 5",
item_UnlockEomuk = "어묵 해금",
item_Sign2 = "간판 Lv2",
item_Table6 = "테이블 6",
item_Stove2 = "화구 Lv2",
item_UnlockTwigim = "튀김 해금",
item_Sauce2 = "양념 비법 Lv2",
item_Tray2 = "큰 쟁반",
item_Table8 = "테이블 7·8",
},
en = {
title = "Bunsik Tycoon",
@@ -58,7 +107,6 @@ local STRINGS: { [string]: { [string]: string } } = {
stage2 = "Stage 2 · Indoor Shop",
next = "Next",
close = "Close",
language = "한국어",
cookAction = "Cook {menu}",
cookWait = "Waiting for customers",
cookHandFull = "Hands are full",
@@ -74,29 +122,268 @@ local STRINGS: { [string]: { [string]: string } } = {
boostDesc = "Get 10 minutes of sales (₩{amount}) now",
boostGot = "Money Boost: +₩{amount}!",
purchased = "{name} bought!",
newMenu = "New menu: {menuName}! Customers will start ordering it",
expanded = "Your shop moved indoors! New upgrades unlocked",
plotOwner = "{name}'s Bunsik Shop",
plotEmpty = "Empty lot",
neighbor = "Neighbor shop",
helperNote = "Your helper is cooking! Grab dishes from the counter",
saveFail = "Couldn't load your save. Please rejoin",
serverFull = "Server is full",
visitor = "This is a friend's shop",
devTitle = "Dev test",
devMoney = "+₩1,000",
devDouble = "Toggle x2",
devReset = "Reset",
devResetDone = "Progress reset",
settings = "Settings",
language = "Language",
langAuto = "Auto",
mouseLook = "Turn camera with mouse",
mouseHint = "Hold Ctrl to show the mouse cursor",
sfx = "Sound effects",
on = "On",
off = "Off",
visitAction = "Eat here as a customer",
visitFull = "No free seats. Come back in a bit",
guestSeated = "You sat down! Wait for your food (jump to stand up)",
guestBonus = "Yum! Tasting bonus +₩{amount}",
guestAte = "Yum! That was tasty",
guestHungry = "The food took too long, so you stood up",
guestArrived = "{name} came in as a customer! They pay double",
npcShop1 = "Tteoksun's Bunsik",
npcShop2 = "Grandma's Bunsik",
npcShop3 = "Little Bunsik",
npcShop4 = "Yummy Bunsik",
npcShop5 = "Alley Bunsik",
npcShop6 = "Twigim King",
menu_Tteokbokki = "Tteokbokki",
menu_Gimbap = "Gimbap",
menu_Sundae = "Sundae",
menu_Eomuk = "Fish Cake",
menu_Twigim = "Twigim",
item_Table2 = "Table 2",
item_UnlockGimbap = "Unlock Gimbap",
item_Sign1 = "Sign Lv1",
item_Stove1 = "Stove Lv1",
item_Table3 = "Table 3",
item_UnlockSundae = "Unlock Sundae",
item_Sauce1 = "Secret Sauce Lv1",
item_Helper = "Hire Helper",
item_Table4 = "Table 4",
item_Expand = "Indoor Shop",
item_Tray1 = "Tray",
item_Table5 = "Table 5",
item_UnlockEomuk = "Unlock Fish Cake",
item_Sign2 = "Sign Lv2",
item_Table6 = "Table 6",
item_Stove2 = "Stove Lv2",
item_UnlockTwigim = "Unlock Twigim",
item_Sauce2 = "Secret Sauce Lv2",
item_Tray2 = "Big Tray",
item_Table8 = "Tables 7-8",
},
ja = {
title = "ブンシク・タイクーン",
money = "₩{money}",
shop = "アップグレード",
buy = "買う",
bought = "完了",
locked = "ロック中",
notEnough = "あと₩{need}必要です",
maxed = "アップグレードを全部買いました!2号店は次のアップデートで登場します",
stage1 = "ステージ1 · 屋台",
stage2 = "ステージ2 · 室内のお店",
next = "次",
close = "閉じる",
cookAction = "{menu}を作る",
cookWait = "お客さんを待っています",
cookHandFull = "手がいっぱいです",
stoveObject = "コンロ",
tut1 = "お客さんが来たよ!光っているコンロに行って、ボタンを長押ししてね",
tut2 = "できた!お皿をお客さんの席まで運んでね",
tut3 = "お金をかせいだよ!下の[買う]ボタンでテーブルを買ってね",
tutDone = "よくできました!お客さんを迎えて、お店を大きくしよう",
double = "収益2倍",
doubleOwned = "収益2倍 適用中",
doubleDesc = "すべての売上がずっと2倍",
boost = "マネーブースト",
boostDesc = "今の売上10分ぶん(₩{amount})をすぐにもらう",
boostGot = "マネーブースト ₩{amount}をもらいました!",
purchased = "{name}を買いました!",
newMenu = "新メニュー「{menuName}」!お客さんが{menuName}も注文するようになるよ",
expanded = "室内のお店に広げました!新しいアップグレードが開きました",
plotOwner = "{name}のブンシク店",
plotEmpty = "空き地",
neighbor = "となりのお店",
helperNote = "アルバイトが料理中!カウンターからお皿を取ってね",
saveFail = "セーブデータを読み込めませんでした。もう一度入ってください",
serverFull = "サーバーが満員です",
visitor = "友だちのお店です",
devTitle = "開発者テスト",
devMoney = "+₩1,000",
devDouble = "2倍 オン/オフ",
devReset = "最初から",
devResetDone = "進行状況を最初に戻しました",
settings = "設定",
language = "言語",
langAuto = "自動",
mouseLook = "マウスでカメラを回す",
mouseHint = "Ctrlを押している間はマウスカーソルが出ます",
sfx = "効果音",
on = "オン",
off = "オフ",
visitAction = "お客さんとして入る",
visitFull = "空いている席がありません。少ししてから来てね",
guestSeated = "席に座ったよ!料理を待とう(ジャンプで立ち上がる)",
guestBonus = "もぐもぐ!試食ボーナス ₩{amount}をもらいました",
guestAte = "もぐもぐ!おいしかった",
guestHungry = "料理が遅すぎたので立ち上がりました",
guestArrived = "{name}さんがお客さんとして来たよ!このお客さんは2倍払います",
npcShop1 = "トッスニ食堂",
npcShop2 = "おばあちゃん食堂",
npcShop3 = "ちびっこ食堂",
npcShop4 = "うまうま食堂",
npcShop5 = "路地裏食堂",
npcShop6 = "天ぷら王食堂",
menu_Tteokbokki = "トッポッキ",
menu_Gimbap = "キンパ",
menu_Sundae = "スンデ",
menu_Eomuk = "おでん",
menu_Twigim = "天ぷら",
item_Table2 = "テーブル2",
item_UnlockGimbap = "キンパ解放",
item_Sign1 = "看板 Lv1",
item_Stove1 = "コンロ Lv1",
item_Table3 = "テーブル3",
item_UnlockSundae = "スンデ解放",
item_Sauce1 = "秘伝のタレ Lv1",
item_Helper = "アルバイトを雇う",
item_Table4 = "テーブル4",
item_Expand = "室内のお店に拡張",
item_Tray1 = "おぼん",
item_Table5 = "テーブル5",
item_UnlockEomuk = "おでん解放",
item_Sign2 = "看板 Lv2",
item_Table6 = "テーブル6",
item_Stove2 = "コンロ Lv2",
item_UnlockTwigim = "天ぷら解放",
item_Sauce2 = "秘伝のタレ Lv2",
item_Tray2 = "大きなおぼん",
item_Table8 = "テーブル7・8",
},
zh = {
title = "韩式小吃大亨",
money = "₩{money}",
shop = "升级",
buy = "购买",
bought = "已完成",
locked = "未解锁",
notEnough = "还差₩{need}",
maxed = "所有升级都买完了!2号店将在下次更新开放",
stage1 = "第1阶段 · 路边摊",
stage2 = "第2阶段 · 室内小吃店",
next = "下一个",
close = "关闭",
cookAction = "制作{menu}",
cookWait = "等待客人中",
cookHandFull = "手里拿满了",
stoveObject = "灶台",
tut1 = "客人来了!走到发光的灶台,按住按钮",
tut2 = "做好了!把盘子端到客人的座位上",
tut3 = "赚到钱了!点下面的[购买]按钮买一张桌子",
tutDone = "做得好!继续招待客人,把店做大吧",
double = "双倍收益",
doubleOwned = "双倍收益生效中",
doubleDesc = "所有销售额永久翻倍",
boost = "金钱加速",
boostDesc = "立即获得当前10分钟的销售额(₩{amount})",
boostGot = "金钱加速:获得₩{amount}!",
purchased = "已购买{name}!",
newMenu = "新菜品:{menuName}!客人会开始点{menuName}了",
expanded = "搬进室内小吃店了!新的升级已解锁",
plotOwner = "{name}的小吃店",
plotEmpty = "空地",
neighbor = "邻居的店",
helperNote = "店员正在做菜!去柜台拿盘子吧",
saveFail = "无法读取存档,请重新加入",
serverFull = "服务器已满",
visitor = "这是朋友的店",
devTitle = "开发者测试",
devMoney = "+₩1,000",
devDouble = "开关双倍",
devReset = "重新开始",
devResetDone = "进度已重置",
settings = "设置",
language = "语言",
langAuto = "自动",
mouseLook = "移动鼠标转动视角",
mouseHint = "按住Ctrl会显示鼠标光标",
sfx = "音效",
on = "开",
off = "关",
visitAction = "作为客人进店",
visitFull = "没有空座位,过一会儿再来吧",
guestSeated = "坐下了!等着上菜吧(跳一下就能站起来)",
guestBonus = "好吃!获得试吃奖励₩{amount}",
guestAte = "好吃!真美味",
guestHungry = "菜上得太慢,你站起来了",
guestArrived = "{name}作为客人来了!这位客人付双倍价钱",
npcShop1 = "小年糕小吃店",
npcShop2 = "奶奶小吃店",
npcShop3 = "小不点小吃店",
npcShop4 = "美味小吃店",
npcShop5 = "胡同小吃店",
npcShop6 = "炸物王小吃店",
menu_Tteokbokki = "炒年糕",
menu_Gimbap = "紫菜包饭",
menu_Sundae = "血肠",
menu_Eomuk = "鱼饼",
menu_Twigim = "炸物",
item_Table2 = "桌子2",
item_UnlockGimbap = "解锁紫菜包饭",
item_Sign1 = "招牌 Lv1",
item_Stove1 = "灶台 Lv1",
item_Table3 = "桌子3",
item_UnlockSundae = "解锁血肠",
item_Sauce1 = "秘制酱料 Lv1",
item_Helper = "雇佣店员",
item_Table4 = "桌子4",
item_Expand = "扩建室内小吃店",
item_Tray1 = "托盘",
item_Table5 = "桌子5",
item_UnlockEomuk = "解锁鱼饼",
item_Sign2 = "招牌 Lv2",
item_Table6 = "桌子6",
item_Stove2 = "灶台 Lv2",
item_UnlockTwigim = "解锁炸物",
item_Sauce2 = "秘制酱料 Lv2",
item_Tray2 = "大托盘",
item_Table8 = "桌子7·8",
},
}
Locale.LANGS = { "ko", "en" }
-- 설정 창에 나오는 순서와 각 언어 이름(언어와 상관없이 그 나라 말로 씁니다)
Locale.LANGS = { "ko", "en", "ja", "zh" }
Locale.LANG_NAMES = { ko = "한국어", en = "English", ja = "日本語", zh = "中文" } :: { [string]: string }
-- 로블록스 계정 언어(LocaleId, 예: "ko-kr", "zh-cn")로 화면 언어를 고릅니다. 지원하지 않는 언어는 영어.
function Locale.pick(localeId: string): string
if string.sub(string.lower(localeId), 1, 2) == "ko" then
return "ko"
local prefix = string.sub(string.lower(localeId), 1, 2)
if STRINGS[prefix] then
return prefix
end
return "en"
end
-- 저장된 설정("" = 자동)과 계정 언어로 실제 화면 언어를 정합니다.
function Locale.resolve(setting: string, localeId: string): string
if STRINGS[setting] then
return setting
end
return Locale.pick(localeId)
end
function Locale.t(lang: string, key: string, args: { [string]: any }?): string
local tbl = STRINGS[lang] or STRINGS.en
local s = tbl[key] or STRINGS.en[key] or key
@@ -109,6 +396,14 @@ function Locale.t(lang: string, key: string, args: { [string]: any }?): string
return s
end
function Locale.menuName(lang: string, menu: string): string
return Locale.t(lang, "menu_" .. menu)
end
function Locale.itemName(lang: string, id: string): string
return Locale.t(lang, "item_" .. id)
end
function Locale.keys(lang: string): { string }
local out = {}
for k in STRINGS[lang] do

View File

@@ -18,13 +18,14 @@ export type Customer = {
seat: number,
menu: string,
state: CustomerState,
untilT: number, -- walking/eating이 끝나는 시각
untilT: number, -- walking/eating이 끝나는 시각. 플레이어 손님은 기다리다 일어나는 시각
guest: number?, -- 다른 플레이어가 손님으로 왔으면 그 UserId
}
export type Event =
{ kind: "spawn", id: number, seat: number, menu: string }
| { kind: "seated", id: number }
| { kind: "leave", id: number, seat: number }
| { kind: "leave", id: number, seat: number, guest: number?, served: boolean }
| { kind: "counter", menu: string }
export type Shop = {
@@ -76,6 +77,14 @@ local function freeSeat(self: Shop): number?
return nil
end
-- 다음 손님이 주문할 메뉴(해금된 메뉴를 돌아가며)
local function nextOrder(self: Shop): string
local menus = self.stats.menus
local menu = menus[(self.menuIndex % #menus) + 1]
self.menuIndex += 1
return menu
end
-- 아직 접시가 정해지지 않은 주문(먼저 온 손님부터). 걷는 중인 손님도 주문은 이미 정해져 있습니다.
function Shop.openOrders(self: Shop): { Customer }
local covered: { [string]: number } = {}
@@ -125,10 +134,14 @@ function Shop.tick(self: Shop, now: number): { Event }
if c.state == "walking" and now >= c.untilT then
c.state = "waiting"
table.insert(events, { kind = "seated", id = id } :: Event)
elseif c.state == "eating" and now >= c.untilT then
elseif c.state ~= "walking" and now >= c.untilT and (c.state == "eating" or c.guest ~= nil) then
-- 다 먹었거나, 플레이어 손님이 너무 오래 기다렸으면 나갑니다.
self.customers[id] = nil
self.seatTaken[c.seat] = nil
table.insert(events, { kind = "leave", id = id, seat = c.seat } :: Event)
table.insert(
events,
{ kind = "leave", id = id, seat = c.seat, guest = c.guest, served = c.state == "eating" } :: Event
)
end
end
@@ -136,9 +149,7 @@ function Shop.tick(self: Shop, now: number): { Event }
local seat = freeSeat(self)
if seat then
self.lastId += 1
local menus = self.stats.menus
local menu = menus[(self.menuIndex % #menus) + 1]
self.menuIndex += 1
local menu = nextOrder(self)
local c: Customer = {
id = self.lastId,
seat = seat,
@@ -201,6 +212,9 @@ function Shop.serve(self: Shop, id: number): number?
c.state = "eating"
c.untilT = self.now + Economy.EAT
local earn = Economy.dishPrice(c.menu, self.stats, self.moneyMult)
if c.guest then
earn *= Economy.GUEST_MULT
end
self.money += earn
self.earned += earn
self.served += 1
@@ -226,9 +240,50 @@ function Shop.buyNext(self: Shop): (Purchase?, string?)
if p.effect.spawn then
self.nextSpawn = math.min(self.nextSpawn, self.now + p.effect.spawn)
end
if p.effect.menu then
-- 새 메뉴를 사면 다음 손님이 바로 그 메뉴를 주문해서, 산 효과가 곧바로 보이게 합니다.
self.menuIndex = #self.stats.menus - 1
self.nextSpawn = math.min(self.nextSpawn, self.now + 1)
end
return p, nil
end
-- 다른 플레이어가 손님으로 와서 빈자리에 앉습니다(걷지 않고 바로 주문). 자리가 없거나 이미 앉아 있으면 nil.
function Shop.addGuest(self: Shop, userId: number): Customer?
for _, c in self.customers do
if c.guest == userId then
return nil
end
end
local seat = freeSeat(self)
if not seat then
return nil
end
self.lastId += 1
local c: Customer = {
id = self.lastId,
seat = seat,
menu = nextOrder(self),
state = "waiting",
untilT = self.now + Economy.GUEST_WAIT,
guest = userId,
}
self.customers[c.id] = c
self.seatTaken[seat] = c.id
return c
end
-- 플레이어 손님이 먼저 일어났을 때(점프, 퇴장). 이벤트 없이 자리만 비웁니다.
function Shop.removeGuest(self: Shop, id: number): Customer?
local c = self.customers[id]
if not c or not c.guest then
return nil
end
self.customers[id] = nil
self.seatTaken[c.seat] = nil
return c
end
function Shop.addMoney(self: Shop, amount: number)
self.money += amount
end

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

View File

@@ -6,7 +6,7 @@ local Shop = require("../src/shared/Shop")
local Sim = {}
function Sim.run(mult: number, limit: number): { { t: number, id: string, name: string, cost: number } }
function Sim.run(mult: number, limit: number): { { t: number, id: string, cost: number } }
local shop = Shop.new(0, 0, 0)
shop.moneyMult = mult
local dt = 0.1
@@ -51,7 +51,7 @@ function Sim.run(mult: number, limit: number): { { t: number, id: string, name:
local p = Shop.nextPurchase(shop)
if p and shop.money >= p.cost then
Shop.buyNext(shop)
table.insert(log, { t = t, id = p.id, name = p.name, cost = p.cost })
table.insert(log, { t = t, id = p.id, cost = p.cost })
end
t += dt
end