feat(bunsik): 가게 꾸미기 3D 투명 미리보기·회전, 테이블·의자 따로 배치, 아래 [사기] 막대 → 튜토리얼, 손님 느리게, 2배 돈 "이미 보유" 수정
- 아래 추천 [사기] 막대를 없애고 튜토리얼 말풍선을 아래 가운데로. 튜토리얼 3단계는 [가게 꾸미기]에서 의자 놓기
- 상점에서 꾸미기 탭을 빼고 따로 [가게 꾸미기] 버튼·창. 카드를 고르면 캐릭터 앞에 투명 미리보기가 붙어 다니고
[돌리기](R)·[놓기](F)로 그 자리에 놓음(놓을 때 돈). [옮기기]로 놓은 물건·조리대를 들어서 옮김
- 의자를 테이블에서 떼어 {x,z,f,r}로 저장(등받이로 방향 보임). 의자는 보는 쪽 앞에 테이블이 있어야 하고,
테이블을 옮기거나 돌리면 그 테이블을 보는 의자도 같이. 예전 {t,s} 저장은 자동 변환. 새 요청 buyAt
- 테이블은 의자 없이 따로 판매(20 + 15×테이블 수²)
- 손님 간격 10초 → 20초(손님 속도 갈래도 2배), 대신 음식값 2배로 1분 매출 유지. 실내 11분·2층 50분(봇)
- 2배 돈: 게임 주인은 게임패스를 자동 보유하는데 [처음부터]·2배 끄기 뒤 버튼이 결제 창을 띄워 "이미 보유"가 나옴.
누르면 먼저 보유를 확인해 바로 켜고, [처음부터]도 2배를 유지
- 검사 위치 0.5칸 자리 길 검사 오류 수정(touches가 막힌 칸 안쪽을 보던 문제)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -71,16 +71,16 @@ Economy.KICK_SHIELD = 180 -- 손님을 쫓겨난 가게는 3분 동안 다시
|
||||
Economy.TRANSFER_WALK = 7 -- 옆 가게에서 우리 가게 자리까지 걸어오는 시간(초)
|
||||
|
||||
Economy.START_MONEY = 0
|
||||
Economy.START_SPAWN = 10 -- 처음 손님 간격(예전 6초에서 느리게)
|
||||
Economy.START_SPAWN = 20 -- 처음 손님 간격(6초 → 10초 → 20초로 느리게)
|
||||
Economy.START_COOK = 2.5
|
||||
Economy.START_MENUS = { "Tteokbokki" }
|
||||
|
||||
Economy.MENUS = {
|
||||
Tteokbokki = { price = 15, icon = "🌶️" },
|
||||
Gimbap = { price = 25, icon = "🍙" },
|
||||
Sundae = { price = 40, icon = "🌭" },
|
||||
Eomuk = { price = 50, icon = "🍢" },
|
||||
Twigim = { price = 70, icon = "🍤" },
|
||||
Tteokbokki = { price = 30, icon = "🌶️" },
|
||||
Gimbap = { price = 50, icon = "🍙" },
|
||||
Sundae = { price = 80, icon = "🌭" },
|
||||
Eomuk = { price = 100, icon = "🍢" },
|
||||
Twigim = { price = 140, icon = "🍤" },
|
||||
} :: { [string]: Menu }
|
||||
|
||||
-- 메뉴 표시 순서
|
||||
@@ -118,13 +118,13 @@ Economy.TRACKS = {
|
||||
{
|
||||
id = "Speed", -- 손님 오는 속도(간판·전단지): 손님 간격(초)
|
||||
levels = {
|
||||
{ cost = 60, stage = 1, value = 8.5 },
|
||||
{ cost = 150, stage = 1, value = 7 },
|
||||
{ cost = 320, stage = 1, value = 6 },
|
||||
{ cost = 1000, stage = 2, value = 5 },
|
||||
{ cost = 2000, stage = 2, value = 4.2 },
|
||||
{ cost = 6500, stage = 3, value = 3.5 },
|
||||
{ cost = 11000, stage = 3, value = 3 },
|
||||
{ cost = 60, stage = 1, value = 17 },
|
||||
{ cost = 150, stage = 1, value = 14 },
|
||||
{ cost = 320, stage = 1, value = 12 },
|
||||
{ cost = 1000, stage = 2, value = 10 },
|
||||
{ cost = 2000, stage = 2, value = 8.5 },
|
||||
{ cost = 6500, stage = 3, value = 7 },
|
||||
{ cost = 11000, stage = 3, value = 6 },
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -177,8 +177,8 @@ function Economy.role(id: string): Role?
|
||||
return roleById[id]
|
||||
end
|
||||
|
||||
-- 자리(손님 의자). 테이블 하나에 의자 4개까지. 건물 단계별로 놓을 수 있는 수가 다릅니다.
|
||||
Economy.CHAIRS_PER_TABLE = 4
|
||||
-- 자리(손님 의자). 테이블과 의자는 따로 사서 놓습니다. 건물 단계별로 놓을 수 있는 수가 다릅니다.
|
||||
Economy.CHAIRS_PER_TABLE = 4 -- 추천·봇 가정: 테이블 하나에 의자 4개쯤(앞·뒤·왼쪽·오른쪽)
|
||||
Economy.SEAT_CAP = { 6, 14, 24 } -- 단계별 최대 의자 수
|
||||
Economy.TABLE_CAP = { 3, 6, 12 } -- 단계별 최대 테이블 수
|
||||
|
||||
@@ -191,9 +191,9 @@ function Economy.seatCost(s: number): number
|
||||
return math.floor(raw / 5 + 0.5) * 5
|
||||
end
|
||||
|
||||
-- 테이블(의자 1개 포함)은 자리 값에 테이블 값을 더합니다.
|
||||
function Economy.tableCost(tables: number, seats: number): number
|
||||
return Economy.seatCost(seats + 1) + 15 * tables * tables
|
||||
-- 테이블만(의자는 따로). tables = 지금 놓은 테이블 수
|
||||
function Economy.tableCost(tables: number): number
|
||||
return 20 + 15 * tables * tables
|
||||
end
|
||||
|
||||
-- 꾸미기 소품(손님 수와 상관없는 장식). 크기는 Floor.FOOTPRINT
|
||||
@@ -397,8 +397,9 @@ function Economy.offers(levels: Levels, tables: number, seats: number): { Offer
|
||||
if seats < tables * Economy.CHAIRS_PER_TABLE then
|
||||
table.insert(out, { kind = "seat", id = "Seat", cost = Economy.seatCost(seats + 1) })
|
||||
end
|
||||
if tables < Economy.tableCap(stats.stage) then
|
||||
table.insert(out, { kind = "table", id = "Table", cost = Economy.tableCost(tables, seats) })
|
||||
-- 테이블은 지금 테이블들이 거의 찼을 때만 추천합니다.
|
||||
if tables < Economy.tableCap(stats.stage) and seats >= tables * Economy.CHAIRS_PER_TABLE - 1 then
|
||||
table.insert(out, { kind = "table", id = "Table", cost = Economy.tableCost(tables) })
|
||||
end
|
||||
end
|
||||
table.sort(out, function(a, b)
|
||||
|
||||
@@ -6,14 +6,16 @@
|
||||
-- 저장 모양(Layout):
|
||||
-- stove = { x, z, r } 조리대(포장마차 수레 + 카운터). r은 90도 단위 회전(0~3), 앞(+Z)으로 손님을 봄
|
||||
-- tables = { { x, z, f } } f = 층(1 또는 2)
|
||||
-- chairs = { { t, s } } t = 테이블 번호, s = 테이블의 어느 쪽(1 앞 +Z, 2 오른쪽 +X, 3 뒤 -Z, 4 왼쪽 -X)
|
||||
-- chairs = { { x, z, f, r } } r = 의자가 보는 쪽(0 +Z, 1 +X, 2 -Z, 3 -X)
|
||||
-- decor = { { k, x, z, f, r } } k = 소품 종류(Economy.DECOR)
|
||||
-- 의자는 테이블에 붙어 있어서 테이블을 옮기면 같이 옮겨집니다. 손님 자리 번호 = chairs 순서.
|
||||
-- 의자는 테이블과 따로 놓지만, 보는 쪽 바로 앞에 테이블이 있어야 합니다(손님이 그 테이블에서 먹음).
|
||||
-- 테이블을 옮기거나 돌리면 그 테이블을 보는 의자도 같이 옮겨집니다. 손님 자리 번호 = chairs 순서.
|
||||
-- 예전 저장 모양 chairs = { { t, s } }(테이블 번호, 테이블의 쪽 1 앞 +Z, 2 +X, 3 -Z, 4 -X)은 clean이 바꿔 줍니다.
|
||||
|
||||
export type Pos = { x: number, z: number, f: number }
|
||||
export type Stove = { x: number, z: number, r: number }
|
||||
export type Table = { x: number, z: number, f: number }
|
||||
export type Chair = { t: number, s: number }
|
||||
export type Chair = { x: number, z: number, f: number, r: number }
|
||||
export type Decor = { k: string, x: number, z: number, f: number, r: number }
|
||||
|
||||
export type Layout = {
|
||||
@@ -46,7 +48,8 @@ Floor.STAIR_HALF_W = 2.5
|
||||
|
||||
Floor.TABLE_SIZE = 5
|
||||
Floor.CHAIR_SIZE = 2
|
||||
Floor.CHAIR_OFFSET = 3.5 -- 테이블 가운데에서 의자 가운데까지
|
||||
Floor.CHAIR_OFFSET = 3.5 -- 테이블 가운데에서 의자 가운데까지(자동 배치)
|
||||
Floor.CHAIR_REACH = 2 -- 의자 가운데에서 보는 쪽으로 이만큼 앞 점이 테이블 위여야 함
|
||||
|
||||
-- 소품 크기(가로 x, 세로 z, 회전 0 기준). walk = 밟고 지나갈 수 있음(러그)
|
||||
Floor.FOOTPRINT = {
|
||||
@@ -73,11 +76,18 @@ local SIDES = {
|
||||
}
|
||||
Floor.SIDES = SIDES
|
||||
|
||||
-- 테이블 쪽 s(1 앞 +Z, 2 +X, 3 -Z, 4 -X)에 테이블을 보고 붙는 의자
|
||||
function Floor.chairAt(t: Table, s: number): Chair
|
||||
local d = SIDES[s]
|
||||
return { x = t.x + d.x * Floor.CHAIR_OFFSET, z = t.z + d.z * Floor.CHAIR_OFFSET, f = t.f, r = (s + 1) % 4 }
|
||||
end
|
||||
|
||||
function Floor.default(): Layout
|
||||
local t = { x = -9, z = -10, f = 1 }
|
||||
return {
|
||||
stove = { x = 0, z = -26, r = 0 },
|
||||
tables = { { x = -9, z = -10, f = 1 } },
|
||||
chairs = { { t = 1, s = 1 } },
|
||||
tables = { t },
|
||||
chairs = { Floor.chairAt(t, 1) },
|
||||
decor = {},
|
||||
}
|
||||
end
|
||||
@@ -101,17 +111,39 @@ function Floor.stovePoint(stove: Stove, p: { x: number, z: number }): (number, n
|
||||
return stove.x + dx, stove.z + dz
|
||||
end
|
||||
|
||||
-- 의자가 보는 쪽(단위 벡터)
|
||||
function Floor.facing(r: number): (number, number)
|
||||
return Floor.rotate(0, 1, r)
|
||||
end
|
||||
|
||||
function Floor.chairPos(layout: Layout, i: number): Pos?
|
||||
local c = layout.chairs[i]
|
||||
local t = c and layout.tables[c.t]
|
||||
if not t then
|
||||
if not c then
|
||||
return nil
|
||||
end
|
||||
local d = SIDES[c.s]
|
||||
if not d then
|
||||
return { x = c.x, z = c.z, f = c.f }
|
||||
end
|
||||
|
||||
-- 의자가 보는 테이블 번호(앞에 테이블이 없으면 nil). 여럿이면 가장 가까운 것
|
||||
function Floor.chairTable(layout: Layout, i: number): number?
|
||||
local c = layout.chairs[i]
|
||||
if not c then
|
||||
return nil
|
||||
end
|
||||
return { x = t.x + d.x * Floor.CHAIR_OFFSET, z = t.z + d.z * Floor.CHAIR_OFFSET, f = t.f }
|
||||
local dx, dz = Floor.facing(c.r)
|
||||
local px, pz = c.x + dx * Floor.CHAIR_REACH, c.z + dz * Floor.CHAIR_REACH
|
||||
local half = Floor.TABLE_SIZE / 2 + 0.25
|
||||
local best: number? = nil
|
||||
local bestD = math.huge
|
||||
for ti, t in layout.tables do
|
||||
if t.f == c.f and math.abs(px - t.x) <= half and math.abs(pz - t.z) <= half then
|
||||
local d = (px - t.x) ^ 2 + (pz - t.z) ^ 2
|
||||
if d < bestD then
|
||||
best, bestD = ti, d
|
||||
end
|
||||
end
|
||||
end
|
||||
return best
|
||||
end
|
||||
|
||||
local function rectAt(x: number, z: number, w: number, d: number, r: number, f: number): Rect
|
||||
@@ -161,16 +193,13 @@ function Floor.pieces(layout: Layout): { Piece }
|
||||
walk = false,
|
||||
})
|
||||
end
|
||||
for i in layout.chairs do
|
||||
local p = Floor.chairPos(layout, i)
|
||||
if p then
|
||||
table.insert(out, {
|
||||
kind = "chair",
|
||||
index = i,
|
||||
rect = rectAt(p.x, p.z, Floor.CHAIR_SIZE, Floor.CHAIR_SIZE, 0, p.f),
|
||||
walk = false,
|
||||
})
|
||||
end
|
||||
for i, c in layout.chairs do
|
||||
table.insert(out, {
|
||||
kind = "chair",
|
||||
index = i,
|
||||
rect = rectAt(c.x, c.z, Floor.CHAIR_SIZE, Floor.CHAIR_SIZE, 0, c.f),
|
||||
walk = false,
|
||||
})
|
||||
end
|
||||
for i, d in layout.decor do
|
||||
local f = Floor.FOOTPRINT[d.k]
|
||||
@@ -263,8 +292,9 @@ end
|
||||
|
||||
-- 사각형 바로 둘레 칸 중 닿는 칸이 있는지
|
||||
local function touches(seen: { [number]: boolean }, r: Rect): boolean
|
||||
local i0, j0 = cellOf(r.x0 - 0.5, r.z0 - 0.5)
|
||||
local i1, j1 = cellOf(r.x1 + 0.5 - 1e-6, r.z1 + 0.5 - 1e-6)
|
||||
-- 0.5칸 자리도 막힌 칸 바로 바깥 줄을 보도록 한 칸씩 넓힙니다.
|
||||
local i0, j0 = cellOf(r.x0 - 1 + 1e-6, r.z0 - 1 + 1e-6)
|
||||
local i1, j1 = cellOf(r.x1 + 1 - 1e-6, r.z1 + 1 - 1e-6)
|
||||
for i = i0, i1 do
|
||||
for j = j0, j1 do
|
||||
if seen[key(i, j)] then
|
||||
@@ -280,7 +310,8 @@ local function inBounds(r: Rect): boolean
|
||||
end
|
||||
|
||||
-- 배치 전체를 검사합니다. 문제가 없으면 nil, 있으면 이유를 돌려줍니다.
|
||||
-- "bounds"(밖), "overlap"(겹침), "reserved"(문·계단), "floor"(2층 없음), "blocked"(길이 막힘), "chair"(잘못된 의자)
|
||||
-- "bounds"(밖), "overlap"(겹침), "reserved"(문·계단), "floor"(2층 없음), "blocked"(길이 막힘),
|
||||
-- "chair"(의자 앞에 테이블이 없음)
|
||||
function Floor.validate(layout: Layout, stage: number): string?
|
||||
local pieces = Floor.pieces(layout)
|
||||
if #pieces ~= 3 + #layout.tables + #layout.chairs + #layout.decor then
|
||||
@@ -303,14 +334,11 @@ function Floor.validate(layout: Layout, stage: number): string?
|
||||
if layout.stove.r % 1 ~= 0 then
|
||||
return "bounds"
|
||||
end
|
||||
-- 같은 테이블의 같은 쪽에 의자 둘 금지
|
||||
local used: { [string]: boolean } = {}
|
||||
for _, c in layout.chairs do
|
||||
local k = `{c.t}:{c.s}`
|
||||
if used[k] then
|
||||
-- 의자는 테이블을 봐야 함
|
||||
for i in layout.chairs do
|
||||
if not Floor.chairTable(layout, i) then
|
||||
return "chair"
|
||||
end
|
||||
used[k] = true
|
||||
end
|
||||
for a = 1, #pieces do
|
||||
local pa = pieces[a]
|
||||
@@ -318,7 +346,6 @@ function Floor.validate(layout: Layout, stage: number): string?
|
||||
for b = a + 1, #pieces do
|
||||
local pb = pieces[b]
|
||||
if not pb.walk then
|
||||
-- 의자는 자기 테이블과 붙어 있어도 됩니다(실제로 겹치지 않음).
|
||||
if overlap(pa.rect, pb.rect) then
|
||||
return "overlap"
|
||||
end
|
||||
@@ -404,10 +431,20 @@ function Floor.clean(raw: any): Layout
|
||||
layout.chairs = {}
|
||||
for _, c in raw.chairs do
|
||||
if typeof(c) == "table" then
|
||||
local t = math.floor(num(c.t, 0))
|
||||
local s = math.floor(num(c.s, 0))
|
||||
if layout.tables[t] and SIDES[s] then
|
||||
table.insert(layout.chairs, { t = t, s = s })
|
||||
if typeof(c.x) == "number" and typeof(c.z) == "number" then
|
||||
table.insert(layout.chairs, {
|
||||
x = num(c.x, 0),
|
||||
z = num(c.z, 0),
|
||||
f = if c.f == 2 then 2 else 1,
|
||||
r = math.floor(num(c.r, 0)) % 4,
|
||||
})
|
||||
else
|
||||
-- 예전 모양(테이블 번호 + 쪽)
|
||||
local t = math.floor(num(c.t, 0))
|
||||
local s = math.floor(num(c.s, 0))
|
||||
if layout.tables[t] and SIDES[s] then
|
||||
table.insert(layout.chairs, Floor.chairAt(layout.tables[t], s))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -430,7 +467,7 @@ function Floor.clean(raw: any): Layout
|
||||
layout.tables = { { x = -9, z = -10, f = 1 } }
|
||||
end
|
||||
if #layout.chairs == 0 then
|
||||
layout.chairs = { { t = 1, s = 1 } }
|
||||
layout.chairs = { Floor.chairAt(layout.tables[1], 1) }
|
||||
end
|
||||
return layout
|
||||
end
|
||||
@@ -467,7 +504,22 @@ local function candidates(f: number): { { x: number, z: number, f: number } }
|
||||
return out
|
||||
end
|
||||
|
||||
-- 새 테이블(+의자 1개)을 놓을 곳을 찾아 layout에 넣습니다. 놓으면 테이블 번호를 돌려줍니다.
|
||||
-- 테이블별로 그 테이블을 보는 의자 번호들
|
||||
local function chairsByTable(layout: Layout): { [number]: { number } }
|
||||
local out: { [number]: { number } } = {}
|
||||
for ci in layout.chairs do
|
||||
local ti = Floor.chairTable(layout, ci)
|
||||
if ti then
|
||||
out[ti] = out[ti] or {}
|
||||
table.insert(out[ti], ci)
|
||||
end
|
||||
end
|
||||
return out
|
||||
end
|
||||
Floor.chairsByTable = chairsByTable
|
||||
|
||||
-- 새 테이블을 놓을 곳을 찾아 layout에 넣습니다(의자는 따로). 의자 하나는 붙일 수 있는 곳만 고릅니다.
|
||||
-- 놓으면 테이블 번호를 돌려줍니다.
|
||||
function Floor.addTable(layout: Layout, stage: number): number?
|
||||
local floors: { number } = { 1 }
|
||||
if stage >= 3 then
|
||||
@@ -485,14 +537,16 @@ function Floor.addTable(layout: Layout, stage: number): number?
|
||||
for _, f in floors do
|
||||
for _, c in candidates(f) do
|
||||
local test = Floor.clone(layout)
|
||||
table.insert(test.tables, { x = c.x, z = c.z, f = c.f })
|
||||
local ti = #test.tables
|
||||
for _, s in { 1, 3, 2, 4 } do
|
||||
test.chairs[#layout.chairs + 1] = { t = ti, s = s }
|
||||
if Floor.validate(test, stage) == nil then
|
||||
layout.tables = test.tables
|
||||
layout.chairs = test.chairs
|
||||
return ti
|
||||
local t = { x = c.x, z = c.z, f = c.f }
|
||||
table.insert(test.tables, t)
|
||||
if Floor.validate(test, stage) == nil then
|
||||
for _, s in { 1, 3, 2, 4 } do
|
||||
local withChair = Floor.clone(test)
|
||||
table.insert(withChair.chairs, Floor.chairAt(t, s))
|
||||
if Floor.validate(withChair, stage) == nil then
|
||||
layout.tables = test.tables
|
||||
return #layout.tables
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -500,21 +554,27 @@ function Floor.addTable(layout: Layout, stage: number): number?
|
||||
return nil
|
||||
end
|
||||
|
||||
-- 의자 1개를 빈 쪽에 붙입니다(table을 주면 그 테이블 먼저). 놓은 의자 번호를 돌려줍니다.
|
||||
-- 의자 1개를 테이블 빈 쪽에 붙입니다(prefer 테이블 먼저, 그다음 의자가 적은 테이블부터). 놓은 의자 번호를 돌려줍니다.
|
||||
function Floor.addChair(layout: Layout, stage: number, prefer: number?): number?
|
||||
local by = chairsByTable(layout)
|
||||
local order = {}
|
||||
if prefer and layout.tables[prefer] then
|
||||
table.insert(order, prefer)
|
||||
end
|
||||
for i in layout.tables do
|
||||
if i ~= prefer then
|
||||
table.insert(order, i)
|
||||
end
|
||||
table.insert(order, i)
|
||||
end
|
||||
table.sort(order, function(a, b)
|
||||
if a == prefer or b == prefer then
|
||||
return a == prefer and b ~= prefer
|
||||
end
|
||||
local na, nb = by[a] and #by[a] or 0, by[b] and #by[b] or 0
|
||||
if na ~= nb then
|
||||
return na < nb
|
||||
end
|
||||
return a < b
|
||||
end)
|
||||
for _, ti in order do
|
||||
for _, s in { 1, 3, 2, 4 } do
|
||||
local test = Floor.clone(layout)
|
||||
table.insert(test.chairs, { t = ti, s = s })
|
||||
table.insert(test.chairs, Floor.chairAt(layout.tables[ti], s))
|
||||
if Floor.validate(test, stage) == nil then
|
||||
layout.chairs = test.chairs
|
||||
return #layout.chairs
|
||||
@@ -554,46 +614,56 @@ function Floor.addDecor(layout: Layout, stage: number, kind: string): number?
|
||||
return nil
|
||||
end
|
||||
|
||||
local function snap(v: number): number
|
||||
return math.floor(v * 2 + 0.5) / 2 -- 0.5 stud 단위
|
||||
end
|
||||
|
||||
-- 물건 하나를 옮긴 새 배치를 만들어 검사합니다. 문제없으면 (새 배치, nil), 아니면 (nil, 이유)
|
||||
-- kind: "stove" | "table" | "decor" | "chair"(chair는 s만 바꿈: x 자리에 쪽 번호)
|
||||
-- kind: "stove" | "table" | "decor" | "chair". r은 90도 단위 회전.
|
||||
-- 테이블은 둥글어서 r은 그 테이블을 보는 의자들을 테이블 둘레로 돌리는 횟수입니다(지금 자리 기준).
|
||||
export type Move = { kind: string, i: number, x: number, z: number, f: number?, r: number? }
|
||||
|
||||
function Floor.move(layout: Layout, stage: number, m: Move): (Layout?, string?)
|
||||
-- 검사 없이 옮긴 배치(꾸미기 화면 미리보기용). 없는 물건이면 nil
|
||||
function Floor.applyMove(layout: Layout, m: Move): Layout?
|
||||
local test = Floor.clone(layout)
|
||||
local x = math.floor(m.x * 2 + 0.5) / 2 -- 0.5 stud 단위
|
||||
local z = math.floor(m.z * 2 + 0.5) / 2
|
||||
local x = snap(m.x)
|
||||
local z = snap(m.z)
|
||||
local f = if m.f == 2 then 2 else 1
|
||||
local r = math.floor(m.r or 0) % 4
|
||||
if m.kind == "stove" then
|
||||
test.stove = { x = x, z = z, r = r }
|
||||
elseif m.kind == "table" then
|
||||
local t = test.tables[m.i]
|
||||
local t = layout.tables[m.i]
|
||||
if not t then
|
||||
return nil, "none"
|
||||
return nil
|
||||
end
|
||||
local attached: { number } = chairsByTable(layout)[m.i] or {}
|
||||
for _, ci in attached do
|
||||
local c = layout.chairs[ci]
|
||||
local ox, oz = Floor.rotate(c.x - t.x, c.z - t.z, r)
|
||||
test.chairs[ci] = { x = x + ox, z = z + oz, f = f, r = (c.r + r) % 4 }
|
||||
end
|
||||
test.tables[m.i] = { x = x, z = z, f = f }
|
||||
elseif m.kind == "decor" then
|
||||
local d = test.decor[m.i]
|
||||
if not d then
|
||||
return nil, "none"
|
||||
return nil
|
||||
end
|
||||
test.decor[m.i] = { k = d.k, x = x, z = z, f = f, r = r }
|
||||
elseif m.kind == "chair" then
|
||||
local c = test.chairs[m.i]
|
||||
local s = math.floor(m.x)
|
||||
if not c or not SIDES[s] then
|
||||
return nil, "none"
|
||||
if not test.chairs[m.i] then
|
||||
return nil
|
||||
end
|
||||
-- 다른 테이블로 옮길 수도 있음(z 자리에 테이블 번호, 0이면 그대로)
|
||||
local t = math.floor(m.z)
|
||||
if t ~= 0 then
|
||||
if not test.tables[t] then
|
||||
return nil, "none"
|
||||
end
|
||||
c.t = t
|
||||
end
|
||||
c.s = s
|
||||
test.chairs[m.i] = { x = x, z = z, f = f, r = r }
|
||||
else
|
||||
return nil
|
||||
end
|
||||
return test
|
||||
end
|
||||
|
||||
function Floor.move(layout: Layout, stage: number, m: Move): (Layout?, string?)
|
||||
local test = Floor.applyMove(layout, m)
|
||||
if not test then
|
||||
return nil, "none"
|
||||
end
|
||||
local why = Floor.validate(test, stage)
|
||||
@@ -603,13 +673,51 @@ function Floor.move(layout: Layout, stage: number, m: Move): (Layout?, string?)
|
||||
return test, nil
|
||||
end
|
||||
|
||||
-- 새 물건 하나를 정한 자리에 놓은 새 배치를 만들어 검사합니다. 문제없으면 (새 배치, nil, 번호), 아니면 (nil, 이유)
|
||||
-- kind: "table" | "chair" | "decor"(k = 소품 종류)
|
||||
export type Add = { kind: string, k: string?, x: number, z: number, f: number?, r: number? }
|
||||
|
||||
-- 검사 없이 새 물건을 넣은 배치와 그 번호(꾸미기 화면 미리보기용). 잘못된 종류면 nil
|
||||
function Floor.applyAdd(layout: Layout, a: Add): (Layout?, number?)
|
||||
local test = Floor.clone(layout)
|
||||
local x = snap(a.x)
|
||||
local z = snap(a.z)
|
||||
local f = if a.f == 2 then 2 else 1
|
||||
local r = math.floor(a.r or 0) % 4
|
||||
local index: number
|
||||
if a.kind == "table" then
|
||||
table.insert(test.tables, { x = x, z = z, f = f })
|
||||
index = #test.tables
|
||||
elseif a.kind == "chair" then
|
||||
table.insert(test.chairs, { x = x, z = z, f = f, r = r })
|
||||
index = #test.chairs
|
||||
elseif a.kind == "decor" and a.k and Floor.FOOTPRINT[a.k] and a.k ~= "Stove" then
|
||||
table.insert(test.decor, { k = a.k, x = x, z = z, f = f, r = r })
|
||||
index = #test.decor
|
||||
else
|
||||
return nil, nil
|
||||
end
|
||||
return test, index
|
||||
end
|
||||
|
||||
function Floor.add(layout: Layout, stage: number, a: Add): (Layout?, string?, number?)
|
||||
local test, index = Floor.applyAdd(layout, a)
|
||||
if not test then
|
||||
return nil, "none", nil
|
||||
end
|
||||
local why = Floor.validate(test, stage)
|
||||
if why then
|
||||
return nil, why, nil
|
||||
end
|
||||
return test, nil, index
|
||||
end
|
||||
|
||||
-- 2층 건물로 올릴 때처럼 배치가 더 이상 맞지 않으면, 문제 있는 물건을 빈 곳으로 옮깁니다.
|
||||
-- 테이블은 자기를 보는 의자와 같이 옮기고, 남은 의자는 빈 테이블 쪽에 다시 붙입니다(자리 수는 그대로).
|
||||
function Floor.repair(layout: Layout, stage: number): Layout
|
||||
if Floor.validate(layout, stage) == nil then
|
||||
return layout
|
||||
end
|
||||
local fixed = Floor.clone(layout)
|
||||
-- 조리대가 문제면 기본 자리로
|
||||
local reserved = Floor.reserved(stage)
|
||||
local function bad(rect: Rect): boolean
|
||||
if not inBounds(rect) or (rect.f == 2 and stage < 3) then
|
||||
@@ -622,71 +730,95 @@ function Floor.repair(layout: Layout, stage: number): Layout
|
||||
end
|
||||
return false
|
||||
end
|
||||
local fixed = Floor.clone(layout)
|
||||
local decor = fixed.decor
|
||||
fixed.decor = {}
|
||||
local pieces = Floor.pieces(fixed)
|
||||
if bad(pieces[1].rect) then
|
||||
fixed.stove = Floor.default().stove
|
||||
end
|
||||
-- 문제 있는 테이블(또는 그 의자)·소품을 빼고 다시 놓습니다.
|
||||
local movedTables: { number } = {}
|
||||
local chairBad: { [number]: boolean } = {}
|
||||
local tableBad: { [number]: boolean } = {}
|
||||
for _, p in pieces do
|
||||
if (p.kind == "table" or p.kind == "chair") and bad(p.rect) then
|
||||
local ti = if p.kind == "table" then p.index else fixed.chairs[p.index].t
|
||||
tableBad[ti] = true
|
||||
if p.kind == "chair" and bad(p.rect) then
|
||||
chairBad[p.index] = true
|
||||
elseif p.kind == "table" and bad(p.rect) then
|
||||
tableBad[p.index] = true
|
||||
end
|
||||
end
|
||||
for i in fixed.tables do
|
||||
if tableBad[i] then
|
||||
table.insert(movedTables, i)
|
||||
local by = chairsByTable(layout)
|
||||
local owner: { [number]: number } = {}
|
||||
for ti, list in by do
|
||||
for _, ci in list do
|
||||
owner[ci] = ti
|
||||
end
|
||||
end
|
||||
for _, ti in movedTables do
|
||||
-- 그 테이블을 아무도 안 쓰는 먼 곳에 잠깐 두고, 빈 곳을 찾아 옮깁니다.
|
||||
local chairsOf = {}
|
||||
for ci, c in fixed.chairs do
|
||||
if c.t == ti then
|
||||
table.insert(chairsOf, ci)
|
||||
end
|
||||
-- 먼저 문제없는 테이블과 그 의자만 남깁니다.
|
||||
local keepIndex: { [number]: number } = {} -- 예전 테이블 번호 -> 새 번호
|
||||
local tables: { Table } = {}
|
||||
for ti, t in fixed.tables do
|
||||
if not tableBad[ti] then
|
||||
table.insert(tables, t)
|
||||
keepIndex[ti] = #tables
|
||||
end
|
||||
local placed = false
|
||||
local floors: { number } = if stage >= 3 then { 2, 1 } else { 1 }
|
||||
for _, f in floors do
|
||||
if placed then
|
||||
break
|
||||
end
|
||||
for _, c in candidates(f) do
|
||||
local test = Floor.clone(fixed)
|
||||
test.tables[ti] = { x = c.x, z = c.z, f = f }
|
||||
local ok = true
|
||||
for _, ci in chairsOf do
|
||||
local found = false
|
||||
for _, s in { 1, 3, 2, 4 } do
|
||||
test.chairs[ci] = { t = ti, s = s }
|
||||
-- 의자끼리 같은 쪽이면 안 되므로 다른 의자와 비교
|
||||
local dup = false
|
||||
for _, cj in chairsOf do
|
||||
if cj < ci and test.chairs[cj].s == s then
|
||||
dup = true
|
||||
end
|
||||
end
|
||||
if not dup then
|
||||
found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
local chairs: { Chair } = {}
|
||||
local leftover = 0
|
||||
for ci, c in fixed.chairs do
|
||||
local ti = owner[ci]
|
||||
if ti and keepIndex[ti] and not chairBad[ci] then
|
||||
table.insert(chairs, c)
|
||||
elseif not ti or keepIndex[ti] then
|
||||
leftover += 1
|
||||
end
|
||||
end
|
||||
fixed.tables = tables
|
||||
fixed.chairs = chairs
|
||||
-- 문제 있는 테이블은 의자와 함께 빈 곳으로 옮깁니다. 의자 모양(상대 위치)은 그대로.
|
||||
for ti, t in layout.tables do
|
||||
if tableBad[ti] then
|
||||
local group: { number } = by[ti] or {}
|
||||
local placed = false
|
||||
local floors: { number } = if stage >= 3 then { 2, 1 } else { 1 }
|
||||
for _, f in floors do
|
||||
for _, c in candidates(f) do
|
||||
local test = Floor.clone(fixed)
|
||||
table.insert(test.tables, { x = c.x, z = c.z, f = f })
|
||||
for _, ci in group do
|
||||
local ch = layout.chairs[ci]
|
||||
table.insert(test.chairs, { x = c.x + ch.x - t.x, z = c.z + ch.z - t.z, f = f, r = ch.r })
|
||||
end
|
||||
if Floor.validate(test, stage) == nil then
|
||||
fixed = test
|
||||
placed = true
|
||||
break
|
||||
end
|
||||
ok = ok and found
|
||||
end
|
||||
if ok and Floor.validate(test, stage) == nil then
|
||||
fixed = test
|
||||
placed = true
|
||||
if placed then
|
||||
break
|
||||
end
|
||||
end
|
||||
if not placed then
|
||||
Floor.addTable(fixed, stage)
|
||||
leftover += #group
|
||||
end
|
||||
end
|
||||
end
|
||||
for _ = 1, leftover do
|
||||
Floor.addChair(fixed, stage)
|
||||
end
|
||||
-- 그래도 맞지 않으면 처음 배치에서 같은 수만큼 다시 놓습니다.
|
||||
if Floor.validate(fixed, stage) ~= nil then
|
||||
local fresh = Floor.default()
|
||||
for _ = 2, #layout.tables do
|
||||
Floor.addTable(fresh, stage)
|
||||
end
|
||||
for _ = 2, #layout.chairs do
|
||||
Floor.addChair(fresh, stage)
|
||||
end
|
||||
fixed = fresh
|
||||
end
|
||||
-- 소품은 맞지 않으면 다시 놓고, 놓을 곳이 없으면 뺍니다.
|
||||
local decor = fixed.decor
|
||||
fixed.decor = {}
|
||||
for _, d in decor do
|
||||
local test = Floor.clone(fixed)
|
||||
table.insert(test.decor, d)
|
||||
@@ -798,8 +930,8 @@ function Floor.pathToChair(layout: Layout, stage: number, chair: number): { Pos
|
||||
end
|
||||
-- 의자 바로 앞(테이블 반대쪽, 없으면 옆) 빈칸까지 걸어간 뒤 의자에 앉습니다.
|
||||
local function approach(g: Grid): (number, number)
|
||||
local c = layout.chairs[chair]
|
||||
local back = SIDES[c.s]
|
||||
local fx, fz = Floor.facing(layout.chairs[chair].r)
|
||||
local back = { x = -fx, z = -fz }
|
||||
local dirs = { back, { x = back.z, z = back.x }, { x = -back.z, z = -back.x } }
|
||||
local dist = Floor.CHAIR_SIZE / 2 + 0.6
|
||||
for _, d in dirs do
|
||||
|
||||
@@ -47,7 +47,7 @@ local STRINGS: { [string]: { [string]: string } } = {
|
||||
stoveObject = "조리대",
|
||||
tut1 = "손님이 왔어요! 빛나는 조리대로 가서 요리를 시작해요",
|
||||
tut2 = "다 만들었어요! 접시를 손님 자리로 가져가세요",
|
||||
tut3 = "돈을 벌었어요! 아래 [사기] 버튼으로 의자를 사세요",
|
||||
tut3 = "돈을 벌었어요! [가게 꾸미기]에서 의자를 골라 테이블 앞에 놓아 보세요",
|
||||
tutDone = "잘했어요! 계속 손님을 받고 가게를 키워 보세요",
|
||||
double = "2배 수익",
|
||||
doubleOwned = "2배 수익 적용 중",
|
||||
@@ -130,6 +130,11 @@ local STRINGS: { [string]: { [string]: string } } = {
|
||||
decor_Teddy = "곰인형",
|
||||
decor_Fridge = "냉장고",
|
||||
place = "배치하기",
|
||||
btnDecorate = "가게 꾸미기",
|
||||
decorateTitle = "가게 꾸미기",
|
||||
moveItems = "옮기기",
|
||||
decoKeys = "(R 돌리기 · F 놓기)",
|
||||
why_money = "돈이 모자라요",
|
||||
seatsNow = "자리 {n}/{max}",
|
||||
decorNow = "소품 {n}/{max}",
|
||||
staffLockedCard = "알바생 기능 업그레이드를 사면 열려요",
|
||||
@@ -163,7 +168,7 @@ local STRINGS: { [string]: { [string]: string } } = {
|
||||
watchAd = "광고 보기",
|
||||
promoteFree = "그냥 홍보",
|
||||
kickAction = "손님 쫓아내기",
|
||||
decoPick = "옮길 물건을 눌러요",
|
||||
decoPick = "옮길 물건(테이블·의자·소품·조리대)을 눌러요",
|
||||
decoMove = "바닥을 눌러 옮겨요",
|
||||
decoChair = "쪽을 고르거나 다른 테이블을 눌러요",
|
||||
decoOk = "여기 좋아요! [놓기]를 눌러요",
|
||||
@@ -181,7 +186,7 @@ local STRINGS: { [string]: { [string]: string } } = {
|
||||
why_reserved = "문 앞과 계단은 비워 둬요",
|
||||
why_floor = "2층이 아직 없어요",
|
||||
why_blocked = "손님 길이 막혀요",
|
||||
why_chair = "그쪽엔 의자를 놓을 수 없어요",
|
||||
why_chair = "의자가 테이블을 보게 놓아요([돌리기])",
|
||||
why_none = "다시 골라 주세요",
|
||||
upgraded = "{name} Lv{level}!",
|
||||
floor2 = "2층이 생겼어요! 테이블을 더 놓을 수 있어요",
|
||||
@@ -256,7 +261,7 @@ local STRINGS: { [string]: { [string]: string } } = {
|
||||
stoveObject = "Stove",
|
||||
tut1 = "A customer is here! Go to the glowing stove and start cooking",
|
||||
tut2 = "Done! Bring the dish to the customer's seat",
|
||||
tut3 = "You earned money! Tap [Buy] at the bottom to get a chair",
|
||||
tut3 = "You earned money! Open [Decorate], pick a chair and place it at a table",
|
||||
tutDone = "Great job! Keep serving and grow your shop",
|
||||
double = "Double Money",
|
||||
doubleOwned = "Double Money active",
|
||||
@@ -339,6 +344,11 @@ local STRINGS: { [string]: { [string]: string } } = {
|
||||
decor_Teddy = "Teddy Bear",
|
||||
decor_Fridge = "Fridge",
|
||||
place = "Arrange",
|
||||
btnDecorate = "Decorate",
|
||||
decorateTitle = "Decorate Shop",
|
||||
moveItems = "Move",
|
||||
decoKeys = "(R turn · F place)",
|
||||
why_money = "Not enough money",
|
||||
seatsNow = "Seats {n}/{max}",
|
||||
decorNow = "Decor {n}/{max}",
|
||||
staffLockedCard = "Buy the Staff Unlock upgrade to open this",
|
||||
@@ -372,7 +382,7 @@ local STRINGS: { [string]: { [string]: string } } = {
|
||||
watchAd = "Watch ad",
|
||||
promoteFree = "Just promote",
|
||||
kickAction = "Shoo customers",
|
||||
decoPick = "Tap something to move",
|
||||
decoPick = "Tap a table, chair, decor or the stove to move it",
|
||||
decoMove = "Tap the floor to move it",
|
||||
decoChair = "Pick a side or tap another table",
|
||||
decoOk = "Looks good! Tap [Place]",
|
||||
@@ -390,7 +400,7 @@ local STRINGS: { [string]: { [string]: string } } = {
|
||||
why_reserved = "Keep the door and stairs clear",
|
||||
why_floor = "No 2nd floor yet",
|
||||
why_blocked = "It blocks the customers' path",
|
||||
why_chair = "Can't put a chair there",
|
||||
why_chair = "Turn the chair to face a table",
|
||||
why_none = "Please pick again",
|
||||
upgraded = "{name} Lv{level}!",
|
||||
floor2 = "You built a 2nd floor! Room for more tables",
|
||||
@@ -465,7 +475,7 @@ local STRINGS: { [string]: { [string]: string } } = {
|
||||
stoveObject = "コンロ",
|
||||
tut1 = "お客さんが来たよ!光っているコンロに行って料理を始めよう",
|
||||
tut2 = "できた!お皿をお客さんの席まで運んでね",
|
||||
tut3 = "お金をかせいだよ!下の[買う]ボタンでいすを買ってね",
|
||||
tut3 = "お金をかせいだよ![かざる]でいすを選んで、テーブルの前に置いてね",
|
||||
tutDone = "よくできました!お客さんを迎えて、お店を大きくしよう",
|
||||
double = "収益2倍",
|
||||
doubleOwned = "収益2倍 適用中",
|
||||
@@ -548,6 +558,11 @@ local STRINGS: { [string]: { [string]: string } } = {
|
||||
decor_Teddy = "くまのぬいぐるみ",
|
||||
decor_Fridge = "れいぞうこ",
|
||||
place = "ならべる",
|
||||
btnDecorate = "かざる",
|
||||
decorateTitle = "お店をかざる",
|
||||
moveItems = "動かす",
|
||||
decoKeys = "(R 回す · F 置く)",
|
||||
why_money = "お金が足りないよ",
|
||||
seatsNow = "席 {n}/{max}",
|
||||
decorNow = "かざり {n}/{max}",
|
||||
staffLockedCard = "「アルバイト解放」を買うと開くよ",
|
||||
@@ -581,7 +596,7 @@ local STRINGS: { [string]: { [string]: string } } = {
|
||||
watchAd = "広告を見る",
|
||||
promoteFree = "ふつうに宣伝",
|
||||
kickAction = "お客さんを追い出す",
|
||||
decoPick = "動かす物をタップしてね",
|
||||
decoPick = "動かす物(テーブル・いす・小物・コンロ)をタップしてね",
|
||||
decoMove = "床をタップして動かそう",
|
||||
decoChair = "向きを選ぶか、別のテーブルをタップ",
|
||||
decoOk = "いいね![置く]をタップ",
|
||||
@@ -599,7 +614,7 @@ local STRINGS: { [string]: { [string]: string } } = {
|
||||
why_reserved = "ドアと階段の前はあけてね",
|
||||
why_floor = "2階がまだないよ",
|
||||
why_blocked = "お客さんの道がふさがるよ",
|
||||
why_chair = "そこにはいすを置けないよ",
|
||||
why_chair = "いすをテーブルに向けてね([回す])",
|
||||
why_none = "もう一度選んでね",
|
||||
upgraded = "{name} Lv{level}!",
|
||||
floor2 = "2階ができたよ!テーブルをもっと置けるよ",
|
||||
@@ -674,7 +689,7 @@ local STRINGS: { [string]: { [string]: string } } = {
|
||||
stoveObject = "灶台",
|
||||
tut1 = "客人来了!走到发光的灶台开始做菜吧",
|
||||
tut2 = "做好了!把盘子端到客人的座位上",
|
||||
tut3 = "赚到钱了!点下面的[购买]按钮买一把椅子",
|
||||
tut3 = "赚到钱了!在[装饰]里选一把椅子,放在桌子前面吧",
|
||||
tutDone = "做得好!继续招待客人,把店做大吧",
|
||||
double = "双倍收益",
|
||||
doubleOwned = "双倍收益生效中",
|
||||
@@ -757,6 +772,11 @@ local STRINGS: { [string]: { [string]: string } } = {
|
||||
decor_Teddy = "泰迪熊",
|
||||
decor_Fridge = "冰箱",
|
||||
place = "摆放",
|
||||
btnDecorate = "装饰",
|
||||
decorateTitle = "装饰店铺",
|
||||
moveItems = "移动",
|
||||
decoKeys = "(R 旋转 · F 放下)",
|
||||
why_money = "钱不够",
|
||||
seatsNow = "座位 {n}/{max}",
|
||||
decorNow = "装饰 {n}/{max}",
|
||||
staffLockedCard = "购买“解锁店员”升级后开放",
|
||||
@@ -790,7 +810,7 @@ local STRINGS: { [string]: { [string]: string } } = {
|
||||
watchAd = "看广告",
|
||||
promoteFree = "直接宣传",
|
||||
kickAction = "赶走客人",
|
||||
decoPick = "点要移动的东西",
|
||||
decoPick = "点要移动的东西(桌子·椅子·摆件·灶台)",
|
||||
decoMove = "点地面来移动",
|
||||
decoChair = "选方向或点另一张桌子",
|
||||
decoOk = "很好!点[放下]",
|
||||
@@ -808,7 +828,7 @@ local STRINGS: { [string]: { [string]: string } } = {
|
||||
why_reserved = "门口和楼梯要空着",
|
||||
why_floor = "还没有二楼",
|
||||
why_blocked = "挡住了客人的路",
|
||||
why_chair = "那边不能放椅子",
|
||||
why_chair = "让椅子朝向桌子([旋转])",
|
||||
why_none = "请重新选择",
|
||||
upgraded = "{name} Lv{level}!",
|
||||
floor2 = "盖好二楼了!可以放更多桌子",
|
||||
|
||||
Reference in New Issue
Block a user