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

@@ -0,0 +1,236 @@
--!strict
-- 가게 한 곳의 규칙(손님, 주문, 조리, 서빙, 돈, 구매)을 담은 순수 로직입니다.
-- 로블록스 API를 쓰지 않아서 lune 단위 테스트와 시뮬레이터에서 그대로 돌립니다.
-- 화면(NPC, 접시 모형, 효과)은 서버의 PlotController가 이벤트를 받아 그립니다.
-- 로블록스에서는 script.Parent, lune(테스트)에서는 파일 경로로 불러옵니다.
local Economy: typeof(require(script.Parent.Economy)) = if script
then require(script.Parent.Economy)
else (require :: any)("./Economy")
type Stats = typeof(Economy.statsAt(0))
type Purchase = typeof(Economy.PURCHASES[1])
export type CustomerState = "walking" | "waiting" | "eating"
export type Customer = {
id: number,
seat: number,
menu: string,
state: CustomerState,
untilT: number, -- walking/eating이 끝나는 시각
}
export type Event =
{ kind: "spawn", id: number, seat: number, menu: string }
| { kind: "seated", id: number }
| { kind: "leave", id: number, seat: number }
| { kind: "counter", menu: string }
export type Shop = {
money: number,
bought: number,
moneyMult: number,
stats: Stats,
customers: { [number]: Customer },
seatTaken: { [number]: number },
hand: { string },
counter: { string },
now: number,
nextSpawn: number,
nextHelper: number,
menuIndex: number,
lastId: number,
served: number,
earned: number,
}
local Shop = {}
function Shop.new(money: number, bought: number, now: number): Shop
return {
money = money,
bought = math.clamp(bought, 0, #Economy.PURCHASES),
moneyMult = 1,
stats = Economy.statsAt(bought),
customers = {},
seatTaken = {},
hand = {},
counter = {},
now = now,
nextSpawn = now, -- 접속하자마자 첫 손님
nextHelper = now,
menuIndex = 0,
lastId = 0,
served = 0,
earned = 0,
}
end
local function freeSeat(self: Shop): number?
for seat = 1, self.stats.seats do
if self.seatTaken[seat] == nil then
return seat
end
end
return nil
end
-- 아직 접시가 정해지지 않은 주문(먼저 온 손님부터). 걷는 중인 손님도 주문은 이미 정해져 있습니다.
function Shop.openOrders(self: Shop): { Customer }
local covered: { [string]: number } = {}
for _, m in self.hand do
covered[m] = (covered[m] or 0) + 1
end
for _, m in self.counter do
covered[m] = (covered[m] or 0) + 1
end
local list = {}
for _, c in self.customers do
if c.state ~= "eating" then
table.insert(list, c)
end
end
table.sort(list, function(a, b)
return a.id < b.id
end)
local open = {}
for _, c in list do
local n = covered[c.menu] or 0
if n > 0 then
covered[c.menu] = n - 1
else
table.insert(open, c)
end
end
return open
end
-- 지금 조리대에서 만들 메뉴(없으면 nil)
function Shop.nextCookMenu(self: Shop): string?
local open = Shop.openOrders(self)
return if open[1] then open[1].menu else nil
end
function Shop.handFull(self: Shop): boolean
return #self.hand >= self.stats.carry
end
-- 시간을 now까지 진행합니다. 일어난 일을 이벤트로 돌려줍니다.
function Shop.tick(self: Shop, now: number): { Event }
self.now = now
local events: { Event } = {}
for id, c in self.customers do
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
self.customers[id] = nil
self.seatTaken[c.seat] = nil
table.insert(events, { kind = "leave", id = id, seat = c.seat } :: Event)
end
end
if now >= self.nextSpawn then
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 c: Customer = {
id = self.lastId,
seat = seat,
menu = menu,
state = "walking",
untilT = now + Economy.WALK_IN,
}
self.customers[c.id] = c
self.seatTaken[seat] = c.id
table.insert(events, { kind = "spawn", id = c.id, seat = seat, menu = menu } :: Event)
end
self.nextSpawn = now + self.stats.spawn
end
if self.stats.helper and now >= self.nextHelper then
local menu = Shop.nextCookMenu(self)
if menu and #self.counter < Economy.COUNTER_MAX then
table.insert(self.counter, menu)
table.insert(events, { kind = "counter", menu = menu } :: Event)
self.nextHelper = now + self.stats.cook
end
end
return events
end
-- 플레이어가 조리대에서 다 만들었을 때. 만든 메뉴를 돌려줍니다.
function Shop.cook(self: Shop): string?
if Shop.handFull(self) then
return nil
end
local menu = Shop.nextCookMenu(self)
if menu then
table.insert(self.hand, menu)
end
return menu
end
-- 알바생이 만들어 둔 접시를 손에 듭니다. 든 접시 수를 돌려줍니다.
function Shop.pickup(self: Shop): number
local n = 0
while #self.counter > 0 and not Shop.handFull(self) do
table.insert(self.hand, table.remove(self.counter, 1) :: string)
n += 1
end
return n
end
-- 손에 든 접시를 손님에게 줍니다. 번 돈을 돌려줍니다(못 주면 nil).
function Shop.serve(self: Shop, id: number): number?
local c = self.customers[id]
if not c or c.state ~= "waiting" then
return nil
end
local idx = table.find(self.hand, c.menu)
if not idx then
return nil
end
table.remove(self.hand, idx)
c.state = "eating"
c.untilT = self.now + Economy.EAT
local earn = Economy.dishPrice(c.menu, self.stats, self.moneyMult)
self.money += earn
self.earned += earn
self.served += 1
return earn
end
function Shop.nextPurchase(self: Shop): Purchase?
return Economy.PURCHASES[self.bought + 1]
end
-- 다음 업그레이드를 삽니다. 성공하면 산 항목을 돌려줍니다.
function Shop.buyNext(self: Shop): (Purchase?, string?)
local p = Shop.nextPurchase(self)
if not p then
return nil, "max"
end
if self.money < p.cost then
return nil, "money"
end
self.money -= p.cost
self.bought += 1
self.stats = Economy.statsAt(self.bought)
if p.effect.spawn then
self.nextSpawn = math.min(self.nextSpawn, self.now + p.effect.spawn)
end
return p, nil
end
function Shop.addMoney(self: Shop, amount: number)
self.money += amount
end
return Shop