From fdc5c05c2c511355d76b1897271073eed53bad13 Mon Sep 17 00:00:00 2001 From: EJClaw Date: Wed, 14 Oct 2026 05:22:17 +0900 Subject: [PATCH] =?UTF-8?q?feat(bunsik):=20=EA=B0=80=EA=B2=8C=20=EA=BE=B8?= =?UTF-8?q?=EB=AF=B8=EA=B8=B0=203D=20=ED=88=AC=EB=AA=85=20=EB=AF=B8?= =?UTF-8?q?=EB=A6=AC=EB=B3=B4=EA=B8=B0=C2=B7=ED=9A=8C=EC=A0=84,=20?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EB=B8=94=C2=B7=EC=9D=98=EC=9E=90=20=EB=94=B0?= =?UTF-8?q?=EB=A1=9C=20=EB=B0=B0=EC=B9=98,=20=EC=95=84=EB=9E=98=20[?= =?UTF-8?q?=EC=82=AC=EA=B8=B0]=20=EB=A7=89=EB=8C=80=20=E2=86=92=20?= =?UTF-8?q?=ED=8A=9C=ED=86=A0=EB=A6=AC=EC=96=BC,=20=EC=86=90=EB=8B=98=20?= =?UTF-8?q?=EB=8A=90=EB=A6=AC=EA=B2=8C,=202=EB=B0=B0=20=EB=8F=88=20"?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=20=EB=B3=B4=EC=9C=A0"=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 아래 추천 [사기] 막대를 없애고 튜토리얼 말풍선을 아래 가운데로. 튜토리얼 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 --- bunsik-tycoon/ECONOMY.md | 92 +- bunsik-tycoon/NETWORK.md | 17 +- bunsik-tycoon/PLAYTEST.md | 25 +- bunsik-tycoon/src/client/Decorate.luau | 998 +++++++++---------- bunsik-tycoon/src/client/Hud.luau | 149 +-- bunsik-tycoon/src/client/Layout.luau | 98 +- bunsik-tycoon/src/client/Main.client.luau | 18 +- bunsik-tycoon/src/client/ShopWindow.luau | 70 +- bunsik-tycoon/src/server/Game.luau | 44 +- bunsik-tycoon/src/server/PlotBuilder.luau | 107 +- bunsik-tycoon/src/server/PlotController.luau | 165 +-- bunsik-tycoon/src/shared/Economy.luau | 41 +- bunsik-tycoon/src/shared/Floor.luau | 378 ++++--- bunsik-tycoon/src/shared/Locale.luau | 44 +- bunsik-tycoon/tests/Economy.spec.luau | 27 +- bunsik-tycoon/tests/Floor.spec.luau | 126 ++- bunsik-tycoon/tests/Layout.spec.luau | 25 +- bunsik-tycoon/tests/Shop.spec.luau | 38 +- bunsik-tycoon/tests/cloud/dump_gui.luau | 9 +- bunsik-tycoon/tests/cloud/integration.luau | 77 +- bunsik-tycoon/tests/cloud/server.luau | 83 +- bunsik-tycoon/tools/simlib.luau | 3 +- 22 files changed, 1527 insertions(+), 1107 deletions(-) diff --git a/bunsik-tycoon/ECONOMY.md b/bunsik-tycoon/ECONOMY.md index 7fcba79..1d6bf99 100644 --- a/bunsik-tycoon/ECONOMY.md +++ b/bunsik-tycoon/ECONOMY.md @@ -1,6 +1,7 @@ # 분식집 타이쿤 — 경제 수치표 2026-10-14 개편: 한 줄로 쭉 사던 업그레이드 20개를 **갈래별 업그레이드**로 나누고, 자리는 **테이블·의자를 사서 원하는 곳에 놓는** 방식으로 바꿨습니다. 손님은 예전보다 느리게 옵니다(6초 → 10초). +같은 날 2차 조정: 손님 간격을 10초 → 20초로 한 번 더 늘리고, 1분 매출이 그대로 가도록 음식 값을 모두 2배로 올렸습니다. 테이블과 의자는 따로 삽니다. 숫자의 원본은 `src/shared/Economy.luau`입니다. 표의 시각은 시뮬레이터 `tools/sim.luau`가 **실제 게임 로직(`src/shared/Shop.luau`)**을 봇으로 돌려서 낸 값입니다. ``` @@ -14,10 +15,11 @@ lune run tests/Sim.spec.luau # 목표 범위 자동 검사(check.sh에 포함) | 항목 | 값 | 설명 | |---|---|---| | 처음 자리 | 테이블 1 + 의자 1 | 손님 자리 수 = 놓은 의자 수 | -| 손님 간격 | 10초 | 빈자리가 없으면 그냥 지나감. 접속하자마자 첫 손님 | +| 손님 간격 | 20초 | 빈자리가 없으면 그냥 지나감. 접속하자마자 첫 손님 | | 손님 걷기 | 길 길이 ÷ 18 stud/초 | 입구에서 의자까지 실제 길을 걸음(1.5~9초). 2층은 계단을 올라감 | | 조리(화구 수준) | 2.5 | 요리 창의 누르는 양 기준(`src/shared/Recipes.luau`) | | 식사 시간 | 6초 | 다 먹으면 자리가 빔. 돈은 접시를 놓는 순간 들어옴 | +| 처음 메뉴 | 떡볶이 30원 | | | 시작 돈 | 0 | | ## 업그레이드 갈래 @@ -27,9 +29,9 @@ lune run tests/Sim.spec.luau # 목표 범위 자동 검사(check.sh에 포함) | 갈래 | 단계별 효과와 값 | 필요 건물 | |---|---|---| | 건물 | 실내 분식집 450 → 2층 5,000 | 2층은 실내부터 | -| 메뉴 | 김밥(25원) 40, 순대(40원) 160 / 어묵(50원) 950, 튀김(70원) 2,000 | 어묵·튀김은 실내 | +| 메뉴 | 김밥(50원) 40, 순대(80원) 160 / 어묵(100원) 950, 튀김(140원) 2,000 | 어묵·튀김은 실내 | | 판매 금액 | x1.25 120, x1.5 260 / x1.75 1,100, x2 2,400 / x2.5 7,000, x3 12,000 | 3·4단계 실내, 5·6단계 2층 | -| 손님 속도(간격) | 8.5초 60, 7초 150, 6초 320 / 5초 1,000, 4.2초 2,000 / 3.5초 6,500, 3초 11,000 | 4·5단계 실내, 6·7단계 2층 | +| 손님 속도(간격) | 17초 60, 14초 150, 12초 320 / 10초 1,000, 8.5초 2,000 / 7초 6,500, 6초 11,000 | 4·5단계 실내, 6·7단계 2층 | | 화구 | 1.8 90 / 1.4 800, 1 1,800 | 2·3단계 실내 | | 쟁반(드는 접시) | 2개 700, 3개 2,600 | 실내 | | 알바생 기능 | 250 | 포장마차 | @@ -37,7 +39,8 @@ lune run tests/Sim.spec.luau # 목표 범위 자동 검사(check.sh에 포함) ## 자리(꾸미기) - 의자: s번째 자리 값 = 10 × (s−1)^2.1 (5원 단위). 2번째 10원, 3번째 45원, 4번째 100원, 8번째 595원, 12번째 1,540원, 24번째 7,240원. -- 테이블: 다음 자리 값 + 15 × (테이블 수)². 테이블 하나에 의자 4개까지(앞·뒤·왼쪽·오른쪽). 새 테이블에는 의자 1개가 같이 옵니다. +- 테이블: 20 + 15 × (지금 테이블 수)². 테이블만 오고 의자는 따로 삽니다. 2번째 35원, 3번째 80원, 4번째 155원. +- 의자는 테이블을 바라보게 놓으면 어디든 됩니다(예전처럼 테이블 앞·뒤·왼쪽·오른쪽 네 자리에 묶이지 않음). 추천 구매와 봇은 테이블 하나에 의자 4개쯤으로 보고, 의자가 (테이블 수 × 4 − 1)개 이상일 때만 테이블을 추천합니다. - 건물별 최대: 포장마차 테이블 3·의자 6, 실내 테이블 6·의자 14, 2층 테이블 12·의자 24. - 소품(장식, 손님 수와 무관): 화분 50, 러그 80, 풍선 120, 스탠드 150, 곰인형 250, 음료 냉장고 400. 최대 20개. - 테이블·의자·조리대·소품은 꾸미기 화면에서 옮깁니다. 문 앞과 2층 계단 자리에는 못 놓고, 문에서 조리대 앞·모든 의자까지 걸어갈 길이 있어야 합니다(`src/shared/Floor.luau`). @@ -59,46 +62,49 @@ lune run tests/Sim.spec.luau # 목표 범위 자동 검사(check.sh에 포함) | # | 구매 | 값 | 도달 시각 | 2배 게임패스 | |---|---|---|---|---| | 1 | 의자 1개 | 10 | 0:09 | 0:09 | -| 2 | 메뉴: 김밥 | 40 | 0:42 | 0:20 | -| 3 | 의자 1개 | 45 | 1:05 | 0:42 | -| 4 | 손님 속도 1 | 60 | 1:39 | 0:53 | -| 5 | 화구 1 | 90 | 2:36 | 1:16 | -| 6 | 의자 1개 | 100 | 3:28 | 1:48 | -| 7 | 판매 금액 1 | 120 | 4:31 | 2:19 | -| 8 | 손님 속도 2 | 150 | 5:33 | 2:51 | -| 9 | 메뉴: 순대 | 160 | 6:45 | 3:22 | -| 10 | 테이블(+의자 1개) | 200 | 7:46 | 4:04 | -| 11 | 알바생 기능 | 250 | 9:09 | 4:45 | -| 12 | 요리 알바 고용 | 200 | 10:10 | 5:06 | -| 13 | 판매 금액 2 | 260 | 10:50 | 5:31 | -| 14 | 의자 1개 | 295 | 11:41 | 5:51 | -| 15 | 손님 속도 3 | 320 | 12:40 | 6:11 | -| 16 | 건물: 실내 분식집 | 450 | 13:53 | 6:39 | -| 17 | 홍보 알바 고용 | 400 | 14:53 | 7:15 | -| 18 | 의자 1개 | 430 | 15:54 | 7:46 | -| 19 | 서빙 알바 고용 | 500 | 17:04 | 8:16 | -| 20 | 서빙 알바 고용 | 500 | 17:58 | 8:36 | -| 21 | 의자 1개 | 595 | 19:26 | 9:15 | -| 22 | 쟁반 1 | 700 | 20:54 | 9:58 | -| 23 | 화구 2 | 800 | 22:45 | 10:52 | -| 24 | 테이블(+의자 1개) | 850 | 24:40 | 11:40 | -| 25 | 메뉴: 어묵 | 950 | 26:47 | 12:34 | -| 26 | 손님 속도 4 | 1,000 | 28:38 | 13:23 | -| 27 | 의자 1개 | 1,010 | 29:58 | 14:08 | -| 28 | 판매 금액 3 | 1,100 | 31:40 | 14:49 | -| 29 | 의자 1개 | 1,260 | 33:12 | 15:35 | -| 30 | 의자 1개 | 1,540 | 35:11 | 16:31 | -| 31 | 화구 3 | 1,800 | 37:22 | 17:34 | -| 32 | 테이블(+의자 1개) | 1,980 | 39:45 | 18:43 | -| 33 | 메뉴: 튀김 | 2,000 | 42:18 | 19:50 | -| 34 | 손님 속도 5 | 2,000 | 44:17 | 20:47 | -| 35 | 의자 1개 | 2,185 | 46:08 | 21:40 | -| 36 | 판매 금액 4 | 2,400 | 48:01 | 22:38 | -| 37 | 쟁반 2 | 2,600 | 49:53 | 23:31 | -| 38 | 건물: 2층 | 5,000 | 53:32 | 25:18 | +| 2 | 메뉴: 김밥 | 40 | 0:20 | 0:09 | +| 3 | 의자 1개 | 45 | 0:31 | 0:20 | +| 4 | 테이블 | 35 | 0:42 | 0:20 | +| 5 | 손님 속도 1 | 60 | 1:01 | 0:31 | +| 6 | 화구 1 | 90 | 1:55 | 0:50 | +| 7 | 의자 1개 | 100 | 2:28 | 1:06 | +| 8 | 판매 금액 1 | 120 | 3:12 | 1:32 | +| 9 | 손님 속도 2 | 150 | 4:20 | 1:49 | +| 10 | 메뉴: 순대 | 160 | 5:05 | 2:20 | +| 11 | 의자 1개 | 185 | 5:42 | 2:31 | +| 12 | 알바생 기능 | 250 | 6:33 | 2:54 | +| 13 | 요리 알바 고용 | 200 | 7:15 | 3:08 | +| 14 | 판매 금액 2 | 260 | 7:51 | 3:45 | +| 15 | 의자 1개 | 295 | 9:01 | 4:13 | +| 16 | 손님 속도 3 | 320 | 9:47 | 4:31 | +| 17 | 건물: 실내 분식집 | 450 | 11:01 | 4:57 | +| 18 | 홍보 알바 고용 | 400 | 12:01 | 5:33 | +| 19 | 의자 1개 | 430 | 12:57 | 6:02 | +| 20 | 테이블 | 80 | 13:02 | 6:07 | +| 21 | 서빙 알바 고용 | 500 | 13:55 | 6:33 | +| 22 | 서빙 알바 고용 | 500 | 15:07 | 7:00 | +| 23 | 의자 1개 | 595 | 16:28 | 7:45 | +| 24 | 쟁반 1 | 700 | 17:53 | 8:24 | +| 25 | 의자 1개 | 790 | 19:42 | 9:09 | +| 26 | 화구 2 | 800 | 21:26 | 9:49 | +| 27 | 메뉴: 어묵 | 950 | 23:24 | 10:43 | +| 28 | 손님 속도 4 | 1,000 | 25:08 | 11:22 | +| 29 | 의자 1개 | 1,010 | 26:41 | 12:09 | +| 30 | 판매 금액 3 | 1,100 | 28:08 | 12:50 | +| 31 | 의자 1개 | 1,260 | 29:39 | 13:35 | +| 32 | 테이블 | 155 | 29:44 | 13:40 | +| 33 | 의자 1개 | 1,540 | 31:44 | 14:31 | +| 34 | 화구 3 | 1,800 | 33:50 | 15:27 | +| 35 | 의자 1개 | 1,845 | 36:14 | 16:34 | +| 36 | 메뉴: 튀김 | 2,000 | 38:35 | 17:38 | +| 37 | 손님 속도 5 | 2,000 | 40:32 | 18:20 | +| 38 | 의자 1개 | 2,185 | 42:22 | 19:19 | +| 39 | 판매 금액 4 | 2,400 | 44:15 | 20:14 | +| 40 | 쟁반 2 | 2,600 | 46:10 | 21:11 | +| 41 | 건물: 2층 | 5,000 | 49:41 | 22:54 | -- 첫 구매(의자)는 9초, 포장마차 단계 구매 간격은 23~83초입니다. -- 실내 분식집은 14분(2배 게임패스 7분), 2층은 54분(25분)입니다. +- 첫 구매(의자)는 9초, 포장마차 단계 구매 간격은 11~74초입니다. +- 실내 분식집은 11분(2배 게임패스 5분), 2층은 50분(23분)입니다. - 2층 뒤에는 판매 금액 5·6단계, 손님 속도 6·7단계, 남은 자리(최대 24석)가 남습니다. ## 유료 상품 diff --git a/bunsik-tycoon/NETWORK.md b/bunsik-tycoon/NETWORK.md index 25cda6f..80ae284 100644 --- a/bunsik-tycoon/NETWORK.md +++ b/bunsik-tycoon/NETWORK.md @@ -14,7 +14,7 @@ | Levels | string | 갈래 레벨 `"Stage=1,Menu=2,Price=0,Speed=1,Stove=0,Tray=0,Staff=1"` (Economy.TRACK_ORDER 순서). `Shared.Codec.decodeMap` 로 읽음 | | Stage | number | 건물 단계 1 포장마차, 2 실내, 3 2층 | | Seats, Tables | number | 놓은 의자 수(= 손님 자리 수), 테이블 수 | -| Layout | string | 배치 JSON(`Floor.Layout` 모양). `HttpService:JSONDecode` 후 `Floor.clean` | +| Layout | string | 배치 JSON(`Floor.Layout` 모양). `HttpService:JSONDecode` 후 `Floor.clean`. 의자는 `{x, z, f, r}`(r = 보는 쪽 0 +Z, 1 +X, 2 -Z, 3 -X)이고, 보는 쪽 바로 앞에 테이블이 있어야 함. 예전 `{t, s}` 모양은 `Floor.clean`이 바꿈 | | Staff | string | 고용한 알바 수 `"Cook=1,Server=0,Promoter=0"` | | Strike | bool | 시급이 모자라 알바생이 쉬는 중 | | Wage | number | 1분마다 주는 시급 합계 | @@ -29,7 +29,7 @@ | DesignsOwned | string | 유료 디자인 보유 목록 `"Candy,Hanok"` | | Double | bool | 2배 수익 | | Boost | number | 돈 부스트 팩 지급액 | -| Tut | number | 튜토리얼 단계(0 끝, 1 조리대로, 2 서빙, 3 사기) | +| Tut | number | 튜토리얼 단계(0 끝, 1 조리대로, 2 서빙, 3 가게 꾸미기에서 의자 놓기) | | Carry, Hand | number, string | 든 접시 수, 든 메뉴 `"Gimbap,Sundae"` | | Orders | string | 메뉴별 열린 주문 `"Tteokbokki=2,Gimbap=1"` | | Lang, LangSetting, MouseLook, Sfx, Dev | | 설정(예전과 같음) | @@ -54,7 +54,9 @@ 부지 안 `Upgrades/Furniture` 폴더에 서버가 짓습니다. 꾸미기 화면이 눌러서 고를 수 있게 모델마다 속성을 붙입니다. - `ItemKind` = "table" | "chair" | "decor" | "stove", `ItemIndex` = Layout 목록 번호(조리대는 1) +- 모델 기준점(WorldPivot) = 놓는 자리 `Origin * CFrame.new(x, 바닥 높이, z) * CFrame.Angles(0, r·90°, 0)` - 조리대(포장마차 수레)는 `Plot.Base.Stall` 모델 그대로 옮깁니다(인스턴스가 바뀌지 않아서 조리대 버튼이 계속 붙어 있음). +- 새 물건 미리보기 모형: `ReplicatedStorage.BunsikTemplates`의 `Table`, `Chair`, `Decor_<소품>`(기준점 = 원점). 서버 시작 때 만듭니다. ## 요청 (Action kind, arg) @@ -62,11 +64,12 @@ |---|---|---| | `cookStart`, `cook` | 메뉴 | 요리 창(예전과 같음) | | `upgrade` | 갈래 id | 다음 단계 구매 | -| `buySeat` | 테이블 번호 또는 nil | 의자 1개(빈 쪽에 자동 배치) | -| `buyTable` | nil | 테이블 + 의자 1개(빈 곳 자동 배치) | +| `buyAt` | `{kind="table"/"chair"/"decor", k=소품 id, x, z, f, r}` | 꾸미기 화면 [놓기]: 그 자리에 새 물건을 사서 놓기(Floor.add로 검사, 실패면 `placeFail`, 돈은 성공할 때만) | +| `buySeat` | 테이블 번호 또는 nil | 의자 1개(테이블 빈 쪽에 자동 배치, 테스트·예전 경로) | +| `buyTable` | nil | 테이블만(빈 곳 자동 배치, 의자는 따로) | | `buyDecor` | 소품 id | 소품 1개(빈 곳 자동 배치) | -| `buyOffer` | `"Seat"`/`"Table"`/갈래 id | 화면 아래 추천 막대의 [사기] | -| `move` | `{kind="stove"/"table"/"decor", i, x, z, f, r}` | 옮기기(Floor.move로 검사). 의자는 `{kind="chair", i, x=쪽(1~4), z=테이블 번호(0=그대로)}` | +| `buyOffer` | `"Seat"`/`"Table"`/갈래 id | 추천 구매(화면 막대는 없어졌고 테스트용으로 남김) | +| `move` | `{kind="stove"/"table"/"chair"/"decor", i, x, z, f, r}` | 옮기기(Floor.move로 검사). 테이블의 r은 그 테이블을 보는 의자들을 테이블 둘레로 돌리는 횟수(의자도 같이 옮겨짐) | | `hire`, `fire` | 역할 id | 알바 고용·해고 | | `rename` | 문자열(최대 20자) | 이름 바꾸기(TextService 필터) | | `rainbow` | bool | 무지개 이름 켜기/끄기. 없으면 게임패스 결제 창 | @@ -86,4 +89,4 @@ - `renamed`, `nameRejected`(필터 실패·빈 이름), `designSet {design}`, `designLocked`(실내 분식집부터) - `promoted {n}`, `promoteNone`(데려올 손님 없음), `promoteFull`(빈자리 없음), `promoteWait {sec}`, `adUnavailable` - `kicked {n, shop}`(내가 쫓아냄), `kickedBy {name}`(내 가게 손님이 쫓겨남), `shielded`(보호 중), `kickOwn`(내 가게는 안 됨) -- `rushOn {min}`, `notEnough {need}` +- `rushOn {min}`, `notEnough {need}`, `doubleOwned`(2배 수익 게임패스를 이미 가지고 있어 결제 창 대신 바로 켬) diff --git a/bunsik-tycoon/PLAYTEST.md b/bunsik-tycoon/PLAYTEST.md index ede2852..7cfabb8 100644 --- a/bunsik-tycoon/PLAYTEST.md +++ b/bunsik-tycoon/PLAYTEST.md @@ -8,24 +8,25 @@ ## 해 볼 것 (20~30분) -1. 튜토리얼: 노란 줄과 화살표를 따라 조리대로 가서 [요리하기](PC는 E)를 누르고, 손님이 주문한 메뉴를 만들어 손님 자리로 가져갑니다. 접시가 손에서도 테이블 위에서도 **눕혀서** 보이는지 봐 주세요(예전에 세로로 서던 문제). -2. 돈이 생기면 아래 막대의 [사기]로 의자를 삽니다. 막대에는 지금 살 수 있는 것 중 가장 싼 것이 나옵니다. -3. 분홍 [상점] 버튼: 탭 4개 +1. 튜토리얼: 노란 줄과 화살표를 따라 조리대로 가서 [요리하기](PC는 E)를 누르고, 손님이 주문한 메뉴를 만들어 손님 자리로 가져갑니다. 안내 말풍선은 화면 **아래 가운데**에 나옵니다(예전 [사기] 막대는 없앰). +2. 돈이 생기면 말풍선과 손가락이 [가게 꾸미기] 버튼을 가리킵니다. 의자를 골라 테이블 앞에 놓으면 튜토리얼이 끝납니다. +3. 분홍 [상점] 버튼: 탭 3개 - 업그레이드: 건물(포장마차 → 실내 분식집 → 2층), 새 메뉴, 판매 금액, 손님 속도, 화구, 쟁반, 알바생 기능을 따로따로 삽니다. 실내 분식집이 필요한 것은 자물쇠와 "실내 분식집부터"가 붙습니다. - - 꾸미기: 테이블(의자 1개 포함), 의자, 소품 6가지(화분·카펫·풍선·전등·곰인형·냉장고). [배치하기]를 누르면 꾸미기 화면이 열립니다. - 알바생: 알바생 기능을 사면 열립니다. 요리·서빙·홍보 알바를 고용하고 뺄 수 있고, 시급은 1분마다 나갑니다. 돈이 모자라면 알바생 머리 위에 💤가 뜨고 쉽니다. - 내 가게: 가게 이름 쓰고 [저장], 무지개 이름(💎 게임패스), 건물 디자인 5개(실내 분식집부터, 사탕 궁전·한옥은 💎 게임패스). -4. 꾸미기 화면(위에서 내려다보는 화면, 캐릭터는 멈춤) - - 테이블·의자·조리대·소품을 눌러 고르고, 바닥을 누르거나 끌어서 옮긴 뒤 [놓기]. 놓을 수 있으면 초록, 안 되면 빨강과 이유(문 앞, 겹침, 길이 막힘 등)가 나옵니다. - - 의자는 앞·오른쪽·뒤·왼쪽 버튼으로 붙는 쪽을 바꾸고, 다른 테이블을 누르면 그 테이블로 옮겨 갑니다. - - 조리대와 소품은 [돌리기]로 돌립니다. 2층 건물이면 1층·2층 버튼이 나옵니다. [나가기]로 끝냅니다. +4. 초록 [가게 꾸미기] 버튼(상점과 따로): 테이블, 의자, 소품 6가지(화분·카펫·풍선·전등·곰인형·냉장고) 카드와 큰 [옮기기] 버튼 + - 카드를 누르면 창이 닫히고, 그 물건이 **투명하게 캐릭터 앞에 붙어 다닙니다**. 걸어 다니며 자리를 잡고 [돌리기]로 방향을 바꾼 뒤 [놓기]를 누르면 거기에 놓이고 그때 돈이 나갑니다. PC는 R 돌리기, F 놓기도 됩니다. + - 놓을 수 있으면 초록, 안 되면 빨강과 이유(문 앞, 겹침, 손님 길 막힘, 돈 부족 등)가 위에 나옵니다. [취소]나 [나가기]로 그만둡니다. + - 테이블과 의자는 따로 삽니다(테이블에 의자가 딸려 오지 않음). 의자는 등받이가 있어서 방향이 보이고, **의자가 테이블을 보게** 놓아야 합니다. 손님은 의자가 보는 쪽 테이블에서 먹습니다. + - [옮기기]를 누르고 이미 놓은 테이블·의자·소품·조리대를 누르면 그 물건을 들고 옮길 수 있습니다. 테이블을 들면 그 테이블을 보는 의자도 같이 따라오고, [돌리기]는 의자들을 테이블 둘레로 돌립니다. + - 2층 건물이면 계단으로 2층에 올라가서 놓으면 2층에 놓입니다. 5. 실내 분식집을 사면 천장·지붕이 있는 건물이 생기고, 2층을 사면 계단과 2층이 생깁니다. 2층에 놓은 자리에도 손님이 계단을 올라가 앉는지 봐 주세요. 6. 오른쪽 위(휴대폰)·오른쪽(PC) 손님 버튼 - 📣 홍보: 옆 가게에서 기다리던 손님이 최대 3명(빈자리만큼) 걸어서 우리 가게로 옵니다. 광고를 볼 수 있는 계정이면 [광고 보기]가 나오고, 아니면 바로 홍보됩니다(3분마다). 비공개 게임이라 지금은 광고가 나오지 않는 것이 정상입니다. - 손님 러시(💎 15로벅스): 10분 동안 손님이 2배 빨리 옵니다. 진짜 결제 창이 뜹니다. 7. 옆 가게 입구에 가면 버튼이 두 개 있습니다: [손님으로 들어가기](E), [손님 쫓아내기](F, 💎 15로벅스). 쫓아내기를 사면 그 가게에서 기다리던 손님이 일어나 우리 가게로 옵니다. 당한 가게는 3분 동안 보호됩니다. 진짜 결제 창이 뜹니다. 8. 손님 모습: 머리·모자·옷이 다른 사람 손님이 대부분이고, 가끔 펭귄·곰·북극곰·고양이·강아지·판다·여우·쥐 같은 동물 손님이 옵니다. 서버가 켜지고 10초쯤은 기본 모습 손님이 올 수 있습니다. -9. 손님은 예전보다 느리게 옵니다(처음 10초에 한 명). 업그레이드의 손님 속도, 홍보 알바, 손님 러시로 빨라집니다. +9. 손님은 예전보다 훨씬 느리게 옵니다(처음 20초에 한 명). 대신 음식값을 2배로 올려서 버는 속도는 비슷합니다. 업그레이드의 손님 속도, 홍보 알바, 손님 러시로 빨라집니다. 10. 다른 플레이어가 같은 서버에 있으면, 가게 이름·무지개 이름·건물 디자인이 그 사람 화면에도 보이는지 봐 주세요. 11. 나갔다가 다시 들어와서 돈·업그레이드·배치·알바생·이름·디자인이 그대로인지 봅니다. @@ -33,14 +34,14 @@ [설정] 창 맨 아래 `개발자 테스트` 줄: - `+1,000원`: 돈을 바로 넣습니다. 뒤쪽 업그레이드를 빨리 확인할 때 씁니다(여러 번 누르면 2층까지 빨리 갈 수 있음). -- `2배 켜기/끄기`: 2배 수익 게임패스를 산 것처럼 켭니다(이번 접속에만 적용). -- `처음부터`: 돈·업그레이드·배치·알바생·튜토리얼을 처음으로 되돌립니다. 이름과 산 게임패스는 남습니다. +- `2배 켜기/끄기`: 2배 수익을 켜고 끕니다(이번 접속에만 적용). 게임 주인 계정은 게임패스를 자동으로 가지고 있어서, 꺼 둔 뒤 [2배 돈]을 누르면 결제 창 없이 다시 켜집니다. +- `처음부터`: 돈·업그레이드·배치·알바생·튜토리얼을 처음으로 되돌립니다. 이름과 산 게임패스(2배 수익 포함)는 남습니다. [2배 돈], [부스트], 손님 러시, 쫓아내기, 무지개 이름, 유료 디자인은 진짜 결제 창이 뜹니다. 누르면 실제 로벅스가 나가니, 결제 테스트가 필요할 때만 쓰세요. ## 알려 주시면 좋은 것 -- 꾸미기 화면: 위에서 보는 화면이 잘 보이는지, 고르고 옮기기가 손가락·마우스로 쉬운지, 지붕·2층이 잘 숨겨지는지 +- 가게 꾸미기: 투명 미리보기가 캐릭터 앞에서 잘 따라오는지, 거리가 적당한지, 돌리기·놓기가 쉬운지, 휴대폰에서 버튼이 조이스틱·점프에 안 가리는지 - 손님·알바생이 걷고 앉는 모습, 동물 손님 모습이 어색하지 않은지 - 서빙 알바가 접시를 들고 손님에게 가는 모습 - 너무 빠르거나 느리다고 느낀 구간(어떤 업그레이드 근처인지). 손님이 너무 느리게 오는지 diff --git a/bunsik-tycoon/src/client/Decorate.luau b/bunsik-tycoon/src/client/Decorate.luau index 7fe646e..b9d8179 100644 --- a/bunsik-tycoon/src/client/Decorate.luau +++ b/bunsik-tycoon/src/client/Decorate.luau @@ -1,16 +1,20 @@ --!strict --- 꾸미기(배치) 화면: 상점 창 꾸미기 탭의 [배치하기]로 엽니다. --- - 카메라가 내 가게 위에서 내려다봅니다(1층/2층 바꾸기). 위를 가리는 지붕·천장·2층 바닥은 내 화면에서만 숨깁니다. --- - 물건(테이블·의자·소품·조리대)을 눌러 고르고, 바닥을 누르거나 끌어서 옮길 자리를 정합니다(0.5칸 단위). --- 조리대·소품은 [돌리기], 의자는 쪽 버튼(앞·오른쪽·뒤·왼쪽)과 다른 테이블 누르기로 옮깁니다. --- - 옮길 자리는 바닥에 초록(놓을 수 있음)/빨강(안 됨) 판으로 보이고, 안 되는 이유를 위에 씁니다. --- 검사는 서버와 같은 Floor.move이고, [놓기]를 누르면 서버에 "move"를 보냅니다(서버가 다시 검사하고 모델을 다시 지음). --- 캐릭터 조작 멈춤·다른 UI 숨기기는 Main이 onOpen/onClose로 합니다(요리 창과 같은 방식). +-- 꾸미기(놓기) 화면: 화면의 [가게 꾸미기] 창에서 물건을 고르거나 [옮기기]를 누르면 시작합니다. +-- - 들기: 고른 물건의 투명한 미리보기가 내 캐릭터 바로 앞에 붙어 다닙니다. 걸어 다니며 자리를 잡고 +-- [돌리기](PC: R)로 방향을 바꾼 뒤 [놓기](PC: F)를 누르면 그 자리에 놓습니다. +-- 놓을 수 있으면 초록, 안 되면 빨강과 이유(문 앞, 겹침, 길이 막힘, 의자 앞에 테이블 없음, 돈 부족 등)가 나옵니다. +-- 검사는 서버와 같은 Floor.add / Floor.move이고, 서버가 다시 검사합니다. 새 물건 값은 놓을 때 나갑니다. +-- - 옮기기: 내 가게의 테이블·의자·소품·조리대를 누르면 그 물건을 듭니다(원래 물건은 내 화면에서만 숨김). +-- 테이블을 들면 그 테이블을 보는 의자도 같이 들리고, [돌리기]는 의자들을 테이블 둘레로 돌립니다. +-- - 층은 캐릭터가 서 있는 층(2층 건물이면 계단으로 올라가서 놓음)입니다. +-- 캐릭터는 그대로 움직이고, 다른 화면 UI와 조리대 버튼은 Main이 onOpen/onClose로 숨깁니다. local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local Shared = ReplicatedStorage:WaitForChild("Shared") +local Economy = require(Shared:WaitForChild("Economy")) local Floor = require(Shared:WaitForChild("Floor")) local Locale = require(Shared:WaitForChild("Locale")) local Info = require(script.Parent:WaitForChild("Info")) @@ -21,84 +25,109 @@ local Decorate = {} export type Handle = { gui: ScreenGui, - open: () -> (), + -- kind = "table" | "chair" | "decor"(k = 소품 종류)이면 새 물건 들기, "move"면 옮길 물건 고르기 + start: (kind: string, k: string?) -> (), close: () -> (), isOpen: () -> boolean, + holding: () -> boolean, -- 물건을 들고 있으면 true(PC 마우스 회전은 그대로) onOpen: (fn: () -> ()) -> (), - onClose: (fn: () -> ()) -> (), + -- 끝날 때. placed = 새 물건을 놓으려고 보냈으면 "new", 옮기기를 보냈으면 "move", 그냥 나가면 nil + onClose: (fn: (placed: string?) -> ()) -> (), setLayout: (lay: Layout.Result) -> (), notify: (key: string, args: { [string]: any }?) -> (), destroy: () -> (), } -type Selection = { kind: string, i: number } +type Hold = { + new: boolean, + kind: string, -- "table" | "chair" | "decor" | "stove" + k: string?, -- 새 소품 종류 + i: number, -- 옮기는 물건 번호(새 물건이면 0) + r: number, -- 회전(테이블은 지금 자리 기준 돌린 횟수) +} + +type Piece = { kind: string, index: number, clone: Model, from: CFrame?, pivot: CFrame } local GOOD = Color3.fromRGB(70, 220, 120) local BAD = Color3.fromRGB(255, 70, 70) -local HIDE_ABOVE = 4 -- 보는 층 바닥보다 이만큼 위에서 시작하는 부품은 숨김(천장·지붕·위층) local function snap(v: number): number return math.floor(v * 2 + 0.5) / 2 end --- 검사 없이 옮긴 배치(바닥 판 그리기용). Floor.move와 같은 규칙으로 바꿉니다. -local function applyMove(layout: Floor.Layout, m: Floor.Move): Floor.Layout - local test = Floor.clone(layout) - 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 = m.x, z = m.z, r = r } - elseif m.kind == "table" and test.tables[m.i] then - test.tables[m.i] = { x = m.x, z = m.z, f = f } - elseif m.kind == "decor" and test.decor[m.i] then - local d = test.decor[m.i] - test.decor[m.i] = { k = d.k, x = m.x, z = m.z, f = f, r = r } - elseif m.kind == "chair" and test.chairs[m.i] then - local c = test.chairs[m.i] - if m.z ~= 0 and test.tables[m.z] then - c.t = m.z - end - if Floor.SIDES[m.x] then - c.s = m.x - end +-- 캐릭터 가운데에서 미리보기 가운데까지 거리(물건 크기에 맞춤) +local function holdDistance(h: Hold, layout: Floor.Layout): number + if h.kind == "table" then + return 6 + elseif h.kind == "chair" then + return 3.5 + elseif h.kind == "stove" then + return 11 end - return test + local k = h.k + if not k and layout.decor[h.i] then + k = layout.decor[h.i].k + end + local fp = k and Floor.FOOTPRINT[k] + return if fp then math.max(fp.w, fp.d) / 2 + 2.5 else 3.5 end --- 물건의 층 -local function itemFloor(layout: Floor.Layout, kind: string, i: number): number - if kind == "table" then +-- 배치 속 물건 하나의 놓는 자리(x, z, 층, 회전) +local function spot(layout: Floor.Layout, kind: string, i: number): (number?, number?, number?, number?) + if kind == "stove" then + local s = layout.stove + return s.x, s.z, 1, s.r + elseif kind == "table" then local t = layout.tables[i] - return if t then t.f else 1 + if t then + return t.x, t.z, t.f, 0 + end elseif kind == "chair" then local c = layout.chairs[i] - local t = c and layout.tables[c.t] - return if t then t.f else 1 + if c then + return c.x, c.z, c.f, c.r + end elseif kind == "decor" then local d = layout.decor[i] - return if d then d.f else 1 - end - return 1 -end - --- 물건의 지금 자리를 옮기기 요청 모양으로 -local function currentMove(layout: Floor.Layout, sel: Selection): Floor.Move? - if sel.kind == "stove" then - local s = layout.stove - return { kind = "stove", i = 1, x = s.x, z = s.z, f = 1, r = s.r } - elseif sel.kind == "table" then - local t = layout.tables[sel.i] - return t and { kind = "table", i = sel.i, x = t.x, z = t.z, f = t.f, r = 0 } - elseif sel.kind == "decor" then - local d = layout.decor[sel.i] - return d and { kind = "decor", i = sel.i, x = d.x, z = d.z, f = d.f, r = d.r } - elseif sel.kind == "chair" then - local c = layout.chairs[sel.i] - return c and { kind = "chair", i = sel.i, x = c.s, z = 0, f = 1, r = 0 } + if d then + return d.x, d.z, d.f, d.r + end end return nil end +-- 미리보기용으로 복사한 모형 정리: 부딪히지 않고, 빛·소리·버튼 없이 반투명하게 +local function ghostify(m: Model) + for _, d in m:GetDescendants() do + if d:IsA("BasePart") then + d.Anchored = true + d.CanCollide = false + d.CanQuery = false + d.CanTouch = false + d.CastShadow = false + d.Transparency = 0.45 + d.Transparency * 0.55 + elseif d:IsA("Decal") then + d.Transparency = 0.45 + d.Transparency * 0.55 + elseif + d:IsA("ProximityPrompt") + or d:IsA("Sound") + or d:IsA("Light") + or d:IsA("ParticleEmitter") + or d:IsA("Fire") + or d:IsA("Smoke") + or d:IsA("Sparkles") + or d:IsA("BillboardGui") + or d:IsA("Highlight") + or d:IsA("BaseScript") + then + d:Destroy() + end + end + for name in m:GetAttributes() do + m:SetAttribute(name, nil) + end +end + function Decorate.build(parent: Instance, state: Instance, plot: Model, send: (string, any?) -> ()): Handle local function lang(): string return Info.attr(state, "Lang", "ko") @@ -106,6 +135,7 @@ function Decorate.build(parent: Instance, state: Instance, plot: Model, send: (s local function L(key: string, args: { [string]: any }?): string return Locale.t(lang(), key, args) end + local player = state :: any local gui = Instance.new("ScreenGui") gui.Name = "BunsikDecorate" @@ -119,7 +149,6 @@ function Decorate.build(parent: Instance, state: Instance, plot: Model, send: (s scale.Parent = root local exitBtn, exitLabel = Theme.iconButton(root, "Exit", Theme.RED, "close") - local floorBtn, floorLabel = Theme.textButton(root, "Floor", Theme.SKY, 22) local infoBox = Theme.frame(root, "Info", Theme.WHITE) Theme.round(infoBox) local infoStroke = Theme.stroke(infoBox, Theme.edge(Theme.MINT), 4) @@ -128,48 +157,42 @@ function Decorate.build(parent: Instance, state: Instance, plot: Model, send: (s infoIcon.frame.Position = UDim2.new(0, 10, 0.5, 0) infoIcon.frame.Size = UDim2.new(0, 48, 0.8, 0) local infoText = Theme.text(infoBox, "Text") - infoText.Position = UDim2.new(0, 64, 0.14, 0) - infoText.Size = UDim2.new(1, -80, 0.72, 0) + infoText.Position = UDim2.new(0, 64, 0.12, 0) + infoText.Size = UDim2.new(1, -80, 0.76, 0) infoText.ZIndex = 2 local rotateBtn, rotateLabel = Theme.textButton(root, "Rotate", Theme.LAVENDER, 22) local cancelBtn, cancelLabel = Theme.textButton(root, "Cancel", Theme.GRAY, 22) local okBtn, okLabel = Theme.textButton(root, "Place", Theme.MINT, 22) - local sideBtns: { Theme.Button } = {} - local sideLabels: { TextLabel } = {} - for s = 1, 4 do - local b, t = Theme.textButton(root, "Side" .. s, Theme.ORANGE, 22) - sideBtns[s] = b - sideLabels[s] = t - end - -- 바닥 판과 고른 물건 빛 - local world = Instance.new("Folder") - world.Name = "BunsikDecorateGhost" + -- 미리보기 모형(내 화면에만) + local ghost = Instance.new("Model") + ghost.Name = "BunsikDecorateGhost" local highlight = Instance.new("Highlight") - highlight.FillColor = Theme.YELLOW - highlight.FillTransparency = 0.6 + highlight.FillTransparency = 0.55 highlight.OutlineColor = Theme.WHITE highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop - highlight.Parent = world - local ghostParts: { BasePart } = {} + highlight.Parent = ghost + local plates: { BasePart } = {} local isOpen = false - local floorNow = 1 - local sel: Selection? = nil - local pending: Floor.Move? = nil + local hold: Hold? = nil + local pieces: { Piece } = {} + local hiddenParts: { [BasePart]: boolean } = {} -- 옮기는 원래 물건(내 화면에서만 숨김) -> 원래 CanCollide + local target: { x: number, z: number, f: number }? = nil local valid = false local why: string? = nil local message: string? = nil local messageToken = 0 - local dragging = false - local dragOffset = Vector2.zero local openFns: { () -> () } = {} - local closeFns: { () -> () } = {} + local closeFns: { (string?) -> () } = {} local conns: { RBXScriptConnection } = {} - local openConns: { RBXScriptConnection } = {} - local hidden: { [BasePart]: boolean } = {} - local saved: { kind: Enum.CameraType, fov: number }? = nil + + -- 배치는 속성이 바뀔 때만 다시 읽습니다(매 프레임 JSON을 풀지 않게). + local layoutNow = Info.layout(state) + local function curLayout(): Floor.Layout + return layoutNow + end local function origin(): CFrame? local o = plot:GetAttribute("Origin") @@ -181,58 +204,11 @@ function Decorate.build(parent: Instance, state: Instance, plot: Model, send: (s local function floorY(f: number): number return Floor.BASE_Y + (if f == 2 then Floor.FLOOR2_Y else 0) end - - -- 위를 가리는 부품 숨기기(내 화면에서만) - local function hideCheck(p: BasePart, o: CFrame) - local cf, sz = p.CFrame, p.Size - local halfY = math.abs(cf.RightVector.Y) * sz.X / 2 - + math.abs(cf.UpVector.Y) * sz.Y / 2 - + math.abs(cf.LookVector.Y) * sz.Z / 2 - local bottom = o:PointToObjectSpace(p.Position).Y - halfY - if bottom > floorY(floorNow) + HIDE_ABOVE then - hidden[p] = true - p.LocalTransparencyModifier = 1 - end - end - local function unhideAll() - for p in hidden do - p.LocalTransparencyModifier = 0 - end - table.clear(hidden) - end - local function hideAll() - unhideAll() - local o = origin() - local up = plot:FindFirstChild("Upgrades") - if not o or not up then - return - end - for _, d in up:GetDescendants() do - if d:IsA("BasePart") then - hideCheck(d, o) - end - end + local function placeCF(o: CFrame, x: number, z: number, f: number, r: number): CFrame + return o * CFrame.new(x, floorY(f), z) * CFrame.Angles(0, r * math.pi / 2, 0) end - local function placeCamera() - local o = origin() - local camera = workspace.CurrentCamera - if not o or not camera then - return - end - local vp = camera.ViewportSize - local aspect = if vp.Y > 0 then vp.X / vp.Y else 16 / 9 - camera.CameraType = Enum.CameraType.Scriptable - camera.FieldOfView = 70 - local k = 2 * math.tan(math.rad(35)) - -- 깊이 56칸(+위아래 UI 자리), 너비 66칸이 다 보이는 높이 - local h = math.max(86 / k, 74 / (k * aspect)) - local center = o * CFrame.new(0, floorY(floorNow), (Floor.Z0 + Floor.Z1) / 2 + 3) - local eye = center.Position + o.UpVector * h - camera.CFrame = CFrame.lookAt(eye, center.Position, o.LookVector) - end - - -- 물건 모델 찾기 + -- 물건 모형 찾기(조리대는 수레 모형) local function itemModel(kind: string, i: number): Model? if kind == "stove" then local base = plot:FindFirstChild("Base") @@ -244,7 +220,7 @@ function Decorate.build(parent: Instance, state: Instance, plot: Model, send: (s if not furniture then return nil end - for _, d in furniture:GetDescendants() do + for _, d in furniture:GetChildren() do if d:IsA("Model") and d:GetAttribute("ItemKind") == kind and d:GetAttribute("ItemIndex") == i then return d end @@ -252,274 +228,246 @@ function Decorate.build(parent: Instance, state: Instance, plot: Model, send: (s return nil end - local function clearGhost() - for _, p in ghostParts do - p:Destroy() + local function cost(h: Hold): number? + if not h.new then + return nil end - table.clear(ghostParts) + if h.kind == "chair" then + return Economy.seatCost(Info.attr(state, "Seats", 1) + 1) + elseif h.kind == "table" then + return Economy.tableCost(Info.attr(state, "Tables", 1)) + end + local d = h.k and Economy.decor(h.k) + return d and d.cost end - local function drawGhost(layout: Floor.Layout, m: Floor.Move, ok: boolean) + local function itemName(h: Hold, layout: Floor.Layout): (string, string) + if h.kind == "stove" then + return L("stoveObject"), "flame" + elseif h.kind == "table" then + return L("thing_Table"), "table" + elseif h.kind == "chair" then + return L("thing_Seat"), Info.SEAT_ICON + end + local k = h.k or (layout.decor[h.i] and layout.decor[h.i].k) or "" + return L("decor_" .. k), Info.DECOR_ICON[k] or "sparkle" + end + + -- 원래 물건 숨기기/되돌리기(옮기는 동안 내 화면에서만, 지나갈 수 있게) + local function hideModel(m: Model) + for _, d in m:GetDescendants() do + if d:IsA("BasePart") and hiddenParts[d] == nil then + hiddenParts[d] = d.CanCollide + d.LocalTransparencyModifier = 1 + d.CanCollide = false + end + end + end + local function unhideAll() + for p, collide in hiddenParts do + if p.Parent then + p.LocalTransparencyModifier = 0 + p.CanCollide = collide + end + end + table.clear(hiddenParts) + end + + local function clearGhost() + for _, pc in pieces do + pc.clone:Destroy() + end + table.clear(pieces) + for _, p in plates do + p:Destroy() + end + table.clear(plates) + ghost.Parent = nil + unhideAll() + end + + -- 든 물건의 미리보기 모형 만들기 + local function buildGhost(h: Hold) clearGhost() + local layout = curLayout() + local function addPiece(kind: string, index: number, source: Model?, from: CFrame?) + if not source then + return + end + local c = source:Clone() + ghostify(c) + c.Parent = ghost + table.insert(pieces, { kind = kind, index = index, clone = c, from = from, pivot = source:GetPivot() }) + end local o = origin() if not o then return end - for _, pc in Floor.pieces(layout) do - local mine = pc.kind == m.kind and pc.index == m.i - if m.kind == "table" and pc.kind == "chair" then - local c = layout.chairs[pc.index] - mine = c ~= nil and c.t == m.i + if h.new then + local templates = ReplicatedStorage:FindFirstChild("BunsikTemplates") + local name = if h.kind == "table" + then "Table" + elseif h.kind == "chair" then "Chair" + else "Decor_" .. (h.k or "") + local src = templates and templates:FindFirstChild(name) + addPiece(h.kind, 0, if src and src:IsA("Model") then src else nil, nil) + else + local function addExisting(kind: string, i: number) + local m = itemModel(kind, i) + local x, z, f, r = spot(layout, kind, i) + if m and x then + addPiece(kind, i, m, placeCF(o, x, z :: number, f :: number, r :: number)) + hideModel(m) + end end - if mine then + addExisting(h.kind, h.i) + if h.kind == "table" then + local attached: { number } = Floor.chairsByTable(layout)[h.i] or {} + for _, ci in attached do + addExisting("chair", ci) + end + end + end + ghost.Parent = workspace + end + + -- 지금 들고 있는 물건을 target 자리에 둔 배치(검사 없이)와 새 물건 번호 + local function preview( + h: Hold, + layout: Floor.Layout, + t: { x: number, z: number, f: number } + ): (Floor.Layout?, number?) + if h.new then + return Floor.applyAdd(layout, { kind = h.kind, k = h.k, x = t.x, z = t.z, f = t.f, r = h.r }) + end + return Floor.applyMove(layout, { kind = h.kind, i = h.i, x = t.x, z = t.z, f = t.f, r = h.r }), h.i + end + + local function drawPlates(o: CFrame, test: Floor.Layout, h: Hold, index: number?) + for _, p in plates do + p:Destroy() + end + table.clear(plates) + local mine: { [string]: boolean } = {} + for _, pc in pieces do + mine[`{pc.kind}:{if h.new then index or 0 else pc.index}`] = true + end + for _, pc in Floor.pieces(test) do + if mine[`{pc.kind}:{pc.index}`] then local r = pc.rect local p = Instance.new("Part") - p.Name = "Ghost" + p.Name = "Plate" p.Anchored = true p.CanCollide = false p.CanQuery = false p.CanTouch = false p.CastShadow = false - p.Material = Enum.Material.SmoothPlastic - p.Color = if ok then GOOD else BAD - p.Transparency = 0.35 - p.Size = Vector3.new(math.max(0.2, r.x1 - r.x0), 0.3, math.max(0.2, r.z1 - r.z0)) - p.CFrame = o * CFrame.new((r.x0 + r.x1) / 2, floorY(r.f) + 0.3, (r.z0 + r.z1) / 2) - p.Parent = world - table.insert(ghostParts, p) + p.Material = Enum.Material.Neon + p.Color = if valid then GOOD else BAD + p.Transparency = 0.55 + p.Size = Vector3.new(math.max(0.2, r.x1 - r.x0), 0.12, math.max(0.2, r.z1 - r.z0)) + p.CFrame = o * CFrame.new((r.x0 + r.x1) / 2, floorY(r.f) + 0.08, (r.z0 + r.z1) / 2) + p.Parent = ghost + table.insert(plates, p) end end end - local function itemName(s: Selection, layout: Floor.Layout): (string, string) - if s.kind == "stove" then - return L("stoveObject"), "flame" - elseif s.kind == "table" then - return `{L("thing_Table")} {s.i}`, "table" - elseif s.kind == "chair" then - return L("thing_Seat"), Info.SEAT_ICON - end - local d = layout.decor[s.i] - local k = if d then d.k else "" - return L("decor_" .. k), Info.DECOR_ICON[k] or "sparkle" - end - - local function place(o: GuiObject, r: Layout.Rect) - o.AnchorPoint = Vector2.new(0.5, 0.5) - o.Position = UDim2.fromOffset(r.x + r.w / 2, r.y + r.h / 2) - o.Size = UDim2.fromOffset(r.w, r.h) - end - - -- 화면 다시 그리기(안내 글, 버튼, 바닥 판) + -- 안내 글과 버튼 local function redraw() - local layout = Info.layout(state) - local st = stage() exitLabel.Text = L("exit") - floorBtn.button.Visible = st >= 3 - floorLabel.Text = L("floorN", { n = 3 - floorNow }) rotateLabel.Text = L("rotate") cancelLabel.Text = L("cancel") okLabel.Text = L("placeIt") - for s = 1, 4 do - sideLabels[s].Text = L(`side_{s}`) - end - local s = sel - local kind = if s then s.kind else "" - local isChair = kind == "chair" - rotateBtn.button.Visible = kind == "stove" or kind == "decor" - for i, b in sideBtns do - b.button.Visible = isChair - local side = if pending and pending.kind == "chair" - then pending.x - elseif s and isChair and layout.chairs[s.i] then layout.chairs[s.i].s - else 0 - b.setColor(if i == side then Theme.ORANGE else Theme.lighten(Theme.ORANGE, 0.45)) - end - cancelBtn.button.Visible = pending ~= nil - okBtn.button.Visible = s ~= nil - okBtn.setColor(if pending and valid then Theme.MINT else Theme.GRAY) - - -- 안내 글 + local h = hold + local layout = curLayout() + rotateBtn.button.Visible = h ~= nil and not (h.new and h.kind == "table") + cancelBtn.button.Visible = h ~= nil + okBtn.button.Visible = h ~= nil + okBtn.setColor(if h and valid then Theme.MINT else Theme.GRAY) local text: string local color = Theme.MINT if message then text = message color = Theme.ORANGE - elseif not s then + elseif not h then text = L("decoPick") infoIcon.set("hand") - elseif pending and not valid then + elseif not valid then text = L("why_" .. (why or "none")) color = Theme.RED - elseif pending then - text = L("decoOk") else - text = if isChair then L("decoChair") else L("decoMove") + text = L("decoOk") end - if s then - local name, icon = itemName(s, layout) + if h then + local name, icon = itemName(h, layout) infoIcon.set(icon) + local c = cost(h) + if c then + name = `{name} {Locale.number(c)}` + end text = `{name} · {text}` + if UserInputService.KeyboardEnabled and not message then + text ..= " " .. L("decoKeys") + end end infoText.Text = text infoText.TextColor3 = if color == Theme.RED then Theme.edge(Theme.RED) else Theme.TEXT infoStroke.Color = Theme.edge(color) - - -- 고른 물건 빛, 바닥 판 - highlight.Adornee = if s then itemModel(s.kind, s.i) else nil - if pending then - drawGhost(applyMove(layout, pending), pending, valid) - else - clearGhost() - end + highlight.FillColor = if valid then GOOD else BAD + highlight.OutlineColor = if valid then Theme.WHITE else BAD end - -- 옮길 자리 정하기(검사 포함) - local function setPending(m: Floor.Move?) - pending = m - message = nil - if m then - local layout = Info.layout(state) - local cur = sel and currentMove(layout, sel) - -- 제자리면 옮길 것 없음 - if cur and cur.x == m.x and cur.z == m.z and (cur.f or 1) == (m.f or 1) and (cur.r or 0) == (m.r or 0) then - pending = nil - else - local ok, reason = Floor.move(layout, stage(), m) - valid = ok ~= nil - why = reason + -- 캐릭터 앞 자리 계산 → 바뀌면 다시 검사 + local lastKey = "" + local function update(force: boolean?) + local h = hold + local o = origin() + local char = player.Character + local rootPart = char and char:FindFirstChild("HumanoidRootPart") :: BasePart? + if not h or not o or not rootPart then + return + end + local layout = curLayout() + local lp = o:PointToObjectSpace(rootPart.Position) + local look = o:VectorToObjectSpace(rootPart.CFrame.LookVector) + local flat = Vector2.new(look.X, look.Z) + flat = if flat.Magnitude > 1e-3 then flat.Unit else Vector2.new(0, -1) + local dist = holdDistance(h, layout) + local f = if stage() >= 3 and lp.Y > Floor.BASE_Y + Floor.FLOOR2_Y - 4 then 2 else 1 + local t = { x = snap(lp.X + flat.X * dist), z = snap(lp.Z + flat.Y * dist), f = f } + local key = `{t.x},{t.z},{t.f},{h.r}` + if key == lastKey and not force then + return + end + lastKey = key + target = t + local test, index = preview(h, layout, t) + if not test then + valid, why = false, "none" + elseif h.kind == "stove" and f == 2 then + valid, why = false, "floor" + else + why = Floor.validate(test, stage()) + valid = why == nil + local c = cost(h) + if valid and c and Info.attr(state, "Money", 0) < c then + valid, why = false, "money" end end - redraw() - end - - local function choose(s: Selection?) - sel = s - dragging = false - setPending(nil) - end - - -- 지금 옮기려는 모양(없으면 지금 자리) - local function base(): Floor.Move? - if pending then - return table.clone(pending) - end - local s = sel - return if s then currentMove(Info.layout(state), s) else nil - end - - local function floorPoint(sx: number, sy: number): Vector2? - local o = origin() - local camera = workspace.CurrentCamera - if not o or not camera then - return nil - end - local ray = camera:ScreenPointToRay(sx, sy) - local n = o.UpVector - local p0 = (o * CFrame.new(0, floorY(floorNow), 0)).Position - local denom = ray.Direction:Dot(n) - if math.abs(denom) < 1e-4 then - return nil - end - local t = (p0 - ray.Origin):Dot(n) / denom - if t < 0 then - return nil - end - local hit = o:PointToObjectSpace(ray.Origin + ray.Direction * t) - return Vector2.new(hit.X, hit.Z) - end - - local function pickItem(sx: number, sy: number): Selection? - local camera = workspace.CurrentCamera - if not camera then - return nil - end - local layout = Info.layout(state) - local list: { Instance } = {} - local up = plot:FindFirstChild("Upgrades") - local furniture = up and up:FindFirstChild("Furniture") - if furniture then - for _, d in furniture:GetDescendants() do - local kind = d:GetAttribute("ItemKind") - local i = d:GetAttribute("ItemIndex") - if - d:IsA("Model") - and typeof(kind) == "string" - and typeof(i) == "number" - and itemFloor(layout, kind, i) == floorNow - then - table.insert(list, d) + -- 미리보기 모형 옮기기 + if test then + for _, pc in pieces do + local idx = if h.new then index or 0 else pc.index + local x, z, pf, r = spot(test, pc.kind, idx) + if x then + local to = placeCF(o, x, z :: number, pf :: number, r :: number) + pc.clone:PivotTo(if pc.from then to * pc.from:Inverse() * pc.pivot else to) end end + drawPlates(o, test, h, index) end - if floorNow == 1 then - local stall = itemModel("stove", 1) - if stall then - table.insert(list, stall) - end - end - local params = RaycastParams.new() - params.FilterType = Enum.RaycastFilterType.Include - params.FilterDescendantsInstances = list - local ray = camera:ScreenPointToRay(sx, sy) - local res = workspace:Raycast(ray.Origin, ray.Direction * 1000, params) - local inst: Instance? = res and res.Instance - while inst and inst ~= plot do - local kind = inst:GetAttribute("ItemKind") - local i = inst:GetAttribute("ItemIndex") - if inst:IsA("Model") and typeof(kind) == "string" and typeof(i) == "number" then - return { kind = kind, i = i } - end - inst = inst.Parent - end - return nil - end - - local function moveTo(p: Vector2) - local m = base() - if not m or m.kind == "chair" then - return - end - m.x = snap(p.X + dragOffset.X) - m.z = snap(p.Y + dragOffset.Y) - m.f = if m.kind == "stove" then 1 else floorNow - setPending(m) - end - - -- 누르기: 물건이면 고르기(의자를 고른 상태에서 테이블이면 그 테이블로), 바닥이면 옮기기 - local function press(sx: number, sy: number) - local hit = pickItem(sx, sy) - local s = sel - if hit and s and s.kind == "chair" and hit.kind == "table" then - local m = base() - if m then - m.z = hit.i - setPending(m) - end - return - end - if hit and s and hit.kind == s.kind and hit.i == s.i and s.kind ~= "chair" then - -- 고른 물건을 다시 누르면 끌어서 옮기기 - local p = floorPoint(sx, sy) - local m = base() - if p and m then - dragOffset = Vector2.new(m.x - p.X, m.z - p.Y) - dragging = true - end - return - end - if hit then - choose(hit) - return - end - if s and s.kind ~= "chair" then - local p = floorPoint(sx, sy) - if p then - dragOffset = Vector2.zero - moveTo(p) - dragging = true - end - end + redraw() end local function showMessage(text: string) @@ -537,189 +485,231 @@ function Decorate.build(parent: Instance, state: Instance, plot: Model, send: (s end) end - local function close() + local renderConn: RBXScriptConnection? = nil + + local function close(placed: string?) if not isOpen then return end isOpen = false gui.Enabled = false - for _, c in openConns do - c:Disconnect() - end - table.clear(openConns) - sel = nil - pending = nil - dragging = false + hold = nil + target = nil clearGhost() - highlight.Adornee = nil - world.Parent = nil - unhideAll() - local camera = workspace.CurrentCamera - if camera and saved then - camera.FieldOfView = saved.fov - camera.CameraType = saved.kind + if renderConn then + renderConn:Disconnect() + renderConn = nil end - saved = nil for _, fn in closeFns do - fn() + fn(placed) end end + local function beginHold(h: Hold) + hold = h + valid = false + why = nil + message = nil + lastKey = "" + buildGhost(h) + update(true) + end + local function open() - if isOpen or not origin() then + if isOpen then return end isOpen = true - floorNow = 1 - sel = nil - pending = nil - message = nil - local camera = workspace.CurrentCamera - if camera then - saved = { kind = camera.CameraType, fov = camera.FieldOfView } - end - world.Parent = workspace gui.Enabled = true - hideAll() - placeCamera() - local up = plot:FindFirstChild("Upgrades") - if up then - -- 서버가 건물·가구를 다시 지으면 새 부품도 숨기고, 고른 물건 빛을 새 모델에 붙입니다. - table.insert( - openConns, - up.DescendantAdded:Connect(function(d) - task.defer(function() - local o = origin() - if isOpen and o and d:IsA("BasePart") and d.Parent then - hideCheck(d, o) - end - if isOpen and d:IsA("Model") then - redraw() - end - end) - end) - ) - end - if camera then - table.insert(openConns, camera:GetPropertyChangedSignal("ViewportSize"):Connect(placeCamera)) - end - redraw() + renderConn = RunService.RenderStepped:Connect(function() + update() + end) for _, fn in openFns do fn() end end - -- 입력 + local function start(kind: string, k: string?) + if not origin() then + return + end + open() + if kind == "move" then + hold = nil + clearGhost() + redraw() + else + -- 새 의자는 캐릭터가 보는 쪽(앞의 테이블 쪽)을 보게 들고 시작합니다. + local r = 0 + local o = origin() + local char = player.Character + local rootPart = char and char:FindFirstChild("HumanoidRootPart") :: BasePart? + if kind == "chair" and o and rootPart then + local look = o:VectorToObjectSpace(rootPart.CFrame.LookVector) + local best = -math.huge + for cr = 0, 3 do + local fx, fz = Floor.facing(cr) + local d = fx * look.X + fz * look.Z + if d > best then + best, r = d, cr + end + end + end + beginHold({ new = true, kind = kind, k = k, i = 0, r = r }) + end + end + + -- 옮길 물건 고르기(누른 곳의 내 가게 물건) + -- screen = true면 상단 바를 뺀 화면 좌표(터치), 아니면 뷰포트 좌표(마우스) + local function pickItem(sx: number, sy: number, screen: boolean): (string?, number?) + local camera = workspace.CurrentCamera + if not camera then + return nil, nil + end + local list: { Instance } = {} + local up = plot:FindFirstChild("Upgrades") + local furniture = up and up:FindFirstChild("Furniture") + if furniture then + for _, d in furniture:GetChildren() do + if d:IsA("Model") and typeof(d:GetAttribute("ItemKind")) == "string" then + table.insert(list, d) + end + end + end + local stall = itemModel("stove", 1) + if stall then + table.insert(list, stall) + end + local params = RaycastParams.new() + params.FilterType = Enum.RaycastFilterType.Include + params.FilterDescendantsInstances = list + local ray = if screen then camera:ScreenPointToRay(sx, sy) else camera:ViewportPointToRay(sx, sy) + local res = workspace:Raycast(ray.Origin, ray.Direction * 1000, params) + local inst: Instance? = res and res.Instance + while inst and inst ~= plot do + if inst == stall then + return "stove", 1 + end + local kind = inst:GetAttribute("ItemKind") + local i = inst:GetAttribute("ItemIndex") + if inst:IsA("Model") and typeof(kind) == "string" and typeof(i) == "number" then + return kind, i + end + inst = inst.Parent + end + return nil, nil + end + + local function tryPick(sx: number, sy: number, screen: boolean) + if not isOpen or hold then + return + end + local kind, i = pickItem(sx, sy, screen) + if kind and i then + local layout = curLayout() + local _, _, _, r = spot(layout, kind, i) + beginHold({ new = false, kind = kind, i = i, r = if kind == "table" then 0 else r or 0 }) + end + end + + local function rotate() + local h = hold + if h and not (h.new and h.kind == "table") then + h.r = (h.r + 1) % 4 + update(true) + end + end + + local function placeNow() + local h = hold + local t = target + if not h or not t then + return + end + if not valid then + -- 왜 안 되는지 한 번 더 크게 보여 줍니다. + showMessage(L("why_" .. (why or "none"))) + return + end + if h.new then + send("buyAt", { kind = h.kind, k = h.k, x = t.x, z = t.z, f = t.f, r = h.r }) + close("new") + else + send("move", { kind = h.kind, i = h.i, x = t.x, z = t.z, f = t.f, r = h.r }) + -- 옮기기는 계속 다른 물건을 고를 수 있게 고르기로 돌아갑니다. + hold = nil + target = nil + clearGhost() + redraw() + end + end + + local function cancel() + if hold and not hold.new then + hold = nil + target = nil + clearGhost() + redraw() + else + close(nil) + end + end + + -- 입력: 누르기(옮길 물건 고르기), R 돌리기, F 놓기 table.insert( conns, UserInputService.InputBegan:Connect(function(io: InputObject, processed: boolean) if not isOpen or processed then return end - local t = io.UserInputType - if t == Enum.UserInputType.MouseButton1 or t == Enum.UserInputType.Touch then - press(io.Position.X, io.Position.Y) + if io.UserInputType == Enum.UserInputType.MouseButton1 then + local p = UserInputService:GetMouseLocation() + tryPick(p.X, p.Y, false) + elseif io.KeyCode == Enum.KeyCode.R then + rotate() + elseif io.KeyCode == Enum.KeyCode.F then + placeNow() end end) ) table.insert( conns, - UserInputService.InputChanged:Connect(function(io: InputObject) - if not isOpen or not dragging then - return - end - local t = io.UserInputType - if t == Enum.UserInputType.MouseMovement or t == Enum.UserInputType.Touch then - local p = floorPoint(io.Position.X, io.Position.Y) - if p then - moveTo(p) - end + UserInputService.TouchTapInWorld:Connect(function(pos: Vector2, processed: boolean) + if not processed then + tryPick(pos.X, pos.Y, true) end end) ) table.insert( conns, - UserInputService.InputEnded:Connect(function(io: InputObject) - local t = io.UserInputType - if t == Enum.UserInputType.MouseButton1 or t == Enum.UserInputType.Touch then - dragging = false - end - end) - ) - table.insert(conns, exitBtn.button.Activated:Connect(close)) - table.insert( - conns, - floorBtn.button.Activated:Connect(function() - floorNow = 3 - floorNow - hideAll() - placeCamera() - -- 테이블·소품을 고른 채로 층을 바꾸면 그 층으로 옮기기 - local m = base() - if m and (m.kind == "table" or m.kind == "decor") then - m.f = floorNow - setPending(m) - else - redraw() - end - end) - ) - table.insert( - conns, - rotateBtn.button.Activated:Connect(function() - local m = base() - if m then - m.r = ((m.r or 0) + 1) % 4 - setPending(m) - end - end) - ) - for s, b in sideBtns do - table.insert( - conns, - b.button.Activated:Connect(function() - local m = base() - if m and m.kind == "chair" then - m.x = s - setPending(m) - end - end) - ) - end - table.insert( - conns, - cancelBtn.button.Activated:Connect(function() - setPending(nil) - end) - ) - table.insert( - conns, - okBtn.button.Activated:Connect(function() - local m = pending - if m and valid then - send("move", { kind = m.kind, i = m.i, x = m.x, z = m.z, f = m.f, r = m.r }) - pending = nil - redraw() - end + exitBtn.button.Activated:Connect(function() + close(nil) end) ) + table.insert(conns, rotateBtn.button.Activated:Connect(rotate)) + table.insert(conns, cancelBtn.button.Activated:Connect(cancel)) + table.insert(conns, okBtn.button.Activated:Connect(placeNow)) table.insert( conns, state.AttributeChanged:Connect(function(key: string) if not isOpen then return end - if key == "Layout" or key == "Stage" then - local s = sel - -- 물건이 없어졌으면 고르기 해제 - if s and not currentMove(Info.layout(state), s) then - sel = nil + if key == "Layout" or key == "Stage" or key == "Money" or key == "Seats" or key == "Tables" then + if key == "Layout" then + layoutNow = Info.layout(state) end - if stage() < 3 and floorNow == 2 then - floorNow = 1 - hideAll() - placeCamera() + local h = hold + -- 옮기던 물건이 없어졌으면 내려놓기 + if h and not h.new and not spot(curLayout(), h.kind, h.i) then + hold = nil + clearGhost() + elseif h and not h.new and key == "Layout" then + -- 서버가 가구를 다시 지었으면 새 모형을 다시 숨기고 미리보기를 새로 만듭니다. + buildGhost(h) end - setPending(pending) + update(true) + redraw() elseif key == "Lang" then redraw() end @@ -728,11 +718,16 @@ function Decorate.build(parent: Instance, state: Instance, plot: Model, send: (s return { gui = gui, - open = open, - close = close, + start = start, + close = function() + close(nil) + end, isOpen = function() return isOpen end, + holding = function() + return hold ~= nil + end, onOpen = function(fn) table.insert(openFns, fn) end, @@ -743,15 +738,16 @@ function Decorate.build(parent: Instance, state: Instance, plot: Model, send: (s scale.Scale = lay.scale root.Size = UDim2.fromOffset(math.ceil(lay.width), math.ceil(lay.height)) local d = lay.deco - place(exitBtn.button, d.exit) - place(floorBtn.button, d.floor) - place(infoBox, d.info) - place(rotateBtn.button, d.tools[4]) - place(cancelBtn.button, d.tools[5]) - place(okBtn.button, d.tools[6]) - for s, b in sideBtns do - place(b.button, d.tools[s]) + local function place(o: GuiObject, r: Layout.Rect) + o.AnchorPoint = Vector2.new(0.5, 0.5) + o.Position = UDim2.fromOffset(r.x + r.w / 2, r.y + r.h / 2) + o.Size = UDim2.fromOffset(r.w, r.h) end + place(exitBtn.button, d.exit) + place(infoBox, d.info) + place(rotateBtn.button, d.tools[1]) + place(cancelBtn.button, d.tools[2]) + place(okBtn.button, d.tools[3]) end, notify = function(key: string, args: { [string]: any }?) if isOpen then @@ -759,11 +755,11 @@ function Decorate.build(parent: Instance, state: Instance, plot: Model, send: (s end end, destroy = function() - close() + close(nil) for _, c in conns do c:Disconnect() end - world:Destroy() + ghost:Destroy() gui:Destroy() end, } diff --git a/bunsik-tycoon/src/client/Hud.luau b/bunsik-tycoon/src/client/Hud.luau index 7f8676f..54a0708 100644 --- a/bunsik-tycoon/src/client/Hud.luau +++ b/bunsik-tycoon/src/client/Hud.luau @@ -1,6 +1,6 @@ --!strict --- 화면 UI: 돈, 손에 든 접시, 다음 업그레이드 막대, 상점·2배 수익·돈 부스트 버튼, 홍보·손님 러시 버튼, 설정, --- 튜토리얼 말풍선, 알림, 그리고 창(상점 탭 4개, 설정, 요리, 홍보 확인). +-- 화면 UI: 돈, 손에 든 접시, 상점·가게 꾸미기·2배 수익·돈 부스트 버튼, 홍보·손님 러시 버튼, 설정, +-- 튜토리얼 말풍선(아래 가운데), 알림, 그리고 창(상점 탭 3개, 가게 꾸미기, 설정, 요리, 홍보 확인). -- 모양은 Theme("사탕" 스타일), 배치는 Layout, 상점 창은 ShopWindow, 요리 창은 Kitchen 모듈. -- 상태는 `state` 인스턴스(실제 게임에서는 Player)의 속성에서 읽습니다. 서버에서도 만들 수 있어서 원격 테스트로 검사합니다. @@ -27,10 +27,11 @@ export type HudHandle = { -- UI가 쓸 수 있는 화면 크기(픽셀, 상단 바 제외)와 터치 화면 여부로 배치를 다시 잡습니다. setLayout: (size: Vector2, touch: boolean) -> (), layout: () -> Layout.Result, - -- "shop"(tab: "upgrade"/"decor"/"staff"/"mine"), "settings", "kitchen", "promote", nil(닫기) + -- "shop"(tab: "upgrade"/"staff"/"mine"), "decor"(가게 꾸미기 창), "settings", "kitchen", "promote", nil(닫기) open: (which: string?, tab: string?) -> (), menuOpen: () -> boolean, -- 창이 열려 있으면 true(마우스 커서를 풀어 줌) - onDecorate: (fn: () -> ()) -> (), -- 상점 창 [배치하기]를 눌렀을 때 + -- 가게 꾸미기 창에서 물건(kind = "table"/"chair"/"decor", k = 소품 종류)이나 [옮기기](kind = "move")를 골랐을 때 + onDecorate: (fn: (kind: string, k: string?) -> ()) -> (), kitchen: Kitchen.KitchenHandle, shop: ShopWindow.Handle, destroy: () -> (), @@ -73,6 +74,7 @@ local TOAST_STYLE: { [string]: { icon: string, color: Color3 } } = { kickOwn = { icon = "store", color = Theme.GRAY }, rushOn = { icon = "bolt", color = Theme.YELLOW }, boostGot = { icon = "bolt", color = Theme.YELLOW }, + doubleOwned = { icon = "moneyBag", color = Theme.LAVENDER }, guestBonus = { icon = "coin", color = Theme.MINT }, guestArrived = { icon = "customer", color = Theme.SKY }, guestSeated = { icon = "customer", color = Theme.SKY }, @@ -215,52 +217,18 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () list.SortOrder = Enum.SortOrder.LayoutOrder list.Parent = toasts - -- 다음 업그레이드 막대(아래): 아이콘 동그라미, 이름, 진행 막대, [사기] - local card = Theme.frame(root, "Next") - local cardBody = Theme.frame(card, "Body", Theme.WHITE) - cardBody.Size = UDim2.fromScale(1, 1) - Theme.corner(cardBody, 26) - local cardStroke = Theme.stroke(cardBody, Theme.edge(Theme.PINK), 4) - local iconBox = Theme.frame(cardBody, "IconBox", Theme.PINK) - iconBox.AnchorPoint = Vector2.new(0, 0.5) - iconBox.Position = UDim2.new(0, 10, 0.5, 0) - iconBox.Size = UDim2.fromOffset(64, 64) - Theme.round(iconBox) - Theme.gradient(iconBox, Color3.fromRGB(255, 236, 242), Color3.fromRGB(255, 205, 220)) - Theme.stroke(iconBox, Theme.lighten(Theme.PINK, 0.3), 3) - local itemImg = Info.glyph(iconBox, "Icon", "table") - Theme.place(itemImg.frame, 0.5, 0.5, 0.86, 0.86) - local cardTitle = Theme.text(cardBody, "Title") - cardTitle.TextXAlignment = Enum.TextXAlignment.Left - cardTitle.Position = UDim2.fromOffset(84, 10) - cardTitle.Size = UDim2.new(1, -236, 0, 30) - local bar = Theme.frame(cardBody, "Bar", Color3.fromRGB(240, 228, 236)) - bar.Position = UDim2.fromOffset(84, 46) - bar.Size = UDim2.new(1, -236, 0, 26) - Theme.round(bar) - Theme.stroke(bar, Theme.LINE, 2) - local barFill = Theme.frame(bar, "Fill", Theme.MINT) - barFill.Size = UDim2.fromScale(0, 1) - Theme.round(barFill) - Theme.gradient(barFill, Color3.fromRGB(120, 235, 170), Theme.MINT) - local cardCost = Theme.text(bar, "Cost", Theme.edge(Theme.MINT), true) - cardCost.Position = UDim2.fromOffset(8, 2) - cardCost.Size = UDim2.new(1, -16, 1, -4) - cardCost.ZIndex = 3 - local buy, buyLabel = Theme.textButton(card, "Buy", Theme.MINT, 22) - buy.button.AnchorPoint = Vector2.new(0.5, 0.5) - buy.button.ZIndex = 3 - local pointer = Theme.icon(card, "Pointer", "hand") + -- 튜토리얼 손가락: 3단계에서 [가게 꾸미기] 버튼을 가리킵니다. + local pointer = Theme.icon(root, "Pointer", "hand") pointer.Size = UDim2.fromOffset(56, 56) - pointer.AnchorPoint = Vector2.new(0.5, 1) - pointer.Rotation = 180 + pointer.AnchorPoint = Vector2.new(0.5, 0) pointer.ZIndex = 8 pointer.Visible = false - -- 버튼 묶음: 상점, 2배 수익, 돈 부스트 / 설정(아이콘만) + -- 버튼 묶음: 상점, 가게 꾸미기, 2배 수익, 돈 부스트 / 설정(아이콘만) local listBtn, listLabel = Theme.iconButton(root, "ListButton", Theme.PINK, "cart") local listBadge, listBadgeText = Theme.badge(listBtn.button, "Badge") listBadgeText.Text = "!" + local decoBtn, decoLabel = Theme.iconButton(root, "Decorate", Theme.MINT, "table") local settingsBtn = Theme.button(root, "Settings", Theme.SKY, 20) local gear = Theme.icon(settingsBtn.face, "Icon", "gear") Theme.place(gear, 0.5, 0.5, 0.72, 0.72) @@ -329,14 +297,15 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () dim.ZIndex = 10 dim.Parent = root - -- 상점 창(탭 4개) - local decorateFns: { () -> () } = {} - local shop = ShopWindow.build(root, state, send, function() + -- 상점 창(탭 3개)과 가게 꾸미기 창 + local decorateFns: { (string, string?) -> () } = {} + local shop = ShopWindow.build(root, state, send, function(kind: string, k: string?) for _, fn in decorateFns do - fn() + fn(kind, k) end end) local panel = shop.frame + local decorPanel = shop.decorFrame -- 홍보 확인 창: 광고를 보면 무엇을 받는지 먼저 알려 주고, 고르게 합니다(광고는 늘 선택). local promotePanel = Theme.panel(root, "PromotePanel", Theme.SKY) @@ -416,8 +385,6 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () local screen = Vector2.new(1100, 620) local touch = false local layoutNow: Layout.Result - local buyBob: Tween? = nil - local lastCan = false local function relayout() local dev = attr(state, "Dev", false) == true local lay = Layout.compute(screen.X, screen.Y, touch, dev) @@ -429,8 +396,8 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () place(carry, lay.carry) place(hint, lay.hint) place(toasts, lay.toasts) - place(card, lay.card) place(listBtn.button, lay.list) + place(decoBtn.button, lay.decorate) place(settingsBtn.button, lay.settings) place(passBtn.button, lay.double) place(boostBtn.button, lay.boost) @@ -439,19 +406,15 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () place(settings, lay.settingsPanel) shop.setLayout(lay) kitchen.setLayout(lay) - -- [사기] 버튼은 막대 안 좌표로 - local b = lay.buy - if buyBob then - buyBob:Cancel() - buyBob = nil + -- 튜토리얼 손가락은 [가게 꾸미기] 버튼 바로 아래(휴대폰) 또는 오른쪽(PC)에서 버튼을 가리킵니다. + local d = lay.decorate + if lay.touch then + pointer.Rotation = 0 + pointer.Position = UDim2.fromOffset(d.x + d.w / 2, d.y + d.h + 2) + else + pointer.Rotation = -90 + pointer.Position = UDim2.fromOffset(d.x + d.w + 34, d.y + d.h / 2 - 28) end - buy.button.Position = UDim2.fromOffset(b.x - lay.card.x + b.w / 2, b.y - lay.card.y + b.h / 2) - buy.button.Size = UDim2.fromOffset(b.w, b.h) - -- 살 수 있을 때만 [사기] 버튼이 둥실거림(늘 보이는 것 중 움직이는 것은 이것 하나) - if lastCan then - buyBob = keep(Theme.bob(buy.button, 4, 0.8)) - end - pointer.Position = UDim2.fromOffset(b.x - lay.card.x + b.w / 2, b.y - lay.card.y - 2) local r = lay.rows place(promoteWin, lay.confirm) for _, c in { setPanel.close, promotePanel.close } do @@ -498,7 +461,6 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () end local lastMoney: number? = nil - local nextOffer: Economy.Offer? = nil -- 돈이 늘면 "+N"이 떠오르고 돈 알약이 통 튑니다. local function moneyPop(gain: number) @@ -573,36 +535,11 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () end carry.Size = UDim2.fromOffset(stats.carry * 42 + 20, layoutNow.carry.h) - -- 다음 추천: 지금 살 수 있는 것 중 가장 싼 것(갈래 다음 단계, 의자, 테이블) + -- 지금 살 수 있는 것 중 가장 싼 것(갈래 다음 단계, 의자, 테이블). 살 수 있으면 상점 버튼에 ! 배지 local offer = Economy.offers(levels, tables, seats)[1] - nextOffer = offer - local can = false - if offer then - cardTitle.Text = Info.offerName(lang(), levels, offer) - cardCost.Text = `{Locale.number(math.min(m, offer.cost))} / {Locale.number(offer.cost)}` - barFill.Size = UDim2.fromScale(if offer.cost > 0 then math.clamp(m / offer.cost, 0, 1) else 1, 1) - barFill.Visible = m > 0 or offer.cost == 0 - itemImg.set(Info.offerIcon(levels, offer)) - can = m >= offer.cost - buyLabel.Text = L("buy") - buy.setColor(if can then Theme.MINT else Theme.GRAY) - buy.button.Visible = true - else - cardTitle.Text = L("maxed") - cardCost.Text = "" - barFill.Size = UDim2.fromScale(1, 1) - barFill.Visible = true - itemImg.set("star") - buy.button.Visible = false - end - cardStroke.Color = if can then Theme.edge(Theme.MINT) else Theme.edge(Theme.PINK) - if can ~= lastCan then - lastCan = can - relayout() - end - listBadge.Visible = can + listBadge.Visible = offer ~= nil and m >= offer.cost - -- 튜토리얼 안내 + -- 튜토리얼 안내(아래 가운데 말풍선) local tut = attr(state, "Tut", 0) if tut == 1 or tut == 2 or tut == 3 then hint.Visible = true @@ -610,7 +547,7 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () else hint.Visible = false end - pointer.Visible = tut == 3 and offer ~= nil + pointer.Visible = tut == 3 if (layoutNow.rows.devY ~= nil) ~= (attr(state, "Dev", false) == true) then relayout() @@ -621,6 +558,7 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () end listLabel.Text = L("btnShop") + decoLabel.Text = L("btnDecorate") setPanel.title.Text = L("settings") langLabel.Text = L("language") local current = attr(state, "LangSetting", "") @@ -715,6 +653,11 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () else shop.close() end + if which == "decor" then + shop.openDecor() + else + shop.closeDecor() + end settings.Visible = which == "settings" promoteWin.Visible = which == "promote" if which == "kitchen" then @@ -730,7 +673,7 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () end end kitchen.onClose(function() - if not panel.Visible and not settings.Visible and not promoteWin.Visible then + if not panel.Visible and not decorPanel.Visible and not settings.Visible and not promoteWin.Visible then dim.Visible = false end end) @@ -765,14 +708,12 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () local function on(sig: RBXScriptSignal, fn: (...any) -> ()) table.insert(conns, sig:Connect(fn)) end - on(buy.button.Activated, function() - if nextOffer then - send("buyOffer", nextOffer.id) - end - end) on(listBtn.button.Activated, function() show(if panel.Visible then nil else "shop") end) + on(decoBtn.button.Activated, function() + show(if decorPanel.Visible then nil else "decor") + end) on(dim.Activated, function() -- 요리 중에는 바깥을 눌러도 닫지 않습니다(실수로 닫히지 않게). if not kitchen.isOpen() then @@ -787,9 +728,11 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () show(nil) end) end - on(shop.closeButton.Activated, function() - show(nil) - end) + for _, b in { shop.closeButton, shop.decorCloseButton } do + on(b.Activated, function() + show(nil) + end) + end for l, b in langButtons do on(b.button.Activated, function() send("lang", l) @@ -858,9 +801,9 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () end, open = show, menuOpen = function(): boolean - return panel.Visible or settings.Visible or promoteWin.Visible or kitchen.isOpen() + return panel.Visible or decorPanel.Visible or settings.Visible or promoteWin.Visible or kitchen.isOpen() end, - onDecorate = function(fn: () -> ()) + onDecorate = function(fn: (string, string?) -> ()) table.insert(decorateFns, fn) end, destroy = function() diff --git a/bunsik-tycoon/src/client/Layout.luau b/bunsik-tycoon/src/client/Layout.luau index 9432316..3f141a6 100644 --- a/bunsik-tycoon/src/client/Layout.luau +++ b/bunsik-tycoon/src/client/Layout.luau @@ -2,9 +2,9 @@ -- 화면 UI 배치 계산(로블록스 서비스 없이 숫자만 다룸, lune 단위 테스트로 검사). -- 입력은 UI가 쓸 수 있는 화면 크기(상단 바·노치를 뺀 안전 영역, 픽셀)와 터치 화면 여부입니다. -- 결과 좌표는 기준 단위이고, 화면 픽셀 = 기준 단위 × scale 입니다. --- 배치 원칙(어지럽지 않게): 늘 보이는 것 — 돈(위 가운데), 버튼 3개(상점·2배·부스트)는 한 묶음, --- 손님 버튼 2개(홍보·러시)는 다른 묶음, 설정(오른쪽 위), 다음 업그레이드 막대(아래 가운데), 손에 든 접시(막대 바로 위). --- 나머지는 창으로 엽니다. +-- 배치 원칙(어지럽지 않게): 늘 보이는 것 — 돈(위 가운데), 버튼 4개(상점·가게 꾸미기·2배·부스트)는 한 묶음, +-- 손님 버튼 2개(홍보·러시)는 다른 묶음, 설정(오른쪽 위), 튜토리얼 말풍선(아래 가운데, 튜토리얼 중에만), +-- 손에 든 접시(말풍선 자리 바로 위). 나머지는 창으로 엽니다. -- PC는 상점 묶음을 왼쪽에 세로로, 손님 묶음을 오른쪽에 세로로 둡니다. -- 휴대폰은 상점 묶음을 왼쪽 위에, 손님 묶음을 오른쪽 위(설정 왼쪽)에 가로로 둡니다. -- 터치 화면에서는 로블록스 기본 조이스틱 자리(왼쪽 40% × 아래 2/3)와 점프 버튼 자리(오른쪽 아래)에 @@ -21,28 +21,27 @@ export type Result = { touch: boolean, money: Rect, carry: Rect, - hint: Rect, + hint: Rect, -- 튜토리얼 말풍선(아래 가운데) toasts: Rect, - card: Rect, -- 다음 업그레이드 막대 - buy: Rect, -- 막대 안의 [사기] 버튼(화면 기준 위치) settings: Rect, list: Rect, -- 상점(업그레이드) 버튼 + decorate: Rect, -- 가게 꾸미기 버튼 double: Rect, boost: Rect, promote: Rect, -- 홍보(옆 가게 손님 데려오기) rush: Rect, -- 손님 러시 - panel: Rect, -- 상점 창(탭 4개) + panel: Rect, -- 상점 창(탭 3개), 가게 꾸미기 창(같은 자리) tabs: { Rect }, -- 상점 창 왼쪽 탭 버튼(창 기준) content: Rect, -- 상점 창 안 탭 내용 자리(창 기준). 카드는 이 안을 칸으로 나눠 씁니다 + decorContent: Rect, -- 가게 꾸미기 창 안 카드 자리(창 기준, 탭 없이 넓게) settingsPanel: Rect, kitchen: Rect, -- 요리 창 confirm: Rect, -- 홍보 확인 창(광고 보기 / 그냥 홍보) - -- 꾸미기(배치) 화면. 이때는 다른 UI를 숨기고 캐릭터 조작을 멈춥니다(조이스틱 없음). + -- 꾸미기(놓기) 화면. 다른 UI는 숨기고, 캐릭터는 걸어 다니며 투명 미리보기를 옮깁니다(조이스틱·점프 그대로). deco: { exit: Rect, - floor: Rect, -- 1층/2층 바꾸기 - info: Rect, -- 고른 물건 이름과 안내 글 - tools: { Rect }, -- 아래 버튼 칸 6개(오른쪽부터 확인·취소·돌리기, 의자는 1~4칸에 쪽 버튼) + info: Rect, -- 든 물건 이름·값과 안내 글 + tools: { Rect }, -- 아래 버튼 3개(돌리기·취소·놓기). 휴대폰은 조이스틱과 점프 버튼 사이 }, -- 설정 창 안쪽 줄(설정 창 기준 y) rows: { @@ -58,8 +57,7 @@ export type Result = { Layout.HEADER_H = 58 -- 창 위쪽 색 띠 높이(Theme.panel과 같음) -local CARD_W, CARD_H = 470, 84 -local BUY_W, BUY_H = 132, 64 +local HINT_W, HINT_H = 560, 76 local function rect(x: number, y: number, w: number, h: number): Rect return { x = x, y = y, w = w, h = h } @@ -89,58 +87,65 @@ function Layout.compute(w: number, h: number, touch: boolean, dev: boolean): Res local W, H = w / s, h / s local cx = W / 2 - local money, settings, list, double, boost, promote, rush, hint + local money, settings, list, decorate, double, boost, promote, rush + local topEnd: number -- 위쪽 늘 보이는 것들의 아래 끝 if touch then - money = rect(cx - 125, 6, 250, 54) list = rect(8, 6, 84, 84) - double = rect(100, 10, 76, 76) - boost = rect(184, 10, 76, 76) + decorate = rect(100, 10, 76, 76) + double = rect(184, 10, 76, 76) + boost = rect(268, 10, 76, 76) settings = rect(W - 72, 6, 64, 64) promote = rect(W - 156, 10, 76, 76) rush = rect(W - 240, 10, 76, 76) - local hintW = math.min(600, W - 40) - hint = rect(cx - hintW / 2, 98, hintW, 72) + -- 돈은 왼쪽 묶음과 오른쪽 묶음 사이 가운데 + local mid = (boost.x + boost.w + rush.x) / 2 + money = rect(mid - 125, 6, 250, 54) + topEnd = 94 else money = rect(cx - 140, 8, 280, 58) settings = rect(W - 70, 8, 60, 60) - local top = H / 2 - 170 + local top = H / 2 - 205 list = rect(12, top, 96, 96) - double = rect(18, top + 96 + 20, 84, 84) - boost = rect(18, top + 96 + 20 + 84 + 30, 84, 84) -- 위에 "+금액" 꼬리표가 붙어서 더 띄움 + decorate = rect(18, top + 96 + 16, 84, 84) + double = rect(18, top + 96 + 16 + 84 + 16, 84, 84) + boost = rect(18, top + 96 + 16 + 84 + 16 + 84 + 30, 84, 84) -- 위에 "+금액" 꼬리표가 붙어서 더 띄움 promote = rect(W - 102, H / 2 - 110, 84, 84) rush = rect(W - 102, H / 2 + 10, 84, 84) - local hintW = math.min(620, W - 2 * 130) - hint = rect(cx - hintW / 2, 76, hintW, 72) + topEnd = money.y + money.h end - -- 아래 막대: 터치 화면에서는 점프 버튼 왼쪽까지 밀어 둡니다. - local cardX = cx - CARD_W / 2 + -- 튜토리얼 말풍선(아래 가운데): 터치 화면에서는 점프 버튼 왼쪽까지 밀어 둡니다. + local hintW = math.min(HINT_W, W - 20) + local hintX = cx - hintW / 2 if touch then local zones = Layout.touchZones(w, h) - cardX = math.min(cardX, zones.jump.x / s - 8 - CARD_W) + hintX = math.min(hintX, zones.jump.x / s - 8 - hintW) + else + hintW = math.min(hintW, W - 2 * 130) + hintX = cx - hintW / 2 end - cardX = math.max(cardX, 10) - local card = rect(cardX, H - 8 - CARD_H, CARD_W, CARD_H) - local buy = rect(card.x + CARD_W - 10 - BUY_W, card.y + (CARD_H - BUY_H) / 2, BUY_W, BUY_H) - local carry = rect(card.x + CARD_W / 2 - 90, card.y - 48, 180, 42) + hintX = math.max(hintX, 10) + local hint = rect(hintX, H - 8 - HINT_H, hintW, HINT_H) + local carry = rect(hint.x + hintW / 2 - 90, hint.y - 48, 180, 42) - local toastsTop = hint.y + hint.h + 8 - local toastsW = math.min(480, hint.w) + local toastsTop = topEnd + 8 + local toastsW = math.min(480, W - 2 * 130) local toasts = rect(cx - toastsW / 2, toastsTop, toastsW, math.max(0, carry.y - 6 - toastsTop)) - -- 상점 창: 왼쪽에 큰 탭 버튼 4개(업그레이드·꾸미기·알바생·내 가게), 오른쪽에 탭 내용 + -- 상점 창: 왼쪽에 큰 탭 버튼 3개(업그레이드·알바생·내 가게), 오른쪽에 탭 내용 local pw = if touch then math.min(860, W - 24) else 860 local ph = math.min(if touch then 400 else 500, H - 12) local panel = rect(cx - pw / 2, math.max(6, H * 0.5 - ph / 2), pw, ph) local pad, gap = 14, 8 local tabW = if touch then 96 else 104 local top = Layout.HEADER_H + 10 - local tabH = (ph - top - pad - 3 * gap) / 4 + local tabH = (ph - top - pad - 2 * gap) / 3 local tabs: { Rect } = {} - for i = 1, 4 do + for i = 1, 3 do tabs[i] = rect(pad, top + (i - 1) * (tabH + gap), tabW, tabH) end local content = rect(pad + tabW + 12, top, pw - (pad + tabW + 12) - pad, ph - top - pad) + local decorContent = rect(pad, top, pw - 2 * pad, ph - top - pad) -- 홍보 확인 창 local cw = math.min(480, W - 24) @@ -172,23 +177,24 @@ function Layout.compute(w: number, h: number, touch: boolean, dev: boolean): Res local kh = math.min(if touch then 396 else 480, H - 8) local kitchen = rect(cx - kw / 2, math.max(4, H * 0.5 - kh / 2), kw, kh) - -- 꾸미기 화면: 왼쪽 위 나가기, 오른쪽 위 층 바꾸기, 위 가운데 안내, 아래 버튼 6칸 + -- 꾸미기 화면: 왼쪽 위 나가기, 위 가운데 안내, 아래 버튼 3개(돌리기·취소·놓기) local bs = if touch then 76 else 84 local exit = rect(8, 6, bs, bs) - local floorBtn = rect(W - 8 - bs, 6, bs, bs) - local infoW = math.min(560, W - 2 * (bs + 24)) + local infoW = math.min(600, W - 2 * (bs + 24)) local info = rect(cx - infoW / 2, 8, infoW, if touch then 64 else 70) local toolGap = 10 - local toolsW = 6 * bs + 5 * toolGap + local toolsW = 3 * bs + 2 * toolGap local toolX = cx - toolsW / 2 if touch then - -- 점프 버튼 자리는 피합니다(조이스틱은 조작을 멈춰서 안 보임). + -- 조이스틱(왼쪽 아래)과 점프 버튼(오른쪽 아래) 사이에 둡니다. local zones = Layout.touchZones(w, h) - toolX = math.min(toolX, zones.jump.x / s - 8 - toolsW) + local left = (zones.stick.x + zones.stick.w) / s + 8 + local right = zones.jump.x / s - 8 + toolX = math.clamp((left + right) / 2 - toolsW / 2, left, math.max(left, right - toolsW)) end toolX = math.max(toolX, 8) local tools: { Rect } = {} - for i = 1, 6 do + for i = 1, 3 do tools[i] = rect(toolX + (i - 1) * (bs + toolGap), H - 8 - bs, bs, bs) end @@ -201,10 +207,9 @@ function Layout.compute(w: number, h: number, touch: boolean, dev: boolean): Res carry = carry, hint = hint, toasts = toasts, - card = card, - buy = buy, settings = settings, list = list, + decorate = decorate, double = double, boost = boost, promote = promote, @@ -212,10 +217,11 @@ function Layout.compute(w: number, h: number, touch: boolean, dev: boolean): Res panel = panel, tabs = tabs, content = content, + decorContent = decorContent, settingsPanel = settingsPanel, kitchen = kitchen, confirm = confirm, - deco = { exit = exit, floor = floorBtn, info = info, tools = tools }, + deco = { exit = exit, info = info, tools = tools }, rows = { langButtonH = langButtonH, mouseY = mouseY, diff --git a/bunsik-tycoon/src/client/Main.client.luau b/bunsik-tycoon/src/client/Main.client.luau index 4da3c88..96f09bf 100644 --- a/bunsik-tycoon/src/client/Main.client.luau +++ b/bunsik-tycoon/src/client/Main.client.luau @@ -138,28 +138,26 @@ hud.kitchen.onClose(function() end) Plots.start(world:WaitForChild("Plots"), player, player.UserId, send) --- 꾸미기(배치) 화면: 상점 창 [배치하기]로 열고, 여는 동안은 요리 창처럼 캐릭터 조작을 멈추고 화면 UI를 숨깁니다. +-- 꾸미기(놓기) 화면: [가게 꾸미기] 창에서 물건이나 [옮기기]를 고르면 엽니다. +-- 캐릭터는 걸어 다니며 투명 미리보기를 옮기고, 그동안 다른 화면 UI와 조리대 버튼(E)은 숨깁니다. local deco = Decorate.build(player:WaitForChild("PlayerGui"), player, plot, send) decorate = deco deco.setLayout(hud.layout()) -hud.onDecorate(function() +hud.onDecorate(function(kind: string, k: string?) hud.open(nil) - deco.open() + deco.start(kind, k) end) deco.onOpen(function() hud.gui.Enabled = false ProximityPromptService.Enabled = false - if controls then - controls:Disable() - end end) -deco.onClose(function() +deco.onClose(function(placed: string?) hud.gui.Enabled = true ProximityPromptService.Enabled = true - if controls then - controls:Enable() + -- 새 물건을 놓았으면 더 살 수 있게 가게 꾸미기 창을 다시 엽니다. + if placed == "new" then + hud.open("decor") end - hud.open("shop", "decor") end) Guide.start(player) diff --git a/bunsik-tycoon/src/client/ShopWindow.luau b/bunsik-tycoon/src/client/ShopWindow.luau index de67655..c82f093 100644 --- a/bunsik-tycoon/src/client/ShopWindow.luau +++ b/bunsik-tycoon/src/client/ShopWindow.luau @@ -1,9 +1,10 @@ --!strict --- 상점 창: 왼쪽 큰 탭 버튼 4개와 탭 내용. +-- 상점 창: 왼쪽 큰 탭 버튼 3개와 탭 내용. -- 업그레이드: 갈래(건물·메뉴·판매 금액·손님 속도·화구·쟁반·알바생 기능)마다 카드 한 장. 다음 단계 효과와 값, [사기] --- 꾸미기: 테이블·의자·소품 사기, 큰 [배치하기] 버튼(꾸미기 화면 열기) -- 알바생: 역할(요리·서빙·홍보)별 고용·빼기, 시급 -- 내 가게: 가게 이름, 무지개 이름, 건물 디자인 +-- 가게 꾸미기 창(상점과 따로, 화면의 [가게 꾸미기] 버튼): 테이블·의자·소품 카드와 큰 [옮기기] 버튼. +-- 카드를 누르면 창이 닫히고 그 물건을 투명하게 들고 걸어가서 놓습니다(Decorate). 돈은 놓을 때 나갑니다. -- 카드는 처음에 다 만들어 두고 속성이 바뀌면 글자·색만 바꿉니다. 칸 위치는 탭 내용 자리 비율이라 배치가 바뀌어도 그대로입니다. local ReplicatedStorage = game:GetService("ReplicatedStorage") @@ -20,6 +21,11 @@ local ShopWindow = {} export type Handle = { frame: Frame, closeButton: TextButton, + decorFrame: Frame, -- 가게 꾸미기 창 + decorCloseButton: TextButton, + openDecor: () -> (), + closeDecor: () -> (), + decorOpen: () -> boolean, open: (tab: string?) -> (), close: () -> (), isOpen: () -> boolean, @@ -29,10 +35,9 @@ export type Handle = { destroy: () -> (), } -ShopWindow.TABS = { "upgrade", "decor", "staff", "mine" } +ShopWindow.TABS = { "upgrade", "staff", "mine" } local TAB_INFO: { [string]: { key: string, icon: string, color: Color3 } } = { upgrade = { key = "tabUpgrade", icon = "upgrade", color = Theme.PINK }, - decor = { key = "tabDecor", icon = "table", color = Theme.MINT }, staff = { key = "tabStaff", icon = "chef", color = Theme.ORANGE }, mine = { key = "tabMine", icon = "store", color = Theme.SKY }, } @@ -176,7 +181,13 @@ local function setCard(c: Card, mode: string, cost: number?, can: boolean?, stat end end -function ShopWindow.build(root: Frame, state: Instance, send: (string, any?) -> (), onDecorate: () -> ()): Handle +-- onDecorate(kind, k): 가게 꾸미기 창에서 고른 것. kind = "table" | "chair" | "decor"(k = 소품 종류) | "move"(옮기기) +function ShopWindow.build( + root: Frame, + state: Instance, + send: (string, any?) -> (), + onDecorate: (kind: string, k: string?) -> () +): Handle local function lang(): string return Info.attr(state, "Lang", "ko") end @@ -261,8 +272,12 @@ function ShopWindow.build(root: Frame, state: Instance, send: (string, any?) -> end) end - -- 2) 꾸미기: 왼쪽 큰 [배치하기], 오른쪽 4x2 카드(테이블, 의자, 소품 6개) - local placeBtn = Theme.button(pages.decor, "Place", Theme.MINT, 22) + -- 2) 가게 꾸미기 창: 왼쪽 큰 [옮기기], 오른쪽 4x2 카드(테이블, 의자, 소품 6개) + local decorPanel = Theme.panel(root, "DecorPanel", Theme.MINT) + local decorFrame = decorPanel.frame + local decorPage = Theme.frame(decorPanel.body, "Page_decor") + decorPage.ZIndex = 3 + local placeBtn = Theme.button(decorPage, "Place", Theme.MINT, 22) cell(placeBtn.button, 1, 1, 5, 2, 1, 2) placeBtn.button.ZIndex = 4 local placeIcon = Theme.icon(placeBtn.face, "Icon", "hand") @@ -275,7 +290,7 @@ function ShopWindow.build(root: Frame, state: Instance, send: (string, any?) -> Theme.place(placeCount, 0.5, 0.8, 0.86, 0.1) placeCount.ZIndex = 4 on(placeBtn.button.Activated, function() - onDecorate() + onDecorate("move", nil) end) local decorIds = { "Table", "Seat" } for _, d in Economy.DECOR do @@ -283,7 +298,7 @@ function ShopWindow.build(root: Frame, state: Instance, send: (string, any?) -> end local decorCards: { [string]: Card } = {} for i, id in decorIds do - local c = makeCard(pages.decor, "Decor_" .. id) + local c = makeCard(decorPage, "Decor_" .. id) cell(c.holder, 2 + (i - 1) % 4, 1 + (i - 1) // 4, 5, 2) c.note.Visible = false c.title.Position = UDim2.fromScale(0.5, 0.56) @@ -293,11 +308,11 @@ function ShopWindow.build(root: Frame, state: Instance, send: (string, any?) -> decorCards[id] = c on(c.buy.button.Activated, function() if id == "Table" then - send("buyTable") + onDecorate("table", nil) elseif id == "Seat" then - send("buySeat") + onDecorate("chair", nil) else - send("buyDecor", id) + onDecorate("decor", id) end end) end @@ -583,7 +598,8 @@ function ShopWindow.build(root: Frame, state: Instance, send: (string, any?) -> local layout = Info.layout(state) local seatCap = Economy.seatCap(stats.stage) local tableCap = Economy.tableCap(stats.stage) - placeLabel.Text = L("place") + decorPanel.title.Text = L("decorateTitle") + placeLabel.Text = L("moveItems") placeCount.Text = L("seatsNow", { n = seats, max = seatCap }) local counts: { [string]: number } = {} for _, d in layout.decor do @@ -600,10 +616,10 @@ function ShopWindow.build(root: Frame, state: Instance, send: (string, any?) -> c.title.Text = L("thing_Table") c.tagText.Text = `{tables}/{tableCap}` c.tag.Visible = true - if tables >= tableCap or seats >= seatCap then + if tables >= tableCap then setCard(c, "off", nil, nil, L("full")) else - buyable(c, Economy.tableCost(tables, seats)) + buyable(c, Economy.tableCost(tables)) end elseif id == "Seat" then c.title.Text = L("thing_Seat") @@ -611,8 +627,6 @@ function ShopWindow.build(root: Frame, state: Instance, send: (string, any?) -> c.tag.Visible = true if seats >= seatCap then setCard(c, "off", nil, nil, L("full")) - elseif seats >= tables * Economy.CHAIRS_PER_TABLE then - setCard(c, "off", nil, nil, L("needTable")) else buyable(c, Economy.seatCost(seats + 1)) end @@ -736,7 +750,7 @@ function ShopWindow.build(root: Frame, state: Instance, send: (string, any?) -> end -- 살 수 있는 것이 있는 탭에 ! 배지 tabBadges.upgrade.Visible = refreshUpgrade(levels, stats, money) - tabBadges.decor.Visible = refreshDecor(stats, money) + refreshDecor(stats, money) refreshStaff(stats, money) refreshMine(stats) end @@ -759,11 +773,31 @@ function ShopWindow.build(root: Frame, state: Instance, send: (string, any?) -> page.Position = UDim2.fromOffset(c.x, c.y) page.Size = UDim2.fromOffset(c.w, c.h) end + decorFrame.AnchorPoint = Vector2.new(0.5, 0.5) + decorFrame.Position = frame.Position + decorFrame.Size = frame.Size + decorPanel.close.button.Size = UDim2.fromOffset(lay.rows.closeH, lay.rows.closeH) + local dc = lay.decorContent + decorPage.Position = UDim2.fromOffset(dc.x, dc.y) + decorPage.Size = UDim2.fromOffset(dc.w, dc.h) end return { frame = frame, closeButton = shopPanel.close.button, + decorFrame = decorFrame, + decorCloseButton = decorPanel.close.button, + openDecor = function() + decorFrame.Visible = true + Theme.pop(decorFrame) + refresh() + end, + closeDecor = function() + decorFrame.Visible = false + end, + decorOpen = function() + return decorFrame.Visible + end, open = function(tab: string?) if tab and TAB_INFO[tab] then current = tab diff --git a/bunsik-tycoon/src/server/Game.luau b/bunsik-tycoon/src/server/Game.luau index 4377a3e..33ba52c 100644 --- a/bunsik-tycoon/src/server/Game.luau +++ b/bunsik-tycoon/src/server/Game.luau @@ -524,6 +524,20 @@ local function onAction(player: Player, kind: any, arg: any) if typeof(arg) == "string" and Economy.decor(arg) then controller:buyDecor(arg) end + elseif kind == "buyAt" then + -- 꾸미기 화면에서 정한 자리에 새 물건 사서 놓기: { kind = "table"|"chair"|"decor", k, x, z, f, r } + if typeof(arg) == "table" and (arg.kind == "table" or arg.kind == "chair" or arg.kind == "decor") then + local x, z = num(arg.x), num(arg.z) + local k = if typeof(arg.k) == "string" and Economy.decor(arg.k) then arg.k else nil + if x and z and (arg.kind ~= "decor" or k) then + local itemKind: string = arg.kind + controller:buyItem( + itemKind, + k, + { kind = itemKind, k = k, x = x, z = z, f = num(arg.f), r = num(arg.r) } + ) + end + end elseif kind == "move" then if typeof(arg) == "table" and typeof(arg.kind) == "string" then local i, x, z = num(arg.i), num(arg.x), num(arg.z) @@ -582,8 +596,18 @@ local function onAction(player: Player, kind: any, arg: any) applySettings(player, controller.data) end elseif kind == "pass" then + -- 이미 가진 게임패스(로블록스 소유 확인이 늦었거나, 개발자 테스트로 꺼 둔 경우)면 결제 창 대신 바로 켭니다. if Products.DOUBLE_MONEY_PASS ~= 0 and controller.shop.moneyMult == 1 then - MarketplaceService:PromptGamePassPurchase(player, Products.DOUBLE_MONEY_PASS) + task.spawn(function() + if ownsPass(player, Products.DOUBLE_MONEY_PASS) then + if controllers[player] == controller then + controller:setDouble(true) + controller:notify("doubleOwned") + end + elseif player.Parent then + MarketplaceService:PromptGamePassPurchase(player, Products.DOUBLE_MONEY_PASS) + end + end) end elseif kind == "dev_money" and isDev(player) then controller:addMoney(1000) @@ -592,11 +616,17 @@ local function onAction(player: Player, kind: any, arg: any) elseif kind == "dev_reset" and isDev(player) then resetData(controller.data) local slot = controller.slot - local passes = { rainbow = controller.rainbowOwned, designs = controller.designsOwned } + -- 산 게임패스(2배 수익·무지개·디자인)는 처음부터 해도 그대로 둡니다. + local passes = { + rainbow = controller.rainbowOwned, + designs = controller.designsOwned, + double = controller.shop.moneyMult > 1, + } controller:destroy() local fresh = makeController(player, slot, controller.data) fresh.rainbowOwned = passes.rainbow fresh.designsOwned = passes.designs + fresh.shop.moneyMult = if passes.double then 2 else 1 controllers[player] = fresh placeCharacter(player, fresh) fresh:sync() @@ -662,7 +692,14 @@ end local function onPassBought(player: Player, passId: number, purchased: boolean) local controller = controllers[player] - if not purchased or not controller or passId == 0 then + if not controller or passId == 0 then + return + end + if not purchased then + -- "이미 가지고 있어요" 창을 닫은 경우: 정말 가지고 있으면 켭니다. + if passId == Products.DOUBLE_MONEY_PASS and ownsPass(player, passId) and controllers[player] == controller then + controller:setDouble(true) + end return end if passId == Products.DOUBLE_MONEY_PASS then @@ -682,6 +719,7 @@ end function Game.start() slots = World.build() + PlotBuilder.buildTemplates() task.spawn(function() Npc.preload() Npc.preloadCustomers() diff --git a/bunsik-tycoon/src/server/PlotBuilder.luau b/bunsik-tycoon/src/server/PlotBuilder.luau index 88d3fa3..a6f89ea 100644 --- a/bunsik-tycoon/src/server/PlotBuilder.luau +++ b/bunsik-tycoon/src/server/PlotBuilder.luau @@ -733,10 +733,43 @@ local function tagItem(m: Model, kind: string, index: number) m:SetAttribute("ItemIndex", index) end +-- 놓는 자리 CFrame: 바닥 가운데, r은 90도 단위 회전(Floor.rotate와 같은 방향) +local function turned(base: CFrame, r: number): CFrame + return base * CFrame.Angles(0, r * math.pi / 2, 0) +end + +-- 모델 기준점(WorldPivot)은 놓는 자리입니다. 꾸미기 화면이 이 기준으로 투명 미리보기를 옮깁니다. +local function buildTable(parent: Instance, base: CFrame, i: number): Model + local m = Build.model(parent, "Table" .. i) + tagItem(m, "table", i) + Build.cylinder(m, base * CFrame.new(0, 1.25, 0), 2.5, 0.6, rgb(160, 160, 165)) + Build.cylinder(m, base * CFrame.new(0, 0.1, 0), 0.2, 2.6, rgb(160, 160, 165)) + Build.cylinder(m, base * CFrame.new(0, 2.6, 0), 0.3, Floor.TABLE_SIZE, TABLE_COLORS[(i - 1) % #TABLE_COLORS + 1]) + m.WorldPivot = base + return m +end + +-- 의자: 둥근 방석 + 등받이(앉는 사람 뒤 -Z). base는 이미 돌린 자리(+Z = 보는 쪽) +local function buildChair(parent: Instance, base: CFrame, i: number): Model + local m = Build.model(parent, "Chair" .. i) + tagItem(m, "chair", i) + local color = STOOL_COLORS[(i - 1) % #STOOL_COLORS + 1] + Build.cylinder(m, base * CFrame.new(0, 0.9, 0), 1.8, Floor.CHAIR_SIZE, color) + Build.part(m, { + size = Vector3.new(1.8, 1.7, 0.25), + cf = base * CFrame.new(0, 2.65, -0.85), + color = color, + collide = false, + }) + m.WorldPivot = base + return m +end + local function buildDecor(parent: Instance, base: CFrame, d: Floor.Decor, index: number) local m = Build.model(parent, "Decor" .. index) tagItem(m, "decor", index) - local cf = base * CFrame.Angles(0, d.r * math.pi / 2, 0) + local cf = turned(base, d.r) + m.WorldPivot = cf local function at(x: number, y: number, z: number): CFrame return cf * CFrame.new(x, y, z) end @@ -860,38 +893,42 @@ function PlotBuilder.buildFurniture(refs: BaseRefs, cf: CFrame, layout: Floor.La local folder = refs.furniture folder:ClearAllChildren() for i, t in layout.tables do - local m = Build.model(folder, "Table" .. i) - tagItem(m, "table", i) - local base = PlotBuilder.floorCFrame(cf, t.x, t.z, t.f) - Build.cylinder(m, base * CFrame.new(0, 1.25, 0), 2.5, 0.6, rgb(160, 160, 165)) - Build.cylinder(m, base * CFrame.new(0, 0.1, 0), 0.2, 2.6, rgb(160, 160, 165)) - Build.cylinder( - m, - base * CFrame.new(0, 2.6, 0), - 0.3, - Floor.TABLE_SIZE, - TABLE_COLORS[(i - 1) % #TABLE_COLORS + 1] - ) + buildTable(folder, PlotBuilder.floorCFrame(cf, t.x, t.z, t.f), i) end - for i in layout.chairs do - local p = Floor.chairPos(layout, i) - if p then - local m = Build.model(folder, "Chair" .. i) - tagItem(m, "chair", i) - Build.cylinder( - m, - PlotBuilder.floorCFrame(cf, p.x, p.z, p.f) * CFrame.new(0, 0.9, 0), - 1.8, - Floor.CHAIR_SIZE, - STOOL_COLORS[(i - 1) % #STOOL_COLORS + 1] - ) - end + for i, c in layout.chairs do + buildChair(folder, turned(PlotBuilder.floorCFrame(cf, c.x, c.z, c.f), c.r), i) end for i, d in layout.decor do buildDecor(folder, PlotBuilder.floorCFrame(cf, d.x, d.z, d.f), d, i) end end +-- 꾸미기 화면의 새 물건 미리보기용 모형(ReplicatedStorage.BunsikTemplates). 기준점 = 원점, 회전 0 +-- 이름: Table, Chair, Decor_<소품 종류> +function PlotBuilder.buildTemplates(): Folder + local old = ReplicatedStorage:FindFirstChild("BunsikTemplates") + if old then + old:Destroy() + end + local folder = Instance.new("Folder") + folder.Name = "BunsikTemplates" + buildTable(folder, CFrame.identity, 1).Name = "Table" + buildChair(folder, CFrame.identity, 1).Name = "Chair" + for _, d in Economy.DECOR do + buildDecor(folder, CFrame.identity, { k = d.id, x = 0, z = 0, f = 1, r = 0 }, 0) + local m = folder:FindFirstChild("Decor0") + if m then + m.Name = "Decor_" .. d.id + end + end + for _, m in folder:GetChildren() do + m:SetAttribute("ItemKind", nil) + m:SetAttribute("ItemIndex", nil) + end + folder.Parent = ReplicatedStorage + return folder +end + -- 수레를 배치된 자리로 옮깁니다. function PlotBuilder.placeStall(refs: BaseRefs, cf: CFrame, stove: Floor.Stove) refs.stall:PivotTo(PlotBuilder.stallCFrame(cf, stove)) @@ -1101,25 +1138,23 @@ end -- 손님 의자 위(앉는 위치, 테이블을 봄)와 테이블 위 접시 위치(월드 좌표) function PlotBuilder.seatCFrame(cf: CFrame, layout: Floor.Layout, seat: number): CFrame - local p = Floor.chairPos(layout, seat) local c = layout.chairs[seat] - local t = c and layout.tables[c.t] - if not p or not t then + if not c then return PlotBuilder.floorCFrame(cf, 0, 0, 1) end - local pos = (PlotBuilder.floorCFrame(cf, p.x, p.z, p.f) * CFrame.new(0, 1.8, 0)).Position - local look = (PlotBuilder.floorCFrame(cf, t.x, t.z, t.f) * CFrame.new(0, 1.8, 0)).Position - return CFrame.lookAt(pos, look) + local base = PlotBuilder.floorCFrame(cf, c.x, c.z, c.f) + local fx, fz = Floor.facing(c.r) + return CFrame.lookAt((base * CFrame.new(0, 1.8, 0)).Position, (base * CFrame.new(fx, 1.8, fz)).Position) end +-- 접시는 의자가 보는 쪽 테이블 위(의자에서 2.2 앞) function PlotBuilder.dishCFrame(cf: CFrame, layout: Floor.Layout, seat: number): CFrame local c = layout.chairs[seat] - local t = c and layout.tables[c.t] - local d = c and Floor.SIDES[c.s] - if not t or not d then + if not c then return PlotBuilder.floorCFrame(cf, 0, 0, 1) end - return PlotBuilder.floorCFrame(cf, t.x + d.x * 1.3, t.z + d.z * 1.3, t.f) * CFrame.new(0, 2.75, 0) + local fx, fz = Floor.facing(c.r) + return PlotBuilder.floorCFrame(cf, c.x + fx * 2.2, c.z + fz * 2.2, c.f) * CFrame.new(0, 2.75, 0) end -- 카운터 위 i번째 접시 자리(3개씩 두 줄) diff --git a/bunsik-tycoon/src/server/PlotController.luau b/bunsik-tycoon/src/server/PlotController.luau index d707cd8..f8b0268 100644 --- a/bunsik-tycoon/src/server/PlotController.luau +++ b/bunsik-tycoon/src/server/PlotController.luau @@ -990,99 +990,114 @@ function PlotController.resettleCustomers(self: PlotController) end end --- 의자 1개 사기(빈 쪽에 자동 배치) -function PlotController.buySeat(self: PlotController, tableIndex: number?): boolean - local seats = #self.layout.chairs - local stage = self:stage() - if seats >= Economy.seatCap(stage) then - self:notify("seatMax") - return false - end - if seats >= #self.layout.tables * Economy.CHAIRS_PER_TABLE then - self:notify("tableFull") - return false - end - local cost = Economy.seatCost(seats + 1) - if self.shop.money < cost then - self:needMoney(cost) - return false - end - local test = Floor.clone(self.layout) - local ci = Floor.addChair(test, stage, tableIndex) - if not ci then - self:notify("noSpace") - return false - end - Shop.spend(self.shop, cost) - self.layout = test - Shop.setSeats(self.shop, #self.layout.chairs) - self:applyLayout() - flash(self.slot.refs.furniture:FindFirstChild("Chair" .. ci)) - self:notify("seatAdded") - self:afterPurchase() - return true -end - --- 테이블(+의자 1개) 사기 -function PlotController.buyTable(self: PlotController): boolean +-- 사려는 물건의 값. 살 수 없으면 (nil, 알림 키) +function PlotController.priceOf(self: PlotController, kind: string, k: string?): (number?, string?) local seats = #self.layout.chairs local tables = #self.layout.tables local stage = self:stage() - if tables >= Economy.tableCap(stage) then - self:notify("tableMax") + if kind == "chair" then + if seats >= Economy.seatCap(stage) then + return nil, "seatMax" + end + return Economy.seatCost(seats + 1), nil + elseif kind == "table" then + if tables >= Economy.tableCap(stage) then + return nil, "tableMax" + end + return Economy.tableCost(tables), nil + elseif kind == "decor" then + local d = k and Economy.decor(k) + if not d then + return nil, nil + end + if #self.layout.decor >= Economy.DECOR_MAX then + return nil, "noSpace" + end + return d.cost, nil + end + return nil, nil +end + +-- 물건 사기 공통. place가 있으면 그 자리에(꾸미기 화면에서 놓기), 없으면 빈 곳에 자동으로 놓습니다. +function PlotController.buyItem( + self: PlotController, + kind: string, + k: string?, + place: Floor.Add?, + prefer: number? +): boolean + local cost, why = self:priceOf(kind, k) + if not cost then + if why then + self:notify(why) + end return false end - if seats >= Economy.seatCap(stage) then - self:notify("seatMax") - return false - end - local cost = Economy.tableCost(tables, seats) if self.shop.money < cost then self:needMoney(cost) return false end - local test = Floor.clone(self.layout) - local ti = Floor.addTable(test, stage) - if not ti then - self:notify("noSpace") - return false + local stage = self:stage() + local layout: Floor.Layout? + local index: number? + if place then + local fail: string? + layout, fail, index = Floor.add(self.layout, stage, { + kind = kind, + k = k, + x = place.x, + z = place.z, + f = place.f, + r = place.r, + }) + if not layout then + self:notify("placeFail", { why = fail or "bounds" }) + return false + end + else + local test = Floor.clone(self.layout) + if kind == "chair" then + index = Floor.addChair(test, stage, prefer) + elseif kind == "table" then + index = Floor.addTable(test, stage) + elseif k then + index = Floor.addDecor(test, stage, k) + end + if not index then + self:notify("noSpace") + return false + end + layout = test end Shop.spend(self.shop, cost) - self.layout = test + self.layout = layout :: Floor.Layout Shop.setSeats(self.shop, #self.layout.chairs) self:applyLayout() - flash(self.slot.refs.furniture:FindFirstChild("Table" .. ti)) - self:notify("tableAdded") + local name = if kind == "chair" then "Chair" elseif kind == "table" then "Table" else "Decor" + flash(self.slot.refs.furniture:FindFirstChild(name .. tostring(index))) + if kind == "chair" then + self:notify("seatAdded") + elseif kind == "table" then + self:notify("tableAdded") + else + self:notify("decorAdded", { kind = k }) + end self:afterPurchase() return true end +-- 의자 1개 사기(테이블 빈 쪽에 자동 배치) +function PlotController.buySeat(self: PlotController, tableIndex: number?): boolean + return self:buyItem("chair", nil, nil, tableIndex) +end + +-- 테이블만 사기(빈 곳에 자동 배치, 의자는 따로) +function PlotController.buyTable(self: PlotController): boolean + return self:buyItem("table", nil, nil, nil) +end + function PlotController.buyDecor(self: PlotController, kind: string): boolean - local d = Economy.decor(kind) - if not d then - return false - end - if #self.layout.decor >= Economy.DECOR_MAX then - self:notify("noSpace") - return false - end - if self.shop.money < d.cost then - self:needMoney(d.cost) - return false - end - local test = Floor.clone(self.layout) - local di = Floor.addDecor(test, self:stage(), kind) - if not di then - self:notify("noSpace") - return false - end - Shop.spend(self.shop, d.cost) - self.layout = test - self:applyLayout() - flash(self.slot.refs.furniture:FindFirstChild("Decor" .. di)) - self:notify("decorAdded", { kind = kind }) - self:afterPurchase() - return true + return self:buyItem("decor", kind, nil, nil) end -- 화면 아래 추천 막대의 [사기] diff --git a/bunsik-tycoon/src/shared/Economy.luau b/bunsik-tycoon/src/shared/Economy.luau index eb26846..27c5c88 100644 --- a/bunsik-tycoon/src/shared/Economy.luau +++ b/bunsik-tycoon/src/shared/Economy.luau @@ -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) diff --git a/bunsik-tycoon/src/shared/Floor.luau b/bunsik-tycoon/src/shared/Floor.luau index 6900d73..4b28839 100644 --- a/bunsik-tycoon/src/shared/Floor.luau +++ b/bunsik-tycoon/src/shared/Floor.luau @@ -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 diff --git a/bunsik-tycoon/src/shared/Locale.luau b/bunsik-tycoon/src/shared/Locale.luau index d9b89c0..67d6936 100644 --- a/bunsik-tycoon/src/shared/Locale.luau +++ b/bunsik-tycoon/src/shared/Locale.luau @@ -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 = "盖好二楼了!可以放更多桌子", diff --git a/bunsik-tycoon/tests/Economy.spec.luau b/bunsik-tycoon/tests/Economy.spec.luau index c95d28b..a4fb2f9 100644 --- a/bunsik-tycoon/tests/Economy.spec.luau +++ b/bunsik-tycoon/tests/Economy.spec.luau @@ -21,7 +21,7 @@ end local lv0 = Economy.emptyLevels() local s0 = Economy.stats(lv0, 1) T.eq(s0.seats, 1, "처음 자리 1") -T.eq(s0.spawn, 10, "처음 손님 간격 10초(예전 6초보다 느림)") +T.eq(s0.spawn, 20, "처음 손님 간격 20초(6초 → 10초 → 20초로 느리게)") T.eq(s0.cook, 2.5, "처음 조리 2.5") T.eq(#s0.menus, 1, "처음 메뉴 1개") T.eq(s0.carry, 1, "처음 접시 1개") @@ -44,20 +44,22 @@ T.eq(Economy.cleanLevels({ Menu = 99 }).Menu, 4, "레벨은 최대값으로 자 Economy.stats(all, 1) T.eq(#Economy.START_MENUS, 1, "START_MENUS 불변") -T.eq(Economy.dishPrice("Tteokbokki", s0, 1), 15, "떡볶이 15") +T.eq(Economy.dishPrice("Tteokbokki", s0, 1), 30, "떡볶이 30") local p2 = Economy.stats(Economy.cleanLevels({ Price = 2 }), 1) -T.eq(Economy.dishPrice("Gimbap", p2, 1), 37, "김밥 25 x 1.5 = 37(내림)") -T.eq(Economy.dishPrice("Tteokbokki", s0, 2), 30, "2배 수익") +T.eq(Economy.dishPrice("Gimbap", p2, 1), 75, "김밥 50 x 1.5 = 75") +T.eq(Economy.dishPrice("Tteokbokki", s0, 2), 60, "2배 수익") -- 자리 값 T.eq(Economy.seatCost(1), 0, "첫 자리 공짜") -T.eq(Economy.seatCost(2), 10, "두 번째 자리 10원(첫 구매 10초 안)") +T.eq(Economy.seatCost(2), 10, "두 번째 자리 10원(첫 손님 한 명 값으로 삼)") local prev = 0 for s = 2, 24 do T.check(Economy.seatCost(s) > prev, `자리 {s} 값이 오름`) prev = Economy.seatCost(s) end -T.check(Economy.tableCost(1, 1) > Economy.seatCost(2), "테이블은 의자보다 비쌈") +T.check(Economy.tableCost(1) > Economy.seatCost(2), "테이블은 의자보다 비쌈") +T.eq(Economy.tableCost(1), 35, "두 번째 테이블 35원(의자는 따로)") +T.check(Economy.tableCost(2) > Economy.tableCost(1), "테이블이 많을수록 비쌈") -- 살 수 있는 것: 건물 단계 조건 local offers = Economy.offers(lv0, 1, 1) @@ -67,7 +69,12 @@ for _, o in offers do end T.check(ids.Menu and ids.Price and ids.Speed and ids.Stage and ids.Staff, "처음 살 수 있는 갈래") T.check(not ids.Tray, "쟁반은 실내 분식집부터") -T.check(ids.Seat and ids.Table, "의자·테이블") +T.check(ids.Seat and not ids.Table, "테이블에 빈 의자 자리가 많으면 의자만 추천") +local near = {} +for _, o in Economy.offers(lv0, 1, 3) do + near[o.id] = true +end +T.check(near.Seat and near.Table, "테이블이 거의 차면(의자 3개) 테이블도 추천") T.check(offers[1].cost <= offers[#offers].cost, "싼 순서") local capped = Economy.offers(lv0, 3, 6) for _, o in capped do @@ -78,8 +85,8 @@ end T.eq(Economy.wage("Cook", s0), 12, "요리 알바 시급 12") T.eq(Economy.wage("Cook", p2), 18, "판매 금액 1.5배면 시급도 1.5배") T.eq(Economy.totalWage({ Cook = 2, Server = 1 }, s0), 39, "시급 합") -T.eq(Economy.spawnInterval(s0, 1, false), 7.5, "홍보 알바 x0.75") -T.eq(Economy.spawnInterval(s0, 0, true), 5, "손님 러시 x0.5") +T.eq(Economy.spawnInterval(s0, 1, false), 15, "홍보 알바 x0.75") +T.eq(Economy.spawnInterval(s0, 0, true), 10, "손님 러시 x0.5") -- 예전 세이브 옮기기 local lv8, seats8, tables8, cooks8 = Economy.migrate(8) @@ -95,7 +102,7 @@ T.eq(seats20, 8, "자리 8") T.eq(tables20, 6, "테이블은 2단계 최대 6") T.eq(Economy.migrate(0).Menu, 0, "예전 0개") -T.check(Economy.incomePerMinute(s0) >= 20 and Economy.incomePerMinute(s0) <= 60, "처음 1분 매출 20~60원") +T.check(Economy.incomePerMinute(s0) >= 40 and Economy.incomePerMinute(s0) <= 100, "처음 1분 매출 40~100원") T.check(Economy.boostAmount(Economy.stats(all, 24)) > Economy.boostAmount(s0), "후반일수록 부스트가 큼") T.eq(Economy.shopLevel(lv0, 1), 0, "처음 가게 레벨 0") diff --git a/bunsik-tycoon/tests/Floor.spec.luau b/bunsik-tycoon/tests/Floor.spec.luau index 1e07fe8..3aa6da8 100644 --- a/bunsik-tycoon/tests/Floor.spec.luau +++ b/bunsik-tycoon/tests/Floor.spec.luau @@ -8,6 +8,8 @@ T.eq(#base.chairs, 1, "처음 의자 1개") local p1 = Floor.chairPos(base, 1) T.eq(p1 and p1.x, -9, "첫 의자 x") T.eq(p1 and p1.z, -6.5, "첫 의자는 테이블 앞(+Z) 3.5") +T.eq(base.chairs[1].r, 2, "첫 의자는 테이블(-Z)을 봄") +T.eq(Floor.chairTable(base, 1), 1, "첫 의자는 테이블 1을 봄") -- 밖, 겹침, 문 앞 T.eq(select(2, Floor.move(base, 1, { kind = "table", i = 1, x = 40, z = 0 })), "bounds", "부지 밖") @@ -19,12 +21,68 @@ T.eq(why, nil, "빈 곳으로 옮기기") T.eq(moved and Floor.chairPos(moved, 1).x, 20, "의자도 같이 옮겨짐") T.eq(base.tables[1].x, -9, "원래 배치는 그대로(복사본)") --- 의자 쪽 바꾸기, 같은 쪽 두 개 금지 +-- 테이블을 돌리면 의자가 테이블 둘레로 돌아감 +local turned = Floor.move(base, 1, { kind = "table", i = 1, x = -9, z = -10, r = 1 }) +T.check(turned ~= nil, "테이블 돌리기") +if turned then + T.eq(turned.chairs[1].x, -5.5, "의자가 +X 쪽으로") + T.eq(turned.chairs[1].z, -10, "의자 z") + T.eq(turned.chairs[1].r, 3, "의자는 계속 테이블을 봄") + T.eq(Floor.chairTable(turned, 1), 1, "돌린 뒤에도 테이블 1을 봄") +end + +-- 의자는 따로 옮기고 돌림. 앞에 테이블이 있어야 하고, 겹치면 안 됨 local two = Floor.clone(base) T.check(Floor.addChair(two, 1, 1) ~= nil, "의자 추가") T.eq(#two.chairs, 2, "의자 2") -T.check(two.chairs[2].s ~= two.chairs[1].s, "다른 쪽에 붙음") -T.eq(select(2, Floor.move(two, 1, { kind = "chair", i = 2, x = 1, z = 0 })), "chair", "같은 쪽 금지") +T.check(two.chairs[2].x ~= two.chairs[1].x or two.chairs[2].z ~= two.chairs[1].z, "다른 자리에 붙음") +T.eq(Floor.chairTable(two, 2), 1, "새 의자도 테이블 1을 봄") +T.eq( + select(2, Floor.move(two, 1, { kind = "chair", i = 2, x = -9, z = -6.5, r = 2 })), + "overlap", + "다른 의자와 겹치면 안 됨" +) +T.eq( + select(2, Floor.move(two, 1, { kind = "chair", i = 2, x = 10, z = 0, r = 0 })), + "chair", + "앞에 테이블이 없으면 안 됨" +) +T.eq( + select(2, Floor.move(two, 1, { kind = "chair", i = 2, x = -12.5, z = -10, r = 3 })), + "chair", + "테이블 반대쪽을 보면 안 됨" +) +local side, sideWhy = Floor.move(two, 1, { kind = "chair", i = 2, x = -12.5, z = -10, r = 1 }) +T.eq(sideWhy, nil, "테이블 왼쪽에서 테이블을 보게 놓기") +T.eq(side and side.chairs[2].r, 1, "의자 방향 저장") +local corner = Floor.move(two, 1, { kind = "chair", i = 2, x = -10.5, z = -13.5, r = 0 }) +T.check(corner ~= nil, "테이블 가장자리 쪽에 비스듬히 놓아도 됨") + +-- 새 물건을 정한 자리에 놓기 +local added, addWhy, ai = Floor.add(base, 1, { kind = "table", x = 12, z = 0 }) +T.eq(addWhy, nil, "테이블 놓기") +T.eq(ai, 2, "테이블 번호 2") +if added then + local withChair, cw, ci = Floor.add(added, 1, { kind = "chair", x = 12, z = 3.5, r = 2 }) + T.eq(cw, nil, "새 테이블 앞에 의자 놓기") + T.eq(ci, 2, "의자 번호 2") + T.eq(withChair and Floor.chairTable(withChair, 2), 2, "새 의자는 테이블 2를 봄") +end +T.eq( + select(2, Floor.add(base, 1, { kind = "chair", x = 20, z = 0, r = 0 })), + "chair", + "테이블 없는 곳에 의자 안 됨" +) +T.eq( + select(2, Floor.add(base, 1, { kind = "decor", k = "Plant", x = 0, z = 17 })), + "reserved", + "문 앞 소품 안 됨" +) +T.eq( + select(2, Floor.add(base, 1, { kind = "decor", k = "Stove", x = 20, z = 0 })), + "none", + "조리대는 새로 못 놓음" +) -- 테이블 자동 배치: 단계별 최대까지 놓을 수 있어야 함 local full = Floor.clone(base) @@ -32,8 +90,9 @@ for _ = 2, 6 do T.check(Floor.addTable(full, 2) ~= nil, "테이블 자동 배치") end T.eq(#full.tables, 6, "테이블 6") +T.eq(#full.chairs, 1, "테이블만 늘고 의자는 그대로") T.eq(Floor.validate(full, 2), nil, "자동 배치 결과가 검사 통과") -for _ = 1, 8 do +for _ = 1, 13 do T.check(Floor.addChair(full, 2) ~= nil, "의자 자동 배치") end T.eq(#full.chairs, 14, "의자 14(2단계 최대)") @@ -51,14 +110,16 @@ end -- 길을 막으면 거절: 조리대 앞을 테이블로 막기 local block = Floor.clone(base) block.tables = { { x = -5, z = -21, f = 1 }, { x = 5, z = -21, f = 1 }, { x = 0, z = -17, f = 1 } } -block.chairs = { { t = 1, s = 1 }, { t = 2, s = 1 }, { t = 3, s = 1 } } +block.chairs = {} +for i = 1, 3 do + block.chairs[i] = Floor.chairAt(block.tables[i], 1) +end T.eq(Floor.validate(block, 1), "blocked", "조리대 앞을 테이블로 둘러싸면 거절") -block.tables[3] = { x = 0, z = -10, f = 1 } -T.eq(Floor.validate(block, 1), nil, "한쪽을 열면 통과") +local opened = Floor.move(block, 1, { kind = "table", i = 3, x = 0, z = -10 }) +T.check(opened ~= nil, "한쪽을 열면 통과(의자도 같이 옮겨짐)") -- 2층(3단계): 계단 자리 정리 후 2층에도 배치 -local stair = Floor.clone(base) -stair.tables[1] = { x = -28, z = -2, f = 1 } +local stair = Floor.move(base, 2, { kind = "table", i = 1, x = -28, z = -2 }) :: Floor.Layout T.eq(Floor.validate(stair, 2), nil, "2단계에서는 계단 자리에 놓아도 됨") T.check(Floor.validate(stair, 3) ~= nil, "3단계에서는 계단 자리와 겹침") local fixed = Floor.repair(stair, 3) @@ -75,22 +136,36 @@ for _, t in up.tables do end T.check(on2 > 0, "3단계에서는 2층에도 테이블이 놓임") T.eq(Floor.validate(up, 3), nil, "2층 배치 통과") -for i, t in up.tables do - if t.f == 2 then - for ci, c in up.chairs do - if c.t == i then - local path = Floor.pathToChair(up, 3, ci) - local sawStair = false - for _, pt in path do - if pt.f == 2 then - sawStair = true - end - end - T.check(sawStair, "2층 의자 길은 계단을 지남") +for _ = 1, 10 do + Floor.addChair(up, 3) +end +local chairs2 = 0 +for ci, c in up.chairs do + if c.f == 2 then + chairs2 += 1 + local path = Floor.pathToChair(up, 3, ci) + local sawStair = false + for _, pt in path do + if pt.f == 2 then + sawStair = true end end + T.check(sawStair, "2층 의자 길은 계단을 지남") end end +T.check(chairs2 > 0, "2층에도 의자가 놓임") +T.eq(Floor.validate(up, 3), nil, "2층 의자 배치 통과") + +-- 2층으로 올릴 때 계단 자리 테이블은 의자와 같이 옮겨지고 자리 수는 그대로 +local crowded = Floor.clone(base) +crowded.tables[2] = { x = -28, z = -2, f = 1 } +table.insert(crowded.chairs, Floor.chairAt(crowded.tables[2], 1)) +table.insert(crowded.chairs, Floor.chairAt(crowded.tables[2], 2)) +T.eq(Floor.validate(crowded, 2), nil, "2단계 배치") +local moved3 = Floor.repair(crowded, 3) +T.eq(Floor.validate(moved3, 3), nil, "3단계 repair 통과") +T.eq(#moved3.chairs, 3, "자리 수 그대로") +T.eq(#moved3.tables, 2, "테이블 수 그대로") -- 조리대 회전·이동 local s2, sw = Floor.move(base, 1, { kind = "stove", i = 1, x = 20, z = -28, r = 2 }) @@ -113,6 +188,15 @@ local cleaned = T.eq(cleaned.stove.x, 0, "이상한 값은 기본값") T.eq(cleaned.tables[1].f, 1, "층은 1 또는 2") T.eq(#cleaned.chairs, 1, "없는 테이블 의자는 빼고 기본 의자") +local old = Floor.clean({ tables = { { x = 0, z = 0, f = 1 } }, chairs = { { t = 1, s = 2 }, { t = 1, s = 4 } } }) +T.eq(#old.chairs, 2, "예전 모양 의자 2개") +T.eq(old.chairs[1].x, 3.5, "예전 쪽 2(+X) -> x 3.5") +T.eq(old.chairs[1].r, 3, "예전 쪽 2 의자는 -X(테이블)를 봄") +T.eq(old.chairs[2].r, 1, "예전 쪽 4 의자는 +X를 봄") +T.eq(Floor.validate(old, 1), nil, "예전 모양을 바꾼 배치 통과") +local new = Floor.clean({ chairs = { { x = 2, z = 3, f = 2, r = 7 } } }) +T.eq(new.chairs[1].r, 3, "방향은 0~3") +T.eq(new.chairs[1].f, 2, "층 저장") T.eq(#Floor.clean(nil).tables, 1, "nil이면 기본 배치") T.done("Floor.spec") diff --git a/bunsik-tycoon/tests/Layout.spec.luau b/bunsik-tycoon/tests/Layout.spec.luau index 92ea33d..7306b05 100644 --- a/bunsik-tycoon/tests/Layout.spec.luau +++ b/bunsik-tycoon/tests/Layout.spec.luau @@ -48,9 +48,9 @@ for _, d in DEVICES do carry = L.carry, hint = L.hint, toasts = L.toasts, - card = L.card, settings = L.settings, list = L.list, + decorate = L.decorate, double = L.double, boost = L.boost, promote = L.promote, @@ -59,7 +59,6 @@ for _, d in DEVICES do for name, r in hud do T.check(inside(r, L.width, L.height), `{tag}: {name} 화면 안`) end - T.check(inside(L.buy, L.width, L.height), `{tag}: 사기 버튼 화면 안`) local names = {} for name in hud do table.insert(names, name) @@ -79,9 +78,9 @@ for _, d in DEVICES do T.check(inside(L.kitchen, L.width, L.height), `{tag}: 요리 창 화면 안`) T.check(inside(L.confirm, L.width, L.height), `{tag}: 홍보 확인 창 화면 안`) - -- 상점 창 안: 탭 4개와 내용 자리가 창 안에, 서로 안 겹침 + -- 상점 창 안: 탭 3개와 내용 자리가 창 안에, 서로 안 겹침 local panelBox = { x = 0, y = 0, w = L.panel.w, h = L.panel.h } - T.eq(#L.tabs, 4, `{tag}: 탭 4개`) + T.eq(#L.tabs, 3, `{tag}: 탭 3개`) for i, t in L.tabs do T.check(inside(t, panelBox.w, panelBox.h), `{tag}: 탭 {i} 창 안`) T.check(not overlap(t, L.content), `{tag}: 탭 {i}와 내용 안 겹침`) @@ -92,11 +91,14 @@ for _, d in DEVICES do end end T.check(inside(L.content, panelBox.w, panelBox.h), `{tag}: 탭 내용 창 안`) - -- 카드 칸(업그레이드 4x2, 꾸미기 5x2, 알바생 3x1): 손가락으로 누를 만큼 큼 - for _, grid in { { 4, 2 }, { 5, 2 }, { 3, 1 } } do + T.check(inside(L.decorContent, panelBox.w, panelBox.h), `{tag}: 가게 꾸미기 내용 창 안`) + T.check(L.decorContent.y >= Layout.HEADER_H, `{tag}: 가게 꾸미기 내용은 제목 띠 아래`) + -- 카드 칸(업그레이드 4x2, 알바생 3x1, 가게 꾸미기 5x2): 손가락으로 누를 만큼 큼 + for _, grid in { { 4, 2, L.content }, { 3, 1, L.content }, { 5, 2, L.decorContent } } do -- ShopWindow의 칸: 내용 자리를 똑같이 나누고 칸마다 8씩 띄움 - local cw = L.content.w / grid[1] - 8 - local chh = L.content.h / grid[2] - 8 + local box = grid[3] :: Rect + local cw = box.w / grid[1] - 8 + local chh = box.h / grid[2] - 8 T.check( cw * L.scale >= 90 and chh * L.scale >= 90, `{tag}: {grid[1]}x{grid[2]} 카드가 손가락으로 누를 만큼 큼({math.floor(cw * L.scale)}x{math.floor( @@ -106,7 +108,8 @@ for _, d in DEVICES do end -- 꾸미기 화면 버튼: 화면 안, 서로 안 겹침, 누르기 쉬움 - local deco: { [string]: Rect } = { exit = L.deco.exit, floor = L.deco.floor, info = L.deco.info } + T.eq(#L.deco.tools, 3, `{tag}: 꾸미기 버튼 3개`) + local deco: { [string]: Rect } = { exit = L.deco.exit, info = L.deco.info } for i, r in L.deco.tools do deco["tool" .. i] = r end @@ -128,9 +131,9 @@ for _, d in DEVICES do if d.touch then local zones = Layout.touchZones(d.w, d.h) local buttons: { [string]: Rect } = { - buy = L.buy, settings = L.settings, list = L.list, + decorate = L.decorate, double = L.double, boost = L.boost, promote = L.promote, @@ -142,9 +145,11 @@ for _, d in DEVICES do T.check(not overlap(p, zones.jump), `{tag}: {name} 버튼이 점프 버튼 자리 피함`) T.check(p.h >= 44, `{tag}: {name} 버튼 높이 {math.floor(p.h)}px ≥ 44(어린이 손가락)`) end + -- 꾸미기 화면에서는 걸어 다니므로 조이스틱 자리도 피함 for name, r in deco do local p = px(r, L.scale) T.check(not overlap(p, zones.jump), `{tag}: 꾸미기 {name}이 점프 버튼 자리 피함`) + T.check(not overlap(p, zones.stick), `{tag}: 꾸미기 {name}이 조이스틱 자리 피함`) if name ~= "info" then T.check(p.h >= 44, `{tag}: 꾸미기 {name} 버튼 높이 {math.floor(p.h)}px ≥ 44`) end diff --git a/bunsik-tycoon/tests/Shop.spec.luau b/bunsik-tycoon/tests/Shop.spec.luau index aab0016..f04a114 100644 --- a/bunsik-tycoon/tests/Shop.spec.luau +++ b/bunsik-tycoon/tests/Shop.spec.luau @@ -23,17 +23,17 @@ T.eq(Shop.nextCookMenu(s), "Tteokbokki", "걷는 중인 손님 주문도 미리 T.eq(Shop.serve(s, 1), nil, "앉기 전에는 서빙 불가") -- 자리가 1개면 두 번째 손님은 못 들어옴 -T.eq(#kinds(Shop.tick(s, 110), "spawn"), 0, "빈자리 없으면 손님이 지나감") +T.eq(#kinds(Shop.tick(s, 120), "spawn"), 0, "빈자리 없으면 손님이 지나감") T.eq(s.customers[1].state, "waiting", "자리에 앉음") -- 조리 -> 서빙 -> 돈 T.eq(Shop.cook(s), "Tteokbokki", "조리하면 떡볶이") T.eq(Shop.cook(s), nil, "손이 꽉 차면 더 못 만듦") -T.eq(Shop.serve(s, 1), 15, "떡볶이 15원") -T.eq(s.money, 15, "돈 15") +T.eq(Shop.serve(s, 1), 30, "떡볶이 30원") +T.eq(s.money, 30, "돈 30") T.eq(#s.hand, 0, "접시를 내려놓음") T.eq(Shop.serve(s, 1), nil, "같은 손님에게 두 번 못 줌") -T.check(#kinds(Shop.tick(s, 110 + Economy.EAT + 0.1), "leave") == 1, "다 먹으면 나감") +T.check(#kinds(Shop.tick(s, 120 + Economy.EAT + 0.1), "leave") == 1, "다 먹으면 나감") T.eq(s.customers[1], nil, "손님 목록에서 빠짐") -- 갈래 업그레이드 @@ -62,16 +62,16 @@ T.eq(select(2, Shop.buyLevel(b, "Nope")), "max", "없는 갈래") local sp = Shop.new({ money = 60, now = 0 }) Shop.tick(sp, 0) Shop.buyLevel(sp, "Speed") -T.eq(sp.stats.spawn, 8.5, "간격 8.5초") -T.check(sp.nextSpawn <= 8.5, "산 직후 다음 손님 시각이 당겨짐") +T.eq(sp.stats.spawn, 17, "간격 17초") +T.check(sp.nextSpawn <= 17, "산 직후 다음 손님 시각이 당겨짐") -- 자리 local seats = Shop.new({ money = 0, now = 0, seats = 2 }) Shop.tick(seats, 0) -T.eq(#kinds(Shop.tick(seats, 10), "spawn"), 1, "자리 2개면 두 번째 손님") +T.eq(#kinds(Shop.tick(seats, 20), "spawn"), 1, "자리 2개면 두 번째 손님") Shop.setSeats(seats, 3) T.eq(seats.stats.seats, 3, "자리 3") -T.check(seats.nextSpawn <= 11, "자리가 생기면 곧 손님") +T.check(seats.nextSpawn <= 21, "자리가 생기면 곧 손님") -- 2배 수익 local d = Shop.new({ money = 0, now = 0 }) @@ -79,12 +79,12 @@ d.moneyMult = 2 Shop.tick(d, 0) Shop.tick(d, 3) Shop.cook(d) -T.eq(Shop.serve(d, 1), 30, "2배 수익이면 30원") +T.eq(Shop.serve(d, 1), 60, "2배 수익이면 60원") -- 요리 화면에서 메뉴 고르기: 주문이 있는 메뉴만 만들 수 있음 local pick = Shop.new({ money = 0, now = 0, seats = 2, levels = { Menu = 1 } }) Shop.tick(pick, 0) -Shop.tick(pick, 10) +Shop.tick(pick, 20) local counts = Shop.openCounts(pick) T.eq(counts.Tteokbokki, 1, "떡볶이 주문 1") T.eq(counts.Gimbap, 1, "김밥 주문 1") @@ -137,22 +137,22 @@ T.eq(#sv.counter, 0, "카운터에서 빠짐") T.eq(Shop.serve(sv, 1), nil, "알바가 가져가는 손님은 플레이어가 못 줌") local e3 = Shop.tick(sv, Economy.WALK_IN + 0.1 + Economy.SERVER_TRIP + 0.1) local delivered = kinds(e3, "delivered") -T.eq(delivered[1] and delivered[1].earn, 15, "서빙 알바가 놓으면 돈") +T.eq(delivered[1] and delivered[1].earn, 30, "서빙 알바가 놓으면 돈") T.eq(sv.customers[1].state, "eating", "먹는 중") -- 홍보 알바·손님 러시 local pr = Shop.new({ money = 0, now = 0, levels = { Staff = 1 }, staff = { Promoter = 1 } }) -T.eq(Shop.spawnInterval(pr), 7.5, "홍보 알바 간격 x0.75") +T.eq(Shop.spawnInterval(pr), 15, "홍보 알바 간격 x0.75") Shop.addRush(pr, 30) -T.eq(Shop.spawnInterval(pr), 3.75, "러시 x0.5") +T.eq(Shop.spawnInterval(pr), 7.5, "러시 x0.5") Shop.tick(pr, 31) T.eq(pr.rushLeft, 0, "러시 끝") -- 옆 가게로 손님 데려가기: 먹는 중이 아닌 NPC 손님만, 늦게 온 손님부터 local victim = Shop.new({ money = 0, now = 0, seats = 3, levels = { Menu = 1 } }) Shop.tick(victim, 0) -Shop.tick(victim, 10) Shop.tick(victim, 20) +Shop.tick(victim, 40) Shop.cook(victim) -- 1번 손님 떡볶이를 들고 있음 local taken = Shop.takeCustomers(victim, 5) T.eq(#taken, 3, "3명 모두 데려감(아직 못 먹음)") @@ -160,7 +160,7 @@ T.eq(taken[1].id, 3, "늦게 온 손님부터") T.eq(next(victim.customers), nil, "손님 없음") -- 남은 떡볶이 접시: 다음 손님이 떡볶이를 주문 victim.menuIndex = 1 -- 원래라면 다음은 김밥 -local nextEv = kinds(Shop.tick(victim, 30), "spawn") +local nextEv = kinds(Shop.tick(victim, 60), "spawn") T.eq(nextEv[1] and nextEv[1].menu, "Tteokbokki", "주인 없는 접시 메뉴를 다음 손님이 주문") local thief = Shop.new({ money = 0, now = 0, seats = 2 }) @@ -193,15 +193,15 @@ 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, "빈자리가 없으면 못 앉음") -T.eq(#kinds(Shop.tick(g, 10.5), "spawn"), 0, "플레이어 손님 자리에는 NPC가 안 옴") +T.eq(#kinds(Shop.tick(g, 20.5), "spawn"), 0, "플레이어 손님 자리에는 NPC가 안 옴") Shop.cook(g) -T.eq(Shop.serve(g, 1), 15, "NPC 손님은 1배") +T.eq(Shop.serve(g, 1), 30, "NPC 손님은 1배") local gid = (guest :: any).id T.eq(Shop.nextCookMenu(g), (guest :: any).menu, "플레이어 손님 주문도 조리대에 뜸") Shop.cook(g) -T.eq(Shop.serve(g, gid), 30, "플레이어 손님은 2배") +T.eq(Shop.serve(g, gid), 60, "플레이어 손님은 2배") local guestLeave = nil -for _, e in Shop.tick(g, 10.5 + Economy.EAT + 0.1) do +for _, e in Shop.tick(g, 20.5 + Economy.EAT + 0.1) do if e.kind == "leave" and e.guest then guestLeave = e end diff --git a/bunsik-tycoon/tests/cloud/dump_gui.luau b/bunsik-tycoon/tests/cloud/dump_gui.luau index e97fc7c..46fd0aa 100644 --- a/bunsik-tycoon/tests/cloud/dump_gui.luau +++ b/bunsik-tycoon/tests/cloud/dump_gui.luau @@ -176,12 +176,9 @@ local SHOTS = { ), shot("phone_tut", PHONE, shopState("", 1, 1, { Money = 15, Tut = 3 })), shot("phone_shop", PHONE, shopState(EARLY, 2, 1, { Money = 150 }), { open = "shop" }), - shot( - "phone_shop_decor", - PHONE, - shopState(MID, 3, 2, { Money = 400, Layout = LAYOUT }), - { open = "shop", tab = "decor" } - ), + shot("phone_decor", PHONE, shopState(MID, 3, 2, { Money = 400, Layout = LAYOUT }), { open = "decor" }), + shot("pc_decor", PC, shopState(MID, 3, 2, { Money = 60, Layout = LAYOUT }), { open = "decor" }), + shot("pc_tut", PC, shopState("", 1, 1, { Money = 15, Tut = 3 })), shot( "phone_shop_staff", PHONE, diff --git a/bunsik-tycoon/tests/cloud/integration.luau b/bunsik-tycoon/tests/cloud/integration.luau index 9a01086..6d1dd43 100644 --- a/bunsik-tycoon/tests/cloud/integration.luau +++ b/bunsik-tycoon/tests/cloud/integration.luau @@ -105,23 +105,23 @@ local function label(o: Instance?): string? end local moneyText = root:FindFirstChild("Money"):FindFirstChild("Text", true) :: TextLabel eq(moneyText.Text, "5", "돈 표시") -local nextCard = root:FindFirstChild("Next") :: Frame -local nextTitle = nextCard:FindFirstChild("Title", true) :: TextLabel -check(nextTitle.Text ~= "" and not string.find(nextTitle.Text, "_"), `추천 구매 이름 ({nextTitle.Text})`) -eq((nextCard:FindFirstChild("Cost", true) :: TextLabel).Text, "5 / 10", "추천 구매(의자 10원) 진행 막대") -check((root:FindFirstChild("Hint") :: Frame).Visible, "튜토리얼 말풍선 보임") -check((nextCard:FindFirstChild("Pointer") :: ImageLabel).Visible, "튜토리얼 3: [사기] 가리키는 손") -local buyBtn = nextCard:FindFirstChild("Buy") :: TextButton -eq(label(buyBtn), "사기", "사기 버튼 글자") -eq( - (buyBtn:FindFirstChild("Base") :: Frame).BackgroundColor3, - Theme.darken(Theme.GRAY, 0.3), - "돈이 모자라면 회색" +check(root:FindFirstChild("Next") == nil, "아래 [사기] 막대 없음") +local hintFrame = root:FindFirstChild("Hint") :: Frame +check(hintFrame.Visible, "튜토리얼 말풍선 보임") +local hintText = hintFrame:FindFirstChild("Text", true) :: TextLabel +check( + string.find(hintText.Text, "가게 꾸미기") ~= nil, + `튜토리얼 3은 가게 꾸미기 안내 ({hintText.Text})` ) +check((root:FindFirstChild("Pointer") :: ImageLabel).Visible, "튜토리얼 3: [가게 꾸미기] 가리키는 손") +local lay0 = hud.layout() +check(hintFrame.Position.Y.Offset > lay0.height / 2, "튜토리얼 말풍선은 화면 아래쪽") local listButton = root:FindFirstChild("ListButton") :: TextButton eq(label(listButton), "상점", "상점 버튼 글자") +local decoButton = root:FindFirstChild("Decorate") :: TextButton +eq(label(decoButton), "가게 꾸미기", "가게 꾸미기 버튼 글자") +check(not (listButton:FindFirstChild("Badge") :: Frame).Visible, "살 것이 없으면 배지 없음") state:SetAttribute("Money", 15) -eq((buyBtn:FindFirstChild("Base") :: Frame).BackgroundColor3, Theme.darken(Theme.MINT, 0.3), "살 수 있으면 초록") check((listButton:FindFirstChild("Badge") :: Frame).Visible, "살 수 있으면 상점 버튼에 ! 배지") eq( (root:FindFirstChild("Gain") :: TextLabel?) and (root:FindFirstChild("Gain") :: TextLabel).Text, @@ -132,20 +132,26 @@ for _, name in { "Promote", "Rush", "Double", "Boost", "Settings" } do check(root:FindFirstChild(name) ~= nil, `버튼 {name}`) end state:SetAttribute("Lang", "en") -check(nextTitle.Text ~= "" and not string.find(nextTitle.Text, "의자"), `영어 추천 구매 ({nextTitle.Text})`) +eq(label(decoButton), "Decorate", "영어 가게 꾸미기 버튼") state:SetAttribute("Lang", "ko") +state:SetAttribute("Tut", 0) +check( + not hintFrame.Visible and not (root:FindFirstChild("Pointer") :: ImageLabel).Visible, + "튜토리얼 끝나면 아래 말풍선 없음" +) -section("상점 창(탭 4개)") +section("상점 창(탭 3개)") hud.open("shop") local panel = root:FindFirstChild("Panel") :: Frame check(hud.menuOpen() and panel.Visible, "상점 창 열기") local function page(id: string): Frame return panel:FindFirstChild("Page_" .. id, true) :: Frame end -for _, id in { "upgrade", "decor", "staff", "mine" } do +for _, id in { "upgrade", "staff", "mine" } do check(page(id) ~= nil, `탭 {id}`) check(panel:FindFirstChild("Tab_" .. id, true) ~= nil, `탭 버튼 {id}`) end +check(panel:FindFirstChild("Tab_decor", true) == nil, "상점에는 꾸미기 탭 없음") check(page("upgrade").Visible, "처음엔 업그레이드 탭") for _, id in Economy.TRACK_ORDER do local card = page("upgrade"):FindFirstChild("Track_" .. id, true) @@ -155,13 +161,22 @@ for _, id in Economy.TRACK_ORDER do end local tray = page("upgrade"):FindFirstChild("Track_Tray", true) :: Frame check((tray:FindFirstChild("Lock", true) :: ImageLabel).Visible, "쟁반은 포장마차에서 잠김") -hud.open("shop", "decor") -check(page("decor").Visible and not page("upgrade").Visible, "꾸미기 탭") -check(page("decor"):FindFirstChild("Place", true) ~= nil, "배치하기 버튼") -check(page("decor"):FindFirstChild("Decor_Table", true) ~= nil, "테이블 카드") -for _, d in Economy.DECOR do - check(page("decor"):FindFirstChild("Decor_" .. d.id, true) ~= nil, `소품 카드 {d.id}`) +hud.open("decor") +local decorPanel = root:FindFirstChild("DecorPanel") :: Frame +check(decorPanel.Visible and not panel.Visible and hud.menuOpen(), "가게 꾸미기 창(상점과 따로)") +local decorPage = decorPanel:FindFirstChild("Page_decor", true) :: Frame +check(decorPage ~= nil, "가게 꾸미기 카드 자리") +eq(label(decorPage:FindFirstChild("Place", true)), "옮기기", "옮기기 버튼") +for _, id in { "Table", "Seat" } do + check(decorPage:FindFirstChild("Decor_" .. id, true) ~= nil, `{id} 카드`) end +for _, d in Economy.DECOR do + check(decorPage:FindFirstChild("Decor_" .. d.id, true) ~= nil, `소품 카드 {d.id}`) +end +local tableCost = (decorPage:FindFirstChild("Decor_Table", true) :: Frame):FindFirstChild("Buy", true) +eq(label(tableCost), Locale.number(Economy.tableCost(1)), "테이블 값(의자 없이)") +hud.open("shop", "upgrade") +check(not decorPanel.Visible and panel.Visible, "창은 하나만 열림(꾸미기 → 상점)") hud.open("shop", "staff") check((page("staff"):FindFirstChild("Locked", true) :: Frame).Visible, "알바생 기능 전에는 잠김") state:SetAttribute("Levels", "Staff=1") @@ -219,6 +234,7 @@ local SAMPLES = { kickOwn = {}, rushOn = { min = 10 }, notEnough = { need = "100" }, + doubleOwned = {}, } for _, lang in { "ko", "en", "ja", "zh" } do for key, args in SAMPLES do @@ -260,6 +276,23 @@ hud.destroy() section("꾸미기 화면(클라이언트 모듈)") local Decorate = require(StarterPlayer.StarterPlayerScripts.Client.Decorate) check(typeof(Decorate.build) == "function", "꾸미기 모듈") +local dstate = Instance.new("Folder") +dstate:SetAttribute("Lang", "ko") +dstate:SetAttribute("Stage", 1) +dstate:SetAttribute("Money", 100) +local dplot = Instance.new("Model") +dplot:SetAttribute("Origin", CFrame.new()) +local dholder = Instance.new("Folder") +local deco = Decorate.build(dholder, dstate, dplot, function() end) +local Layout = require(StarterPlayer.StarterPlayerScripts.Client.Layout) +deco.setLayout(Layout.compute(750, 332, true, false)) +local droot = deco.gui:FindFirstChild("Root") :: Frame +for _, name in { "Exit", "Info", "Rotate", "Cancel", "Place" } do + check(droot:FindFirstChild(name) ~= nil, `꾸미기 {name}`) +end +check(droot:FindFirstChild("Floor") == nil and droot:FindFirstChild("Side1") == nil, "예전 층·쪽 버튼 없음") +check(not deco.isOpen() and not deco.holding(), "처음엔 닫힘") +deco.destroy() section("요리 창(메뉴 고르기 → 조리 과정 → 완성)") local kstate = Instance.new("Folder") diff --git a/bunsik-tycoon/tests/cloud/server.luau b/bunsik-tycoon/tests/cloud/server.luau index 4f73092..fc84f67 100644 --- a/bunsik-tycoon/tests/cloud/server.luau +++ b/bunsik-tycoon/tests/cloud/server.luau @@ -175,7 +175,7 @@ eq(owner:GetAttribute("Tut"), 2, "튜토리얼 2단계") -- 접시가 똑바로 놓이는지(예전에 세로로 서던 문제) local held = dyn:FindFirstChild("Dish_Tteokbokki") :: Model check(held ~= nil, "접시 모형") -eq(c:serve(1), 15, "서빙 15원") +eq(c:serve(1), 30, "서빙 30원") local onTable = dyn:FindFirstChild("Dish_Tteokbokki") :: Model local up = onTable and onTable:GetPivot().UpVector check(up and up.Y > 0.99, `테이블 위 접시가 똑바로 놓임 (UpVector.Y {up and up.Y})`) @@ -218,11 +218,60 @@ for _ = 1, 4 do check(c:buyTable(), "테이블 구매") end eq(#c.layout.tables, 5, "테이블 5") -for _ = 1, 5 do +eq(owner:GetAttribute("Seats"), 2, "테이블만 사면 의자는 그대로") +for _ = 1, 9 do check(c:buySeat(nil), "의자 구매") end eq(owner:GetAttribute("Seats"), 11, "의자 11") eq(Floor.validate(c.layout, 2), nil, "배치 검사 통과") +-- 꾸미기 화면처럼 정한 자리에 새 물건 놓기(투명 미리보기 → 놓기) +local tableAt = nil +for _, spotXZ in { { 22, -20 }, { -22, -20 }, { 22, 0 }, { -22, 0 } } do + if not tableAt and c:buyItem("table", nil, { kind = "table", x = spotXZ[1], z = spotXZ[2], f = 1 }) then + tableAt = spotXZ + end +end +check(tableAt ~= nil, "정한 자리에 테이블 놓기") +if tableAt then + local tn = #c.layout.tables + eq(c.layout.tables[tn].x, tableAt[1], "테이블 x 그대로") + check( + c:buyItem("chair", nil, { kind = "chair", x = tableAt[1], z = tableAt[2] - 3.5, f = 1, r = 0 }), + "테이블 뒤에 의자 놓기" + ) + local cn = #c.layout.chairs + eq(c.layout.chairs[cn].r, 0, "의자 방향 저장") + eq(Floor.chairTable(c.layout, cn), tn, "새 의자는 새 테이블을 봄") + check(furniture:FindFirstChild("Chair" .. cn) ~= nil, "새 의자 모형") + local seatCf = PlotBuilder.seatCFrame(slots[1].cf, c.layout, cn) + local tablePos = PlotBuilder.floorCFrame(slots[1].cf, tableAt[1], tableAt[2], 1).Position + local toTable = (Vector3.new(tablePos.X, seatCf.Position.Y, tablePos.Z) - seatCf.Position).Unit + check(seatCf.LookVector:Dot(toTable) > 0.9, "앉은 손님은 테이블을 봄") + local dish = PlotBuilder.dishCFrame(slots[1].cf, c.layout, cn) + local local_ = slots[1].cf:PointToObjectSpace(dish.Position) + check(math.abs(local_.X - tableAt[1]) <= 2.5 and math.abs(local_.Z - tableAt[2]) <= 2.5, "접시는 테이블 위") +end +local seatsBefore = #c.layout.chairs +local moneyBefore = c.shop.money +check( + not c:buyItem("chair", nil, { kind = "chair", x = 0, z = 5, f = 1, r = 0 }), + "테이블 없는 곳에 의자 못 놓음" +) +eq(#c.layout.chairs, seatsBefore, "실패하면 의자 그대로") +eq(c.shop.money, moneyBefore, "실패하면 돈 안 나감") +check(noted("placeFail"), "못 놓는 이유 알림") +local teddy = false +for _, spotXZ in { { 0, 8 }, { 16, 12 }, { -16, 12 }, { 30, -20 }, { -30, -20 } } do + teddy = teddy + or c:buyItem("decor", "Teddy", { kind = "decor", k = "Teddy", x = spotXZ[1], z = spotXZ[2], f = 1, r = 2 }) +end +check(teddy, "정한 자리에 곰인형") +eq(c.layout.decor[#c.layout.decor].r, 2, "소품 방향 저장") +local templates = PlotBuilder.buildTemplates() +for _, name in { "Table", "Chair", "Decor_Plant", "Decor_Fridge" } do + local tm = templates:FindFirstChild(name) :: Model? + check(tm ~= nil and tm:GetPivot().Position.Magnitude < 1e-3, `미리보기 모형 {name}(기준점 원점)`) +end check(c:buyDecor("Plant"), "화분 구매") check(c:buyDecor("Balloons"), "풍선 구매") check(furniture:FindFirstChild("Decor1") ~= nil, "소품 모형") @@ -239,18 +288,33 @@ local stallBefore = slots[1].refs.stall:GetPivot().Position check(c:move({ kind = "stove", i = 1, x = 4, z = -28, r = 0 }), "조리대 옮기기") check((slots[1].refs.stall:GetPivot().Position - stallBefore).Magnitude > 3, "수레 모형이 옮겨짐") check(slots[1].refs.stove:IsDescendantOf(slots[1].refs.stall), "조리대 인스턴스는 그대로(버튼 유지)") --- 의자 1을 빈 쪽이 있는 다른 테이블로 옮기기(테이블 1은 네 쪽이 다 찼을 수 있음) +-- 의자 1을 다른 테이블의 빈 쪽으로 옮기기 local sideMoved = false -for ti in c.layout.tables do +local from = Floor.chairTable(c.layout, 1) +for ti, tb in c.layout.tables do for side = 1, 4 do - if not sideMoved and ti ~= c.layout.chairs[1].t then - sideMoved = c:move({ kind = "chair", i = 1, x = side, z = ti }) + if not sideMoved and ti ~= from then + local at = Floor.chairAt(tb, side) + sideMoved = c:move({ kind = "chair", i = 1, x = at.x, z = at.z, f = at.f, r = at.r }) end end end check(sideMoved, "의자를 다른 테이블·다른 쪽으로 옮기기") +-- 테이블을 옮기면 그 테이블을 보는 의자도 같이 +local tIndex = Floor.chairTable(c.layout, 1) :: number +local tb0 = c.layout.tables[tIndex] +local ch0 = c.layout.chairs[1] +local movedWith = false +for _, d in { { 0, -4 }, { 0, 4 }, { 4, 0 }, { -4, 0 }, { 6, 6 }, { -6, -6 } } do + if not movedWith and c:move({ kind = "table", i = tIndex, x = tb0.x + d[1], z = tb0.z + d[2], f = tb0.f }) then + movedWith = true + eq(c.layout.chairs[1].x, ch0.x + d[1], "의자도 같이 옮겨짐") + end +end +check(movedWith, "의자 붙은 테이블 옮기기") c.shop.money = 0 check(not c:buyTable(), "돈 모자라면 테이블 못 삼") +check(not c:buyItem("chair", nil, { kind = "chair", x = 0, z = 0, f = 1, r = 0 }), "돈 모자라면 의자 못 놓음") check(noted("notEnough"), "모자란 돈 알림") c:addMoney(1_000_000) @@ -301,9 +365,10 @@ end check(#c.layout.tables > before2, "테이블 늘어남") check(on2 ~= nil, "2층에 테이블") if on2 then + check(c:buySeat(on2), "2층 테이블에 의자") local chair2 = nil - for ci, ch in c.layout.chairs do - if ch.t == on2 then + for ci in c.layout.chairs do + if Floor.chairTable(c.layout, ci) == on2 then chair2 = ci end end @@ -349,7 +414,7 @@ end local served = c.shop.served - served0 print(`5분 영업(알바만): 서빙 {served}회, 돈 {c.shop.money - money0}`) check(delivered, "서빙 알바가 접시를 들고 감") -check(served > 20, "알바만으로 5분 동안 20회 넘게 서빙") +check(served > 12, "알바만으로 5분 동안 12회 넘게 서빙(손님 간격 20초 기준)") check(c.shop.money > money0, "시급을 내고도 돈이 늘어남") task.wait(Economy.WALK_IN + 2) check(count_(dyn, "Customer") <= Economy.seatCap(3) + 6, "손님 NPC가 쌓이지 않음") diff --git a/bunsik-tycoon/tools/simlib.luau b/bunsik-tycoon/tools/simlib.luau index 5735629..d0a9ecf 100644 --- a/bunsik-tycoon/tools/simlib.luau +++ b/bunsik-tycoon/tools/simlib.luau @@ -91,8 +91,9 @@ function Sim.run(mult: number, limit: number, untilStage: number?): { Entry } Shop.spend(shop, b.cost) if b.kind == "table" then tables += 1 + else + Shop.setSeats(shop, shop.stats.seats + 1) end - Shop.setSeats(shop, shop.stats.seats + 1) end local label = if b.kind == "track" then `{b.id}{shop.levels[b.id]}` else b.id table.insert(log, { t = t, id = label, cost = b.cost, kind = b.kind })