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:
@@ -1,5 +1,6 @@
|
||||
--!strict
|
||||
-- 분식집 첫 10분 경제 수치. ECONOMY.md 표, tools/economy_sim.py 와 같은 숫자여야 합니다.
|
||||
-- 분식집 경제 수치. ECONOMY.md 표와 같은 숫자여야 합니다.
|
||||
-- 숫자를 바꾸면 `lune run tools/sim.luau` 로 구매 시점을 다시 확인합니다.
|
||||
|
||||
export type Effect = {
|
||||
seats: number?, -- 테이블 수
|
||||
@@ -8,19 +9,44 @@ export type Effect = {
|
||||
price: number?, -- 가격 배율
|
||||
helper: boolean?, -- 알바생(조리 자동)
|
||||
menu: string?, -- 해금할 메뉴
|
||||
carry: number?, -- 한 번에 드는 접시 수
|
||||
stage: number?, -- 가게 단계(2 = 실내 분식집)
|
||||
}
|
||||
|
||||
export type Purchase = {
|
||||
id: string,
|
||||
name: string,
|
||||
nameEn: string,
|
||||
cost: number,
|
||||
effect: Effect,
|
||||
}
|
||||
|
||||
export type Menu = {
|
||||
name: string,
|
||||
nameEn: string,
|
||||
price: number,
|
||||
icon: string,
|
||||
}
|
||||
|
||||
export type Stats = {
|
||||
seats: number,
|
||||
spawn: number,
|
||||
cook: number,
|
||||
price: number,
|
||||
helper: boolean,
|
||||
menus: { string },
|
||||
carry: number,
|
||||
stage: number,
|
||||
}
|
||||
|
||||
local Economy = {}
|
||||
|
||||
Economy.WALK = 5 -- 조리대 -> 테이블 -> 조리대 왕복(초)
|
||||
Economy.WALK = 5 -- 조리대 -> 테이블 -> 조리대 왕복(초, 시뮬레이터 가정)
|
||||
Economy.EAT = 6 -- 식사 시간(초)
|
||||
Economy.WALK_IN = 2.5 -- 손님이 입구에서 자리까지 걷는 시간(초)
|
||||
Economy.COUNTER_MAX = 3 -- 알바생이 미리 만들어 두는 접시 최대 수
|
||||
Economy.BOOST_MINUTES = 10 -- 돈 부스트 팩: 현재 1분 매출 x 10분
|
||||
Economy.BOOST_MIN = 100 -- 돈 부스트 팩 최소 지급액
|
||||
|
||||
Economy.START = {
|
||||
money = 0,
|
||||
@@ -30,25 +56,123 @@ Economy.START = {
|
||||
price = 1,
|
||||
helper = false,
|
||||
menus = { "Tteokbokki" },
|
||||
carry = 1,
|
||||
stage = 1,
|
||||
}
|
||||
|
||||
Economy.MENUS = {
|
||||
Tteokbokki = { name = "떡볶이", price = 10 },
|
||||
Gimbap = { name = "김밥", price = 20 },
|
||||
Sundae = { name = "순대", price = 35 },
|
||||
}
|
||||
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 = "🍤" },
|
||||
} :: { [string]: Menu }
|
||||
|
||||
-- 메뉴 표시 순서
|
||||
Economy.MENU_ORDER = { "Tteokbokki", "Gimbap", "Sundae", "Eomuk", "Twigim" }
|
||||
|
||||
-- 1~10: 첫 10분(1단계 포장마차). 11~20: 2단계 실내 분식집.
|
||||
Economy.PURCHASES = {
|
||||
{ id = "Table2", name = "테이블 2", cost = 10, effect = { seats = 2 } },
|
||||
{ id = "UnlockGimbap", name = "김밥 해금", cost = 40, effect = { menu = "Gimbap" } },
|
||||
{ id = "Sign1", name = "간판 Lv1", cost = 70, effect = { spawn = 5 } },
|
||||
{ id = "Stove1", name = "화구 Lv1", cost = 90, effect = { cook = 1.5 } },
|
||||
{ id = "Table3", name = "테이블 3", cost = 120, effect = { seats = 3 } },
|
||||
{ id = "UnlockSundae", name = "순대 해금", cost = 160, effect = { menu = "Sundae" } },
|
||||
{ id = "Sauce1", name = "양념 비법 Lv1", cost = 240, effect = { price = 1.5 } },
|
||||
{ id = "Helper", name = "알바생 고용", cost = 360, effect = { helper = true } },
|
||||
{ id = "Table4", name = "테이블 4", cost = 480, effect = { seats = 4, spawn = 4 } },
|
||||
{ id = "Expand", name = "실내 분식집 확장", cost = 600, effect = {} },
|
||||
{ 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 = "Tray1", name = "쟁반", nameEn = "Tray", cost = 700, effect = { carry = 2 } },
|
||||
{ id = "Table5", name = "테이블 5", nameEn = "Table 5", 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 = "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 } },
|
||||
} :: { Purchase }
|
||||
|
||||
Economy.MAX_SEATS = 8
|
||||
|
||||
-- 앞에서부터 `bought`개를 산 상태의 능력치
|
||||
function Economy.statsAt(bought: number): Stats
|
||||
local s = Economy.START
|
||||
local stats: Stats = {
|
||||
seats = s.seats,
|
||||
spawn = s.spawn,
|
||||
cook = s.cook,
|
||||
price = s.price,
|
||||
helper = s.helper,
|
||||
menus = table.clone(s.menus),
|
||||
carry = s.carry,
|
||||
stage = s.stage,
|
||||
}
|
||||
for i = 1, math.min(bought, #Economy.PURCHASES) do
|
||||
local e = Economy.PURCHASES[i].effect
|
||||
if e.seats then
|
||||
stats.seats = e.seats
|
||||
end
|
||||
if e.spawn then
|
||||
stats.spawn = e.spawn
|
||||
end
|
||||
if e.cook then
|
||||
stats.cook = e.cook
|
||||
end
|
||||
if e.price then
|
||||
stats.price = e.price
|
||||
end
|
||||
if e.helper then
|
||||
stats.helper = true
|
||||
end
|
||||
if e.menu then
|
||||
table.insert(stats.menus, e.menu)
|
||||
end
|
||||
if e.carry then
|
||||
stats.carry = e.carry
|
||||
end
|
||||
if e.stage then
|
||||
stats.stage = e.stage
|
||||
end
|
||||
end
|
||||
return stats
|
||||
end
|
||||
|
||||
-- 한 접시 값(정수). moneyMult는 2배 수익 게임패스(1 또는 2)
|
||||
function Economy.dishPrice(menu: string, stats: Stats, moneyMult: number): number
|
||||
return math.floor(Economy.MENUS[menu].price * stats.price) * moneyMult
|
||||
end
|
||||
|
||||
-- 현재 능력치로 1분에 버는 돈(대략). 돈 부스트 팩 지급액 계산용
|
||||
function Economy.incomePerMinute(stats: Stats): number
|
||||
local total = 0
|
||||
for _, m in stats.menus do
|
||||
total += Economy.dishPrice(m, stats, 1)
|
||||
end
|
||||
local avg = total / #stats.menus
|
||||
-- 손님 수는 간격과 자리 회전(식사+이동+조리) 중 느린 쪽으로 제한
|
||||
local perSeat = 60 / (Economy.EAT + Economy.WALK_IN + Economy.WALK + stats.cook)
|
||||
local customers = math.min(60 / stats.spawn, perSeat * stats.seats)
|
||||
return math.floor(customers * avg)
|
||||
end
|
||||
|
||||
function Economy.boostAmount(stats: Stats): number
|
||||
return math.max(Economy.BOOST_MIN, Economy.incomePerMinute(stats) * Economy.BOOST_MINUTES)
|
||||
end
|
||||
|
||||
return Economy
|
||||
|
||||
127
bunsik-tycoon/src/shared/Locale.luau
Normal file
127
bunsik-tycoon/src/shared/Locale.luau
Normal file
@@ -0,0 +1,127 @@
|
||||
--!strict
|
||||
-- 화면 글자(한국어·영어). 키가 없으면 키 이름을 그대로 보여 줘서 빠진 번역이 바로 보입니다.
|
||||
|
||||
local Locale = {}
|
||||
|
||||
local STRINGS: { [string]: { [string]: string } } = {
|
||||
ko = {
|
||||
title = "분식집 타이쿤",
|
||||
money = "{money}원",
|
||||
shop = "업그레이드",
|
||||
buy = "사기",
|
||||
bought = "완료",
|
||||
locked = "잠김",
|
||||
notEnough = "돈이 {need}원 더 필요해요",
|
||||
maxed = "모든 업그레이드를 샀어요! 2호점은 다음 업데이트에서 열려요",
|
||||
stage1 = "1단계 · 포장마차",
|
||||
stage2 = "2단계 · 실내 분식집",
|
||||
next = "다음",
|
||||
close = "닫기",
|
||||
language = "English",
|
||||
cookAction = "{menu} 만들기",
|
||||
cookWait = "손님 기다리는 중",
|
||||
cookHandFull = "손이 꽉 찼어요",
|
||||
stoveObject = "조리대",
|
||||
tut1 = "손님이 왔어요! 빛나는 조리대로 가서 버튼을 꾹 누르세요",
|
||||
tut2 = "다 만들었어요! 접시를 손님 자리로 가져가세요",
|
||||
tut3 = "돈을 벌었어요! 아래 [사기] 버튼으로 테이블을 사세요",
|
||||
tutDone = "잘했어요! 계속 손님을 받고 가게를 키워 보세요",
|
||||
double = "2배 수익",
|
||||
doubleOwned = "2배 수익 적용 중",
|
||||
doubleDesc = "모든 판매 금액이 영원히 2배",
|
||||
boost = "돈 부스트",
|
||||
boostDesc = "지금 매출 10분치 {amount}원 즉시 받기",
|
||||
boostGot = "돈 부스트 {amount}원을 받았어요!",
|
||||
purchased = "{name} 구매 완료!",
|
||||
expanded = "실내 분식집으로 확장했어요! 새 업그레이드가 열렸어요",
|
||||
plotOwner = "{name}의 분식집",
|
||||
plotEmpty = "빈 가게 자리",
|
||||
helperNote = "알바생이 요리 중! 카운터에서 접시를 가져가세요",
|
||||
saveFail = "저장된 데이터를 불러오지 못했어요. 다시 접속해 주세요",
|
||||
visitor = "다른 친구의 가게예요",
|
||||
devTitle = "개발자 테스트",
|
||||
devMoney = "+1,000원",
|
||||
devDouble = "2배 켜기/끄기",
|
||||
devReset = "처음부터",
|
||||
devResetDone = "진행을 처음으로 되돌렸어요",
|
||||
},
|
||||
en = {
|
||||
title = "Bunsik Tycoon",
|
||||
money = "₩{money}",
|
||||
shop = "Upgrades",
|
||||
buy = "Buy",
|
||||
bought = "Done",
|
||||
locked = "Locked",
|
||||
notEnough = "Need ₩{need} more",
|
||||
maxed = "All upgrades bought! Shop #2 opens in the next update",
|
||||
stage1 = "Stage 1 · Street Stall",
|
||||
stage2 = "Stage 2 · Indoor Shop",
|
||||
next = "Next",
|
||||
close = "Close",
|
||||
language = "한국어",
|
||||
cookAction = "Cook {menu}",
|
||||
cookWait = "Waiting for customers",
|
||||
cookHandFull = "Hands are full",
|
||||
stoveObject = "Stove",
|
||||
tut1 = "A customer is here! Go to the glowing stove and hold the button",
|
||||
tut2 = "Done! Bring the dish to the customer's seat",
|
||||
tut3 = "You earned money! Tap [Buy] at the bottom to get a table",
|
||||
tutDone = "Great job! Keep serving and grow your shop",
|
||||
double = "Double Money",
|
||||
doubleOwned = "Double Money active",
|
||||
doubleDesc = "All sales are doubled forever",
|
||||
boost = "Money Boost",
|
||||
boostDesc = "Get 10 minutes of sales (₩{amount}) now",
|
||||
boostGot = "Money Boost: +₩{amount}!",
|
||||
purchased = "{name} bought!",
|
||||
expanded = "Your shop moved indoors! New upgrades unlocked",
|
||||
plotOwner = "{name}'s Bunsik Shop",
|
||||
plotEmpty = "Empty lot",
|
||||
helperNote = "Your helper is cooking! Grab dishes from the counter",
|
||||
saveFail = "Couldn't load your save. Please rejoin",
|
||||
visitor = "This is a friend's shop",
|
||||
devTitle = "Dev test",
|
||||
devMoney = "+₩1,000",
|
||||
devDouble = "Toggle x2",
|
||||
devReset = "Reset",
|
||||
devResetDone = "Progress reset",
|
||||
},
|
||||
}
|
||||
|
||||
Locale.LANGS = { "ko", "en" }
|
||||
|
||||
function Locale.pick(localeId: string): string
|
||||
if string.sub(string.lower(localeId), 1, 2) == "ko" then
|
||||
return "ko"
|
||||
end
|
||||
return "en"
|
||||
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
|
||||
if args then
|
||||
s = string.gsub(s, "{(%w+)}", function(k)
|
||||
local v = args[k]
|
||||
return if v ~= nil then tostring(v) else "{" .. k .. "}"
|
||||
end)
|
||||
end
|
||||
return s
|
||||
end
|
||||
|
||||
function Locale.keys(lang: string): { string }
|
||||
local out = {}
|
||||
for k in STRINGS[lang] do
|
||||
table.insert(out, k)
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
-- 숫자에 천 단위 쉼표
|
||||
function Locale.number(n: number): string
|
||||
local s = tostring(math.floor(n))
|
||||
local out = string.reverse((string.gsub(string.reverse(s), "(%d%d%d)", "%1,")))
|
||||
return (string.gsub(out, "^(-?),", "%1"))
|
||||
end
|
||||
|
||||
return Locale
|
||||
7
bunsik-tycoon/src/shared/Products.luau
Normal file
7
bunsik-tycoon/src/shared/Products.luau
Normal file
@@ -0,0 +1,7 @@
|
||||
--!strict
|
||||
-- 게임패스·개발자 상품 ID. tools/cloud.py products 로 만들고 여기에 적습니다. 0이면 버튼을 숨깁니다.
|
||||
|
||||
return {
|
||||
DOUBLE_MONEY_PASS = 2026574937,
|
||||
MONEY_BOOST_PRODUCT = 3717970589,
|
||||
}
|
||||
236
bunsik-tycoon/src/shared/Shop.luau
Normal file
236
bunsik-tycoon/src/shared/Shop.luau
Normal 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
|
||||
8
bunsik-tycoon/src/shared/Sounds.luau
Normal file
8
bunsik-tycoon/src/shared/Sounds.luau
Normal file
@@ -0,0 +1,8 @@
|
||||
--!strict
|
||||
-- 효과음 ID. ProSoundEffects는 로블록스가 라이선스한 공개 효과음이라 누구나 쓸 수 있습니다.
|
||||
|
||||
return {
|
||||
SIZZLE = "rbxassetid://9114542867", -- Fry Or Sizzle 1 (SFX), ProSoundEffects
|
||||
COIN = "rbxasset://sounds/electronicpingshort.wav", -- 로블록스 기본 내장음
|
||||
BUY = "rbxasset://sounds/electronicpingshort.wav",
|
||||
}
|
||||
Reference in New Issue
Block a user