Compare commits
21 Commits
1958a2dd99
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25df3d4846 | ||
|
|
fdc5c05c2c | ||
|
|
e57e908b85 | ||
|
|
d0ae06e198 | ||
|
|
d8eaa01495 | ||
|
|
d72b166b97 | ||
|
|
80f5055ecd | ||
|
|
51298fcfa1 | ||
|
|
52668f219a | ||
|
|
8d29656aa3 | ||
|
|
2b64bfc392 | ||
|
|
02df9101bb | ||
|
|
05848d19d6 | ||
|
|
998b2467d6 | ||
|
|
4d861b8fd3 | ||
|
|
c7af87c646 | ||
|
|
ebfe23c509 | ||
|
|
802ba10e1a | ||
|
|
060974e277 | ||
|
|
dcf0ca6912 | ||
|
|
61b3f7730d |
4
.gitignore
vendored
@@ -1,2 +1,6 @@
|
||||
__pycache__/
|
||||
*.pyc
|
||||
build/
|
||||
*.rbxl
|
||||
*.rbxlx
|
||||
.cache/
|
||||
|
||||
38
DECISIONS.md
@@ -5,9 +5,16 @@
|
||||
|
||||
## 0. 역할 분담
|
||||
|
||||
- 코드(Luau)는 AI가 이 리포에 작성합니다. 사용자는 Lua를 몰라도 됩니다.
|
||||
- 사용자는 계정·인증, Studio에서 플레이 테스트, 맵이나 외형 확인, 출시 버튼 누르기를 맡습니다.
|
||||
- 사용자가 직접 해야 하는 일은 그때그때 순서대로 안내합니다.
|
||||
2026-10-12 사용자 요청으로 바꿨습니다: **에셋 검색, 제작, 테스트까지 AI가 서버에서 전부 합니다.**
|
||||
|
||||
- AI가 하는 일: Luau 코드, 맵·UI 제작, Creator Store 에셋 검색과 가져오기, 자동 테스트(단위 테스트와 로블록스 서버 원격 실행), 테스트 플레이스 업로드, 게임패스·개발자 상품 등록, 썸네일 제작과 업로드.
|
||||
- 사용자가 하는 일은 본인 계정으로만 되는 것만 남깁니다.
|
||||
1. 계정 준비: 2단계 인증, 신분증 나이 확인(`SETUP.md` 1~3).
|
||||
2. 게임 자리 만들기 1회: Studio에서 빈 게임을 한 번 Publish합니다. 새 게임을 만드는 공식 API가 없어서 이 한 번은 Studio가 필요합니다(`SETUP.md` 4).
|
||||
3. Open Cloud API 키 발급 1회(`SETUP.md` 5).
|
||||
4. 돈·법적 절차: 로벅스 수수료 결제, 설문(Maturity & Compliance Questionnaire), DevEx.
|
||||
5. (권장) 출시 전 직접 플레이해 보고 느낌 말해 주기. 재미와 조작감은 자동 테스트로 판단할 수 없습니다.
|
||||
- AI가 사용자 계정 비밀번호나 로그인 쿠키(.ROBLOSECURITY)를 받아서 대신 로그인하는 방식은 쓰지 않습니다. 계정 전체 권한이 넘어가고 2단계 인증도 무의미해집니다. API 키는 게임 하나와 서버 IP로 권한을 좁힐 수 있어서 이쪽을 씁니다.
|
||||
|
||||
## 1. 개발 방식: Rojo
|
||||
|
||||
@@ -24,6 +31,20 @@
|
||||
4. Open Cloud Place Publishing API로 테스트용 플레이스에 올리고, 사용자는 로블록스에서 바로 플레이해 봅니다.
|
||||
5. 맵이나 외형을 Studio에서 손봤다면 `rojo syncback`으로 리포에 다시 넣습니다.
|
||||
|
||||
에셋 확보 방식(2026-10-12 확인):
|
||||
- 검색: Creator Store 검색 API(`apis.roblox.com/toolbox-service/v2/assets:search`). 인증 없이도 결과가 나오는 것을 서버에서 확인했습니다.
|
||||
- 가져오기: Luau Execution 작업 안에서 `AssetService:LoadAssetAsync`로 불러오고 `SerializationService:SerializeInstancesAsync`로 `.rbxm`을 받아 리포 `assets/`에 넣습니다. 2026-10-14 확인: 로블록스가 만든 에셋만 불러와지고, 남이 만든 무료 모델은 "User is not authorized"로 막힙니다(`AllowInsertFreeAssets`는 스크립트에서 쓸 수 없음). 아바타 아이템(옷·머리·동물 번들)은 `HumanoidDescription`으로 소유 없이 NPC에 입힐 수 있습니다(`bunsik-tycoon/assets/npc_assets.md`).
|
||||
- 직접 만든 이미지·모델·소리: Open Cloud Assets API로 올립니다. 업로드마다 로블록스 검수가 붙습니다.
|
||||
- 주의: Place Publishing API는 Union(PartOperation)과 SurfaceAppearance를 올리지 못합니다. 그래서 Union 대신 Part 조합이나 MeshPart를 씁니다.
|
||||
- 원칙(2026-10-12 사용자 요청): 마음에 드는 에셋이 없으면 직접 만듭니다. 분식집은 지금 모두 직접 만든 것입니다.
|
||||
- 맵·가게·음식 모형: 코드로 Part를 조합(`src/server/PlotBuilder.luau`, `Food.luau`)
|
||||
- 효과음 4개: `tools/sfx.py`로 합성해 오디오 에셋으로 업로드(`sfx/`, ID는 `src/shared/Sounds.luau`)
|
||||
- 게임패스·상품 아이콘, 게임 아이콘, 썸네일: `tools/art.py`로 그림(`art/`)
|
||||
- 로블록스 기본 제공만 그대로 씀: 손님 NPC의 아바타(로블록스가 만든 옷·머리·얼굴·동물 번들, 2026-10-14부터), 기본 걷기·앉기 애니메이션
|
||||
- 원격 실행 한도: 작업 1회 5분, 키 주인 기준 분당 5회 생성.
|
||||
|
||||
근거: https://create.roblox.com/docs/cloud/reference/features/luau-execution , https://create.roblox.com/docs/cloud/guides/usage-place-publishing , https://create.roblox.com/docs/cloud/reference/features/assets , https://create.roblox.com/docs/reference/engine/classes/AssetService
|
||||
|
||||
리포 구조(분식집 기준, 아이돌도 같은 모양):
|
||||
```
|
||||
bunsik-tycoon/
|
||||
@@ -31,8 +52,9 @@ bunsik-tycoon/
|
||||
src/server/ 서버 코드(돈, 세이브, 결제)
|
||||
src/client/ 화면 UI, 입력
|
||||
src/shared/ 경제 수치표 같은 공용 데이터
|
||||
assets/ 맵·모델(.rbxm)
|
||||
tools/ 시뮬레이터 등 개발 도구
|
||||
art/ 직접 그린 아이콘·썸네일(PNG)
|
||||
sfx/ 직접 합성한 효과음(OGG)
|
||||
tools/ 시뮬레이터, 업로드·원격 테스트, 그림·소리 생성 도구
|
||||
```
|
||||
|
||||
근거: https://github.com/rojo-rbx/rojo/releases , https://create.roblox.com/docs/scripting/sync , https://create.roblox.com/docs/cloud/guides/usage-place-publishing , https://create.roblox.com/docs/cloud/reference/features/luau-execution
|
||||
@@ -128,12 +150,12 @@ bunsik-tycoon/
|
||||
|
||||
## 7. 일정
|
||||
|
||||
코드는 AI가 쓰므로, 일정을 정하는 건 사용자의 준비·테스트 시간과 출시 후 60일 심사입니다.
|
||||
사용자가 하루 1~2시간 테스트할 수 있다고 보고 잡았습니다.
|
||||
제작과 테스트는 AI가 하므로, 일정을 정하는 건 사용자의 계정 준비와 출시 후 60일 심사입니다.
|
||||
사용자의 직접 플레이 확인은 마일스톤마다 10~20분이면 됩니다.
|
||||
|
||||
| 기간 | 내용 |
|
||||
|---|---|
|
||||
| 0주차 | 사용자 준비: 계정 생성, 2단계 인증, 신분증 나이 확인, Studio 설치(`SETUP.md`), Open Cloud API 키 발급 |
|
||||
| 0주차 | 사용자 준비: 계정 생성, 2단계 인증, 신분증 나이 확인, 빈 게임 Publish 1회, Open Cloud API 키 발급(`SETUP.md`) |
|
||||
| 분식집 1~3주 | MVP 제작·테스트·출시(16세 이상 공개) |
|
||||
| 분식집 출시 후 60일 | 조건 충족 유저 고유 플레이 250회(약 250명) 달성, 업데이트 1~2회 |
|
||||
| 아이돌 (분식집 출시 2~3주 뒤 착수) | 약 4주. 의상 에셋 작업이 많음 |
|
||||
|
||||
13
README.md
@@ -15,4 +15,15 @@
|
||||
|
||||
사용자 준비(계정·2단계 인증·나이 확인·Studio 설치): [SETUP.md](SETUP.md)
|
||||
|
||||
현재 단계: 결정 사항 확정, 사용자 계정 준비 중. 다음은 Rojo 프로젝트 골격
|
||||
현재 단계: 분식집 2026-10-14 개편(갈래 업그레이드, 꾸미기 배치, 2층, 알바생 역할·시급, 홍보·쫓아내기·손님 러시, 가게 이름·디자인, 다양한 손님)을 비공개 게임에 올려 사용자 플레이 테스트 중([bunsik-tycoon/PLAYTEST.md](bunsik-tycoon/PLAYTEST.md)). 서버↔화면 약속은 [bunsik-tycoon/NETWORK.md](bunsik-tycoon/NETWORK.md)
|
||||
|
||||
개발 도구 설치와 검사:
|
||||
```
|
||||
rokit install # rojo, selene, stylua, lune, luau-lsp (버전은 rokit.toml)
|
||||
bunsik-tycoon/tools/check.sh # 스타일·린트·타입 검사·단위 테스트·빌드
|
||||
python3 bunsik-tycoon/tools/cloud.py publish bunsik-tycoon/build/BunsikTycoon.rbxl # 저장 버전 업로드
|
||||
python3 bunsik-tycoon/tools/cloud.py run bunsik-tycoon/tests/cloud/server.luau --version N # 로블록스 서버 통합 테스트(서버)
|
||||
python3 bunsik-tycoon/tools/cloud.py run bunsik-tycoon/tests/cloud/integration.luau --version N # 로블록스 서버 통합 테스트(화면 UI)
|
||||
bunsik-tycoon/tools/preview.sh .cache/preview # 화면 UI 미리보기 그림
|
||||
python3 bunsik-tycoon/tools/cloud.py publish bunsik-tycoon/build/BunsikTycoon.rbxl --published # 실제 서버에 반영
|
||||
```
|
||||
|
||||
62
SETUP.md
@@ -1,7 +1,7 @@
|
||||
# 0주차 준비: 계정 만들기부터 Studio 설치까지
|
||||
# 0주차 준비: 계정 만들기부터 API 키 발급까지
|
||||
|
||||
사용자(2004년생, 만 18세 이상, Windows)가 직접 하는 준비 단계입니다. 2026-10-10 기준으로 확인했습니다.
|
||||
순서대로 하면 되고, 1~4는 오늘 해 두는 게 좋습니다. 계정이 만들어진 지 2일이 지나야 게임을 공개할 수 있기 때문입니다.
|
||||
사용자(2004년생, 만 18세 이상, Windows)가 직접 하는 준비 단계입니다. 2026-10-10 기준으로 확인했고, 2026-10-12에 "제작·테스트는 AI가 전부"로 바뀐 내용을 반영했습니다.
|
||||
순서대로 하면 되고, 1~5는 오늘 해 두는 게 좋습니다. 계정이 만들어진 지 2일이 지나야 게임을 공개할 수 있기 때문입니다.
|
||||
|
||||
## 1. 계정 만들기 (PC 브라우저, 5분)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
2. 생년월일을 **실제 생일**로 넣습니다. 나중에 신분증으로 나이를 확인할 때 생일이 다르면 실패합니다.
|
||||
3. 사용자 이름(Username)을 정합니다.
|
||||
- 게임 페이지에 "만든 사람"으로 그대로 보입니다. 실명은 피하고, 스튜디오 이름처럼 쓸 이름으로 정합니다(예: `BunsikStudio`).
|
||||
- 정한 이름: `tkrmagid` (2026-10-12).
|
||||
- 영문·숫자·밑줄(_) 1개, 3~20자입니다. 나중에 바꾸려면 1,000 로벅스가 듭니다.
|
||||
- 표시 이름(Display Name)은 따로 있고 무료로 바꿀 수 있습니다.
|
||||
4. 비밀번호를 정하고 가입을 마칩니다. 사람 확인 퍼즐이 나오면 풉니다.
|
||||
@@ -34,24 +35,61 @@
|
||||
|
||||
신분증 확인은 로블록스가 계약한 Persona라는 회사가 처리합니다.
|
||||
|
||||
## 4. Roblox Studio 설치 (10분)
|
||||
## 4. Studio로 빈 게임 한 번 올리기 (15분, 딱 한 번)
|
||||
|
||||
게임 제작과 테스트는 AI가 서버에서 하지만, **새 게임을 만드는 공식 API가 없어서** 게임 자리 하나는 Studio에서 만들어야 합니다. 그 뒤로는 Studio를 열 일이 없습니다.
|
||||
|
||||
요구 사항: Windows 10 이상, 메모리 3GB 이상, 화면 1600×900 이상.
|
||||
|
||||
1. https://create.roblox.com 에 로그인하고 Studio 다운로드 버튼을 누릅니다.
|
||||
2. 받은 `RobloxStudio.exe`를 실행하고 설치가 끝나면 Launch Studio를 누릅니다.
|
||||
3. 방금 만든 계정으로 로그인합니다.
|
||||
4. 빈 템플릿(Baseplate)을 하나 열어서 화면이 뜨는지만 확인하고 닫습니다.
|
||||
2. 받은 `RobloxStudio.exe`를 실행하고, 설치가 끝나면 같은 계정으로 로그인합니다.
|
||||
3. 새로 만들기에서 **Baseplate**를 엽니다. 아무것도 고치지 않습니다.
|
||||
4. 위 메뉴 File → **Publish to Roblox**를 누릅니다.
|
||||
5. 새 게임 만들기 창에서 이름은 `Bunsik Tycoon`, 만든 사람은 본인 계정, 기기는 컴퓨터·휴대폰·태블릿을 모두 고르고 Create를 누릅니다.
|
||||
6. 올라가면 비공개 상태로 만들어집니다. 그대로 두고 Studio를 닫습니다.
|
||||
7. https://create.roblox.com/dashboard/creations 에서 `Bunsik Tycoon`을 누르고, 브라우저 주소창의 주소를 복사해 둡니다(AI에게 보낼 것).
|
||||
|
||||
## 5. 다음 단계에서 같이 할 것 (지금은 안 해도 됨)
|
||||
## 5. Open Cloud API 키 만들기 (10분, 딱 한 번)
|
||||
|
||||
AI가 서버에서 게임을 올리고, 로블록스 서버에서 테스트를 돌리고, 에셋·게임패스를 등록할 때 쓰는 열쇠입니다. 계정 비밀번호와 달리 **이 게임 하나, 이 서버 IP 하나**로 권한을 좁힐 수 있습니다.
|
||||
|
||||
1. https://create.roblox.com/dashboard/credentials?activeTab=ApiKeysTab 에서 **Create API Key**를 누릅니다.
|
||||
2. Name: `ejclaw-server`
|
||||
3. Access Permissions에서 아래 API를 하나씩 추가합니다. 각 API마다 Restrict by Experience 스위치를 직접 켜고(처음엔 꺼져 있음) `Bunsik Tycoon`을 고른 뒤, 오른쪽 작업(Operations)을 고릅니다. 목록 이름이 표와 조금 다르면 검색칸에 앞부분만 입력해 찾습니다.
|
||||
|
||||
| API (Select API System) | 고를 작업 | 쓰는 곳 |
|
||||
|---|---|---|
|
||||
| universe-places | write | 게임 파일 올리기 |
|
||||
| luau-execution-sessions | 보이는 것 전부 | 로블록스 서버에서 테스트 실행 |
|
||||
| universe | read, write | 게임 설정 읽기, 출시 때 공개 전환 |
|
||||
| game-pass | read, write | 게임패스 등록 |
|
||||
| developer-product | read, write | 개발자 상품 등록 |
|
||||
| asset | read, write | 만든 이미지·모델 올리기(게임 단위 제한 없음) |
|
||||
|
||||
4. Security → Accepted IP Addresses에 `211.213.11.141` 하나만 넣습니다. 키가 새어도 이 서버 밖에서는 못 씁니다. 서버 IP가 바뀌면 AI가 알려 드립니다.
|
||||
5. Expiration은 비워 둡니다(60일 동안 안 쓰면 자동으로 만료됩니다).
|
||||
6. **Save & Generate Key**를 누르고, 나온 키를 **Copy Key to Clipboard**로 복사합니다. 이 화면을 닫으면 다시 볼 수 없습니다.
|
||||
7. 키를 디스코드 방에 붙여 넣으면 AI가 바로 서버의 비밀 저장소로 옮깁니다. **옮겼다는 답이 오면 그 메시지는 지워 주세요.**
|
||||
|
||||
### 발급 결과 (2026-10-12)
|
||||
|
||||
- 키는 서버 `secrets.json`의 `roblox.opencloud/bunsik-tycoon`에 있습니다. 리포와 채팅에는 넣지 않습니다.
|
||||
- Bunsik Tycoon: universe `10770390863`, 루트 플레이스 `98118751156219`.
|
||||
- 서버에서 확인한 것: 게임 설정 읽기·수정, 게임패스·개발자 상품 목록, 에셋 읽기, Rojo 빌드 업로드(Saved 버전 4), 그 버전에서 Luau 원격 실행. 모두 성공했습니다.
|
||||
- 2026-10-12 API로 만든 것: 게임패스 `Double Money (2배 수익)` 199 로벅스(ID 2026574937), 개발자 상품 `Money Boost (돈 부스트)` 25 로벅스(ID 3717970589), 서버 인원 6명, 게임 설명, 효과음 오디오 4개(직접 합성).
|
||||
- 게임 아이콘(`bunsik-tycoon/art/game_icon.png`)과 썸네일(`art/thumbnail_1.png`)은 그려 두었습니다. 올리는 공식 API가 없어서 출시 직전에 Creator Hub → Bunsik Tycoon → Places → Thumbnails 화면에서 직접 올립니다(그때 화면 순서를 안내).
|
||||
|
||||
## 6. 나중에 할 것 (지금은 안 해도 됨)
|
||||
|
||||
- Open Cloud API 키 발급: 테스트용 플레이스를 만든 뒤, 권한을 그 게임 하나로 좁혀서 만듭니다. 화면을 보면서 안내합니다.
|
||||
- 로벅스 1,000개 구매: 분식집을 초중생에게 공개할 때 낼 환불형 수수료입니다. 출시 직전에 삽니다(DECISIONS.md 5절).
|
||||
- 설문(Maturity & Compliance Questionnaire): 출시 직전에 화면 순서대로 안내합니다.
|
||||
- 마일스톤마다 테스트 게임 링크를 드리면 10~20분 직접 해 보고 느낌만 알려 주세요.
|
||||
|
||||
## 다 했으면 알려 줄 것
|
||||
|
||||
- 사용자 이름(게임 페이지에 보일 이름)
|
||||
- 2단계 인증, 나이 확인, Studio 설치가 끝났는지
|
||||
- 2단계 인증과 신분증 나이 확인이 끝났는지
|
||||
- 4번 7단계에서 복사한 `Bunsik Tycoon` 주소
|
||||
- 5번에서 만든 API 키
|
||||
- 막힌 화면이 있으면 그 화면 캡처
|
||||
|
||||
근거: https://create.roblox.com/docs/production/publishing/kids-and-select , https://create.roblox.com/docs/production/publishing/account-verification , https://create.roblox.com/docs/studio/setup
|
||||
근거: https://create.roblox.com/docs/production/publishing/kids-and-select , https://create.roblox.com/docs/production/publishing/account-verification , https://create.roblox.com/docs/studio/setup , https://create.roblox.com/docs/cloud/auth/api-keys , https://create.roblox.com/docs/cloud/guides/usage-place-publishing
|
||||
|
||||
@@ -1,55 +1,124 @@
|
||||
# 분식집 타이쿤 — 첫 10분 경제 수치표 (초안)
|
||||
# 분식집 타이쿤 — 경제 수치표
|
||||
|
||||
목표: 첫 구매는 10초 안에, 그 뒤로는 40~90초마다 하나씩 사고, 10분 무렵 "실내 분식집 확장"(2단계)에 닿게 합니다.
|
||||
숫자는 `tools/economy_sim.py`로 1초 단위 시뮬레이션을 돌려 맞췄습니다. 표를 고치면 시뮬레이터도 같이 고치고 다시 돌립니다.
|
||||
2026-10-14 개편: 한 줄로 쭉 사던 업그레이드 20개를 **갈래별 업그레이드**로 나누고, 자리는 **테이블·의자를 사서 원하는 곳에 놓는** 방식으로 바꿨습니다. 손님은 예전보다 느리게 옵니다(6초 → 10초).
|
||||
같은 날 2차 조정: 손님 간격을 10초 → 20초로 한 번 더 늘리고, 1분 매출이 그대로 가도록 음식 값을 모두 2배로 올렸습니다. 테이블과 의자는 따로 삽니다.
|
||||
숫자의 원본은 `src/shared/Economy.luau`입니다. 표의 시각은 시뮬레이터 `tools/sim.luau`가 **실제 게임 로직(`src/shared/Shop.luau`)**을 봇으로 돌려서 낸 값입니다.
|
||||
|
||||
```
|
||||
lune run tools/sim.luau # 기본
|
||||
lune run tools/sim.luau x2 # 2배 수익 게임패스
|
||||
lune run tests/Sim.spec.luau # 목표 범위 자동 검사(check.sh에 포함)
|
||||
```
|
||||
|
||||
## 기본 설정
|
||||
|
||||
| 항목 | 값 | 설명 |
|
||||
|---|---|---|
|
||||
| 처음 테이블 수 | 1 | 동시에 앉을 수 있는 손님 수 |
|
||||
| 손님 간격 | 6초 | 빈자리가 없으면 그냥 지나감 |
|
||||
| 조리 시간 | 2.5초 | 조리대에서 버튼을 누르고 있는 시간 |
|
||||
| 왕복 시간 | 약 5초 | 조리대 → 테이블 → 조리대 |
|
||||
| 식사 시간 | 6초 | 다 먹으면 자리가 빔 |
|
||||
| 처음 자리 | 테이블 1 + 의자 1 | 손님 자리 수 = 놓은 의자 수 |
|
||||
| 손님 간격 | 20초 | 빈자리가 없으면 그냥 지나감. 접속하자마자 첫 손님 |
|
||||
| 손님 걷기 | 길 길이 ÷ 18 stud/초 | 입구에서 의자까지 실제 길을 걸음(1.5~9초). 2층은 계단을 올라감 |
|
||||
| 조리(화구 수준) | 2.5 | 요리 창의 누르는 양 기준(`src/shared/Recipes.luau`) |
|
||||
| 식사 시간 | 6초 | 다 먹으면 자리가 빔. 돈은 접시를 놓는 순간 들어옴 |
|
||||
| 처음 메뉴 | 떡볶이 30원 | |
|
||||
| 시작 돈 | 0 | |
|
||||
|
||||
## 메뉴 가격
|
||||
## 업그레이드 갈래
|
||||
|
||||
| 메뉴 | 한 접시 | 해금 |
|
||||
같은 갈래 안에서는 앞 단계부터 차례로 삽니다. "필요 건물"보다 낮은 단계에서는 잠겨 있습니다.
|
||||
|
||||
| 갈래 | 단계별 효과와 값 | 필요 건물 |
|
||||
|---|---|---|
|
||||
| 떡볶이 | 10 | 처음부터 |
|
||||
| 김밥 | 20 | 구매 2번 |
|
||||
| 순대 | 35 | 구매 6번 |
|
||||
| 건물 | 실내 분식집 450 → 2층 5,000 | 2층은 실내부터 |
|
||||
| 메뉴 | 김밥(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층 |
|
||||
| 손님 속도(간격) | 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 | 포장마차 |
|
||||
|
||||
손님은 해금된 메뉴를 돌아가며 주문합니다.
|
||||
## 자리(꾸미기)
|
||||
|
||||
## 구매 순서와 시점
|
||||
- 의자: s번째 자리 값 = 10 × (s−1)^2.1 (5원 단위). 2번째 10원, 3번째 45원, 4번째 100원, 8번째 595원, 12번째 1,540원, 24번째 7,240원.
|
||||
- 테이블: 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`).
|
||||
|
||||
"도달 시각"은 쉬지 않고 최적으로 플레이했을 때의 값입니다. 실제 아이들은 1.3~1.5배쯤 걸릴 것으로 보고, 출시 전 플레이 테스트로 다시 맞춥니다.
|
||||
## 알바생
|
||||
|
||||
| # | 구매 | 비용 | 효과 | 도달 시각 | 2배 게임패스 |
|
||||
|---|---|---|---|---|---|
|
||||
| 1 | 테이블 2 | 10 | 테이블 1 → 2 | 0:08 | 0:08 |
|
||||
| 2 | 김밥 해금 | 40 | 메뉴 추가(20) | 0:46 | 0:28 |
|
||||
| 3 | 간판 Lv1 | 70 | 손님 간격 6 → 5초 | 1:32 | 0:46 |
|
||||
| 4 | 화구 Lv1 | 90 | 조리 2.5 → 1.5초 | 2:22 | 1:12 |
|
||||
| 5 | 테이블 3 | 120 | 테이블 2 → 3 | 3:23 | 1:42 |
|
||||
| 6 | 순대 해금 | 160 | 메뉴 추가(35) | 4:33 | 2:25 |
|
||||
| 7 | 양념 비법 Lv1 | 240 | 모든 메뉴 가격 1.5배 | 5:50 | 3:07 |
|
||||
| 8 | 알바생 고용 | 360 | 조리 자동, 플레이어는 나르기만 | 7:14 | 3:49 |
|
||||
| 9 | 테이블 4 | 480 | 테이블 3 → 4, 손님 간격 5 → 4초 | 8:31 | 4:26 |
|
||||
| 10 | 실내 분식집 확장 | 600 | 2단계 진입(새 맵 구역, 다음 업그레이드 줄) | 10:01 | 5:11 |
|
||||
알바생 기능을 산 뒤 역할별로 돈을 내고 고용합니다. 시급은 1분마다(게임 속 1시간 = 1분) 나가고, 판매 금액 배율만큼 오릅니다. 돈이 모자라면 빚 없이 알바생이 쉬고(💤), 돈이 생기면 다시 일합니다.
|
||||
|
||||
구매 간격은 8초 → 38초 → 46초 → … → 90초로 조금씩 늘어납니다. 비용은 한 단계에 약 1.3배씩 오릅니다.
|
||||
| 역할 | 하는 일 | 고용비 | 시급(기본) | 최대 |
|
||||
|---|---|---|---|---|
|
||||
| 요리 알바 | 카운터에 접시를 만들어 둠(조리 수준 초마다 1개) | 200 | 12 | 2 |
|
||||
| 서빙 알바 | 카운터 접시를 손님 자리로 날라 줌 | 500 | 15 | 2 |
|
||||
| 홍보 알바 | 입구에서 전단지, 손님 간격 x0.75 | 400 | 10 | 1 |
|
||||
|
||||
## 10분 이후 규칙 (2단계부터)
|
||||
## 구매 순서와 시점(봇)
|
||||
|
||||
- 같은 종류 업그레이드의 다음 레벨 비용은 이전 비용의 1.15배로 시작하고, 매출이 느는 속도에 맞춰 시뮬레이터로 조정합니다.
|
||||
- 구매 간격 목표: 2단계는 1~2분, 3단계는 2~4분.
|
||||
- 오프라인 수익과 체인점(리버스, 영구 수익 배율)은 2차 업데이트에서 넣습니다.
|
||||
봇은 지금 살 수 있는 것 중 가장 싼 것부터 삽니다(갈래 업그레이드, 의자, 테이블, 알바 고용). 쉬지 않고 플레이했을 때의 값이고, 아이들은 1.3~1.5배쯤 걸릴 것으로 봅니다. 실내 확장만 먼저 노리면 더 빨리 살 수 있습니다.
|
||||
|
||||
## 게임패스·상품과의 관계
|
||||
| # | 구매 | 값 | 도달 시각 | 2배 게임패스 |
|
||||
|---|---|---|---|---|
|
||||
| 1 | 의자 1개 | 10 | 0:09 | 0:09 |
|
||||
| 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 |
|
||||
|
||||
- 2배 수익 게임패스는 진행 속도를 약 2배로 만듭니다(위 표의 오른쪽 열). 무과금 유저도 10분에 확장할 수 있으니, 결제하지 않아도 답답하지 않은 선입니다.
|
||||
- 돈 부스트 팩(개발자 상품)은 "현재 1분 매출 × N분" 방식으로 줍니다. 고정 금액으로 주면 후반에는 쓸모가 없어지고 초반에는 밸런스를 깨기 때문입니다.
|
||||
- 첫 구매(의자)는 9초, 포장마차 단계 구매 간격은 11~74초입니다.
|
||||
- 실내 분식집은 11분(2배 게임패스 5분), 2층은 50분(23분)입니다.
|
||||
- 2층 뒤에는 판매 금액 5·6단계, 손님 속도 6·7단계, 남은 자리(최대 24석)가 남습니다.
|
||||
|
||||
## 유료 상품
|
||||
|
||||
| 상품 | 종류 | 가격(로벅스) | 효과 |
|
||||
|---|---|---|---|
|
||||
| 2배 수익 | 게임패스 | 199 | 모든 판매 금액 2배 |
|
||||
| 무지개 가게 이름 | 게임패스 | 99 | 이름판·간판 글자가 무지개로 움직임(모두에게 보임). 켜고 끌 수 있음 |
|
||||
| 사탕 궁전 디자인 | 게임패스 | 149 | 실내 분식집 이상 건물 디자인(하트·막대사탕·체크무늬 바닥) |
|
||||
| 한옥 분식집 디자인 | 게임패스 | 149 | 기와지붕·나무 기둥·등롱 |
|
||||
| 돈 부스트 팩 | 개발자 상품 | 25 | 지금 1분 매출 × 10분(최소 100원) |
|
||||
| 손님 러시 | 개발자 상품 | 15 | 10분 동안 손님 간격 절반 |
|
||||
| 옆 가게 손님 쫓아내기 | 개발자 상품 | 15 | 고른 옆 가게에서 음식을 아직 못 받은 손님이 모두 일어나고, 우리 빈자리만큼 우리 가게로 옴. 당한 가게는 3분 동안 다시 당하지 않음 |
|
||||
| 홍보(광고 보상) | 보상형 광고 | 무료 | 광고를 보면 옆 가게 손님이 최대 3명(빈자리만큼) 옴. 광고 대기 45초. 광고를 볼 수 없으면 광고 없이 3분마다 홍보 |
|
||||
|
||||
- 무료 디자인: 기본(크림), 민트 카페, 벽돌 분식집.
|
||||
- 홍보는 NPC 이웃 가게 손님부터 데려와서 다른 플레이어 가게는 되도록 건드리지 않습니다.
|
||||
|
||||
98
bunsik-tycoon/NETWORK.md
Normal file
@@ -0,0 +1,98 @@
|
||||
# 서버 ↔ 클라이언트 약속 (2026-10-14 개편)
|
||||
|
||||
서버는 상태를 **속성(Attribute)** 으로 내보내고, 클라이언트는 `Remotes.Action:FireServer(kind, arg)` 로 요청합니다.
|
||||
알림은 `Remotes.Notify:FireClient(player, key, args)` 이고, 글자는 클라이언트가 `Locale.t(lang, key, args)` 로 씁니다.
|
||||
경제·배치 규칙은 공용 모듈(`src/shared/Economy.luau`, `Shop.luau`, `Floor.luau`)이 원본입니다. 클라이언트는 같은 모듈로 값·미리보기를 계산하고, 서버가 다시 검사합니다.
|
||||
|
||||
## 플레이어 속성 (Player)
|
||||
|
||||
| 속성 | 형 | 뜻 |
|
||||
|---|---|---|
|
||||
| Ready | bool | 세이브 로드 끝 |
|
||||
| Plot | number | 내 부지 번호 |
|
||||
| Money, Earned | number | 돈, 지금까지 번 돈 |
|
||||
| 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`. 의자는 `{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분마다 주는 시급 합계 |
|
||||
| RushUntil | number | 손님 러시가 끝나는 서버 시각(`workspace:GetServerTimeNow()` 기준, 0이면 없음) |
|
||||
| PromoteAt | number | 다음 홍보를 할 수 있는 서버 시각(광고 없이) |
|
||||
| PromoteAdAt | number | 광고를 보고 홍보할 수 있는 서버 시각 |
|
||||
| KickCredits | number | 남은 "손님 쫓아내기" 횟수(유료로 산 것) |
|
||||
| ShopName | string | 내가 정한 가게 이름 원문("" = 기본 이름). 다른 사람에게 보이는 이름은 부지 속성 ShopName(필터 거친 글) |
|
||||
| Rainbow | bool | 무지개 이름 켜기 설정 |
|
||||
| NameColor | number | 가게 이름 글자색(Economy.NAME_COLORS 번호 1~10, 0 = 디자인 기본색) |
|
||||
| DevFree | bool | 개발자 결제 테스트 모드(로벅스 버튼이 결제 없이 바로 지급, 이번 접속만) |
|
||||
| RainbowOwned | bool | 무지개 이름 게임패스 보유 |
|
||||
| Design | string | 건물 디자인 id(Economy.DESIGNS) |
|
||||
| DesignsOwned | string | 유료 디자인 보유 목록 `"Candy,Hanok"` |
|
||||
| Double | bool | 2배 수익 |
|
||||
| Boost | number | 돈 부스트 팩 지급액 |
|
||||
| Tut | number | 튜토리얼 단계(0 끝, 1 조리대로, 2 서빙, 3 가게 꾸미기에서 의자 놓기) |
|
||||
| Carry, Hand | number, string | 든 접시 수, 든 메뉴 `"Gimbap,Sundae"` |
|
||||
| Orders | string | 메뉴별 열린 주문 `"Tteokbokki=2,Gimbap=1"` |
|
||||
| Lang, LangSetting, MouseLook, Sfx, Dev | | 설정(예전과 같음) |
|
||||
|
||||
## 부지 모델 속성 (workspace.BunsikWorld.Plots.PlotN, 모두에게 보임)
|
||||
|
||||
| 속성 | 뜻 |
|
||||
|---|---|
|
||||
| OwnerId, OwnerName | 플레이어 가게 주인 |
|
||||
| Npc | 이웃 가게(NPC) 번호 |
|
||||
| Level | 가게 레벨(Economy.shopLevel) |
|
||||
| Stage | 건물 단계 |
|
||||
| Menus | 파는 메뉴 `"Tteokbokki,Gimbap"` (메뉴판) |
|
||||
| PriceMult | 판매 금액 배율(메뉴판 값) |
|
||||
| ShopName | 필터를 거친 가게 이름("" = 기본 이름 "{name}의 분식집") |
|
||||
| Rainbow | 무지개 이름(게임패스 + 켜짐). 켜져 있으면 NameColor보다 먼저 |
|
||||
| NameColor | 가게 이름 글자색 번호(0 = 기본) |
|
||||
| Design | 건물 디자인 |
|
||||
| ShieldUntil | 손님 쫓아내기 보호가 끝나는 서버 시각 |
|
||||
| Origin | 부지 기준 CFrame. 배치 좌표 (x, z, 층 f) → 월드: `Origin * CFrame.new(x, Floor.BASE_Y + (f == 2 and Floor.FLOOR2_Y or 0), z)` |
|
||||
|
||||
## 배치 물건 모델
|
||||
|
||||
부지 안 `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)
|
||||
|
||||
| kind | arg | 서버가 하는 일 |
|
||||
|---|---|---|
|
||||
| `cookStart`, `cook` | 메뉴 | 요리 창(예전과 같음) |
|
||||
| `upgrade` | 갈래 id | 다음 단계 구매 |
|
||||
| `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"/"chair"/"decor", i, x, z, f, r}` | 옮기기(Floor.move로 검사). 테이블의 r은 그 테이블을 보는 의자들을 테이블 둘레로 돌리는 횟수(의자도 같이 옮겨짐) |
|
||||
| `remove` | `{kind="table"/"chair"/"decor", i}` | 꾸미기 [삭제]: 지우고 산 값 돌려받기(Floor.remove + Shop.removeSeat 검사, 실패면 `removeFail`) |
|
||||
| `nameColor` | 0~10 | 가게 이름 색(고르면 무지개는 꺼짐) |
|
||||
| `hire`, `fire` | 역할 id | 알바 고용·해고 |
|
||||
| `rename` | 문자열(최대 20자) | 이름 바꾸기(TextService 필터) |
|
||||
| `rainbow` | bool | 무지개 이름 켜기/끄기. 없으면 게임패스 결제 창 |
|
||||
| `design` | 디자인 id | 디자인 바꾸기(실내 분식집부터). 유료인데 없으면 결제 창 |
|
||||
| `promote` | `{ad=bool}` | 홍보. ad=true면 보상형 광고(서버가 AdService로 띄움), 아니면 대기 시간 확인 후 바로 |
|
||||
| `kick` | 부지 번호 | 손님 쫓아내기. 횟수가 있으면 바로 쓰고, 없으면 결제 창(결제되면 그 부지에 씀) |
|
||||
| `rush` | nil | 손님 러시 결제 창 |
|
||||
| `visit`, `lang`, `mouseLook`, `sfx`, `pass`, `boost`, `dev_*` | | 예전과 같음. `dev_free`는 결제 테스트 모드 켜기/끄기(게임 주인만) |
|
||||
|
||||
## 알림 키 (Notify)
|
||||
|
||||
예전 키(`purchased` 등)에 더해:
|
||||
- `upgraded {track, level}` 갈래 업그레이드, `newMenu {menu}`, `expanded`(실내), `floor2`(2층)
|
||||
- `seatAdded`, `tableAdded`, `decorAdded {kind}`, `noSpace`(놓을 곳 없음), `seatMax`, `tableMax`, `needStage`
|
||||
- `placeFail {why}`: why = bounds | overlap | reserved | floor | blocked | chair
|
||||
- `hired {role}`, `fired {role}`, `staffLocked`, `staffMax`, `strike`(시급 부족), `strikeOver`
|
||||
- `renamed`, `nameRejected`(필터 실패·빈 이름), `designSet {design}`, `designLocked`(실내 분식집부터)
|
||||
- `promoted {n}`, `promoteNone`(데려올 손님 없음), `promoteFull`(빈자리 없음), `promoteWait {sec}`, `adUnavailable`
|
||||
- `kicked {n, shop}`(내가 쫓아냄), `kickedBy {name}`(내 가게 손님이 쫓겨남), `shielded`(보호 중), `kickOwn`(내 가게는 안 됨)
|
||||
- `removed {thing, money}`, `removeFail {why}`(why = stove | last | hasChairs | busy | 배치 검사 이유), `devFreeOn`, `devFreeOff`
|
||||
- `rushOn {min}`, `notEnough {need}`, `doubleOwned`(2배 수익 게임패스를 이미 가지고 있어 결제 창 대신 바로 켬)
|
||||
51
bunsik-tycoon/PLAYTEST.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# 분식집 타이쿤 — 직접 해 보기 안내
|
||||
|
||||
## 들어가는 법
|
||||
|
||||
1. `tkrmagid` 계정으로 로그인한 PC나 휴대폰에서 https://www.roblox.com/games/98118751156219/Bunsik-Tycoon 을 엽니다.
|
||||
2. 초록색 플레이 버튼을 누릅니다. 게임은 비공개라서 주인 계정만 들어갈 수 있습니다.
|
||||
3. 들어가면 바로 내 가게 조리대 앞으로 옮겨집니다. 예전 저장(한 줄 업그레이드)은 새 구조로 자동으로 옮겨집니다(산 만큼 갈래 레벨·테이블·의자·요리 알바로).
|
||||
|
||||
## 해 볼 것 (20~30분)
|
||||
|
||||
1. 튜토리얼: 노란 줄과 화살표를 따라 조리대로 가서 [요리하기](PC는 E)를 누르고, 손님이 주문한 메뉴를 만들어 손님 자리로 가져갑니다. 안내 말풍선은 화면 **아래 가운데**에 나옵니다(예전 [사기] 막대는 없앰).
|
||||
2. 돈이 생기면 말풍선과 손가락이 [가게 꾸미기] 버튼을 가리킵니다. 의자를 골라 테이블 앞에 놓으면 튜토리얼이 끝납니다.
|
||||
3. 분홍 [상점] 버튼: 탭 3개
|
||||
- 업그레이드: 건물(포장마차 → 실내 분식집 → 2층), 새 메뉴, 판매 금액, 손님 속도, 화구, 쟁반, 알바생 기능을 따로따로 삽니다. 실내 분식집이 필요한 것은 자물쇠와 "실내 분식집부터"가 붙습니다.
|
||||
- 알바생: 알바생 기능을 사면 열립니다. 요리·서빙·홍보 알바를 고용하고 뺄 수 있고, 시급은 1분마다 나갑니다. 돈이 모자라면 알바생 머리 위에 💤가 뜨고 쉽니다.
|
||||
- 내 가게: 가게 이름 쓰고 [저장]. **이름 색**은 무료 10색(빨강·주황·노랑·초록·하늘·파랑·보라·분홍·흰색·검정) 중에서 고르고(고른 색을 다시 누르면 디자인 기본색), 맨 오른쪽 무지개 칸은 💎 게임패스입니다. 건물 디자인 5개(실내 분식집부터, 사탕 궁전·한옥은 💎 게임패스).
|
||||
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. 손님은 예전보다 훨씬 느리게 옵니다(처음 20초에 한 명). 대신 음식값을 2배로 올려서 버는 속도는 비슷합니다. 업그레이드의 손님 속도, 홍보 알바, 손님 러시로 빨라집니다.
|
||||
10. 다른 플레이어가 같은 서버에 있으면, 가게 이름·무지개 이름·건물 디자인이 그 사람 화면에도 보이는지 봐 주세요.
|
||||
11. 나갔다가 다시 들어와서 돈·업그레이드·배치·알바생·이름·디자인이 그대로인지 봅니다.
|
||||
|
||||
## 개발자 테스트 버튼(주인 계정에만 보임)
|
||||
|
||||
[설정] 창 맨 아래 `개발자 테스트` 줄:
|
||||
- `+1,000원`: 돈을 바로 넣습니다. 뒤쪽 업그레이드를 빨리 확인할 때 씁니다(여러 번 누르면 2층까지 빨리 갈 수 있음).
|
||||
- `결제 테스트 켜기/끄기`: 켜면 **로벅스 버튼이 결제 창 없이 바로 됩니다**(이번 접속만). 2배 돈, 부스트, 손님 러시, 쫓아내기(옆 가게 입구 F), 홍보 광고 보상(광고 없이 바로), 무지개 이름, 유료 디자인(사탕 궁전·한옥)을 진짜 로벅스 없이 시험할 수 있습니다. 켜는 순간 게임패스는 "안 가진 상태"로 바뀌어서 사는 과정을 볼 수 있고, 끄면 실제로 가진 게임패스로 돌아갑니다(게임 주인 계정은 게임패스를 모두 자동으로 가지고 있음).
|
||||
- `2배 켜기/끄기`: 2배 수익을 켜고 끕니다(이번 접속에만 적용).
|
||||
- `처음부터`: 돈·업그레이드·배치·알바생·튜토리얼을 처음으로 되돌립니다. 이름과 산 게임패스(2배 수익 포함)는 남습니다.
|
||||
|
||||
`결제 테스트`를 끈 상태에서는 [2배 돈], [부스트], 손님 러시, 쫓아내기, 무지개 이름, 유료 디자인이 진짜 결제 창을 띄웁니다. 결제 테스트가 필요하면 꼭 먼저 `결제 테스트 켜기`를 누르세요.
|
||||
|
||||
## 알려 주시면 좋은 것
|
||||
|
||||
- 가게 꾸미기: 투명 미리보기가 캐릭터 앞에서 잘 따라오는지, 거리가 적당한지, 돌리기·배치·이동·삭제가 쉬운지, 휴대폰에서 아래 물건 줄과 버튼이 조이스틱·점프에 안 가리는지
|
||||
- 손님·알바생이 걷고 앉는 모습, 동물 손님 모습이 어색하지 않은지
|
||||
- 서빙 알바가 접시를 들고 손님에게 가는 모습
|
||||
- 너무 빠르거나 느리다고 느낀 구간(어떤 업그레이드 근처인지). 손님이 너무 느리게 오는지
|
||||
- 휴대폰에서 버튼이 가려지거나 누르기 어려운 곳, 글자가 넘치거나 그림이 빈 네모로 나오는 곳
|
||||
- 오류나 멈춤이 있었다면 그때 한 행동과 화면 캡처
|
||||
@@ -20,7 +20,7 @@
|
||||
- 1단계: 떡볶이 포장마차 1대, 테이블 1개 (튜토리얼)
|
||||
- 2단계: 메뉴 추가(김밥·순대·튀김·어묵), 손님 증가
|
||||
- 3단계: 실내 분식집으로 확장, 직원 고용
|
||||
- 4단계: 2호점/멀티플로어, 인테리어 테마 해금
|
||||
- 4단계: 2층(2026-10-14 사용자 요청으로 2호점 대신), 인테리어 테마(건물 디자인) 해금
|
||||
- 5단계: 전국 체인 + 한정 메뉴 + 별 5개 평점 제국
|
||||
|
||||
## 5. 주요 시스템
|
||||
@@ -56,13 +56,10 @@
|
||||
- 가챠는 2차에도 넣지 않음
|
||||
|
||||
## 8. 제작 일정 (마일스톤)
|
||||
코드는 AI가 쓰고 사용자가 매일 1~2시간 테스트한다고 보고 3주로 잡았습니다(원안 14일).
|
||||
- M0 (0주차): 사용자 계정 준비(2단계 인증, 나이 확인, Studio 설치, API 키) + Rojo 골격
|
||||
- M1 (1주차 전반): 부지 배정 + 맵 블록아웃 + 조리대/요리 + 돈 수금
|
||||
- M2 (1주차 후반): 손님 AI 동선·주문·지불
|
||||
- M3 (2주차 전반): 업그레이드 10개·실내 확장 + ProfileStore 세이브
|
||||
- M4 (2주차 후반): 게임패스·개발자 상품 + UI 다듬기 + 한국어·영어
|
||||
- M5 (3주차): 플레이 테스트·밸런싱 + 썸네일/아이콘 + 설문 작성 + 출시(16세 이상 공개)
|
||||
제작·테스트는 AI가 하고, 사용자는 마일스톤마다 직접 플레이해 보는 것만 한다고 보고 3주로 잡았습니다(원안 14일).
|
||||
- M0 (0주차): 사용자 계정 준비(2단계 인증, 나이 확인, 빈 게임 Publish 1회, API 키) + Rojo 골격(완료)
|
||||
- M1~M4: 맵·조리·손님·업그레이드 20개(1단계 10 + 2단계 10)·세이브·게임패스·개발자 상품·한국어/영어 UI(2026-10-12 완료, 비공개 게임 버전 6에 올림. 사용자 플레이 테스트 단계. 해 보는 법은 `PLAYTEST.md`)
|
||||
- M5 (3주차): 사용자 플레이 테스트 반영·밸런싱 + 게임 아이콘/썸네일 + 설문 작성 + 출시(16세 이상 공개)
|
||||
- 출시 후 60일: 초중생 계정 공개 조건(조건 충족 유저의 고유 플레이 250회, 약 250명) 달성
|
||||
|
||||
## 9. 기술 스택
|
||||
@@ -94,28 +91,48 @@
|
||||
- 소셜(MVP): 남의 가게에 걸어 들어가 구경할 수 있고, 친구와 같은 서버에서 놉니다.
|
||||
- 소셜(2차): 친구 가게의 손님이 되어 주문하기, 친구를 직원으로 고용하기.
|
||||
|
||||
### B. 요리 조작: 누르고 있기 + 들고 가서 내려놓기
|
||||
1. 조리대에 다가가면 "떡볶이 만들기" 버튼이 뜹니다(로블록스 기본 ProximityPrompt). PC는 E키, 모바일은 화면 터치.
|
||||
2. 버튼을 2.5초 누르고 있으면 완성됩니다. 게이지가 차고, 지글지글 조리음이 납니다(쇼츠용 ASMR 포인트).
|
||||
3. 완성된 접시를 손에 들고 주문한 손님 테이블에 가면 자동으로 놓입니다.
|
||||
4. 손님이 먹고 돈을 내면 동전이 튀어나오고 "+10" 숫자가 뜹니다.
|
||||
- 타이밍 맞추기는 넣지 않습니다. 어린 아이가 실패하면 바로 그만두기 때문입니다.
|
||||
- 손님 머리 위 말풍선에 메뉴 그림을 띄워서 글을 못 읽어도 알 수 있게 합니다.
|
||||
- 처음 접속하면 화살표가 조리대 → 손님 순서로 안내합니다. 첫 서빙까지 30초 안이 목표입니다.
|
||||
- "화구" 업그레이드로 누르는 시간이 짧아지고, "알바생"을 고용하면 조리가 자동이 됩니다.
|
||||
### B. 요리 조작: 요리 창(메뉴 고르기 → 메뉴별 조리 과정 → 완성) + 들고 가서 내려놓기
|
||||
2026-10-13 사용자 요청으로 "버튼 꾹 누르기"에서 바꿨습니다. 코드는 `src/shared/Recipes.luau`(과정·진행 상태), `src/client/Kitchen.luau`(화면).
|
||||
1. 조리대에 다가가 버튼(PC는 E키, 휴대폰은 터치)을 누르면 요리 창이 열립니다. 창이 열린 동안은 캐릭터가 움직이지 않습니다.
|
||||
2. 메뉴 고르기: 해금된 메뉴 카드에 손님 얼굴과 주문 수(x2)가 붙고 통통 튑니다. 주문이 없는 메뉴는 흐리게, 안 산 메뉴는 자물쇠입니다.
|
||||
- 주문 없는 메뉴는 고를 수 없습니다. 아무도 안 시킨 접시를 들고 갇히는 일을 막기 위해서입니다(서버도 같은 규칙으로 검사).
|
||||
3. 조리: 메뉴마다 2~3단계이고, 단계마다 조작이 다릅니다. 창 안 어디를 눌러도 되고 실패는 없습니다.
|
||||
- 떡볶이(팬): 떡 넣기(톡톡) → 양념 붓기(꾹) → 젓기(문지르기)
|
||||
- 김밥(도마): 재료 올리기(톡톡) → 말기(문지르기) → 썰기(톡톡)
|
||||
- 순대(찜기): 넣기(톡톡) → 찌기(꾹) → 썰기(톡톡)
|
||||
- 어묵(냄비): 꼬치에 끼우기(톡톡) → 국물에 담그기(꾹)
|
||||
- 튀김(튀김기): 튀김옷(문지르기) → 튀기기(꾹) → 건지기(톡톡)
|
||||
- 단계 표시는 글 대신 도구 그림 동그라미 1-2-3, 손가락 그림이 할 동작(톡톡·꾹·좌우로 문지르기)을 보여 줍니다. 누를 때마다 재료가 쌓이고 효과음이 납니다.
|
||||
4. 완성: 접시가 튀어나오고 마스코트 떡이가 기뻐합니다. 주문이 남고 손에 자리가 있으면 바로 다음 메뉴 고르기, 아니면 창이 닫힙니다.
|
||||
5. 완성된 접시를 손에 들고 주문한 손님 테이블에 가면 자동으로 놓입니다. 손님 머리 위 말풍선은 음식 그림이고, 받으면 하트로 바뀝니다.
|
||||
- 다른 게임과 비교해 정한 것: Papa's 시리즈·Cooking Mama처럼 단계마다 다른 짧은 동작을 쓰되, 어린아이가 실패하면 그만두므로 태우기·시간 제한은 넣지 않았습니다(Restaurant Tycoon 2도 실패 없음). 한 접시 4~6초로 짧게 하고, 반복이 지루해지지 않게 "화구" 업그레이드가 누르는 양을 60%·40%로 줄이고 "알바생"이 자동으로 만들어 줍니다.
|
||||
- 한 접시에 손이 더 가므로 1단계 메뉴 값을 올렸습니다(`ECONOMY.md`).
|
||||
|
||||
### C. 경제 수치
|
||||
- 첫 10분 표: `ECONOMY.md`. 첫 구매 0:08, 10번째 구매(실내 확장) 10:01.
|
||||
- 시뮬레이터: `tools/economy_sim.py`.
|
||||
- 첫 10분 표: `ECONOMY.md`. 첫 구매 0:05, 10번째 구매(실내 확장) 9:39.
|
||||
- 시뮬레이터: `tools/sim.luau`(실제 게임 로직 Shop.luau를 봇이 플레이). 표는 1단계 10개 + 2단계 10개.
|
||||
|
||||
### D. 출시 대상과 언어
|
||||
- 출시 직후 60일은 나이 확인을 마친 16세 이상만 볼 수 있습니다. 그동안 조건 충족 유저의 고유 플레이 250회(서로 다른 유저 약 250명)를 모아야 초중생 계정(Kids·Select)에 공개됩니다.
|
||||
- 그래서 MVP부터 한국어·영어를 같이 넣고, 홍보는 "K-푸드 타이쿤"으로 해외 유저까지 노립니다.
|
||||
- 콘텐츠 등급은 Minimal(가장 낮은 단계)을 목표로 합니다. Kids 계정은 Minimal·Mild만 볼 수 있습니다.
|
||||
|
||||
### F. 2026-10-14 개편(사용자 요청 목록 반영)
|
||||
- 업그레이드를 갈래별로 나눔: 건물(포장마차 → 실내 분식집 → 2층), 메뉴, 판매 금액, 손님 속도, 화구, 쟁반, 알바생 기능. 수치는 `ECONOMY.md`, 코드는 `src/shared/Economy.luau`.
|
||||
- 손님 간격 6초 → 10초(느리게). 빨리 오게 하는 방법: 손님 속도 갈래, 홍보 알바(x0.75), 손님 러시(유료, 10분 x0.5).
|
||||
- 꾸미기: 테이블·의자·소품을 사서 원하는 곳에 놓고, 조리대(수레)도 옮김. 의자는 테이블의 앞·뒤·왼쪽·오른쪽 중 한 곳에 붙음(손님이 테이블을 보고 앉고 접시가 테이블 위에 놓이게). 검사는 서버가 다시 함: 부지 안, 겹침 없음, 문 앞·계단 비움, 문에서 조리대 앞과 모든 의자까지 길이 있어야 함(`src/shared/Floor.luau`). 손님은 그 길을 따라 걷고, 2층 손님은 계단을 올라감.
|
||||
- 알바생: 알바생 기능 업그레이드 뒤 역할별 고용(요리·서빙·홍보). 시급은 1분마다 나가고, 돈이 모자라면 빚 없이 쉼.
|
||||
- 가게 이름: 20자, TextService 필터를 거친 글만 다른 사람에게 보임(필터 실패 시 기본 이름). 무지개 이름은 게임패스.
|
||||
- 건물 디자인: 실내 분식집부터. 무료 3종(기본·민트·벽돌), 유료 게임패스 2종(사탕 궁전·한옥).
|
||||
- 홍보: 보상형 광고(AdService)를 보면 옆 가게 손님이 최대 3명 옴. 광고는 13세 미만·일부 지역에는 나오지 않고, 게임이 공개되고 월 방문자 2,000명 이상 등 조건을 채워야 나옵니다. 그래서 광고를 볼 수 없으면 광고 없이 3분마다 홍보할 수 있게 했습니다(광고가 진행을 막지 않게 하라는 로블록스 규칙에도 맞음). NPC 이웃 가게 손님부터 데려옵니다.
|
||||
- 손님 쫓아내기(유료): 고른 옆 가게의 음식을 아직 못 받은 손님이 모두 일어나 우리 빈자리만큼 우리 가게로 옴. 다른 플레이어 가게에도 쓸 수 있어서 "돈 내고 남 괴롭히기"로 신고될 수 있습니다. 그래서 당한 가게는 3분 보호, 먹는 손님·플레이어 손님은 건드리지 않음, 당한 사람에게 알림. 출시 전에 NPC 이웃 가게에만 쓰게 바꿀지 다시 정합니다.
|
||||
- 손님 외형: 사람이 가장 많이, 가끔 동물 손님.
|
||||
|
||||
### E. 가격(초안, 출시 후 Managed Pricing으로 조정)
|
||||
| 상품 | 종류 | 가격 |
|
||||
|---|---|---|
|
||||
| 2배 수익 | 게임패스 | 199 로벅스 |
|
||||
| 돈 부스트 팩(현재 매출 10분치) | 개발자 상품 | 25 로벅스 |
|
||||
| 자동 요리사, VIP 테마, 추가 가게 슬롯 | 게임패스(2차) | 149~299 로벅스 |
|
||||
| 무지개 가게 이름 | 게임패스 | 99 로벅스 |
|
||||
| 사탕 궁전·한옥 디자인 | 게임패스 | 각 149 로벅스 |
|
||||
| 손님 러시(10분), 손님 쫓아내기(1회) | 개발자 상품 | 각 15 로벅스 |
|
||||
|
||||
BIN
bunsik-tycoon/art/candy_design.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
bunsik-tycoon/art/double_money.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
bunsik-tycoon/art/game_icon.png
Normal file
|
After Width: | Height: | Size: 119 KiB |
BIN
bunsik-tycoon/art/hanok_design.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
bunsik-tycoon/art/kick.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
bunsik-tycoon/art/kitchen.png
Normal file
|
After Width: | Height: | Size: 142 KiB |
BIN
bunsik-tycoon/art/money_boost.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
bunsik-tycoon/art/promote_ad.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
bunsik-tycoon/art/rainbow_name.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
bunsik-tycoon/art/rush.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
bunsik-tycoon/art/thumbnail_1.png
Normal file
|
After Width: | Height: | Size: 190 KiB |
BIN
bunsik-tycoon/art/ui_icons.png
Normal file
|
After Width: | Height: | Size: 301 KiB |
BIN
bunsik-tycoon/assets/npc_animals.rbxm
Normal file
253
bunsik-tycoon/assets/npc_assets.md
Normal file
@@ -0,0 +1,253 @@
|
||||
# 손님 NPC 외형 에셋 (2026-10-14 확인)
|
||||
|
||||
결론: **Option A(HumanoidDescription)로 충분합니다.** 사람·동물 모두 R15 그대로라 기존 걷기·대기·앉기 애니메이션을 같이 씁니다.
|
||||
Option B(Creator Store 동물 모델)는 Luau Execution에서 남의 모델을 불러올 권한이 없어 막혔습니다(아래 참고). 직접 Part로 동물을 만들 필요는 없습니다.
|
||||
|
||||
## 확인 방법
|
||||
|
||||
- 확인 스크립트: `python3 tools/cloud.py run tools/npc_verify_avatars.luau --out assets/npc_animals.rbxm`
|
||||
(로블록스 서버, 최근 저장 버전에서 `Players:CreateHumanoidModelFromDescription(desc, Enum.HumanoidRigType.R15)`)
|
||||
- 아래 표의 아이템 73개를 하나씩 기본 몸에 붙여 봄: **73개 모두 적용**(장신구·Shirt·Pants 생성, Head 메시 교체 확인)
|
||||
- 사람 무작위 조합 6개 + 동물 프리셋 11개 = **17개 모두 생성 성공**. 각 모델: R15 관절 15개 이름 모두 있음, 스크립트 0개(Animate 제거 뒤), 높이 4.8~6.3, HipHeight 1.92~2.19
|
||||
- 애니메이션 3개(walk 507777826 / idle 507766388 / sit 2506281703)가 모든 모델의 Animator에서 로드됨(Length 0.67 / 3.77 / 0.92, IsPlaying true)
|
||||
- 관절은 새 아바타 관절(`AnimationConstraint`, `IsKinematic=true`)입니다. Luau Execution은 시뮬레이션을 돌리지 않아(`RunService:IsRunning()=false`, 떨어지는 블록도 그대로) **관절이 실제로 움직이는지는 서버 실행으로 확인 못 함** → Studio 플레이 테스트에서 한 번 눈으로 확인하세요. 몸 모양만 바꾼 R15라 일반 아바타와 같은 조건입니다.
|
||||
- 아이템 소유는 필요 없음: 유료 아이템(예: Pink Pigtails, Unicorn Beanie)도 서버에서 그대로 붙습니다.
|
||||
- 모든 ID는 로블록스 제작(Creator Id 1)입니다. `MarketplaceService:GetProductInfo`와 카탈로그 검색(`CreatorTargetId=1`)으로 확인했습니다.
|
||||
|
||||
## 중요 발견
|
||||
|
||||
1. **클래식 얼굴(`Face` 속성)은 이제 안 보입니다.** 기본 머리가 얼굴이 그려진 다이내믹 헤드라서, `Face = 144075659`(Smile)를 넣어도 머리 텍스처가 그대로이고 Decal도 생기지 않습니다. 얼굴을 바꾸려면 `Head`에 다이내믹 헤드 ID를 넣으세요(`FACE_HEADS`). 피부색은 `HeadColor` 등 description 색으로 줍니다.
|
||||
2. 장신구는 `Handle.AccessoryRigidConstraint`로 붙습니다(Weld 아님). 위치는 모델을 Workspace에 넣고 한 프레임(Heartbeat) 지나야 맞춰집니다.
|
||||
3. 동물 머리 모자 중 Beary Cute(28998435)·Cute Fox(61773267)는 머리 **위에** 얹히는 모양입니다(아랫면이 머리 아래보다 0.93 위). `HatAttachment.Position`을 그만큼 올리고 `Humanoid:AddAccessory`로 다시 붙이면 목 위치로 내려갑니다(확인: 차이 0.93 → 0). 다른 동물 머리는 처음부터 머리 전체를 덮습니다(차이 −0.09~0.15).
|
||||
4. 모델 안에 플레이어용 `Animate` LocalScript가 들어 있습니다. 서버 NPC에서는 돌지 않으니 지우면 됩니다.
|
||||
5. 지금 `Npc.luau`의 `colorize`는 부위 이름으로 색을 덮어씁니다. 동물 몸(텍스처가 있는 메시)과 옷 입은 사람에게는 쓰지 말고, 색은 description의 `*Color`로만 주세요.
|
||||
6. 생성 시간: 처음 1개 약 1초, 그다음은 0.02~0.35초. 서버 시작 때 종류별 템플릿을 만들어 두고 `Clone`하는 지금 방식이 맞습니다.
|
||||
|
||||
## Luau 데이터 표
|
||||
|
||||
```luau
|
||||
-- 사람: 로블록스 제작 머리카락(HairAccessory, 문자열로 넣음). 7193…/9244…는 레이어드 머리카락(자동으로 머리에 맞춰짐)
|
||||
local HAIR = {
|
||||
63690008, -- Pal Hair
|
||||
451221329, -- True Blue Hair
|
||||
376526888, -- Straight Blonde Hair
|
||||
376524487, -- Blonde Spiked Hair
|
||||
376548738, -- Brown Charmer Hair
|
||||
376527350, -- Black Ponytail
|
||||
451220849, -- Lavender Updo
|
||||
62234425, -- Brown Hair
|
||||
2956239660, -- Belle Of Belfast Long Red Hair
|
||||
3814476174, -- Colorful Braids
|
||||
24910539, -- Pink Pigtails
|
||||
7193442167, -- Pony Tail - Black
|
||||
9244095135, -- Pony Tail - Blonde
|
||||
6993754725, -- Straight Bangs - Black
|
||||
7193448258, -- Wavy Middle Part - Brown
|
||||
9243987340, -- Short and Sleek - Blonde
|
||||
7193450455, -- Curly Afro - Black
|
||||
7193452166, -- Short Curls - Black
|
||||
9244148336, -- Braided Hair - Blonde
|
||||
430063008, -- Strawberry Ice Cream Hair
|
||||
727320877, -- Long Pastel Hair
|
||||
}
|
||||
-- 어린이용 귀여운 모자(HatAccessory, 35% 정도만 씌우기 추천)
|
||||
local HATS = {
|
||||
1028606, -- Red Baseball Cap
|
||||
607702162, -- Roblox Baseball Cap
|
||||
321570512, -- Chill Cap
|
||||
10911990, -- Propeller Beanie
|
||||
67291394, -- Unicorn Beanie
|
||||
3756496643, -- Pizza Time Cap
|
||||
100932329, -- Pink Flower Crown
|
||||
150337770, -- Spring Crown of Flowers
|
||||
118280079, -- Narwhal Beanie
|
||||
215724779, -- Robot Beanie
|
||||
116778296, -- Wide-brimmed Straw Cap
|
||||
833771553, -- Starbling Beanie
|
||||
3756447657, -- Lil' Kitty Cap
|
||||
439943629, -- Sleepy Mouse Cap
|
||||
1536057124, -- Spring Bunny Headband
|
||||
}
|
||||
-- 클래식 옷(Shirt / Pants), 모두 무료
|
||||
local SHIRTS = {
|
||||
144076358, -- Blue and Black Motorcycle Shirt
|
||||
607785314, -- ROBLOX Jacket
|
||||
398633584, -- Denim Jacket with White Hoodie
|
||||
144076436, -- Grey Striped Shirt with Denim Jacket
|
||||
398634295, -- Pastel Starburst Top with Gray Jacket
|
||||
3670737444, -- Roblox Shirt - Simple Pattern
|
||||
382538059, -- Green Jersey
|
||||
398635081, -- Blue Plaid Shirt
|
||||
382537702, -- Teal Shirt
|
||||
382537085, -- I <3 Pizza Shirt
|
||||
382538295, -- Guitar Tee with Black Jacket
|
||||
4047884939, -- My Favorite Pizza Shirt
|
||||
4047884046, -- Guitar Tee with Black Jacket
|
||||
4047886060, -- Purple and Teal Top
|
||||
}
|
||||
local PANTS = {
|
||||
144076760, -- Dark Green Jeans
|
||||
398634487, -- Beautiful You Jeans
|
||||
398633812, -- Black Jeans with White Shoes
|
||||
398635338, -- Ripped Skater Pants
|
||||
382537806, -- Jean Shorts
|
||||
382538503, -- Black Jeans with Sneakers
|
||||
382537569, -- Black Jeans
|
||||
382537950, -- Jean Shorts with White Shoes
|
||||
}
|
||||
-- 얼굴 = 다이내믹 헤드(Head). 앞 7개 무료, 뒤 8개 유료(소유 불필요)
|
||||
local FACE_HEADS = {
|
||||
10725626210, -- Woman Face
|
||||
10725826963, -- Man Face
|
||||
11308945948, -- Check It
|
||||
15938951781, -- Silly Fun
|
||||
10687288296, -- Dylan Default
|
||||
10638267973, -- Stevie Standard
|
||||
10723855306, -- Devon Default
|
||||
13692975981, -- Friendly Smile
|
||||
11163789916, -- The Winning Smile
|
||||
12954264879, -- Joyful Smile
|
||||
13682064263, -- Happy :D
|
||||
130433936882245, -- Super Super Happy Face
|
||||
11159990982, -- Classic Female Face
|
||||
11180212350, -- Classic Male Face
|
||||
16042049101, -- Happy Wink
|
||||
}
|
||||
|
||||
-- 동물: body = {Torso, LeftArm, RightArm, LeftLeg, RightLeg}, colors = {Head, Torso, LeftArm, RightArm, LeftLeg, RightLeg}
|
||||
-- hideHead: 동물 머리 모자가 사람 머리를 다 덮으므로 Head를 투명하게. lowerHat: 모자를 목까지 내림(위 3번)
|
||||
local function rgb(r, g, b) return Color3.fromRGB(r, g, b) end
|
||||
local W, G = rgb(245, 245, 245), rgb(163, 162, 165)
|
||||
local ANIMALS = {
|
||||
-- 공식 번들 몸(Penguin 284) + Tokyokhaos Penguin 머리
|
||||
{ name = "Penguin", body = { 46358991, 46359095, 46359040, 46359181, 46359241 }, hat = "15967866", colors = { W, W, W, W, W, W }, hideHead = true },
|
||||
-- 공식 번들 몸(Bear Suit 309) + Beary Cute 머리
|
||||
{ name = "Bear", body = { 27132957, 27133013, 27132990, 27133040, 27133055 }, hat = "28998435", lowerHat = true, hideHead = true,
|
||||
colors = { rgb(160, 110, 80), rgb(160, 110, 80), rgb(110, 75, 55), rgb(110, 75, 55), rgb(110, 75, 55), rgb(110, 75, 55) } },
|
||||
-- 공식 번들 그대로(Polar Bear 195)
|
||||
{ name = "PolarBear", body = { 137715759, 137715036, 137715073, 137715120, 137715151 }, hat = "137714793", hideHead = true,
|
||||
colors = { rgb(248, 248, 248), rgb(248, 248, 248), rgb(248, 248, 248), rgb(248, 248, 248), rgb(248, 248, 248), rgb(248, 248, 248) } },
|
||||
-- 공식 번들 그대로(Blue Collar Cat 182)
|
||||
{ name = "Cat", body = { 146176562, 146176342, 146176447, 146176406, 146176511 }, hat = "146176716", colors = { G, G, G, G, G, G }, hideHead = true },
|
||||
-- 공식 번들 그대로(White Collar Dog 11)
|
||||
{ name = "Dog", body = { 1796148633, 1796137813, 1796141971, 1796143895, 1796146180 }, hat = "1796135151", colors = { G, G, G, G, G, G }, hideHead = true },
|
||||
-- Bear Suit 몸을 흑백으로 + Panda 머리(27369187)
|
||||
{ name = "Panda", body = { 27132957, 27133013, 27132990, 27133040, 27133055 }, hat = "27369187", hideHead = true,
|
||||
colors = { rgb(242, 242, 242), rgb(242, 242, 242), rgb(30, 30, 30), rgb(30, 30, 30), rgb(30, 30, 30), rgb(30, 30, 30) } },
|
||||
-- 기본 몸 + Cute Fox 머리 + 주황 꼬리 + 옷
|
||||
{ name = "Fox", hat = "61773267", lowerHat = true, tail = "187846604", shirt = 382537702, pants = 382537806, hideHead = true,
|
||||
colors = { rgb(235, 120, 40), rgb(235, 120, 40), rgb(235, 120, 40), rgb(235, 120, 40), rgb(250, 240, 230), rgb(250, 240, 230) } },
|
||||
-- 기본 몸 + Sleepy Mouse Cap(머리 전체) + 옷
|
||||
{ name = "Mouse", hat = "439943629", shirt = 398635081, pants = 144076760, hideHead = true,
|
||||
colors = { rgb(170, 185, 215), rgb(170, 185, 215), rgb(170, 185, 215), rgb(170, 185, 215), rgb(170, 185, 215), rgb(170, 185, 215) } },
|
||||
-- "동물 분장 사람" 가벼운 버전: 동물 얼굴 다이내믹 헤드 + 귀 + 꼬리 + 옷(사람 얼굴 모양이라 동물 느낌은 약함)
|
||||
{ name = "Bunny", head = 119665103921086, ears = "1080949", tail = "738679517", shirt = 4047886060, pants = 382537950, colors = { W, W, W, W, W, W } },
|
||||
{ name = "Kitty", head = 82082995456115, ears = "1374269", tail = "187846604", shirt = 382537085, pants = 398634487,
|
||||
colors = { rgb(250, 200, 140), rgb(250, 200, 140), rgb(250, 200, 140), rgb(250, 200, 140), rgb(250, 200, 140), rgb(250, 200, 140) } },
|
||||
{ name = "Puppy", head = 138526270057654, ears = "11142487", shirt = 144076436, pants = 382538503,
|
||||
colors = { rgb(220, 180, 130), rgb(220, 180, 130), rgb(220, 180, 130), rgb(220, 180, 130), rgb(220, 180, 130), rgb(220, 180, 130) } },
|
||||
}
|
||||
local SKIN = { rgb(255, 220, 190), rgb(240, 200, 160), rgb(205, 160, 120), rgb(150, 105, 75) }
|
||||
```
|
||||
|
||||
추천 비율: 사람 75%, 동물 25%(Penguin·Bear·PolarBear·Cat·Dog·Panda·Fox·Mouse를 주로, Bunny·Kitty·Puppy는 가끔).
|
||||
|
||||
빼 둔 후보(이유): Panda Monk 371·Grizzly Warrior 370·Guardian Lion 599(전사·무서운 얼굴), Fancy Mr. Fox 404(Rthro라 키가 큼, HipHeight 2.81~3.29), Cute Kitty·Spring Bunny·Puppy·Raccoon·Lion 다이내믹 헤드는 회색 사람 머리에 수염만 그린 모양이라 단독 동물로는 약함, 남이 만든 UGC 미니 번들(내려갈 수 있고 SurfaceAppearance 포함).
|
||||
|
||||
## 불러오는 코드 (서버에서 확인한 순서 그대로)
|
||||
|
||||
```luau
|
||||
local Players = game:GetService("Players")
|
||||
local RunService = game:GetService("RunService")
|
||||
|
||||
local function setColors(d: HumanoidDescription, c: { Color3 })
|
||||
d.HeadColor, d.TorsoColor, d.LeftArmColor, d.RightArmColor, d.LeftLegColor, d.RightLegColor = c[1], c[2], c[3], c[4], c[5], c[6]
|
||||
end
|
||||
|
||||
local function humanDesc(rng: Random): HumanoidDescription
|
||||
local d = Instance.new("HumanoidDescription")
|
||||
d.HairAccessory = tostring(HAIR[rng:NextInteger(1, #HAIR)])
|
||||
if rng:NextNumber() < 0.35 then
|
||||
d.HatAccessory = tostring(HATS[rng:NextInteger(1, #HATS)])
|
||||
end
|
||||
d.Shirt = SHIRTS[rng:NextInteger(1, #SHIRTS)]
|
||||
d.Pants = PANTS[rng:NextInteger(1, #PANTS)]
|
||||
d.Head = FACE_HEADS[rng:NextInteger(1, #FACE_HEADS)]
|
||||
local s = SKIN[rng:NextInteger(1, #SKIN)]
|
||||
setColors(d, { s, s, s, s, s, s })
|
||||
local h = 0.85 + rng:NextNumber() * 0.15 -- 어린이~어른 키
|
||||
d.HeightScale, d.WidthScale, d.DepthScale, d.HeadScale = h, 0.9, 0.9, 1
|
||||
return d
|
||||
end
|
||||
|
||||
local function animalDesc(a): HumanoidDescription
|
||||
local d = Instance.new("HumanoidDescription")
|
||||
if a.body then
|
||||
d.Torso, d.LeftArm, d.RightArm, d.LeftLeg, d.RightLeg = a.body[1], a.body[2], a.body[3], a.body[4], a.body[5]
|
||||
end
|
||||
if a.head then
|
||||
d.Head = a.head
|
||||
end
|
||||
d.HatAccessory = a.hat or a.ears or ""
|
||||
d.WaistAccessory = a.tail or ""
|
||||
d.Shirt = a.shirt or 0
|
||||
d.Pants = a.pants or 0
|
||||
setColors(d, a.colors)
|
||||
return d
|
||||
end
|
||||
|
||||
-- 템플릿 하나 만들기(서버 시작 때 종류마다 1번). 실패하면 nil → 기존 블록 NPC로 대신.
|
||||
local function buildTemplate(d: HumanoidDescription, a): Model?
|
||||
local ok, m = pcall(Players.CreateHumanoidModelFromDescription, Players, d, Enum.HumanoidRigType.R15)
|
||||
if not ok then
|
||||
warn("[Bunsik] NPC 외형 생성 실패", m)
|
||||
return nil
|
||||
end
|
||||
local animate = m:FindFirstChild("Animate")
|
||||
if animate then
|
||||
animate:Destroy()
|
||||
end
|
||||
m:PivotTo(CFrame.new(0, 500, 0)) -- 맵 밖 높은 곳(아래쪽은 FallenPartsDestroyHeight에 걸릴 수 있음)
|
||||
local root = m:FindFirstChild("HumanoidRootPart") :: BasePart
|
||||
root.Anchored = true
|
||||
m.Parent = workspace -- 장신구 위치가 맞춰지려면 Workspace 안에서 한 프레임 필요
|
||||
RunService.Heartbeat:Wait()
|
||||
if a then
|
||||
local head = m:FindFirstChild("Head") :: BasePart
|
||||
local hum = m:FindFirstChildOfClass("Humanoid") :: Humanoid
|
||||
if a.lowerHat then
|
||||
for _, acc in m:GetChildren() do
|
||||
if acc:IsA("Accessory") and acc.AccessoryType == Enum.AccessoryType.Hat then
|
||||
local h = acc:FindFirstChild("Handle") :: BasePart
|
||||
local att = h:FindFirstChild("HatAttachment") :: Attachment?
|
||||
local drop = (h.Position.Y - h.Size.Y / 2) - (head.Position.Y - head.Size.Y / 2)
|
||||
if att and drop > 0.1 then
|
||||
att.Position += Vector3.new(0, drop, 0)
|
||||
acc.Parent = nil
|
||||
hum:AddAccessory(acc) -- 다시 붙여야 바로 반영됨
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if a.hideHead then
|
||||
head.Transparency = 1
|
||||
end
|
||||
end
|
||||
m.Parent = nil
|
||||
return m
|
||||
end
|
||||
-- 이후: template:Clone() → (colorize 하지 말 것) → 지금 Npc.spawn 의 고정·트윈·Animator 처리 그대로
|
||||
```
|
||||
|
||||
## Option B (Creator Store 동물 모델) 결과
|
||||
|
||||
- `AssetService:LoadAssetAsync`, `InsertService:LoadAsset` 둘 다 남이 만든 무료 모델 12개(Low Poly Dog/Panda, Cute Penguin, Animal Pack 등)에서 `User is not authorized to access Asset.` 로블록스가 만든 에셋(1374269 Kitty Ears)은 둘 다 성공.
|
||||
- DECISIONS.md 0-1에 적힌 `AllowInsertFreeAssets`는 스크립트에서 `Workspace`의 멤버가 아닙니다(읽기·쓰기 모두 오류). 그래서 Luau Execution으로 남의 무료 모델을 가져오는 길은 지금 막혀 있습니다. 게임 주인 계정이 Toolbox에서 그 모델을 먼저 받아 두면 될 수도 있지만 확인하지 않았습니다.
|
||||
- 대신 **.rbxm 내보내기는 됩니다.** `SerializationService:SerializeInstancesAsync({ ... })`로 buffer를 만들고 스크립트가 `return { BinaryOutput = buf, ReturnValues = { ... } }`를 돌려주면 `cloud.py run … --out 파일`로 받습니다(다른 값을 함께 return하면 "Script must return exactly one table" 오류).
|
||||
- `assets/npc_animals.rbxm`(199 KB, `<roblox!` 바이너리): 위 동물 프리셋 11개 + 사람 예시 1개, 모두 Anchored 해제·Animate 제거 상태. 같은 실행 안에서 `DeserializeInstancesAsync`로 다시 읽어 12개를 확인했습니다. 게임은 실행 중에 HumanoidDescription으로 만들면 되니 필수는 아니고, 아바타 서비스가 실패할 때 쓸 예비본이나 Studio 미리보기용입니다.
|
||||
|
||||
## 도구
|
||||
|
||||
- `tools/npc_search.py` — Creator Store 검색, 카탈로그(로블록스 제작) 검색, 번들 구성품 보기(공개 API)
|
||||
- `tools/npc_verify_avatars.luau` — 위 표 전체 확인 + `npc_animals.rbxm` 내보내기
|
||||
- `tools/npc_inspect_models.luau` — Option B 모델 조사(지금은 권한 오류로 막힘)
|
||||
65
bunsik-tycoon/default.project.json
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"name": "BunsikTycoon",
|
||||
"tree": {
|
||||
"$className": "DataModel",
|
||||
"ReplicatedStorage": {
|
||||
"Shared": {
|
||||
"$path": "src/shared"
|
||||
},
|
||||
"Remotes": {
|
||||
"$className": "Folder",
|
||||
"Action": {
|
||||
"$className": "RemoteEvent"
|
||||
},
|
||||
"Notify": {
|
||||
"$className": "RemoteEvent"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ServerScriptService": {
|
||||
"Server": {
|
||||
"$path": "src/server"
|
||||
},
|
||||
"Vendor": {
|
||||
"$className": "Folder",
|
||||
"ProfileStore": {
|
||||
"$path": "vendor/ProfileStore.luau"
|
||||
}
|
||||
}
|
||||
},
|
||||
"StarterPlayer": {
|
||||
"StarterPlayerScripts": {
|
||||
"Client": {
|
||||
"$path": "src/client"
|
||||
}
|
||||
},
|
||||
"$properties": {
|
||||
"CharacterWalkSpeed": 20,
|
||||
"CameraMaxZoomDistance": 80
|
||||
}
|
||||
},
|
||||
"SoundService": {
|
||||
"Sfx": {
|
||||
"$className": "SoundGroup",
|
||||
"$properties": {
|
||||
"Volume": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"Workspace": {
|
||||
"$properties": {
|
||||
"FilteringEnabled": true
|
||||
}
|
||||
},
|
||||
"Players": {
|
||||
"$properties": {
|
||||
"CharacterAutoLoads": true
|
||||
}
|
||||
},
|
||||
"Lighting": {
|
||||
"$properties": {
|
||||
"ClockTime": 14.5
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1
bunsik-tycoon/selene.toml
Normal file
@@ -0,0 +1 @@
|
||||
std = "roblox"
|
||||
BIN
bunsik-tycoon/sfx/buy.ogg
Normal file
BIN
bunsik-tycoon/sfx/coin.ogg
Normal file
BIN
bunsik-tycoon/sfx/levelup.ogg
Normal file
BIN
bunsik-tycoon/sfx/pop.ogg
Normal file
BIN
bunsik-tycoon/sfx/sizzle.ogg
Normal file
979
bunsik-tycoon/src/client/Decorate.luau
Normal file
@@ -0,0 +1,979 @@
|
||||
--!strict
|
||||
-- 꾸미기 모드: 화면의 [가게 꾸미기] 버튼으로 들어갑니다. 다른 화면 UI는 숨기고 캐릭터는 그대로 걸어 다닙니다.
|
||||
-- - 아래 물건 줄(테이블·의자·소품 6가지, 값과 개수)에서 하나를 고르면 그 물건의 투명한 미리보기가 캐릭터 바로 앞에
|
||||
-- 붙어 다닙니다. 걸어가서 자리를 잡고 [돌리기](PC: R)로 방향을 바꾼 뒤 [배치](PC: F)를 누르면 그 자리에 놓이고
|
||||
-- 그때 돈이 나갑니다. 놓을 수 있으면 초록, 안 되면 빨강과 이유(문 앞, 겹침, 길 막힘, 의자 앞에 테이블 없음, 돈 부족)가 나옵니다.
|
||||
-- - [이동]: "이동할 가구를 고르세요" → 내 가게의 테이블·의자·소품·조리대를 누르면 그 물건을 들고(원래 물건은 내 화면에서만 숨김)
|
||||
-- 같은 방법으로 옮기고 돌립니다. 테이블을 들면 그 테이블을 보는 의자도 같이 들리고, [돌리기]는 의자들을 테이블 둘레로 돌립니다.
|
||||
-- - [삭제]: "삭제할 가구를 고르세요" → 누르면 빨갛게 표시되고, [삭제]를 한 번 더 누르면 지우고 산 값을 돌려받습니다.
|
||||
-- - 층은 캐릭터가 서 있는 층(2층 건물이면 계단으로 올라가서 놓음)입니다.
|
||||
-- 검사는 서버와 같은 Floor.add / Floor.move / Floor.remove이고, 서버가 다시 검사합니다.
|
||||
-- 다른 화면 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"))
|
||||
local Layout = require(script.Parent:WaitForChild("Layout"))
|
||||
local Theme = require(script.Parent:WaitForChild("Theme"))
|
||||
|
||||
local Decorate = {}
|
||||
|
||||
export type Handle = {
|
||||
gui: ScreenGui,
|
||||
open: () -> (), -- 꾸미기 모드 들어가기(아래 물건 줄)
|
||||
close: () -> (),
|
||||
isOpen: () -> boolean,
|
||||
holding: () -> boolean, -- 물건을 들고 있으면 true(PC 마우스 회전은 그대로)
|
||||
onOpen: (fn: () -> ()) -> (),
|
||||
onClose: (fn: () -> ()) -> (),
|
||||
setLayout: (lay: Layout.Result) -> (),
|
||||
notify: (key: string, args: { [string]: any }?) -> (),
|
||||
destroy: () -> (),
|
||||
}
|
||||
|
||||
type Hold = {
|
||||
new: boolean,
|
||||
kind: string, -- "table" | "chair" | "decor" | "stove"
|
||||
k: string?, -- 새 소품 종류
|
||||
i: number, -- 옮기는 물건 번호(새 물건이면 0)
|
||||
r: number, -- 회전(테이블은 지금 자리 기준 돌린 횟수)
|
||||
}
|
||||
|
||||
-- 아래 물건 줄 순서: 테이블, 의자, 소품(Economy.DECOR 순서)
|
||||
local ITEMS: { { kind: string, k: string? } } = { { kind = "table" }, { kind = "chair" } }
|
||||
for _, d in Economy.DECOR do
|
||||
table.insert(ITEMS, { kind = "decor", k = d.id })
|
||||
end
|
||||
Decorate.ITEMS = ITEMS
|
||||
|
||||
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 function snap(v: number): number
|
||||
return math.floor(v * 2 + 0.5) / 2
|
||||
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
|
||||
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
|
||||
|
||||
-- 배치 속 물건 하나의 놓는 자리(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]
|
||||
if t then
|
||||
return t.x, t.z, t.f, 0
|
||||
end
|
||||
elseif kind == "chair" then
|
||||
local c = layout.chairs[i]
|
||||
if c then
|
||||
return c.x, c.z, c.f, c.r
|
||||
end
|
||||
elseif kind == "decor" then
|
||||
local d = layout.decor[i]
|
||||
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")
|
||||
end
|
||||
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"
|
||||
gui.ResetOnSpawn = false
|
||||
gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
|
||||
gui.DisplayOrder = 5
|
||||
gui.Enabled = false
|
||||
gui.Parent = parent
|
||||
local root = Theme.frame(gui, "Root")
|
||||
local scale = Instance.new("UIScale")
|
||||
scale.Parent = root
|
||||
|
||||
local exitBtn, exitLabel = Theme.iconButton(root, "Exit", Theme.RED, "close")
|
||||
local infoBox = Theme.frame(root, "Info", Theme.WHITE)
|
||||
Theme.round(infoBox)
|
||||
local infoStroke = Theme.stroke(infoBox, Theme.edge(Theme.MINT), 4)
|
||||
local infoIcon = Info.glyph(infoBox, "Icon", "hand")
|
||||
infoIcon.frame.AnchorPoint = Vector2.new(0, 0.5)
|
||||
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.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 moveBtn, moveLabel = Theme.iconButton(root, "Move", Theme.SKY, "hand")
|
||||
local deleteBtn, deleteLabel = Theme.iconButton(root, "Delete", Theme.RED, "close")
|
||||
|
||||
-- 아래 물건 줄(넘치면 옆으로 밀어 봄)
|
||||
local strip = Instance.new("ScrollingFrame")
|
||||
strip.Name = "Items"
|
||||
strip.BackgroundTransparency = 1
|
||||
strip.BorderSizePixel = 0
|
||||
strip.ScrollingDirection = Enum.ScrollingDirection.X
|
||||
strip.AutomaticCanvasSize = Enum.AutomaticSize.X
|
||||
strip.CanvasSize = UDim2.new()
|
||||
strip.ScrollBarThickness = 4
|
||||
strip.ElasticBehavior = Enum.ElasticBehavior.Never
|
||||
strip.Parent = root
|
||||
local stripList = Instance.new("UIListLayout")
|
||||
stripList.FillDirection = Enum.FillDirection.Horizontal
|
||||
stripList.Padding = UDim.new(0, 10)
|
||||
stripList.SortOrder = Enum.SortOrder.LayoutOrder
|
||||
stripList.VerticalAlignment = Enum.VerticalAlignment.Top
|
||||
stripList.Parent = strip
|
||||
type ItemButton = { b: Theme.Button, glyph: Info.Glyph, price: TextLabel, tag: TextLabel }
|
||||
local itemButtons: { ItemButton } = {}
|
||||
for n, it in ITEMS do
|
||||
local b = Theme.button(strip, "Item_" .. (it.k or it.kind), Theme.WHITE, 18)
|
||||
b.button.LayoutOrder = n
|
||||
local icon = if it.kind == "table"
|
||||
then "table"
|
||||
elseif it.kind == "chair" then Info.SEAT_ICON
|
||||
else Info.DECOR_ICON[it.k or ""] or "sparkle"
|
||||
local g = Info.glyph(b.face, "Icon", icon)
|
||||
g.frame.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
g.frame.Position = UDim2.fromScale(0.5, 0.4)
|
||||
g.frame.Size = UDim2.fromScale(0.62, 0.62)
|
||||
g.zindex(4)
|
||||
local price = Theme.text(b.button, "Price", Theme.edge(Theme.MINT), true)
|
||||
price.AnchorPoint = Vector2.new(0.5, 1)
|
||||
price.Position = UDim2.fromScale(0.5, 1)
|
||||
price.Size = UDim2.fromScale(1, 0.3)
|
||||
price.ZIndex = 5
|
||||
local tag = Theme.text(b.button, "Count", Theme.edge(Theme.LAVENDER), true)
|
||||
tag.AnchorPoint = Vector2.new(1, 0)
|
||||
tag.Position = UDim2.new(1, 2, 0, -4)
|
||||
tag.Size = UDim2.fromScale(0.7, 0.26)
|
||||
tag.ZIndex = 6
|
||||
itemButtons[n] = { b = b, glyph = g, price = price, tag = tag }
|
||||
end
|
||||
|
||||
-- 미리보기 모형(내 화면에만)
|
||||
local ghost = Instance.new("Model")
|
||||
ghost.Name = "BunsikDecorateGhost"
|
||||
local highlight = Instance.new("Highlight")
|
||||
highlight.FillTransparency = 0.55
|
||||
highlight.OutlineColor = Theme.WHITE
|
||||
highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
|
||||
highlight.Parent = ghost
|
||||
local plates: { BasePart } = {}
|
||||
|
||||
local isOpen = false
|
||||
local mode = "menu" -- "menu"(물건 줄) | "hold"(들고 있음) | "pickMove"(이동할 것 고르기) | "pickDelete"(지울 것 고르기)
|
||||
local delSel: { kind: string, i: number }? = nil
|
||||
local selHighlight = Instance.new("Highlight")
|
||||
selHighlight.FillColor = BAD
|
||||
selHighlight.FillTransparency = 0.4
|
||||
selHighlight.OutlineColor = Theme.WHITE
|
||||
selHighlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
|
||||
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 openFns: { () -> () } = {}
|
||||
local closeFns: { () -> () } = {}
|
||||
local conns: { RBXScriptConnection } = {}
|
||||
|
||||
-- 배치는 속성이 바뀔 때만 다시 읽습니다(매 프레임 JSON을 풀지 않게).
|
||||
local layoutNow = Info.layout(state)
|
||||
local function curLayout(): Floor.Layout
|
||||
return layoutNow
|
||||
end
|
||||
|
||||
local function origin(): CFrame?
|
||||
local o = plot:GetAttribute("Origin")
|
||||
return if typeof(o) == "CFrame" then o else nil
|
||||
end
|
||||
local function stage(): number
|
||||
return Info.attr(state, "Stage", 1)
|
||||
end
|
||||
local function floorY(f: number): number
|
||||
return Floor.BASE_Y + (if f == 2 then Floor.FLOOR2_Y else 0)
|
||||
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 itemModel(kind: string, i: number): Model?
|
||||
if kind == "stove" then
|
||||
local base = plot:FindFirstChild("Base")
|
||||
local stall = base and base:FindFirstChild("Stall")
|
||||
return if stall and stall:IsA("Model") then stall else nil
|
||||
end
|
||||
local up = plot:FindFirstChild("Upgrades")
|
||||
local furniture = up and up:FindFirstChild("Furniture")
|
||||
if not furniture then
|
||||
return nil
|
||||
end
|
||||
for _, d in furniture:GetChildren() do
|
||||
if d:IsA("Model") and d:GetAttribute("ItemKind") == kind and d:GetAttribute("ItemIndex") == i then
|
||||
return d
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function cost(h: Hold): number?
|
||||
if not h.new then
|
||||
return nil
|
||||
end
|
||||
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 buyInfo(kind: string, k: string?): (number?, boolean)
|
||||
local st = stage()
|
||||
local seats = Info.attr(state, "Seats", 1)
|
||||
local tables = Info.attr(state, "Tables", 1)
|
||||
if kind == "chair" then
|
||||
return Economy.seatCost(seats + 1), seats < Economy.seatCap(st)
|
||||
elseif kind == "table" then
|
||||
return Economy.tableCost(tables), tables < Economy.tableCap(st)
|
||||
end
|
||||
local d = k and Economy.decor(k)
|
||||
return d and d.cost, #curLayout().decor < Economy.DECOR_MAX
|
||||
end
|
||||
|
||||
-- 지우면 돌려받는 값(서버 PlotController.removeItem과 같음)
|
||||
local function refundOf(kind: string, i: number): number
|
||||
local layout = curLayout()
|
||||
if kind == "chair" then
|
||||
return Economy.seatCost(#layout.chairs)
|
||||
elseif kind == "table" then
|
||||
return Economy.tableCost(#layout.tables - 1)
|
||||
elseif kind == "decor" and layout.decor[i] then
|
||||
local d = Economy.decor(layout.decor[i].k)
|
||||
return if d then d.cost else 0
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
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
|
||||
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
|
||||
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 = "Plate"
|
||||
p.Anchored = true
|
||||
p.CanCollide = false
|
||||
p.CanQuery = false
|
||||
p.CanTouch = false
|
||||
p.CastShadow = false
|
||||
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 refreshStrip()
|
||||
local money = Info.attr(state, "Money", 0)
|
||||
local st = stage()
|
||||
local layout = curLayout()
|
||||
local counts: { [string]: number } = {}
|
||||
for _, d in layout.decor do
|
||||
counts[d.k] = (counts[d.k] or 0) + 1
|
||||
end
|
||||
for n, it in ITEMS do
|
||||
local ib = itemButtons[n]
|
||||
local c, canBuy = buyInfo(it.kind, it.k)
|
||||
local can = canBuy and c ~= nil and money >= c
|
||||
ib.b.setColor(if can then Theme.MINT else Theme.GRAY)
|
||||
ib.glyph.fade(if canBuy then 0 else 0.5)
|
||||
ib.price.Text = if canBuy then Locale.number(c or 0) else L("full")
|
||||
if it.kind == "table" then
|
||||
ib.tag.Text = `{#layout.tables}/{Economy.tableCap(st)}`
|
||||
elseif it.kind == "chair" then
|
||||
ib.tag.Text = `{#layout.chairs}/{Economy.seatCap(st)}`
|
||||
else
|
||||
local cnt = counts[it.k or ""] or 0
|
||||
ib.tag.Text = if cnt > 0 then `x{cnt}` else ""
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 안내 글과 버튼(모드마다)
|
||||
local function redraw()
|
||||
exitLabel.Text = L("exit")
|
||||
rotateLabel.Text = L("rotate")
|
||||
cancelLabel.Text = L("cancel")
|
||||
moveLabel.Text = L("btnMove")
|
||||
deleteLabel.Text = L("btnDelete")
|
||||
local h = hold
|
||||
local layout = curLayout()
|
||||
local menu = mode == "menu"
|
||||
strip.Visible = menu
|
||||
moveBtn.button.Visible = menu
|
||||
deleteBtn.button.Visible = menu
|
||||
rotateBtn.button.Visible = h ~= nil and not (h.new and h.kind == "table")
|
||||
cancelBtn.button.Visible = not menu
|
||||
local sel = delSel
|
||||
if mode == "pickDelete" then
|
||||
okBtn.button.Visible = sel ~= nil
|
||||
okLabel.Text = L("btnDelete")
|
||||
okBtn.setColor(Theme.RED)
|
||||
else
|
||||
okBtn.button.Visible = h ~= nil
|
||||
okLabel.Text = L("placeIt")
|
||||
okBtn.setColor(if h and valid then Theme.MINT else Theme.GRAY)
|
||||
end
|
||||
selHighlight.Adornee = nil
|
||||
selHighlight.Parent = nil
|
||||
local text: string
|
||||
local color = Theme.MINT
|
||||
if message then
|
||||
text = message
|
||||
color = Theme.ORANGE
|
||||
infoIcon.set("hand")
|
||||
elseif menu then
|
||||
text = L("decoChoose")
|
||||
infoIcon.set("table")
|
||||
elseif mode == "pickMove" then
|
||||
text = L("decoPickMove")
|
||||
infoIcon.set("hand")
|
||||
elseif mode == "pickDelete" then
|
||||
color = Theme.RED
|
||||
infoIcon.set("close")
|
||||
text = L("decoPickDelete")
|
||||
if sel then
|
||||
local name, icon = itemName({ new = false, kind = sel.kind, i = sel.i, r = 0 }, layout)
|
||||
infoIcon.set(icon)
|
||||
text = `{name} · {L("decoDeleteAsk", { money = Locale.number(refundOf(sel.kind, sel.i)) })}`
|
||||
local m = itemModel(sel.kind, sel.i)
|
||||
if m then
|
||||
selHighlight.Adornee = m
|
||||
selHighlight.Parent = m
|
||||
end
|
||||
end
|
||||
elseif h and not valid then
|
||||
text = L("why_" .. (why or "none"))
|
||||
color = Theme.RED
|
||||
else
|
||||
text = L("decoOk")
|
||||
end
|
||||
if h and mode == "hold" 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.FillColor = if valid then GOOD else BAD
|
||||
highlight.OutlineColor = if valid then Theme.WHITE else BAD
|
||||
if menu then
|
||||
refreshStrip()
|
||||
end
|
||||
end
|
||||
|
||||
-- 캐릭터 앞 자리 계산 → 바뀌면 다시 검사
|
||||
local lastKey = ""
|
||||
local function update(force: boolean?)
|
||||
local h = hold
|
||||
if not h then
|
||||
return
|
||||
end
|
||||
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
|
||||
-- 미리보기 모형 옮기기
|
||||
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
|
||||
redraw()
|
||||
end
|
||||
|
||||
local function showMessage(text: string)
|
||||
message = text
|
||||
messageToken += 1
|
||||
local token = messageToken
|
||||
redraw()
|
||||
task.delay(3, function()
|
||||
if token == messageToken then
|
||||
message = nil
|
||||
if isOpen then
|
||||
redraw()
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local renderConn: RBXScriptConnection? = nil
|
||||
|
||||
local function close()
|
||||
if not isOpen then
|
||||
return
|
||||
end
|
||||
isOpen = false
|
||||
gui.Enabled = false
|
||||
hold = nil
|
||||
target = nil
|
||||
delSel = nil
|
||||
mode = "menu"
|
||||
clearGhost()
|
||||
selHighlight.Adornee = nil
|
||||
selHighlight.Parent = nil
|
||||
if renderConn then
|
||||
renderConn:Disconnect()
|
||||
renderConn = nil
|
||||
end
|
||||
for _, fn in closeFns do
|
||||
fn()
|
||||
end
|
||||
end
|
||||
|
||||
local function setMode(m: string)
|
||||
mode = m
|
||||
hold = nil
|
||||
target = nil
|
||||
delSel = nil
|
||||
message = nil
|
||||
clearGhost()
|
||||
redraw()
|
||||
end
|
||||
|
||||
local function beginHold(h: Hold)
|
||||
mode = "hold"
|
||||
hold = h
|
||||
delSel = nil
|
||||
valid = false
|
||||
why = nil
|
||||
message = nil
|
||||
lastKey = ""
|
||||
buildGhost(h)
|
||||
update(true)
|
||||
end
|
||||
|
||||
local function open()
|
||||
if isOpen or not origin() then
|
||||
return
|
||||
end
|
||||
isOpen = true
|
||||
gui.Enabled = true
|
||||
-- 화면이 그려질 때마다 미리보기를 캐릭터 앞으로(서버 테스트에서는 Heartbeat)
|
||||
local step = if RunService:IsClient() then RunService.RenderStepped else RunService.Heartbeat
|
||||
renderConn = step:Connect(function()
|
||||
update()
|
||||
end)
|
||||
for _, fn in openFns do
|
||||
fn()
|
||||
end
|
||||
setMode("menu")
|
||||
end
|
||||
|
||||
-- 물건 줄에서 새 물건 고르기
|
||||
local function startNew(kind: string, k: string?)
|
||||
local c, canBuy = buyInfo(kind, k)
|
||||
if not canBuy then
|
||||
showMessage(L("full"))
|
||||
return
|
||||
end
|
||||
if c and Info.attr(state, "Money", 0) < c then
|
||||
showMessage(L("why_money"))
|
||||
return
|
||||
end
|
||||
-- 새 의자는 캐릭터가 보는 쪽(앞의 테이블 쪽)을 보게 들고 시작합니다.
|
||||
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
|
||||
|
||||
-- 옮길 물건 고르기(누른 곳의 내 가게 물건)
|
||||
-- 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 (mode ~= "pickMove" and mode ~= "pickDelete") then
|
||||
return
|
||||
end
|
||||
local kind, i = pickItem(sx, sy, screen)
|
||||
if not kind or not i then
|
||||
return
|
||||
end
|
||||
if mode == "pickMove" then
|
||||
local _, _, _, r = spot(curLayout(), kind, i)
|
||||
beginHold({ new = false, kind = kind, i = i, r = if kind == "table" then 0 else r or 0 })
|
||||
elseif kind == "stove" then
|
||||
showMessage(L("why_stove"))
|
||||
else
|
||||
delSel = { kind = kind, i = i }
|
||||
message = nil
|
||||
redraw()
|
||||
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 sel = delSel
|
||||
if mode == "pickDelete" then
|
||||
if sel then
|
||||
send("remove", { kind = sel.kind, i = sel.i })
|
||||
delSel = nil
|
||||
redraw()
|
||||
end
|
||||
return
|
||||
end
|
||||
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 })
|
||||
else
|
||||
send("move", { kind = h.kind, i = h.i, x = t.x, z = t.z, f = t.f, r = h.r })
|
||||
end
|
||||
-- 놓은 뒤에는 물건 줄로 돌아갑니다(더 사거나 이동·삭제).
|
||||
setMode("menu")
|
||||
end
|
||||
|
||||
local function cancel()
|
||||
local h = hold
|
||||
if h and not h.new then
|
||||
setMode("pickMove")
|
||||
elseif mode == "pickDelete" and delSel then
|
||||
delSel = nil
|
||||
redraw()
|
||||
else
|
||||
setMode("menu")
|
||||
end
|
||||
end
|
||||
|
||||
-- 입력: 누르기(옮길 물건 고르기), R 돌리기, F 놓기
|
||||
table.insert(
|
||||
conns,
|
||||
UserInputService.InputBegan:Connect(function(io: InputObject, processed: boolean)
|
||||
if not isOpen or processed then
|
||||
return
|
||||
end
|
||||
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.TouchTapInWorld:Connect(function(pos: Vector2, processed: boolean)
|
||||
if not processed then
|
||||
tryPick(pos.X, pos.Y, true)
|
||||
end
|
||||
end)
|
||||
)
|
||||
table.insert(conns, exitBtn.button.Activated:Connect(close))
|
||||
table.insert(
|
||||
conns,
|
||||
moveBtn.button.Activated:Connect(function()
|
||||
setMode("pickMove")
|
||||
end)
|
||||
)
|
||||
table.insert(
|
||||
conns,
|
||||
deleteBtn.button.Activated:Connect(function()
|
||||
setMode("pickDelete")
|
||||
end)
|
||||
)
|
||||
for n, it in ITEMS do
|
||||
table.insert(
|
||||
conns,
|
||||
itemButtons[n].b.button.Activated:Connect(function()
|
||||
if mode == "menu" then
|
||||
startNew(it.kind, it.k)
|
||||
end
|
||||
end)
|
||||
)
|
||||
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" or key == "Money" or key == "Seats" or key == "Tables" then
|
||||
if key == "Layout" then
|
||||
layoutNow = Info.layout(state)
|
||||
end
|
||||
local h = hold
|
||||
-- 지우려고 고른 물건 번호는 배치가 바뀌면 달라질 수 있으니 풉니다.
|
||||
if key == "Layout" then
|
||||
delSel = nil
|
||||
end
|
||||
-- 옮기던 물건이 없어졌으면 내려놓기
|
||||
if h and not h.new and not spot(curLayout(), h.kind, h.i) then
|
||||
setMode("menu")
|
||||
return
|
||||
elseif h and not h.new and key == "Layout" then
|
||||
-- 서버가 가구를 다시 지었으면 새 모형을 다시 숨기고 미리보기를 새로 만듭니다.
|
||||
buildGhost(h)
|
||||
end
|
||||
update(true)
|
||||
redraw()
|
||||
elseif key == "Lang" then
|
||||
redraw()
|
||||
end
|
||||
end)
|
||||
)
|
||||
|
||||
return {
|
||||
gui = gui,
|
||||
open = open,
|
||||
close = close,
|
||||
isOpen = function()
|
||||
return isOpen
|
||||
end,
|
||||
holding = function()
|
||||
return hold ~= nil
|
||||
end,
|
||||
onOpen = function(fn)
|
||||
table.insert(openFns, fn)
|
||||
end,
|
||||
onClose = function(fn)
|
||||
table.insert(closeFns, fn)
|
||||
end,
|
||||
setLayout = function(lay: Layout.Result)
|
||||
scale.Scale = lay.scale
|
||||
root.Size = UDim2.fromOffset(math.ceil(lay.width), math.ceil(lay.height))
|
||||
local d = lay.deco
|
||||
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])
|
||||
place(strip, d.strip)
|
||||
place(moveBtn.button, d.move)
|
||||
place(deleteBtn.button, d.delete)
|
||||
for _, ib in itemButtons do
|
||||
ib.b.button.Size = UDim2.fromOffset(d.move.w, d.move.h)
|
||||
end
|
||||
end,
|
||||
notify = function(key: string, args: { [string]: any }?)
|
||||
if isOpen then
|
||||
showMessage(Info.toast(lang(), key, args))
|
||||
end
|
||||
end,
|
||||
destroy = function()
|
||||
close()
|
||||
for _, c in conns do
|
||||
c:Disconnect()
|
||||
end
|
||||
ghost:Destroy()
|
||||
gui:Destroy()
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
return Decorate
|
||||
60
bunsik-tycoon/src/client/Guide.luau
Normal file
@@ -0,0 +1,60 @@
|
||||
--!strict
|
||||
-- 튜토리얼 화살표: 캐릭터에서 목표(조리대, 손님 자리)까지 빛나는 줄과 위에서 통통 튀는 화살표.
|
||||
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local RunService = game:GetService("RunService")
|
||||
|
||||
local Icons = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("Icons"))
|
||||
|
||||
local Guide = {}
|
||||
|
||||
function Guide.start(player: Player)
|
||||
local beam = Instance.new("Beam")
|
||||
beam.Color = ColorSequence.new(Color3.fromRGB(255, 230, 60))
|
||||
beam.Width0 = 0.6
|
||||
beam.Width1 = 0.6
|
||||
beam.FaceCamera = true
|
||||
beam.LightEmission = 1
|
||||
beam.Transparency = NumberSequence.new(0.2)
|
||||
beam.Segments = 1
|
||||
local a0 = Instance.new("Attachment")
|
||||
a0.Name = "GuideFrom"
|
||||
local a1 = Instance.new("Attachment")
|
||||
a1.Name = "GuideTo"
|
||||
beam.Attachment0 = a0
|
||||
beam.Attachment1 = a1
|
||||
|
||||
local arrow = Instance.new("BillboardGui")
|
||||
arrow.Name = "GuideArrow"
|
||||
arrow.Size = UDim2.fromOffset(70, 70)
|
||||
arrow.AlwaysOnTop = true
|
||||
arrow.LightInfluence = 0
|
||||
local label = Instance.new("ImageLabel")
|
||||
label.Size = UDim2.fromScale(1, 1)
|
||||
label.BackgroundTransparency = 1
|
||||
Icons.apply(label, "arrowDown")
|
||||
label.Parent = arrow
|
||||
|
||||
RunService.RenderStepped:Connect(function()
|
||||
local value = player:FindFirstChild("Guide") :: ObjectValue?
|
||||
local target = value and value.Value :: BasePart?
|
||||
local char = player.Character
|
||||
local root = char and char:FindFirstChild("HumanoidRootPart") :: BasePart?
|
||||
local tut = player:GetAttribute("Tut")
|
||||
if target and root and (tut == 1 or tut == 2) then
|
||||
a0.Parent = root
|
||||
a1.Parent = target
|
||||
beam.Parent = target
|
||||
arrow.Adornee = target
|
||||
arrow.StudsOffset = Vector3.new(0, 3 + math.abs(math.sin(os.clock() * 4)) * 1.5, 0)
|
||||
arrow.Parent = target
|
||||
else
|
||||
beam.Parent = nil
|
||||
arrow.Parent = nil
|
||||
a0.Parent = nil
|
||||
a1.Parent = nil
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
return Guide
|
||||
823
bunsik-tycoon/src/client/Hud.luau
Normal file
@@ -0,0 +1,823 @@
|
||||
--!strict
|
||||
-- 화면 UI: 돈, 손에 든 접시, 상점·가게 꾸미기·2배 수익·돈 부스트 버튼, 홍보·손님 러시 버튼, 설정,
|
||||
-- 튜토리얼 말풍선(아래 가운데), 알림, 그리고 창(상점 탭 3개, 설정, 요리, 홍보 확인).
|
||||
-- [가게 꾸미기]는 창 없이 꾸미기 모드(Decorate)를 엽니다.
|
||||
-- 모양은 Theme("사탕" 스타일), 배치는 Layout, 상점 창은 ShopWindow, 요리 창은 Kitchen 모듈.
|
||||
-- 상태는 `state` 인스턴스(실제 게임에서는 Player)의 속성에서 읽습니다. 서버에서도 만들 수 있어서 원격 테스트로 검사합니다.
|
||||
|
||||
local AdService = game:GetService("AdService")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local TweenService = game:GetService("TweenService")
|
||||
|
||||
local Shared = ReplicatedStorage:WaitForChild("Shared")
|
||||
local Economy = require(Shared:WaitForChild("Economy"))
|
||||
local Locale = require(Shared:WaitForChild("Locale"))
|
||||
local Products = require(Shared:WaitForChild("Products"))
|
||||
local Info = require(script.Parent:WaitForChild("Info"))
|
||||
local Kitchen = require(script.Parent:WaitForChild("Kitchen"))
|
||||
local Layout = require(script.Parent:WaitForChild("Layout"))
|
||||
local ShopWindow = require(script.Parent:WaitForChild("ShopWindow"))
|
||||
local Theme = require(script.Parent:WaitForChild("Theme"))
|
||||
|
||||
local Hud = {}
|
||||
|
||||
export type HudHandle = {
|
||||
gui: ScreenGui,
|
||||
refresh: () -> (),
|
||||
notify: (key: string, args: { [string]: any }?) -> (),
|
||||
-- UI가 쓸 수 있는 화면 크기(픽셀, 상단 바 제외)와 터치 화면 여부로 배치를 다시 잡습니다.
|
||||
setLayout: (size: Vector2, touch: boolean) -> (),
|
||||
layout: () -> Layout.Result,
|
||||
-- "shop"(tab: "upgrade"/"staff"/"mine"), "settings", "kitchen", "promote", nil(닫기)
|
||||
open: (which: string?, tab: string?) -> (),
|
||||
menuOpen: () -> boolean, -- 창이 열려 있으면 true(마우스 커서를 풀어 줌)
|
||||
onDecorate: (fn: () -> ()) -> (), -- [가게 꾸미기] 버튼을 눌렀을 때
|
||||
kitchen: Kitchen.KitchenHandle,
|
||||
shop: ShopWindow.Handle,
|
||||
destroy: () -> (),
|
||||
}
|
||||
|
||||
-- 알림 종류별 아이콘과 색
|
||||
local TOAST_STYLE: { [string]: { icon: string, color: Color3 } } = {
|
||||
purchased = { icon = "check", color = Theme.MINT },
|
||||
newMenu = { icon = "star", color = Theme.ORANGE },
|
||||
expanded = { icon = "store", color = Theme.YELLOW },
|
||||
floor2 = { icon = "store", color = Theme.YELLOW },
|
||||
upgraded = { icon = "upgrade", color = Theme.MINT },
|
||||
seatAdded = { icon = "table", color = Theme.MINT },
|
||||
tableAdded = { icon = "table", color = Theme.MINT },
|
||||
decorAdded = { icon = "sparkle", color = Theme.MINT },
|
||||
noSpace = { icon = "table", color = Theme.GRAY },
|
||||
seatMax = { icon = "table", color = Theme.GRAY },
|
||||
tableMax = { icon = "table", color = Theme.GRAY },
|
||||
tableFull = { icon = "table", color = Theme.GRAY },
|
||||
needStage = { icon = "lock", color = Theme.GRAY },
|
||||
placeFail = { icon = "close", color = Theme.RED },
|
||||
hired = { icon = "chef", color = Theme.MINT },
|
||||
fired = { icon = "chef", color = Theme.GRAY },
|
||||
staffLocked = { icon = "lock", color = Theme.GRAY },
|
||||
staffMax = { icon = "chef", color = Theme.GRAY },
|
||||
strike = { icon = "chef", color = Theme.RED },
|
||||
strikeOver = { icon = "chef", color = Theme.MINT },
|
||||
renamed = { icon = "sign", color = Theme.SKY },
|
||||
nameRejected = { icon = "sign", color = Theme.GRAY },
|
||||
designSet = { icon = "store", color = Theme.SKY },
|
||||
designLocked = { icon = "lock", color = Theme.GRAY },
|
||||
promoted = { icon = "customer", color = Theme.SKY },
|
||||
promoteNone = { icon = "customer", color = Theme.GRAY },
|
||||
promoteFull = { icon = "customer", color = Theme.GRAY },
|
||||
promoteWait = { icon = "customer", color = Theme.GRAY },
|
||||
adUnavailable = { icon = "customer", color = Theme.GRAY },
|
||||
kicked = { icon = "customer", color = Theme.MINT },
|
||||
kickedBy = { icon = "customer", color = Theme.RED },
|
||||
shielded = { icon = "lock", color = Theme.GRAY },
|
||||
kickOwn = { icon = "store", color = Theme.GRAY },
|
||||
rushOn = { icon = "bolt", color = Theme.YELLOW },
|
||||
boostGot = { icon = "bolt", color = Theme.YELLOW },
|
||||
doubleOwned = { icon = "moneyBag", color = Theme.LAVENDER },
|
||||
removed = { icon = "check", color = Theme.MINT },
|
||||
removeFail = { icon = "close", color = Theme.RED },
|
||||
devFreeOn = { icon = "wrench", color = Theme.YELLOW },
|
||||
devFreeOff = { icon = "wrench", color = Theme.GRAY },
|
||||
guestBonus = { icon = "coin", color = Theme.MINT },
|
||||
guestArrived = { icon = "customer", color = Theme.SKY },
|
||||
guestSeated = { icon = "customer", color = Theme.SKY },
|
||||
guestAte = { icon = "heart", color = Theme.PINK },
|
||||
notEnough = { icon = "coin", color = Theme.GRAY },
|
||||
tutDone = { icon = "mascot", color = Theme.PINK },
|
||||
devResetDone = { icon = "wrench", color = Theme.GRAY },
|
||||
}
|
||||
|
||||
local attr = Info.attr
|
||||
|
||||
-- 알림 글(메뉴·갈래·역할·소품·디자인 id를 내 언어 이름으로 바꿔 씀). 꾸미기 화면도 같이 씁니다.
|
||||
Hud.toastText = Info.toast
|
||||
|
||||
local function at(o: GuiObject, x: number, y: number, w: number, h: number)
|
||||
o.Position = UDim2.fromOffset(x, y)
|
||||
o.Size = UDim2.fromOffset(w, h)
|
||||
end
|
||||
|
||||
-- 설정 창 한 줄(아이콘 + 이름)
|
||||
local function settingRow(parent: Instance, name: string, icon: string): (Frame, TextLabel)
|
||||
local row = Theme.frame(parent, name)
|
||||
row.ZIndex = 3
|
||||
local ic = Theme.icon(row, "Icon", icon)
|
||||
ic.Size = UDim2.fromOffset(40, 40)
|
||||
ic.Position = UDim2.fromScale(0, 0.5)
|
||||
ic.AnchorPoint = Vector2.new(0, 0.5)
|
||||
ic.ZIndex = 4
|
||||
local t = Theme.text(row, "Text")
|
||||
t.Position = UDim2.new(0, 50, 0.5, 0)
|
||||
t.AnchorPoint = Vector2.new(0, 0.5)
|
||||
t.Size = UDim2.new(1, -50, 0, 30)
|
||||
t.TextXAlignment = Enum.TextXAlignment.Left
|
||||
t.ZIndex = 4
|
||||
return row, t
|
||||
end
|
||||
|
||||
function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> ()): HudHandle
|
||||
local gui = Instance.new("ScreenGui")
|
||||
gui.Name = "BunsikHud"
|
||||
gui.ResetOnSpawn = false
|
||||
gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
|
||||
gui.Parent = parent
|
||||
|
||||
local tweens: { Tween } = {}
|
||||
local function keep(t: Tween): Tween
|
||||
table.insert(tweens, t)
|
||||
return t
|
||||
end
|
||||
|
||||
local function lang(): string
|
||||
return attr(state, "Lang", "ko")
|
||||
end
|
||||
local function L(key: string, args: { [string]: any }?): string
|
||||
return Locale.t(lang(), key, args)
|
||||
end
|
||||
|
||||
-- 루트는 기준 단위(화면 픽셀 / 배율) 크기로 만들고 UIScale로 키워 화면을 꽉 채웁니다.
|
||||
local root = Theme.frame(gui, "Root")
|
||||
root.Size = UDim2.fromOffset(1100, 620)
|
||||
local scale = Instance.new("UIScale")
|
||||
scale.Parent = root
|
||||
|
||||
-- 돈: 노란 알약 + 왼쪽에 튀어나온 동전, 숫자는 둥근 글꼴
|
||||
local money = Theme.frame(root, "Money")
|
||||
local moneyScale = Instance.new("UIScale")
|
||||
moneyScale.Parent = money
|
||||
local pill = Theme.frame(money, "Pill", Theme.YELLOW)
|
||||
pill.AnchorPoint = Vector2.new(0, 0.5)
|
||||
pill.Position = UDim2.new(0, 26, 0.5, 0)
|
||||
pill.Size = UDim2.new(1, -26, 0, 46)
|
||||
Theme.round(pill)
|
||||
Theme.stroke(pill, Theme.edge(Theme.YELLOW), 3.5)
|
||||
Theme.gradient(pill, Color3.fromRGB(255, 232, 120), Theme.YELLOW)
|
||||
local pillGloss = Theme.frame(pill, "Gloss", Theme.WHITE)
|
||||
pillGloss.BackgroundTransparency = 0.55
|
||||
pillGloss.Position = UDim2.fromOffset(40, 5)
|
||||
pillGloss.Size = UDim2.new(1, -64, 0, 10)
|
||||
Theme.round(pillGloss)
|
||||
local moneyText = Theme.text(pill, "Text", Theme.edge(Theme.YELLOW), true)
|
||||
moneyText.Position = UDim2.fromOffset(40, 5)
|
||||
moneyText.Size = UDim2.new(1, -56, 1, -10)
|
||||
moneyText.ZIndex = 2
|
||||
local coin = Theme.icon(money, "Coin", "coin")
|
||||
coin.Size = UDim2.fromOffset(62, 62)
|
||||
coin.Position = UDim2.new(0, -4, 0.5, 0)
|
||||
coin.AnchorPoint = Vector2.new(0, 0.5)
|
||||
coin.ZIndex = 3
|
||||
|
||||
-- 손에 든 접시: 든 만큼 음식 그림, 빈 칸은 점선 동그라미
|
||||
local carry = Theme.frame(root, "Carry", Theme.WHITE)
|
||||
carry.BackgroundTransparency = 0.1
|
||||
Theme.round(carry)
|
||||
Theme.stroke(carry, Theme.LINE, 3)
|
||||
local carryList = Instance.new("UIListLayout")
|
||||
carryList.FillDirection = Enum.FillDirection.Horizontal
|
||||
carryList.HorizontalAlignment = Enum.HorizontalAlignment.Center
|
||||
carryList.VerticalAlignment = Enum.VerticalAlignment.Center
|
||||
carryList.Padding = UDim.new(0, 6)
|
||||
carryList.SortOrder = Enum.SortOrder.LayoutOrder
|
||||
carryList.Parent = carry
|
||||
local carrySlots: { ImageLabel } = {}
|
||||
for i = 1, 3 do
|
||||
local slot = Theme.icon(carry, "Slot" .. i, "plate")
|
||||
slot.Size = UDim2.fromOffset(36, 36)
|
||||
slot.LayoutOrder = i
|
||||
slot.BackgroundColor3 = Theme.CREAM
|
||||
Theme.round(slot)
|
||||
carrySlots[i] = slot
|
||||
end
|
||||
|
||||
-- 튜토리얼 말풍선: 마스코트 떡이가 말해 줍니다.
|
||||
local hint = Theme.frame(root, "Hint")
|
||||
local bubble = Theme.frame(hint, "Bubble", Theme.WHITE)
|
||||
bubble.Position = UDim2.fromOffset(44, 0)
|
||||
bubble.Size = UDim2.new(1, -44, 1, 0)
|
||||
Theme.corner(bubble, 22)
|
||||
Theme.stroke(bubble, Theme.PINK, 4)
|
||||
local hintText = Theme.text(bubble, "Text")
|
||||
hintText.Position = UDim2.fromOffset(46, 8)
|
||||
hintText.Size = UDim2.new(1, -60, 1, -16)
|
||||
local mascot = Theme.icon(hint, "Mascot", "mascot")
|
||||
mascot.Size = UDim2.fromOffset(84, 84)
|
||||
mascot.AnchorPoint = Vector2.new(0, 0.5)
|
||||
mascot.Position = UDim2.fromScale(0, 0.5)
|
||||
mascot.ZIndex = 3
|
||||
keep(
|
||||
TweenService:Create(
|
||||
mascot,
|
||||
TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true),
|
||||
{ Rotation = 8 }
|
||||
)
|
||||
):Play()
|
||||
|
||||
-- 알림(새 알림이 위에, 최대 3개)
|
||||
local toasts = Theme.frame(root, "Toasts")
|
||||
local list = Instance.new("UIListLayout")
|
||||
list.HorizontalAlignment = Enum.HorizontalAlignment.Center
|
||||
list.Padding = UDim.new(0, 6)
|
||||
list.SortOrder = Enum.SortOrder.LayoutOrder
|
||||
list.Parent = toasts
|
||||
|
||||
-- 튜토리얼 손가락: 3단계에서 [가게 꾸미기] 버튼을 가리킵니다.
|
||||
local pointer = Theme.icon(root, "Pointer", "hand")
|
||||
pointer.Size = UDim2.fromOffset(56, 56)
|
||||
pointer.AnchorPoint = Vector2.new(0.5, 0)
|
||||
pointer.ZIndex = 8
|
||||
pointer.Visible = false
|
||||
|
||||
-- 버튼 묶음: 상점, 가게 꾸미기, 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)
|
||||
gear.ZIndex = 4
|
||||
local passBtn, passLabel = Theme.iconButton(root, "Double", Theme.LAVENDER, "moneyBag")
|
||||
local x2 = Theme.text(passBtn.button, "X2", Theme.edge(Theme.LAVENDER), true)
|
||||
x2.Text = "x2"
|
||||
x2.TextColor3 = Color3.fromRGB(255, 236, 90)
|
||||
x2.AnchorPoint = Vector2.new(1, 0)
|
||||
x2.Position = UDim2.new(1, 4, 0, -6)
|
||||
x2.Size = UDim2.fromScale(0.5, 0.34)
|
||||
x2.ZIndex = 6
|
||||
local passCheck = Theme.icon(passBtn.button, "Owned", "check")
|
||||
passCheck.Size = UDim2.fromScale(0.4, 0.4)
|
||||
passCheck.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
passCheck.Position = UDim2.new(1, -6, 0, 6)
|
||||
passCheck.ZIndex = 8
|
||||
local boostBtn, boostLabel = Theme.iconButton(root, "Boost", Theme.ORANGE, "bolt")
|
||||
local boostTag = Theme.frame(boostBtn.button, "Tag", Theme.MINT)
|
||||
boostTag.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
boostTag.Position = UDim2.new(0.5, 0, 0, 2)
|
||||
boostTag.Size = UDim2.new(0.9, 0, 0, 22)
|
||||
boostTag.ZIndex = 8
|
||||
Theme.round(boostTag)
|
||||
Theme.stroke(boostTag, Theme.edge(Theme.MINT), 2.5)
|
||||
local boostAmount = Theme.text(boostTag, "Text", Theme.edge(Theme.MINT), true)
|
||||
boostAmount.Position = UDim2.fromOffset(6, 2)
|
||||
boostAmount.Size = UDim2.new(1, -12, 1, -4)
|
||||
boostAmount.ZIndex = 9
|
||||
|
||||
-- 손님 버튼 묶음: 홍보(옆 가게 손님 데려오기, 대기 시간 표시), 손님 러시(남은 시간 표시)
|
||||
local promoteBtn, promoteLabel, promoteImg = Theme.iconButton(root, "Promote", Theme.SKY, "customer")
|
||||
promoteImg.Visible = false
|
||||
local promoteEmoji = Theme.text(promoteBtn.face, "Emoji")
|
||||
Theme.place(promoteEmoji, 0.5, 0.44, 0.66, 0.62)
|
||||
promoteEmoji.ZIndex = 4
|
||||
promoteEmoji.Text = "📣"
|
||||
local rushBtn, rushLabel = Theme.iconButton(root, "Rush", Theme.YELLOW, "customer")
|
||||
local rushBolt = Theme.icon(rushBtn.button, "Bolt", "bolt")
|
||||
rushBolt.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
rushBolt.Position = UDim2.new(1, -8, 0, 8)
|
||||
rushBolt.Size = UDim2.fromScale(0.42, 0.42)
|
||||
rushBolt.ZIndex = 8
|
||||
local rushPrice = Theme.frame(rushBtn.button, "Price", Theme.LAVENDER)
|
||||
rushPrice.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
rushPrice.Position = UDim2.fromOffset(10, 4)
|
||||
rushPrice.Size = UDim2.new(0.56, 0, 0, 20)
|
||||
rushPrice.ZIndex = 8
|
||||
Theme.round(rushPrice)
|
||||
Theme.stroke(rushPrice, Theme.edge(Theme.LAVENDER), 2)
|
||||
local rushPriceText = Theme.text(rushPrice, "Text", Theme.edge(Theme.LAVENDER), true)
|
||||
rushPriceText.Position = UDim2.fromOffset(4, 2)
|
||||
rushPriceText.Size = UDim2.new(1, -8, 1, -4)
|
||||
rushPriceText.ZIndex = 9
|
||||
|
||||
-- 창 뒤 어둡게(누르면 창 닫힘)
|
||||
local dim = Instance.new("TextButton")
|
||||
dim.Name = "Dim"
|
||||
dim.Text = ""
|
||||
dim.AutoButtonColor = false
|
||||
dim.BorderSizePixel = 0
|
||||
dim.BackgroundColor3 = Color3.fromRGB(40, 20, 50)
|
||||
dim.BackgroundTransparency = 0.5
|
||||
dim.Size = UDim2.fromScale(1, 1)
|
||||
dim.Visible = false
|
||||
dim.ZIndex = 10
|
||||
dim.Parent = root
|
||||
|
||||
-- 상점 창(탭 3개)
|
||||
local decorateFns: { () -> () } = {}
|
||||
local shop = ShopWindow.build(root, state, send)
|
||||
local panel = shop.frame
|
||||
|
||||
-- 홍보 확인 창: 광고를 보면 무엇을 받는지 먼저 알려 주고, 고르게 합니다(광고는 늘 선택).
|
||||
local promotePanel = Theme.panel(root, "PromotePanel", Theme.SKY)
|
||||
local promoteWin = promotePanel.frame
|
||||
promoteWin.ZIndex = 24
|
||||
local promoteBig = Theme.text(promotePanel.body, "Emoji")
|
||||
promoteBig.Text = "📣"
|
||||
promoteBig.TextColor3 = Theme.WHITE
|
||||
promoteBig.Position = UDim2.fromOffset(18, Layout.HEADER_H + 12)
|
||||
promoteBig.Size = UDim2.fromScale(0.22, 0.36)
|
||||
promoteBig.ZIndex = 3
|
||||
local promoteText = Theme.text(promotePanel.body, "Text")
|
||||
promoteText.Position = UDim2.new(0.26, 0, 0, Layout.HEADER_H + 12)
|
||||
promoteText.Size = UDim2.fromScale(0.7, 0.36)
|
||||
promoteText.ZIndex = 3
|
||||
local adBtn, adLabel = Theme.textButton(promotePanel.body, "WatchAd", Theme.MINT, 20)
|
||||
adBtn.button.AnchorPoint = Vector2.new(0, 1)
|
||||
adBtn.button.Position = UDim2.new(0.04, 0, 1, -14)
|
||||
adBtn.button.Size = UDim2.new(0.44, 0, 0, 62)
|
||||
adBtn.button.ZIndex = 4
|
||||
local freeBtn, freeLabel = Theme.textButton(promotePanel.body, "Free", Theme.SKY, 20)
|
||||
freeBtn.button.AnchorPoint = Vector2.new(1, 1)
|
||||
freeBtn.button.Position = UDim2.new(0.96, 0, 1, -14)
|
||||
freeBtn.button.Size = UDim2.new(0.44, 0, 0, 62)
|
||||
freeBtn.button.ZIndex = 4
|
||||
|
||||
-- 설정 창(언어, 마우스로 화면 돌리기, 효과음, 개발자 테스트)
|
||||
local setPanel = Theme.panel(root, "SettingsPanel", Theme.SKY)
|
||||
local settings = setPanel.frame
|
||||
local langRow, langLabel = settingRow(settings, "LangRow", "globe")
|
||||
langRow.ZIndex = 3
|
||||
at(langRow, 22, 66, 300, 40)
|
||||
local langChoices = { "" }
|
||||
for _, l in Locale.LANGS do
|
||||
table.insert(langChoices, l)
|
||||
end
|
||||
local langButtons: { [string]: Theme.Button } = {}
|
||||
local langLabels: { [string]: TextLabel } = {}
|
||||
for _, l in langChoices do
|
||||
local b, t = Theme.textButton(settings, "Lang_" .. (if l == "" then "auto" else l), Theme.GRAY, 16)
|
||||
b.button.ZIndex = 3
|
||||
langButtons[l] = b
|
||||
langLabels[l] = t
|
||||
end
|
||||
local mouseRow, mouseLabel = settingRow(settings, "MouseRow", "mouse")
|
||||
local mouseBtn, mouseValue = Theme.textButton(settings, "MouseLook", Theme.MINT)
|
||||
mouseBtn.button.ZIndex = 3
|
||||
local mouseHint = Theme.text(settings, "MouseHint")
|
||||
mouseHint.TextColor3 = Theme.SOFT
|
||||
mouseHint.TextXAlignment = Enum.TextXAlignment.Left
|
||||
mouseHint.ZIndex = 3
|
||||
local sfxRow, sfxLabel = settingRow(settings, "SfxRow", "speaker")
|
||||
local sfxBtn, sfxValue = Theme.textButton(settings, "Sfx", Theme.MINT)
|
||||
sfxBtn.button.ZIndex = 3
|
||||
local devRow, devTitle = settingRow(settings, "DevLabel", "wrench")
|
||||
local devButtons: { [string]: Theme.Button } = {}
|
||||
local devLabels: { [string]: TextLabel } = {}
|
||||
for _, key in { "devMoney", "devFree", "devDouble", "devReset" } do
|
||||
local b, t = Theme.textButton(settings, key, Color3.fromRGB(130, 120, 160), 16)
|
||||
b.button.ZIndex = 3
|
||||
devButtons[key] = b
|
||||
devLabels[key] = t
|
||||
end
|
||||
for _, o in { mouseRow, sfxRow, devRow } :: { GuiObject } do
|
||||
o.ZIndex = 3
|
||||
end
|
||||
|
||||
-- 요리 창
|
||||
local kitchen = Kitchen.build(root, state, send)
|
||||
|
||||
-- 화면 크기에 맞춰 배치합니다(Layout 모듈). 버튼은 가운데 기준이라 누르면 제자리에서 작아집니다.
|
||||
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 screen = Vector2.new(1100, 620)
|
||||
local touch = false
|
||||
local layoutNow: Layout.Result
|
||||
local function relayout()
|
||||
local dev = attr(state, "Dev", false) == true
|
||||
local lay = Layout.compute(screen.X, screen.Y, touch, dev)
|
||||
layoutNow = lay
|
||||
scale.Scale = lay.scale
|
||||
-- Offset은 정수라서 올림해 화면을 다 덮습니다(1 기준 단위 미만 차이).
|
||||
root.Size = UDim2.fromOffset(math.ceil(lay.width), math.ceil(lay.height))
|
||||
place(money, lay.money)
|
||||
place(carry, lay.carry)
|
||||
place(hint, lay.hint)
|
||||
place(toasts, lay.toasts)
|
||||
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)
|
||||
place(promoteBtn.button, lay.promote)
|
||||
place(rushBtn.button, lay.rush)
|
||||
place(settings, lay.settingsPanel)
|
||||
shop.setLayout(lay)
|
||||
kitchen.setLayout(lay)
|
||||
-- 튜토리얼 손가락은 [가게 꾸미기] 버튼 바로 아래(휴대폰) 또는 오른쪽(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
|
||||
local r = lay.rows
|
||||
place(promoteWin, lay.confirm)
|
||||
for _, c in { setPanel.close, promotePanel.close } do
|
||||
c.button.Size = UDim2.fromOffset(r.closeH, r.closeH)
|
||||
end
|
||||
local i = 0
|
||||
for _, l in langChoices do
|
||||
at(langButtons[l].button, 22 + i * 104, 106, 96, r.langButtonH)
|
||||
i += 1
|
||||
end
|
||||
local mouseY = r.mouseY
|
||||
mouseRow.Visible = mouseY ~= nil
|
||||
mouseBtn.button.Visible = mouseY ~= nil
|
||||
mouseHint.Visible = mouseY ~= nil
|
||||
if mouseY then
|
||||
at(mouseRow, 22, mouseY, 360, r.toggleH)
|
||||
at(mouseBtn.button, 0, 0, 120, r.toggleH)
|
||||
mouseBtn.button.Position = UDim2.new(1, -142, 0, mouseY)
|
||||
at(mouseHint, 72, mouseY + r.toggleH + 6, 440, 24)
|
||||
end
|
||||
at(sfxRow, 22, r.sfxY, 360, r.toggleH)
|
||||
at(sfxBtn.button, 0, 0, 120, r.toggleH)
|
||||
sfxBtn.button.Position = UDim2.new(1, -142, 0, r.sfxY)
|
||||
local devY = r.devY
|
||||
devRow.Visible = devY ~= nil
|
||||
if devY then
|
||||
at(devRow, 22, devY, 360, 36)
|
||||
end
|
||||
local j = 0
|
||||
for _, key in { "devMoney", "devFree", "devDouble", "devReset" } do
|
||||
local db = devButtons[key].button
|
||||
db.Visible = devY ~= nil
|
||||
if devY then
|
||||
at(db, 22 + j * 130, devY + 40, 122, r.devButtonH)
|
||||
end
|
||||
j += 1
|
||||
end
|
||||
end
|
||||
relayout()
|
||||
|
||||
local function toggle(b: Theme.Button, label: TextLabel, on: boolean)
|
||||
label.Text = L(if on then "on" else "off")
|
||||
b.setColor(if on then Theme.MINT else Theme.GRAY)
|
||||
end
|
||||
|
||||
local lastMoney: number? = nil
|
||||
|
||||
-- 돈이 늘면 "+N"이 떠오르고 돈 알약이 통 튑니다.
|
||||
local function moneyPop(gain: number)
|
||||
moneyScale.Scale = 1.12
|
||||
TweenService:Create(moneyScale, TweenInfo.new(0.35, Enum.EasingStyle.Back), { Scale = 1 }):Play()
|
||||
local f = Theme.text(root, "Gain", Theme.edge(Theme.MINT), true)
|
||||
f.Text = "+" .. Locale.number(gain)
|
||||
f.TextColor3 = Color3.fromRGB(150, 255, 170)
|
||||
local m = layoutNow.money
|
||||
f.AnchorPoint = Vector2.new(0.5, 0)
|
||||
f.Size = UDim2.fromOffset(160, 34)
|
||||
f.Position = UDim2.fromOffset(m.x + m.w / 2 + 20, m.y + m.h - 4)
|
||||
f.ZIndex = 9
|
||||
TweenService:Create(f, TweenInfo.new(0.9, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
|
||||
Position = UDim2.fromOffset(m.x + m.w / 2 + 20, m.y + m.h + 26),
|
||||
TextTransparency = 1,
|
||||
}):Play()
|
||||
local st = f:FindFirstChildOfClass("UIStroke")
|
||||
if st then
|
||||
TweenService:Create(st, TweenInfo.new(0.9), { Transparency = 1 }):Play()
|
||||
end
|
||||
task.delay(1, function()
|
||||
f:Destroy()
|
||||
end)
|
||||
end
|
||||
|
||||
-- 홍보·러시 버튼의 남은 시간(1초마다 다시 씀)
|
||||
local function timers()
|
||||
local now = Info.now()
|
||||
local wait = attr(state, "PromoteAt", 0) - now
|
||||
local adOk = Products.PROMOTE_AD_PRODUCT ~= 0 and attr(state, "PromoteAdAt", 0) <= now
|
||||
promoteLabel.Text = if wait > 0 then Info.clock(wait) else L("btnPromote")
|
||||
promoteBtn.setColor(if wait > 0 and not adOk then Theme.GRAY else Theme.SKY)
|
||||
local rushLeft = attr(state, "RushUntil", 0) - now
|
||||
rushLabel.Text = if rushLeft > 0 then Info.clock(rushLeft) else L("btnRush")
|
||||
local price = Info.robux("RUSH_PRODUCT")
|
||||
rushPrice.Visible = price ~= nil and rushLeft <= 0
|
||||
rushPriceText.Text = price or ""
|
||||
freeLabel.Text = if wait > 0 then Info.clock(wait) else L("promoteFree")
|
||||
freeBtn.setColor(if wait > 0 then Theme.GRAY else Theme.SKY)
|
||||
end
|
||||
|
||||
local function refresh()
|
||||
local m = attr(state, "Money", 0)
|
||||
local levels = Info.levels(state)
|
||||
local seats = attr(state, "Seats", 1)
|
||||
local tables = attr(state, "Tables", 1)
|
||||
local stats = Economy.stats(levels, seats)
|
||||
moneyText.Text = Locale.number(m)
|
||||
if lastMoney and m > lastMoney then
|
||||
moneyPop(m - lastMoney)
|
||||
end
|
||||
lastMoney = m
|
||||
|
||||
-- 손에 든 접시
|
||||
local handStr = attr(state, "Hand", "") :: string
|
||||
local hand = if handStr == "" then {} else string.split(handStr, ",")
|
||||
local held = attr(state, "Carry", #hand)
|
||||
carry.Visible = held > 0
|
||||
for i, slot in carrySlots do
|
||||
slot.Visible = i <= stats.carry
|
||||
local menu = hand[i]
|
||||
if menu and Economy.MENUS[menu] then
|
||||
Theme.setIcon(slot, menu)
|
||||
slot.ImageTransparency = 0
|
||||
slot.BackgroundTransparency = 1
|
||||
else
|
||||
Theme.setIcon(slot, "plate")
|
||||
slot.ImageTransparency = if i <= held then 0 else 0.75
|
||||
slot.BackgroundTransparency = if i <= held then 1 else 0
|
||||
end
|
||||
end
|
||||
carry.Size = UDim2.fromOffset(stats.carry * 42 + 20, layoutNow.carry.h)
|
||||
|
||||
-- 지금 살 수 있는 것 중 가장 싼 것(갈래 다음 단계, 의자, 테이블). 살 수 있으면 상점 버튼에 ! 배지
|
||||
local offer = Economy.offers(levels, tables, seats)[1]
|
||||
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
|
||||
hintText.Text = L("tut" .. tut)
|
||||
else
|
||||
hint.Visible = false
|
||||
end
|
||||
pointer.Visible = tut == 3
|
||||
|
||||
if (layoutNow.rows.devY ~= nil) ~= (attr(state, "Dev", false) == true) then
|
||||
relayout()
|
||||
end
|
||||
devTitle.Text = L("devTitle")
|
||||
for key, t in devLabels do
|
||||
t.Text = L(key)
|
||||
end
|
||||
local free = attr(state, "DevFree", false) == true
|
||||
devLabels.devFree.Text = L(if free then "devFreeBtnOff" else "devFreeBtnOn")
|
||||
devButtons.devFree.setColor(if free then Theme.MINT else Color3.fromRGB(130, 120, 160))
|
||||
|
||||
listLabel.Text = L("btnShop")
|
||||
decoLabel.Text = L("btnDecorate")
|
||||
setPanel.title.Text = L("settings")
|
||||
langLabel.Text = L("language")
|
||||
local current = attr(state, "LangSetting", "")
|
||||
for l, b in langButtons do
|
||||
langLabels[l].Text = if l == "" then L("langAuto") else Locale.LANG_NAMES[l]
|
||||
b.setColor(if l == current then Theme.SKY else Theme.GRAY)
|
||||
end
|
||||
mouseLabel.Text = L("mouseLook")
|
||||
mouseHint.Text = L("mouseHint")
|
||||
toggle(mouseBtn, mouseValue, attr(state, "MouseLook", true) == true)
|
||||
sfxLabel.Text = L("sfx")
|
||||
toggle(sfxBtn, sfxValue, attr(state, "Sfx", true) == true)
|
||||
|
||||
local double = attr(state, "Double", false)
|
||||
passBtn.button.Visible = Products.DOUBLE_MONEY_PASS ~= 0
|
||||
passLabel.Text = if double then L("doubleOn") else L("btnDouble")
|
||||
passCheck.Visible = double
|
||||
x2.Visible = not double
|
||||
passBtn.button.Active = not double
|
||||
boostBtn.button.Visible = Products.MONEY_BOOST_PRODUCT ~= 0 and offer ~= nil
|
||||
boostLabel.Text = L("btnBoost")
|
||||
boostAmount.Text = "+" .. Locale.number(attr(state, "Boost", Economy.BOOST_MIN))
|
||||
|
||||
promotePanel.title.Text = L("promoteTitle")
|
||||
promoteText.Text = L("promoteAdText")
|
||||
adLabel.Text = L("watchAd")
|
||||
timers()
|
||||
|
||||
kitchen.refresh()
|
||||
if shop.isOpen() then
|
||||
shop.refresh()
|
||||
end
|
||||
end
|
||||
|
||||
local toastN = 0
|
||||
local function notify(key: string, args: { [string]: any }?)
|
||||
local style = TOAST_STYLE[key] or { icon = "sparkle", color = Theme.SKY }
|
||||
toastN += 1
|
||||
-- 오래된 알림은 3개까지만 남깁니다.
|
||||
local alive = {}
|
||||
for _, t in toasts:GetChildren() do
|
||||
if t:IsA("Frame") then
|
||||
table.insert(alive, t)
|
||||
end
|
||||
end
|
||||
table.sort(alive, function(a, b)
|
||||
return a.LayoutOrder < b.LayoutOrder
|
||||
end)
|
||||
for i = 3, #alive do
|
||||
alive[i]:Destroy()
|
||||
end
|
||||
local toast = Theme.frame(toasts, "Toast", Theme.WHITE)
|
||||
toast.Size = UDim2.new(1, -20, 0, 46)
|
||||
toast.LayoutOrder = -toastN -- 새 알림이 위에
|
||||
Theme.round(toast)
|
||||
local st = Theme.stroke(toast, style.color, 3.5)
|
||||
local sc = Instance.new("UIScale")
|
||||
sc.Parent = toast
|
||||
local dot = Theme.frame(toast, "Dot", style.color)
|
||||
dot.AnchorPoint = Vector2.new(0, 0.5)
|
||||
dot.Position = UDim2.new(0, 4, 0.5, 0)
|
||||
dot.Size = UDim2.fromOffset(38, 38)
|
||||
dot.ZIndex = 2
|
||||
Theme.round(dot)
|
||||
Theme.gradient(dot, Theme.lighten(style.color, 0.5), Theme.lighten(style.color, 0.2))
|
||||
local ic = Theme.icon(toast, "Icon", style.icon)
|
||||
ic.ZIndex = 3
|
||||
ic.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
ic.Position = UDim2.new(0, 23, 0.5, 0)
|
||||
ic.Size = UDim2.fromOffset(32, 32)
|
||||
local t = Theme.text(toast, "Text")
|
||||
t.Position = UDim2.fromOffset(52, 8)
|
||||
t.Size = UDim2.new(1, -68, 1, -16)
|
||||
t.ZIndex = 2
|
||||
t.Text = Hud.toastText(lang(), key, args)
|
||||
Theme.pop(toast)
|
||||
task.delay(2.8, function()
|
||||
local info = TweenInfo.new(0.4)
|
||||
TweenService:Create(toast, info, { BackgroundTransparency = 1 }):Play()
|
||||
TweenService:Create(dot, info, { BackgroundTransparency = 1 }):Play()
|
||||
TweenService:Create(t, info, { TextTransparency = 1 }):Play()
|
||||
TweenService:Create(ic, info, { ImageTransparency = 1 }):Play()
|
||||
TweenService:Create(st, info, { Transparency = 1 }):Play()
|
||||
task.wait(0.45)
|
||||
toast:Destroy()
|
||||
end)
|
||||
end
|
||||
|
||||
local function show(which: string?, tab: string?)
|
||||
if which == "shop" then
|
||||
shop.open(tab)
|
||||
else
|
||||
shop.close()
|
||||
end
|
||||
settings.Visible = which == "settings"
|
||||
promoteWin.Visible = which == "promote"
|
||||
if which == "kitchen" then
|
||||
kitchen.open()
|
||||
else
|
||||
kitchen.close()
|
||||
end
|
||||
dim.Visible = which ~= nil
|
||||
if which == "settings" then
|
||||
Theme.pop(settings)
|
||||
elseif which == "promote" then
|
||||
Theme.pop(promoteWin)
|
||||
end
|
||||
end
|
||||
kitchen.onClose(function()
|
||||
if not panel.Visible and not settings.Visible and not promoteWin.Visible then
|
||||
dim.Visible = false
|
||||
end
|
||||
end)
|
||||
|
||||
-- 홍보: 광고를 볼 수 있으면 먼저 물어보고(보상 안내), 아니면 바로 무료 홍보를 보냅니다.
|
||||
local checkingAd = false
|
||||
local function pressPromote()
|
||||
if checkingAd then
|
||||
return
|
||||
end
|
||||
local now = Info.now()
|
||||
if Products.PROMOTE_AD_PRODUCT == 0 or attr(state, "PromoteAdAt", 0) > now then
|
||||
send("promote", { ad = false })
|
||||
return
|
||||
end
|
||||
checkingAd = true
|
||||
task.spawn(function()
|
||||
local ok, result = pcall(function()
|
||||
return AdService:GetAdAvailabilityNowAsync(Enum.AdFormat.RewardedVideo)
|
||||
end)
|
||||
checkingAd = false
|
||||
if ok and result and result.AdAvailabilityResult == Enum.AdAvailabilityResult.IsAvailable then
|
||||
timers()
|
||||
show("promote")
|
||||
else
|
||||
send("promote", { ad = false })
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local conns: { RBXScriptConnection } = {}
|
||||
local function on(sig: RBXScriptSignal, fn: (...any) -> ())
|
||||
table.insert(conns, sig:Connect(fn))
|
||||
end
|
||||
on(listBtn.button.Activated, function()
|
||||
show(if panel.Visible then nil else "shop")
|
||||
end)
|
||||
on(decoBtn.button.Activated, function()
|
||||
show(nil)
|
||||
for _, fn in decorateFns do
|
||||
fn()
|
||||
end
|
||||
end)
|
||||
on(dim.Activated, function()
|
||||
-- 요리 중에는 바깥을 눌러도 닫지 않습니다(실수로 닫히지 않게).
|
||||
if not kitchen.isOpen() then
|
||||
show(nil)
|
||||
end
|
||||
end)
|
||||
on(settingsBtn.button.Activated, function()
|
||||
show(if settings.Visible then nil else "settings")
|
||||
end)
|
||||
for _, c in { setPanel.close, promotePanel.close } do
|
||||
on(c.button.Activated, function()
|
||||
show(nil)
|
||||
end)
|
||||
end
|
||||
on(shop.closeButton.Activated, function()
|
||||
show(nil)
|
||||
end)
|
||||
for l, b in langButtons do
|
||||
on(b.button.Activated, function()
|
||||
send("lang", l)
|
||||
end)
|
||||
end
|
||||
on(mouseBtn.button.Activated, function()
|
||||
send("mouseLook", attr(state, "MouseLook", true) ~= true)
|
||||
end)
|
||||
on(sfxBtn.button.Activated, function()
|
||||
send("sfx", attr(state, "Sfx", true) ~= true)
|
||||
end)
|
||||
on(passBtn.button.Activated, function()
|
||||
if not attr(state, "Double", false) then
|
||||
send("pass")
|
||||
end
|
||||
end)
|
||||
on(boostBtn.button.Activated, function()
|
||||
send("boost")
|
||||
end)
|
||||
on(promoteBtn.button.Activated, pressPromote)
|
||||
on(rushBtn.button.Activated, function()
|
||||
send("rush")
|
||||
end)
|
||||
on(adBtn.button.Activated, function()
|
||||
show(nil)
|
||||
send("promote", { ad = true })
|
||||
end)
|
||||
on(freeBtn.button.Activated, function()
|
||||
if attr(state, "PromoteAt", 0) <= Info.now() then
|
||||
show(nil)
|
||||
send("promote", { ad = false })
|
||||
end
|
||||
end)
|
||||
local devKinds: { [string]: string } =
|
||||
{ devMoney = "dev_money", devFree = "dev_free", devDouble = "dev_double", devReset = "dev_reset" }
|
||||
for key, kind in devKinds do
|
||||
on(devButtons[key].button.Activated, function()
|
||||
send(kind)
|
||||
end)
|
||||
end
|
||||
on(state.AttributeChanged, refresh)
|
||||
refresh()
|
||||
local alive = true
|
||||
task.spawn(function()
|
||||
while alive do
|
||||
task.wait(1)
|
||||
if alive then
|
||||
timers()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
return {
|
||||
gui = gui,
|
||||
refresh = refresh,
|
||||
notify = notify,
|
||||
kitchen = kitchen,
|
||||
shop = shop,
|
||||
setLayout = function(size: Vector2, isTouch: boolean)
|
||||
screen = size
|
||||
touch = isTouch
|
||||
relayout()
|
||||
refresh()
|
||||
end,
|
||||
layout = function(): Layout.Result
|
||||
return layoutNow
|
||||
end,
|
||||
open = show,
|
||||
menuOpen = function(): boolean
|
||||
return panel.Visible or settings.Visible or promoteWin.Visible or kitchen.isOpen()
|
||||
end,
|
||||
onDecorate = function(fn: () -> ())
|
||||
table.insert(decorateFns, fn)
|
||||
end,
|
||||
destroy = function()
|
||||
alive = false
|
||||
for _, c in conns do
|
||||
c:Disconnect()
|
||||
end
|
||||
for _, t in tweens do
|
||||
t:Cancel()
|
||||
end
|
||||
kitchen.destroy()
|
||||
shop.destroy()
|
||||
gui:Destroy()
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
return Hud
|
||||
273
bunsik-tycoon/src/client/Info.luau
Normal file
@@ -0,0 +1,273 @@
|
||||
--!strict
|
||||
-- 화면 여러 곳(HUD, 상점 창, 요리 창, 꾸미기)에서 같이 쓰는 것:
|
||||
-- 플레이어 속성(NETWORK.md)에서 갈래 레벨·능력치·알바·배치 읽기,
|
||||
-- 업그레이드·물건별 그림(아이콘 그림에 없는 것은 이모지), 다음 단계 효과 글, 알림 글.
|
||||
|
||||
local HttpService = game:GetService("HttpService")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Shared = ReplicatedStorage:WaitForChild("Shared")
|
||||
local Codec = require(Shared:WaitForChild("Codec"))
|
||||
local Economy = require(Shared:WaitForChild("Economy"))
|
||||
local Floor = require(Shared:WaitForChild("Floor"))
|
||||
local Icons = require(Shared:WaitForChild("Icons"))
|
||||
local Locale = require(Shared:WaitForChild("Locale"))
|
||||
local Products = require(Shared:WaitForChild("Products"))
|
||||
local Theme = require(script.Parent:WaitForChild("Theme"))
|
||||
|
||||
local Info = {}
|
||||
|
||||
function Info.attr(state: Instance, key: string, default: any): any
|
||||
local v = state:GetAttribute(key)
|
||||
if v == nil then
|
||||
return default
|
||||
end
|
||||
return v
|
||||
end
|
||||
|
||||
function Info.levels(state: Instance): Economy.Levels
|
||||
return Economy.cleanLevels(Codec.decodeMap(state:GetAttribute("Levels")))
|
||||
end
|
||||
|
||||
function Info.stats(state: Instance): Economy.Stats
|
||||
return Economy.stats(Info.levels(state), Info.attr(state, "Seats", 1))
|
||||
end
|
||||
|
||||
function Info.staff(state: Instance): { [string]: number }
|
||||
return Codec.decodeMap(state:GetAttribute("Staff"))
|
||||
end
|
||||
|
||||
function Info.layout(state: Instance): Floor.Layout
|
||||
local raw = state:GetAttribute("Layout")
|
||||
local decoded = nil
|
||||
if typeof(raw) == "string" and raw ~= "" then
|
||||
local ok, v = pcall(function()
|
||||
return HttpService:JSONDecode(raw)
|
||||
end)
|
||||
if ok then
|
||||
decoded = v
|
||||
end
|
||||
end
|
||||
return Floor.clean(decoded)
|
||||
end
|
||||
|
||||
function Info.now(): number
|
||||
return workspace:GetServerTimeNow()
|
||||
end
|
||||
|
||||
-- 초 → "2:05"
|
||||
function Info.clock(sec: number): string
|
||||
local s = math.max(0, math.ceil(sec))
|
||||
return string.format("%d:%02d", s // 60, s % 60)
|
||||
end
|
||||
|
||||
-- 1.25 → "1.25", 2 → "2"
|
||||
function Info.num(n: number): string
|
||||
return (string.format("%.2f", n):gsub("%.?0+$", ""))
|
||||
end
|
||||
|
||||
-- 그림: 아이콘 그림 이름(Icons.OFFSET) 또는 이모지
|
||||
Info.TRACK_ICON = {
|
||||
Stage = "store",
|
||||
Menu = "star",
|
||||
Price = "sauce",
|
||||
Speed = "sign",
|
||||
Stove = "flame",
|
||||
Tray = "tray",
|
||||
Staff = "chef",
|
||||
} :: { [string]: string }
|
||||
|
||||
Info.ROLE_ICON = { Cook = "chef", Server = "tray", Promoter = "📣" } :: { [string]: string }
|
||||
|
||||
Info.DECOR_ICON = {
|
||||
Plant = "🪴",
|
||||
Rug = "🧶",
|
||||
Balloons = "🎈",
|
||||
Lamp = "💡",
|
||||
Teddy = "🧸",
|
||||
Fridge = "🧊",
|
||||
} :: { [string]: string }
|
||||
|
||||
Info.SEAT_ICON = "🪑"
|
||||
|
||||
-- 로벅스 가격(배지 글자용, Products 키별). 실제 가격은 로블록스 상품 설정이 원본입니다.
|
||||
Info.ROBUX = {
|
||||
RAINBOW_NAME_PASS = 99,
|
||||
CANDY_DESIGN_PASS = 149,
|
||||
HANOK_DESIGN_PASS = 149,
|
||||
RUSH_PRODUCT = 15,
|
||||
KICK_PRODUCT = 15,
|
||||
} :: { [string]: number }
|
||||
|
||||
-- 그 상품이 열려 있으면 "R$99" 같은 배지 글자, 아니면 nil
|
||||
function Info.robux(productKey: string): string?
|
||||
local id = (Products :: any)[productKey]
|
||||
if typeof(id) ~= "number" or id == 0 then
|
||||
return nil
|
||||
end
|
||||
local price = Info.ROBUX[productKey]
|
||||
return if price then `R${price}` else "R$"
|
||||
end
|
||||
|
||||
-- 디자인 견본 색(벽, 지붕, 테두리). 서버 PlotBuilder.PALETTES와 같은 색
|
||||
Info.DESIGN_COLORS = {
|
||||
Basic = { Color3.fromRGB(250, 236, 205), Color3.fromRGB(150, 70, 55), Color3.fromRGB(240, 110, 40) },
|
||||
Mint = { Color3.fromRGB(214, 245, 234), Color3.fromRGB(70, 150, 130), Color3.fromRGB(120, 210, 190) },
|
||||
Brick = { Color3.fromRGB(178, 92, 70), Color3.fromRGB(70, 62, 62), Color3.fromRGB(215, 55, 50) },
|
||||
Candy = { Color3.fromRGB(255, 205, 228), Color3.fromRGB(196, 160, 255), Color3.fromRGB(255, 120, 170) },
|
||||
Hanok = { Color3.fromRGB(246, 236, 214), Color3.fromRGB(58, 64, 76), Color3.fromRGB(150, 40, 35) },
|
||||
} :: { [string]: { Color3 } }
|
||||
|
||||
-- 갈래 그림. 메뉴 갈래는 다음에 열리는 메뉴 그림
|
||||
function Info.trackIcon(levels: Economy.Levels, id: string): string
|
||||
if id == "Menu" then
|
||||
local nl = Economy.nextLevel(levels, id)
|
||||
if nl then
|
||||
return nl.value :: string
|
||||
end
|
||||
end
|
||||
return Info.TRACK_ICON[id] or "star"
|
||||
end
|
||||
|
||||
function Info.offerIcon(levels: Economy.Levels, offer: Economy.Offer): string
|
||||
if offer.id == "Seat" then
|
||||
return Info.SEAT_ICON
|
||||
elseif offer.id == "Table" then
|
||||
return "table"
|
||||
end
|
||||
return Info.trackIcon(levels, offer.id)
|
||||
end
|
||||
|
||||
-- 다음 단계가 하는 일(짧은 글). 다 샀으면 nil
|
||||
function Info.effect(lang: string, levels: Economy.Levels, id: string): string?
|
||||
local nl = Economy.nextLevel(levels, id)
|
||||
if not nl then
|
||||
return nil
|
||||
end
|
||||
local st = Economy.stats(levels, 1)
|
||||
local v = nl.value
|
||||
if id == "Stage" then
|
||||
return Locale.t(lang, "fx_Stage", {
|
||||
from = Locale.t(lang, `stage_{st.stage}`),
|
||||
to = Locale.t(lang, `stage_{v}`),
|
||||
})
|
||||
elseif id == "Menu" then
|
||||
return Locale.t(lang, "fx_Menu", { menuName = Locale.menuName(lang, v) })
|
||||
elseif id == "Price" then
|
||||
return Locale.t(lang, "fx_Price", { from = Info.num(st.price), to = Info.num(v) })
|
||||
elseif id == "Speed" then
|
||||
return Locale.t(lang, "fx_Speed", { from = Info.num(st.spawn), to = Info.num(v) })
|
||||
elseif id == "Stove" then
|
||||
local function pct(c: number): string
|
||||
return tostring(math.floor(c / Economy.START_COOK * 100 + 0.5))
|
||||
end
|
||||
return Locale.t(lang, "fx_Stove", { from = pct(st.cook), to = pct(v) })
|
||||
elseif id == "Tray" then
|
||||
return Locale.t(lang, "fx_Tray", { from = st.carry, to = v })
|
||||
end
|
||||
return Locale.t(lang, "fx_" .. id)
|
||||
end
|
||||
|
||||
-- 화면 아래 추천 막대 이름
|
||||
function Info.offerName(lang: string, levels: Economy.Levels, offer: Economy.Offer): string
|
||||
if offer.id == "Seat" or offer.id == "Table" then
|
||||
return Locale.t(lang, "thing_" .. offer.id)
|
||||
end
|
||||
local nl = Economy.nextLevel(levels, offer.id)
|
||||
if offer.id == "Menu" and nl then
|
||||
return Locale.t(lang, "fx_Menu", { menuName = Locale.menuName(lang, nl.value) })
|
||||
elseif offer.id == "Stage" and nl then
|
||||
return Locale.t(lang, `stage_{nl.value}`)
|
||||
end
|
||||
return `{Locale.t(lang, "track_" .. offer.id)} Lv{Economy.level(levels, offer.id) + 1}`
|
||||
end
|
||||
|
||||
-- 알림 글. 서버는 메뉴·갈래·역할·소품·디자인을 id로 보내고, 이름은 내 언어로 바꿔 씁니다.
|
||||
function Info.toast(lang: string, key: string, args: { [string]: any }?): string
|
||||
local a: { [string]: any }? = nil
|
||||
if args then
|
||||
local t = table.clone(args)
|
||||
if typeof(t.menu) == "string" then
|
||||
t.menuName = Locale.menuName(lang, t.menu)
|
||||
end
|
||||
if typeof(t.track) == "string" then
|
||||
t.name = Locale.t(lang, "track_" .. t.track)
|
||||
end
|
||||
if typeof(t.role) == "string" then
|
||||
t.name = Locale.t(lang, "role_" .. t.role)
|
||||
end
|
||||
if typeof(t.kind) == "string" then
|
||||
t.name = Locale.t(lang, "decor_" .. t.kind)
|
||||
end
|
||||
if typeof(t.design) == "string" then
|
||||
t.name = Locale.t(lang, "design_" .. t.design)
|
||||
end
|
||||
if typeof(t.thing) == "string" then
|
||||
local thingKey = if t.thing == "table"
|
||||
then "thing_Table"
|
||||
elseif t.thing == "chair" then "thing_Seat"
|
||||
else "thing_Decor"
|
||||
t.name = Locale.t(lang, thingKey)
|
||||
end
|
||||
if typeof(t.why) == "string" then
|
||||
t.reason = Locale.t(lang, "why_" .. t.why)
|
||||
end
|
||||
a = t
|
||||
end
|
||||
return Locale.t(lang, key, a)
|
||||
end
|
||||
|
||||
-- 아이콘 그림 또는 이모지를 같은 자리에 보여 주는 칸
|
||||
export type Glyph = {
|
||||
frame: Frame,
|
||||
image: ImageLabel,
|
||||
emoji: TextLabel,
|
||||
set: (key: string) -> (),
|
||||
fade: (transparency: number) -> (),
|
||||
zindex: (z: number) -> (),
|
||||
}
|
||||
|
||||
function Info.glyph(parent: Instance, name: string, key: string): Glyph
|
||||
local f = Theme.frame(parent, name)
|
||||
local ratio = Instance.new("UIAspectRatioConstraint")
|
||||
ratio.AspectRatio = 1
|
||||
ratio.Parent = f
|
||||
local img = Theme.icon(f, "Image", "star")
|
||||
img.Size = UDim2.fromScale(1, 1)
|
||||
local emoji = Theme.text(f, "Emoji")
|
||||
emoji.Size = UDim2.fromScale(0.86, 0.86)
|
||||
emoji.Position = UDim2.fromScale(0.07, 0.07)
|
||||
emoji.TextColor3 = Theme.WHITE
|
||||
local function set(k: string)
|
||||
local offset: Vector2? = Icons.OFFSET[k]
|
||||
local isIcon = offset ~= nil
|
||||
img.Visible = isIcon
|
||||
emoji.Visible = not isIcon
|
||||
if isIcon then
|
||||
Icons.apply(img, k)
|
||||
else
|
||||
emoji.Text = k
|
||||
end
|
||||
end
|
||||
set(key)
|
||||
local function zindex(z: number)
|
||||
f.ZIndex = z
|
||||
img.ZIndex = z
|
||||
emoji.ZIndex = z
|
||||
end
|
||||
-- 처음에는 부모 위에 보이게
|
||||
zindex(if parent:IsA("GuiObject") then parent.ZIndex + 1 else 1)
|
||||
return {
|
||||
frame = f,
|
||||
image = img,
|
||||
emoji = emoji,
|
||||
set = set,
|
||||
fade = function(t: number)
|
||||
img.ImageTransparency = t
|
||||
emoji.TextTransparency = t
|
||||
end,
|
||||
zindex = zindex,
|
||||
}
|
||||
end
|
||||
|
||||
return Info
|
||||
1046
bunsik-tycoon/src/client/Kitchen.luau
Normal file
252
bunsik-tycoon/src/client/Layout.luau
Normal file
@@ -0,0 +1,252 @@
|
||||
--!strict
|
||||
-- 화면 UI 배치 계산(로블록스 서비스 없이 숫자만 다룸, lune 단위 테스트로 검사).
|
||||
-- 입력은 UI가 쓸 수 있는 화면 크기(상단 바·노치를 뺀 안전 영역, 픽셀)와 터치 화면 여부입니다.
|
||||
-- 결과 좌표는 기준 단위이고, 화면 픽셀 = 기준 단위 × scale 입니다.
|
||||
-- 배치 원칙(어지럽지 않게): 늘 보이는 것 — 돈(위 가운데), 버튼 4개(상점·가게 꾸미기·2배·부스트)는 한 묶음,
|
||||
-- 손님 버튼 2개(홍보·러시)는 다른 묶음, 설정(오른쪽 위), 튜토리얼 말풍선(아래 가운데, 튜토리얼 중에만),
|
||||
-- 손에 든 접시(말풍선 자리 바로 위). 나머지는 창으로 엽니다.
|
||||
-- PC는 상점 묶음을 왼쪽에 세로로, 손님 묶음을 오른쪽에 세로로 둡니다.
|
||||
-- 휴대폰은 상점 묶음을 왼쪽 위에, 손님 묶음을 오른쪽 위(설정 왼쪽)에 가로로 둡니다.
|
||||
-- 터치 화면에서는 로블록스 기본 조이스틱 자리(왼쪽 40% × 아래 2/3)와 점프 버튼 자리(오른쪽 아래)에
|
||||
-- 누르는 버튼을 두지 않습니다. 두 자리의 크기는 로블록스 PlayerModule(TouchJump, DynamicThumbstick)에서 가져왔습니다.
|
||||
|
||||
local Layout = {}
|
||||
|
||||
export type Rect = { x: number, y: number, w: number, h: number }
|
||||
|
||||
export type Result = {
|
||||
scale: number,
|
||||
width: number, -- 기준 단위 화면 너비
|
||||
height: number,
|
||||
touch: boolean,
|
||||
money: Rect,
|
||||
carry: Rect,
|
||||
hint: Rect, -- 튜토리얼 말풍선(아래 가운데)
|
||||
toasts: Rect,
|
||||
settings: Rect,
|
||||
list: Rect, -- 상점(업그레이드) 버튼
|
||||
decorate: Rect, -- 가게 꾸미기 버튼
|
||||
double: Rect,
|
||||
boost: Rect,
|
||||
promote: Rect, -- 홍보(옆 가게 손님 데려오기)
|
||||
rush: Rect, -- 손님 러시
|
||||
panel: Rect, -- 상점 창(탭 3개), 가게 꾸미기 창(같은 자리)
|
||||
tabs: { Rect }, -- 상점 창 왼쪽 탭 버튼(창 기준)
|
||||
content: Rect, -- 상점 창 안 탭 내용 자리(창 기준). 카드는 이 안을 칸으로 나눠 씁니다
|
||||
decorContent: Rect, -- 가게 꾸미기 창 안 카드 자리(창 기준, 탭 없이 넓게)
|
||||
settingsPanel: Rect,
|
||||
kitchen: Rect, -- 요리 창
|
||||
confirm: Rect, -- 홍보 확인 창(광고 보기 / 그냥 홍보)
|
||||
-- 꾸미기 모드. 다른 UI는 숨기고, 캐릭터는 걸어 다니며 투명 미리보기를 옮깁니다(조이스틱·점프 그대로).
|
||||
deco: {
|
||||
exit: Rect,
|
||||
info: Rect, -- 든 물건 이름·값과 안내 글
|
||||
tools: { Rect }, -- 들고 있을 때 아래 버튼 3개(돌리기·취소·배치). 휴대폰은 조이스틱과 점프 버튼 사이
|
||||
strip: Rect, -- 고를 때 아래 물건 줄(넘치면 옆으로 밀어 봄). 휴대폰은 조이스틱 자리 맨 아래 띠를 씀
|
||||
move: Rect, -- 물건 줄 오른쪽 [이동]
|
||||
delete: Rect, -- 물건 줄 오른쪽 [삭제]
|
||||
},
|
||||
-- 설정 창 안쪽 줄(설정 창 기준 y)
|
||||
rows: {
|
||||
langButtonH: number,
|
||||
mouseY: number?, -- 터치 화면에서는 마우스 줄을 숨김(nil)
|
||||
sfxY: number,
|
||||
toggleH: number,
|
||||
devY: number?, -- 개발자 줄(게임 주인에게만)
|
||||
devButtonH: number,
|
||||
closeH: number,
|
||||
},
|
||||
}
|
||||
|
||||
Layout.HEADER_H = 58 -- 창 위쪽 색 띠 높이(Theme.panel과 같음)
|
||||
|
||||
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 }
|
||||
end
|
||||
|
||||
-- 로블록스 터치 조작이 차지하는 자리(픽셀). 점프 버튼은 두 가지 배치(기본, 아바타 능력 UI)를 모두 덮는 상자입니다.
|
||||
function Layout.touchZones(w: number, h: number): { stick: Rect, jump: Rect }
|
||||
local small = math.min(w, h) <= 500
|
||||
local jx = if small then 136 else 220
|
||||
local jy = if small then 136 else 232
|
||||
return {
|
||||
stick = rect(0, h / 3, w * 0.4, h * 2 / 3),
|
||||
jump = rect(w - jx, h - jy, jx, jy),
|
||||
}
|
||||
end
|
||||
|
||||
function Layout.scaleFor(w: number, h: number, touch: boolean): number
|
||||
if touch then
|
||||
-- 휴대폰은 화면이 작아서 기준 화면을 900x400으로 줄여 글자·버튼을 크게 보여 줍니다.
|
||||
return math.clamp(math.min(w / 900, h / 400), 0.5, 1.4)
|
||||
end
|
||||
return math.clamp(math.min(w / 1100, h / 620), 0.5, 1.4)
|
||||
end
|
||||
|
||||
function Layout.compute(w: number, h: number, touch: boolean, dev: boolean): Result
|
||||
local s = Layout.scaleFor(w, h, touch)
|
||||
local W, H = w / s, h / s
|
||||
local cx = W / 2
|
||||
|
||||
local money, settings, list, decorate, double, boost, promote, rush
|
||||
local topEnd: number -- 위쪽 늘 보이는 것들의 아래 끝
|
||||
if touch then
|
||||
list = rect(8, 6, 84, 84)
|
||||
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 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 - 205
|
||||
list = rect(12, top, 96, 96)
|
||||
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)
|
||||
topEnd = money.y + money.h
|
||||
end
|
||||
|
||||
-- 튜토리얼 말풍선(아래 가운데): 터치 화면에서는 점프 버튼 왼쪽까지 밀어 둡니다.
|
||||
local hintW = math.min(HINT_W, W - 20)
|
||||
local hintX = cx - hintW / 2
|
||||
if touch then
|
||||
local zones = Layout.touchZones(w, h)
|
||||
hintX = math.min(hintX, zones.jump.x / s - 8 - hintW)
|
||||
else
|
||||
hintW = math.min(hintW, W - 2 * 130)
|
||||
hintX = cx - hintW / 2
|
||||
end
|
||||
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 = 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))
|
||||
|
||||
-- 상점 창: 왼쪽에 큰 탭 버튼 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 - 2 * gap) / 3
|
||||
local tabs: { Rect } = {}
|
||||
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)
|
||||
local ch = math.min(250, H - 12)
|
||||
local confirm = rect(cx - cw / 2, math.max(6, H * 0.5 - ch / 2), cw, ch)
|
||||
|
||||
-- 설정 창 줄: 제목 띠(0~58), 언어 이름(70), 언어 버튼(106~), 마우스(PC만), 효과음, 개발자(주인만)
|
||||
local langButtonH = if touch then 52 else 44
|
||||
local toggleH = if touch then 50 else 42
|
||||
local y = 106 + langButtonH + 18
|
||||
local mouseY: number? = nil
|
||||
if not touch then
|
||||
mouseY = y
|
||||
y += toggleH + 40
|
||||
end
|
||||
local sfxY = y
|
||||
y += toggleH + 16
|
||||
local devY: number? = nil
|
||||
if dev then
|
||||
devY = y
|
||||
y += 36 + toggleH + 16
|
||||
end
|
||||
local setW = 560
|
||||
local setH = math.min(y + 8, H - 12)
|
||||
local settingsPanel = rect(cx - setW / 2, math.max(6, H * 0.5 - setH / 2), setW, setH)
|
||||
|
||||
-- 요리 창: 휴대폰은 거의 화면 가득
|
||||
local kw = if touch then math.min(880, W - 16) else 800
|
||||
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)
|
||||
|
||||
-- 꾸미기 화면: 왼쪽 위 나가기, 위 가운데 안내, 아래 버튼 3개(돌리기·취소·놓기)
|
||||
local bs = if touch then 76 else 84
|
||||
local exit = rect(8, 6, bs, bs)
|
||||
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 = 3 * bs + 2 * toolGap
|
||||
local toolX = cx - toolsW / 2
|
||||
if touch then
|
||||
-- 조이스틱(왼쪽 아래)과 점프 버튼(오른쪽 아래) 사이에 둡니다.
|
||||
local zones = Layout.touchZones(w, h)
|
||||
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, 3 do
|
||||
tools[i] = rect(toolX + (i - 1) * (bs + toolGap), H - 8 - bs, bs, bs)
|
||||
end
|
||||
-- 물건 줄 + [이동] [삭제]: 휴대폰은 점프 버튼 왼쪽까지, PC는 가운데
|
||||
local itemsW = 8 * bs + 7 * toolGap
|
||||
local right = W - 8
|
||||
if touch then
|
||||
right = Layout.touchZones(w, h).jump.x / s - 8
|
||||
end
|
||||
local sideW = 2 * bs + toolGap
|
||||
local stripW = math.min(itemsW, right - 8 - sideW - toolGap)
|
||||
local stripX = if touch then 8 else math.max(8, cx - (stripW + toolGap + sideW) / 2)
|
||||
local strip = rect(stripX, H - 8 - bs, stripW, bs)
|
||||
local moveBtn = rect(stripX + stripW + toolGap, H - 8 - bs, bs, bs)
|
||||
local deleteBtn = rect(moveBtn.x + bs + toolGap, H - 8 - bs, bs, bs)
|
||||
|
||||
return {
|
||||
scale = s,
|
||||
width = W,
|
||||
height = H,
|
||||
touch = touch,
|
||||
money = money,
|
||||
carry = carry,
|
||||
hint = hint,
|
||||
toasts = toasts,
|
||||
settings = settings,
|
||||
list = list,
|
||||
decorate = decorate,
|
||||
double = double,
|
||||
boost = boost,
|
||||
promote = promote,
|
||||
rush = rush,
|
||||
panel = panel,
|
||||
tabs = tabs,
|
||||
content = content,
|
||||
decorContent = decorContent,
|
||||
settingsPanel = settingsPanel,
|
||||
kitchen = kitchen,
|
||||
confirm = confirm,
|
||||
deco = { exit = exit, info = info, tools = tools, strip = strip, move = moveBtn, delete = deleteBtn },
|
||||
rows = {
|
||||
langButtonH = langButtonH,
|
||||
mouseY = mouseY,
|
||||
sfxY = sfxY,
|
||||
toggleH = toggleH,
|
||||
devY = devY,
|
||||
devButtonH = toggleH,
|
||||
closeH = if touch then 50 else 48, -- 창 제목 띠(58) 안에 들어가는 크기
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
return Layout
|
||||
164
bunsik-tycoon/src/client/Main.client.luau
Normal file
@@ -0,0 +1,164 @@
|
||||
-- 클라이언트 진입점: 화면 UI, 내 조리대 버튼, 튜토리얼 화살표, 부지 글자·손님 방문·쫓아내기 버튼, 꾸미기 화면,
|
||||
-- 마우스 회전, 효과음 설정.
|
||||
local Players = game:GetService("Players")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local SoundService = game:GetService("SoundService")
|
||||
|
||||
local Decorate = require(script.Parent.Decorate)
|
||||
local Guide = require(script.Parent.Guide)
|
||||
local Hud = require(script.Parent.Hud)
|
||||
local MouseLook = require(script.Parent.MouseLook)
|
||||
local Plots = require(script.Parent.Plots)
|
||||
local Stove = require(script.Parent.Stove)
|
||||
|
||||
local player = Players.LocalPlayer
|
||||
local remotes = ReplicatedStorage:WaitForChild("Remotes")
|
||||
local action = remotes:WaitForChild("Action") :: RemoteEvent
|
||||
local notifyRemote = remotes:WaitForChild("Notify") :: RemoteEvent
|
||||
|
||||
local function send(kind: string, arg: any?)
|
||||
action:FireServer(kind, arg)
|
||||
end
|
||||
|
||||
-- 서버가 세이브를 불러오고 부지를 줄 때까지 기다립니다.
|
||||
while not player:GetAttribute("Ready") do
|
||||
player:GetAttributeChangedSignal("Ready"):Wait()
|
||||
end
|
||||
|
||||
local hud = Hud.build(player:WaitForChild("PlayerGui"), player, send)
|
||||
local decorate: Decorate.Handle? = nil
|
||||
local UserInputService = game:GetService("UserInputService")
|
||||
local GuiService = game:GetService("GuiService")
|
||||
local camera = workspace.CurrentCamera
|
||||
-- 휴대폰·태블릿 배치: 마지막 입력이 터치면 켜고, 마우스·게임패드면 끕니다(키보드 입력은 채팅일 수 있어 무시).
|
||||
local touch = UserInputService.TouchEnabled and not UserInputService.MouseEnabled
|
||||
local function relayout()
|
||||
-- ScreenGui 크기는 상단 바·노치를 뺀 영역입니다. 첫 프레임 전이라 0이면 화면 크기에서 상단 바만 뺍니다.
|
||||
local size = hud.gui.AbsoluteSize
|
||||
if size.X < 2 or size.Y < 2 then
|
||||
size = camera.ViewportSize - Vector2.new(0, GuiService:GetGuiInset().Y)
|
||||
end
|
||||
hud.setLayout(size, touch)
|
||||
if decorate then
|
||||
decorate.setLayout(hud.layout())
|
||||
end
|
||||
end
|
||||
UserInputService.LastInputTypeChanged:Connect(function(t)
|
||||
local isTouch: boolean? = nil
|
||||
if t == Enum.UserInputType.Touch then
|
||||
isTouch = true
|
||||
elseif t.Name:sub(1, 5) == "Mouse" or t.Name:sub(1, 7) == "Gamepad" then
|
||||
isTouch = false
|
||||
end
|
||||
if isTouch ~= nil and isTouch ~= touch then
|
||||
touch = isTouch
|
||||
relayout()
|
||||
end
|
||||
end)
|
||||
hud.gui:GetPropertyChangedSignal("AbsoluteSize"):Connect(relayout)
|
||||
camera:GetPropertyChangedSignal("ViewportSize"):Connect(relayout)
|
||||
relayout()
|
||||
-- 구매·확장 효과음은 내 화면에서만 크게(위치 없이) 들립니다.
|
||||
local Sounds = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("Sounds"))
|
||||
local sfxGroup = SoundService:WaitForChild("Sfx") :: SoundGroup
|
||||
local function applySfx()
|
||||
sfxGroup.Volume = if player:GetAttribute("Sfx") == false then 0 else 1
|
||||
end
|
||||
player:GetAttributeChangedSignal("Sfx"):Connect(applySfx)
|
||||
applySfx()
|
||||
local function uiSound(id: string, volume: number): Sound
|
||||
local s = Instance.new("Sound")
|
||||
s.SoundId = id
|
||||
s.Volume = volume
|
||||
s.SoundGroup = sfxGroup
|
||||
s.Parent = SoundService
|
||||
return s
|
||||
end
|
||||
local buySound = uiSound(Sounds.BUY, 0.7)
|
||||
local levelSound = uiSound(Sounds.LEVELUP, 0.8)
|
||||
local NOTIFY_SOUND: { [string]: Sound } = {
|
||||
purchased = buySound,
|
||||
newMenu = buySound,
|
||||
boostGot = buySound,
|
||||
guestBonus = buySound,
|
||||
expanded = levelSound,
|
||||
floor2 = levelSound,
|
||||
upgraded = buySound,
|
||||
seatAdded = buySound,
|
||||
tableAdded = buySound,
|
||||
decorAdded = buySound,
|
||||
hired = buySound,
|
||||
designSet = buySound,
|
||||
promoted = buySound,
|
||||
kicked = buySound,
|
||||
rushOn = levelSound,
|
||||
}
|
||||
|
||||
notifyRemote.OnClientEvent:Connect(function(key, args)
|
||||
if typeof(key) == "string" then
|
||||
local a = if typeof(args) == "table" then args else nil
|
||||
hud.notify(key, a)
|
||||
if decorate then
|
||||
decorate.notify(key, a)
|
||||
end
|
||||
local s = NOTIFY_SOUND[key]
|
||||
if s then
|
||||
s:Play()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local plotIndex = player:GetAttribute("Plot")
|
||||
local world = workspace:WaitForChild("BunsikWorld")
|
||||
local plot = world:WaitForChild("Plots"):WaitForChild("Plot" .. tostring(plotIndex))
|
||||
local stove = plot:WaitForChild("Base"):WaitForChild("Stall"):WaitForChild("Stove") :: BasePart
|
||||
Stove.attach(stove, player, function()
|
||||
hud.open("kitchen")
|
||||
end)
|
||||
-- 요리 창이 열려 있는 동안은 캐릭터가 움직이지 않게(휴대폰에서 문지르다 조이스틱이 움직이지 않게) 조작을 멈추고,
|
||||
-- 조리대 버튼(E)도 꺼서 E 키를 요리 동작(톡톡·꾹)에 씁니다.
|
||||
local ProximityPromptService = game:GetService("ProximityPromptService")
|
||||
local controls: any = nil
|
||||
pcall(function()
|
||||
local PlayerModule = require(player:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule")) :: any
|
||||
controls = PlayerModule:GetControls()
|
||||
end)
|
||||
hud.kitchen.onOpen(function()
|
||||
ProximityPromptService.Enabled = false
|
||||
if controls then
|
||||
controls:Disable()
|
||||
end
|
||||
end)
|
||||
hud.kitchen.onClose(function()
|
||||
ProximityPromptService.Enabled = true
|
||||
if controls then
|
||||
controls:Enable()
|
||||
end
|
||||
end)
|
||||
Plots.start(world:WaitForChild("Plots"), player, player.UserId, send)
|
||||
|
||||
-- 꾸미기 모드: 화면의 [가게 꾸미기] 버튼으로 들어갑니다.
|
||||
-- 캐릭터는 걸어 다니며 투명 미리보기를 옮기고, 그동안 다른 화면 UI와 조리대 버튼(E)은 숨깁니다.
|
||||
local deco = Decorate.build(player:WaitForChild("PlayerGui"), player, plot, send)
|
||||
decorate = deco
|
||||
deco.setLayout(hud.layout())
|
||||
hud.onDecorate(function()
|
||||
deco.open()
|
||||
end)
|
||||
deco.onOpen(function()
|
||||
hud.gui.Enabled = false
|
||||
ProximityPromptService.Enabled = false
|
||||
end)
|
||||
deco.onClose(function()
|
||||
hud.gui.Enabled = true
|
||||
ProximityPromptService.Enabled = true
|
||||
end)
|
||||
|
||||
Guide.start(player)
|
||||
MouseLook.start(player, function()
|
||||
return hud.menuOpen() or deco.isOpen()
|
||||
end)
|
||||
if player:GetAttribute("MouseLook") == true and UserInputService.MouseEnabled and UserInputService.KeyboardEnabled then
|
||||
hud.notify("mouseHint")
|
||||
end
|
||||
37
bunsik-tycoon/src/client/MouseLook.luau
Normal file
@@ -0,0 +1,37 @@
|
||||
--!strict
|
||||
-- PC에서 우클릭 없이 마우스만 움직여도 화면이 돌아가게 합니다(마우스를 화면 가운데에 고정).
|
||||
-- 설정에서 끌 수 있고, Ctrl을 누르고 있거나 업그레이드·설정 창이 열려 있으면 커서를 풀어 버튼을 누를 수 있습니다.
|
||||
|
||||
local RunService = game:GetService("RunService")
|
||||
local UserInputService = game:GetService("UserInputService")
|
||||
|
||||
local MouseLook = {}
|
||||
|
||||
-- 지금 마우스를 가운데에 고정할지
|
||||
function MouseLook.shouldLock(setting: boolean, mouse: boolean, ctrl: boolean, menuOpen: boolean): boolean
|
||||
return setting and mouse and not ctrl and not menuOpen
|
||||
end
|
||||
|
||||
function MouseLook.start(state: Instance, menuOpen: () -> boolean)
|
||||
local locked = false
|
||||
RunService:BindToRenderStep("BunsikMouseLook", Enum.RenderPriority.Camera.Value + 1, function()
|
||||
local ctrl = UserInputService:IsKeyDown(Enum.KeyCode.LeftControl)
|
||||
or UserInputService:IsKeyDown(Enum.KeyCode.RightControl)
|
||||
local want = MouseLook.shouldLock(
|
||||
state:GetAttribute("MouseLook") == true,
|
||||
UserInputService.MouseEnabled and UserInputService.KeyboardEnabled,
|
||||
ctrl,
|
||||
menuOpen()
|
||||
)
|
||||
if want then
|
||||
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
|
||||
locked = true
|
||||
elseif locked then
|
||||
-- 우리가 고정했던 것만 풉니다(우클릭 회전 등 기본 동작은 건드리지 않음).
|
||||
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
|
||||
locked = false
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
return MouseLook
|
||||
257
bunsik-tycoon/src/client/Plots.luau
Normal file
@@ -0,0 +1,257 @@
|
||||
--!strict
|
||||
-- 부지 이름판·메뉴판 글자를 보는 사람 언어로 쓰고, 다른 가게 입구에 버튼 두 개를 붙입니다:
|
||||
-- "손님으로 들어가기"(visit), "손님 쫓아내기"(kick, 유료 횟수 또는 결제 창).
|
||||
-- 서버는 부지 모델 속성(OwnerId, OwnerName, Npc, Level, ShopName, Rainbow, Menus, PriceMult, ShieldUntil)만 바꾸고,
|
||||
-- 글자는 각 클라이언트가 만듭니다. 가게 이름은 이름판과 서버가 만든 "ShopNameLabel" 글자(포장마차 천막, 지붕 간판)에 씁니다.
|
||||
-- 무지개 이름(게임패스)이면 그 글자들에 무지개 그러데이션이 돌아갑니다.
|
||||
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local TweenService = game:GetService("TweenService")
|
||||
|
||||
local Shared = ReplicatedStorage:WaitForChild("Shared")
|
||||
local Economy = require(Shared:WaitForChild("Economy"))
|
||||
local Locale = require(Shared:WaitForChild("Locale"))
|
||||
local Products = require(Shared:WaitForChild("Products"))
|
||||
|
||||
local Plots = {}
|
||||
|
||||
local function labels(part: Instance): { TextLabel }
|
||||
local out = {}
|
||||
for _, gui in part:GetChildren() do
|
||||
if gui:IsA("SurfaceGui") then
|
||||
local t = gui:FindFirstChildOfClass("TextLabel")
|
||||
if t then
|
||||
table.insert(out, t)
|
||||
end
|
||||
end
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
-- 가게 이름만(레벨 없이): 정한 이름, 아니면 기본 이름
|
||||
function Plots.shopName(plot: Instance, lang: string): string
|
||||
local custom = plot:GetAttribute("ShopName")
|
||||
if typeof(custom) == "string" and custom ~= "" then
|
||||
return custom
|
||||
end
|
||||
local ownerName = plot:GetAttribute("OwnerName")
|
||||
if typeof(ownerName) == "string" then
|
||||
return Locale.t(lang, "plotOwner", { name = ownerName })
|
||||
end
|
||||
local npc = plot:GetAttribute("Npc")
|
||||
if typeof(npc) == "number" then
|
||||
return Locale.t(lang, `npcShop{npc}`)
|
||||
end
|
||||
return Locale.t(lang, "plotEmpty")
|
||||
end
|
||||
|
||||
-- 이름판 글자: 가게 이름 + 레벨
|
||||
function Plots.nameText(plot: Instance, lang: string): string
|
||||
local open = plot:GetAttribute("OwnerName") ~= nil or plot:GetAttribute("Npc") ~= nil
|
||||
if not open then
|
||||
return Locale.t(lang, "plotEmpty")
|
||||
end
|
||||
local level = plot:GetAttribute("Level")
|
||||
local tail = if typeof(level) == "number" and level > 0 then ` ⭐Lv.{level}` else ""
|
||||
return Plots.shopName(plot, lang) .. tail
|
||||
end
|
||||
|
||||
-- 메뉴판 글자: 파는 메뉴(Menus)와 값(메뉴 값 x PriceMult)
|
||||
function Plots.menuText(plot: Instance, lang: string): string
|
||||
local menus = plot:GetAttribute("Menus")
|
||||
if typeof(menus) ~= "string" or menus == "" then
|
||||
return ""
|
||||
end
|
||||
local mult = plot:GetAttribute("PriceMult")
|
||||
local k = if typeof(mult) == "number" then mult else 1
|
||||
local list = string.split(menus, ",")
|
||||
local lines = {}
|
||||
for _, key in Economy.MENU_ORDER do
|
||||
if table.find(list, key) then
|
||||
local m = Economy.MENUS[key]
|
||||
local price = Locale.t(lang, "money", { money = Locale.number(math.floor(m.price * k)) })
|
||||
table.insert(lines, `{m.icon} {Locale.menuName(lang, key)} {price}`)
|
||||
end
|
||||
end
|
||||
return table.concat(lines, "\n")
|
||||
end
|
||||
|
||||
local RAINBOW = ColorSequence.new({
|
||||
ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 60, 80)),
|
||||
ColorSequenceKeypoint.new(0.2, Color3.fromRGB(255, 160, 40)),
|
||||
ColorSequenceKeypoint.new(0.4, Color3.fromRGB(255, 230, 60)),
|
||||
ColorSequenceKeypoint.new(0.6, Color3.fromRGB(60, 210, 100)),
|
||||
ColorSequenceKeypoint.new(0.8, Color3.fromRGB(60, 140, 255)),
|
||||
ColorSequenceKeypoint.new(1, Color3.fromRGB(190, 80, 255)),
|
||||
})
|
||||
|
||||
-- 가게 이름 글자 꾸미기: 무지개(게임패스)가 켜져 있으면 무지개, 아니면 고른 색(NameColor, 0이면 디자인 기본색).
|
||||
-- 무지개는 글자색을 흰색으로 바꿔야 그러데이션 색이 그대로 보입니다.
|
||||
local original: { [TextLabel]: Color3 } = setmetatable({}, { __mode = "k" }) :: any
|
||||
local spinning: { [UIGradient]: Tween } = setmetatable({}, { __mode = "k" }) :: any
|
||||
local function setRainbow(t: TextLabel, on: boolean)
|
||||
local g = t:FindFirstChild("RainbowGradient") :: UIGradient?
|
||||
if on then
|
||||
if not g then
|
||||
local ng = Instance.new("UIGradient")
|
||||
ng.Name = "RainbowGradient"
|
||||
ng.Color = RAINBOW
|
||||
ng.Parent = t
|
||||
local tw = TweenService:Create(
|
||||
ng,
|
||||
TweenInfo.new(4, Enum.EasingStyle.Linear, Enum.EasingDirection.In, -1),
|
||||
{ Rotation = 360 }
|
||||
)
|
||||
tw:Play()
|
||||
spinning[ng] = tw
|
||||
t.TextColor3 = Color3.new(1, 1, 1)
|
||||
end
|
||||
elseif g then
|
||||
local tw = spinning[g]
|
||||
if tw then
|
||||
tw:Cancel()
|
||||
end
|
||||
g:Destroy()
|
||||
end
|
||||
end
|
||||
|
||||
local function styleName(t: TextLabel, rainbow: boolean, colorIndex: any)
|
||||
if not original[t] then
|
||||
original[t] = t.TextColor3
|
||||
end
|
||||
setRainbow(t, rainbow)
|
||||
if not rainbow then
|
||||
local c = if typeof(colorIndex) == "number" then Economy.NAME_COLORS[colorIndex] else nil
|
||||
t.TextColor3 = if c then Color3.fromRGB(c[1], c[2], c[3]) else original[t]
|
||||
end
|
||||
end
|
||||
|
||||
-- 부지 하나에 연결합니다. state는 Lang·KickCredits 속성을 가진 인스턴스(실제로는 Player).
|
||||
function Plots.attach(plot: Model, state: Instance, myId: number, send: (string, any?) -> ()): () -> ()
|
||||
local base = plot:WaitForChild("Base")
|
||||
local nameBoard = base:WaitForChild("NameBoard")
|
||||
local menuBoard = base:WaitForChild("Stall"):WaitForChild("MenuBoard")
|
||||
local visitPoint = base:WaitForChild("VisitPoint") :: BasePart
|
||||
local index = tonumber(string.match(plot.Name, "%d+"))
|
||||
|
||||
local function prompt(name: string, key: Enum.KeyCode, offset: number): ProximityPrompt
|
||||
local p = Instance.new("ProximityPrompt")
|
||||
p.Name = name
|
||||
p.KeyboardKeyCode = key
|
||||
p.MaxActivationDistance = 12
|
||||
p.RequiresLineOfSight = false
|
||||
p.HoldDuration = 0
|
||||
p.UIOffset = Vector2.new(0, offset)
|
||||
p.Parent = visitPoint
|
||||
return p
|
||||
end
|
||||
local visit = prompt("VisitPrompt", Enum.KeyCode.E, 0)
|
||||
-- 쫓아내기는 실수로 누르지 않게 다른 키(F)와 짧게 꾹 누르기. 버튼 그림은 들어가기 버튼 아래에
|
||||
local kick = prompt("KickPrompt", Enum.KeyCode.F, 90)
|
||||
kick.HoldDuration = 0.6
|
||||
|
||||
local shopLabels: { TextLabel } = {}
|
||||
local function collect()
|
||||
table.clear(shopLabels)
|
||||
for _, d in plot:GetDescendants() do
|
||||
if d:IsA("TextLabel") and d.Name == "ShopNameLabel" then
|
||||
table.insert(shopLabels, d)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local shieldToken = 0
|
||||
local refresh: () -> ()
|
||||
function refresh()
|
||||
local lang = (state:GetAttribute("Lang") :: string?) or "ko"
|
||||
local rainbow = plot:GetAttribute("Rainbow") == true
|
||||
local nameColor = plot:GetAttribute("NameColor")
|
||||
local nameText = Plots.nameText(plot, lang)
|
||||
for _, t in labels(nameBoard) do
|
||||
t.Text = nameText
|
||||
styleName(t, rainbow, nameColor)
|
||||
end
|
||||
local shopName = Plots.shopName(plot, lang)
|
||||
for _, t in shopLabels do
|
||||
if t.Parent then
|
||||
t.Text = shopName
|
||||
styleName(t, rainbow, nameColor)
|
||||
end
|
||||
end
|
||||
local menuText = Plots.menuText(plot, lang)
|
||||
for _, t in labels(menuBoard) do
|
||||
t.Text = menuText
|
||||
end
|
||||
local ownerId = plot:GetAttribute("OwnerId")
|
||||
local open = ownerId ~= nil or plot:GetAttribute("Npc") ~= nil
|
||||
local other = open and ownerId ~= myId
|
||||
visit.Enabled = other
|
||||
visit.ActionText = Locale.t(lang, "visitAction")
|
||||
visit.ObjectText = if ownerId ~= nil then Locale.t(lang, "visitor") else Locale.t(lang, "neighbor")
|
||||
|
||||
-- 쫓아내기: 산 횟수가 있거나 상품이 열려 있을 때만. 보호 중(ShieldUntil)이면 끕니다.
|
||||
local credits = state:GetAttribute("KickCredits")
|
||||
local n = if typeof(credits) == "number" then credits else 0
|
||||
local shield = plot:GetAttribute("ShieldUntil")
|
||||
local left = if typeof(shield) == "number" then shield - workspace:GetServerTimeNow() else 0
|
||||
kick.Enabled = other and (n > 0 or Products.KICK_PRODUCT ~= 0) and left <= 0
|
||||
kick.ActionText = if n > 0 then `{Locale.t(lang, "kickAction")} x{n}` else `💎 {Locale.t(lang, "kickAction")}`
|
||||
kick.ObjectText = visit.ObjectText
|
||||
-- 보호가 끝나면 다시 켜지게
|
||||
if left > 0 then
|
||||
shieldToken += 1
|
||||
local token = shieldToken
|
||||
task.delay(left + 0.1, function()
|
||||
if token == shieldToken and plot.Parent then
|
||||
refresh()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
collect()
|
||||
local conns = {
|
||||
plot.AttributeChanged:Connect(refresh),
|
||||
state:GetAttributeChangedSignal("Lang"):Connect(refresh),
|
||||
state:GetAttributeChangedSignal("KickCredits"):Connect(refresh),
|
||||
-- 건물을 다시 지으면 간판 글자가 새로 생깁니다.
|
||||
plot.DescendantAdded:Connect(function(d)
|
||||
if d:IsA("TextLabel") then
|
||||
task.defer(function()
|
||||
if d.Name == "ShopNameLabel" and d.Parent and not table.find(shopLabels, d) then
|
||||
collect()
|
||||
refresh()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end),
|
||||
visit.Triggered:Connect(function()
|
||||
send("visit", index)
|
||||
end),
|
||||
kick.Triggered:Connect(function()
|
||||
send("kick", index)
|
||||
end),
|
||||
}
|
||||
refresh()
|
||||
return function()
|
||||
for _, c in conns do
|
||||
c:Disconnect()
|
||||
end
|
||||
visit:Destroy()
|
||||
kick:Destroy()
|
||||
end
|
||||
end
|
||||
|
||||
function Plots.start(folder: Instance, state: Instance, myId: number, send: (string, any?) -> ())
|
||||
local function add(plot: Instance)
|
||||
if plot:IsA("Model") then
|
||||
task.spawn(Plots.attach, plot, state, myId, send)
|
||||
end
|
||||
end
|
||||
folder.ChildAdded:Connect(add)
|
||||
for _, plot in folder:GetChildren() do
|
||||
add(plot)
|
||||
end
|
||||
end
|
||||
|
||||
return Plots
|
||||
741
bunsik-tycoon/src/client/ShopWindow.luau
Normal file
@@ -0,0 +1,741 @@
|
||||
--!strict
|
||||
-- 상점 창: 왼쪽 큰 탭 버튼 3개와 탭 내용.
|
||||
-- 업그레이드: 갈래(건물·메뉴·판매 금액·손님 속도·화구·쟁반·알바생 기능)마다 카드 한 장. 다음 단계 효과와 값, [사기]
|
||||
-- 알바생: 역할(요리·서빙·홍보)별 고용·빼기, 시급
|
||||
-- 내 가게: 가게 이름, 이름 색(무료 10색 + 무지개 게임패스), 건물 디자인
|
||||
-- 가게 꾸미기는 상점과 따로(화면의 [가게 꾸미기] 버튼 → Decorate 꾸미기 모드).
|
||||
-- 카드는 처음에 다 만들어 두고 속성이 바뀌면 글자·색만 바꿉니다. 칸 위치는 탭 내용 자리 비율이라 배치가 바뀌어도 그대로입니다.
|
||||
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Shared = ReplicatedStorage:WaitForChild("Shared")
|
||||
local Economy = require(Shared:WaitForChild("Economy"))
|
||||
local Locale = require(Shared:WaitForChild("Locale"))
|
||||
local Info = require(script.Parent:WaitForChild("Info"))
|
||||
local Layout = require(script.Parent:WaitForChild("Layout"))
|
||||
local Theme = require(script.Parent:WaitForChild("Theme"))
|
||||
|
||||
local ShopWindow = {}
|
||||
|
||||
export type Handle = {
|
||||
frame: Frame,
|
||||
closeButton: TextButton,
|
||||
open: (tab: string?) -> (),
|
||||
close: () -> (),
|
||||
isOpen: () -> boolean,
|
||||
tab: () -> string,
|
||||
setLayout: (lay: Layout.Result) -> (),
|
||||
refresh: () -> (),
|
||||
destroy: () -> (),
|
||||
}
|
||||
|
||||
ShopWindow.TABS = { "upgrade", "staff", "mine" }
|
||||
local TAB_INFO: { [string]: { key: string, icon: string, color: Color3 } } = {
|
||||
upgrade = { key = "tabUpgrade", icon = "upgrade", color = Theme.PINK },
|
||||
staff = { key = "tabStaff", icon = "chef", color = Theme.ORANGE },
|
||||
mine = { key = "tabMine", icon = "store", color = Theme.SKY },
|
||||
}
|
||||
|
||||
local GAP = 8 -- 카드 사이 간격(tests/Layout.spec.luau와 같음)
|
||||
|
||||
-- 칸 배치(비율): cols x rows 칸 중 (col, row)부터 spanC x spanR 칸
|
||||
local function cell(o: GuiObject, col: number, row: number, cols: number, rows: number, spanC: number?, spanR: number?)
|
||||
o.Position = UDim2.new((col - 1) / cols, GAP / 2, (row - 1) / rows, GAP / 2)
|
||||
o.Size = UDim2.new((spanC or 1) / cols, -GAP, (spanR or 1) / rows, -GAP)
|
||||
end
|
||||
|
||||
-- 작은 알약 글자(오른쪽 위 "Lv 1/4", 로벅스 가격 등)
|
||||
local function pill(parent: Instance, name: string, color: Color3): (Frame, TextLabel)
|
||||
local f = Theme.frame(parent, name, color)
|
||||
f.AnchorPoint = Vector2.new(1, 0)
|
||||
f.Position = UDim2.new(1, -6, 0, 6)
|
||||
f.Size = UDim2.fromScale(0.46, 0.15)
|
||||
f.ZIndex = 6
|
||||
Theme.round(f)
|
||||
Theme.stroke(f, Theme.edge(color), 2)
|
||||
local t = Theme.text(f, "Text", Theme.edge(color), true)
|
||||
t.Position = UDim2.new(0, 6, 0.12, 0)
|
||||
t.Size = UDim2.new(1, -12, 0.76, 0)
|
||||
t.ZIndex = 7
|
||||
return f, t
|
||||
end
|
||||
|
||||
type Card = {
|
||||
holder: Frame,
|
||||
body: Frame,
|
||||
stroke: UIStroke,
|
||||
glyph: Info.Glyph,
|
||||
title: TextLabel,
|
||||
tag: Frame,
|
||||
tagText: TextLabel,
|
||||
note: TextLabel,
|
||||
buy: Theme.Button,
|
||||
buyLabel: TextLabel,
|
||||
status: TextLabel,
|
||||
lock: ImageLabel,
|
||||
check: ImageLabel,
|
||||
}
|
||||
|
||||
-- 카드 한 장: 그림, 이름, 오른쪽 위 꼬리표, 짧은 설명, 아래 [값] 버튼(또는 상태 글자)
|
||||
local function makeCard(parent: Instance, name: string): Card
|
||||
local holder = Theme.frame(parent, name)
|
||||
holder.ZIndex = 3
|
||||
local body = Theme.frame(holder, "Card", Theme.WHITE)
|
||||
body.Size = UDim2.fromScale(1, 1)
|
||||
body.ZIndex = 3
|
||||
Theme.corner(body, 18)
|
||||
local stroke = Theme.stroke(body, Theme.LINE, 3)
|
||||
local glyph = Info.glyph(body, "Icon", "star")
|
||||
glyph.frame.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
glyph.frame.Position = UDim2.fromScale(0.5, 0.25)
|
||||
glyph.frame.Size = UDim2.fromScale(0.6, 0.34)
|
||||
glyph.zindex(4)
|
||||
local tag, tagText = pill(body, "Tag", Theme.LAVENDER)
|
||||
local title = Theme.text(body, "Name")
|
||||
title.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
title.Position = UDim2.fromScale(0.5, 0.5)
|
||||
title.Size = UDim2.new(1, -12, 0.14, 0)
|
||||
title.ZIndex = 4
|
||||
local note = Theme.text(body, "Note")
|
||||
note.TextColor3 = Theme.SOFT
|
||||
note.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
note.Position = UDim2.fromScale(0.5, 0.635)
|
||||
note.Size = UDim2.new(1, -12, 0.12, 0)
|
||||
note.ZIndex = 4
|
||||
local buy, buyLabel = Theme.textButton(holder, "Buy", Theme.MINT, 14)
|
||||
buy.button.AnchorPoint = Vector2.new(0.5, 1)
|
||||
buy.button.Position = UDim2.new(0.5, 0, 1, -6)
|
||||
buy.button.Size = UDim2.new(1, -14, 0.24, 0)
|
||||
buy.button.ZIndex = 5
|
||||
buyLabel.FontFace = Theme.NUM
|
||||
buyLabel.Position = UDim2.new(0.5, 12, 0.5, 0)
|
||||
buyLabel.Size = UDim2.new(1, -44, 0.62, 0)
|
||||
local coin = Theme.icon(buy.face, "Coin", "coin")
|
||||
coin.AnchorPoint = Vector2.new(0, 0.5)
|
||||
coin.Position = UDim2.new(0, 4, 0.5, 0)
|
||||
coin.Size = UDim2.fromScale(0.26, 1.1)
|
||||
coin.SizeConstraint = Enum.SizeConstraint.RelativeYY
|
||||
coin.ZIndex = 5
|
||||
local status = Theme.text(holder, "Status")
|
||||
status.TextColor3 = Theme.SOFT
|
||||
status.AnchorPoint = Vector2.new(0.5, 1)
|
||||
status.Position = UDim2.new(0.5, 0, 1, -10)
|
||||
status.Size = UDim2.new(1, -16, 0.17, 0)
|
||||
status.ZIndex = 5
|
||||
local lock = Theme.icon(body, "Lock", "lock")
|
||||
lock.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
lock.Position = UDim2.fromScale(0.5, 0.25)
|
||||
lock.Size = UDim2.fromScale(0.3, 0.3)
|
||||
lock.SizeConstraint = Enum.SizeConstraint.RelativeYY
|
||||
lock.ZIndex = 6
|
||||
local check = Theme.icon(body, "Done", "check")
|
||||
check.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
check.Position = UDim2.fromOffset(18, 18)
|
||||
check.Size = UDim2.fromOffset(36, 36)
|
||||
check.ZIndex = 6
|
||||
return {
|
||||
holder = holder,
|
||||
body = body,
|
||||
stroke = stroke,
|
||||
glyph = glyph,
|
||||
title = title,
|
||||
tag = tag,
|
||||
tagText = tagText,
|
||||
note = note,
|
||||
buy = buy,
|
||||
buyLabel = buyLabel,
|
||||
status = status,
|
||||
lock = lock,
|
||||
check = check,
|
||||
}
|
||||
end
|
||||
|
||||
-- 카드 상태: "buy"(값 버튼), "locked"(자물쇠 + 글자), "done"(체크 + 글자), "off"(글자만, 예: 꽉 참)
|
||||
local function setCard(c: Card, mode: string, cost: number?, can: boolean?, statusText: string?)
|
||||
local buyMode = mode == "buy"
|
||||
c.buy.button.Visible = buyMode
|
||||
c.status.Visible = not buyMode
|
||||
c.lock.Visible = mode == "locked"
|
||||
c.check.Visible = mode == "done"
|
||||
c.glyph.fade(if mode == "locked" then 0.55 else 0)
|
||||
if buyMode then
|
||||
c.buyLabel.Text = Locale.number(cost or 0)
|
||||
c.buy.setColor(if can then Theme.MINT else Theme.GRAY)
|
||||
else
|
||||
c.status.Text = statusText or ""
|
||||
c.status.TextColor3 = if mode == "done" then Theme.edge(Theme.MINT) else Theme.SOFT
|
||||
end
|
||||
local tint = if mode == "done" then Theme.MINT elseif buyMode and can then Theme.YELLOW else nil
|
||||
c.stroke.Color = if tint then Theme.edge(tint) else Theme.LINE
|
||||
c.stroke.Thickness = if tint then 4 else 3
|
||||
if tint then
|
||||
Theme.gradient(c.body, Theme.WHITE, Theme.lighten(tint, 0.7))
|
||||
else
|
||||
Theme.gradient(c.body, Theme.WHITE, Color3.fromRGB(250, 246, 250))
|
||||
end
|
||||
end
|
||||
|
||||
function ShopWindow.build(root: Frame, state: Instance, send: (string, any?) -> ()): Handle
|
||||
local function lang(): string
|
||||
return Info.attr(state, "Lang", "ko")
|
||||
end
|
||||
local function L(key: string, args: { [string]: any }?): string
|
||||
return Locale.t(lang(), key, args)
|
||||
end
|
||||
|
||||
local conns: { RBXScriptConnection } = {}
|
||||
local function on(sig: RBXScriptSignal, fn: (...any) -> ())
|
||||
table.insert(conns, sig:Connect(fn))
|
||||
end
|
||||
|
||||
local shopPanel = Theme.panel(root, "Panel", Theme.PINK)
|
||||
local frame = shopPanel.frame
|
||||
local body = shopPanel.body
|
||||
local current = "upgrade"
|
||||
local refresh: () -> ()
|
||||
|
||||
-- 탭 버튼과 탭 내용 자리
|
||||
local tabButtons: { [string]: Theme.Button } = {}
|
||||
local tabLabels: { [string]: TextLabel } = {}
|
||||
local tabBadges: { [string]: Frame } = {}
|
||||
local pages: { [string]: Frame } = {}
|
||||
for _, id in ShopWindow.TABS do
|
||||
local ti = TAB_INFO[id]
|
||||
local b, label = Theme.iconButton(body, "Tab_" .. id, ti.color, ti.icon)
|
||||
b.button.ZIndex = 4
|
||||
label.Size = UDim2.fromScale(1, 0.28)
|
||||
tabButtons[id] = b
|
||||
tabLabels[id] = label
|
||||
local badge, badgeText = Theme.badge(b.button, "Badge")
|
||||
badgeText.Text = "!"
|
||||
badge.Visible = false
|
||||
tabBadges[id] = badge
|
||||
local page = Theme.frame(body, "Page_" .. id)
|
||||
page.ZIndex = 3
|
||||
page.Visible = false
|
||||
pages[id] = page
|
||||
on(b.button.Activated, function()
|
||||
current = id
|
||||
refresh()
|
||||
end)
|
||||
end
|
||||
|
||||
-- 1) 업그레이드: 건물 카드는 두 칸(위 왼쪽), 나머지 6장
|
||||
local upgradeCards: { [string]: Card } = {}
|
||||
local SPOTS: { [string]: { number } } = {
|
||||
Stage = { 1, 1, 2 },
|
||||
Menu = { 3, 1, 1 },
|
||||
Price = { 4, 1, 1 },
|
||||
Speed = { 1, 2, 1 },
|
||||
Stove = { 2, 2, 1 },
|
||||
Tray = { 3, 2, 1 },
|
||||
Staff = { 4, 2, 1 },
|
||||
}
|
||||
for i, id in Economy.TRACK_ORDER do
|
||||
local c = makeCard(pages.upgrade, "Track_" .. id)
|
||||
local spot = SPOTS[id] or { (i - 1) % 4 + 1, (i - 1) // 4 + 1, 1 }
|
||||
cell(c.holder, spot[1], spot[2], 4, 2, spot[3], 1)
|
||||
if id == "Stage" then
|
||||
-- 건물은 크게: 그림과 글자를 왼쪽·오른쪽으로
|
||||
c.glyph.frame.Position = UDim2.fromScale(0.22, 0.4)
|
||||
c.glyph.frame.Size = UDim2.fromScale(0.36, 0.6)
|
||||
c.lock.Position = UDim2.fromScale(0.22, 0.4)
|
||||
for _, t in { c.title, c.note } do
|
||||
t.AnchorPoint = Vector2.new(0, 0.5)
|
||||
t.Size = UDim2.fromScale(0.56, 0.16)
|
||||
end
|
||||
c.title.Position = UDim2.fromScale(0.42, 0.34)
|
||||
c.note.Position = UDim2.fromScale(0.42, 0.52)
|
||||
c.buy.button.AnchorPoint = Vector2.new(1, 1)
|
||||
c.buy.button.Position = UDim2.new(1, -8, 1, -6)
|
||||
c.buy.button.Size = UDim2.fromScale(0.56, 0.24)
|
||||
c.status.AnchorPoint = Vector2.new(1, 1)
|
||||
c.status.Position = UDim2.new(1, -8, 1, -10)
|
||||
c.status.Size = UDim2.fromScale(0.56, 0.17)
|
||||
c.tag.Size = UDim2.fromScale(0.22, 0.15)
|
||||
end
|
||||
upgradeCards[id] = c
|
||||
on(c.buy.button.Activated, function()
|
||||
send("upgrade", id)
|
||||
end)
|
||||
end
|
||||
|
||||
-- 2) 알바생: 위 띠(시급 합계 또는 파업 안내), 역할 카드 3장 / 아직 안 열렸으면 자물쇠 카드
|
||||
local staffOpen = Theme.frame(pages.staff, "Open")
|
||||
staffOpen.Size = UDim2.fromScale(1, 1)
|
||||
staffOpen.ZIndex = 3
|
||||
local banner = Theme.frame(staffOpen, "Banner", Theme.CREAM)
|
||||
banner.Position = UDim2.fromOffset(GAP / 2, GAP / 2)
|
||||
banner.Size = UDim2.new(1, -GAP, 0.15, 0)
|
||||
banner.ZIndex = 3
|
||||
Theme.round(banner)
|
||||
local bannerStroke = Theme.stroke(banner, Theme.LINE, 3)
|
||||
local bannerText = Theme.text(banner, "Text")
|
||||
bannerText.Position = UDim2.new(0, 14, 0.15, 0)
|
||||
bannerText.Size = UDim2.new(1, -28, 0.7, 0)
|
||||
bannerText.ZIndex = 4
|
||||
local roleRow = Theme.frame(staffOpen, "Roles")
|
||||
roleRow.Position = UDim2.fromScale(0, 0.17)
|
||||
roleRow.Size = UDim2.fromScale(1, 0.83)
|
||||
roleRow.ZIndex = 3
|
||||
type RoleCard = { card: Card, wage: TextLabel, fire: Theme.Button, fireLabel: TextLabel }
|
||||
local roleCards: { [string]: RoleCard } = {}
|
||||
for i, r in Economy.ROLES do
|
||||
local c = makeCard(roleRow, "Role_" .. r.id)
|
||||
cell(c.holder, i, 1, #Economy.ROLES, 1)
|
||||
c.glyph.set(Info.ROLE_ICON[r.id] or "chef")
|
||||
c.glyph.frame.Position = UDim2.fromScale(0.5, 0.2)
|
||||
c.glyph.frame.Size = UDim2.fromScale(0.5, 0.26)
|
||||
c.title.Position = UDim2.fromScale(0.5, 0.42)
|
||||
c.title.Size = UDim2.new(1, -12, 0.1, 0)
|
||||
c.note.Position = UDim2.fromScale(0.5, 0.53)
|
||||
c.note.Size = UDim2.new(1, -12, 0.09, 0)
|
||||
c.tag.Size = UDim2.fromScale(0.3, 0.1)
|
||||
local wage = Theme.text(c.body, "Wage")
|
||||
wage.TextColor3 = Theme.edge(Theme.ORANGE)
|
||||
wage.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
wage.Position = UDim2.fromScale(0.5, 0.64)
|
||||
wage.Size = UDim2.new(1, -12, 0.08, 0)
|
||||
wage.ZIndex = 4
|
||||
c.buy.button.Size = UDim2.new(1, -14, 0.2, 0)
|
||||
c.status.Size = UDim2.new(1, -16, 0.14, 0)
|
||||
local fire, fireLabel = Theme.textButton(c.holder, "Fire", Theme.RED, 14)
|
||||
fire.button.AnchorPoint = Vector2.new(0, 1)
|
||||
fire.button.Position = UDim2.new(0, 7, 1, -6)
|
||||
fire.button.Size = UDim2.new(0.36, -7, 0.2, 0)
|
||||
fire.button.ZIndex = 5
|
||||
roleCards[r.id] = { card = c, wage = wage, fire = fire, fireLabel = fireLabel }
|
||||
local roleId = r.id
|
||||
on(c.buy.button.Activated, function()
|
||||
send("hire", roleId)
|
||||
end)
|
||||
on(fire.button.Activated, function()
|
||||
send("fire", roleId)
|
||||
end)
|
||||
end
|
||||
local staffLocked = Theme.frame(pages.staff, "Locked", Theme.WHITE)
|
||||
staffLocked.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
staffLocked.Position = UDim2.fromScale(0.5, 0.5)
|
||||
staffLocked.Size = UDim2.fromScale(0.7, 0.8)
|
||||
staffLocked.ZIndex = 3
|
||||
Theme.corner(staffLocked, 24)
|
||||
Theme.stroke(staffLocked, Theme.LINE, 3)
|
||||
local lockedChef = Theme.icon(staffLocked, "Chef", "chef")
|
||||
Theme.place(lockedChef, 0.5, 0.26, 0.3, 0.36)
|
||||
lockedChef.ImageTransparency = 0.5
|
||||
lockedChef.ZIndex = 4
|
||||
local lockedLock = Theme.icon(staffLocked, "Lock", "lock")
|
||||
Theme.place(lockedLock, 0.62, 0.32, 0.16, 0.2)
|
||||
lockedLock.ZIndex = 5
|
||||
local lockedText = Theme.text(staffLocked, "Text")
|
||||
Theme.place(lockedText, 0.5, 0.58, 0.86, 0.14)
|
||||
lockedText.ZIndex = 4
|
||||
local goUp, goUpLabel = Theme.textButton(staffLocked, "GoUpgrade", Theme.PINK, 18)
|
||||
goUp.button.AnchorPoint = Vector2.new(0.5, 1)
|
||||
goUp.button.Position = UDim2.new(0.5, 0, 1, -12)
|
||||
goUp.button.Size = UDim2.fromScale(0.6, 0.22)
|
||||
goUp.button.ZIndex = 5
|
||||
on(goUp.button.Activated, function()
|
||||
current = "upgrade"
|
||||
refresh()
|
||||
end)
|
||||
|
||||
-- 3) 내 가게: 이름, 이름 색(10색 + 무지개), 디자인
|
||||
local mine = pages.mine
|
||||
local function row(name: string, y: number, h: number): Frame
|
||||
local f = Theme.frame(mine, name)
|
||||
f.Position = UDim2.new(0, GAP / 2, y, 0)
|
||||
f.Size = UDim2.new(1, -GAP, h, 0)
|
||||
f.ZIndex = 3
|
||||
return f
|
||||
end
|
||||
local nameRow = row("NameRow", 0.01, 0.19)
|
||||
local nameTitle = Theme.text(nameRow, "Title")
|
||||
nameTitle.TextXAlignment = Enum.TextXAlignment.Left
|
||||
nameTitle.Position = UDim2.fromScale(0, 0.2)
|
||||
nameTitle.Size = UDim2.fromScale(0.2, 0.6)
|
||||
nameTitle.ZIndex = 4
|
||||
local boxBack = Theme.frame(nameRow, "BoxBack", Theme.WHITE)
|
||||
boxBack.Position = UDim2.fromScale(0.21, 0.05)
|
||||
boxBack.Size = UDim2.fromScale(0.56, 0.9)
|
||||
boxBack.ZIndex = 4
|
||||
Theme.round(boxBack)
|
||||
Theme.stroke(boxBack, Theme.edge(Theme.SKY), 3)
|
||||
local box = Instance.new("TextBox")
|
||||
box.Name = "NameBox"
|
||||
box.BackgroundTransparency = 1
|
||||
box.ClearTextOnFocus = false
|
||||
box.FontFace = Theme.FONT
|
||||
box.TextScaled = true
|
||||
box.TextColor3 = Theme.TEXT
|
||||
box.PlaceholderColor3 = Theme.SOFT
|
||||
box.Text = ""
|
||||
box.Position = UDim2.new(0, 16, 0.18, 0)
|
||||
box.Size = UDim2.new(1, -32, 0.64, 0)
|
||||
box.ZIndex = 5
|
||||
box.Parent = boxBack
|
||||
local saveBtn, saveLabel = Theme.textButton(nameRow, "Save", Theme.SKY, 18)
|
||||
saveBtn.button.Position = UDim2.fromScale(0.79, 0)
|
||||
saveBtn.button.Size = UDim2.fromScale(0.21, 1)
|
||||
saveBtn.button.ZIndex = 4
|
||||
-- 이름은 최대 Economy.NAME_MAX 글자
|
||||
on(box:GetPropertyChangedSignal("Text"), function()
|
||||
local s = box.Text
|
||||
local n = utf8.len(s)
|
||||
if n and n > Economy.NAME_MAX then
|
||||
local cut = utf8.offset(s, Economy.NAME_MAX + 1)
|
||||
if cut then
|
||||
box.Text = string.sub(s, 1, cut - 1)
|
||||
end
|
||||
end
|
||||
end)
|
||||
on(saveBtn.button.Activated, function()
|
||||
send("rename", box.Text)
|
||||
box:ReleaseFocus()
|
||||
end)
|
||||
on(box.FocusLost, function(enter: boolean)
|
||||
if enter then
|
||||
send("rename", box.Text)
|
||||
end
|
||||
end)
|
||||
|
||||
-- 이름 색: 무료 10색 + 무지개(게임패스). 고른 색을 다시 누르면 디자인 기본색으로
|
||||
local colorRow = row("ColorRow", 0.23, 0.17)
|
||||
local colorTitle = Theme.text(colorRow, "Title")
|
||||
colorTitle.TextXAlignment = Enum.TextXAlignment.Left
|
||||
colorTitle.Position = UDim2.fromScale(0, 0.2)
|
||||
colorTitle.Size = UDim2.fromScale(0.13, 0.6)
|
||||
colorTitle.ZIndex = 4
|
||||
type Swatch = { button: TextButton, stroke: UIStroke, check: ImageLabel }
|
||||
local swatches: { Swatch } = {}
|
||||
local SW = 0.87 / 11
|
||||
local function makeSwatch(name: string, n: number, color: Color3): Swatch
|
||||
local b = Instance.new("TextButton")
|
||||
b.Name = name
|
||||
b.Text = ""
|
||||
b.AutoButtonColor = true
|
||||
b.BorderSizePixel = 0
|
||||
b.BackgroundColor3 = color
|
||||
b.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
b.Position = UDim2.fromScale(0.13 + SW * (n - 0.5), 0.5)
|
||||
b.Size = UDim2.new(SW, -6, 0.9, 0)
|
||||
b.ZIndex = 4
|
||||
b.Parent = colorRow
|
||||
Theme.corner(b, 12)
|
||||
local st = Theme.stroke(b, Theme.LINE, 2)
|
||||
local ok = Theme.icon(b, "Done", "check")
|
||||
ok.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
ok.Position = UDim2.fromScale(0.5, 0.5)
|
||||
ok.Size = UDim2.fromScale(0.7, 0.7)
|
||||
ok.SizeConstraint = Enum.SizeConstraint.RelativeYY
|
||||
ok.ZIndex = 5
|
||||
return { button = b, stroke = st, check = ok }
|
||||
end
|
||||
for n, c in Economy.NAME_COLORS do
|
||||
local sw = makeSwatch("Color" .. n, n, Color3.fromRGB(c[1], c[2], c[3]))
|
||||
swatches[n] = sw
|
||||
on(sw.button.Activated, function()
|
||||
local now = Info.attr(state, "NameColor", 0)
|
||||
local rainbowOn = Info.attr(state, "RainbowOwned", false) == true
|
||||
and Info.attr(state, "Rainbow", true) == true
|
||||
send("nameColor", if now == n and not rainbowOn then 0 else n)
|
||||
end)
|
||||
end
|
||||
local rainbowSw = makeSwatch("Rainbow", 11, Theme.WHITE)
|
||||
local rainbowGrad = Instance.new("UIGradient")
|
||||
rainbowGrad.Color = ColorSequence.new({
|
||||
ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 70, 90)),
|
||||
ColorSequenceKeypoint.new(0.25, Color3.fromRGB(255, 170, 40)),
|
||||
ColorSequenceKeypoint.new(0.5, Color3.fromRGB(60, 200, 90)),
|
||||
ColorSequenceKeypoint.new(0.75, Color3.fromRGB(60, 140, 255)),
|
||||
ColorSequenceKeypoint.new(1, Color3.fromRGB(180, 80, 255)),
|
||||
})
|
||||
rainbowGrad.Parent = rainbowSw.button
|
||||
local rainbowPrice, rainbowPriceText = pill(rainbowSw.button, "Price", Theme.LAVENDER)
|
||||
rainbowPrice.AnchorPoint = Vector2.new(0.5, 1)
|
||||
rainbowPrice.Position = UDim2.new(0.5, 0, 0, 4)
|
||||
rainbowPrice.Size = UDim2.fromScale(1.6, 0.4)
|
||||
on(rainbowSw.button.Activated, function()
|
||||
-- 게임패스가 없으면 결제 창, 있으면 켜기/끄기
|
||||
send("rainbow", Info.attr(state, "Rainbow", true) ~= true or Info.attr(state, "RainbowOwned", false) ~= true)
|
||||
end)
|
||||
|
||||
local designHead = row("DesignHead", 0.43, 0.11)
|
||||
local designTitle = Theme.text(designHead, "Title")
|
||||
designTitle.TextXAlignment = Enum.TextXAlignment.Left
|
||||
designTitle.Size = UDim2.fromScale(0.4, 1)
|
||||
designTitle.ZIndex = 4
|
||||
local designNote = Theme.text(designHead, "Note")
|
||||
designNote.TextXAlignment = Enum.TextXAlignment.Right
|
||||
designNote.TextColor3 = Theme.SOFT
|
||||
designNote.Position = UDim2.fromScale(0.4, 0.1)
|
||||
designNote.Size = UDim2.fromScale(0.6, 0.8)
|
||||
designNote.ZIndex = 4
|
||||
local designRow = Theme.frame(mine, "Designs")
|
||||
designRow.Position = UDim2.fromScale(0, 0.55)
|
||||
designRow.Size = UDim2.fromScale(1, 0.45)
|
||||
designRow.ZIndex = 3
|
||||
type DesignCard = {
|
||||
button: Theme.Button,
|
||||
label: TextLabel,
|
||||
swatch: Frame,
|
||||
check: ImageLabel,
|
||||
lock: ImageLabel,
|
||||
price: Frame,
|
||||
priceText: TextLabel,
|
||||
}
|
||||
local designCards: { [string]: DesignCard } = {}
|
||||
for i, d in Economy.DESIGNS do
|
||||
local b = Theme.button(designRow, "Design_" .. d.id, Theme.GRAY, 18)
|
||||
cell(b.button, i, 1, #Economy.DESIGNS, 1)
|
||||
b.button.ZIndex = 4
|
||||
-- 견본: 지붕 / 벽 / 차양 색 띠
|
||||
local swatch = Theme.frame(b.face, "Swatch", Theme.WHITE)
|
||||
swatch.AnchorPoint = Vector2.new(0.5, 0)
|
||||
swatch.Position = UDim2.fromScale(0.5, 0.1)
|
||||
swatch.Size = UDim2.fromScale(0.74, 0.56)
|
||||
swatch.ZIndex = 4
|
||||
swatch.ClipsDescendants = true
|
||||
Theme.corner(swatch, 12)
|
||||
Theme.stroke(swatch, Theme.LINE, 2)
|
||||
local colors = Info.DESIGN_COLORS[d.id] or Info.DESIGN_COLORS.Basic
|
||||
local bands = { { 0, 0.34 }, { 0.34, 0.4 }, { 0.74, 0.26 } }
|
||||
local bandColors = { colors[2], colors[1], colors[3] }
|
||||
for j, part in bands do
|
||||
local band = Theme.frame(swatch, "Band" .. j, bandColors[j])
|
||||
band.Position = UDim2.fromScale(0, part[1])
|
||||
band.Size = UDim2.fromScale(1, part[2])
|
||||
band.ZIndex = 5
|
||||
end
|
||||
local label = Theme.text(b.face, "Label", Theme.edge(Theme.GRAY))
|
||||
label.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
label.Position = UDim2.fromScale(0.5, 0.82)
|
||||
label.Size = UDim2.fromScale(0.9, 0.2)
|
||||
label.ZIndex = 5
|
||||
local ok = Theme.icon(b.button, "Done", "check")
|
||||
ok.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
ok.Position = UDim2.new(1, -8, 0, 8)
|
||||
ok.Size = UDim2.fromOffset(36, 36)
|
||||
ok.ZIndex = 8
|
||||
local lock = Theme.icon(b.face, "Lock", "lock")
|
||||
Theme.place(lock, 0.5, 0.38, 0.4, 0.4)
|
||||
lock.SizeConstraint = Enum.SizeConstraint.RelativeYY
|
||||
lock.ZIndex = 7
|
||||
local price, priceText = pill(b.button, "Price", Theme.LAVENDER)
|
||||
price.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
price.Position = UDim2.new(0.5, 0, 0, 2)
|
||||
price.Size = UDim2.fromScale(0.7, 0.16)
|
||||
price.ZIndex = 8
|
||||
designCards[d.id] = {
|
||||
button = b,
|
||||
label = label,
|
||||
swatch = swatch,
|
||||
check = ok,
|
||||
lock = lock,
|
||||
price = price,
|
||||
priceText = priceText,
|
||||
}
|
||||
local id = d.id
|
||||
on(b.button.Activated, function()
|
||||
if Info.attr(state, "Stage", 1) >= 2 then
|
||||
send("design", id)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local lastName: string? = nil
|
||||
|
||||
local function refreshUpgrade(levels: Economy.Levels, stats: Economy.Stats, money: number): boolean
|
||||
local any = false
|
||||
for _, id in Economy.TRACK_ORDER do
|
||||
local c = upgradeCards[id]
|
||||
local t = Economy.track(id) :: Economy.Track
|
||||
local lv = Economy.level(levels, id)
|
||||
local nl = Economy.nextLevel(levels, id)
|
||||
c.title.Text = L("track_" .. id)
|
||||
c.tagText.Text = `Lv {lv}/{#t.levels}`
|
||||
c.glyph.set(Info.trackIcon(levels, id))
|
||||
c.note.Text = Info.effect(lang(), levels, id) or (if id == "Stage" then L(`stage_{stats.stage}`) else "")
|
||||
if not nl then
|
||||
setCard(c, "done", nil, nil, L("bought"))
|
||||
elseif nl.stage > stats.stage then
|
||||
setCard(c, "locked", nil, nil, L(`lockStage{nl.stage}`))
|
||||
else
|
||||
local can = money >= nl.cost
|
||||
any = any or can
|
||||
setCard(c, "buy", nl.cost, can)
|
||||
end
|
||||
end
|
||||
return any
|
||||
end
|
||||
|
||||
local function refreshStaff(stats: Economy.Stats, money: number)
|
||||
staffOpen.Visible = stats.staffUnlocked
|
||||
staffLocked.Visible = not stats.staffUnlocked
|
||||
lockedText.Text = L("staffLockedCard")
|
||||
goUpLabel.Text = L("goUpgrade")
|
||||
local strike = Info.attr(state, "Strike", false) == true
|
||||
local color = if strike then Theme.RED else Theme.ORANGE
|
||||
banner.BackgroundColor3 = if strike then Theme.lighten(Theme.RED, 0.75) else Theme.CREAM
|
||||
bannerStroke.Color = Theme.lighten(color, 0.3)
|
||||
bannerText.TextColor3 = if strike then Theme.edge(Theme.RED) else Theme.TEXT
|
||||
bannerText.Text = if strike
|
||||
then L("strikeBanner")
|
||||
else L("wageTotal", { wage = Locale.number(Info.attr(state, "Wage", 0)) })
|
||||
local staff = Info.staff(state)
|
||||
for _, r in Economy.ROLES do
|
||||
local rc = roleCards[r.id]
|
||||
local c = rc.card
|
||||
local n = staff[r.id] or 0
|
||||
c.title.Text = L("role_" .. r.id)
|
||||
c.note.Text = L("roleDesc_" .. r.id)
|
||||
c.tagText.Text = `{n}/{r.max}`
|
||||
rc.wage.Text = L("wage", { wage = Locale.number(Economy.wage(r.id, stats)) })
|
||||
rc.fire.button.Visible = n > 0
|
||||
rc.fireLabel.Text = L("fire")
|
||||
-- 고용 버튼은 빼기 버튼이 있으면 오른쪽 2/3만
|
||||
if n > 0 then
|
||||
c.buy.button.AnchorPoint = Vector2.new(1, 1)
|
||||
c.buy.button.Position = UDim2.new(1, -7, 1, -6)
|
||||
c.buy.button.Size = UDim2.new(0.64, -7, 0.2, 0)
|
||||
else
|
||||
c.buy.button.AnchorPoint = Vector2.new(0.5, 1)
|
||||
c.buy.button.Position = UDim2.new(0.5, 0, 1, -6)
|
||||
c.buy.button.Size = UDim2.new(1, -14, 0.2, 0)
|
||||
end
|
||||
if n >= r.max then
|
||||
setCard(c, "off", nil, nil, L("full"))
|
||||
c.status.Position = UDim2.new(0.68, 0, 1, -12)
|
||||
c.status.Size = UDim2.fromScale(0.6, 0.12)
|
||||
else
|
||||
c.status.Position = UDim2.new(0.5, 0, 1, -10)
|
||||
setCard(c, "buy", r.hire, money >= r.hire)
|
||||
end
|
||||
c.check.Visible = false
|
||||
end
|
||||
end
|
||||
|
||||
local function refreshMine(stats: Economy.Stats)
|
||||
nameTitle.Text = L("shopName")
|
||||
box.PlaceholderText = L("namePlaceholder")
|
||||
saveLabel.Text = L("save")
|
||||
local name = Info.attr(state, "ShopName", "") :: string
|
||||
if name ~= lastName and not box:IsFocused() then
|
||||
box.Text = name
|
||||
lastName = name
|
||||
end
|
||||
colorTitle.Text = L("nameColor")
|
||||
local owned = Info.attr(state, "RainbowOwned", false) == true
|
||||
local onNow = owned and Info.attr(state, "Rainbow", true) == true
|
||||
local chosen = if onNow then 11 else Info.attr(state, "NameColor", 0)
|
||||
for n, sw in swatches do
|
||||
sw.check.Visible = n == chosen
|
||||
sw.stroke.Color = if n == chosen then Theme.edge(Theme.MINT) else Theme.LINE
|
||||
sw.stroke.Thickness = if n == chosen then 4 else 2
|
||||
end
|
||||
rainbowSw.check.Visible = onNow
|
||||
rainbowSw.stroke.Color = if onNow then Theme.edge(Theme.MINT) else Theme.LINE
|
||||
rainbowSw.stroke.Thickness = if onNow then 4 else 2
|
||||
local price = Info.robux("RAINBOW_NAME_PASS")
|
||||
rainbowPrice.Visible = not owned and price ~= nil
|
||||
rainbowPriceText.Text = price or ""
|
||||
designTitle.Text = L("designs")
|
||||
local open = stats.stage >= 2
|
||||
designNote.Text = if open then "" else L("designLocked")
|
||||
local selected = Info.attr(state, "Design", "Basic")
|
||||
local ownedList = string.split(Info.attr(state, "DesignsOwned", "") :: string, ",")
|
||||
for _, d in Economy.DESIGNS do
|
||||
local dc = designCards[d.id]
|
||||
local isSel = d.id == selected
|
||||
local color = if isSel then Theme.MINT else Theme.GRAY
|
||||
dc.button.setColor(if open then color else Color3.fromRGB(150, 145, 165))
|
||||
local st = dc.label:FindFirstChildOfClass("UIStroke")
|
||||
if st then
|
||||
st.Color = Theme.edge(dc.button.color())
|
||||
end
|
||||
dc.label.Text = L("design_" .. d.id)
|
||||
dc.check.Visible = isSel and open
|
||||
dc.lock.Visible = not open
|
||||
for _, band in dc.swatch:GetChildren() do
|
||||
if band:IsA("Frame") then
|
||||
band.BackgroundTransparency = if open then 0 else 0.5
|
||||
end
|
||||
end
|
||||
local p = if d.pass and not table.find(ownedList, d.id) then Info.robux(d.pass) else nil
|
||||
dc.price.Visible = p ~= nil
|
||||
dc.priceText.Text = p or ""
|
||||
end
|
||||
end
|
||||
|
||||
function refresh()
|
||||
local levels = Info.levels(state)
|
||||
local stats = Economy.stats(levels, Info.attr(state, "Seats", 1))
|
||||
local money = Info.attr(state, "Money", 0)
|
||||
shopPanel.title.Text = L(TAB_INFO[current].key)
|
||||
for _, id in ShopWindow.TABS do
|
||||
local ti = TAB_INFO[id]
|
||||
pages[id].Visible = id == current
|
||||
tabButtons[id].setColor(if id == current then ti.color else Theme.lighten(ti.color, 0.55))
|
||||
tabLabels[id].Text = L(ti.key)
|
||||
end
|
||||
-- 살 수 있는 것이 있는 탭에 ! 배지
|
||||
tabBadges.upgrade.Visible = refreshUpgrade(levels, stats, money)
|
||||
refreshStaff(stats, money)
|
||||
refreshMine(stats)
|
||||
end
|
||||
|
||||
local function setLayout(lay: Layout.Result)
|
||||
local r = lay.panel
|
||||
frame.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
frame.Position = UDim2.fromOffset(r.x + r.w / 2, r.y + r.h / 2)
|
||||
frame.Size = UDim2.fromOffset(r.w, r.h)
|
||||
shopPanel.close.button.Size = UDim2.fromOffset(lay.rows.closeH, lay.rows.closeH)
|
||||
for i, id in ShopWindow.TABS do
|
||||
local t = lay.tabs[i]
|
||||
local b = tabButtons[id].button
|
||||
b.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
b.Position = UDim2.fromOffset(t.x + t.w / 2, t.y + t.h / 2)
|
||||
b.Size = UDim2.fromOffset(t.w, t.h)
|
||||
end
|
||||
local c = lay.content
|
||||
for _, page in pages do
|
||||
page.Position = UDim2.fromOffset(c.x, c.y)
|
||||
page.Size = UDim2.fromOffset(c.w, c.h)
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
frame = frame,
|
||||
closeButton = shopPanel.close.button,
|
||||
open = function(tab: string?)
|
||||
if tab and TAB_INFO[tab] then
|
||||
current = tab
|
||||
end
|
||||
frame.Visible = true
|
||||
Theme.pop(frame)
|
||||
refresh()
|
||||
end,
|
||||
close = function()
|
||||
frame.Visible = false
|
||||
box:ReleaseFocus()
|
||||
end,
|
||||
isOpen = function()
|
||||
return frame.Visible
|
||||
end,
|
||||
tab = function()
|
||||
return current
|
||||
end,
|
||||
setLayout = function(lay: Layout.Result)
|
||||
setLayout(lay)
|
||||
refresh()
|
||||
end,
|
||||
refresh = refresh,
|
||||
destroy = function()
|
||||
for _, cn in conns do
|
||||
cn:Disconnect()
|
||||
end
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
return ShopWindow
|
||||
38
bunsik-tycoon/src/client/Stove.luau
Normal file
@@ -0,0 +1,38 @@
|
||||
--!strict
|
||||
-- 내 가게 조리대에만 "요리하기" 버튼(ProximityPrompt)을 만듭니다. 다른 사람 가게에서는 버튼이 안 보입니다.
|
||||
-- 버튼을 누르면(PC는 E 키) 요리 창(Kitchen)이 열리고, 메뉴를 골라 조리 과정을 마치면 창이 서버에 "cook"을 보냅니다.
|
||||
-- 서버가 조리대 속성(CookMenu: 만들 주문이 있으면 메뉴 키, HandFull)으로 알려 준 상태에 따라 버튼을 켜고 끕니다.
|
||||
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Shared = ReplicatedStorage:WaitForChild("Shared")
|
||||
local Locale = require(Shared:WaitForChild("Locale"))
|
||||
|
||||
local Stove = {}
|
||||
|
||||
function Stove.attach(stove: BasePart, state: Instance, openKitchen: () -> ()): ProximityPrompt
|
||||
local prompt = Instance.new("ProximityPrompt")
|
||||
prompt.Name = "CookPrompt"
|
||||
prompt.KeyboardKeyCode = Enum.KeyCode.E
|
||||
prompt.MaxActivationDistance = 10
|
||||
prompt.RequiresLineOfSight = false
|
||||
prompt.HoldDuration = 0
|
||||
prompt.Exclusivity = Enum.ProximityPromptExclusivity.OneGlobally
|
||||
|
||||
local function refresh()
|
||||
local lang = (state:GetAttribute("Lang") :: string?) or "ko"
|
||||
local menu = stove:GetAttribute("CookMenu")
|
||||
prompt.ObjectText = Locale.t(lang, "stoveObject")
|
||||
prompt.ActionText = Locale.t(lang, "cookAction")
|
||||
prompt.Enabled = typeof(menu) == "string" and menu ~= ""
|
||||
end
|
||||
|
||||
stove.AttributeChanged:Connect(refresh)
|
||||
state:GetAttributeChangedSignal("Lang"):Connect(refresh)
|
||||
prompt.Triggered:Connect(openKitchen)
|
||||
refresh()
|
||||
prompt.Parent = stove
|
||||
return prompt
|
||||
end
|
||||
|
||||
return Stove
|
||||
369
bunsik-tycoon/src/client/Theme.luau
Normal file
@@ -0,0 +1,369 @@
|
||||
--!strict
|
||||
-- 화면 UI 꾸미기 도구("사탕" 스타일): 밝은 색, 아주 둥근 모서리, 같은 계열의 진한 테두리, 누르면 쏙 들어가는 입체 버튼.
|
||||
-- 규칙(어지럽지 않게):
|
||||
-- - 바탕은 흰색·크림색, 색은 버튼마다 하나만. 테두리와 글자 외곽선은 그 색을 진하게 한 색.
|
||||
-- - 글꼴은 두 가지: 숫자·영어는 둥근 Fredoka(NUM), 한국어 등 글은 굵은 글꼴(FONT, 한글은 로블록스 기본 한글 글꼴로 대체됨).
|
||||
-- - 계속 움직이는 효과는 "지금 누를 수 있는 것"(살 수 있는 업그레이드 등)에만 씁니다.
|
||||
-- 트윈만 쓰고 RenderStepped는 쓰지 않아서 서버(원격 테스트)에서도 만들 수 있습니다.
|
||||
|
||||
local TweenService = game:GetService("TweenService")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Icons = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("Icons"))
|
||||
|
||||
local Theme = {}
|
||||
|
||||
Theme.TEXT = Color3.fromRGB(84, 52, 80) -- 흰 바탕 위 글자(진한 자두색)
|
||||
Theme.SOFT = Color3.fromRGB(150, 120, 145) -- 흐린 글자
|
||||
Theme.WHITE = Color3.new(1, 1, 1)
|
||||
Theme.CREAM = Color3.fromRGB(255, 248, 238)
|
||||
Theme.LINE = Color3.fromRGB(240, 222, 214) -- 흰 바탕 위 얇은 칸 선
|
||||
|
||||
Theme.PINK = Color3.fromRGB(255, 94, 132) -- 대표 색(떡볶이)
|
||||
Theme.YELLOW = Color3.fromRGB(255, 196, 48)
|
||||
Theme.MINT = Color3.fromRGB(46, 204, 128)
|
||||
Theme.SKY = Color3.fromRGB(74, 172, 255)
|
||||
Theme.LAVENDER = Color3.fromRGB(158, 116, 255)
|
||||
Theme.ORANGE = Color3.fromRGB(255, 140, 50)
|
||||
Theme.GRAY = Color3.fromRGB(184, 178, 196)
|
||||
Theme.RED = Color3.fromRGB(255, 76, 76)
|
||||
|
||||
Theme.FONT = Font.new("rbxasset://fonts/families/BuilderSans.json", Enum.FontWeight.Heavy)
|
||||
Theme.NUM = Font.new("rbxasset://fonts/families/FredokaOne.json", Enum.FontWeight.Bold)
|
||||
|
||||
function Theme.darken(c: Color3, k: number): Color3
|
||||
return c:Lerp(Color3.new(0, 0, 0), k)
|
||||
end
|
||||
|
||||
function Theme.lighten(c: Color3, k: number): Color3
|
||||
return c:Lerp(Color3.new(1, 1, 1), k)
|
||||
end
|
||||
|
||||
-- 그 색의 테두리·글자 외곽선 색
|
||||
function Theme.edge(c: Color3): Color3
|
||||
return c:Lerp(Color3.fromRGB(60, 20, 50), 0.55)
|
||||
end
|
||||
|
||||
function Theme.corner(parent: Instance, r: number, scale: number?): UICorner
|
||||
local c = Instance.new("UICorner")
|
||||
c.CornerRadius = UDim.new(scale or 0, r)
|
||||
c.Parent = parent
|
||||
return c
|
||||
end
|
||||
|
||||
function Theme.round(parent: Instance): UICorner
|
||||
return Theme.corner(parent, 0, 0.5)
|
||||
end
|
||||
|
||||
function Theme.stroke(parent: Instance, color: Color3, thickness: number, contextual: boolean?): UIStroke
|
||||
local s = Instance.new("UIStroke")
|
||||
s.Color = color
|
||||
s.Thickness = thickness
|
||||
s.LineJoinMode = Enum.LineJoinMode.Round
|
||||
s.ApplyStrokeMode = if contextual then Enum.ApplyStrokeMode.Contextual else Enum.ApplyStrokeMode.Border
|
||||
s.Parent = parent
|
||||
return s
|
||||
end
|
||||
|
||||
-- 위(밝음) → 아래 그러데이션. 배경색은 흰색으로 두고 색은 그러데이션이 냅니다.
|
||||
function Theme.gradient(parent: GuiObject, top: Color3, bottom: Color3): UIGradient
|
||||
local g = parent:FindFirstChildOfClass("UIGradient") or Instance.new("UIGradient")
|
||||
g.Color = ColorSequence.new(top, bottom)
|
||||
g.Rotation = 90
|
||||
g.Parent = parent
|
||||
parent.BackgroundColor3 = Theme.WHITE
|
||||
return g
|
||||
end
|
||||
|
||||
function Theme.frame(parent: Instance, name: string, color: Color3?): Frame
|
||||
local f = Instance.new("Frame")
|
||||
f.Name = name
|
||||
f.BorderSizePixel = 0
|
||||
f.BackgroundColor3 = color or Theme.WHITE
|
||||
f.BackgroundTransparency = if color then 0 else 1
|
||||
f.Parent = parent
|
||||
return f
|
||||
end
|
||||
|
||||
-- 글자. outline을 주면 흰 글자 + 그 색 외곽선(색 바탕용), 없으면 진한 자두색 글자(흰 바탕용).
|
||||
function Theme.text(parent: Instance, name: string, outline: Color3?, numeric: boolean?): TextLabel
|
||||
local t = Instance.new("TextLabel")
|
||||
t.Name = name
|
||||
t.BackgroundTransparency = 1
|
||||
t.FontFace = if numeric then Theme.NUM else Theme.FONT
|
||||
t.TextScaled = true
|
||||
t.TextWrapped = true
|
||||
t.AutoLocalize = false
|
||||
t.Text = ""
|
||||
if outline then
|
||||
t.TextColor3 = Theme.WHITE
|
||||
Theme.stroke(t, outline, 2.5, true)
|
||||
else
|
||||
t.TextColor3 = Theme.TEXT
|
||||
end
|
||||
t.Parent = parent
|
||||
return t
|
||||
end
|
||||
|
||||
function Theme.icon(parent: Instance, name: string, icon: string): ImageLabel
|
||||
local i = Instance.new("ImageLabel")
|
||||
i.Name = name
|
||||
i.BackgroundTransparency = 1
|
||||
i.ScaleType = Enum.ScaleType.Fit
|
||||
Icons.apply(i, icon)
|
||||
i.Parent = parent
|
||||
return i
|
||||
end
|
||||
|
||||
function Theme.kitchen(parent: Instance, name: string, art: string): ImageLabel
|
||||
local i = Instance.new("ImageLabel")
|
||||
i.Name = name
|
||||
i.BackgroundTransparency = 1
|
||||
i.ScaleType = Enum.ScaleType.Fit
|
||||
Icons.applyKitchen(i, art)
|
||||
i.Parent = parent
|
||||
return i
|
||||
end
|
||||
|
||||
Theme.setIcon = Icons.apply
|
||||
|
||||
-- 가운데 기준 배치(scale 좌표). 아이콘·그림 놓을 때 씁니다.
|
||||
function Theme.place(o: GuiObject, x: number, y: number, w: number, h: number)
|
||||
o.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
o.Position = UDim2.fromScale(x, y)
|
||||
o.Size = UDim2.fromScale(w, h)
|
||||
end
|
||||
|
||||
export type Button = {
|
||||
button: TextButton, -- 누르는 영역(투명). Layout 사각형이 여기에 들어갑니다.
|
||||
face: Frame, -- 색 있는 윗면
|
||||
base: Frame, -- 아래 그림자 판(입체감)
|
||||
scale: UIScale,
|
||||
setColor: (Color3) -> (),
|
||||
color: () -> Color3,
|
||||
}
|
||||
|
||||
-- 입체 버튼: 아래로 DEPTH만큼 진한 판이 보이고, 누르면 윗면이 내려가며 살짝 작아집니다.
|
||||
local DEPTH = 5
|
||||
|
||||
function Theme.button(parent: Instance, name: string, color: Color3, radius: number?): Button
|
||||
local b = Instance.new("TextButton")
|
||||
b.Name = name
|
||||
b.BackgroundTransparency = 1
|
||||
b.AutoButtonColor = false
|
||||
b.Text = ""
|
||||
b.AutoLocalize = false
|
||||
b.Parent = parent
|
||||
local scale = Instance.new("UIScale")
|
||||
scale.Parent = b
|
||||
|
||||
local base = Theme.frame(b, "Base", color)
|
||||
base.Size = UDim2.new(1, 0, 1, -DEPTH)
|
||||
base.Position = UDim2.fromOffset(0, DEPTH)
|
||||
local face = Theme.frame(b, "Face", Theme.WHITE)
|
||||
face.Size = UDim2.new(1, 0, 1, -DEPTH)
|
||||
face.ZIndex = 2
|
||||
for _, f in { base, face } do
|
||||
if radius then
|
||||
Theme.corner(f, radius)
|
||||
else
|
||||
Theme.round(f)
|
||||
end
|
||||
end
|
||||
local baseStroke = Theme.stroke(base, color, 3)
|
||||
local faceStroke = Theme.stroke(face, color, 3)
|
||||
-- 윗부분 반사광(흰 반투명 띠)
|
||||
local gloss = Theme.frame(face, "Gloss", Theme.WHITE)
|
||||
gloss.BackgroundTransparency = 0.6
|
||||
gloss.AnchorPoint = Vector2.new(0.5, 0)
|
||||
gloss.Size = UDim2.new(1, -16, 0.3, 0)
|
||||
gloss.Position = UDim2.new(0.5, 0, 0, 4)
|
||||
gloss.ZIndex = 3
|
||||
if radius then
|
||||
Theme.corner(gloss, math.max(6, radius - 6))
|
||||
else
|
||||
Theme.round(gloss)
|
||||
end
|
||||
|
||||
local current = color
|
||||
local function setColor(c: Color3)
|
||||
current = c
|
||||
Theme.gradient(face, Theme.lighten(c, 0.18), c)
|
||||
base.BackgroundColor3 = Theme.darken(c, 0.3)
|
||||
baseStroke.Color = Theme.edge(c)
|
||||
faceStroke.Color = Theme.edge(c)
|
||||
end
|
||||
setColor(color)
|
||||
|
||||
local down = false
|
||||
local hover = false
|
||||
local function animate()
|
||||
local target = if down then 0.92 elseif hover then 1.05 else 1
|
||||
TweenService:Create(
|
||||
scale,
|
||||
TweenInfo.new(if down then 0.06 else 0.2, if down then Enum.EasingStyle.Quad else Enum.EasingStyle.Back),
|
||||
{ Scale = target }
|
||||
):Play()
|
||||
face.Position = UDim2.fromOffset(0, if down then DEPTH - 1 else 0)
|
||||
end
|
||||
b.MouseButton1Down:Connect(function()
|
||||
down = true
|
||||
animate()
|
||||
end)
|
||||
b.MouseButton1Up:Connect(function()
|
||||
down = false
|
||||
animate()
|
||||
end)
|
||||
b.InputBegan:Connect(function(input: InputObject)
|
||||
-- 터치에서는 MouseEnter가 같이 와서, 마우스일 때만 커집니다.
|
||||
if input.UserInputType == Enum.UserInputType.MouseMovement then
|
||||
hover = true
|
||||
animate()
|
||||
end
|
||||
end)
|
||||
b.MouseLeave:Connect(function()
|
||||
down = false
|
||||
hover = false
|
||||
animate()
|
||||
end)
|
||||
|
||||
return {
|
||||
button = b,
|
||||
face = face,
|
||||
base = base,
|
||||
scale = scale,
|
||||
setColor = setColor,
|
||||
color = function()
|
||||
return current
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
-- 아이콘 버튼: 둥근 네모 안에 큰 아이콘, 아래에 짧은 이름(테두리에 걸침)
|
||||
function Theme.iconButton(parent: Instance, name: string, color: Color3, icon: string): (Button, TextLabel, ImageLabel)
|
||||
local b = Theme.button(parent, name, color, 22)
|
||||
local ic = Theme.icon(b.face, "Icon", icon)
|
||||
ic.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
ic.Position = UDim2.fromScale(0.5, 0.44)
|
||||
ic.Size = UDim2.fromScale(0.72, 0.72)
|
||||
ic.ZIndex = 4
|
||||
local label = Theme.text(b.button, "Label", Theme.edge(color))
|
||||
label.AnchorPoint = Vector2.new(0.5, 1)
|
||||
label.Position = UDim2.new(0.5, 0, 1, 2)
|
||||
label.Size = UDim2.fromScale(1.1, 0.3)
|
||||
label.ZIndex = 5
|
||||
return b, label, ic
|
||||
end
|
||||
|
||||
-- 글자 버튼
|
||||
function Theme.textButton(parent: Instance, name: string, color: Color3, radius: number?): (Button, TextLabel)
|
||||
local b = Theme.button(parent, name, color, radius)
|
||||
local label = Theme.text(b.face, "Label", Theme.edge(color))
|
||||
label.Size = UDim2.new(1, -18, 0.62, 0)
|
||||
label.Position = UDim2.fromScale(0.5, 0.5)
|
||||
label.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
label.ZIndex = 4
|
||||
local function recolor(c: Color3)
|
||||
local s = label:FindFirstChildOfClass("UIStroke")
|
||||
if s then
|
||||
s.Color = Theme.edge(c)
|
||||
end
|
||||
end
|
||||
local set = b.setColor
|
||||
b.setColor = function(c: Color3)
|
||||
set(c)
|
||||
recolor(c)
|
||||
end
|
||||
return b, label
|
||||
end
|
||||
|
||||
-- 빨간 동그라미 알림 배지(예: 살 수 있는 업그레이드가 있으면 "!")
|
||||
function Theme.badge(parent: Instance, name: string): (Frame, TextLabel)
|
||||
local f = Theme.frame(parent, name, Theme.RED)
|
||||
f.Size = UDim2.fromOffset(28, 28)
|
||||
f.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
f.Position = UDim2.new(1, -6, 0, 6)
|
||||
f.ZIndex = 8
|
||||
Theme.round(f)
|
||||
Theme.stroke(f, Theme.WHITE, 3)
|
||||
local t = Theme.text(f, "Text", Theme.edge(Theme.RED), true)
|
||||
t.Size = UDim2.new(1, -8, 1, -8)
|
||||
t.Position = UDim2.fromOffset(4, 4)
|
||||
t.ZIndex = 9
|
||||
return f, t
|
||||
end
|
||||
|
||||
-- 둥실둥실(위아래로 살짝) 움직임. 지금 누를 수 있는 것에만 씁니다.
|
||||
function Theme.bob(o: GuiObject, pixels: number, period: number): Tween
|
||||
local p = o.Position
|
||||
local tw = TweenService:Create(
|
||||
o,
|
||||
TweenInfo.new(period / 2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true),
|
||||
{ Position = p + UDim2.fromOffset(0, -pixels) }
|
||||
)
|
||||
tw:Play()
|
||||
return tw
|
||||
end
|
||||
|
||||
-- 통 튀기(크기). UIScale이 있는 것에 씁니다.
|
||||
function Theme.pop(o: Instance, from: number?)
|
||||
local s = o:FindFirstChildOfClass("UIScale")
|
||||
if s then
|
||||
s.Scale = from or 0.6
|
||||
TweenService:Create(s, TweenInfo.new(0.32, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1 })
|
||||
:Play()
|
||||
end
|
||||
end
|
||||
|
||||
-- 창 틀: 흰 본문(아주 둥근 모서리) + 위쪽 색 띠에 가운데 제목 + 오른쪽 위 빨간 동그라미 X.
|
||||
export type Panel = {
|
||||
frame: Frame,
|
||||
body: Frame,
|
||||
title: TextLabel,
|
||||
close: Button,
|
||||
headerH: number,
|
||||
}
|
||||
|
||||
function Theme.panel(parent: Instance, name: string, color: Color3): Panel
|
||||
local headerH = 58
|
||||
local p = Theme.frame(parent, name)
|
||||
p.Visible = false
|
||||
p.ZIndex = 20
|
||||
local scale = Instance.new("UIScale")
|
||||
scale.Parent = p
|
||||
local body = Theme.frame(p, "Body", Theme.CREAM)
|
||||
body.Size = UDim2.fromScale(1, 1)
|
||||
body.ZIndex = 2
|
||||
Theme.corner(body, 30)
|
||||
Theme.stroke(body, Theme.edge(color), 4)
|
||||
local header = Theme.frame(body, "Header", color)
|
||||
header.Size = UDim2.new(1, 0, 0, headerH)
|
||||
header.ZIndex = 2
|
||||
Theme.corner(header, 30)
|
||||
Theme.gradient(header, Theme.lighten(color, 0.15), color)
|
||||
-- 띠 아래쪽 모서리는 각지게(본문과 이어지게)
|
||||
local fill = Theme.frame(header, "Fill", color)
|
||||
fill.Position = UDim2.new(0, 0, 1, -30)
|
||||
fill.Size = UDim2.new(1, 0, 0, 30)
|
||||
fill.ZIndex = 2
|
||||
Theme.gradient(fill, color, color)
|
||||
local title = Theme.text(header, "Title", Theme.edge(color))
|
||||
title.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
title.Position = UDim2.fromScale(0.5, 0.5)
|
||||
title.Size = UDim2.new(0.6, 0, 0, 38)
|
||||
title.ZIndex = 4
|
||||
local close = Theme.button(p, "Close", Theme.RED)
|
||||
close.button.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
-- 색 띠 오른쪽 안에(화면 밖으로 안 나가게). 크기는 Layout.rows.closeH
|
||||
close.button.Size = UDim2.fromOffset(48, 48)
|
||||
close.button.Position = UDim2.new(1, -36, 0, headerH / 2)
|
||||
close.button.ZIndex = 6
|
||||
local x = Theme.icon(close.face, "X", "close")
|
||||
x.Size = UDim2.fromScale(0.6, 0.6)
|
||||
x.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
x.Position = UDim2.fromScale(0.5, 0.5)
|
||||
x.ZIndex = 4
|
||||
return { frame = p, body = body, title = title, close = close, headerH = headerH }
|
||||
end
|
||||
|
||||
return Theme
|
||||
194
bunsik-tycoon/src/server/Build.luau
Normal file
@@ -0,0 +1,194 @@
|
||||
--!strict
|
||||
-- 파트로 모형을 만드는 작은 도구. Union은 Place Publishing API로 못 올리므로 Part 조합만 씁니다.
|
||||
|
||||
local Icons = require(game:GetService("ReplicatedStorage").Shared.Icons)
|
||||
|
||||
local Build = {}
|
||||
|
||||
export type PartProps = {
|
||||
size: Vector3,
|
||||
cf: CFrame,
|
||||
color: Color3?,
|
||||
material: Enum.Material?,
|
||||
shape: Enum.PartType?,
|
||||
transparency: number?,
|
||||
collide: boolean?,
|
||||
name: string?,
|
||||
wedge: boolean?,
|
||||
neon: boolean?,
|
||||
reflectance: number?,
|
||||
}
|
||||
|
||||
function Build.part(parent: Instance, p: PartProps): BasePart
|
||||
local part: BasePart
|
||||
if p.wedge then
|
||||
part = Instance.new("WedgePart")
|
||||
else
|
||||
local np = Instance.new("Part")
|
||||
if p.shape then
|
||||
np.Shape = p.shape
|
||||
end
|
||||
part = np
|
||||
end
|
||||
part.Anchored = true
|
||||
part.Size = p.size
|
||||
part.CFrame = p.cf
|
||||
part.Color = p.color or Color3.fromRGB(200, 200, 200)
|
||||
part.Material = if p.neon then Enum.Material.Neon else (p.material or Enum.Material.SmoothPlastic)
|
||||
part.Transparency = p.transparency or 0
|
||||
part.CanCollide = if p.collide == nil then true else p.collide
|
||||
part.Reflectance = p.reflectance or 0
|
||||
part.TopSurface = Enum.SurfaceType.Smooth
|
||||
part.BottomSurface = Enum.SurfaceType.Smooth
|
||||
part.CastShadow = (p.transparency or 0) < 0.5
|
||||
part.Name = p.name or "Part"
|
||||
part.Parent = parent
|
||||
return part
|
||||
end
|
||||
|
||||
-- 원기둥(세로로 세운). Roblox 원기둥은 X축이 높이라서 Z축으로 90도 돌립니다.
|
||||
function Build.cylinder(
|
||||
parent: Instance,
|
||||
cf: CFrame,
|
||||
height: number,
|
||||
diameter: number,
|
||||
color: Color3,
|
||||
extra: { [string]: any }?
|
||||
): BasePart
|
||||
local props: PartProps = {
|
||||
size = Vector3.new(height, diameter, diameter),
|
||||
cf = cf * CFrame.Angles(0, 0, math.rad(90)),
|
||||
color = color,
|
||||
shape = Enum.PartType.Cylinder,
|
||||
}
|
||||
if extra then
|
||||
for k, v in extra do
|
||||
(props :: any)[k] = v
|
||||
end
|
||||
end
|
||||
return Build.part(parent, props)
|
||||
end
|
||||
|
||||
function Build.model(parent: Instance, name: string): Model
|
||||
local m = Instance.new("Model")
|
||||
m.Name = name
|
||||
m.Parent = parent
|
||||
return m
|
||||
end
|
||||
|
||||
-- 판(Part) 한 면에 글자를 씁니다.
|
||||
function Build.label(part: BasePart, face: Enum.NormalId, text: string, color: Color3?, bg: Color3?): TextLabel
|
||||
local gui = Instance.new("SurfaceGui")
|
||||
gui.Face = face
|
||||
gui.SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud
|
||||
gui.PixelsPerStud = 40
|
||||
gui.LightInfluence = 0
|
||||
gui.Parent = part
|
||||
local label = Instance.new("TextLabel")
|
||||
label.Size = UDim2.fromScale(1, 1)
|
||||
label.BackgroundTransparency = if bg then 0 else 1
|
||||
label.BackgroundColor3 = bg or Color3.new(1, 1, 1)
|
||||
label.TextColor3 = color or Color3.new(1, 1, 1)
|
||||
label.Font = Enum.Font.FredokaOne
|
||||
label.TextScaled = true
|
||||
label.Text = text
|
||||
label.AutoLocalize = false
|
||||
label.Parent = gui
|
||||
local pad = Instance.new("UIPadding")
|
||||
pad.PaddingTop = UDim.new(0.08, 0)
|
||||
pad.PaddingBottom = UDim.new(0.08, 0)
|
||||
pad.PaddingLeft = UDim.new(0.04, 0)
|
||||
pad.PaddingRight = UDim.new(0.04, 0)
|
||||
pad.Parent = label
|
||||
return label
|
||||
end
|
||||
|
||||
-- 머리 위 말풍선
|
||||
function Build.billboard(adornee: Instance, text: string, size: UDim2, offset: Vector3, color: Color3?): BillboardGui
|
||||
local gui = Instance.new("BillboardGui")
|
||||
gui.Size = size
|
||||
gui.StudsOffset = offset
|
||||
gui.AlwaysOnTop = false
|
||||
gui.LightInfluence = 0
|
||||
gui.MaxDistance = 120
|
||||
gui.Adornee = adornee :: any
|
||||
gui.Parent = adornee
|
||||
local label = Instance.new("TextLabel")
|
||||
label.Name = "Text"
|
||||
label.Size = UDim2.fromScale(1, 1)
|
||||
label.BackgroundColor3 = Color3.new(1, 1, 1)
|
||||
label.BackgroundTransparency = if color then 1 else 0.05
|
||||
label.TextColor3 = color or Color3.fromRGB(40, 30, 30)
|
||||
label.Font = Enum.Font.FredokaOne
|
||||
label.TextScaled = true
|
||||
label.AutoLocalize = false
|
||||
label.Text = text
|
||||
label.Parent = gui
|
||||
if not color then
|
||||
-- 주문 말풍선: 흰 바탕 둘레에 화면 UI와 같은 진한 갈색 테두리(Theme.INK)
|
||||
local corner = Instance.new("UICorner")
|
||||
corner.CornerRadius = UDim.new(0.3, 0)
|
||||
corner.Parent = label
|
||||
local stroke = Instance.new("UIStroke")
|
||||
stroke.Thickness = 3
|
||||
stroke.Color = Color3.fromRGB(59, 30, 18)
|
||||
stroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
|
||||
stroke.Parent = label
|
||||
end
|
||||
return gui
|
||||
end
|
||||
|
||||
-- 손님 주문 말풍선: 흰 동그라미 안에 직접 그린 음식 그림(글을 못 읽어도 알 수 있게). 다 받으면 하트로 바뀝니다(setBubbleIcon).
|
||||
function Build.orderBubble(adornee: Instance, menu: string, size: number, offset: Vector3): BillboardGui
|
||||
local gui = Instance.new("BillboardGui")
|
||||
gui.Size = UDim2.fromOffset(size, size)
|
||||
gui.StudsOffset = offset
|
||||
gui.LightInfluence = 0
|
||||
gui.MaxDistance = 120
|
||||
gui.Adornee = adornee :: any
|
||||
gui.Parent = adornee
|
||||
local bubble = Instance.new("Frame")
|
||||
bubble.Name = "Bubble"
|
||||
bubble.Size = UDim2.fromScale(1, 1)
|
||||
bubble.BackgroundColor3 = Color3.new(1, 1, 1)
|
||||
bubble.Parent = gui
|
||||
local corner = Instance.new("UICorner")
|
||||
corner.CornerRadius = UDim.new(0.5, 0)
|
||||
corner.Parent = bubble
|
||||
local stroke = Instance.new("UIStroke")
|
||||
stroke.Thickness = 3
|
||||
stroke.Color = Color3.fromRGB(255, 94, 132) -- 화면 UI 대표 색(Theme.PINK)
|
||||
stroke.Parent = bubble
|
||||
local icon = Instance.new("ImageLabel")
|
||||
icon.Name = "Icon"
|
||||
icon.BackgroundTransparency = 1
|
||||
icon.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
icon.Position = UDim2.fromScale(0.5, 0.5)
|
||||
icon.Size = UDim2.fromScale(0.8, 0.8)
|
||||
icon.Parent = bubble
|
||||
Icons.apply(icon, menu)
|
||||
return gui
|
||||
end
|
||||
|
||||
function Build.setBubbleIcon(gui: BillboardGui, name: string)
|
||||
local icon = gui:FindFirstChild("Icon", true) :: ImageLabel?
|
||||
if icon then
|
||||
Icons.apply(icon, name)
|
||||
end
|
||||
end
|
||||
|
||||
-- 모델 전체를 하나로 묶습니다(첫 파트 기준). 손에 들기, 트윈 이동용.
|
||||
function Build.weldAll(model: Model, root: BasePart)
|
||||
for _, d in model:GetDescendants() do
|
||||
if d:IsA("BasePart") and d ~= root then
|
||||
local w = Instance.new("WeldConstraint")
|
||||
w.Part0 = root
|
||||
w.Part1 = d
|
||||
w.Parent = d
|
||||
d.Anchored = false
|
||||
end
|
||||
end
|
||||
model.PrimaryPart = root
|
||||
end
|
||||
|
||||
return Build
|
||||
119
bunsik-tycoon/src/server/Data.luau
Normal file
@@ -0,0 +1,119 @@
|
||||
--!strict
|
||||
-- 세이브 데이터(ProfileStore). 세션 잠금으로 서버 이동 때 덮어쓰기·복사를 막습니다.
|
||||
|
||||
local Players = game:GetService("Players")
|
||||
local RunService = game:GetService("RunService")
|
||||
local ServerScriptService = game:GetService("ServerScriptService")
|
||||
|
||||
local ProfileStore = require(ServerScriptService.Vendor.ProfileStore)
|
||||
local Economy = require(game:GetService("ReplicatedStorage").Shared.Economy)
|
||||
local Floor = require(game:GetService("ReplicatedStorage").Shared.Floor)
|
||||
|
||||
local Data = {}
|
||||
|
||||
Data.TEMPLATE = {
|
||||
Money = 0,
|
||||
Bought = 0, -- 예전(버전 1) 한 줄 업그레이드 수. 버전 2로 옮긴 뒤에는 쓰지 않음
|
||||
Levels = {} :: { [string]: number }, -- 업그레이드 갈래 레벨(Economy.TRACKS)
|
||||
Layout = {} :: any, -- 배치(Floor.Layout). 빈 표면 기본 배치
|
||||
Staff = {} :: { [string]: number }, -- 고용한 알바 수
|
||||
ShopName = "", -- 가게 이름 원문("" = 기본 이름)
|
||||
Rainbow = true, -- 무지개 이름 켜기(게임패스가 있을 때만 보임)
|
||||
NameColor = 0, -- 가게 이름 글자색(Economy.NAME_COLORS 번호, 0 = 디자인 기본색)
|
||||
Design = "Basic",
|
||||
RushLeft = 0, -- 손님 러시 남은 초
|
||||
KickCredits = 0, -- 산 "손님 쫓아내기" 남은 횟수
|
||||
PurchaseIdCache = {} :: { string },
|
||||
TutorialDone = false,
|
||||
Lang = "", -- "" = 계정 언어 자동
|
||||
MouseLook = true, -- PC: 우클릭 없이 마우스 이동으로 화면 돌리기
|
||||
Sfx = true, -- 효과음
|
||||
Served = 0,
|
||||
Earned = 0,
|
||||
Version = 2,
|
||||
}
|
||||
|
||||
export type SaveData = typeof(Data.TEMPLATE)
|
||||
|
||||
-- 데이터 구조를 바꾸면 store 이름을 올리지 말고 Version과 Reconcile로 이전합니다.
|
||||
local STORE_NAME = "PlayerData_v1"
|
||||
|
||||
local store = ProfileStore.New(STORE_NAME, Data.TEMPLATE)
|
||||
-- Studio 테스트는 실제 저장소를 건드리지 않습니다.
|
||||
local activeStore = if RunService:IsStudio() then store.Mock else store
|
||||
|
||||
local profiles: { [Player]: any } = {}
|
||||
|
||||
function Data.keyFor(userId: number): string
|
||||
return "Player_" .. userId
|
||||
end
|
||||
|
||||
-- 플레이어 데이터를 불러옵니다. 실패하거나 그 사이 나가면 nil.
|
||||
function Data.load(player: Player): any
|
||||
local profile = activeStore:StartSessionAsync(Data.keyFor(player.UserId), {
|
||||
Cancel = function()
|
||||
return player.Parent ~= Players
|
||||
end,
|
||||
})
|
||||
if profile == nil then
|
||||
return nil
|
||||
end
|
||||
profile:AddUserId(player.UserId)
|
||||
-- Reconcile 전에 버전을 봐야 합니다(빠진 Version은 템플릿 값 2로 채워지므로).
|
||||
local version = profile.Data.Version
|
||||
profile:Reconcile()
|
||||
Data.migrate(profile.Data, if typeof(version) == "number" then version else 1)
|
||||
profile.OnSessionEnd:Connect(function()
|
||||
profiles[player] = nil
|
||||
if player.Parent == Players then
|
||||
player:Kick(
|
||||
"세이브 세션이 다른 서버로 넘어갔어요. 다시 접속해 주세요 / Your save session moved. Please rejoin"
|
||||
)
|
||||
end
|
||||
end)
|
||||
if player.Parent ~= Players then
|
||||
profile:EndSession()
|
||||
return nil
|
||||
end
|
||||
profiles[player] = profile
|
||||
return profile
|
||||
end
|
||||
|
||||
-- 버전 1(한 줄 업그레이드 Bought) -> 버전 2(갈래 레벨, 배치, 알바생)
|
||||
function Data.migrate(data: any, version: number)
|
||||
if version >= 2 then
|
||||
return
|
||||
end
|
||||
local levels, seats, tables, cooks = Economy.migrate(data.Bought or 0)
|
||||
data.Levels = levels
|
||||
data.Staff = { Cook = cooks }
|
||||
local stage = Economy.stats(levels, seats).stage
|
||||
local layout = Floor.default()
|
||||
for _ = 2, tables do
|
||||
Floor.addTable(layout, stage)
|
||||
end
|
||||
for _ = #layout.chairs + 1, seats do
|
||||
Floor.addChair(layout, stage)
|
||||
end
|
||||
data.Layout = layout
|
||||
data.Version = 2
|
||||
end
|
||||
|
||||
function Data.get(player: Player): any
|
||||
return profiles[player]
|
||||
end
|
||||
|
||||
function Data.release(player: Player)
|
||||
local profile = profiles[player]
|
||||
profiles[player] = nil
|
||||
if profile then
|
||||
profile:EndSession()
|
||||
end
|
||||
end
|
||||
|
||||
-- 테스트용: 실제 저장소 대신 Mock 저장소를 씁니다.
|
||||
function Data.useMock()
|
||||
activeStore = store.Mock
|
||||
end
|
||||
|
||||
return Data
|
||||
131
bunsik-tycoon/src/server/Food.luau
Normal file
@@ -0,0 +1,131 @@
|
||||
--!strict
|
||||
-- 메뉴별 접시 모형(파트 조합). 원점은 접시 바닥 가운데입니다.
|
||||
|
||||
local Build = require(script.Parent.Build)
|
||||
|
||||
local Food = {}
|
||||
|
||||
local PLATE = Color3.fromRGB(250, 250, 245)
|
||||
|
||||
local function rc(r: number, g: number, b: number): Color3
|
||||
return Color3.fromRGB(r, g, b)
|
||||
end
|
||||
|
||||
local builders: { [string]: (Model, CFrame) -> () } = {
|
||||
Tteokbokki = function(m, top)
|
||||
Build.cylinder(m, top * CFrame.new(0, 0.05, 0), 0.1, 2, rc(200, 40, 25), { collide = false })
|
||||
for i = 0, 6 do
|
||||
local a = i * math.pi * 2 / 7
|
||||
local r = if i % 2 == 0 then 0.55 else 0.35
|
||||
Build.part(m, {
|
||||
size = Vector3.new(0.9, 0.28, 0.28),
|
||||
cf = top * CFrame.new(math.cos(a) * r, 0.22, math.sin(a) * r) * CFrame.Angles(0, a * 1.7, 0),
|
||||
color = rc(235, 90, 50),
|
||||
collide = false,
|
||||
})
|
||||
end
|
||||
Build.part(m, {
|
||||
size = Vector3.new(0.5, 0.12, 0.25),
|
||||
cf = top * CFrame.new(0.1, 0.4, -0.1) * CFrame.Angles(0, 0.6, 0),
|
||||
color = rc(240, 220, 160),
|
||||
collide = false,
|
||||
})
|
||||
end,
|
||||
Gimbap = function(m, top)
|
||||
for i = 0, 5 do
|
||||
local x = -0.75 + i * 0.3
|
||||
local cf = top * CFrame.new(x, 0.32, 0) * CFrame.Angles(0, 0, math.rad(80))
|
||||
Build.part(m, {
|
||||
size = Vector3.new(0.25, 0.62, 0.62),
|
||||
cf = cf,
|
||||
color = rc(25, 35, 25),
|
||||
shape = Enum.PartType.Cylinder,
|
||||
collide = false,
|
||||
})
|
||||
Build.part(m, {
|
||||
size = Vector3.new(0.27, 0.5, 0.5),
|
||||
cf = cf,
|
||||
color = rc(250, 248, 240),
|
||||
shape = Enum.PartType.Cylinder,
|
||||
collide = false,
|
||||
})
|
||||
Build.part(m, {
|
||||
size = Vector3.new(0.29, 0.2, 0.2),
|
||||
cf = cf,
|
||||
color = if i % 2 == 0 then rc(250, 200, 40) else rc(240, 120, 40),
|
||||
shape = Enum.PartType.Cylinder,
|
||||
collide = false,
|
||||
})
|
||||
end
|
||||
end,
|
||||
Sundae = function(m, top)
|
||||
for i = 0, 5 do
|
||||
local a = i * math.pi * 2 / 6
|
||||
Build.part(m, {
|
||||
size = Vector3.new(0.22, 0.55, 0.55),
|
||||
cf = top * CFrame.new(math.cos(a) * 0.55, 0.3, math.sin(a) * 0.55) * CFrame.Angles(0, -a, math.rad(70)),
|
||||
color = rc(70, 35, 45),
|
||||
shape = Enum.PartType.Cylinder,
|
||||
material = Enum.Material.Pebble,
|
||||
collide = false,
|
||||
})
|
||||
end
|
||||
Build.part(m, {
|
||||
size = Vector3.new(0.4, 0.4, 0.4),
|
||||
cf = top * CFrame.new(0, 0.25, 0),
|
||||
color = rc(230, 200, 120),
|
||||
shape = Enum.PartType.Ball,
|
||||
collide = false,
|
||||
})
|
||||
end,
|
||||
Eomuk = function(m, top)
|
||||
for i = -1, 1 do
|
||||
local base = top * CFrame.new(i * 0.55, 0.2, 0)
|
||||
Build.part(m, {
|
||||
size = Vector3.new(0.08, 1.8, 0.08),
|
||||
cf = base * CFrame.new(0, 0.7, 0),
|
||||
color = rc(190, 150, 100),
|
||||
collide = false,
|
||||
})
|
||||
for j = 0, 2 do
|
||||
Build.part(m, {
|
||||
size = Vector3.new(0.45, 0.28, 0.12),
|
||||
cf = base * CFrame.new(if j % 2 == 0 then 0.06 else -0.06, 0.2 + j * 0.3, 0),
|
||||
color = rc(225, 185, 120),
|
||||
collide = false,
|
||||
})
|
||||
end
|
||||
end
|
||||
end,
|
||||
Twigim = function(m, top)
|
||||
for i = 0, 3 do
|
||||
local a = i * math.pi / 2 + 0.4
|
||||
Build.part(m, {
|
||||
size = Vector3.new(1.0, 0.32, 0.4),
|
||||
cf = top
|
||||
* CFrame.new(math.cos(a) * 0.4, 0.22 + (i % 2) * 0.12, math.sin(a) * 0.4)
|
||||
* CFrame.Angles(0, a, 0),
|
||||
color = rc(230, 170, 60),
|
||||
material = Enum.Material.Sand,
|
||||
collide = false,
|
||||
})
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
-- cf: 접시 바닥 가운데 위치
|
||||
function Food.dish(menu: string, cf: CFrame, parent: Instance): Model
|
||||
local m = Instance.new("Model")
|
||||
m.Name = "Dish_" .. menu
|
||||
local plate = Build.cylinder(m, cf * CFrame.new(0, 0.1, 0), 0.2, 2.4, PLATE, { collide = false, name = "Plate" })
|
||||
local build = builders[menu] or builders.Tteokbokki
|
||||
build(m, cf * CFrame.new(0, 0.2, 0))
|
||||
m.PrimaryPart = plate
|
||||
-- 원기둥 접시는 X축이 세로라 파트 자체가 90도 돌아가 있습니다. 모델 기준점(PivotTo)을 접시 바닥 가운데의
|
||||
-- 똑바른 방향으로 맞춰 둡니다. 안 그러면 손에 들거나 테이블에 놓을 때 접시가 세로로 섭니다.
|
||||
plate.PivotOffset = plate.CFrame:ToObjectSpace(cf)
|
||||
m.Parent = parent
|
||||
return m
|
||||
end
|
||||
|
||||
return Food
|
||||
833
bunsik-tycoon/src/server/Game.luau
Normal file
@@ -0,0 +1,833 @@
|
||||
--!strict
|
||||
-- 서버 시작: 맵, 플레이어 입장·퇴장, 부지 배정, 이웃 가게, 손님 방문, 설정, 리모트, 결제를 연결합니다.
|
||||
|
||||
local AdService = game:GetService("AdService")
|
||||
local MarketplaceService = game:GetService("MarketplaceService")
|
||||
local Players = game:GetService("Players")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local RunService = game:GetService("RunService")
|
||||
local TextService = game:GetService("TextService")
|
||||
|
||||
local Shared = ReplicatedStorage.Shared
|
||||
local Economy = require(Shared.Economy)
|
||||
local Floor = require(Shared.Floor)
|
||||
local Locale = require(Shared.Locale)
|
||||
local Products = require(Shared.Products)
|
||||
|
||||
local Data = require(script.Parent.Data)
|
||||
local Neighbor = require(script.Parent.Neighbor)
|
||||
local Npc = require(script.Parent.Npc)
|
||||
local PlotBuilder = require(script.Parent.PlotBuilder)
|
||||
local PlotController = require(script.Parent.PlotController)
|
||||
local Receipts = require(script.Parent.Receipts)
|
||||
local Transfers = require(script.Parent.Transfers)
|
||||
local World = require(script.Parent.World)
|
||||
|
||||
local Game = {}
|
||||
|
||||
local slots: { World.Slot } = {}
|
||||
local slotOwner: { [number]: Player } = {}
|
||||
local controllers: { [Player]: PlotController.PlotController } = {}
|
||||
local actionTimes: { [Player]: { number } } = {}
|
||||
local neighbors: { [number]: Neighbor.Neighbor } = {} -- 플레이어가 없는 부지의 이웃 가게
|
||||
local guestAt: { [Player]: PlotController.PlotController } = {} -- 손님으로 앉아 있는 가게
|
||||
local bonusAt: { [Player]: number } = {} -- 다음 시식 보너스를 받을 수 있는 시각
|
||||
local kickTarget: { [Player]: { index: number, expires: number } } = {} -- 결제 창을 띄운 쫓아내기 대상
|
||||
local adBusy: { [Player]: boolean } = {}
|
||||
local devFree: { [Player]: boolean } = {} -- 개발자 결제 테스트 모드(로벅스 버튼이 결제 없이 바로 지급, 이번 접속만)
|
||||
-- 아래에서 정의(결제 테스트 모드에서 앞쪽 함수가 부름)
|
||||
local grantProduct: (Player, PlotController.PlotController, number) -> boolean
|
||||
local onPassBought: (Player, number, boolean) -> ()
|
||||
|
||||
local COOK_RANGE = 20 -- 요리 화면에서 만든 접시는 조리대에서 이만큼 안에 있어야 받습니다
|
||||
local VISIT_RANGE = 16 -- 입구에서 이만큼 안에 있어야 손님으로 들어가거나 쫓아낼 수 있습니다
|
||||
local KICK_TARGET_TTL = 120 -- 결제 창을 띄운 뒤 이 시간 안에 결제되면 그 부지에 씁니다
|
||||
|
||||
local Remotes = ReplicatedStorage:WaitForChild("Remotes")
|
||||
local ActionRemote = Remotes:WaitForChild("Action") :: RemoteEvent
|
||||
local NotifyRemote = Remotes:WaitForChild("Notify") :: RemoteEvent
|
||||
|
||||
local function freeSlot(): World.Slot?
|
||||
for _, s in slots do
|
||||
if not slotOwner[s.index] then
|
||||
return s
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- 그 부지에서 열려 있는 가게(플레이어 가게 또는 이웃 가게)
|
||||
local function controllerAt(index: number): PlotController.PlotController?
|
||||
local p = slotOwner[index]
|
||||
if p then
|
||||
return controllers[p]
|
||||
end
|
||||
local n = neighbors[index]
|
||||
return n and n.controller
|
||||
end
|
||||
|
||||
local function allControllers(): { PlotController.PlotController }
|
||||
local out = {}
|
||||
for _, s in slots do
|
||||
local c = controllerAt(s.index)
|
||||
if c then
|
||||
table.insert(out, c)
|
||||
end
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
local function notifyPlayer(player: Player, key: string, args: { [string]: any }?)
|
||||
NotifyRemote:FireClient(player, key, args)
|
||||
end
|
||||
|
||||
-- 다른 가게에 손님으로 간 플레이어 소식. 처음 먹으면 시식 보너스(접시 값)를 내 가게 돈으로 받습니다(1분에 한 번).
|
||||
local function onGuestEvent(kind: string, userId: number, info: { [string]: any })
|
||||
local visitor = Players:GetPlayerByUserId(userId)
|
||||
if not visitor then
|
||||
return
|
||||
end
|
||||
if kind == "served" then
|
||||
local own = controllers[visitor]
|
||||
local now = os.clock()
|
||||
if own and now >= (bonusAt[visitor] or 0) then
|
||||
bonusAt[visitor] = now + Economy.GUEST_BONUS_COOLDOWN
|
||||
own:addMoney(info.price)
|
||||
notifyPlayer(visitor, "guestBonus", { amount = Locale.number(info.price) })
|
||||
else
|
||||
notifyPlayer(visitor, "guestAte")
|
||||
end
|
||||
elseif kind == "left" then
|
||||
guestAt[visitor] = nil
|
||||
if info.reason == "hungry" then
|
||||
notifyPlayer(visitor, "guestHungry")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function openNeighbor(slot: World.Slot)
|
||||
if not slotOwner[slot.index] and not neighbors[slot.index] then
|
||||
neighbors[slot.index] = Neighbor.open(slot, os.clock(), onGuestEvent)
|
||||
end
|
||||
end
|
||||
|
||||
local function closeNeighbor(index: number)
|
||||
local n = neighbors[index]
|
||||
neighbors[index] = nil
|
||||
if n then
|
||||
Neighbor.close(n)
|
||||
end
|
||||
end
|
||||
|
||||
-- 언어·마우스 회전·효과음 설정을 Player 속성으로 내보냅니다. Lang은 실제 화면 언어, LangSetting은 저장된 설정("" = 자동).
|
||||
local function applySettings(player: Player, data: any)
|
||||
player:SetAttribute("LangSetting", data.Lang)
|
||||
player:SetAttribute("Lang", Locale.resolve(data.Lang, player.LocaleId))
|
||||
player:SetAttribute("MouseLook", data.MouseLook ~= false)
|
||||
player:SetAttribute("Sfx", data.Sfx ~= false)
|
||||
end
|
||||
|
||||
-- 조리대 앞에 세웁니다.
|
||||
local function placeCharacter(player: Player, controller: PlotController.PlotController)
|
||||
local char = player.Character
|
||||
if not char then
|
||||
return
|
||||
end
|
||||
local root = char:WaitForChild("HumanoidRootPart", 5) :: BasePart?
|
||||
if not root then
|
||||
return
|
||||
end
|
||||
local refs = controller.slot.refs
|
||||
local pos = PlotBuilder.stallPoint(refs, { x = Floor.STOVE_FRONT.x, z = Floor.STOVE_FRONT.z + 4 })
|
||||
+ Vector3.new(0, 4, 0)
|
||||
local look = PlotBuilder.stallPoint(refs, Floor.STOVE_COOK)
|
||||
char:PivotTo(CFrame.lookAt(pos, Vector3.new(look.X, pos.Y, look.Z)))
|
||||
end
|
||||
|
||||
local function ownsPass(player: Player, passId: number): boolean
|
||||
if passId == 0 then
|
||||
return false
|
||||
end
|
||||
local ok, owns = pcall(function()
|
||||
return MarketplaceService:UserOwnsGamePassAsync(player.UserId, passId)
|
||||
end)
|
||||
return ok and owns == true
|
||||
end
|
||||
|
||||
-- 게임패스: 2배 수익, 무지개 이름, 유료 디자인
|
||||
local function checkPasses(player: Player, controller: PlotController.PlotController)
|
||||
if ownsPass(player, Products.DOUBLE_MONEY_PASS) then
|
||||
controller:setDouble(true)
|
||||
end
|
||||
if ownsPass(player, Products.RAINBOW_NAME_PASS) then
|
||||
controller:setRainbowOwned(true)
|
||||
end
|
||||
for _, d in Economy.DESIGNS do
|
||||
if d.pass and ownsPass(player, (Products :: any)[d.pass] or 0) then
|
||||
controller:setDesignOwned(d.id, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 가게 이름을 필터에 거쳐 모두에게 보이게 합니다. 필터가 실패하면 기본 이름을 씁니다.
|
||||
local function filterName(player: Player, raw: string): string?
|
||||
if raw == "" then
|
||||
return ""
|
||||
end
|
||||
local ok, shown = pcall(function()
|
||||
local result = TextService:FilterStringAsync(raw, player.UserId, Enum.TextFilterContext.PublicChat)
|
||||
return result:GetNonChatStringForBroadcastAsync()
|
||||
end)
|
||||
if not ok or typeof(shown) ~= "string" then
|
||||
return nil
|
||||
end
|
||||
return shown
|
||||
end
|
||||
|
||||
-- 이름 정리: 앞뒤 공백·줄바꿈 제거, 글자 수(UTF-8 글자 기준) 자르기
|
||||
local function cleanName(raw: any): string?
|
||||
if typeof(raw) ~= "string" then
|
||||
return nil
|
||||
end
|
||||
local s = string.gsub(raw, "[%c]", " ")
|
||||
s = string.match(s, "^%s*(.-)%s*$") or ""
|
||||
if utf8.len(s) == nil then
|
||||
return nil
|
||||
end
|
||||
if (utf8.len(s) :: number) > Economy.NAME_MAX then
|
||||
local cut = utf8.offset(s, Economy.NAME_MAX + 1)
|
||||
s = string.sub(s, 1, (cut or #s + 1) - 1)
|
||||
end
|
||||
return s
|
||||
end
|
||||
|
||||
local function rename(player: Player, controller: PlotController.PlotController, raw: any)
|
||||
local name = cleanName(raw)
|
||||
if name == nil then
|
||||
controller:notify("nameRejected")
|
||||
return
|
||||
end
|
||||
local shown = filterName(player, name)
|
||||
if shown == nil or (name ~= "" and string.match(shown, "^[#%s]*$")) then
|
||||
controller:notify("nameRejected")
|
||||
return
|
||||
end
|
||||
if controllers[player] ~= controller then
|
||||
return
|
||||
end
|
||||
controller:setShopName(name, shown)
|
||||
controller:notify("renamed")
|
||||
end
|
||||
|
||||
-- 게임 주인(개발자)만 쓰는 테스트 버튼. 결제 없이 기능을 확인할 수 있게 합니다.
|
||||
local function isDev(player: Player): boolean
|
||||
return game.CreatorType == Enum.CreatorType.User and player.UserId == game.CreatorId
|
||||
end
|
||||
|
||||
local function makeController(player: Player, slot: World.Slot, data: any): PlotController.PlotController
|
||||
return PlotController.new(slot, player, {
|
||||
userId = player.UserId,
|
||||
displayName = player.DisplayName,
|
||||
data = data,
|
||||
now = os.clock(),
|
||||
notify = function(key, args)
|
||||
notifyPlayer(player, key, args)
|
||||
end,
|
||||
guestEvent = onGuestEvent,
|
||||
})
|
||||
end
|
||||
|
||||
local function nearVisit(player: Player, target: PlotController.PlotController): boolean
|
||||
local char = player.Character
|
||||
local root = char and char:FindFirstChild("HumanoidRootPart") :: BasePart?
|
||||
return root ~= nil and (root.Position - target.slot.refs.visit.Position).Magnitude <= VISIT_RANGE
|
||||
end
|
||||
|
||||
-- 다른 가게 입구에서 "손님으로 들어가기"를 눌렀을 때
|
||||
local function visit(player: Player, index: any)
|
||||
if typeof(index) ~= "number" then
|
||||
return
|
||||
end
|
||||
local own = controllers[player]
|
||||
local target = controllerAt(index)
|
||||
local char = player.Character
|
||||
if not own or not target or target == own or not char or not nearVisit(player, target) then
|
||||
return
|
||||
end
|
||||
local prev = guestAt[player]
|
||||
if prev then
|
||||
prev:releaseGuestByUser(player.UserId)
|
||||
end
|
||||
if not target:addGuest(player.UserId, char) then
|
||||
own:notify("visitFull")
|
||||
return
|
||||
end
|
||||
guestAt[player] = target
|
||||
own:notify("guestSeated")
|
||||
target:notify("guestArrived", { name = player.DisplayName })
|
||||
end
|
||||
|
||||
-- 결제 테스트 모드(게임 주인만)
|
||||
local function isFree(player: Player): boolean
|
||||
return devFree[player] == true and isDev(player)
|
||||
end
|
||||
|
||||
-- 개발자 상품 사기: 결제 테스트 모드면 결제 창 없이 바로 지급
|
||||
local function buyProduct(player: Player, controller: PlotController.PlotController, id: number)
|
||||
if id == 0 then
|
||||
return
|
||||
end
|
||||
if isFree(player) then
|
||||
grantProduct(player, controller, id)
|
||||
else
|
||||
MarketplaceService:PromptProductPurchase(player, id)
|
||||
end
|
||||
end
|
||||
|
||||
-- 게임패스 사기: 결제 테스트 모드면 결제 창 없이 이번 접속 동안 가진 것으로
|
||||
local function buyPass(player: Player, passId: number)
|
||||
if passId == 0 then
|
||||
return
|
||||
end
|
||||
if isFree(player) then
|
||||
onPassBought(player, passId, true)
|
||||
else
|
||||
MarketplaceService:PromptGamePassPurchase(player, passId)
|
||||
end
|
||||
end
|
||||
|
||||
-- 홍보 실행(광고 보상 또는 무료). 데려온 수를 돌려줍니다.
|
||||
local function doPromote(controller: PlotController.PlotController): number
|
||||
local sources = {}
|
||||
for _, c in allControllers() do
|
||||
if c ~= controller then
|
||||
table.insert(sources, c)
|
||||
end
|
||||
end
|
||||
local got, why = Transfers.promote(controller, sources)
|
||||
if got > 0 then
|
||||
controller:notify("promoted", { n = got })
|
||||
else
|
||||
controller:notify(if why == "full" then "promoteFull" else "promoteNone")
|
||||
end
|
||||
return got
|
||||
end
|
||||
|
||||
local function promote(player: Player, controller: PlotController.PlotController, arg: any)
|
||||
local now = workspace:GetServerTimeNow()
|
||||
local wantAd = typeof(arg) == "table" and arg.ad == true
|
||||
if wantAd then
|
||||
if Products.PROMOTE_AD_PRODUCT == 0 or adBusy[player] then
|
||||
controller:notify("adUnavailable")
|
||||
return
|
||||
end
|
||||
if now < controller.promoteAdAt then
|
||||
controller:notify("promoteWait", { sec = math.ceil(controller.promoteAdAt - now) })
|
||||
return
|
||||
end
|
||||
-- 광고를 보기 전에 데려올 손님이 있는지 먼저 봅니다(보상을 못 주는 광고를 보여 주지 않게).
|
||||
local any = false
|
||||
for _, c in allControllers() do
|
||||
if c ~= controller then
|
||||
for _, cust in c.shop.customers do
|
||||
if cust.state ~= "eating" and not cust.guest then
|
||||
any = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if not any then
|
||||
controller:notify("promoteNone")
|
||||
return
|
||||
end
|
||||
if isFree(player) then
|
||||
-- 결제 테스트 모드: 광고 없이 광고 보상을 바로 줍니다.
|
||||
grantProduct(player, controller, Products.PROMOTE_AD_PRODUCT)
|
||||
return
|
||||
end
|
||||
adBusy[player] = true
|
||||
task.spawn(function()
|
||||
local ok, result = pcall(function()
|
||||
local reward = AdService:CreateAdRewardFromDevProductId(Products.PROMOTE_AD_PRODUCT)
|
||||
return AdService:ShowRewardedVideoAdAsync(player, reward)
|
||||
end)
|
||||
adBusy[player] = nil
|
||||
-- 보상은 ProcessReceipt(광고 보상 채널)로 옵니다. 광고가 안 나왔으면 알립니다.
|
||||
if not ok or result ~= Enum.ShowAdResult.ShowCompleted then
|
||||
controller:notify("adUnavailable")
|
||||
end
|
||||
end)
|
||||
return
|
||||
end
|
||||
if now < controller.promoteAt then
|
||||
controller:notify("promoteWait", { sec = math.ceil(controller.promoteAt - now) })
|
||||
return
|
||||
end
|
||||
if doPromote(controller) > 0 then
|
||||
controller.promoteAt = now + Economy.PROMOTE_COOLDOWN
|
||||
controller:sync()
|
||||
end
|
||||
end
|
||||
|
||||
-- 손님 쫓아내기 실행(산 횟수 1개 사용). 성공하면 true
|
||||
local function doKick(player: Player, controller: PlotController.PlotController, index: number): boolean
|
||||
local victim = controllerAt(index)
|
||||
if not victim or victim == controller then
|
||||
controller:notify("kickOwn")
|
||||
return false
|
||||
end
|
||||
local now = workspace:GetServerTimeNow()
|
||||
if now < victim.shieldUntil then
|
||||
controller:notify("shielded")
|
||||
return false
|
||||
end
|
||||
local kicked, got = Transfers.kick(controller, victim)
|
||||
if kicked == 0 then
|
||||
controller:notify("promoteNone")
|
||||
return false
|
||||
end
|
||||
controller.data.KickCredits = math.max(0, (controller.data.KickCredits or 0) - 1)
|
||||
victim.shieldUntil = now + Economy.KICK_SHIELD
|
||||
victim.slot.model:SetAttribute("ShieldUntil", victim.shieldUntil)
|
||||
controller:notify("kicked", { n = got })
|
||||
victim:notify("kickedBy", { name = player.DisplayName })
|
||||
controller:sync()
|
||||
return true
|
||||
end
|
||||
|
||||
local function kick(player: Player, controller: PlotController.PlotController, index: any)
|
||||
if typeof(index) ~= "number" then
|
||||
return
|
||||
end
|
||||
local victim = controllerAt(index)
|
||||
if not victim or victim == controller then
|
||||
controller:notify("kickOwn")
|
||||
return
|
||||
end
|
||||
if not nearVisit(player, victim) then
|
||||
return
|
||||
end
|
||||
if workspace:GetServerTimeNow() < victim.shieldUntil then
|
||||
controller:notify("shielded")
|
||||
return
|
||||
end
|
||||
if (controller.data.KickCredits or 0) > 0 then
|
||||
doKick(player, controller, index)
|
||||
elseif Products.KICK_PRODUCT ~= 0 then
|
||||
kickTarget[player] = { index = index, expires = os.clock() + KICK_TARGET_TTL }
|
||||
buyProduct(player, controller, Products.KICK_PRODUCT)
|
||||
end
|
||||
end
|
||||
|
||||
local function resetData(data: any)
|
||||
data.Money = 0
|
||||
data.Bought = 0
|
||||
data.Levels = Economy.emptyLevels()
|
||||
data.Layout = Floor.default()
|
||||
data.Staff = {}
|
||||
data.TutorialDone = false
|
||||
data.Served = 0
|
||||
data.Earned = 0
|
||||
data.RushLeft = 0
|
||||
data.Design = "Basic"
|
||||
end
|
||||
|
||||
local function onPlayerAdded(player: Player)
|
||||
local profile = Data.load(player)
|
||||
if not profile then
|
||||
if player.Parent == Players then
|
||||
player:Kick(Locale.t("ko", "saveFail") .. " / " .. Locale.t("en", "saveFail"))
|
||||
end
|
||||
return
|
||||
end
|
||||
local slot = freeSlot()
|
||||
if not slot then
|
||||
Data.release(player)
|
||||
player:Kick("서버가 꽉 찼어요 / Server is full")
|
||||
return
|
||||
end
|
||||
closeNeighbor(slot.index)
|
||||
slotOwner[slot.index] = player
|
||||
local data = profile.Data
|
||||
applySettings(player, data)
|
||||
local controller = makeController(player, slot, data)
|
||||
controllers[player] = controller
|
||||
player:SetAttribute("Dev", isDev(player))
|
||||
player:SetAttribute("Ready", true)
|
||||
|
||||
player.CharacterAdded:Connect(function()
|
||||
task.defer(function()
|
||||
local current = controllers[player]
|
||||
if current then
|
||||
placeCharacter(player, current)
|
||||
current:rebuildHand()
|
||||
end
|
||||
end)
|
||||
end)
|
||||
if player.Character then
|
||||
task.defer(placeCharacter, player, controller)
|
||||
end
|
||||
task.spawn(checkPasses, player, controller)
|
||||
task.spawn(function()
|
||||
local raw = data.ShopName or ""
|
||||
if raw ~= "" then
|
||||
local shown = filterName(player, raw)
|
||||
if shown and controllers[player] == controller then
|
||||
controller:setShopName(raw, shown)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local function onPlayerRemoving(player: Player)
|
||||
local controller = controllers[player]
|
||||
controllers[player] = nil
|
||||
actionTimes[player] = nil
|
||||
bonusAt[player] = nil
|
||||
kickTarget[player] = nil
|
||||
adBusy[player] = nil
|
||||
devFree[player] = nil
|
||||
local host = guestAt[player]
|
||||
if host then
|
||||
host:releaseGuestByUser(player.UserId)
|
||||
end
|
||||
guestAt[player] = nil
|
||||
if controller then
|
||||
controller.data.RushLeft = controller.shop.rushLeft
|
||||
slotOwner[controller.slot.index] = nil
|
||||
controller:destroy()
|
||||
-- 빈 부지에는 다시 이웃 가게를 엽니다.
|
||||
openNeighbor(controller.slot)
|
||||
end
|
||||
Data.release(player)
|
||||
end
|
||||
|
||||
-- 초당 10회 넘는 요청은 무시합니다.
|
||||
local function allowAction(player: Player): boolean
|
||||
local now = os.clock()
|
||||
local list = actionTimes[player] or {}
|
||||
actionTimes[player] = list
|
||||
while list[1] and now - list[1] > 1 do
|
||||
table.remove(list, 1)
|
||||
end
|
||||
if #list >= 10 then
|
||||
return false
|
||||
end
|
||||
table.insert(list, now)
|
||||
return true
|
||||
end
|
||||
|
||||
local function num(v: any): number?
|
||||
if typeof(v) == "number" and v == v and math.abs(v) < 1e6 then
|
||||
return v
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function onAction(player: Player, kind: any, arg: any)
|
||||
if typeof(kind) ~= "string" or not allowAction(player) then
|
||||
return
|
||||
end
|
||||
local controller = controllers[player]
|
||||
if not controller then
|
||||
return
|
||||
end
|
||||
if kind == "cookStart" or kind == "cook" then
|
||||
-- 요리 창: cookStart(메뉴 고름) → cook(다 만듦). 서버가 고른 메뉴·주문·손 자리·조리대 거리·
|
||||
-- 조리 과정 최소 시간을 다시 검사합니다(PlotController.startCook/finishCook).
|
||||
local now = os.clock()
|
||||
local menu = if typeof(arg) == "string" and Economy.MENUS[arg] then arg else nil
|
||||
local char = player.Character
|
||||
local root = char and char:FindFirstChild("HumanoidRootPart") :: BasePart?
|
||||
local near = not root or (root.Position - controller.slot.refs.stove.Position).Magnitude <= COOK_RANGE
|
||||
if not menu or not near then
|
||||
controller.cookSession = nil
|
||||
elseif kind == "cookStart" then
|
||||
controller:startCook(menu, now)
|
||||
else
|
||||
controller:finishCook(menu, now)
|
||||
end
|
||||
elseif kind == "upgrade" then
|
||||
if typeof(arg) == "string" and Economy.track(arg) then
|
||||
controller:upgrade(arg)
|
||||
end
|
||||
elseif kind == "buyOffer" then
|
||||
if typeof(arg) == "string" and (arg == "Seat" or arg == "Table" or Economy.track(arg)) then
|
||||
controller:buyOffer(arg)
|
||||
end
|
||||
elseif kind == "buySeat" then
|
||||
controller:buySeat(num(arg))
|
||||
elseif kind == "buyTable" then
|
||||
controller:buyTable()
|
||||
elseif kind == "buyDecor" then
|
||||
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)
|
||||
if i and x and z then
|
||||
controller:move({ kind = arg.kind, i = i, x = x, z = z, f = num(arg.f), r = num(arg.r) })
|
||||
end
|
||||
end
|
||||
elseif kind == "hire" or kind == "fire" then
|
||||
if typeof(arg) == "string" and Economy.role(arg) then
|
||||
if kind == "hire" then
|
||||
controller:hire(arg)
|
||||
else
|
||||
controller:fire(arg)
|
||||
end
|
||||
end
|
||||
elseif kind == "rename" then
|
||||
task.spawn(rename, player, controller, arg)
|
||||
elseif kind == "rainbow" then
|
||||
if typeof(arg) == "boolean" then
|
||||
if controller.rainbowOwned then
|
||||
controller:setRainbow(arg)
|
||||
else
|
||||
buyPass(player, Products.RAINBOW_NAME_PASS)
|
||||
end
|
||||
end
|
||||
elseif kind == "nameColor" then
|
||||
if typeof(arg) == "number" and arg == math.floor(arg) and (arg == 0 or Economy.NAME_COLORS[arg]) then
|
||||
controller:setNameColor(arg)
|
||||
end
|
||||
elseif kind == "remove" then
|
||||
-- 꾸미기에서 지우기: { kind = "table"|"chair"|"decor", i }
|
||||
if typeof(arg) == "table" and (arg.kind == "table" or arg.kind == "chair" or arg.kind == "decor") then
|
||||
local i = num(arg.i)
|
||||
if i and i == math.floor(i) then
|
||||
local itemKind: string = arg.kind
|
||||
controller:removeItem(itemKind, i)
|
||||
end
|
||||
end
|
||||
elseif kind == "design" then
|
||||
if typeof(arg) == "string" then
|
||||
local d = Economy.design(arg)
|
||||
local ok, why = controller:setDesign(arg)
|
||||
if not ok and why == "locked" and d and d.pass then
|
||||
buyPass(player, (Products :: any)[d.pass] or 0)
|
||||
end
|
||||
end
|
||||
elseif kind == "promote" then
|
||||
promote(player, controller, arg)
|
||||
elseif kind == "kick" then
|
||||
kick(player, controller, arg)
|
||||
elseif kind == "rush" then
|
||||
buyProduct(player, controller, Products.RUSH_PRODUCT)
|
||||
elseif kind == "visit" then
|
||||
visit(player, arg)
|
||||
elseif kind == "lang" then
|
||||
-- "" = 계정 언어 자동
|
||||
if typeof(arg) == "string" and (arg == "" or table.find(Locale.LANGS, arg)) then
|
||||
controller.data.Lang = arg
|
||||
applySettings(player, controller.data)
|
||||
end
|
||||
elseif kind == "mouseLook" or kind == "sfx" then
|
||||
if typeof(arg) == "boolean" then
|
||||
controller.data[if kind == "sfx" then "Sfx" else "MouseLook"] = arg
|
||||
applySettings(player, controller.data)
|
||||
end
|
||||
elseif kind == "pass" then
|
||||
-- 이미 가진 게임패스(로블록스 소유 확인이 늦었거나, 개발자 테스트로 꺼 둔 경우)면 결제 창 대신 바로 켭니다.
|
||||
if Products.DOUBLE_MONEY_PASS ~= 0 and controller.shop.moneyMult == 1 and isFree(player) then
|
||||
buyPass(player, Products.DOUBLE_MONEY_PASS)
|
||||
elseif Products.DOUBLE_MONEY_PASS ~= 0 and controller.shop.moneyMult == 1 then
|
||||
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)
|
||||
elseif kind == "dev_double" and isDev(player) then
|
||||
controller:setDouble(controller.shop.moneyMult == 1)
|
||||
elseif kind == "dev_free" and isDev(player) then
|
||||
-- 결제 테스트 모드: 켜면 게임패스를 안 가진 상태로 바꾸고(사는 흐름을 볼 수 있게) 로벅스 버튼이 바로 지급됩니다.
|
||||
-- 끄면 실제로 가진 게임패스로 되돌립니다.
|
||||
local on = not devFree[player]
|
||||
devFree[player] = on
|
||||
player:SetAttribute("DevFree", on)
|
||||
controller:setDouble(false)
|
||||
controller:setRainbowOwned(false)
|
||||
for _, d in Economy.DESIGNS do
|
||||
if d.pass then
|
||||
controller:setDesignOwned(d.id, false)
|
||||
end
|
||||
end
|
||||
if not on then
|
||||
task.spawn(checkPasses, player, controller)
|
||||
end
|
||||
controller:notify(if on then "devFreeOn" else "devFreeOff")
|
||||
elseif kind == "dev_reset" and isDev(player) then
|
||||
resetData(controller.data)
|
||||
local slot = controller.slot
|
||||
-- 산 게임패스(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()
|
||||
fresh:notify("devResetDone")
|
||||
elseif kind == "boost" then
|
||||
buyProduct(player, controller, Products.MONEY_BOOST_PRODUCT)
|
||||
end
|
||||
end
|
||||
|
||||
-- 개발자 상품 지급(결제 1회 = 지급 1회). 광고 보상도 여기로 옵니다.
|
||||
function Game.processReceipt(info: { [string]: any }): Enum.ProductPurchaseDecision
|
||||
local player = Players:GetPlayerByUserId(info.PlayerId)
|
||||
local profile = player and Data.get(player)
|
||||
local controller = player and controllers[player]
|
||||
local decision = Receipts.process(profile, tostring(info.PurchaseId), function()
|
||||
if not controller or not player then
|
||||
return false
|
||||
end
|
||||
return grantProduct(player, controller, info.ProductId)
|
||||
end)
|
||||
if decision == "Granted" then
|
||||
return Enum.ProductPurchaseDecision.PurchaseGranted
|
||||
end
|
||||
return Enum.ProductPurchaseDecision.NotProcessedYet
|
||||
end
|
||||
|
||||
-- 개발자 상품 하나를 지급합니다(결제 확인 뒤, 또는 개발자 결제 테스트 모드). 지급했으면 true
|
||||
function grantProduct(player: Player, controller: PlotController.PlotController, id: number): boolean
|
||||
do
|
||||
if id == Products.MONEY_BOOST_PRODUCT then
|
||||
local amount = Economy.boostAmount(controller.shop.stats)
|
||||
controller:addMoney(amount)
|
||||
controller:notify("boostGot", { amount = Locale.number(amount) })
|
||||
return true
|
||||
elseif id == Products.RUSH_PRODUCT and id ~= 0 then
|
||||
controller:addRush(Economy.RUSH_SECONDS)
|
||||
controller:notify("rushOn", { min = math.floor(Economy.RUSH_SECONDS / 60) })
|
||||
return true
|
||||
elseif id == Products.KICK_PRODUCT and id ~= 0 then
|
||||
-- 횟수를 먼저 주고, 결제 창을 띄운 대상이 있으면 바로 씁니다.
|
||||
controller.data.KickCredits = (controller.data.KickCredits or 0) + 1
|
||||
local t = kickTarget[player]
|
||||
kickTarget[player] = nil
|
||||
if t and os.clock() <= t.expires then
|
||||
local target = player
|
||||
task.defer(function()
|
||||
local c = controllers[target]
|
||||
if c then
|
||||
doKick(target, c, t.index)
|
||||
end
|
||||
end)
|
||||
end
|
||||
controller:sync()
|
||||
return true
|
||||
elseif id == Products.PROMOTE_AD_PRODUCT and id ~= 0 then
|
||||
-- 광고 보상: 데려올 손님이 없으면 짧은 손님 러시로 대신 줍니다.
|
||||
if doPromote(controller) == 0 then
|
||||
controller:addRush(60)
|
||||
end
|
||||
controller.promoteAdAt = workspace:GetServerTimeNow() + Economy.PROMOTE_AD_COOLDOWN
|
||||
controller:sync()
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function onPassBought(player: Player, passId: number, purchased: boolean)
|
||||
local controller = controllers[player]
|
||||
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
|
||||
controller:setDouble(true)
|
||||
elseif passId == Products.RAINBOW_NAME_PASS then
|
||||
controller:setRainbowOwned(true)
|
||||
controller:setRainbow(true)
|
||||
else
|
||||
for _, d in Economy.DESIGNS do
|
||||
if d.pass and (Products :: any)[d.pass] == passId then
|
||||
controller:setDesignOwned(d.id, true)
|
||||
controller:setDesign(d.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Game.start()
|
||||
slots = World.build()
|
||||
PlotBuilder.buildTemplates()
|
||||
task.spawn(function()
|
||||
Npc.preload()
|
||||
Npc.preloadCustomers()
|
||||
end)
|
||||
for _, slot in slots do
|
||||
openNeighbor(slot)
|
||||
end
|
||||
|
||||
Players.PlayerAdded:Connect(onPlayerAdded)
|
||||
Players.PlayerRemoving:Connect(onPlayerRemoving)
|
||||
for _, p in Players:GetPlayers() do
|
||||
task.spawn(onPlayerAdded, p)
|
||||
end
|
||||
ActionRemote.OnServerEvent:Connect(onAction)
|
||||
|
||||
MarketplaceService.ProcessReceipt = Game.processReceipt
|
||||
MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPassBought)
|
||||
|
||||
local acc = 0
|
||||
RunService.Heartbeat:Connect(function(dt)
|
||||
acc += dt
|
||||
if acc < 0.1 then
|
||||
return
|
||||
end
|
||||
acc = 0
|
||||
local now = os.clock()
|
||||
for _, c in controllers do
|
||||
c:update(now)
|
||||
end
|
||||
for _, n in neighbors do
|
||||
Neighbor.update(n, now)
|
||||
end
|
||||
end)
|
||||
print(`[Bunsik] server ready, {#Economy.TRACKS} upgrade tracks, {#slots} plots`)
|
||||
end
|
||||
|
||||
-- 테스트용: 홍보·쫓아내기 실행을 바로 부릅니다(원격 테스트에서 가짜 플레이어로).
|
||||
Game._doPromote = doPromote
|
||||
Game._cleanName = cleanName
|
||||
|
||||
return Game
|
||||
2
bunsik-tycoon/src/server/Main.server.luau
Normal file
@@ -0,0 +1,2 @@
|
||||
-- 서버 진입점. 실제 로직은 Game 모듈에 있습니다(원격 테스트에서 모듈을 직접 불러 씁니다).
|
||||
require(script.Parent.Game).start()
|
||||
87
bunsik-tycoon/src/server/Neighbor.luau
Normal file
@@ -0,0 +1,87 @@
|
||||
--!strict
|
||||
-- 이웃 가게(NPC 가게): 플레이어가 없는 부지에 미리 키워 둔 가게를 열어 거리가 비어 보이지 않게 합니다.
|
||||
-- 사장님 NPC가 알아서 요리하고 서빙합니다. 플레이어는 손님으로 들어가 먹어 볼 수 있습니다(돈 보상은 없음).
|
||||
-- 진짜 플레이어가 들어오면 그 부지의 이웃 가게는 닫힙니다.
|
||||
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Shop = require(ReplicatedStorage.Shared.Shop)
|
||||
|
||||
local Data = require(script.Parent.Data)
|
||||
local Npc = require(script.Parent.Npc)
|
||||
local PlotBuilder = require(script.Parent.PlotBuilder)
|
||||
local PlotController = require(script.Parent.PlotController)
|
||||
|
||||
local Neighbor = {}
|
||||
|
||||
-- 부지 번호별 이웃 가게 크기(산 업그레이드 수). 처음 온 플레이어보다 큰 가게가 많아서 "나도 저렇게 키우고 싶다"를 노립니다.
|
||||
Neighbor.LEVELS = { 14, 7, 20, 10, 17, 4 }
|
||||
Neighbor.SERVE_GAP = 1 -- 사장님이 접시를 내려놓는 간격(초)
|
||||
Neighbor.DESIGNS = { "Mint", "Basic", "Brick", "Basic", "Mint", "Basic" } -- 무료 디자인만
|
||||
|
||||
export type Neighbor = {
|
||||
controller: PlotController.PlotController,
|
||||
busyUntil: number,
|
||||
}
|
||||
|
||||
export type Slot = PlotController.Slot
|
||||
|
||||
function Neighbor.open(slot: Slot, now: number, guestEvent: PlotController.GuestEvent?): Neighbor
|
||||
local owner = Instance.new("Folder")
|
||||
owner.Name = "Neighbor" .. slot.index
|
||||
-- 예전 한 줄 업그레이드 수로 크기를 정하고 새 구조(갈래·배치·알바)로 옮깁니다.
|
||||
local data: any = {
|
||||
Money = 1e12, -- 시급을 못 내서 쉬는 일이 없게
|
||||
Bought = Neighbor.LEVELS[slot.index] or 10,
|
||||
TutorialDone = true,
|
||||
Served = 0,
|
||||
Earned = 0,
|
||||
Design = Neighbor.DESIGNS[slot.index] or "Basic",
|
||||
}
|
||||
Data.migrate(data, 1)
|
||||
local controller = PlotController.new(slot, owner, {
|
||||
userId = -slot.index,
|
||||
displayName = "",
|
||||
data = data,
|
||||
now = now,
|
||||
npc = slot.index,
|
||||
guestEvent = guestEvent,
|
||||
})
|
||||
-- 포장마차 뒤에 서 있는 사장님
|
||||
local pos = PlotBuilder.stallPoint(slot.refs, { x = 3, z = -4 })
|
||||
local look = PlotBuilder.stallPoint(slot.refs, { x = 3, z = 10 })
|
||||
local keeper = Npc.spawn(slot.refs.dynamic, CFrame.new(pos), controller.rng, Color3.fromRGB(240, 110, 40))
|
||||
keeper.model.Name = "Keeper"
|
||||
keeper.root.CFrame = Npc.standCFrame(keeper, pos, look)
|
||||
return { controller = controller, busyUntil = now }
|
||||
end
|
||||
|
||||
-- 0.1초마다 부릅니다. 손님 처리 + 사장님 봇(만들기 → 내려놓기)
|
||||
function Neighbor.update(n: Neighbor, now: number)
|
||||
local c = n.controller
|
||||
c:update(now)
|
||||
if c.destroyed or now < n.busyUntil then
|
||||
return
|
||||
end
|
||||
local shop = c.shop
|
||||
if (shop.staff.Cook or 0) > 0 then
|
||||
c:pickup()
|
||||
elseif not Shop.handFull(shop) and Shop.nextCookMenu(shop) then
|
||||
c:cook()
|
||||
n.busyUntil = now + shop.stats.cook
|
||||
return
|
||||
end
|
||||
for id, cust in shop.customers do
|
||||
if cust.state == "waiting" and table.find(shop.hand, cust.menu) then
|
||||
c:serve(id)
|
||||
n.busyUntil = now + Neighbor.SERVE_GAP
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Neighbor.close(n: Neighbor)
|
||||
n.controller:destroy()
|
||||
end
|
||||
|
||||
return Neighbor
|
||||
372
bunsik-tycoon/src/server/Npc.luau
Normal file
@@ -0,0 +1,372 @@
|
||||
--!strict
|
||||
-- 손님·알바생 NPC. 로블록스 기본 아바타(R15)를 서버 시작 때 몇 개 만들어 두고 복제해서 씁니다.
|
||||
-- 물리로 걷게 하면 테이블에 걸리거나 늦게 도착하므로, 몸을 고정(Anchored)하고 트윈으로 옮깁니다.
|
||||
|
||||
local Players = game:GetService("Players")
|
||||
local RunService = game:GetService("RunService")
|
||||
local TweenService = game:GetService("TweenService")
|
||||
|
||||
local NpcLooks = require(script.Parent.NpcLooks)
|
||||
|
||||
local Npc = {}
|
||||
|
||||
local ANIM: { [string]: string } = {
|
||||
walk = "rbxassetid://507777826",
|
||||
idle = "rbxassetid://507766388",
|
||||
sit = "rbxassetid://2506281703",
|
||||
}
|
||||
|
||||
local SKIN = {
|
||||
Color3.fromRGB(255, 220, 190),
|
||||
Color3.fromRGB(240, 200, 160),
|
||||
Color3.fromRGB(205, 160, 120),
|
||||
Color3.fromRGB(150, 105, 75),
|
||||
}
|
||||
local SHIRT = {
|
||||
Color3.fromRGB(230, 70, 70),
|
||||
Color3.fromRGB(70, 130, 230),
|
||||
Color3.fromRGB(250, 200, 60),
|
||||
Color3.fromRGB(90, 190, 110),
|
||||
Color3.fromRGB(180, 100, 220),
|
||||
Color3.fromRGB(255, 150, 190),
|
||||
Color3.fromRGB(250, 250, 250),
|
||||
}
|
||||
local PANTS = {
|
||||
Color3.fromRGB(40, 50, 90),
|
||||
Color3.fromRGB(60, 60, 60),
|
||||
Color3.fromRGB(120, 90, 60),
|
||||
Color3.fromRGB(30, 90, 140),
|
||||
}
|
||||
|
||||
local template: Model? = nil
|
||||
local loading = false
|
||||
|
||||
local function makeBlockNpc(): Model
|
||||
-- 아바타를 못 불러올 때 쓰는 간단한 블록 사람
|
||||
local m = Instance.new("Model")
|
||||
m.Name = "Npc"
|
||||
local root = Instance.new("Part")
|
||||
root.Name = "HumanoidRootPart"
|
||||
root.Size = Vector3.new(2, 2, 1)
|
||||
root.Transparency = 1
|
||||
root.Parent = m
|
||||
local function piece(name: string, size: Vector3, offset: Vector3)
|
||||
local p = Instance.new("Part")
|
||||
p.Name = name
|
||||
p.Size = size
|
||||
p.CFrame = CFrame.new(offset)
|
||||
p.Parent = m
|
||||
end
|
||||
piece("UpperTorso", Vector3.new(2, 2, 1), Vector3.zero)
|
||||
piece("Head", Vector3.new(1.2, 1.2, 1.2), Vector3.new(0, 1.6, 0))
|
||||
piece("LeftUpperLeg", Vector3.new(0.9, 2, 1), Vector3.new(-0.5, -2, 0))
|
||||
piece("RightUpperLeg", Vector3.new(0.9, 2, 1), Vector3.new(0.5, -2, 0))
|
||||
m.PrimaryPart = root
|
||||
local h = Instance.new("Humanoid")
|
||||
h.Parent = m
|
||||
for _, p in m:GetChildren() do
|
||||
if p:IsA("BasePart") and p ~= root then
|
||||
local w = Instance.new("WeldConstraint")
|
||||
w.Part0 = root
|
||||
w.Part1 = p
|
||||
w.Parent = p
|
||||
end
|
||||
end
|
||||
return m
|
||||
end
|
||||
|
||||
-- 서버 시작 때 한 번 호출. 실패하면 블록 사람으로 대신합니다.
|
||||
function Npc.preload()
|
||||
if template then
|
||||
return
|
||||
end
|
||||
if loading then
|
||||
-- 다른 곳에서 이미 만드는 중이면 끝날 때까지 기다립니다.
|
||||
while loading do
|
||||
task.wait()
|
||||
end
|
||||
return
|
||||
end
|
||||
loading = true
|
||||
local ok, model = pcall(function()
|
||||
local desc = Instance.new("HumanoidDescription")
|
||||
return Players:CreateHumanoidModelFromDescription(desc, Enum.HumanoidRigType.R15)
|
||||
end)
|
||||
if ok and model then
|
||||
template = model
|
||||
else
|
||||
warn("[Bunsik] NPC 아바타 생성 실패, 블록 NPC 사용:", model)
|
||||
template = makeBlockNpc()
|
||||
end
|
||||
loading = false
|
||||
end
|
||||
|
||||
local function pick<T>(list: { T }, rng: Random): T
|
||||
return list[rng:NextInteger(1, #list)]
|
||||
end
|
||||
|
||||
local function colorize(m: Model, rng: Random, shirtOverride: Color3?)
|
||||
local skin = pick(SKIN, rng)
|
||||
local shirt = shirtOverride or pick(SHIRT, rng)
|
||||
local pants = pick(PANTS, rng)
|
||||
for _, p in m:GetDescendants() do
|
||||
if p:IsA("BasePart") then
|
||||
local n = p.Name
|
||||
if n == "Head" or string.find(n, "Hand") then
|
||||
p.Color = skin
|
||||
elseif string.find(n, "Torso") or string.find(n, "UpperArm") or string.find(n, "LowerArm") then
|
||||
p.Color = shirt
|
||||
elseif string.find(n, "Leg") or string.find(n, "Foot") then
|
||||
p.Color = pants
|
||||
end
|
||||
end
|
||||
end
|
||||
local bc = m:FindFirstChildOfClass("BodyColors")
|
||||
if bc then
|
||||
bc:Destroy()
|
||||
end
|
||||
end
|
||||
|
||||
export type Handle = {
|
||||
model: Model,
|
||||
root: BasePart,
|
||||
humanoid: Humanoid,
|
||||
tracks: { [string]: AnimationTrack },
|
||||
tween: Tween?,
|
||||
}
|
||||
|
||||
-- 복제한 모형을 NPC로 준비합니다(충돌 끄기, 고정, 애니메이션).
|
||||
local function setup(m: Model, parent: Instance, cf: CFrame): Handle
|
||||
local root = m:FindFirstChild("HumanoidRootPart") :: BasePart
|
||||
for _, p in m:GetDescendants() do
|
||||
if p:IsA("BasePart") then
|
||||
p.CanCollide = false
|
||||
p.CanQuery = false
|
||||
p.CanTouch = false
|
||||
p.Massless = true
|
||||
end
|
||||
end
|
||||
root.Anchored = true
|
||||
local humanoid = m:FindFirstChildOfClass("Humanoid") :: Humanoid
|
||||
humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
|
||||
humanoid.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
|
||||
humanoid.BreakJointsOnDeath = false
|
||||
humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
|
||||
m:PivotTo(cf)
|
||||
m.Parent = parent
|
||||
local h: Handle = { model = m, root = root, humanoid = humanoid, tracks = {}, tween = nil }
|
||||
local animator: Animator = humanoid:FindFirstChildOfClass("Animator") or Instance.new("Animator")
|
||||
animator.Parent = humanoid
|
||||
for name: string, id: string in ANIM do
|
||||
local a = Instance.new("Animation")
|
||||
a.AnimationId = id
|
||||
local ok, track = pcall(function()
|
||||
return animator:LoadAnimation(a)
|
||||
end)
|
||||
if ok and track then
|
||||
track.Looped = true
|
||||
h.tracks[name] = track
|
||||
end
|
||||
end
|
||||
Npc.play(h, "idle")
|
||||
return h
|
||||
end
|
||||
|
||||
-- 알바생·사장님: 기본 몸에 색 옷
|
||||
function Npc.spawn(parent: Instance, cf: CFrame, rng: Random, shirt: Color3?): Handle
|
||||
if not template then
|
||||
Npc.preload()
|
||||
end
|
||||
local m = (template :: Model):Clone()
|
||||
m.Name = "Customer"
|
||||
colorize(m, rng, shirt)
|
||||
return setup(m, parent, cf)
|
||||
end
|
||||
|
||||
-- 손님 외형 템플릿(서버 시작 때 만들어 두고 복제). 사람은 무작위 조합 여러 벌, 동물은 프리셋마다 한 벌.
|
||||
local humanTemplates: { Model } = {}
|
||||
local animalTemplates: { { model: Model, rare: boolean } } = {}
|
||||
local looksLoading = false
|
||||
local HUMAN_VARIANTS = 12
|
||||
|
||||
local function buildLook(desc: HumanoidDescription, a: NpcLooks.Animal?): Model?
|
||||
local ok, m = pcall(function()
|
||||
return Players:CreateHumanoidModelFromDescription(desc, Enum.HumanoidRigType.R15)
|
||||
end)
|
||||
if not ok or not m then
|
||||
warn("[Bunsik] 손님 외형 생성 실패:", m)
|
||||
return nil
|
||||
end
|
||||
local model = m :: Model
|
||||
local animate = model:FindFirstChild("Animate")
|
||||
if animate then
|
||||
animate:Destroy()
|
||||
end
|
||||
local root = model:FindFirstChild("HumanoidRootPart") :: BasePart?
|
||||
if not root then
|
||||
return nil
|
||||
end
|
||||
root.Anchored = true
|
||||
model:PivotTo(CFrame.new(0, 500, 0)) -- 맵 밖 높은 곳
|
||||
model.Parent = workspace -- 장신구 위치가 맞춰지려면 Workspace 안에서 한 프레임 필요
|
||||
RunService.Heartbeat:Wait()
|
||||
if a then
|
||||
local head = model:FindFirstChild("Head") :: BasePart?
|
||||
local hum = model:FindFirstChildOfClass("Humanoid")
|
||||
if a.lowerHat and head and hum then
|
||||
-- 머리 위에 얹히는 동물 머리 모자를 목까지 내립니다.
|
||||
for _, acc in model:GetChildren() do
|
||||
if acc:IsA("Accessory") and acc.AccessoryType == Enum.AccessoryType.Hat then
|
||||
local h = acc:FindFirstChild("Handle") :: BasePart?
|
||||
local att = h and h:FindFirstChild("HatAttachment") :: Attachment?
|
||||
if h and att then
|
||||
local drop = (h.Position.Y - h.Size.Y / 2) - (head.Position.Y - head.Size.Y / 2)
|
||||
if drop > 0.1 then
|
||||
att.Position += Vector3.new(0, drop, 0)
|
||||
acc.Parent = nil
|
||||
hum:AddAccessory(acc)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if a.hideHead and head then
|
||||
head.Transparency = 1
|
||||
local face = head:FindFirstChildOfClass("Decal")
|
||||
if face then
|
||||
face:Destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
model.Parent = nil
|
||||
model.Name = "Customer"
|
||||
return model
|
||||
end
|
||||
|
||||
-- 서버 시작 때 한 번(백그라운드). 만드는 동안 온 손님은 기본 몸으로 옵니다.
|
||||
function Npc.preloadCustomers()
|
||||
if looksLoading or #humanTemplates > 0 then
|
||||
return
|
||||
end
|
||||
looksLoading = true
|
||||
local rng = Random.new(20261014)
|
||||
for _ = 1, HUMAN_VARIANTS do
|
||||
local m = buildLook(NpcLooks.human(rng), nil)
|
||||
if m then
|
||||
table.insert(humanTemplates, m)
|
||||
end
|
||||
end
|
||||
for _, a in NpcLooks.ANIMALS do
|
||||
local m = buildLook(NpcLooks.animal(a), a)
|
||||
if m then
|
||||
m:SetAttribute("Animal", a.name)
|
||||
table.insert(animalTemplates, { model = m, rare = a.rare == true })
|
||||
end
|
||||
end
|
||||
looksLoading = false
|
||||
end
|
||||
|
||||
function Npc.lookCount(): (number, number)
|
||||
return #humanTemplates, #animalTemplates
|
||||
end
|
||||
|
||||
-- 손님 NPC: 사람이 가장 많이(75%), 가끔 동물(동물 분장 사람은 더 드물게)
|
||||
function Npc.spawnCustomer(parent: Instance, cf: CFrame, rng: Random): Handle
|
||||
local chosen: Model? = nil
|
||||
if #animalTemplates > 0 and rng:NextNumber() < NpcLooks.ANIMAL_CHANCE then
|
||||
local list = {}
|
||||
for _, t in animalTemplates do
|
||||
if not t.rare or rng:NextNumber() < 0.4 then
|
||||
table.insert(list, t.model)
|
||||
end
|
||||
end
|
||||
if #list > 0 then
|
||||
chosen = list[rng:NextInteger(1, #list)]
|
||||
end
|
||||
end
|
||||
if not chosen and #humanTemplates > 0 then
|
||||
chosen = humanTemplates[rng:NextInteger(1, #humanTemplates)]
|
||||
end
|
||||
if not chosen then
|
||||
return Npc.spawn(parent, cf, rng)
|
||||
end
|
||||
return setup((chosen :: Model):Clone(), parent, cf)
|
||||
end
|
||||
|
||||
function Npc.play(h: Handle, name: string)
|
||||
for n, t in h.tracks do
|
||||
if n ~= name and t.IsPlaying then
|
||||
t:Stop(0.15)
|
||||
end
|
||||
end
|
||||
local t = h.tracks[name]
|
||||
if t and not t.IsPlaying then
|
||||
t:Play(0.15)
|
||||
end
|
||||
end
|
||||
|
||||
-- 높이(엉덩이 높이)를 맞춘 서 있는 자세 위치
|
||||
function Npc.standCFrame(h: Handle, floorPos: Vector3, lookAt: Vector3): CFrame
|
||||
local hip = h.humanoid.HipHeight + h.root.Size.Y / 2
|
||||
local pos = floorPos + Vector3.new(0, hip, 0)
|
||||
local look = Vector3.new(lookAt.X, pos.Y, lookAt.Z)
|
||||
if (look - pos).Magnitude < 0.01 then
|
||||
look = pos + Vector3.new(0, 0, -1)
|
||||
end
|
||||
return CFrame.lookAt(pos, look)
|
||||
end
|
||||
|
||||
-- 바닥 지점들을 차례로 걸어갑니다. 전체 걸리는 시간(초)을 맞춰 줍니다.
|
||||
function Npc.walk(h: Handle, points: { Vector3 }, duration: number, onDone: (() -> ())?)
|
||||
if h.tween then
|
||||
h.tween:Cancel()
|
||||
end
|
||||
local total = 0
|
||||
for i = 2, #points do
|
||||
total += (points[i] - points[i - 1]).Magnitude
|
||||
end
|
||||
Npc.play(h, "walk")
|
||||
local alive = true
|
||||
h.model.Destroying:Connect(function()
|
||||
alive = false
|
||||
end)
|
||||
task.spawn(function()
|
||||
for i = 2, #points do
|
||||
if not alive then
|
||||
return
|
||||
end
|
||||
local seg = (points[i] - points[i - 1]).Magnitude
|
||||
local t = if total > 0 then duration * seg / total else 0
|
||||
local target = Npc.standCFrame(h, points[i], points[i] + (points[i] - points[i - 1]))
|
||||
if t > 0.01 then
|
||||
local tw = TweenService:Create(h.root, TweenInfo.new(t, Enum.EasingStyle.Linear), { CFrame = target })
|
||||
h.tween = tw
|
||||
tw:Play()
|
||||
tw.Completed:Wait()
|
||||
else
|
||||
h.root.CFrame = target
|
||||
end
|
||||
end
|
||||
h.tween = nil
|
||||
if alive then
|
||||
Npc.play(h, "idle")
|
||||
if onDone then
|
||||
onDone()
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function Npc.sit(h: Handle, seat: CFrame)
|
||||
if h.tween then
|
||||
h.tween:Cancel()
|
||||
h.tween = nil
|
||||
end
|
||||
-- 앉은 자세에서 엉덩이가 의자 위에 오도록 살짝 낮춥니다.
|
||||
h.root.CFrame = seat * CFrame.new(0, h.root.Size.Y / 2 + 0.6, 0)
|
||||
if h.tracks.sit then
|
||||
Npc.play(h, "sit")
|
||||
end
|
||||
end
|
||||
|
||||
return Npc
|
||||
332
bunsik-tycoon/src/server/NpcLooks.luau
Normal file
@@ -0,0 +1,332 @@
|
||||
--!strict
|
||||
-- 손님 외형: 로블록스가 만든 옷·머리·얼굴 아이템과 동물 번들(모두 Creator Id 1, 2026-10-14 서버에서 확인).
|
||||
-- 사람은 무작위 조합, 동물은 정해 둔 프리셋입니다. 모두 R15라 걷기·앉기 애니메이션을 그대로 씁니다.
|
||||
-- 조사 기록: assets/npc_assets.md (도구: tools/npc_verify_avatars.luau)
|
||||
|
||||
local NpcLooks = {}
|
||||
|
||||
NpcLooks.ANIMAL_CHANCE = 0.25 -- 사람이 가장 많이(75%), 동물 손님은 가끔
|
||||
|
||||
-- 사람: 로블록스 제작 머리카락(HairAccessory, 문자열로 넣음). 7193…/9244…는 레이어드 머리카락(자동으로 머리에 맞춰짐)
|
||||
NpcLooks.HAIR = {
|
||||
63690008, -- Pal Hair
|
||||
451221329, -- True Blue Hair
|
||||
376526888, -- Straight Blonde Hair
|
||||
376524487, -- Blonde Spiked Hair
|
||||
376548738, -- Brown Charmer Hair
|
||||
376527350, -- Black Ponytail
|
||||
451220849, -- Lavender Updo
|
||||
62234425, -- Brown Hair
|
||||
2956239660, -- Belle Of Belfast Long Red Hair
|
||||
3814476174, -- Colorful Braids
|
||||
24910539, -- Pink Pigtails
|
||||
7193442167, -- Pony Tail - Black
|
||||
9244095135, -- Pony Tail - Blonde
|
||||
6993754725, -- Straight Bangs - Black
|
||||
7193448258, -- Wavy Middle Part - Brown
|
||||
9243987340, -- Short and Sleek - Blonde
|
||||
7193450455, -- Curly Afro - Black
|
||||
7193452166, -- Short Curls - Black
|
||||
9244148336, -- Braided Hair - Blonde
|
||||
430063008, -- Strawberry Ice Cream Hair
|
||||
727320877, -- Long Pastel Hair
|
||||
}
|
||||
-- 어린이용 귀여운 모자(HatAccessory, 35% 정도만 씌우기 추천)
|
||||
NpcLooks.HATS = {
|
||||
1028606, -- Red Baseball Cap
|
||||
607702162, -- Roblox Baseball Cap
|
||||
321570512, -- Chill Cap
|
||||
10911990, -- Propeller Beanie
|
||||
67291394, -- Unicorn Beanie
|
||||
3756496643, -- Pizza Time Cap
|
||||
100932329, -- Pink Flower Crown
|
||||
150337770, -- Spring Crown of Flowers
|
||||
118280079, -- Narwhal Beanie
|
||||
215724779, -- Robot Beanie
|
||||
116778296, -- Wide-brimmed Straw Cap
|
||||
833771553, -- Starbling Beanie
|
||||
3756447657, -- Lil' Kitty Cap
|
||||
439943629, -- Sleepy Mouse Cap
|
||||
1536057124, -- Spring Bunny Headband
|
||||
}
|
||||
-- 클래식 옷(Shirt / Pants), 모두 무료
|
||||
NpcLooks.SHIRTS = {
|
||||
144076358, -- Blue and Black Motorcycle Shirt
|
||||
607785314, -- ROBLOX Jacket
|
||||
398633584, -- Denim Jacket with White Hoodie
|
||||
144076436, -- Grey Striped Shirt with Denim Jacket
|
||||
398634295, -- Pastel Starburst Top with Gray Jacket
|
||||
3670737444, -- Roblox Shirt - Simple Pattern
|
||||
382538059, -- Green Jersey
|
||||
398635081, -- Blue Plaid Shirt
|
||||
382537702, -- Teal Shirt
|
||||
382537085, -- I <3 Pizza Shirt
|
||||
382538295, -- Guitar Tee with Black Jacket
|
||||
4047884939, -- My Favorite Pizza Shirt
|
||||
4047884046, -- Guitar Tee with Black Jacket
|
||||
4047886060, -- Purple and Teal Top
|
||||
}
|
||||
NpcLooks.PANTS = {
|
||||
144076760, -- Dark Green Jeans
|
||||
398634487, -- Beautiful You Jeans
|
||||
398633812, -- Black Jeans with White Shoes
|
||||
398635338, -- Ripped Skater Pants
|
||||
382537806, -- Jean Shorts
|
||||
382538503, -- Black Jeans with Sneakers
|
||||
382537569, -- Black Jeans
|
||||
382537950, -- Jean Shorts with White Shoes
|
||||
}
|
||||
-- 얼굴 = 다이내믹 헤드(Head). 앞 7개 무료, 뒤 8개 유료(소유 불필요)
|
||||
NpcLooks.FACE_HEADS = {
|
||||
10725626210, -- Woman Face
|
||||
10725826963, -- Man Face
|
||||
11308945948, -- Check It
|
||||
15938951781, -- Silly Fun
|
||||
10687288296, -- Dylan Default
|
||||
10638267973, -- Stevie Standard
|
||||
10723855306, -- Devon Default
|
||||
13692975981, -- Friendly Smile
|
||||
11163789916, -- The Winning Smile
|
||||
12954264879, -- Joyful Smile
|
||||
13682064263, -- Happy :D
|
||||
130433936882245, -- Super Super Happy Face
|
||||
11159990982, -- Classic Female Face
|
||||
11180212350, -- Classic Male Face
|
||||
16042049101, -- Happy Wink
|
||||
}
|
||||
|
||||
-- 동물: body = {Torso, LeftArm, RightArm, LeftLeg, RightLeg}, colors = {Head, Torso, LeftArm, RightArm, LeftLeg, RightLeg}
|
||||
-- hideHead: 동물 머리 모자가 사람 머리를 다 덮으므로 Head를 투명하게. lowerHat: 모자를 목까지 내림(위 3번)
|
||||
local function rgb(r: number, g: number, b: number): Color3
|
||||
return Color3.fromRGB(r, g, b)
|
||||
end
|
||||
local W, G = rgb(245, 245, 245), rgb(163, 162, 165)
|
||||
-- 항목마다 필드가 달라서(luau-lsp가 한 모양으로 묶으려 함) animal()로 하나씩 Animal로 바꿉니다.
|
||||
local function animal(a: any): Animal
|
||||
return a
|
||||
end
|
||||
local ANIMALS: { Animal } = {
|
||||
-- 공식 번들 몸(Penguin 284) + Tokyokhaos Penguin 머리
|
||||
animal({
|
||||
name = "Penguin",
|
||||
body = { 46358991, 46359095, 46359040, 46359181, 46359241 },
|
||||
hat = "15967866",
|
||||
colors = { W, W, W, W, W, W },
|
||||
hideHead = true,
|
||||
}),
|
||||
-- 공식 번들 몸(Bear Suit 309) + Beary Cute 머리
|
||||
animal({
|
||||
name = "Bear",
|
||||
body = { 27132957, 27133013, 27132990, 27133040, 27133055 },
|
||||
hat = "28998435",
|
||||
lowerHat = true,
|
||||
hideHead = true,
|
||||
colors = {
|
||||
rgb(160, 110, 80),
|
||||
rgb(160, 110, 80),
|
||||
rgb(110, 75, 55),
|
||||
rgb(110, 75, 55),
|
||||
rgb(110, 75, 55),
|
||||
rgb(110, 75, 55),
|
||||
},
|
||||
}),
|
||||
-- 공식 번들 그대로(Polar Bear 195)
|
||||
animal({
|
||||
name = "PolarBear",
|
||||
body = { 137715759, 137715036, 137715073, 137715120, 137715151 },
|
||||
hat = "137714793",
|
||||
hideHead = true,
|
||||
colors = {
|
||||
rgb(248, 248, 248),
|
||||
rgb(248, 248, 248),
|
||||
rgb(248, 248, 248),
|
||||
rgb(248, 248, 248),
|
||||
rgb(248, 248, 248),
|
||||
rgb(248, 248, 248),
|
||||
},
|
||||
}),
|
||||
-- 공식 번들 그대로(Blue Collar Cat 182)
|
||||
animal({
|
||||
name = "Cat",
|
||||
body = { 146176562, 146176342, 146176447, 146176406, 146176511 },
|
||||
hat = "146176716",
|
||||
colors = { G, G, G, G, G, G },
|
||||
hideHead = true,
|
||||
}),
|
||||
-- 공식 번들 그대로(White Collar Dog 11)
|
||||
animal({
|
||||
name = "Dog",
|
||||
body = { 1796148633, 1796137813, 1796141971, 1796143895, 1796146180 },
|
||||
hat = "1796135151",
|
||||
colors = { G, G, G, G, G, G },
|
||||
hideHead = true,
|
||||
}),
|
||||
-- Bear Suit 몸을 흑백으로 + Panda 머리(27369187)
|
||||
animal({
|
||||
name = "Panda",
|
||||
body = { 27132957, 27133013, 27132990, 27133040, 27133055 },
|
||||
hat = "27369187",
|
||||
hideHead = true,
|
||||
colors = {
|
||||
rgb(242, 242, 242),
|
||||
rgb(242, 242, 242),
|
||||
rgb(30, 30, 30),
|
||||
rgb(30, 30, 30),
|
||||
rgb(30, 30, 30),
|
||||
rgb(30, 30, 30),
|
||||
},
|
||||
}),
|
||||
-- 기본 몸 + Cute Fox 머리 + 주황 꼬리 + 옷
|
||||
animal({
|
||||
name = "Fox",
|
||||
hat = "61773267",
|
||||
lowerHat = true,
|
||||
tail = "187846604",
|
||||
shirt = 382537702,
|
||||
pants = 382537806,
|
||||
hideHead = true,
|
||||
colors = {
|
||||
rgb(235, 120, 40),
|
||||
rgb(235, 120, 40),
|
||||
rgb(235, 120, 40),
|
||||
rgb(235, 120, 40),
|
||||
rgb(250, 240, 230),
|
||||
rgb(250, 240, 230),
|
||||
},
|
||||
}),
|
||||
-- 기본 몸 + Sleepy Mouse Cap(머리 전체) + 옷
|
||||
animal({
|
||||
name = "Mouse",
|
||||
hat = "439943629",
|
||||
shirt = 398635081,
|
||||
pants = 144076760,
|
||||
hideHead = true,
|
||||
colors = {
|
||||
rgb(170, 185, 215),
|
||||
rgb(170, 185, 215),
|
||||
rgb(170, 185, 215),
|
||||
rgb(170, 185, 215),
|
||||
rgb(170, 185, 215),
|
||||
rgb(170, 185, 215),
|
||||
},
|
||||
}),
|
||||
-- "동물 분장 사람" 가벼운 버전: 동물 얼굴 다이내믹 헤드 + 귀 + 꼬리 + 옷(사람 얼굴 모양이라 동물 느낌은 약함)
|
||||
animal({
|
||||
name = "Bunny",
|
||||
head = 119665103921086,
|
||||
ears = "1080949",
|
||||
tail = "738679517",
|
||||
shirt = 4047886060,
|
||||
pants = 382537950,
|
||||
colors = { W, W, W, W, W, W },
|
||||
}),
|
||||
animal({
|
||||
name = "Kitty",
|
||||
head = 82082995456115,
|
||||
ears = "1374269",
|
||||
tail = "187846604",
|
||||
shirt = 382537085,
|
||||
pants = 398634487,
|
||||
colors = {
|
||||
rgb(250, 200, 140),
|
||||
rgb(250, 200, 140),
|
||||
rgb(250, 200, 140),
|
||||
rgb(250, 200, 140),
|
||||
rgb(250, 200, 140),
|
||||
rgb(250, 200, 140),
|
||||
},
|
||||
}),
|
||||
animal({
|
||||
name = "Puppy",
|
||||
head = 138526270057654,
|
||||
ears = "11142487",
|
||||
shirt = 144076436,
|
||||
pants = 382538503,
|
||||
colors = {
|
||||
rgb(220, 180, 130),
|
||||
rgb(220, 180, 130),
|
||||
rgb(220, 180, 130),
|
||||
rgb(220, 180, 130),
|
||||
rgb(220, 180, 130),
|
||||
rgb(220, 180, 130),
|
||||
},
|
||||
}),
|
||||
}
|
||||
NpcLooks.ANIMALS = ANIMALS
|
||||
NpcLooks.SKIN = { rgb(255, 220, 190), rgb(240, 200, 160), rgb(205, 160, 120), rgb(150, 105, 75) }
|
||||
|
||||
export type Animal = {
|
||||
name: string,
|
||||
body: { number }?,
|
||||
head: number?,
|
||||
hat: string?,
|
||||
ears: string?,
|
||||
tail: string?,
|
||||
shirt: number?,
|
||||
pants: number?,
|
||||
colors: { Color3 },
|
||||
hideHead: boolean?,
|
||||
lowerHat: boolean?,
|
||||
rare: boolean?,
|
||||
}
|
||||
|
||||
-- 동물 분장 사람(Bunny·Kitty·Puppy)은 동물 느낌이 약해서 가끔만
|
||||
for _, a in NpcLooks.ANIMALS do
|
||||
if a.name == "Bunny" or a.name == "Kitty" or a.name == "Puppy" then
|
||||
a.rare = true
|
||||
end
|
||||
end
|
||||
|
||||
local function setColors(d: HumanoidDescription, c: { Color3 })
|
||||
d.HeadColor = c[1]
|
||||
d.TorsoColor = c[2]
|
||||
d.LeftArmColor = c[3]
|
||||
d.RightArmColor = c[4]
|
||||
d.LeftLegColor = c[5]
|
||||
d.RightLegColor = c[6]
|
||||
end
|
||||
|
||||
local function pick<T>(list: { T }, rng: Random): T
|
||||
return list[rng:NextInteger(1, #list)]
|
||||
end
|
||||
|
||||
function NpcLooks.human(rng: Random): HumanoidDescription
|
||||
local d = Instance.new("HumanoidDescription")
|
||||
d.HairAccessory = tostring(pick(NpcLooks.HAIR, rng))
|
||||
if rng:NextNumber() < 0.35 then
|
||||
d.HatAccessory = tostring(pick(NpcLooks.HATS, rng))
|
||||
end
|
||||
d.Shirt = pick(NpcLooks.SHIRTS, rng)
|
||||
d.Pants = pick(NpcLooks.PANTS, rng)
|
||||
d.Head = pick(NpcLooks.FACE_HEADS, rng)
|
||||
local s = pick(NpcLooks.SKIN, rng)
|
||||
setColors(d, { s, s, s, s, s, s })
|
||||
local h = 0.85 + rng:NextNumber() * 0.15 -- 어린이~어른 키
|
||||
d.HeightScale = h
|
||||
d.WidthScale = 0.9
|
||||
d.DepthScale = 0.9
|
||||
d.HeadScale = 1
|
||||
return d
|
||||
end
|
||||
|
||||
function NpcLooks.animal(a: Animal): HumanoidDescription
|
||||
local d = Instance.new("HumanoidDescription")
|
||||
if a.body then
|
||||
d.Torso = a.body[1]
|
||||
d.LeftArm = a.body[2]
|
||||
d.RightArm = a.body[3]
|
||||
d.LeftLeg = a.body[4]
|
||||
d.RightLeg = a.body[5]
|
||||
end
|
||||
if a.head then
|
||||
d.Head = a.head
|
||||
end
|
||||
d.HatAccessory = a.hat or a.ears or ""
|
||||
d.WaistAccessory = a.tail or ""
|
||||
d.Shirt = a.shirt or 0
|
||||
d.Pants = a.pants or 0
|
||||
setColors(d, a.colors)
|
||||
return d
|
||||
end
|
||||
|
||||
return NpcLooks
|
||||
1172
bunsik-tycoon/src/server/PlotBuilder.luau
Normal file
1453
bunsik-tycoon/src/server/PlotController.luau
Normal file
64
bunsik-tycoon/src/server/Receipts.luau
Normal file
@@ -0,0 +1,64 @@
|
||||
--!strict
|
||||
-- 개발자 상품 결제 처리: 결제 한 번에 정확히 한 번만 지급합니다(DECISIONS.md 2절).
|
||||
-- 로블록스 API에 직접 기대지 않게 프로필과 지급 함수를 받아서, lune 단위 테스트로도 검증합니다.
|
||||
|
||||
local Receipts = {}
|
||||
|
||||
Receipts.CACHE_SIZE = 100
|
||||
|
||||
-- Enum.ProductPurchaseDecision 대신 문자열을 돌려주고, 호출하는 쪽에서 Enum으로 바꿉니다.
|
||||
export type Decision = "Granted" | "NotProcessedYet"
|
||||
|
||||
export type ProfileLike = {
|
||||
Data: { PurchaseIdCache: { string }? },
|
||||
LastSavedData: { PurchaseIdCache: { string }? },
|
||||
IsActive: (self: any) -> boolean,
|
||||
Save: (self: any) -> (),
|
||||
OnAfterSave: { Wait: (self: any) -> () },
|
||||
}
|
||||
|
||||
local function isSaved(profile: ProfileLike, purchaseId: string): boolean
|
||||
local saved = profile.LastSavedData and profile.LastSavedData.PurchaseIdCache
|
||||
return saved ~= nil and table.find(saved, purchaseId) ~= nil
|
||||
end
|
||||
|
||||
-- profile이 nil이면(아직 로드 안 됨, 이미 나감) 나중에 다시 시도하게 합니다.
|
||||
function Receipts.process(profile: ProfileLike?, purchaseId: string, grant: () -> boolean): Decision
|
||||
if profile == nil or not profile:IsActive() then
|
||||
return "NotProcessedYet"
|
||||
end
|
||||
local cache = profile.Data.PurchaseIdCache
|
||||
if cache == nil then
|
||||
return "NotProcessedYet"
|
||||
end
|
||||
if table.find(cache, purchaseId) == nil then
|
||||
local ok, granted = pcall(grant)
|
||||
if not ok or granted ~= true then
|
||||
if not ok then
|
||||
warn("[Bunsik] 상품 지급 오류:", granted)
|
||||
end
|
||||
return "NotProcessedYet"
|
||||
end
|
||||
while #cache >= Receipts.CACHE_SIZE do
|
||||
table.remove(cache, 1)
|
||||
end
|
||||
table.insert(cache, purchaseId)
|
||||
end
|
||||
-- 지급과 PurchaseId가 같이 저장된 것을 확인한 뒤에만 완료로 알립니다.
|
||||
if isSaved(profile, purchaseId) then
|
||||
return "Granted"
|
||||
end
|
||||
while profile:IsActive() do
|
||||
local last = profile.LastSavedData
|
||||
profile:Save()
|
||||
if profile.LastSavedData == last then
|
||||
profile.OnAfterSave:Wait()
|
||||
end
|
||||
if isSaved(profile, purchaseId) then
|
||||
return "Granted"
|
||||
end
|
||||
end
|
||||
return "NotProcessedYet"
|
||||
end
|
||||
|
||||
return Receipts
|
||||
61
bunsik-tycoon/src/server/Transfers.luau
Normal file
@@ -0,0 +1,61 @@
|
||||
--!strict
|
||||
-- 옆 가게 손님 주고받기(홍보, 손님 쫓아내기). 손님 NPC는 원래 가게에서 일어나 길을 따라 걸어옵니다.
|
||||
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Economy = require(ReplicatedStorage.Shared.Economy)
|
||||
local Shop = require(ReplicatedStorage.Shared.Shop)
|
||||
|
||||
local PlotController = require(script.Parent.PlotController)
|
||||
|
||||
type Controller = PlotController.PlotController
|
||||
|
||||
local Transfers = {}
|
||||
|
||||
-- 홍보: 옆 가게들에서 아직 음식을 못 받은 손님을 빈자리만큼(최대 PROMOTE_MAX) 데려옵니다.
|
||||
-- NPC 이웃 가게 손님부터 데려와서 다른 플레이어 가게는 되도록 건드리지 않습니다.
|
||||
-- 돌려주는 값: 데려온 수, 실패 이유("full" | "none")
|
||||
function Transfers.promote(target: Controller, sources: { Controller }): (number, string?)
|
||||
local free = Shop.freeSeatCount(target.shop)
|
||||
if free <= 0 then
|
||||
return 0, "full"
|
||||
end
|
||||
local want = math.min(Economy.PROMOTE_MAX, free)
|
||||
local ordered = table.clone(sources)
|
||||
table.sort(ordered, function(a, b)
|
||||
local an = if a.opts.npc then 0 else 1
|
||||
local bn = if b.opts.npc then 0 else 1
|
||||
if an ~= bn then
|
||||
return an < bn
|
||||
end
|
||||
-- 가까운 가게부터
|
||||
local ta = (a.slot.cf.Position - target.slot.cf.Position).Magnitude
|
||||
local tb = (b.slot.cf.Position - target.slot.cf.Position).Magnitude
|
||||
return ta < tb
|
||||
end)
|
||||
local got = 0
|
||||
for _, src in ordered do
|
||||
if got >= want then
|
||||
break
|
||||
end
|
||||
if src ~= target and not src.destroyed then
|
||||
local list = src:giveCustomers(want - got)
|
||||
got += target:receiveCustomers(list)
|
||||
end
|
||||
end
|
||||
if got == 0 then
|
||||
return 0, "none"
|
||||
end
|
||||
return got, nil
|
||||
end
|
||||
|
||||
-- 손님 쫓아내기: 그 가게의 아직 음식을 못 받은 NPC 손님이 모두 일어납니다.
|
||||
-- 우리 가게 빈자리만큼은 우리 가게로 오고, 나머지는 길로 나갑니다.
|
||||
-- 돌려주는 값: 쫓아낸 수, 우리 가게로 온 수
|
||||
function Transfers.kick(kicker: Controller, victim: Controller): (number, number)
|
||||
local list = victim:giveCustomers(math.huge)
|
||||
local got = kicker:receiveCustomers(list)
|
||||
return #list, got
|
||||
end
|
||||
|
||||
return Transfers
|
||||
177
bunsik-tycoon/src/server/World.luau
Normal file
@@ -0,0 +1,177 @@
|
||||
--!strict
|
||||
-- 맵: 가운데 "분식 거리"와 양쪽에 부지 6칸. 모두 코드로 지어서 리포가 원본이 됩니다.
|
||||
|
||||
local Lighting = game:GetService("Lighting")
|
||||
|
||||
local Build = require(script.Parent.Build)
|
||||
local PlotBuilder = require(script.Parent.PlotBuilder)
|
||||
|
||||
local World = {}
|
||||
|
||||
World.PLOT_COUNT = 6
|
||||
World.STREET_HALF = 14 -- 길 폭의 절반
|
||||
local PLOT_X = { -80, 0, 80 }
|
||||
local PLOT_Z = 14 + 40 + 2 -- 길 가장자리 + 부지 반 길이 + 여유
|
||||
|
||||
local function rgb(r: number, g: number, b: number): Color3
|
||||
return Color3.fromRGB(r, g, b)
|
||||
end
|
||||
|
||||
-- i번째 부지의 기준 좌표. 입구(+Z)가 길을 봅니다.
|
||||
function World.plotCFrame(i: number): CFrame
|
||||
local col = ((i - 1) % 3) + 1
|
||||
local north = i <= 3
|
||||
local x = PLOT_X[col]
|
||||
if north then
|
||||
return CFrame.new(x, 0, -PLOT_Z)
|
||||
end
|
||||
return CFrame.new(x, 0, PLOT_Z) * CFrame.Angles(0, math.pi, 0)
|
||||
end
|
||||
|
||||
local function setupLighting()
|
||||
Lighting.ClockTime = 14.5
|
||||
Lighting.Brightness = 2.2
|
||||
Lighting.Ambient = rgb(120, 115, 110)
|
||||
Lighting.OutdoorAmbient = rgb(150, 145, 140)
|
||||
Lighting.EnvironmentDiffuseScale = 0.5
|
||||
Lighting.EnvironmentSpecularScale = 0.5
|
||||
Lighting.GlobalShadows = true
|
||||
if not Lighting:FindFirstChildOfClass("Atmosphere") then
|
||||
local a = Instance.new("Atmosphere")
|
||||
a.Density = 0.25
|
||||
a.Color = rgb(200, 220, 255)
|
||||
a.Decay = rgb(120, 140, 170)
|
||||
a.Parent = Lighting
|
||||
end
|
||||
if not Lighting:FindFirstChildOfClass("Sky") then
|
||||
Instance.new("Sky").Parent = Lighting
|
||||
end
|
||||
end
|
||||
|
||||
export type Slot = {
|
||||
index: number,
|
||||
cf: CFrame,
|
||||
model: Model,
|
||||
refs: PlotBuilder.BaseRefs,
|
||||
}
|
||||
|
||||
-- 맵을 짓고 부지 목록을 돌려줍니다. 여러 번 불러도 한 번만 짓습니다.
|
||||
function World.build(): { Slot }
|
||||
local existing = workspace:FindFirstChild("BunsikWorld")
|
||||
if existing then
|
||||
existing:Destroy()
|
||||
end
|
||||
setupLighting()
|
||||
local root = Instance.new("Folder")
|
||||
root.Name = "BunsikWorld"
|
||||
root.Parent = workspace
|
||||
|
||||
-- 잔디 바닥, 길, 인도, 차선
|
||||
Build.part(root, {
|
||||
name = "Ground",
|
||||
size = Vector3.new(400, 2, 260),
|
||||
cf = CFrame.new(0, -1, 0),
|
||||
color = rgb(110, 170, 90),
|
||||
material = Enum.Material.Grass,
|
||||
})
|
||||
Build.part(root, {
|
||||
name = "Street",
|
||||
size = Vector3.new(260, 0.2, World.STREET_HALF * 2),
|
||||
cf = CFrame.new(0, 0.1, 0),
|
||||
color = rgb(70, 70, 75),
|
||||
material = Enum.Material.Asphalt,
|
||||
})
|
||||
for i = -6, 6 do
|
||||
Build.part(root, {
|
||||
size = Vector3.new(8, 0.05, 0.6),
|
||||
cf = CFrame.new(i * 18, 0.22, 0),
|
||||
color = rgb(250, 240, 200),
|
||||
collide = false,
|
||||
})
|
||||
end
|
||||
-- 가로등
|
||||
for i = -3, 3 do
|
||||
for _, side in { -1, 1 } do
|
||||
local x = i * 40 + 20 * side
|
||||
local z = side * (World.STREET_HALF - 1)
|
||||
Build.part(root, {
|
||||
size = Vector3.new(0.6, 14, 0.6),
|
||||
cf = CFrame.new(x, 7, z),
|
||||
color = rgb(60, 60, 65),
|
||||
material = Enum.Material.Metal,
|
||||
})
|
||||
local lamp = Build.part(root, {
|
||||
size = Vector3.new(1.6, 1.6, 1.6),
|
||||
cf = CFrame.new(x, 14.5, z),
|
||||
color = rgb(255, 240, 200),
|
||||
shape = Enum.PartType.Ball,
|
||||
neon = true,
|
||||
collide = false,
|
||||
})
|
||||
local light = Instance.new("PointLight")
|
||||
light.Range = 24
|
||||
light.Brightness = 0.7
|
||||
light.Color = rgb(255, 230, 180)
|
||||
light.Parent = lamp
|
||||
end
|
||||
end
|
||||
-- 거리 입구 아치
|
||||
for _, x in { -128, 128 } do
|
||||
for _, side in { -1, 1 } do
|
||||
Build.part(root, {
|
||||
size = Vector3.new(2, 20, 2),
|
||||
cf = CFrame.new(x, 10, side * World.STREET_HALF),
|
||||
color = rgb(200, 50, 40),
|
||||
})
|
||||
end
|
||||
local arch = Build.part(root, {
|
||||
name = "Arch",
|
||||
size = Vector3.new(2, 5, World.STREET_HALF * 2 + 4),
|
||||
cf = CFrame.new(x, 21, 0),
|
||||
color = rgb(255, 215, 80),
|
||||
})
|
||||
local face = if x < 0 then Enum.NormalId.Right else Enum.NormalId.Left
|
||||
Build.label(arch, face, "분식 거리 · BUNSIK STREET", rgb(190, 40, 30))
|
||||
end
|
||||
-- 바깥 나무
|
||||
local rng = Random.new(7)
|
||||
for _ = 1, 40 do
|
||||
local x = rng:NextNumber(-190, 190)
|
||||
local z = (if rng:NextNumber() < 0.5 then -1 else 1) * rng:NextNumber(102, 125)
|
||||
Build.cylinder(root, CFrame.new(x, 3, z), 6, 1.6, rgb(120, 80, 50))
|
||||
Build.part(root, {
|
||||
size = Vector3.new(9, 9, 9),
|
||||
cf = CFrame.new(x, 9, z),
|
||||
color = rgb(70 + rng:NextInteger(0, 30), 150, 70),
|
||||
shape = Enum.PartType.Ball,
|
||||
material = Enum.Material.LeafyGrass,
|
||||
})
|
||||
end
|
||||
|
||||
-- 시작 지점(길 가운데). 들어오면 바로 자기 부지로 옮겨집니다.
|
||||
local spawn = Instance.new("SpawnLocation")
|
||||
spawn.Name = "Spawn"
|
||||
spawn.Anchored = true
|
||||
spawn.Size = Vector3.new(10, 0.4, 10)
|
||||
spawn.CFrame = CFrame.new(0, 0.3, 0)
|
||||
spawn.Duration = 0
|
||||
spawn.Transparency = 1
|
||||
spawn.CanCollide = false
|
||||
spawn.Parent = root
|
||||
|
||||
local plots = Instance.new("Folder")
|
||||
plots.Name = "Plots"
|
||||
plots.Parent = root
|
||||
local slots: { Slot } = {}
|
||||
for i = 1, World.PLOT_COUNT do
|
||||
local cf = World.plotCFrame(i)
|
||||
local model = Instance.new("Model")
|
||||
model.Name = "Plot" .. i
|
||||
model.Parent = plots
|
||||
local refs = PlotBuilder.buildBase(model, cf)
|
||||
table.insert(slots, { index = i, cf = cf, model = model, refs = refs })
|
||||
end
|
||||
return slots
|
||||
end
|
||||
|
||||
return World
|
||||
38
bunsik-tycoon/src/shared/Codec.luau
Normal file
@@ -0,0 +1,38 @@
|
||||
--!strict
|
||||
-- 속성(Attribute)에 표·목록을 글자로 담는 작은 도구. 속성은 표를 담을 수 없어서 씁니다.
|
||||
-- encodeMap({Cook=1, Server=0}, {"Cook","Server"}) -> "Cook=1,Server=0"
|
||||
-- decodeMap("Cook=1,Server=0") -> {Cook=1, Server=0}
|
||||
|
||||
local Codec = {}
|
||||
|
||||
function Codec.encodeMap(map: { [string]: number }, order: { string }): string
|
||||
local parts = {}
|
||||
for _, k in order do
|
||||
table.insert(parts, `{k}={map[k] or 0}`)
|
||||
end
|
||||
return table.concat(parts, ",")
|
||||
end
|
||||
|
||||
function Codec.decodeMap(s: any): { [string]: number }
|
||||
local out = {}
|
||||
if typeof(s) ~= "string" then
|
||||
return out
|
||||
end
|
||||
for k, v in string.gmatch(s, "([%w_]+)=([%-%d%.]+)") do
|
||||
out[k] = tonumber(v) or 0
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
function Codec.decodeList(s: any): { string }
|
||||
local out = {}
|
||||
if typeof(s) ~= "string" then
|
||||
return out
|
||||
end
|
||||
for item in string.gmatch(s, "[^,]+") do
|
||||
table.insert(out, item)
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
return Codec
|
||||
514
bunsik-tycoon/src/shared/Economy.luau
Normal file
@@ -0,0 +1,514 @@
|
||||
--!strict
|
||||
-- 분식집 경제 수치. ECONOMY.md 표와 같은 숫자여야 합니다.
|
||||
-- 숫자를 바꾸면 `lune run tools/sim.luau` 로 구매 시점을 다시 확인합니다.
|
||||
--
|
||||
-- 2026-10-14: 한 줄로 쭉 사던 업그레이드 20개를 갈래(트랙)별로 나눴습니다.
|
||||
-- 갈래: 건물(포장마차 → 실내 → 2층), 메뉴 해금, 판매 금액, 손님 오는 속도, 화구, 쟁반, 알바생 기능
|
||||
-- 자리(테이블·의자)는 꾸미기에서 사고 원하는 곳에 놓습니다. 손님이 앉는 자리 수 = 놓은 의자 수입니다.
|
||||
-- 알바생은 알바생 기능을 산 뒤 역할(요리·서빙·홍보)별로 돈 주고 고용하고, 1분마다 시급을 줍니다.
|
||||
|
||||
export type Level = {
|
||||
cost: number,
|
||||
stage: number, -- 이 단계(건물) 이상이어야 살 수 있음
|
||||
value: any, -- 갈래마다 뜻이 다름(메뉴 이름, 배율, 초, 접시 수, 단계)
|
||||
}
|
||||
|
||||
export type Track = {
|
||||
id: string,
|
||||
levels: { Level },
|
||||
}
|
||||
|
||||
export type Levels = { [string]: number }
|
||||
|
||||
export type Staff = { [string]: number } -- 역할별 고용 수(Cook, Server, Promoter)
|
||||
|
||||
export type Stats = {
|
||||
stage: number,
|
||||
menus: { string },
|
||||
price: number,
|
||||
spawn: number, -- 손님 간격(초). 홍보 알바·손님 러시 반영 전 값
|
||||
cook: number,
|
||||
carry: number,
|
||||
staffUnlocked: boolean,
|
||||
seats: number,
|
||||
}
|
||||
|
||||
export type Role = {
|
||||
id: string,
|
||||
hire: number, -- 고용비(한 번)
|
||||
wage: number, -- 시급(1분마다, 판매 금액 배율을 곱함)
|
||||
max: number,
|
||||
}
|
||||
|
||||
export type Menu = {
|
||||
price: number,
|
||||
icon: string,
|
||||
}
|
||||
|
||||
local Economy = {}
|
||||
|
||||
Economy.WALK = 5 -- 조리대 -> 테이블 -> 조리대 왕복(초, 시뮬레이터 가정)
|
||||
Economy.EAT = 6 -- 식사 시간(초)
|
||||
Economy.WALK_IN = 2.5 -- 손님이 입구에서 자리까지 걷는 기본 시간(초). 실제 길 길이에 맞춰 자리마다 바뀝니다
|
||||
Economy.COUNTER_MAX = 3 -- 요리 알바가 미리 만들어 두는 접시 최대 수(요리 알바 1명당)
|
||||
Economy.BOOST_MINUTES = 10 -- 돈 부스트 팩: 현재 1분 매출 x 10분
|
||||
Economy.BOOST_MIN = 100 -- 돈 부스트 팩 최소 지급액
|
||||
Economy.GUEST_MULT = 2 -- 다른 플레이어가 손님으로 오면 주인은 접시 값의 2배를 받습니다
|
||||
Economy.GUEST_WAIT = 60 -- 손님으로 온 플레이어가 음식을 기다리는 최대 시간(초)
|
||||
Economy.GUEST_BONUS_COOLDOWN = 60 -- 손님으로 먹었을 때 시식 보너스는 1분에 한 번
|
||||
|
||||
Economy.WAGE_PERIOD = 60 -- 시급은 1분마다 줍니다(게임 속 1시간 = 1분)
|
||||
Economy.STRIKE_RETRY = 5 -- 시급이 모자라 쉬는 알바생은 5초마다 다시 확인
|
||||
Economy.SERVER_TRIP = 3 -- 서빙 알바가 카운터에서 손님 자리까지 가는 기본 시간(초, 자리마다 바뀜)
|
||||
Economy.PROMOTER_MULT = 0.75 -- 홍보 알바가 있으면 손님 간격 x0.75
|
||||
|
||||
Economy.RUSH_SECONDS = 600 -- 손님 러시(유료): 10분 동안
|
||||
Economy.RUSH_MULT = 0.5 -- 손님 간격 절반
|
||||
Economy.PROMOTE_MAX = 3 -- 홍보 한 번에 옆 가게에서 데려오는 손님 수(빈자리만큼)
|
||||
Economy.PROMOTE_COOLDOWN = 180 -- 광고 없이 하는 홍보 대기 시간(초)
|
||||
Economy.PROMOTE_AD_COOLDOWN = 45 -- 광고를 보고 하는 홍보 대기 시간(초)
|
||||
Economy.KICK_SHIELD = 180 -- 손님을 쫓겨난 가게는 3분 동안 다시 쫓겨나지 않음
|
||||
Economy.TRANSFER_WALK = 7 -- 옆 가게에서 우리 가게 자리까지 걸어오는 시간(초)
|
||||
|
||||
Economy.START_MONEY = 0
|
||||
Economy.START_SPAWN = 20 -- 처음 손님 간격(6초 → 10초 → 20초로 느리게)
|
||||
Economy.START_COOK = 2.5
|
||||
Economy.START_MENUS = { "Tteokbokki" }
|
||||
|
||||
Economy.MENUS = {
|
||||
Tteokbokki = { price = 30, icon = "🌶️" },
|
||||
Gimbap = { price = 50, icon = "🍙" },
|
||||
Sundae = { price = 80, icon = "🌭" },
|
||||
Eomuk = { price = 100, icon = "🍢" },
|
||||
Twigim = { price = 140, icon = "🍤" },
|
||||
} :: { [string]: Menu }
|
||||
|
||||
-- 메뉴 표시 순서
|
||||
Economy.MENU_ORDER = { "Tteokbokki", "Gimbap", "Sundae", "Eomuk", "Twigim" }
|
||||
|
||||
-- 업그레이드 갈래. 각 갈래는 앞 단계부터 차례로 삽니다.
|
||||
Economy.TRACKS = {
|
||||
{
|
||||
id = "Stage", -- 건물: 1 포장마차 → 2 실내 분식집 → 3 2층
|
||||
levels = {
|
||||
{ cost = 450, stage = 1, value = 2 },
|
||||
{ cost = 5000, stage = 2, value = 3 },
|
||||
},
|
||||
},
|
||||
{
|
||||
id = "Menu", -- 새 메뉴 해금
|
||||
levels = {
|
||||
{ cost = 40, stage = 1, value = "Gimbap" },
|
||||
{ cost = 160, stage = 1, value = "Sundae" },
|
||||
{ cost = 950, stage = 2, value = "Eomuk" },
|
||||
{ cost = 2000, stage = 2, value = "Twigim" },
|
||||
},
|
||||
},
|
||||
{
|
||||
id = "Price", -- 판매 금액(양념 비법): 모든 메뉴 값 배율
|
||||
levels = {
|
||||
{ cost = 120, stage = 1, value = 1.25 },
|
||||
{ cost = 260, stage = 1, value = 1.5 },
|
||||
{ cost = 1100, stage = 2, value = 1.75 },
|
||||
{ cost = 2400, stage = 2, value = 2 },
|
||||
{ cost = 7000, stage = 3, value = 2.5 },
|
||||
{ cost = 12000, stage = 3, value = 3 },
|
||||
},
|
||||
},
|
||||
{
|
||||
id = "Speed", -- 손님 오는 속도(간판·전단지): 손님 간격(초)
|
||||
levels = {
|
||||
{ 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 },
|
||||
},
|
||||
},
|
||||
{
|
||||
id = "Stove", -- 화구: 요리 창에서 누르는 양(조리 수준)
|
||||
levels = {
|
||||
{ cost = 90, stage = 1, value = 1.8 },
|
||||
{ cost = 800, stage = 2, value = 1.4 },
|
||||
{ cost = 1800, stage = 2, value = 1 },
|
||||
},
|
||||
},
|
||||
{
|
||||
id = "Tray", -- 쟁반: 한 번에 드는 접시 수
|
||||
levels = {
|
||||
{ cost = 700, stage = 2, value = 2 },
|
||||
{ cost = 2600, stage = 2, value = 3 },
|
||||
},
|
||||
},
|
||||
{
|
||||
id = "Staff", -- 알바생 기능 해금(이걸 사야 알바생을 고용할 수 있음)
|
||||
levels = {
|
||||
{ cost = 250, stage = 1, value = true },
|
||||
},
|
||||
},
|
||||
} :: { Track }
|
||||
|
||||
Economy.TRACK_ORDER = {} :: { string }
|
||||
local trackById: { [string]: Track } = {}
|
||||
for _, t in Economy.TRACKS do
|
||||
table.insert(Economy.TRACK_ORDER, t.id)
|
||||
trackById[t.id] = t
|
||||
end
|
||||
|
||||
function Economy.track(id: string): Track?
|
||||
return trackById[id]
|
||||
end
|
||||
|
||||
-- 알바생 역할. 시급은 판매 금액 배율만큼 오릅니다(가게가 클수록 시급도 높음).
|
||||
Economy.ROLES = {
|
||||
{ id = "Cook", hire = 200, wage = 12, max = 2 }, -- 요리: 카운터에 접시를 만들어 둠
|
||||
{ id = "Server", hire = 500, wage = 15, max = 2 }, -- 서빙: 카운터 접시를 손님 자리로 날라 줌
|
||||
{ id = "Promoter", hire = 400, wage = 10, max = 1 }, -- 홍보: 입구에서 전단지, 손님 간격 x0.75
|
||||
} :: { Role }
|
||||
|
||||
local roleById: { [string]: Role } = {}
|
||||
for _, r in Economy.ROLES do
|
||||
roleById[r.id] = r
|
||||
end
|
||||
|
||||
function Economy.role(id: string): Role?
|
||||
return roleById[id]
|
||||
end
|
||||
|
||||
-- 자리(손님 의자). 테이블과 의자는 따로 사서 놓습니다. 건물 단계별로 놓을 수 있는 수가 다릅니다.
|
||||
Economy.CHAIRS_PER_TABLE = 4 -- 추천·봇 가정: 테이블 하나에 의자 4개쯤(앞·뒤·왼쪽·오른쪽)
|
||||
Economy.SEAT_CAP = { 6, 14, 24 } -- 단계별 최대 의자 수
|
||||
Economy.TABLE_CAP = { 3, 6, 12 } -- 단계별 최대 테이블 수
|
||||
|
||||
-- s번째 자리(의자)를 사는 값. 처음 자리는 공짜(처음부터 테이블 1 + 의자 1).
|
||||
function Economy.seatCost(s: number): number
|
||||
if s <= 1 then
|
||||
return 0
|
||||
end
|
||||
local raw = 10 * (s - 1) ^ 2.1
|
||||
return math.floor(raw / 5 + 0.5) * 5
|
||||
end
|
||||
|
||||
-- 테이블만(의자는 따로). tables = 지금 놓은 테이블 수
|
||||
function Economy.tableCost(tables: number): number
|
||||
return 20 + 15 * tables * tables
|
||||
end
|
||||
|
||||
-- 꾸미기 소품(손님 수와 상관없는 장식). 크기는 Floor.FOOTPRINT
|
||||
Economy.DECOR = {
|
||||
{ id = "Plant", cost = 50 },
|
||||
{ id = "Rug", cost = 80 },
|
||||
{ id = "Balloons", cost = 120 },
|
||||
{ id = "Lamp", cost = 150 },
|
||||
{ id = "Teddy", cost = 250 },
|
||||
{ id = "Fridge", cost = 400 },
|
||||
} :: { { id: string, cost: number } }
|
||||
|
||||
Economy.DECOR_MAX = 20
|
||||
|
||||
function Economy.decor(id: string): { id: string, cost: number }?
|
||||
for _, d in Economy.DECOR do
|
||||
if d.id == id then
|
||||
return d
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- 가게 건물 디자인(실내 분식집 이상에서 바꿀 수 있음). pass가 있으면 게임패스(Products 키)로 삽니다.
|
||||
Economy.DESIGNS = {
|
||||
{ id = "Basic" },
|
||||
{ id = "Mint" },
|
||||
{ id = "Brick" },
|
||||
{ id = "Candy", pass = "CANDY_DESIGN_PASS" },
|
||||
{ id = "Hanok", pass = "HANOK_DESIGN_PASS" },
|
||||
} :: { { id: string, pass: string? } }
|
||||
|
||||
function Economy.design(id: string): { id: string, pass: string? }?
|
||||
for _, d in Economy.DESIGNS do
|
||||
if d.id == id then
|
||||
return d
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
Economy.NAME_MAX = 20 -- 가게 이름 최대 글자 수
|
||||
|
||||
-- 가게 이름 글자색(무료 10가지). 0 = 건물 디자인 기본색. 무지개(게임패스)를 켜면 무지개가 먼저 보입니다.
|
||||
-- 이름은 Locale "color_<번호>"
|
||||
Economy.NAME_COLORS = {
|
||||
{ 230, 50, 50 }, -- 빨강
|
||||
{ 255, 140, 30 }, -- 주황
|
||||
{ 255, 210, 40 }, -- 노랑
|
||||
{ 60, 185, 80 }, -- 초록
|
||||
{ 70, 200, 230 }, -- 하늘
|
||||
{ 50, 100, 230 }, -- 파랑
|
||||
{ 150, 80, 220 }, -- 보라
|
||||
{ 255, 110, 170 }, -- 분홍
|
||||
{ 255, 255, 255 }, -- 흰색
|
||||
{ 30, 30, 35 }, -- 검정
|
||||
} :: { { number } }
|
||||
|
||||
function Economy.level(levels: Levels, id: string): number
|
||||
return levels[id] or 0
|
||||
end
|
||||
|
||||
function Economy.emptyLevels(): Levels
|
||||
local out = {}
|
||||
for _, id in Economy.TRACK_ORDER do
|
||||
out[id] = 0
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
-- 저장된 값을 정리합니다(없는 갈래, 범위 밖 숫자).
|
||||
function Economy.cleanLevels(raw: any): Levels
|
||||
local out = Economy.emptyLevels()
|
||||
if typeof(raw) == "table" then
|
||||
for _, t in Economy.TRACKS do
|
||||
local v = raw[t.id]
|
||||
if typeof(v) == "number" then
|
||||
out[t.id] = math.clamp(math.floor(v), 0, #t.levels)
|
||||
end
|
||||
end
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
-- 갈래 레벨과 자리 수로 능력치를 계산합니다.
|
||||
function Economy.stats(levels: Levels, seats: number): Stats
|
||||
local stats: Stats = {
|
||||
stage = 1,
|
||||
menus = table.clone(Economy.START_MENUS),
|
||||
price = 1,
|
||||
spawn = Economy.START_SPAWN,
|
||||
cook = Economy.START_COOK,
|
||||
carry = 1,
|
||||
staffUnlocked = false,
|
||||
seats = math.max(1, seats),
|
||||
}
|
||||
for _, t in Economy.TRACKS do
|
||||
local n = math.min(levels[t.id] or 0, #t.levels)
|
||||
for i = 1, n do
|
||||
local v = t.levels[i].value
|
||||
if t.id == "Stage" then
|
||||
stats.stage = v
|
||||
elseif t.id == "Menu" then
|
||||
table.insert(stats.menus, v)
|
||||
elseif t.id == "Price" then
|
||||
stats.price = v
|
||||
elseif t.id == "Speed" then
|
||||
stats.spawn = v
|
||||
elseif t.id == "Stove" then
|
||||
stats.cook = v
|
||||
elseif t.id == "Tray" then
|
||||
stats.carry = v
|
||||
elseif t.id == "Staff" then
|
||||
stats.staffUnlocked = true
|
||||
end
|
||||
end
|
||||
end
|
||||
return stats
|
||||
end
|
||||
|
||||
-- 갈래의 다음 단계(없으면 nil)
|
||||
function Economy.nextLevel(levels: Levels, id: string): Level?
|
||||
local t = trackById[id]
|
||||
if not t then
|
||||
return nil
|
||||
end
|
||||
return t.levels[(levels[id] or 0) + 1]
|
||||
end
|
||||
|
||||
function Economy.seatCap(stage: number): number
|
||||
return Economy.SEAT_CAP[math.clamp(stage, 1, #Economy.SEAT_CAP)]
|
||||
end
|
||||
|
||||
function Economy.tableCap(stage: number): number
|
||||
return Economy.TABLE_CAP[math.clamp(stage, 1, #Economy.TABLE_CAP)]
|
||||
end
|
||||
|
||||
-- 한 접시 값(정수). moneyMult는 2배 수익 게임패스(1 또는 2)
|
||||
function Economy.dishPrice(menu: string, stats: Stats, moneyMult: number): number
|
||||
return math.floor(Economy.MENUS[menu].price * stats.price) * moneyMult
|
||||
end
|
||||
|
||||
-- 역할별 시급(1분마다)
|
||||
function Economy.wage(roleId: string, stats: Stats): number
|
||||
local r = roleById[roleId]
|
||||
if not r then
|
||||
return 0
|
||||
end
|
||||
return math.floor(r.wage * stats.price + 0.5)
|
||||
end
|
||||
|
||||
function Economy.totalWage(staff: Staff, stats: Stats): number
|
||||
local total = 0
|
||||
for _, r in Economy.ROLES do
|
||||
total += (staff[r.id] or 0) * Economy.wage(r.id, stats)
|
||||
end
|
||||
return total
|
||||
end
|
||||
|
||||
-- 손님 간격(초): 홍보 알바, 손님 러시 반영
|
||||
function Economy.spawnInterval(stats: Stats, promoters: number, rush: boolean): number
|
||||
local s = stats.spawn
|
||||
if promoters > 0 then
|
||||
s *= Economy.PROMOTER_MULT
|
||||
end
|
||||
if rush then
|
||||
s *= Economy.RUSH_MULT
|
||||
end
|
||||
return s
|
||||
end
|
||||
|
||||
-- 현재 능력치로 1분에 버는 돈(대략). 돈 부스트 팩 지급액 계산용
|
||||
function Economy.incomePerMinute(stats: Stats): number
|
||||
local total = 0
|
||||
for _, m in stats.menus do
|
||||
total += Economy.dishPrice(m, stats, 1)
|
||||
end
|
||||
local avg = total / #stats.menus
|
||||
-- 손님 수는 간격과 자리 회전(식사+이동+조리) 중 느린 쪽으로 제한
|
||||
local perSeat = 60 / (Economy.EAT + Economy.WALK_IN + Economy.WALK + stats.cook)
|
||||
local customers = math.min(60 / stats.spawn, perSeat * stats.seats)
|
||||
return math.floor(customers * avg)
|
||||
end
|
||||
|
||||
function Economy.boostAmount(stats: Stats): number
|
||||
return math.max(Economy.BOOST_MIN, Economy.incomePerMinute(stats) * Economy.BOOST_MINUTES)
|
||||
end
|
||||
|
||||
-- 이름판에 붙는 가게 레벨: 산 업그레이드 단계 수 + 늘린 자리 수
|
||||
function Economy.shopLevel(levels: Levels, seats: number): number
|
||||
local n = math.max(0, seats - 1)
|
||||
for _, id in Economy.TRACK_ORDER do
|
||||
n += levels[id] or 0
|
||||
end
|
||||
return n
|
||||
end
|
||||
|
||||
export type Offer = {
|
||||
kind: string, -- "track" | "seat" | "table"
|
||||
id: string, -- 갈래 id 또는 "Seat"/"Table"
|
||||
cost: number,
|
||||
}
|
||||
|
||||
-- 지금 살 수 있는 다음 단계들(건물 단계 조건을 채운 것). 화면 아래 "다음 업그레이드" 추천과 봇이 씁니다.
|
||||
-- tables: 놓은 테이블 수, seats: 놓은 의자 수
|
||||
function Economy.offers(levels: Levels, tables: number, seats: number): { Offer }
|
||||
local stats = Economy.stats(levels, seats)
|
||||
local out: { Offer } = {}
|
||||
for _, id in Economy.TRACK_ORDER do
|
||||
local nl = Economy.nextLevel(levels, id)
|
||||
if nl and nl.stage <= stats.stage then
|
||||
table.insert(out, { kind = "track", id = id, cost = nl.cost })
|
||||
end
|
||||
end
|
||||
if seats < Economy.seatCap(stats.stage) then
|
||||
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) 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)
|
||||
if a.cost ~= b.cost then
|
||||
return a.cost < b.cost
|
||||
end
|
||||
return a.id < b.id
|
||||
end)
|
||||
return out
|
||||
end
|
||||
|
||||
-- 예전 세이브(한 줄 업그레이드 Bought개)를 갈래 레벨로 옮깁니다.
|
||||
-- 돌려주는 값: 레벨, 자리 수, 테이블 수, 요리 알바 수
|
||||
function Economy.migrate(bought: number): (Levels, number, number, number)
|
||||
local OLD = {
|
||||
"Table2",
|
||||
"UnlockGimbap",
|
||||
"Sign1",
|
||||
"Stove1",
|
||||
"Table3",
|
||||
"UnlockSundae",
|
||||
"Sauce1",
|
||||
"Helper",
|
||||
"Table4",
|
||||
"Expand",
|
||||
"Tray1",
|
||||
"Table5",
|
||||
"UnlockEomuk",
|
||||
"Sign2",
|
||||
"Table6",
|
||||
"Stove2",
|
||||
"UnlockTwigim",
|
||||
"Sauce2",
|
||||
"Tray2",
|
||||
"Table8",
|
||||
}
|
||||
local levels = Economy.emptyLevels()
|
||||
local seats = 1
|
||||
local cooks = 0
|
||||
local function up(id: string, n: number)
|
||||
levels[id] = math.max(levels[id], n)
|
||||
end
|
||||
for i = 1, math.clamp(bought, 0, #OLD) do
|
||||
local id = OLD[i]
|
||||
if id == "Table2" then
|
||||
seats = 2
|
||||
elseif id == "Table3" then
|
||||
seats = 3
|
||||
elseif id == "Table4" then
|
||||
seats = 4
|
||||
up("Speed", 3)
|
||||
elseif id == "Table5" then
|
||||
seats = 5
|
||||
elseif id == "Table6" then
|
||||
seats = 6
|
||||
elseif id == "Table8" then
|
||||
seats = 8
|
||||
up("Speed", 5)
|
||||
elseif id == "UnlockGimbap" then
|
||||
up("Menu", 1)
|
||||
elseif id == "UnlockSundae" then
|
||||
up("Menu", 2)
|
||||
elseif id == "UnlockEomuk" then
|
||||
up("Menu", 3)
|
||||
elseif id == "UnlockTwigim" then
|
||||
up("Menu", 4)
|
||||
elseif id == "Sign1" then
|
||||
up("Speed", 2)
|
||||
elseif id == "Sign2" then
|
||||
up("Speed", 4)
|
||||
elseif id == "Stove1" then
|
||||
up("Stove", 1)
|
||||
elseif id == "Stove2" then
|
||||
up("Stove", 3)
|
||||
elseif id == "Sauce1" then
|
||||
up("Price", 2)
|
||||
elseif id == "Sauce2" then
|
||||
up("Price", 4)
|
||||
elseif id == "Helper" then
|
||||
up("Staff", 1)
|
||||
cooks = 1
|
||||
elseif id == "Expand" then
|
||||
up("Stage", 1)
|
||||
elseif id == "Tray1" then
|
||||
up("Tray", 1)
|
||||
elseif id == "Tray2" then
|
||||
up("Tray", 2)
|
||||
end
|
||||
end
|
||||
-- 예전 테이블은 1인석이었으므로 자리 수만큼 테이블을 둡니다(단계별 최대 수 안에서).
|
||||
local stage = Economy.stats(levels, seats).stage
|
||||
local tables = math.min(seats, Economy.tableCap(stage))
|
||||
seats = math.min(seats, tables * Economy.CHAIRS_PER_TABLE)
|
||||
return levels, seats, tables, cooks
|
||||
end
|
||||
|
||||
return Economy
|
||||
1016
bunsik-tycoon/src/shared/Floor.luau
Normal file
101
bunsik-tycoon/src/shared/Icons.luau
Normal file
@@ -0,0 +1,101 @@
|
||||
--!strict
|
||||
-- 화면 UI 그림. 직접 그린 그림 두 장을 칸으로 잘라 씁니다.
|
||||
-- ASSET(art/ui_icons.png, tools/icons.py): 128px 칸 8x8. 버튼 아이콘, 메뉴, 요리 재료·도구
|
||||
-- KITCHEN_ASSET(art/kitchen.png, tools/kitchen_art.py): 256px 칸 4x4. 조리 도구(팬·도마·찜기·냄비·튀김기), 마스코트 떡이
|
||||
-- 칸 순서를 바꾸면 각 도구의 --luau 출력으로 아래 표를 다시 맞추고, 그림을 새로 올려(tools/cloud.py image) ID를 바꿉니다.
|
||||
|
||||
local Icons = {}
|
||||
|
||||
Icons.ASSET = "rbxassetid://111384470366371"
|
||||
Icons.CELL = Vector2.new(128, 128)
|
||||
Icons.KITCHEN_ASSET = "rbxassetid://118704012792360"
|
||||
Icons.KITCHEN_CELL = Vector2.new(256, 256)
|
||||
|
||||
Icons.OFFSET = {
|
||||
coin = Vector2.new(0, 0),
|
||||
moneyBag = Vector2.new(128, 0),
|
||||
bolt = Vector2.new(256, 0),
|
||||
gear = Vector2.new(384, 0),
|
||||
upgrade = Vector2.new(512, 0),
|
||||
plate = Vector2.new(640, 0),
|
||||
lock = Vector2.new(768, 0),
|
||||
check = Vector2.new(896, 0),
|
||||
close = Vector2.new(0, 128),
|
||||
table = Vector2.new(128, 128),
|
||||
sign = Vector2.new(256, 128),
|
||||
flame = Vector2.new(384, 128),
|
||||
sauce = Vector2.new(512, 128),
|
||||
chef = Vector2.new(640, 128),
|
||||
store = Vector2.new(768, 128),
|
||||
tray = Vector2.new(896, 128),
|
||||
Tteokbokki = Vector2.new(0, 256),
|
||||
Gimbap = Vector2.new(128, 256),
|
||||
Sundae = Vector2.new(256, 256),
|
||||
Eomuk = Vector2.new(384, 256),
|
||||
Twigim = Vector2.new(512, 256),
|
||||
globe = Vector2.new(640, 256),
|
||||
speaker = Vector2.new(768, 256),
|
||||
mouse = Vector2.new(896, 256),
|
||||
wrench = Vector2.new(0, 384),
|
||||
star = Vector2.new(128, 384),
|
||||
sparkle = Vector2.new(256, 384),
|
||||
rays = Vector2.new(384, 384),
|
||||
glow = Vector2.new(512, 384),
|
||||
arrowDown = Vector2.new(640, 384),
|
||||
scroll = Vector2.new(768, 384),
|
||||
hand = Vector2.new(896, 384),
|
||||
riceCake = Vector2.new(0, 512),
|
||||
riceCakeRed = Vector2.new(128, 512),
|
||||
riceCakes = Vector2.new(256, 512),
|
||||
sauceBowl = Vector2.new(384, 512),
|
||||
sauceBlob = Vector2.new(512, 512),
|
||||
spatula = Vector2.new(640, 512),
|
||||
bubble = Vector2.new(768, 512),
|
||||
steam = Vector2.new(896, 512),
|
||||
fillings = Vector2.new(0, 640),
|
||||
mat = Vector2.new(128, 640),
|
||||
knife = Vector2.new(256, 640),
|
||||
gimbapSlice = Vector2.new(384, 640),
|
||||
sundaeRaw = Vector2.new(512, 640),
|
||||
sundaePiece = Vector2.new(640, 640),
|
||||
sundaeSlice = Vector2.new(768, 640),
|
||||
fishCake = Vector2.new(896, 640),
|
||||
batter = Vector2.new(0, 768),
|
||||
shrimpRaw = Vector2.new(128, 768),
|
||||
shrimpBatter = Vector2.new(256, 768),
|
||||
tongs = Vector2.new(384, 768),
|
||||
customer = Vector2.new(512, 768),
|
||||
mascot = Vector2.new(640, 768),
|
||||
heart = Vector2.new(768, 768),
|
||||
cart = Vector2.new(896, 768),
|
||||
pot = Vector2.new(0, 896),
|
||||
} :: { [string]: Vector2 }
|
||||
|
||||
Icons.KITCHEN = {
|
||||
pan = Vector2.new(0, 0),
|
||||
board = Vector2.new(256, 0),
|
||||
steamer = Vector2.new(512, 0),
|
||||
pot = Vector2.new(768, 0),
|
||||
fryer = Vector2.new(0, 256),
|
||||
mascot = Vector2.new(256, 256),
|
||||
mascotCheer = Vector2.new(512, 256),
|
||||
gimbapRoll = Vector2.new(768, 256),
|
||||
plateBig = Vector2.new(0, 512),
|
||||
burst = Vector2.new(256, 512),
|
||||
} :: { [string]: Vector2 }
|
||||
|
||||
-- ImageLabel/ImageButton에 아이콘을 씌웁니다.
|
||||
function Icons.apply(image: ImageLabel, name: string)
|
||||
image.Image = Icons.ASSET
|
||||
image.ImageRectOffset = Icons.OFFSET[name] or Vector2.zero
|
||||
image.ImageRectSize = Icons.CELL
|
||||
end
|
||||
|
||||
-- 큰 요리 그림(조리 도구, 마스코트)
|
||||
function Icons.applyKitchen(image: ImageLabel, name: string)
|
||||
image.Image = Icons.KITCHEN_ASSET
|
||||
image.ImageRectOffset = Icons.KITCHEN[name] or Vector2.zero
|
||||
image.ImageRectSize = Icons.KITCHEN_CELL
|
||||
end
|
||||
|
||||
return Icons
|
||||
995
bunsik-tycoon/src/shared/Locale.luau
Normal file
@@ -0,0 +1,995 @@
|
||||
--!strict
|
||||
-- 화면 글자(한국어·영어·일본어·중국어 간체). 키가 없으면 영어, 그것도 없으면 키 이름을 그대로 보여 줘서 빠진 번역이 바로 보입니다.
|
||||
-- 메뉴 이름은 "menu_<메뉴 키>", 업그레이드 갈래는 "track_<id>", 알바 역할은 "role_<id>", 소품은 "decor_<id>",
|
||||
-- 디자인은 "design_<id>", 배치 실패 이유는 "why_<이유>" 키에 있습니다.
|
||||
|
||||
local Locale = {}
|
||||
|
||||
local STRINGS: { [string]: { [string]: string } } = {
|
||||
ko = {
|
||||
title = "분식집 타이쿤",
|
||||
money = "{money}원",
|
||||
buy = "사기",
|
||||
bought = "완료",
|
||||
locked = "잠김",
|
||||
notEnough = "돈이 {need}원 더 필요해요",
|
||||
maxed = "모든 업그레이드 완료!",
|
||||
next = "다음",
|
||||
nextUp = "다음 업그레이드",
|
||||
doubleOn = "적용 중",
|
||||
close = "닫기",
|
||||
cookAction = "요리하기",
|
||||
cook_Twigim_3 = "집게로 건져요",
|
||||
cook_Twigim_2 = "기름에 바삭하게 튀겨요",
|
||||
cook_Twigim_1 = "새우에 튀김옷을 입혀요",
|
||||
cook_Eomuk_2 = "국물에 퐁당 담가요",
|
||||
cook_Eomuk_1 = "어묵을 꼬치에 끼워요",
|
||||
cook_Sundae_3 = "먹기 좋게 썰어요",
|
||||
cook_Sundae_2 = "김이 나게 푹 쪄요",
|
||||
cook_Sundae_1 = "순대를 찜기에 넣어요",
|
||||
cook_Gimbap_3 = "송송 썰어요",
|
||||
cook_Gimbap_2 = "돌돌 말아요",
|
||||
cook_Gimbap_1 = "김 위에 재료를 올려요",
|
||||
cook_Tteokbokki_3 = "주걱으로 휘휘 저어요",
|
||||
cook_Tteokbokki_2 = "빨간 양념을 부어요",
|
||||
cook_Tteokbokki_1 = "떡을 팬에 넣어요",
|
||||
gestureRub = "문질문질!",
|
||||
gestureHold = "꾹 누르고 있기",
|
||||
gestureTap = "톡톡! {n}번",
|
||||
cookDone = "완성!",
|
||||
chooseMenu = "무엇을 만들까요? 손님이 주문한 걸 골라요!",
|
||||
cookTitle = "요리하기",
|
||||
btnBoost = "부스트",
|
||||
btnDouble = "2배 돈",
|
||||
btnShop = "상점",
|
||||
cookWait = "손님 기다리는 중",
|
||||
cookHandFull = "손이 꽉 찼어요! 먼저 손님에게 가져다줘요",
|
||||
stoveObject = "조리대",
|
||||
tut1 = "손님이 왔어요! 빛나는 조리대로 가서 요리를 시작해요",
|
||||
tut2 = "다 만들었어요! 접시를 손님 자리로 가져가세요",
|
||||
tut3 = "돈을 벌었어요! [가게 꾸미기]에서 의자를 골라 테이블 앞에 놓아 보세요",
|
||||
tutDone = "잘했어요! 계속 손님을 받고 가게를 키워 보세요",
|
||||
double = "2배 수익",
|
||||
doubleOwned = "2배 수익 적용 중",
|
||||
doubleDesc = "모든 판매 금액이 영원히 2배",
|
||||
boost = "돈 부스트",
|
||||
boostDesc = "지금 매출 10분치 {amount}원 즉시 받기",
|
||||
boostGot = "돈 부스트 {amount}원을 받았어요!",
|
||||
purchased = "{name} 구매 완료!",
|
||||
newMenu = "새 메뉴 {menuName}! 이제 손님이 {menuName}도 주문해요",
|
||||
expanded = "실내 분식집으로 확장했어요! 디자인도 바꿀 수 있어요",
|
||||
plotOwner = "{name}의 분식집",
|
||||
plotEmpty = "빈 가게 자리",
|
||||
neighbor = "이웃 가게",
|
||||
helperNote = "알바생이 요리 중! 카운터에서 접시를 가져가세요",
|
||||
saveFail = "저장된 데이터를 불러오지 못했어요. 다시 접속해 주세요",
|
||||
serverFull = "서버가 꽉 찼어요",
|
||||
visitor = "다른 친구의 가게예요",
|
||||
devTitle = "개발자 테스트",
|
||||
devMoney = "+1,000원",
|
||||
devDouble = "2배 켜기/끄기",
|
||||
devReset = "처음부터",
|
||||
devResetDone = "진행을 처음으로 되돌렸어요",
|
||||
settings = "설정",
|
||||
language = "언어",
|
||||
langAuto = "자동",
|
||||
mouseLook = "마우스로 화면 돌리기",
|
||||
mouseHint = "Ctrl을 누르고 있으면 마우스 커서가 나와요",
|
||||
sfx = "효과음",
|
||||
on = "켜짐",
|
||||
off = "꺼짐",
|
||||
visitAction = "손님으로 들어가기",
|
||||
visitFull = "빈자리가 없어요. 조금 뒤에 다시 와 주세요",
|
||||
guestSeated = "자리에 앉았어요! 음식을 기다려요 (점프하면 일어나요)",
|
||||
guestBonus = "냠냠! 시식 보너스 {amount}원을 받았어요",
|
||||
guestAte = "냠냠! 맛있게 먹었어요",
|
||||
guestHungry = "음식이 너무 늦게 나와서 일어났어요",
|
||||
guestArrived = "{name}님이 손님으로 왔어요! 이 손님은 2배 값을 내요",
|
||||
npcShop1 = "떡순이네 분식",
|
||||
npcShop2 = "할머니 분식",
|
||||
npcShop3 = "꼬마 분식",
|
||||
npcShop4 = "맛나 분식",
|
||||
npcShop5 = "골목 분식",
|
||||
npcShop6 = "튀김왕 분식",
|
||||
menu_Tteokbokki = "떡볶이",
|
||||
menu_Gimbap = "김밥",
|
||||
menu_Sundae = "순대",
|
||||
menu_Eomuk = "어묵",
|
||||
menu_Twigim = "튀김",
|
||||
stage_1 = "포장마차",
|
||||
stage_2 = "실내 분식집",
|
||||
stage_3 = "2층 분식집",
|
||||
tabUpgrade = "업그레이드",
|
||||
tabDecor = "꾸미기",
|
||||
tabStaff = "알바생",
|
||||
tabMine = "내 가게",
|
||||
track_Stage = "가게 건물",
|
||||
track_Menu = "새 메뉴",
|
||||
track_Price = "판매 금액",
|
||||
track_Speed = "손님 속도",
|
||||
track_Stove = "화구",
|
||||
track_Tray = "쟁반",
|
||||
track_Staff = "알바생 기능",
|
||||
fx_Stage = "{from} → {to}",
|
||||
fx_Menu = "새 메뉴 {menuName}",
|
||||
fx_Price = "판매 금액 x{from} → x{to}",
|
||||
fx_Speed = "손님 간격 {from}초 → {to}초",
|
||||
fx_Stove = "요리 일 {from}% → {to}%",
|
||||
fx_Tray = "접시 {from}개 → {to}개",
|
||||
fx_Staff = "알바생을 고용할 수 있어요",
|
||||
lockStage2 = "실내 분식집부터",
|
||||
lockStage3 = "2층부터",
|
||||
full = "꽉 찼어요",
|
||||
needTable = "테이블 먼저",
|
||||
thing_Seat = "의자",
|
||||
thing_Table = "테이블",
|
||||
decor_Plant = "화분",
|
||||
decor_Rug = "카펫",
|
||||
decor_Balloons = "풍선",
|
||||
decor_Lamp = "전등",
|
||||
decor_Teddy = "곰인형",
|
||||
decor_Fridge = "냉장고",
|
||||
place = "배치하기",
|
||||
btnDecorate = "가게 꾸미기",
|
||||
decorateTitle = "가게 꾸미기",
|
||||
moveItems = "옮기기",
|
||||
decoKeys = "(R 돌리기 · F 놓기)",
|
||||
why_money = "돈이 모자라요",
|
||||
btnMove = "이동",
|
||||
btnDelete = "삭제",
|
||||
decoChoose = "아래에서 놓을 물건을 골라요. [이동]·[삭제]로 놓은 가구를 고쳐요",
|
||||
decoPickMove = "이동할 가구를 고르세요(누르기)",
|
||||
decoPickDelete = "삭제할 가구를 고르세요(누르기)",
|
||||
decoDeleteAsk = "[삭제]를 누르면 지우고 {money}원을 돌려받아요",
|
||||
why_stove = "조리대는 지울 수 없어요(이동은 돼요)",
|
||||
why_last = "마지막 테이블·의자는 지울 수 없어요",
|
||||
why_hasChairs = "이 테이블을 보는 의자를 먼저 옮기거나 지워요",
|
||||
why_busy = "손님이 앉아 있는 의자예요. 다 먹고 나면 지워요",
|
||||
removed = "{name}을(를) 지우고 {money}원을 돌려받았어요",
|
||||
removeFail = "못 지워요: {reason}",
|
||||
thing_Decor = "소품",
|
||||
nameColor = "이름 색",
|
||||
devFree = "결제 테스트 켜기",
|
||||
devFreeBtnOn = "결제 테스트 켜기",
|
||||
devFreeBtnOff = "결제 테스트 끄기",
|
||||
devFreeOn = "결제 테스트 모드: 로벅스 버튼이 결제 없이 바로 돼요(이번 접속만). 게임패스는 안 가진 상태로 바꿨어요",
|
||||
devFreeOff = "결제 테스트 모드를 껐어요. 실제로 가진 게임패스로 돌아가요",
|
||||
seatsNow = "자리 {n}/{max}",
|
||||
decorNow = "소품 {n}/{max}",
|
||||
staffLockedCard = "알바생 기능 업그레이드를 사면 열려요",
|
||||
goUpgrade = "업그레이드 보기",
|
||||
role_Cook = "요리 알바",
|
||||
role_Server = "서빙 알바",
|
||||
role_Promoter = "홍보 알바",
|
||||
roleDesc_Cook = "접시를 만들어 둬요",
|
||||
roleDesc_Server = "손님에게 날라 줘요",
|
||||
roleDesc_Promoter = "손님이 더 빨리 와요",
|
||||
hire = "고용",
|
||||
fire = "빼기",
|
||||
wage = "시급 {wage}원 · 1분마다",
|
||||
wageTotal = "시급 합계 {wage}원 · 1분마다",
|
||||
strikeBanner = "돈이 모자라서 알바생이 쉬고 있어요",
|
||||
shopName = "가게 이름",
|
||||
namePlaceholder = "이름을 써 주세요",
|
||||
save = "저장",
|
||||
rainbow = "무지개 이름",
|
||||
designs = "가게 디자인",
|
||||
design_Basic = "기본",
|
||||
design_Mint = "민트",
|
||||
design_Brick = "벽돌",
|
||||
design_Candy = "사탕 궁전",
|
||||
design_Hanok = "한옥",
|
||||
inUse = "사용 중",
|
||||
btnPromote = "홍보",
|
||||
btnRush = "러시",
|
||||
promoteTitle = "홍보하기",
|
||||
promoteAdText = "광고를 보면\n옆 가게 손님이 와요",
|
||||
watchAd = "광고 보기",
|
||||
promoteFree = "그냥 홍보",
|
||||
kickAction = "손님 쫓아내기",
|
||||
decoPick = "옮길 물건(테이블·의자·소품·조리대)을 눌러요",
|
||||
decoMove = "바닥을 눌러 옮겨요",
|
||||
decoChair = "쪽을 고르거나 다른 테이블을 눌러요",
|
||||
decoOk = "여기 좋아요! [놓기]를 눌러요",
|
||||
rotate = "돌리기",
|
||||
placeIt = "놓기",
|
||||
cancel = "취소",
|
||||
exit = "나가기",
|
||||
floorN = "{n}층",
|
||||
side_1 = "앞",
|
||||
side_2 = "오른쪽",
|
||||
side_3 = "뒤",
|
||||
side_4 = "왼쪽",
|
||||
why_bounds = "가게 밖이에요",
|
||||
why_overlap = "다른 물건과 겹쳐요",
|
||||
why_reserved = "문 앞과 계단은 비워 둬요",
|
||||
why_floor = "2층이 아직 없어요",
|
||||
why_blocked = "손님 길이 막혀요",
|
||||
why_chair = "의자가 테이블을 보게 놓아요([돌리기])",
|
||||
why_none = "다시 골라 주세요",
|
||||
upgraded = "{name} Lv{level}!",
|
||||
floor2 = "2층이 생겼어요! 테이블을 더 놓을 수 있어요",
|
||||
seatAdded = "의자를 놓았어요! 손님 자리가 늘었어요",
|
||||
tableAdded = "테이블을 놓았어요!",
|
||||
decorAdded = "{name} 설치 완료!",
|
||||
noSpace = "놓을 곳이 없어요. [배치하기]로 옮겨 보세요",
|
||||
seatMax = "자리가 꽉 찼어요. 건물을 키워 보세요",
|
||||
tableMax = "테이블을 더 놓을 수 없어요",
|
||||
tableFull = "테이블마다 의자가 꽉 찼어요. 테이블을 사요",
|
||||
needStage = "건물을 먼저 키워요",
|
||||
placeFail = "여기는 안 돼요: {reason}",
|
||||
hired = "{name} 고용!",
|
||||
fired = "{name} 한 명을 뺐어요",
|
||||
staffLocked = "알바생 기능을 먼저 사요",
|
||||
staffMax = "더 고용할 수 없어요",
|
||||
strike = "돈이 모자라 알바생이 쉬어요",
|
||||
strikeOver = "알바생이 다시 일해요!",
|
||||
renamed = "가게 이름을 바꿨어요!",
|
||||
nameRejected = "그 이름은 쓸 수 없어요",
|
||||
designSet = "{name} 디자인으로 바꿨어요!",
|
||||
designLocked = "실내 분식집부터 바꿀 수 있어요",
|
||||
promoted = "손님 {n}명이 우리 가게로 와요!",
|
||||
promoteNone = "데려올 손님이 없어요",
|
||||
promoteFull = "빈자리가 없어요",
|
||||
promoteWait = "{sec}초 뒤에 다시 할 수 있어요",
|
||||
adUnavailable = "지금은 광고를 볼 수 없어요",
|
||||
kicked = "손님 {n}명이 우리 가게로 왔어요!",
|
||||
kickedBy = "{name}님이 우리 손님을 데려갔어요!",
|
||||
shielded = "그 가게는 잠깐 보호 중이에요",
|
||||
kickOwn = "내 가게에는 쓸 수 없어요",
|
||||
rushOn = "손님 러시 {min}분 시작!",
|
||||
},
|
||||
en = {
|
||||
title = "Bunsik Tycoon",
|
||||
money = "₩{money}",
|
||||
buy = "Buy",
|
||||
bought = "Done",
|
||||
locked = "Locked",
|
||||
notEnough = "Need ₩{need} more",
|
||||
maxed = "All upgrades done!",
|
||||
next = "Next",
|
||||
nextUp = "Next Upgrade",
|
||||
doubleOn = "Active",
|
||||
close = "Close",
|
||||
cookAction = "Cook",
|
||||
cook_Twigim_3 = "Pick it up with the tongs",
|
||||
cook_Twigim_2 = "Fry it until crispy",
|
||||
cook_Twigim_1 = "Coat the shrimp in batter",
|
||||
cook_Eomuk_2 = "Dip it in the hot soup",
|
||||
cook_Eomuk_1 = "Put the fish cake on the skewer",
|
||||
cook_Sundae_3 = "Slice it up",
|
||||
cook_Sundae_2 = "Steam it nice and hot",
|
||||
cook_Sundae_1 = "Put the sundae in the steamer",
|
||||
cook_Gimbap_3 = "Slice it",
|
||||
cook_Gimbap_2 = "Roll it up",
|
||||
cook_Gimbap_1 = "Put fillings on the seaweed",
|
||||
cook_Tteokbokki_3 = "Stir it with the spatula",
|
||||
cook_Tteokbokki_2 = "Pour in the red sauce",
|
||||
cook_Tteokbokki_1 = "Put the rice cakes in the pan",
|
||||
gestureRub = "Rub rub!",
|
||||
gestureHold = "Press and hold",
|
||||
gestureTap = "Tap! x{n}",
|
||||
cookDone = "Done!",
|
||||
chooseMenu = "What shall we cook? Pick what a customer ordered!",
|
||||
cookTitle = "Cooking",
|
||||
btnBoost = "Boost",
|
||||
btnDouble = "2x Cash",
|
||||
btnShop = "Shop",
|
||||
cookWait = "Waiting for customers",
|
||||
cookHandFull = "Hands are full! Serve the customer first",
|
||||
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! 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",
|
||||
doubleDesc = "All sales are doubled forever",
|
||||
boost = "Money Boost",
|
||||
boostDesc = "Get 10 minutes of sales (₩{amount}) now",
|
||||
boostGot = "Money Boost: +₩{amount}!",
|
||||
purchased = "{name} bought!",
|
||||
newMenu = "New menu: {menuName}! Customers will start ordering it",
|
||||
expanded = "Your shop moved indoors! You can change its design now",
|
||||
plotOwner = "{name}'s Bunsik Shop",
|
||||
plotEmpty = "Empty lot",
|
||||
neighbor = "Neighbor shop",
|
||||
helperNote = "Your helper is cooking! Grab dishes from the counter",
|
||||
saveFail = "Couldn't load your save. Please rejoin",
|
||||
serverFull = "Server is full",
|
||||
visitor = "This is a friend's shop",
|
||||
devTitle = "Dev test",
|
||||
devMoney = "+₩1,000",
|
||||
devDouble = "Toggle x2",
|
||||
devReset = "Reset",
|
||||
devResetDone = "Progress reset",
|
||||
settings = "Settings",
|
||||
language = "Language",
|
||||
langAuto = "Auto",
|
||||
mouseLook = "Turn camera with mouse",
|
||||
mouseHint = "Hold Ctrl to show the mouse cursor",
|
||||
sfx = "Sound effects",
|
||||
on = "On",
|
||||
off = "Off",
|
||||
visitAction = "Eat here as a customer",
|
||||
visitFull = "No free seats. Come back in a bit",
|
||||
guestSeated = "You sat down! Wait for your food (jump to stand up)",
|
||||
guestBonus = "Yum! Tasting bonus +₩{amount}",
|
||||
guestAte = "Yum! That was tasty",
|
||||
guestHungry = "The food took too long, so you stood up",
|
||||
guestArrived = "{name} came in as a customer! They pay double",
|
||||
npcShop1 = "Tteoksun's Bunsik",
|
||||
npcShop2 = "Grandma's Bunsik",
|
||||
npcShop3 = "Little Bunsik",
|
||||
npcShop4 = "Yummy Bunsik",
|
||||
npcShop5 = "Alley Bunsik",
|
||||
npcShop6 = "Twigim King",
|
||||
menu_Tteokbokki = "Tteokbokki",
|
||||
menu_Gimbap = "Gimbap",
|
||||
menu_Sundae = "Sundae",
|
||||
menu_Eomuk = "Fish Cake",
|
||||
menu_Twigim = "Twigim",
|
||||
stage_1 = "Street Stall",
|
||||
stage_2 = "Indoor Shop",
|
||||
stage_3 = "2-Floor Shop",
|
||||
tabUpgrade = "Upgrades",
|
||||
tabDecor = "Decorate",
|
||||
tabStaff = "Staff",
|
||||
tabMine = "My Shop",
|
||||
track_Stage = "Building",
|
||||
track_Menu = "New Menu",
|
||||
track_Price = "Prices",
|
||||
track_Speed = "Customer Speed",
|
||||
track_Stove = "Stove",
|
||||
track_Tray = "Tray",
|
||||
track_Staff = "Staff Unlock",
|
||||
fx_Stage = "{from} → {to}",
|
||||
fx_Menu = "New: {menuName}",
|
||||
fx_Price = "Prices x{from} → x{to}",
|
||||
fx_Speed = "Customer every {from}s → {to}s",
|
||||
fx_Stove = "Cooking work {from}% → {to}%",
|
||||
fx_Tray = "Carry {from} → {to} dishes",
|
||||
fx_Staff = "You can hire staff",
|
||||
lockStage2 = "From Indoor Shop",
|
||||
lockStage3 = "From 2nd Floor",
|
||||
full = "Full",
|
||||
needTable = "Table first",
|
||||
thing_Seat = "Chair",
|
||||
thing_Table = "Table",
|
||||
decor_Plant = "Plant",
|
||||
decor_Rug = "Rug",
|
||||
decor_Balloons = "Balloons",
|
||||
decor_Lamp = "Lamp",
|
||||
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",
|
||||
btnMove = "Move",
|
||||
btnDelete = "Delete",
|
||||
decoChoose = "Pick something below to place. Use [Move]/[Delete] to fix furniture",
|
||||
decoPickMove = "Tap the furniture to move",
|
||||
decoPickDelete = "Tap the furniture to delete",
|
||||
decoDeleteAsk = "Tap [Delete] to remove it and get {money} back",
|
||||
why_stove = "The stove can't be deleted (you can move it)",
|
||||
why_last = "You can't delete your last table or chair",
|
||||
why_hasChairs = "Move or delete the chairs facing this table first",
|
||||
why_busy = "A customer is sitting there. Try after they finish",
|
||||
removed = "Removed {name} and got {money} back",
|
||||
removeFail = "Can't delete: {reason}",
|
||||
thing_Decor = "Decor",
|
||||
nameColor = "Name color",
|
||||
devFree = "Test pay ON",
|
||||
devFreeBtnOn = "Test pay ON",
|
||||
devFreeBtnOff = "Test pay OFF",
|
||||
devFreeOn = "Test pay mode: Robux buttons work for free (this session). Game passes were reset to not owned",
|
||||
devFreeOff = "Test pay mode off. Back to the game passes you really own",
|
||||
seatsNow = "Seats {n}/{max}",
|
||||
decorNow = "Decor {n}/{max}",
|
||||
staffLockedCard = "Buy the Staff Unlock upgrade to open this",
|
||||
goUpgrade = "See upgrades",
|
||||
role_Cook = "Cook",
|
||||
role_Server = "Server",
|
||||
role_Promoter = "Promoter",
|
||||
roleDesc_Cook = "Makes dishes for you",
|
||||
roleDesc_Server = "Brings food to customers",
|
||||
roleDesc_Promoter = "Customers come faster",
|
||||
hire = "Hire",
|
||||
fire = "Remove",
|
||||
wage = "Pay ₩{wage} · every min",
|
||||
wageTotal = "Total pay ₩{wage} · every min",
|
||||
strikeBanner = "Not enough money, so staff are resting",
|
||||
shopName = "Shop name",
|
||||
namePlaceholder = "Type a name",
|
||||
save = "Save",
|
||||
rainbow = "Rainbow name",
|
||||
designs = "Shop design",
|
||||
design_Basic = "Classic",
|
||||
design_Mint = "Mint",
|
||||
design_Brick = "Brick",
|
||||
design_Candy = "Candy Palace",
|
||||
design_Hanok = "Hanok",
|
||||
inUse = "In use",
|
||||
btnPromote = "Promote",
|
||||
btnRush = "Rush",
|
||||
promoteTitle = "Promote",
|
||||
promoteAdText = "Watch an ad and customers from other shops come to yours",
|
||||
watchAd = "Watch ad",
|
||||
promoteFree = "Just promote",
|
||||
kickAction = "Shoo customers",
|
||||
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]",
|
||||
rotate = "Turn",
|
||||
placeIt = "Place",
|
||||
cancel = "Cancel",
|
||||
exit = "Exit",
|
||||
floorN = "{n}F",
|
||||
side_1 = "Front",
|
||||
side_2 = "Right",
|
||||
side_3 = "Back",
|
||||
side_4 = "Left",
|
||||
why_bounds = "That's outside the shop",
|
||||
why_overlap = "It overlaps something",
|
||||
why_reserved = "Keep the door and stairs clear",
|
||||
why_floor = "No 2nd floor yet",
|
||||
why_blocked = "It blocks the customers' path",
|
||||
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",
|
||||
seatAdded = "Chair placed! One more seat",
|
||||
tableAdded = "Table placed!",
|
||||
decorAdded = "{name} placed!",
|
||||
noSpace = "No space. Move things with [Arrange]",
|
||||
seatMax = "Seats are full. Upgrade your building",
|
||||
tableMax = "Can't add more tables",
|
||||
tableFull = "Every table is full of chairs. Buy a table",
|
||||
needStage = "Upgrade your building first",
|
||||
placeFail = "Can't go here: {reason}",
|
||||
hired = "Hired a {name}!",
|
||||
fired = "Removed a {name}",
|
||||
staffLocked = "Buy the Staff Unlock first",
|
||||
staffMax = "Can't hire more",
|
||||
strike = "Not enough money, so staff stopped working",
|
||||
strikeOver = "Staff are back to work!",
|
||||
renamed = "Shop renamed!",
|
||||
nameRejected = "That name can't be used",
|
||||
designSet = "Changed to {name}!",
|
||||
designLocked = "Unlocks with the Indoor Shop",
|
||||
promoted = "{n} customers are coming to your shop!",
|
||||
promoteNone = "No customers to bring",
|
||||
promoteFull = "No free seats",
|
||||
promoteWait = "Try again in {sec}s",
|
||||
adUnavailable = "No ad right now",
|
||||
kicked = "{n} customers came to your shop!",
|
||||
kickedBy = "{name} took your customers!",
|
||||
shielded = "That shop is protected for now",
|
||||
kickOwn = "Not on your own shop",
|
||||
rushOn = "Customer rush for {min} min!",
|
||||
},
|
||||
ja = {
|
||||
title = "ブンシク・タイクーン",
|
||||
money = "₩{money}",
|
||||
buy = "買う",
|
||||
bought = "完了",
|
||||
locked = "ロック中",
|
||||
notEnough = "あと₩{need}必要です",
|
||||
maxed = "アップグレードぜんぶ完了!",
|
||||
next = "次",
|
||||
nextUp = "次のアップグレード",
|
||||
doubleOn = "適用中",
|
||||
close = "閉じる",
|
||||
cookAction = "料理する",
|
||||
cook_Twigim_3 = "トングで取り出そう",
|
||||
cook_Twigim_2 = "カリッと揚げよう",
|
||||
cook_Twigim_1 = "エビに衣をつけよう",
|
||||
cook_Eomuk_2 = "スープにつけよう",
|
||||
cook_Eomuk_1 = "おでんを串にさそう",
|
||||
cook_Sundae_3 = "食べやすく切ろう",
|
||||
cook_Sundae_2 = "ほかほかに蒸そう",
|
||||
cook_Sundae_1 = "スンデを蒸し器に入れよう",
|
||||
cook_Gimbap_3 = "トントン切ろう",
|
||||
cook_Gimbap_2 = "くるくる巻こう",
|
||||
cook_Gimbap_1 = "のりの上に具をのせよう",
|
||||
cook_Tteokbokki_3 = "ヘラでぐるぐる混ぜよう",
|
||||
cook_Tteokbokki_2 = "赤いタレをかけよう",
|
||||
cook_Tteokbokki_1 = "おもちをフライパンに入れよう",
|
||||
gestureRub = "こすこす!",
|
||||
gestureHold = "長押し",
|
||||
gestureTap = "タップ!{n}回",
|
||||
cookDone = "できた!",
|
||||
chooseMenu = "何を作る?お客さんの注文を選んでね!",
|
||||
cookTitle = "料理する",
|
||||
btnBoost = "ブースト",
|
||||
btnDouble = "2倍",
|
||||
btnShop = "ショップ",
|
||||
cookWait = "お客さんを待っています",
|
||||
cookHandFull = "手がいっぱい!先にお客さんに運んでね",
|
||||
stoveObject = "コンロ",
|
||||
tut1 = "お客さんが来たよ!光っているコンロに行って料理を始めよう",
|
||||
tut2 = "できた!お皿をお客さんの席まで運んでね",
|
||||
tut3 = "お金をかせいだよ![かざる]でいすを選んで、テーブルの前に置いてね",
|
||||
tutDone = "よくできました!お客さんを迎えて、お店を大きくしよう",
|
||||
double = "収益2倍",
|
||||
doubleOwned = "収益2倍 適用中",
|
||||
doubleDesc = "すべての売上がずっと2倍",
|
||||
boost = "マネーブースト",
|
||||
boostDesc = "今の売上10分ぶん(₩{amount})をすぐにもらう",
|
||||
boostGot = "マネーブースト ₩{amount}をもらいました!",
|
||||
purchased = "{name}を買いました!",
|
||||
newMenu = "新メニュー「{menuName}」!お客さんが{menuName}も注文するようになるよ",
|
||||
expanded = "室内のお店に広げました!デザインも変えられるよ",
|
||||
plotOwner = "{name}のブンシク店",
|
||||
plotEmpty = "空き地",
|
||||
neighbor = "となりのお店",
|
||||
helperNote = "アルバイトが料理中!カウンターからお皿を取ってね",
|
||||
saveFail = "セーブデータを読み込めませんでした。もう一度入ってください",
|
||||
serverFull = "サーバーが満員です",
|
||||
visitor = "友だちのお店です",
|
||||
devTitle = "開発者テスト",
|
||||
devMoney = "+₩1,000",
|
||||
devDouble = "2倍 オン/オフ",
|
||||
devReset = "最初から",
|
||||
devResetDone = "進行状況を最初に戻しました",
|
||||
settings = "設定",
|
||||
language = "言語",
|
||||
langAuto = "自動",
|
||||
mouseLook = "マウスでカメラを回す",
|
||||
mouseHint = "Ctrlを押している間はマウスカーソルが出ます",
|
||||
sfx = "効果音",
|
||||
on = "オン",
|
||||
off = "オフ",
|
||||
visitAction = "お客さんとして入る",
|
||||
visitFull = "空いている席がありません。少ししてから来てね",
|
||||
guestSeated = "席に座ったよ!料理を待とう(ジャンプで立ち上がる)",
|
||||
guestBonus = "もぐもぐ!試食ボーナス ₩{amount}をもらいました",
|
||||
guestAte = "もぐもぐ!おいしかった",
|
||||
guestHungry = "料理が遅すぎたので立ち上がりました",
|
||||
guestArrived = "{name}さんがお客さんとして来たよ!このお客さんは2倍払います",
|
||||
npcShop1 = "トッスニ食堂",
|
||||
npcShop2 = "おばあちゃん食堂",
|
||||
npcShop3 = "ちびっこ食堂",
|
||||
npcShop4 = "うまうま食堂",
|
||||
npcShop5 = "路地裏食堂",
|
||||
npcShop6 = "天ぷら王食堂",
|
||||
menu_Tteokbokki = "トッポッキ",
|
||||
menu_Gimbap = "キンパ",
|
||||
menu_Sundae = "スンデ",
|
||||
menu_Eomuk = "おでん",
|
||||
menu_Twigim = "天ぷら",
|
||||
stage_1 = "屋台",
|
||||
stage_2 = "室内のお店",
|
||||
stage_3 = "2階建てのお店",
|
||||
tabUpgrade = "アップグレード",
|
||||
tabDecor = "かざる",
|
||||
tabStaff = "アルバイト",
|
||||
tabMine = "わたしのお店",
|
||||
track_Stage = "お店の建物",
|
||||
track_Menu = "新メニュー",
|
||||
track_Price = "売る値段",
|
||||
track_Speed = "お客さんの速さ",
|
||||
track_Stove = "コンロ",
|
||||
track_Tray = "おぼん",
|
||||
track_Staff = "アルバイト解放",
|
||||
fx_Stage = "{from} → {to}",
|
||||
fx_Menu = "新メニュー {menuName}",
|
||||
fx_Price = "値段 x{from} → x{to}",
|
||||
fx_Speed = "お客さん {from}秒ごと → {to}秒ごと",
|
||||
fx_Stove = "料理の手間 {from}% → {to}%",
|
||||
fx_Tray = "お皿 {from}枚 → {to}枚",
|
||||
fx_Staff = "アルバイトをやとえるよ",
|
||||
lockStage2 = "室内のお店から",
|
||||
lockStage3 = "2階から",
|
||||
full = "いっぱい",
|
||||
needTable = "先にテーブル",
|
||||
thing_Seat = "いす",
|
||||
thing_Table = "テーブル",
|
||||
decor_Plant = "植木",
|
||||
decor_Rug = "じゅうたん",
|
||||
decor_Balloons = "ふうせん",
|
||||
decor_Lamp = "ランプ",
|
||||
decor_Teddy = "くまのぬいぐるみ",
|
||||
decor_Fridge = "れいぞうこ",
|
||||
place = "ならべる",
|
||||
btnDecorate = "かざる",
|
||||
decorateTitle = "お店をかざる",
|
||||
moveItems = "動かす",
|
||||
decoKeys = "(R 回す · F 置く)",
|
||||
why_money = "お金が足りないよ",
|
||||
btnMove = "移動",
|
||||
btnDelete = "削除",
|
||||
decoChoose = "下から置く物を選んでね。[移動]・[削除]で家具をなおせるよ",
|
||||
decoPickMove = "移動する家具をタップしてね",
|
||||
decoPickDelete = "削除する家具をタップしてね",
|
||||
decoDeleteAsk = "[削除]を押すと消して{money}円もどってくるよ",
|
||||
why_stove = "コンロは消せないよ(移動はできるよ)",
|
||||
why_last = "最後のテーブル・いすは消せないよ",
|
||||
why_hasChairs = "このテーブルを向いたいすを先に動かすか消してね",
|
||||
why_busy = "お客さんが座っているいすだよ。食べ終わったら消してね",
|
||||
removed = "{name}を消して{money}円もどってきたよ",
|
||||
removeFail = "消せないよ: {reason}",
|
||||
thing_Decor = "小物",
|
||||
nameColor = "名前の色",
|
||||
devFree = "課金テスト オン",
|
||||
devFreeBtnOn = "課金テスト オン",
|
||||
devFreeBtnOff = "課金テスト オフ",
|
||||
devFreeOn = "課金テストモード: Robuxボタンが支払いなしで使えます(今回だけ)。ゲームパスは持っていない状態にしました",
|
||||
devFreeOff = "課金テストモードをオフにしました。実際に持っているゲームパスに戻ります",
|
||||
seatsNow = "席 {n}/{max}",
|
||||
decorNow = "かざり {n}/{max}",
|
||||
staffLockedCard = "「アルバイト解放」を買うと開くよ",
|
||||
goUpgrade = "アップグレードを見る",
|
||||
role_Cook = "料理係",
|
||||
role_Server = "配膳係",
|
||||
role_Promoter = "宣伝係",
|
||||
roleDesc_Cook = "お皿を作っておくよ",
|
||||
roleDesc_Server = "お客さんに運ぶよ",
|
||||
roleDesc_Promoter = "お客さんが早く来るよ",
|
||||
hire = "やとう",
|
||||
fire = "へらす",
|
||||
wage = "時給 ₩{wage}・1分ごと",
|
||||
wageTotal = "時給の合計 ₩{wage}・1分ごと",
|
||||
strikeBanner = "お金が足りなくてアルバイトが休んでいるよ",
|
||||
shopName = "お店の名前",
|
||||
namePlaceholder = "名前を書いてね",
|
||||
save = "保存",
|
||||
rainbow = "にじ色の名前",
|
||||
designs = "お店のデザイン",
|
||||
design_Basic = "基本",
|
||||
design_Mint = "ミント",
|
||||
design_Brick = "レンガ",
|
||||
design_Candy = "キャンディ城",
|
||||
design_Hanok = "韓屋",
|
||||
inUse = "使用中",
|
||||
btnPromote = "宣伝",
|
||||
btnRush = "ラッシュ",
|
||||
promoteTitle = "宣伝する",
|
||||
promoteAdText = "広告を見ると、となりのお店のお客さんがこっちに来るよ",
|
||||
watchAd = "広告を見る",
|
||||
promoteFree = "ふつうに宣伝",
|
||||
kickAction = "お客さんを追い出す",
|
||||
decoPick = "動かす物(テーブル・いす・小物・コンロ)をタップしてね",
|
||||
decoMove = "床をタップして動かそう",
|
||||
decoChair = "向きを選ぶか、別のテーブルをタップ",
|
||||
decoOk = "いいね![置く]をタップ",
|
||||
rotate = "回す",
|
||||
placeIt = "置く",
|
||||
cancel = "キャンセル",
|
||||
exit = "出る",
|
||||
floorN = "{n}階",
|
||||
side_1 = "前",
|
||||
side_2 = "右",
|
||||
side_3 = "後ろ",
|
||||
side_4 = "左",
|
||||
why_bounds = "お店の外だよ",
|
||||
why_overlap = "ほかの物と重なるよ",
|
||||
why_reserved = "ドアと階段の前はあけてね",
|
||||
why_floor = "2階がまだないよ",
|
||||
why_blocked = "お客さんの道がふさがるよ",
|
||||
why_chair = "いすをテーブルに向けてね([回す])",
|
||||
why_none = "もう一度選んでね",
|
||||
upgraded = "{name} Lv{level}!",
|
||||
floor2 = "2階ができたよ!テーブルをもっと置けるよ",
|
||||
seatAdded = "いすを置いたよ!席がふえたよ",
|
||||
tableAdded = "テーブルを置いたよ!",
|
||||
decorAdded = "{name}を置いたよ!",
|
||||
noSpace = "置く場所がないよ。[ならべる]で動かしてみて",
|
||||
seatMax = "席がいっぱい。建物を大きくしよう",
|
||||
tableMax = "これ以上テーブルを置けないよ",
|
||||
tableFull = "どのテーブルもいすがいっぱい。テーブルを買おう",
|
||||
needStage = "先に建物を大きくしよう",
|
||||
placeFail = "ここはだめ:{reason}",
|
||||
hired = "{name}をやとったよ!",
|
||||
fired = "{name}を一人へらしたよ",
|
||||
staffLocked = "先に「アルバイト解放」を買おう",
|
||||
staffMax = "これ以上やとえないよ",
|
||||
strike = "お金が足りなくてアルバイトが休んでるよ",
|
||||
strikeOver = "アルバイトがまた働くよ!",
|
||||
renamed = "お店の名前を変えたよ!",
|
||||
nameRejected = "その名前は使えないよ",
|
||||
designSet = "{name}デザインにしたよ!",
|
||||
designLocked = "室内のお店から変えられるよ",
|
||||
promoted = "お客さんが{n}人来るよ!",
|
||||
promoteNone = "連れてこられるお客さんがいないよ",
|
||||
promoteFull = "空いている席がないよ",
|
||||
promoteWait = "{sec}秒後にまたできるよ",
|
||||
adUnavailable = "今は広告を見られないよ",
|
||||
kicked = "お客さんが{n}人こっちに来たよ!",
|
||||
kickedBy = "{name}さんがお客さんを連れていったよ!",
|
||||
shielded = "そのお店は今守られているよ",
|
||||
kickOwn = "自分のお店には使えないよ",
|
||||
rushOn = "お客さんラッシュ{min}分スタート!",
|
||||
},
|
||||
zh = {
|
||||
title = "韩式小吃大亨",
|
||||
money = "₩{money}",
|
||||
buy = "购买",
|
||||
bought = "已完成",
|
||||
locked = "未解锁",
|
||||
notEnough = "还差₩{need}",
|
||||
maxed = "所有升级都完成了!",
|
||||
next = "下一个",
|
||||
nextUp = "下一个升级",
|
||||
doubleOn = "已生效",
|
||||
close = "关闭",
|
||||
cookAction = "做菜",
|
||||
cook_Twigim_3 = "用夹子夹出来",
|
||||
cook_Twigim_2 = "炸得脆脆的",
|
||||
cook_Twigim_1 = "给虾裹上面糊",
|
||||
cook_Eomuk_2 = "放进汤里泡一泡",
|
||||
cook_Eomuk_1 = "把鱼饼串到签子上",
|
||||
cook_Sundae_3 = "切成小块",
|
||||
cook_Sundae_2 = "热乎乎地蒸",
|
||||
cook_Sundae_1 = "把米肠放进蒸锅",
|
||||
cook_Gimbap_3 = "切成片",
|
||||
cook_Gimbap_2 = "卷起来",
|
||||
cook_Gimbap_1 = "在紫菜上放馅料",
|
||||
cook_Tteokbokki_3 = "用铲子搅一搅",
|
||||
cook_Tteokbokki_2 = "倒入红色酱料",
|
||||
cook_Tteokbokki_1 = "把年糕放进锅里",
|
||||
gestureRub = "来回搓!",
|
||||
gestureHold = "按住不放",
|
||||
gestureTap = "点一点!{n}次",
|
||||
cookDone = "完成!",
|
||||
chooseMenu = "做什么呢?选客人点的菜吧!",
|
||||
cookTitle = "做菜",
|
||||
btnBoost = "加速",
|
||||
btnDouble = "双倍",
|
||||
btnShop = "商店",
|
||||
cookWait = "等待客人中",
|
||||
cookHandFull = "手里拿满了!先端给客人吧",
|
||||
stoveObject = "灶台",
|
||||
tut1 = "客人来了!走到发光的灶台开始做菜吧",
|
||||
tut2 = "做好了!把盘子端到客人的座位上",
|
||||
tut3 = "赚到钱了!在[装饰]里选一把椅子,放在桌子前面吧",
|
||||
tutDone = "做得好!继续招待客人,把店做大吧",
|
||||
double = "双倍收益",
|
||||
doubleOwned = "双倍收益生效中",
|
||||
doubleDesc = "所有销售额永久翻倍",
|
||||
boost = "金钱加速",
|
||||
boostDesc = "立即获得当前10分钟的销售额(₩{amount})",
|
||||
boostGot = "金钱加速:获得₩{amount}!",
|
||||
purchased = "已购买{name}!",
|
||||
newMenu = "新菜品:{menuName}!客人会开始点{menuName}了",
|
||||
expanded = "搬进室内小吃店了!现在可以更换设计",
|
||||
plotOwner = "{name}的小吃店",
|
||||
plotEmpty = "空地",
|
||||
neighbor = "邻居的店",
|
||||
helperNote = "店员正在做菜!去柜台拿盘子吧",
|
||||
saveFail = "无法读取存档,请重新加入",
|
||||
serverFull = "服务器已满",
|
||||
visitor = "这是朋友的店",
|
||||
devTitle = "开发者测试",
|
||||
devMoney = "+₩1,000",
|
||||
devDouble = "开关双倍",
|
||||
devReset = "重新开始",
|
||||
devResetDone = "进度已重置",
|
||||
settings = "设置",
|
||||
language = "语言",
|
||||
langAuto = "自动",
|
||||
mouseLook = "移动鼠标转动视角",
|
||||
mouseHint = "按住Ctrl会显示鼠标光标",
|
||||
sfx = "音效",
|
||||
on = "开",
|
||||
off = "关",
|
||||
visitAction = "作为客人进店",
|
||||
visitFull = "没有空座位,过一会儿再来吧",
|
||||
guestSeated = "坐下了!等着上菜吧(跳一下就能站起来)",
|
||||
guestBonus = "好吃!获得试吃奖励₩{amount}",
|
||||
guestAte = "好吃!真美味",
|
||||
guestHungry = "菜上得太慢,你站起来了",
|
||||
guestArrived = "{name}作为客人来了!这位客人付双倍价钱",
|
||||
npcShop1 = "小年糕小吃店",
|
||||
npcShop2 = "奶奶小吃店",
|
||||
npcShop3 = "小不点小吃店",
|
||||
npcShop4 = "美味小吃店",
|
||||
npcShop5 = "胡同小吃店",
|
||||
npcShop6 = "炸物王小吃店",
|
||||
menu_Tteokbokki = "炒年糕",
|
||||
menu_Gimbap = "紫菜包饭",
|
||||
menu_Sundae = "血肠",
|
||||
menu_Eomuk = "鱼饼",
|
||||
menu_Twigim = "炸物",
|
||||
stage_1 = "路边摊",
|
||||
stage_2 = "室内小吃店",
|
||||
stage_3 = "两层小吃店",
|
||||
tabUpgrade = "升级",
|
||||
tabDecor = "装饰",
|
||||
tabStaff = "店员",
|
||||
tabMine = "我的店",
|
||||
track_Stage = "店铺建筑",
|
||||
track_Menu = "新菜品",
|
||||
track_Price = "售价",
|
||||
track_Speed = "客人速度",
|
||||
track_Stove = "灶台",
|
||||
track_Tray = "托盘",
|
||||
track_Staff = "解锁店员",
|
||||
fx_Stage = "{from} → {to}",
|
||||
fx_Menu = "新菜品 {menuName}",
|
||||
fx_Price = "售价 x{from} → x{to}",
|
||||
fx_Speed = "每{from}秒 → 每{to}秒来客",
|
||||
fx_Stove = "做菜步骤 {from}% → {to}%",
|
||||
fx_Tray = "盘子 {from}个 → {to}个",
|
||||
fx_Staff = "可以雇佣店员",
|
||||
lockStage2 = "室内小吃店解锁",
|
||||
lockStage3 = "两层后解锁",
|
||||
full = "已满",
|
||||
needTable = "先买桌子",
|
||||
thing_Seat = "椅子",
|
||||
thing_Table = "桌子",
|
||||
decor_Plant = "盆栽",
|
||||
decor_Rug = "地毯",
|
||||
decor_Balloons = "气球",
|
||||
decor_Lamp = "台灯",
|
||||
decor_Teddy = "泰迪熊",
|
||||
decor_Fridge = "冰箱",
|
||||
place = "摆放",
|
||||
btnDecorate = "装饰",
|
||||
decorateTitle = "装饰店铺",
|
||||
moveItems = "移动",
|
||||
decoKeys = "(R 旋转 · F 放下)",
|
||||
why_money = "钱不够",
|
||||
btnMove = "移动",
|
||||
btnDelete = "删除",
|
||||
decoChoose = "从下面选要摆放的东西。用[移动]·[删除]调整家具",
|
||||
decoPickMove = "点要移动的家具",
|
||||
decoPickDelete = "点要删除的家具",
|
||||
decoDeleteAsk = "按[删除]就会删掉并退回{money}元",
|
||||
why_stove = "灶台不能删除(可以移动)",
|
||||
why_last = "最后一张桌子或椅子不能删除",
|
||||
why_hasChairs = "先移动或删除朝向这张桌子的椅子",
|
||||
why_busy = "有客人坐在这把椅子上。吃完再删吧",
|
||||
removed = "删除了{name},退回{money}元",
|
||||
removeFail = "不能删除: {reason}",
|
||||
thing_Decor = "摆件",
|
||||
nameColor = "名字颜色",
|
||||
devFree = "付费测试 开",
|
||||
devFreeBtnOn = "付费测试 开",
|
||||
devFreeBtnOff = "付费测试 关",
|
||||
devFreeOn = "付费测试模式: Robux按钮无需付款即可使用(仅本次)。游戏通行证已改为未拥有",
|
||||
devFreeOff = "已关闭付费测试模式。恢复为实际拥有的游戏通行证",
|
||||
seatsNow = "座位 {n}/{max}",
|
||||
decorNow = "装饰 {n}/{max}",
|
||||
staffLockedCard = "购买“解锁店员”升级后开放",
|
||||
goUpgrade = "查看升级",
|
||||
role_Cook = "厨师",
|
||||
role_Server = "服务员",
|
||||
role_Promoter = "宣传员",
|
||||
roleDesc_Cook = "帮你做好菜",
|
||||
roleDesc_Server = "把菜端给客人",
|
||||
roleDesc_Promoter = "客人来得更快",
|
||||
hire = "雇佣",
|
||||
fire = "减少",
|
||||
wage = "时薪 ₩{wage}・每分钟",
|
||||
wageTotal = "时薪合计 ₩{wage}・每分钟",
|
||||
strikeBanner = "钱不够,店员在休息",
|
||||
shopName = "店名",
|
||||
namePlaceholder = "输入店名",
|
||||
save = "保存",
|
||||
rainbow = "彩虹店名",
|
||||
designs = "店铺设计",
|
||||
design_Basic = "经典",
|
||||
design_Mint = "薄荷",
|
||||
design_Brick = "砖墙",
|
||||
design_Candy = "糖果宫殿",
|
||||
design_Hanok = "韩屋",
|
||||
inUse = "使用中",
|
||||
btnPromote = "宣传",
|
||||
btnRush = "客潮",
|
||||
promoteTitle = "宣传",
|
||||
promoteAdText = "看广告后,邻店的客人会来你的店",
|
||||
watchAd = "看广告",
|
||||
promoteFree = "直接宣传",
|
||||
kickAction = "赶走客人",
|
||||
decoPick = "点要移动的东西(桌子·椅子·摆件·灶台)",
|
||||
decoMove = "点地面来移动",
|
||||
decoChair = "选方向或点另一张桌子",
|
||||
decoOk = "很好!点[放下]",
|
||||
rotate = "旋转",
|
||||
placeIt = "放下",
|
||||
cancel = "取消",
|
||||
exit = "退出",
|
||||
floorN = "{n}楼",
|
||||
side_1 = "前",
|
||||
side_2 = "右",
|
||||
side_3 = "后",
|
||||
side_4 = "左",
|
||||
why_bounds = "在店外面",
|
||||
why_overlap = "和别的东西重叠了",
|
||||
why_reserved = "门口和楼梯要空着",
|
||||
why_floor = "还没有二楼",
|
||||
why_blocked = "挡住了客人的路",
|
||||
why_chair = "让椅子朝向桌子([旋转])",
|
||||
why_none = "请重新选择",
|
||||
upgraded = "{name} Lv{level}!",
|
||||
floor2 = "盖好二楼了!可以放更多桌子",
|
||||
seatAdded = "放好椅子了!座位多了一个",
|
||||
tableAdded = "放好桌子了!",
|
||||
decorAdded = "{name}放好了!",
|
||||
noSpace = "没有空位。用[摆放]挪一挪吧",
|
||||
seatMax = "座位满了。升级建筑吧",
|
||||
tableMax = "不能再放桌子了",
|
||||
tableFull = "每张桌子都放满椅子了。买张桌子吧",
|
||||
needStage = "先升级建筑吧",
|
||||
placeFail = "这里不行:{reason}",
|
||||
hired = "雇了{name}!",
|
||||
fired = "减少了一名{name}",
|
||||
staffLocked = "先购买“解锁店员”",
|
||||
staffMax = "不能再雇了",
|
||||
strike = "钱不够,店员停工了",
|
||||
strikeOver = "店员回来工作了!",
|
||||
renamed = "店名改好了!",
|
||||
nameRejected = "不能用这个名字",
|
||||
designSet = "换成{name}设计了!",
|
||||
designLocked = "室内小吃店后可以更换",
|
||||
promoted = "{n}位客人要来你的店了!",
|
||||
promoteNone = "没有可以拉来的客人",
|
||||
promoteFull = "没有空座位",
|
||||
promoteWait = "{sec}秒后可以再来",
|
||||
adUnavailable = "现在没有广告",
|
||||
kicked = "{n}位客人来你的店了!",
|
||||
kickedBy = "{name}把你的客人拉走了!",
|
||||
shielded = "那家店暂时受保护",
|
||||
kickOwn = "不能对自己的店用",
|
||||
rushOn = "客潮开始,持续{min}分钟!",
|
||||
},
|
||||
}
|
||||
|
||||
-- 설정 창에 나오는 순서와 각 언어 이름(언어와 상관없이 그 나라 말로 씁니다)
|
||||
Locale.LANGS = { "ko", "en", "ja", "zh" }
|
||||
Locale.LANG_NAMES = { ko = "한국어", en = "English", ja = "日本語", zh = "中文" } :: { [string]: string }
|
||||
|
||||
-- 로블록스 계정 언어(LocaleId, 예: "ko-kr", "zh-cn")로 화면 언어를 고릅니다. 지원하지 않는 언어는 영어.
|
||||
function Locale.pick(localeId: string): string
|
||||
local prefix = string.sub(string.lower(localeId), 1, 2)
|
||||
if STRINGS[prefix] then
|
||||
return prefix
|
||||
end
|
||||
return "en"
|
||||
end
|
||||
|
||||
-- 저장된 설정("" = 자동)과 계정 언어로 실제 화면 언어를 정합니다.
|
||||
function Locale.resolve(setting: string, localeId: string): string
|
||||
if STRINGS[setting] then
|
||||
return setting
|
||||
end
|
||||
return Locale.pick(localeId)
|
||||
end
|
||||
|
||||
function Locale.t(lang: string, key: string, args: { [string]: any }?): string
|
||||
local tbl = STRINGS[lang] or STRINGS.en
|
||||
local s = tbl[key] or STRINGS.en[key] or key
|
||||
if args then
|
||||
s = string.gsub(s, "{(%w+)}", function(k)
|
||||
local v = args[k]
|
||||
return if v ~= nil then tostring(v) else "{" .. k .. "}"
|
||||
end)
|
||||
end
|
||||
return s
|
||||
end
|
||||
|
||||
function Locale.menuName(lang: string, menu: string): string
|
||||
return Locale.t(lang, "menu_" .. menu)
|
||||
end
|
||||
|
||||
function Locale.keys(lang: string): { string }
|
||||
local out = {}
|
||||
for k in STRINGS[lang] do
|
||||
table.insert(out, k)
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
-- 숫자에 천 단위 쉼표
|
||||
function Locale.number(n: number): string
|
||||
local s = tostring(math.floor(n))
|
||||
local out = string.reverse((string.gsub(string.reverse(s), "(%d%d%d)", "%1,")))
|
||||
return (string.gsub(out, "^(-?),", "%1"))
|
||||
end
|
||||
|
||||
return Locale
|
||||
13
bunsik-tycoon/src/shared/Products.luau
Normal file
@@ -0,0 +1,13 @@
|
||||
--!strict
|
||||
-- 게임패스·개발자 상품 ID. tools/cloud.py products 로 만들고 여기에 적습니다. 0이면 버튼을 숨깁니다.
|
||||
|
||||
return {
|
||||
DOUBLE_MONEY_PASS = 2026574937,
|
||||
MONEY_BOOST_PRODUCT = 3717970589,
|
||||
RAINBOW_NAME_PASS = 2033912456, -- 가게 이름 무지개
|
||||
CANDY_DESIGN_PASS = 2034416415, -- 건물 디자인: 사탕 궁전
|
||||
HANOK_DESIGN_PASS = 2034032432, -- 건물 디자인: 한옥 분식집
|
||||
RUSH_PRODUCT = 3718393895, -- 손님 러시 10분(소모성)
|
||||
KICK_PRODUCT = 3718393909, -- 옆 가게 손님 쫓아내기 1회(소모성)
|
||||
PROMOTE_AD_PRODUCT = 3718393920, -- 보상형 광고 보상(홍보 1회). 광고 보상은 개발자 상품으로 받습니다
|
||||
}
|
||||
209
bunsik-tycoon/src/shared/Recipes.luau
Normal file
@@ -0,0 +1,209 @@
|
||||
--!strict
|
||||
-- 메뉴별 조리 과정(요리 화면의 단계)과 진행 상태 기계. 로블록스 API를 쓰지 않아서 lune 테스트와 시뮬레이터에서 그대로 씁니다.
|
||||
-- 단계 종류(모두 실패 없음, 어린아이도 끝까지 할 수 있게):
|
||||
-- tap = 재료를 톡톡 누르기(need번)
|
||||
-- hold = 꾹 누르고 있기(need초)
|
||||
-- rub = 손가락·마우스로 문지르기(이동 거리 need × RUB_UNIT 기준 단위)
|
||||
-- "화구" 업그레이드(stats.cook 2.5 → 1.5 → 1)를 사면 누르는 횟수·시간이 같은 비율로 줄어듭니다.
|
||||
|
||||
local Recipes = {}
|
||||
|
||||
export type StepKind = "tap" | "hold" | "rub"
|
||||
|
||||
export type Step = {
|
||||
kind: StepKind,
|
||||
key: string, -- 안내 글 Locale 키(cook_<메뉴>_<번호>)
|
||||
base: number, -- 화구 Lv0 기준 횟수·초·문지르기 양
|
||||
tool: string, -- 누르는 물건 그림(Kitchen 그림 이름)
|
||||
}
|
||||
|
||||
export type Recipe = {
|
||||
stage: string, -- 조리 도구 그림(팬, 도마, 찜기, 냄비, 튀김기)
|
||||
steps: { Step },
|
||||
}
|
||||
|
||||
Recipes.BASE_COOK = 2.5 -- Economy.START_COOK과 같음
|
||||
Recipes.RUB_UNIT = 260 -- 문지르기 1번 = 기준 단위 260만큼 움직이기
|
||||
|
||||
Recipes.LIST = {
|
||||
Tteokbokki = {
|
||||
stage = "pan",
|
||||
steps = {
|
||||
{ kind = "tap", key = "cook_Tteokbokki_1", base = 4, tool = "riceCakes" },
|
||||
{ kind = "hold", key = "cook_Tteokbokki_2", base = 1.0, tool = "sauceBowl" },
|
||||
{ kind = "rub", key = "cook_Tteokbokki_3", base = 3, tool = "spatula" },
|
||||
},
|
||||
},
|
||||
Gimbap = {
|
||||
stage = "board",
|
||||
steps = {
|
||||
{ kind = "tap", key = "cook_Gimbap_1", base = 4, tool = "fillings" },
|
||||
{ kind = "rub", key = "cook_Gimbap_2", base = 3, tool = "roll" },
|
||||
{ kind = "tap", key = "cook_Gimbap_3", base = 4, tool = "knife" },
|
||||
},
|
||||
},
|
||||
Sundae = {
|
||||
stage = "steamer",
|
||||
steps = {
|
||||
{ kind = "tap", key = "cook_Sundae_1", base = 3, tool = "sundaeRaw" },
|
||||
{ kind = "hold", key = "cook_Sundae_2", base = 1.2, tool = "fire" },
|
||||
{ kind = "tap", key = "cook_Sundae_3", base = 4, tool = "knife" },
|
||||
},
|
||||
},
|
||||
Eomuk = {
|
||||
stage = "pot",
|
||||
steps = {
|
||||
{ kind = "tap", key = "cook_Eomuk_1", base = 4, tool = "fishCake" },
|
||||
{ kind = "hold", key = "cook_Eomuk_2", base = 1.4, tool = "skewer" },
|
||||
},
|
||||
},
|
||||
Twigim = {
|
||||
stage = "fryer",
|
||||
steps = {
|
||||
{ kind = "rub", key = "cook_Twigim_1", base = 3, tool = "batter" },
|
||||
{ kind = "hold", key = "cook_Twigim_2", base = 1.2, tool = "fire" },
|
||||
{ kind = "tap", key = "cook_Twigim_3", base = 3, tool = "tongs" },
|
||||
},
|
||||
},
|
||||
} :: { [string]: Recipe }
|
||||
|
||||
-- 화구 수준에 맞춘 단계 목표(횟수는 정수, 최소 2번)
|
||||
function Recipes.need(step: Step, cook: number): number
|
||||
local k = cook / Recipes.BASE_COOK
|
||||
if step.kind == "tap" then
|
||||
return math.max(2, math.floor(step.base * k + 0.5))
|
||||
end
|
||||
return step.base * k
|
||||
end
|
||||
|
||||
-- 시뮬레이터용: 아이가 쉬지 않고 했을 때 걸리는 시간(초). 메뉴 고르기·완성 연출 포함.
|
||||
Recipes.TIME_TAP = 0.3 -- 한 번 누르는 데
|
||||
Recipes.TIME_RUB = 0.35 -- 문지르기 1번에
|
||||
Recipes.TIME_STEP = 0.4 -- 단계가 바뀔 때 안내를 보는 시간
|
||||
Recipes.TIME_CHOOSE = 1.0 -- 조리대 버튼 + 메뉴 고르기
|
||||
Recipes.TIME_DONE = 0.6 -- "완성!" 연출
|
||||
|
||||
function Recipes.expectedTime(menu: string, cook: number): number
|
||||
local r = Recipes.LIST[menu]
|
||||
local t = Recipes.TIME_CHOOSE + Recipes.TIME_DONE
|
||||
for _, s in r.steps do
|
||||
local n = Recipes.need(s, cook)
|
||||
t += Recipes.TIME_STEP
|
||||
if s.kind == "tap" then
|
||||
t += n * Recipes.TIME_TAP
|
||||
elseif s.kind == "rub" then
|
||||
t += n * Recipes.TIME_RUB
|
||||
else
|
||||
t += n
|
||||
end
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
-- 서버 검사용: 아주 빠른 사람이 쉬지 않고 했을 때의 최소 시간(초). 꾹 누르기는 정해진 시간을 다 채워야 하고,
|
||||
-- 톡톡·문지르기는 한 번에 MIN_TAP·MIN_RUB초로 봅니다. 메뉴 고르기·완성 연출은 빼서 정상 플레이는 늘 이보다 깁니다.
|
||||
Recipes.MIN_TAP = 0.08
|
||||
Recipes.MIN_RUB = 0.08
|
||||
|
||||
function Recipes.minTime(menu: string, cook: number): number
|
||||
local r = Recipes.LIST[menu]
|
||||
local t = 0
|
||||
for _, s in r.steps do
|
||||
local n = Recipes.need(s, cook)
|
||||
if s.kind == "tap" then
|
||||
t += n * Recipes.MIN_TAP
|
||||
elseif s.kind == "rub" then
|
||||
t += n * Recipes.MIN_RUB
|
||||
else
|
||||
t += n
|
||||
end
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
-- 요리 화면 한 번의 진행 상태
|
||||
export type Phase = "menu" | "cook" | "done"
|
||||
export type Flow = {
|
||||
phase: Phase,
|
||||
cook: number, -- 화구 수준(stats.cook)
|
||||
menu: string?,
|
||||
step: number, -- 지금 단계(1부터)
|
||||
progress: number, -- 지금 단계 진행량(0 ~ need)
|
||||
need: number,
|
||||
}
|
||||
|
||||
function Recipes.newFlow(cook: number): Flow
|
||||
return { phase = "menu", cook = cook, menu = nil, step = 0, progress = 0, need = 0 }
|
||||
end
|
||||
|
||||
function Recipes.current(flow: Flow): Step?
|
||||
local r = flow.menu and Recipes.LIST[flow.menu]
|
||||
return r and r.steps[flow.step]
|
||||
end
|
||||
|
||||
local function startStep(flow: Flow, i: number)
|
||||
local r = Recipes.LIST[flow.menu :: string]
|
||||
flow.step = i
|
||||
flow.progress = 0
|
||||
local s = r.steps[i]
|
||||
flow.need = if s then Recipes.need(s, flow.cook) else 0
|
||||
end
|
||||
|
||||
-- 메뉴를 고르면 첫 단계부터 시작합니다.
|
||||
function Recipes.choose(flow: Flow, menu: string): boolean
|
||||
if flow.phase ~= "menu" or not Recipes.LIST[menu] then
|
||||
return false
|
||||
end
|
||||
flow.menu = menu
|
||||
flow.phase = "cook"
|
||||
startStep(flow, 1)
|
||||
return true
|
||||
end
|
||||
|
||||
-- 입력을 넣습니다. kind가 지금 단계와 다르면 무시합니다.
|
||||
-- 돌려주는 값: nil(무시), "progress", "step"(다음 단계로), "done"(완성)
|
||||
function Recipes.input(flow: Flow, kind: StepKind, amount: number): string?
|
||||
if flow.phase ~= "cook" then
|
||||
return nil
|
||||
end
|
||||
local s = Recipes.current(flow)
|
||||
if not s or s.kind ~= kind or amount <= 0 then
|
||||
return nil
|
||||
end
|
||||
flow.progress = math.min(flow.need, flow.progress + amount)
|
||||
if flow.progress < flow.need - 1e-9 then
|
||||
return "progress"
|
||||
end
|
||||
local r = Recipes.LIST[flow.menu :: string]
|
||||
if flow.step >= #r.steps then
|
||||
flow.phase = "done"
|
||||
return "done"
|
||||
end
|
||||
startStep(flow, flow.step + 1)
|
||||
return "step"
|
||||
end
|
||||
|
||||
-- 완성 뒤 다음 접시를 만들 때(메뉴 고르기로 돌아감)
|
||||
function Recipes.reset(flow: Flow, cook: number)
|
||||
flow.phase = "menu"
|
||||
flow.cook = cook
|
||||
flow.menu = nil
|
||||
flow.step = 0
|
||||
flow.progress = 0
|
||||
flow.need = 0
|
||||
end
|
||||
|
||||
-- 지금 단계까지 포함한 전체 진행률(0~1). 위쪽 단계 표시에 씁니다.
|
||||
function Recipes.fraction(flow: Flow): number
|
||||
local r = flow.menu and Recipes.LIST[flow.menu]
|
||||
if not r then
|
||||
return 0
|
||||
end
|
||||
if flow.phase == "done" then
|
||||
return 1
|
||||
end
|
||||
local part = if flow.need > 0 then flow.progress / flow.need else 0
|
||||
return ((flow.step - 1) + part) / #r.steps
|
||||
end
|
||||
|
||||
return Recipes
|
||||
661
bunsik-tycoon/src/shared/Shop.luau
Normal file
@@ -0,0 +1,661 @@
|
||||
--!strict
|
||||
-- 가게 한 곳의 규칙(손님, 주문, 조리, 서빙, 돈, 업그레이드, 알바생, 시급)을 담은 순수 로직입니다.
|
||||
-- 로블록스 API를 쓰지 않아서 lune 단위 테스트와 시뮬레이터에서 그대로 돌립니다.
|
||||
-- 화면(NPC, 접시 모형, 효과)은 서버의 PlotController가 이벤트를 받아 그립니다.
|
||||
-- 테이블·의자 위치는 모릅니다. 자리 수(seats)와 자리별 걷는 시간(seatWalk)만 압니다.
|
||||
|
||||
-- 로블록스에서는 script.Parent, lune(테스트)에서는 파일 경로로 불러옵니다.
|
||||
local Economy: typeof(require(script.Parent.Economy)) = if script
|
||||
then require(script.Parent.Economy)
|
||||
else (require :: any)("./Economy")
|
||||
|
||||
type Stats = typeof(Economy.stats({}, 1))
|
||||
type Levels = { [string]: number }
|
||||
type Staff = { [string]: number }
|
||||
type Level = typeof(Economy.TRACKS[1].levels[1])
|
||||
|
||||
export type CustomerState = "walking" | "waiting" | "eating"
|
||||
|
||||
export type Customer = {
|
||||
id: number,
|
||||
seat: number,
|
||||
menu: string,
|
||||
state: CustomerState,
|
||||
untilT: number, -- walking/eating이 끝나는 시각. 플레이어 손님은 기다리다 일어나는 시각
|
||||
guest: number?, -- 다른 플레이어가 손님으로 왔으면 그 UserId
|
||||
transfer: boolean?, -- 옆 가게에서 데려온 손님
|
||||
}
|
||||
|
||||
-- 서빙 알바가 나르는 중인 접시
|
||||
export type Trip = {
|
||||
staff: number, -- 서빙 알바 번호(1부터)
|
||||
id: number, -- 손님 id
|
||||
menu: string,
|
||||
doneT: number,
|
||||
}
|
||||
|
||||
export type Event =
|
||||
{ kind: "spawn", id: number, seat: number, menu: string, transfer: boolean? }
|
||||
| { kind: "seated", id: number }
|
||||
| { kind: "leave", id: number, seat: number, guest: number?, served: boolean }
|
||||
| { kind: "counter", menu: string, staff: number }
|
||||
| { kind: "deliver", id: number, menu: string, staff: number, index: number }
|
||||
| { kind: "delivered", id: number, staff: number, earn: number }
|
||||
| { kind: "returned", menu: string, staff: number }
|
||||
| { kind: "wage", amount: number }
|
||||
| { kind: "strike", on: boolean }
|
||||
|
||||
export type Shop = {
|
||||
money: number,
|
||||
levels: Levels,
|
||||
stats: Stats,
|
||||
moneyMult: number,
|
||||
customers: { [number]: Customer },
|
||||
seatTaken: { [number]: number },
|
||||
seatWalk: { [number]: number }, -- 자리별 입구 -> 자리 걷는 시간
|
||||
hand: { string },
|
||||
counter: { string },
|
||||
trips: { [number]: Trip }, -- 서빙 알바 번호 -> 나르는 중
|
||||
staff: Staff,
|
||||
strike: boolean, -- 시급이 모자라 알바생이 쉬는 중
|
||||
wageDue: number, -- 다음 시급 주는 시각
|
||||
cookNext: { [number]: number }, -- 요리 알바 번호 -> 다음에 만들 수 있는 시각
|
||||
rushLeft: number, -- 손님 러시 남은 초
|
||||
now: number,
|
||||
nextSpawn: number,
|
||||
menuIndex: number,
|
||||
lastSeat: number, -- 마지막으로 NPC 손님을 앉힌 자리
|
||||
lastId: number,
|
||||
served: number,
|
||||
earned: number,
|
||||
}
|
||||
|
||||
export type Options = {
|
||||
money: number,
|
||||
levels: Levels?,
|
||||
seats: number?,
|
||||
staff: Staff?,
|
||||
now: number,
|
||||
rushLeft: number?,
|
||||
}
|
||||
|
||||
local Shop = {}
|
||||
|
||||
function Shop.new(opts: Options): Shop
|
||||
local levels = Economy.cleanLevels(opts.levels)
|
||||
local seats = math.max(1, opts.seats or 1)
|
||||
local staff: Staff = {}
|
||||
for _, r in Economy.ROLES do
|
||||
local n = if opts.staff then opts.staff[r.id] else nil
|
||||
staff[r.id] = if typeof(n) == "number" then math.clamp(math.floor(n), 0, r.max) else 0
|
||||
end
|
||||
return {
|
||||
money = opts.money,
|
||||
levels = levels,
|
||||
stats = Economy.stats(levels, seats),
|
||||
moneyMult = 1,
|
||||
customers = {},
|
||||
seatTaken = {},
|
||||
seatWalk = {},
|
||||
hand = {},
|
||||
counter = {},
|
||||
trips = {},
|
||||
staff = staff,
|
||||
strike = false,
|
||||
wageDue = opts.now + Economy.WAGE_PERIOD,
|
||||
cookNext = {},
|
||||
rushLeft = math.max(0, opts.rushLeft or 0),
|
||||
now = opts.now,
|
||||
nextSpawn = opts.now, -- 접속하자마자 첫 손님
|
||||
menuIndex = 0,
|
||||
lastSeat = 0,
|
||||
lastId = 0,
|
||||
served = 0,
|
||||
earned = 0,
|
||||
}
|
||||
end
|
||||
|
||||
local function staffWorking(self: Shop, role: string): number
|
||||
if self.strike or not self.stats.staffUnlocked then
|
||||
return 0
|
||||
end
|
||||
return self.staff[role] or 0
|
||||
end
|
||||
|
||||
function Shop.freeSeat(self: Shop): number?
|
||||
for seat = 1, self.stats.seats do
|
||||
if self.seatTaken[seat] == nil then
|
||||
return seat
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- 새 손님 자리: 마지막으로 앉힌 자리 다음부터 돌아가며 찾습니다(2층·구석 자리도 고르게 쓰이게).
|
||||
local function nextSpawnSeat(self: Shop): number?
|
||||
local n = self.stats.seats
|
||||
for k = 1, n do
|
||||
local seat = ((self.lastSeat + k - 1) % n) + 1
|
||||
if self.seatTaken[seat] == nil then
|
||||
self.lastSeat = seat
|
||||
return seat
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function Shop.freeSeatCount(self: Shop): number
|
||||
local n = 0
|
||||
for seat = 1, self.stats.seats do
|
||||
if self.seatTaken[seat] == nil then
|
||||
n += 1
|
||||
end
|
||||
end
|
||||
return n
|
||||
end
|
||||
|
||||
-- 손에 든 접시·카운터·나르는 중인 접시 중 기다리는 손님이 없는 메뉴(주인 없는 접시).
|
||||
-- 손님이 옆 가게로 가 버려서 남은 접시입니다. 다음 손님이 이 메뉴를 주문하게 해서 접시가 버려지지 않게 합니다.
|
||||
local function orphanMenu(self: Shop): string?
|
||||
local have: { [string]: number } = {}
|
||||
for _, m in self.hand do
|
||||
have[m] = (have[m] or 0) + 1
|
||||
end
|
||||
for _, m in self.counter do
|
||||
have[m] = (have[m] or 0) + 1
|
||||
end
|
||||
for _, t in self.trips do
|
||||
have[t.menu] = (have[t.menu] or 0) + 1
|
||||
end
|
||||
for _, c in self.customers do
|
||||
if c.state ~= "eating" and have[c.menu] then
|
||||
have[c.menu] -= 1
|
||||
end
|
||||
end
|
||||
for _, m in Economy.MENU_ORDER do
|
||||
if (have[m] or 0) > 0 and table.find(self.stats.menus, m) then
|
||||
return m
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- 다음 손님이 주문할 메뉴(주인 없는 접시가 있으면 그 메뉴, 아니면 해금된 메뉴를 돌아가며)
|
||||
local function nextOrder(self: Shop): string
|
||||
local orphan = orphanMenu(self)
|
||||
if orphan then
|
||||
return orphan
|
||||
end
|
||||
local menus = self.stats.menus
|
||||
local menu = menus[(self.menuIndex % #menus) + 1]
|
||||
self.menuIndex += 1
|
||||
return menu
|
||||
end
|
||||
|
||||
-- 아직 접시가 정해지지 않은 주문(먼저 온 손님부터). 걷는 중인 손님도 주문은 이미 정해져 있습니다.
|
||||
function Shop.openOrders(self: Shop): { Customer }
|
||||
local covered: { [string]: number } = {}
|
||||
for _, m in self.hand do
|
||||
covered[m] = (covered[m] or 0) + 1
|
||||
end
|
||||
for _, m in self.counter do
|
||||
covered[m] = (covered[m] or 0) + 1
|
||||
end
|
||||
local tripFor: { [number]: boolean } = {}
|
||||
for _, t in self.trips do
|
||||
tripFor[t.id] = true
|
||||
end
|
||||
local list = {}
|
||||
for _, c in self.customers do
|
||||
if c.state ~= "eating" and not tripFor[c.id] then
|
||||
table.insert(list, c)
|
||||
end
|
||||
end
|
||||
table.sort(list, function(a, b)
|
||||
return a.id < b.id
|
||||
end)
|
||||
local open = {}
|
||||
for _, c in list do
|
||||
local n = covered[c.menu] or 0
|
||||
if n > 0 then
|
||||
covered[c.menu] = n - 1
|
||||
else
|
||||
table.insert(open, c)
|
||||
end
|
||||
end
|
||||
return open
|
||||
end
|
||||
|
||||
-- 지금 조리대에서 만들 메뉴(없으면 nil)
|
||||
function Shop.nextCookMenu(self: Shop): string?
|
||||
local open = Shop.openOrders(self)
|
||||
return if open[1] then open[1].menu else nil
|
||||
end
|
||||
|
||||
-- 메뉴별로 아직 접시가 정해지지 않은 주문 수(요리 화면의 "주문" 표시)
|
||||
function Shop.openCounts(self: Shop): { [string]: number }
|
||||
local counts = {}
|
||||
for _, c in Shop.openOrders(self) do
|
||||
counts[c.menu] = (counts[c.menu] or 0) + 1
|
||||
end
|
||||
return counts
|
||||
end
|
||||
|
||||
function Shop.handFull(self: Shop): boolean
|
||||
return #self.hand >= self.stats.carry
|
||||
end
|
||||
|
||||
function Shop.spawnInterval(self: Shop): number
|
||||
return Economy.spawnInterval(self.stats, staffWorking(self, "Promoter"), self.rushLeft > 0)
|
||||
end
|
||||
|
||||
local function addCustomer(self: Shop, seat: number, menu: string, walk: number, transfer: boolean?): Customer
|
||||
self.lastId += 1
|
||||
local c: Customer = {
|
||||
id = self.lastId,
|
||||
seat = seat,
|
||||
menu = menu,
|
||||
state = "walking",
|
||||
untilT = self.now + walk,
|
||||
transfer = transfer,
|
||||
}
|
||||
self.customers[c.id] = c
|
||||
self.seatTaken[seat] = c.id
|
||||
return c
|
||||
end
|
||||
|
||||
-- 손님 자리까지 서빙 알바가 가는 시간
|
||||
local function tripTime(self: Shop, seat: number): number
|
||||
local walk = self.seatWalk[seat] or Economy.WALK_IN
|
||||
return math.max(1.5, Economy.SERVER_TRIP * walk / Economy.WALK_IN)
|
||||
end
|
||||
|
||||
local function payWages(self: Shop, now: number, events: { Event })
|
||||
if now < self.wageDue then
|
||||
return
|
||||
end
|
||||
local total = Economy.totalWage(self.staff, self.stats)
|
||||
if total <= 0 or not self.stats.staffUnlocked then
|
||||
self.wageDue = now + Economy.WAGE_PERIOD
|
||||
if self.strike then
|
||||
self.strike = false
|
||||
table.insert(events, { kind = "strike", on = false } :: Event)
|
||||
end
|
||||
return
|
||||
end
|
||||
if self.money >= total then
|
||||
self.money -= total
|
||||
self.wageDue = now + Economy.WAGE_PERIOD
|
||||
table.insert(events, { kind = "wage", amount = total } :: Event)
|
||||
if self.strike then
|
||||
self.strike = false
|
||||
table.insert(events, { kind = "strike", on = false } :: Event)
|
||||
end
|
||||
else
|
||||
self.wageDue = now + Economy.STRIKE_RETRY
|
||||
if not self.strike then
|
||||
self.strike = true
|
||||
table.insert(events, { kind = "strike", on = true } :: Event)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 시간을 now까지 진행합니다. 일어난 일을 이벤트로 돌려줍니다.
|
||||
function Shop.tick(self: Shop, now: number): { Event }
|
||||
local dt = math.max(0, now - self.now)
|
||||
self.now = now
|
||||
local events: { Event } = {}
|
||||
if self.rushLeft > 0 then
|
||||
self.rushLeft = math.max(0, self.rushLeft - dt)
|
||||
end
|
||||
|
||||
payWages(self, now, events)
|
||||
|
||||
for id, c in self.customers do
|
||||
if c.state == "walking" and now >= c.untilT then
|
||||
c.state = "waiting"
|
||||
table.insert(events, { kind = "seated", id = id } :: Event)
|
||||
elseif c.state ~= "walking" and now >= c.untilT and (c.state == "eating" or c.guest ~= nil) then
|
||||
-- 다 먹었거나, 플레이어 손님이 너무 오래 기다렸으면 나갑니다.
|
||||
self.customers[id] = nil
|
||||
self.seatTaken[c.seat] = nil
|
||||
table.insert(
|
||||
events,
|
||||
{ kind = "leave", id = id, seat = c.seat, guest = c.guest, served = c.state == "eating" } :: Event
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
if now >= self.nextSpawn then
|
||||
local seat = nextSpawnSeat(self)
|
||||
if seat then
|
||||
local menu = nextOrder(self)
|
||||
local c = addCustomer(self, seat, menu, self.seatWalk[seat] or Economy.WALK_IN)
|
||||
table.insert(events, { kind = "spawn", id = c.id, seat = seat, menu = menu } :: Event)
|
||||
end
|
||||
self.nextSpawn = now + Shop.spawnInterval(self)
|
||||
end
|
||||
|
||||
-- 요리 알바: 한 명마다 조리 수준(초)에 한 접시씩 카운터에 만들어 둡니다.
|
||||
local cooks = staffWorking(self, "Cook")
|
||||
for i = 1, cooks do
|
||||
if now >= (self.cookNext[i] or 0) and #self.counter < Economy.COUNTER_MAX * cooks then
|
||||
local menu = Shop.nextCookMenu(self)
|
||||
if menu then
|
||||
table.insert(self.counter, menu)
|
||||
table.insert(events, { kind = "counter", menu = menu, staff = i } :: Event)
|
||||
self.cookNext[i] = now + self.stats.cook
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 서빙 알바: 다 나른 접시는 손님에게 놓고, 빈 손이면 카운터 접시를 기다리는 손님에게 가져갑니다.
|
||||
for i, t in self.trips do
|
||||
if now >= t.doneT then
|
||||
self.trips[i] = nil
|
||||
local c = self.customers[t.id]
|
||||
if c and c.state == "waiting" then
|
||||
c.state = "eating"
|
||||
c.untilT = now + Economy.EAT
|
||||
local earn = Shop.pay(self, c)
|
||||
table.insert(events, { kind = "delivered", id = c.id, staff = i, earn = earn } :: Event)
|
||||
else
|
||||
table.insert(self.counter, t.menu)
|
||||
table.insert(events, { kind = "returned", menu = t.menu, staff = i } :: Event)
|
||||
end
|
||||
end
|
||||
end
|
||||
local servers = staffWorking(self, "Server")
|
||||
for i = 1, servers do
|
||||
if not self.trips[i] and #self.counter > 0 then
|
||||
local busy: { [number]: boolean } = {}
|
||||
for _, t in self.trips do
|
||||
busy[t.id] = true
|
||||
end
|
||||
local best: Customer? = nil
|
||||
local bestIdx = 0
|
||||
for _, c in self.customers do
|
||||
if c.state == "waiting" and not busy[c.id] and (not best or c.id < best.id) then
|
||||
local idx = table.find(self.counter, c.menu)
|
||||
if idx then
|
||||
best = c
|
||||
bestIdx = idx
|
||||
end
|
||||
end
|
||||
end
|
||||
if best then
|
||||
table.remove(self.counter, bestIdx)
|
||||
self.trips[i] = { staff = i, id = best.id, menu = best.menu, doneT = now + tripTime(self, best.seat) }
|
||||
table.insert(
|
||||
events,
|
||||
{ kind = "deliver", id = best.id, menu = best.menu, staff = i, index = bestIdx } :: Event
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return events
|
||||
end
|
||||
|
||||
-- 손님 한 명 값(접시 값, 플레이어 손님이면 2배)을 받습니다.
|
||||
function Shop.pay(self: Shop, c: Customer): number
|
||||
local earn = Economy.dishPrice(c.menu, self.stats, self.moneyMult)
|
||||
if c.guest then
|
||||
earn *= Economy.GUEST_MULT
|
||||
end
|
||||
self.money += earn
|
||||
self.earned += earn
|
||||
self.served += 1
|
||||
return earn
|
||||
end
|
||||
|
||||
-- 플레이어가 요리 화면에서 다 만들었을 때. 만든 메뉴를 돌려줍니다.
|
||||
-- menu를 주면 그 메뉴를 기다리는 주문이 있을 때만 만들고, 없으면 먼저 온 손님 메뉴를 만듭니다.
|
||||
function Shop.cook(self: Shop, menu: string?): string?
|
||||
if Shop.handFull(self) then
|
||||
return nil
|
||||
end
|
||||
if menu then
|
||||
if not Shop.openCounts(self)[menu] then
|
||||
return nil
|
||||
end
|
||||
else
|
||||
menu = Shop.nextCookMenu(self)
|
||||
end
|
||||
if menu then
|
||||
table.insert(self.hand, menu)
|
||||
end
|
||||
return menu
|
||||
end
|
||||
|
||||
-- 요리 알바가 만들어 둔 접시를 손에 듭니다. 든 접시 수를 돌려줍니다.
|
||||
function Shop.pickup(self: Shop): number
|
||||
local n = 0
|
||||
while #self.counter > 0 and not Shop.handFull(self) do
|
||||
table.insert(self.hand, table.remove(self.counter, 1) :: string)
|
||||
n += 1
|
||||
end
|
||||
return n
|
||||
end
|
||||
|
||||
-- 손에 든 접시를 손님에게 줍니다. 번 돈을 돌려줍니다(못 주면 nil).
|
||||
function Shop.serve(self: Shop, id: number): number?
|
||||
local c = self.customers[id]
|
||||
if not c or c.state ~= "waiting" then
|
||||
return nil
|
||||
end
|
||||
for _, t in self.trips do
|
||||
if t.id == id then
|
||||
return nil -- 서빙 알바가 가져가는 중
|
||||
end
|
||||
end
|
||||
local idx = table.find(self.hand, c.menu)
|
||||
if not idx then
|
||||
return nil
|
||||
end
|
||||
table.remove(self.hand, idx)
|
||||
c.state = "eating"
|
||||
c.untilT = self.now + Economy.EAT
|
||||
return Shop.pay(self, c)
|
||||
end
|
||||
|
||||
-- 돈을 씁니다. 모자라면 false
|
||||
function Shop.spend(self: Shop, cost: number): boolean
|
||||
if cost < 0 or self.money < cost then
|
||||
return false
|
||||
end
|
||||
self.money -= cost
|
||||
return true
|
||||
end
|
||||
|
||||
local function refreshStats(self: Shop)
|
||||
local before = self.stats
|
||||
self.stats = Economy.stats(self.levels, before.seats)
|
||||
if self.stats.spawn < before.spawn then
|
||||
self.nextSpawn = math.min(self.nextSpawn, self.now + Shop.spawnInterval(self))
|
||||
end
|
||||
end
|
||||
|
||||
-- 업그레이드 갈래의 다음 단계를 삽니다. 성공하면 산 단계(Level)를 돌려줍니다.
|
||||
-- 실패 이유: "max"(다 삼), "stage"(건물 단계 부족), "money"
|
||||
function Shop.buyLevel(self: Shop, trackId: string): (Level?, string?)
|
||||
local nl = Economy.nextLevel(self.levels, trackId)
|
||||
if not nl then
|
||||
return nil, "max"
|
||||
end
|
||||
if nl.stage > self.stats.stage then
|
||||
return nil, "stage"
|
||||
end
|
||||
if not Shop.spend(self, nl.cost) then
|
||||
return nil, "money"
|
||||
end
|
||||
self.levels[trackId] += 1
|
||||
refreshStats(self)
|
||||
if trackId == "Menu" then
|
||||
-- 새 메뉴를 사면 다음 손님이 바로 그 메뉴를 주문해서, 산 효과가 곧바로 보이게 합니다.
|
||||
self.menuIndex = #self.stats.menus - 1
|
||||
self.nextSpawn = math.min(self.nextSpawn, self.now + 1)
|
||||
end
|
||||
return nl, nil
|
||||
end
|
||||
|
||||
-- 자리 수가 바뀌었을 때(의자를 사거나 놓음)
|
||||
function Shop.setSeats(self: Shop, seats: number)
|
||||
self.stats = Economy.stats(self.levels, seats)
|
||||
self.stats.seats = math.max(1, seats)
|
||||
-- 새 자리가 생기면 손님이 곧 옵니다.
|
||||
self.nextSpawn = math.min(self.nextSpawn, self.now + 1)
|
||||
end
|
||||
|
||||
-- 자리(의자) 하나를 뺍니다(꾸미기에서 의자 삭제). 누가 앉아 있거나 오는 중이면 false.
|
||||
-- 뒤 번호 자리의 손님·걷는 시간은 한 칸씩 당깁니다(배치의 chairs 목록에서 빠진 것과 같게).
|
||||
function Shop.removeSeat(self: Shop, seat: number): boolean
|
||||
if self.seatTaken[seat] ~= nil or seat < 1 or seat > self.stats.seats or self.stats.seats <= 1 then
|
||||
return false
|
||||
end
|
||||
local taken: { [number]: number } = {}
|
||||
for _, c in self.customers do
|
||||
if c.seat > seat then
|
||||
c.seat -= 1
|
||||
end
|
||||
taken[c.seat] = c.id
|
||||
end
|
||||
self.seatTaken = taken
|
||||
local walk: { [number]: number } = {}
|
||||
for s, w in self.seatWalk do
|
||||
if s < seat then
|
||||
walk[s] = w
|
||||
elseif s > seat then
|
||||
walk[s - 1] = w
|
||||
end
|
||||
end
|
||||
self.seatWalk = walk
|
||||
if self.lastSeat >= seat then
|
||||
self.lastSeat = math.max(0, self.lastSeat - 1)
|
||||
end
|
||||
Shop.setSeats(self, self.stats.seats - 1)
|
||||
return true
|
||||
end
|
||||
|
||||
-- 알바생 고용·해고. 고용은 고용비를 냅니다. 실패 이유: "locked", "max", "money", "none"
|
||||
function Shop.hire(self: Shop, roleId: string): (boolean, string?)
|
||||
local r = Economy.role(roleId)
|
||||
if not r then
|
||||
return false, "none"
|
||||
end
|
||||
if not self.stats.staffUnlocked then
|
||||
return false, "locked"
|
||||
end
|
||||
if (self.staff[roleId] or 0) >= r.max then
|
||||
return false, "max"
|
||||
end
|
||||
if not Shop.spend(self, r.hire) then
|
||||
return false, "money"
|
||||
end
|
||||
self.staff[roleId] = (self.staff[roleId] or 0) + 1
|
||||
if self.wageDue < self.now then
|
||||
self.wageDue = self.now + Economy.WAGE_PERIOD
|
||||
end
|
||||
if roleId == "Promoter" then
|
||||
self.nextSpawn = math.min(self.nextSpawn, self.now + Shop.spawnInterval(self))
|
||||
end
|
||||
return true, nil
|
||||
end
|
||||
|
||||
function Shop.fire(self: Shop, roleId: string): boolean
|
||||
local n = self.staff[roleId] or 0
|
||||
if n <= 0 then
|
||||
return false
|
||||
end
|
||||
self.staff[roleId] = n - 1
|
||||
if roleId == "Server" and self.trips[n] then
|
||||
-- 나르던 접시는 카운터로 돌려놓습니다.
|
||||
table.insert(self.counter, self.trips[n].menu)
|
||||
self.trips[n] = nil
|
||||
end
|
||||
self.cookNext[n] = nil
|
||||
return true
|
||||
end
|
||||
|
||||
-- 손님 러시(유료): 남은 시간을 늘립니다.
|
||||
function Shop.addRush(self: Shop, seconds: number)
|
||||
self.rushLeft += seconds
|
||||
self.nextSpawn = math.min(self.nextSpawn, self.now + Shop.spawnInterval(self))
|
||||
end
|
||||
|
||||
-- 옆 가게에서 손님을 데려갈 때: 아직 음식을 못 받은(먹는 중이 아닌) NPC 손님을 최대 n명 빼서 돌려줍니다.
|
||||
-- 그 손님 자리로 가던 서빙 알바 접시는 카운터로 돌아갑니다.
|
||||
function Shop.takeCustomers(self: Shop, n: number): { Customer }
|
||||
local list = {}
|
||||
for _, c in self.customers do
|
||||
if c.state ~= "eating" and not c.guest then
|
||||
table.insert(list, c)
|
||||
end
|
||||
end
|
||||
-- 늦게 온 손님부터(오래 기다린 손님은 곧 음식을 받으니까)
|
||||
table.sort(list, function(a, b)
|
||||
return a.id > b.id
|
||||
end)
|
||||
local out = {}
|
||||
for i = 1, math.min(n, #list) do
|
||||
local c = list[i]
|
||||
self.customers[c.id] = nil
|
||||
self.seatTaken[c.seat] = nil
|
||||
for s, t in self.trips do
|
||||
if t.id == c.id then
|
||||
table.insert(self.counter, t.menu)
|
||||
self.trips[s] = nil
|
||||
end
|
||||
end
|
||||
table.insert(out, c)
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
-- 옆 가게에서 온 손님을 빈자리에 앉힙니다(walk초 걸어옴). 자리가 없으면 nil
|
||||
function Shop.addTransfer(self: Shop, menu: string, walk: number): Customer?
|
||||
local seat = Shop.freeSeat(self)
|
||||
if not seat then
|
||||
return nil
|
||||
end
|
||||
-- 우리 가게에 없는 메뉴를 원하던 손님은 우리 메뉴로 바꿔 주문합니다.
|
||||
if not table.find(self.stats.menus, menu) then
|
||||
menu = nextOrder(self)
|
||||
end
|
||||
return addCustomer(self, seat, menu, walk, true)
|
||||
end
|
||||
|
||||
-- 다른 플레이어가 손님으로 와서 빈자리에 앉습니다(걷지 않고 바로 주문). 자리가 없거나 이미 앉아 있으면 nil.
|
||||
function Shop.addGuest(self: Shop, userId: number): Customer?
|
||||
for _, c in self.customers do
|
||||
if c.guest == userId then
|
||||
return nil
|
||||
end
|
||||
end
|
||||
local seat = Shop.freeSeat(self)
|
||||
if not seat then
|
||||
return nil
|
||||
end
|
||||
local c = addCustomer(self, seat, nextOrder(self), 0)
|
||||
c.state = "waiting"
|
||||
c.untilT = self.now + Economy.GUEST_WAIT
|
||||
c.guest = userId
|
||||
return c
|
||||
end
|
||||
|
||||
-- 플레이어 손님이 먼저 일어났을 때(점프, 퇴장). 이벤트 없이 자리만 비웁니다.
|
||||
function Shop.removeGuest(self: Shop, id: number): Customer?
|
||||
local c = self.customers[id]
|
||||
if not c or not c.guest then
|
||||
return nil
|
||||
end
|
||||
self.customers[id] = nil
|
||||
self.seatTaken[c.seat] = nil
|
||||
return c
|
||||
end
|
||||
|
||||
function Shop.addMoney(self: Shop, amount: number)
|
||||
self.money += amount
|
||||
end
|
||||
|
||||
return Shop
|
||||
10
bunsik-tycoon/src/shared/Sounds.luau
Normal file
@@ -0,0 +1,10 @@
|
||||
--!strict
|
||||
-- 효과음 ID. 모두 tools/sfx.py로 직접 합성해 tkrmagid 계정으로 올린 것입니다(원본 파일: sfx/*.ogg).
|
||||
|
||||
return {
|
||||
SIZZLE = "rbxassetid://130884716661482", -- 조리 버튼을 누르는 동안(반복)
|
||||
COIN = "rbxassetid://96594483709547", -- 서빙하고 돈 받을 때
|
||||
BUY = "rbxassetid://90178922626515", -- 업그레이드 구매, 돈 부스트
|
||||
LEVELUP = "rbxassetid://134931950463198", -- 실내 분식집 확장
|
||||
POP = "rbxassetid://114946217416724", -- 요리 화면에서 톡톡 누를 때
|
||||
}
|
||||
13
bunsik-tycoon/tests/Codec.spec.luau
Normal file
@@ -0,0 +1,13 @@
|
||||
-- lune run tests/Codec.spec.luau
|
||||
local Codec = require("../src/shared/Codec")
|
||||
local T = require("./check")
|
||||
local s = Codec.encodeMap({ Cook = 1, Server = 2 }, { "Cook", "Server", "Promoter" })
|
||||
T.eq(s, "Cook=1,Server=2,Promoter=0", "encode")
|
||||
local m = Codec.decodeMap(s)
|
||||
T.eq(m.Server, 2, "decode")
|
||||
T.eq(m.Promoter, 0, "decode 0")
|
||||
T.eq(next(Codec.decodeMap(nil)), nil, "nil")
|
||||
T.eq(Codec.decodeMap("Price=1.5").Price, 1.5, "소수")
|
||||
T.eq(#Codec.decodeList("A,B,,C"), 3, "list")
|
||||
T.eq(#Codec.decodeList(""), 0, "빈 list")
|
||||
T.done("Codec.spec")
|
||||
109
bunsik-tycoon/tests/Economy.spec.luau
Normal file
@@ -0,0 +1,109 @@
|
||||
-- 경제 수치표 검사: lune run tests/Economy.spec.luau
|
||||
local Economy = require("../src/shared/Economy")
|
||||
local T = require("./check")
|
||||
|
||||
-- 갈래마다 단계 값이 오르고 필요한 건물 단계가 내려가지 않음
|
||||
for _, t in Economy.TRACKS do
|
||||
local prevCost, prevStage = 0, 1
|
||||
for i, l in t.levels do
|
||||
T.check(l.cost > prevCost, `{t.id}{i} 비용이 앞 단계보다 커야 함`)
|
||||
T.check(l.stage >= prevStage, `{t.id}{i} 필요 단계가 줄지 않음`)
|
||||
prevCost, prevStage = l.cost, l.stage
|
||||
if t.id == "Menu" then
|
||||
T.check(Economy.MENUS[l.value] ~= nil, `없는 메뉴 {l.value}`)
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, key in Economy.MENU_ORDER do
|
||||
T.check(Economy.MENUS[key] ~= nil, `메뉴 순서의 {key}`)
|
||||
end
|
||||
|
||||
local lv0 = Economy.emptyLevels()
|
||||
local s0 = Economy.stats(lv0, 1)
|
||||
T.eq(s0.seats, 1, "처음 자리 1")
|
||||
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개")
|
||||
T.eq(s0.stage, 1, "처음 포장마차")
|
||||
T.eq(s0.staffUnlocked, false, "처음엔 알바생 잠김")
|
||||
|
||||
local all = Economy.emptyLevels()
|
||||
for _, t in Economy.TRACKS do
|
||||
all[t.id] = #t.levels
|
||||
end
|
||||
local sAll = Economy.stats(all, 24)
|
||||
T.eq(sAll.stage, 3, "다 사면 2층")
|
||||
T.eq(#sAll.menus, 5, "메뉴 5개")
|
||||
T.eq(sAll.carry, 3, "접시 3개")
|
||||
T.eq(sAll.staffUnlocked, true, "알바생 열림")
|
||||
T.eq(Economy.stats(Economy.cleanLevels({ Menu = 99, Bad = 3 }), 1).menus[5], "Twigim", "범위를 넘어도 안전")
|
||||
T.eq(Economy.cleanLevels({ Menu = 99 }).Menu, 4, "레벨은 최대값으로 자름")
|
||||
|
||||
-- stats는 START_MENUS를 바꾸면 안 됨
|
||||
Economy.stats(all, 1)
|
||||
T.eq(#Economy.START_MENUS, 1, "START_MENUS 불변")
|
||||
|
||||
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), 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원(첫 손님 한 명 값으로 삼)")
|
||||
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) > 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)
|
||||
local ids = {}
|
||||
for _, o in offers do
|
||||
ids[o.id] = true
|
||||
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 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
|
||||
T.check(o.kind ~= "seat" and o.kind ~= "table", "1단계 자리 최대(6)면 자리 못 삼")
|
||||
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), 15, "홍보 알바 x0.75")
|
||||
T.eq(Economy.spawnInterval(s0, 0, true), 10, "손님 러시 x0.5")
|
||||
|
||||
-- 예전 세이브 옮기기
|
||||
local lv8, seats8, tables8, cooks8 = Economy.migrate(8)
|
||||
T.eq(lv8.Menu, 2, "예전 8개: 메뉴 2")
|
||||
T.eq(lv8.Price, 2, "양념 Lv1 = 판매 금액 1.5배")
|
||||
T.eq(lv8.Staff, 1, "알바생 기능")
|
||||
T.eq(cooks8, 1, "요리 알바 1명")
|
||||
T.eq(seats8, 3, "자리 3")
|
||||
T.eq(tables8, 3, "테이블 3")
|
||||
local lv20, seats20, tables20 = Economy.migrate(20)
|
||||
T.eq(lv20.Stage, 1, "예전 20개: 실내 분식집")
|
||||
T.eq(seats20, 8, "자리 8")
|
||||
T.eq(tables20, 6, "테이블은 2단계 최대 6")
|
||||
T.eq(Economy.migrate(0).Menu, 0, "예전 0개")
|
||||
|
||||
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")
|
||||
|
||||
T.done("Economy.spec")
|
||||
218
bunsik-tycoon/tests/Floor.spec.luau
Normal file
@@ -0,0 +1,218 @@
|
||||
-- 배치·길 찾기 검사: lune run tests/Floor.spec.luau
|
||||
local Floor = require("../src/shared/Floor")
|
||||
local T = require("./check")
|
||||
|
||||
local base = Floor.default()
|
||||
T.eq(Floor.validate(base, 1), nil, "기본 배치는 문제없음")
|
||||
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", "부지 밖")
|
||||
T.eq(select(2, Floor.move(base, 1, { kind = "table", i = 1, x = 0, z = 16 })), "reserved", "문 앞에는 못 놓음")
|
||||
T.eq(select(2, Floor.move(base, 1, { kind = "table", i = 1, x = 0, z = -24 })), "overlap", "조리대와 겹침")
|
||||
T.eq(select(2, Floor.move(base, 1, { kind = "table", i = 1, x = 0, z = 0, f = 2 })), "floor", "2층은 3단계부터")
|
||||
local moved, why = Floor.move(base, 1, { kind = "table", i = 1, x = 20, z = 5 })
|
||||
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].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)
|
||||
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, 13 do
|
||||
T.check(Floor.addChair(full, 2) ~= nil, "의자 자동 배치")
|
||||
end
|
||||
T.eq(#full.chairs, 14, "의자 14(2단계 최대)")
|
||||
T.eq(Floor.validate(full, 2), nil, "의자 14개 배치 통과")
|
||||
|
||||
-- 길: 입구에서 의자까지
|
||||
for i = 1, #full.chairs do
|
||||
local path = Floor.pathToChair(full, 2, i)
|
||||
local last = path[#path]
|
||||
local cp = Floor.chairPos(full, i)
|
||||
T.check(last.x == cp.x and last.z == cp.z, `의자 {i}까지 길 끝`)
|
||||
T.check(Floor.pathLength(path) < 120, `의자 {i} 길 길이 적당`)
|
||||
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 = {}
|
||||
for i = 1, 3 do
|
||||
block.chairs[i] = Floor.chairAt(block.tables[i], 1)
|
||||
end
|
||||
T.eq(Floor.validate(block, 1), "blocked", "조리대 앞을 테이블로 둘러싸면 거절")
|
||||
local opened = Floor.move(block, 1, { kind = "table", i = 3, x = 0, z = -10 })
|
||||
T.check(opened ~= nil, "한쪽을 열면 통과(의자도 같이 옮겨짐)")
|
||||
|
||||
-- 2층(3단계): 계단 자리 정리 후 2층에도 배치
|
||||
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)
|
||||
T.eq(Floor.validate(fixed, 3), nil, "repair 후 통과")
|
||||
local up = Floor.clone(fixed)
|
||||
for _ = 1, 10 do
|
||||
Floor.addTable(up, 3)
|
||||
end
|
||||
local on2 = 0
|
||||
for _, t in up.tables do
|
||||
if t.f == 2 then
|
||||
on2 += 1
|
||||
end
|
||||
end
|
||||
T.check(on2 > 0, "3단계에서는 2층에도 테이블이 놓임")
|
||||
T.eq(Floor.validate(up, 3), nil, "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 })
|
||||
T.eq(sw, nil, "조리대를 옮기고 돌리기")
|
||||
T.eq(s2 and s2.stove.r, 2, "회전 저장")
|
||||
local fx, fz = Floor.stovePoint({ x = 0, z = 0, r = 1 }, { x = 0, z = 4.5 })
|
||||
T.eq(fx, 4.5, "r=1이면 앞이 +X")
|
||||
T.eq(fz, 0, "r=1 z")
|
||||
|
||||
-- 소품
|
||||
local d = Floor.clone(base)
|
||||
T.check(Floor.addDecor(d, 1, "Plant") ~= nil, "화분 놓기")
|
||||
T.check(Floor.addDecor(d, 1, "Rug") ~= nil, "러그 놓기")
|
||||
T.eq(Floor.addDecor(d, 1, "Stove"), nil, "조리대는 소품 아님")
|
||||
T.eq(Floor.validate(d, 1), nil, "소품 배치 통과")
|
||||
|
||||
-- 지우기
|
||||
local rm = Floor.clone(base)
|
||||
Floor.addTable(rm, 1)
|
||||
Floor.addChair(rm, 1, 1)
|
||||
Floor.addDecor(rm, 1, "Plant")
|
||||
T.eq(select(2, Floor.remove(rm, 1, "stove", 1)), "stove", "조리대는 못 지움")
|
||||
T.eq(select(2, Floor.remove(rm, 1, "table", 1)), "hasChairs", "의자가 보는 테이블은 못 지움")
|
||||
local noTable2 = Floor.remove(rm, 1, "table", 2)
|
||||
T.check(noTable2 ~= nil and #noTable2.tables == 1, "의자 없는 테이블 지우기")
|
||||
local oneChair = Floor.remove(rm, 1, "chair", 1)
|
||||
T.check(oneChair ~= nil and #oneChair.chairs == 1, "의자 지우기")
|
||||
T.eq(oneChair and select(2, Floor.remove(oneChair, 1, "chair", 1)), "last", "마지막 의자는 못 지움")
|
||||
local noPlant = Floor.remove(rm, 1, "decor", 1)
|
||||
T.check(noPlant ~= nil and #noPlant.decor == 0, "소품 지우기")
|
||||
T.eq(#rm.decor, 1, "원래 배치는 그대로")
|
||||
|
||||
-- 저장값 정리
|
||||
local cleaned =
|
||||
Floor.clean({ stove = { x = "a" }, tables = { { x = 1, z = 2, f = 9 } }, chairs = { { t = 5, s = 1 } } })
|
||||
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")
|
||||
198
bunsik-tycoon/tests/Layout.spec.luau
Normal file
@@ -0,0 +1,198 @@
|
||||
-- 화면 UI 배치 검사: 기기별 화면에서 UI가 화면 안에 있고, 서로 겹치지 않고,
|
||||
-- 휴대폰에서는 누르는 버튼이 조이스틱·점프 버튼 자리를 피하고 손가락으로 누를 만큼 큰지. lune run tests/Layout.spec.luau
|
||||
local Layout = require("../src/client/Layout")
|
||||
local T = require("./check")
|
||||
|
||||
type Rect = Layout.Rect
|
||||
|
||||
-- 가로 화면 크기(포인트)에서 로블록스 상단 바(58)와 노치(좌우)를 뺀 UI 영역
|
||||
local DEVICES: { { name: string, w: number, h: number, touch: boolean } } = {
|
||||
{ name = "iPhone SE", w = 667, h = 375 - 58, touch = true },
|
||||
{ name = "iPhone 15", w = 844 - 94, h = 390 - 58, touch = true },
|
||||
{ name = "iPhone 15 Pro Max", w = 932 - 118, h = 430 - 58, touch = true },
|
||||
{ name = "Android 640x360", w = 640, h = 360 - 58, touch = true },
|
||||
{ name = "Android 800x360", w = 800, h = 360 - 58, touch = true },
|
||||
{ name = "Galaxy S 915x412", w = 915, h = 412 - 58, touch = true },
|
||||
{ name = "iPad 1024x768", w = 1024, h = 768 - 58, touch = true },
|
||||
{ name = "iPad Pro 11", w = 1194, h = 834 - 58, touch = true },
|
||||
{ name = "PC 1280x720", w = 1280, h = 720 - 58, touch = false },
|
||||
{ name = "PC 1366x768", w = 1366, h = 768 - 58, touch = false },
|
||||
{ name = "PC 1920x1080", w = 1920, h = 1080 - 58, touch = false },
|
||||
{ name = "PC 작은 창 800x600", w = 800, h = 600 - 58, touch = false },
|
||||
}
|
||||
|
||||
local function inside(r: Rect, W: number, H: number): boolean
|
||||
return r.x >= 0 and r.y >= 0 and r.x + r.w <= W + 1e-6 and r.y + r.h <= H + 1e-6
|
||||
end
|
||||
|
||||
local function overlap(a: Rect, b: Rect): boolean
|
||||
return a.x < b.x + b.w and b.x < a.x + a.w and a.y < b.y + b.h and b.y < a.y + a.h
|
||||
end
|
||||
|
||||
local function px(r: Rect, s: number): Rect
|
||||
return { x = r.x * s, y = r.y * s, w = r.w * s, h = r.h * s }
|
||||
end
|
||||
|
||||
for _, d in DEVICES do
|
||||
for _, dev in { false, true } do
|
||||
local L = Layout.compute(d.w, d.h, d.touch, dev)
|
||||
local tag = `{d.name}{if dev then "(개발자)" else ""}`
|
||||
T.check(
|
||||
math.abs(L.width * L.scale - d.w) < 1e-6 and math.abs(L.height * L.scale - d.h) < 1e-6,
|
||||
`{tag}: 화면 꽉 채움`
|
||||
)
|
||||
|
||||
-- 늘 보이는 요소: 화면 안, 서로 안 겹침
|
||||
local hud: { [string]: Rect } = {
|
||||
money = L.money,
|
||||
carry = L.carry,
|
||||
hint = L.hint,
|
||||
toasts = L.toasts,
|
||||
settings = L.settings,
|
||||
list = L.list,
|
||||
decorate = L.decorate,
|
||||
double = L.double,
|
||||
boost = L.boost,
|
||||
promote = L.promote,
|
||||
rush = L.rush,
|
||||
}
|
||||
for name, r in hud do
|
||||
T.check(inside(r, L.width, L.height), `{tag}: {name} 화면 안`)
|
||||
end
|
||||
local names = {}
|
||||
for name in hud do
|
||||
table.insert(names, name)
|
||||
end
|
||||
table.sort(names)
|
||||
for i, a in names do
|
||||
for j = i + 1, #names do
|
||||
local b = names[j]
|
||||
T.check(not overlap(hud[a], hud[b]), `{tag}: {a}와 {b} 안 겹침`)
|
||||
end
|
||||
end
|
||||
T.check(L.toasts.h >= 46, `{tag}: 알림 한 줄 이상 자리`)
|
||||
|
||||
-- 창(업그레이드 목록, 설정)은 화면 안에 다 들어감
|
||||
T.check(inside(L.panel, L.width, L.height), `{tag}: 업그레이드 창 화면 안`)
|
||||
T.check(inside(L.settingsPanel, L.width, L.height), `{tag}: 설정 창 화면 안`)
|
||||
T.check(inside(L.kitchen, L.width, L.height), `{tag}: 요리 창 화면 안`)
|
||||
T.check(inside(L.confirm, L.width, L.height), `{tag}: 홍보 확인 창 화면 안`)
|
||||
|
||||
-- 상점 창 안: 탭 3개와 내용 자리가 창 안에, 서로 안 겹침
|
||||
local panelBox = { x = 0, y = 0, w = L.panel.w, h = L.panel.h }
|
||||
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}와 내용 안 겹침`)
|
||||
T.check(t.y >= Layout.HEADER_H, `{tag}: 탭 {i}는 제목 띠 아래`)
|
||||
T.check(t.h * L.scale >= 44 and t.w * L.scale >= 44, `{tag}: 탭 {i} 누르기 쉬움`)
|
||||
if i > 1 then
|
||||
T.check(not overlap(t, L.tabs[i - 1]), `{tag}: 탭 {i - 1}·{i} 안 겹침`)
|
||||
end
|
||||
end
|
||||
T.check(inside(L.content, panelBox.w, panelBox.h), `{tag}: 탭 내용 창 안`)
|
||||
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 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(
|
||||
chh * L.scale
|
||||
)}px)`
|
||||
)
|
||||
end
|
||||
|
||||
-- 꾸미기 화면 버튼: 화면 안, 서로 안 겹침, 누르기 쉬움
|
||||
T.eq(#L.deco.tools, 3, `{tag}: 꾸미기 버튼 3개`)
|
||||
-- 물건 줄·이동·삭제(고를 때)와 들고 있을 때 버튼은 따로 보이므로 각각 검사합니다.
|
||||
local pick: { [string]: Rect } =
|
||||
{ exit = L.deco.exit, info = L.deco.info, strip = L.deco.strip, move = L.deco.move, delete = L.deco.delete }
|
||||
local pnames = {}
|
||||
for name, r in pick do
|
||||
T.check(inside(r, L.width, L.height), `{tag}: 꾸미기 {name} 화면 안`)
|
||||
table.insert(pnames, name)
|
||||
end
|
||||
table.sort(pnames)
|
||||
for i, a in pnames do
|
||||
for j = i + 1, #pnames do
|
||||
T.check(not overlap(pick[a], pick[pnames[j]]), `{tag}: 꾸미기 {a}와 {pnames[j]} 안 겹침`)
|
||||
end
|
||||
end
|
||||
T.check(L.deco.strip.w >= 3 * L.deco.move.w, `{tag}: 물건 줄에 3칸 넘게 보임`)
|
||||
if d.touch then
|
||||
local zones = Layout.touchZones(d.w, d.h)
|
||||
for name, r in pick do
|
||||
local p = px(r, L.scale)
|
||||
T.check(not overlap(p, zones.jump), `{tag}: 꾸미기 {name}이 점프 버튼 자리 피함`)
|
||||
if name ~= "info" then
|
||||
T.check(p.h >= 44, `{tag}: 꾸미기 {name} 높이 {math.floor(p.h)}px ≥ 44`)
|
||||
end
|
||||
end
|
||||
-- 물건 줄은 조이스틱 자리 맨 아래 띠만 씀(위쪽 2/3 넘게는 비어 있음)
|
||||
local sp = px(L.deco.strip, L.scale)
|
||||
T.check(sp.h <= zones.stick.h / 3, `{tag}: 물건 줄이 조이스틱 자리를 조금만 씀`)
|
||||
end
|
||||
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
|
||||
local dnames = {}
|
||||
for name, r in deco do
|
||||
T.check(inside(r, L.width, L.height), `{tag}: 꾸미기 {name} 화면 안`)
|
||||
table.insert(dnames, name)
|
||||
end
|
||||
table.sort(dnames)
|
||||
for i, a in dnames do
|
||||
for j = i + 1, #dnames do
|
||||
T.check(not overlap(deco[a], deco[dnames[j]]), `{tag}: 꾸미기 {a}와 {dnames[j]} 안 겹침`)
|
||||
end
|
||||
end
|
||||
T.check(L.kitchen.w * L.scale >= 0.6 * d.w or L.kitchen.w >= 780, `{tag}: 요리 창이 충분히 큼`)
|
||||
T.eq(L.rows.devY ~= nil, dev, `{tag}: 개발자 줄은 주인에게만`)
|
||||
T.eq(L.rows.mouseY == nil, d.touch, `{tag}: 마우스 회전 줄은 PC만`)
|
||||
|
||||
if d.touch then
|
||||
local zones = Layout.touchZones(d.w, d.h)
|
||||
local buttons: { [string]: Rect } = {
|
||||
settings = L.settings,
|
||||
list = L.list,
|
||||
decorate = L.decorate,
|
||||
double = L.double,
|
||||
boost = L.boost,
|
||||
promote = L.promote,
|
||||
rush = L.rush,
|
||||
}
|
||||
for name, r in buttons do
|
||||
local p = px(r, L.scale)
|
||||
T.check(not overlap(p, zones.stick), `{tag}: {name} 버튼이 조이스틱 자리 피함`)
|
||||
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
|
||||
end
|
||||
T.check(L.rows.langButtonH * L.scale >= 36, `{tag}: 언어 버튼 누르기 쉬움`)
|
||||
T.check(L.rows.toggleH * L.scale >= 34, `{tag}: 켜기/끄기 버튼 누르기 쉬움`)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- PC는 예전과 같은 기준 화면(1100x620), 휴대폰은 더 크게
|
||||
T.eq(Layout.scaleFor(1100, 620, false), 1, "PC 기준 배율")
|
||||
T.check(
|
||||
Layout.scaleFor(750, 332, true) > Layout.scaleFor(750, 332, false),
|
||||
"휴대폰은 같은 화면에서 더 크게"
|
||||
)
|
||||
|
||||
T.done("Layout")
|
||||
160
bunsik-tycoon/tests/Locale.spec.luau
Normal file
@@ -0,0 +1,160 @@
|
||||
-- 번역 검사: 네 언어 키가 같고, 코드에서 쓰는 키와 메뉴·업그레이드 이름이 모두 있는지. lune run tests/Locale.spec.luau
|
||||
local fs = require("@lune/fs")
|
||||
local Economy = require("../src/shared/Economy")
|
||||
local Locale = require("../src/shared/Locale")
|
||||
local Recipes = require("../src/shared/Recipes")
|
||||
local T = require("./check")
|
||||
|
||||
local NOTIFY = {
|
||||
"upgraded",
|
||||
"newMenu",
|
||||
"expanded",
|
||||
"floor2",
|
||||
"seatAdded",
|
||||
"tableAdded",
|
||||
"decorAdded",
|
||||
"noSpace",
|
||||
"seatMax",
|
||||
"tableMax",
|
||||
"tableFull",
|
||||
"needStage",
|
||||
"placeFail",
|
||||
"hired",
|
||||
"fired",
|
||||
"staffLocked",
|
||||
"staffMax",
|
||||
"strike",
|
||||
"strikeOver",
|
||||
"renamed",
|
||||
"nameRejected",
|
||||
"designSet",
|
||||
"designLocked",
|
||||
"promoted",
|
||||
"promoteNone",
|
||||
"promoteFull",
|
||||
"promoteWait",
|
||||
"adUnavailable",
|
||||
"kicked",
|
||||
"kickedBy",
|
||||
"shielded",
|
||||
"kickOwn",
|
||||
"rushOn",
|
||||
"notEnough",
|
||||
"boostGot",
|
||||
"guestBonus",
|
||||
"guestArrived",
|
||||
"guestSeated",
|
||||
"guestAte",
|
||||
"guestHungry",
|
||||
"visitFull",
|
||||
"tutDone",
|
||||
"devResetDone",
|
||||
}
|
||||
|
||||
local ko = Locale.keys("ko")
|
||||
table.sort(ko)
|
||||
for _, lang in Locale.LANGS do
|
||||
local keys = Locale.keys(lang)
|
||||
T.eq(#keys, #ko, `{lang} 키 개수`)
|
||||
for _, k in ko do
|
||||
T.check(table.find(keys, k) ~= nil, `{lang}에 {k} 있음`)
|
||||
end
|
||||
T.check(Locale.LANG_NAMES[lang] ~= nil, `{lang} 언어 이름`)
|
||||
for i = 1, 6 do
|
||||
T.check(Locale.t(lang, `npcShop{i}`) ~= `npcShop{i}`, `{lang} 이웃 가게 이름 {i}`)
|
||||
end
|
||||
for key in Economy.MENUS do
|
||||
T.check(Locale.menuName(lang, key) ~= "menu_" .. key, `{lang} 메뉴 이름 {key}`)
|
||||
end
|
||||
for _, r in Recipes.LIST do
|
||||
for _, st in r.steps do
|
||||
T.check(Locale.t(lang, st.key) ~= st.key, `{lang} 요리 안내 {st.key}`)
|
||||
end
|
||||
end
|
||||
local function has(key: string, what: string)
|
||||
T.check(Locale.t(lang, key) ~= key, `{lang} {what} {key}`)
|
||||
end
|
||||
for _, t in Economy.TRACKS do
|
||||
has("track_" .. t.id, "업그레이드 갈래 이름")
|
||||
has("fx_" .. t.id, "업그레이드 효과")
|
||||
for _, lv in t.levels do
|
||||
if t.id == "Stage" then
|
||||
has(`stage_{lv.value}`, "건물 단계 이름")
|
||||
end
|
||||
end
|
||||
end
|
||||
has("stage_1", "건물 단계 이름")
|
||||
for _, r in Economy.ROLES do
|
||||
has("role_" .. r.id, "알바 역할")
|
||||
has("roleDesc_" .. r.id, "알바 역할 설명")
|
||||
end
|
||||
for _, d in Economy.DECOR do
|
||||
has("decor_" .. d.id, "소품 이름")
|
||||
end
|
||||
for _, d in Economy.DESIGNS do
|
||||
has("design_" .. d.id, "디자인 이름")
|
||||
end
|
||||
for _, why in { "bounds", "overlap", "reserved", "floor", "blocked", "chair", "none" } do
|
||||
has("why_" .. why, "배치 실패 이유")
|
||||
end
|
||||
for i = 1, 4 do
|
||||
has(`side_{i}`, "의자 쪽")
|
||||
end
|
||||
-- 서버가 보내는 알림 키(NETWORK.md)
|
||||
for _, key in NOTIFY do
|
||||
has(key, "알림")
|
||||
end
|
||||
-- 치환 자리({money} 등)가 한국어와 같아야 함
|
||||
for _, k in ko do
|
||||
local want, got = {}, {}
|
||||
for v in string.gmatch(Locale.t("ko", k), "{(%w+)}") do
|
||||
want[v] = true
|
||||
end
|
||||
for v in string.gmatch(Locale.t(lang, k), "{(%w+)}") do
|
||||
got[v] = true
|
||||
end
|
||||
for v in want do
|
||||
T.check(got[v], `{lang}.{k}에 {"{" .. v .. "}"} 있음`)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function scan(dir: string)
|
||||
for _, name in fs.readDir(dir) do
|
||||
local path = dir .. "/" .. name
|
||||
if fs.isDir(path) then
|
||||
scan(path)
|
||||
elseif string.match(name, "%.luau$") then
|
||||
local src = fs.readFile(path)
|
||||
for _, pat in { 'Locale%.t%([^,]+,%s*"([%w]+)"', '[%s%(:]L%("([%w]+)"[,%)]', 'notify%("([%w]+)"' } do
|
||||
for key in string.gmatch(src, pat) do
|
||||
T.check(table.find(ko, key) ~= nil, `{path}: 키 {key}`)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
scan("src")
|
||||
|
||||
T.eq(Locale.pick("ko-kr"), "ko", "ko-kr -> ko")
|
||||
T.eq(Locale.pick("en-us"), "en", "en-us -> en")
|
||||
T.eq(Locale.pick("ja-jp"), "ja", "ja-jp -> ja")
|
||||
T.eq(Locale.pick("zh-cn"), "zh", "zh-cn -> zh")
|
||||
T.eq(Locale.pick("zh-tw"), "zh", "zh-tw -> zh")
|
||||
T.eq(Locale.pick("fr-fr"), "en", "그 외 -> en")
|
||||
T.eq(Locale.resolve("", "ja-jp"), "ja", "자동이면 계정 언어")
|
||||
T.eq(Locale.resolve("zh", "ko-kr"), "zh", "직접 고른 언어가 먼저")
|
||||
T.eq(Locale.resolve("xx", "ko-kr"), "ko", "모르는 설정이면 계정 언어")
|
||||
T.eq(Locale.t("ko", "money", { money = "1,000" }), "1,000원", "치환")
|
||||
T.eq(
|
||||
Locale.t("ja", "newMenu", { menuName = "キンパ" }),
|
||||
"新メニュー「キンパ」!お客さんがキンパも注文するようになるよ",
|
||||
"같은 자리 두 번 치환"
|
||||
)
|
||||
T.eq(Locale.menuName("zh", "Gimbap"), "紫菜包饭", "중국어 메뉴 이름")
|
||||
T.eq(Locale.t("en", "track_Speed"), "Customer Speed", "영어 갈래 이름")
|
||||
T.eq(Locale.number(1234567), "1,234,567", "쉼표")
|
||||
T.eq(Locale.number(999), "999", "쉼표 없음")
|
||||
T.eq(Locale.number(0), "0", "0")
|
||||
|
||||
T.done("Locale.spec")
|
||||
90
bunsik-tycoon/tests/Receipts.spec.luau
Normal file
@@ -0,0 +1,90 @@
|
||||
-- 결제 1회 = 지급 1회 검사(가짜 프로필): lune run tests/Receipts.spec.luau
|
||||
local Receipts = require("../src/server/Receipts")
|
||||
local T = require("./check")
|
||||
|
||||
local function deepcopy(t)
|
||||
local out = {}
|
||||
for k, v in t do
|
||||
out[k] = if type(v) == "table" then deepcopy(v) else v
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
local function fakeProfile(saveWorks: boolean)
|
||||
local p = {
|
||||
Data = { PurchaseIdCache = {}, Money = 0 },
|
||||
LastSavedData = { PurchaseIdCache = {} },
|
||||
active = true,
|
||||
saves = 0,
|
||||
}
|
||||
function p:IsActive()
|
||||
return self.active
|
||||
end
|
||||
function p:Save()
|
||||
self.saves += 1
|
||||
if saveWorks then
|
||||
self.LastSavedData = deepcopy(self.Data)
|
||||
else
|
||||
self.active = false -- 저장 실패 끝에 세션이 끝난 상황
|
||||
end
|
||||
end
|
||||
p.OnAfterSave = { Wait = function() end }
|
||||
return p
|
||||
end
|
||||
|
||||
local p = fakeProfile(true)
|
||||
local grants = 0
|
||||
local function grant()
|
||||
grants += 1
|
||||
p.Data.Money += 100
|
||||
return true
|
||||
end
|
||||
T.eq(Receipts.process(p, "A", grant), "Granted", "첫 결제 지급")
|
||||
T.eq(grants, 1, "지급 1회")
|
||||
T.eq(p.Data.Money, 100, "돈 들어옴")
|
||||
T.check(table.find(p.LastSavedData.PurchaseIdCache, "A") ~= nil, "저장된 데이터에 PurchaseId 기록")
|
||||
T.eq(Receipts.process(p, "A", grant), "Granted", "같은 결제 재시도도 완료로 답함")
|
||||
T.eq(grants, 1, "같은 결제는 다시 지급하지 않음")
|
||||
T.eq(Receipts.process(p, "B", grant), "Granted", "다른 결제는 지급")
|
||||
T.eq(grants, 2, "지급 2회")
|
||||
|
||||
T.eq(Receipts.process(nil, "C", grant), "NotProcessedYet", "프로필 없으면 나중에")
|
||||
T.eq(grants, 2, "프로필 없으면 지급 안 함")
|
||||
|
||||
local q = fakeProfile(true)
|
||||
T.eq(
|
||||
Receipts.process(q, "X", function()
|
||||
return false
|
||||
end),
|
||||
"NotProcessedYet",
|
||||
"지급 실패면 나중에"
|
||||
)
|
||||
T.eq(#q.Data.PurchaseIdCache, 0, "실패한 결제는 기록 안 함")
|
||||
T.eq(
|
||||
Receipts.process(q, "Y", function()
|
||||
error("boom")
|
||||
end),
|
||||
"NotProcessedYet",
|
||||
"지급 중 오류면 나중에"
|
||||
)
|
||||
|
||||
local r = fakeProfile(false)
|
||||
local rg = 0
|
||||
T.eq(
|
||||
Receipts.process(r, "Z", function()
|
||||
rg += 1
|
||||
return true
|
||||
end),
|
||||
"NotProcessedYet",
|
||||
"저장 확인 못 하면 완료로 답하지 않음"
|
||||
)
|
||||
|
||||
local c = fakeProfile(true)
|
||||
for i = 1, Receipts.CACHE_SIZE + 5 do
|
||||
Receipts.process(c, "P" .. i, function()
|
||||
return true
|
||||
end)
|
||||
end
|
||||
T.eq(#c.Data.PurchaseIdCache, Receipts.CACHE_SIZE, "기록은 최근 100개까지")
|
||||
|
||||
T.done("Receipts.spec")
|
||||
83
bunsik-tycoon/tests/Recipes.spec.luau
Normal file
@@ -0,0 +1,83 @@
|
||||
-- 요리 과정 검사: lune run tests/Recipes.spec.luau
|
||||
local Economy = require("../src/shared/Economy")
|
||||
local Recipes = require("../src/shared/Recipes")
|
||||
local T = require("./check")
|
||||
|
||||
T.eq(Recipes.BASE_COOK, Economy.START_COOK, "기준 화구 수준 = 처음 조리 시간")
|
||||
for _, menu in Economy.MENU_ORDER do
|
||||
local r = Recipes.LIST[menu]
|
||||
T.check(r ~= nil, `{menu} 요리 과정 있음`)
|
||||
T.check(#r.steps >= 2 and #r.steps <= 3, `{menu} 단계 2~3개`)
|
||||
local kinds = {}
|
||||
for i, s in r.steps do
|
||||
T.eq(s.key, `cook_{menu}_{i}`, `{menu} {i}단계 안내 글 키`)
|
||||
kinds[s.kind] = true
|
||||
end
|
||||
local n = 0
|
||||
for _ in kinds do
|
||||
n += 1
|
||||
end
|
||||
T.check(n >= 2, `{menu}: 단계마다 조작이 달라 지루하지 않음`)
|
||||
-- 아이가 한 접시에 쓰는 시간: 처음 3~7초, 화구를 다 사면 더 짧아짐
|
||||
local t0 = Recipes.expectedTime(menu, 2.5)
|
||||
local t2 = Recipes.expectedTime(menu, 1)
|
||||
T.check(t0 >= 3 and t0 <= 7, `{menu} 처음 {t0}초`)
|
||||
T.check(t2 < t0 * 0.75, `{menu} 화구 Lv2면 {t2}초로 빨라짐`)
|
||||
-- 서버 최소 시간: 정상 플레이(아이 속도)보다 넉넉히 짧고, 0보다는 커서 조리 과정 건너뛰기를 막음
|
||||
for _, cook in { 2.5, 1.5, 1 } do
|
||||
local m = Recipes.minTime(menu, cook)
|
||||
T.check(m > 0.3, `{menu} 화구 {cook}: 최소 시간 {m}초 > 0.3`)
|
||||
T.check(
|
||||
m < Recipes.expectedTime(menu, cook) * 0.6,
|
||||
`{menu} 화구 {cook}: 최소 시간이 보통 시간보다 넉넉히 짧음`
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
-- 서로 다른 메뉴는 과정이 다름
|
||||
local seen = {}
|
||||
for menu, r in Recipes.LIST do
|
||||
local sig = r.stage
|
||||
for _, s in r.steps do
|
||||
sig ..= s.kind .. s.tool
|
||||
end
|
||||
T.check(seen[sig] == nil, `{menu} 과정이 다른 메뉴와 같지 않음`)
|
||||
seen[sig] = true
|
||||
end
|
||||
|
||||
-- 누르는 횟수는 정수, 최소 2번
|
||||
T.eq(Recipes.need({ kind = "tap", key = "", base = 4, tool = "" }, 2.5), 4, "화구 Lv0: 4번")
|
||||
T.eq(Recipes.need({ kind = "tap", key = "", base = 4, tool = "" }, 1.5), 2, "화구 Lv1: 2번(2.4 반올림)")
|
||||
T.eq(Recipes.need({ kind = "tap", key = "", base = 4, tool = "" }, 1), 2, "화구 Lv2: 최소 2번")
|
||||
T.check(
|
||||
math.abs(Recipes.need({ kind = "hold", key = "", base = 1, tool = "" }, 1.5) - 0.6) < 1e-9,
|
||||
"꾹 누르기 0.6초"
|
||||
)
|
||||
|
||||
-- 진행 상태: 떡볶이(톡톡 4 → 꾹 1초 → 문지르기 3)
|
||||
local f = Recipes.newFlow(2.5)
|
||||
T.eq(Recipes.input(f, "tap", 1), nil, "메뉴 고르기 전에는 입력 무시")
|
||||
T.eq(Recipes.choose(f, "Nope"), false, "없는 메뉴는 못 고름")
|
||||
T.eq(Recipes.choose(f, "Tteokbokki"), true, "떡볶이 고름")
|
||||
T.eq(f.phase, "cook", "조리 시작")
|
||||
T.eq(Recipes.choose(f, "Gimbap"), false, "조리 중에는 다시 못 고름")
|
||||
T.eq(Recipes.input(f, "hold", 1), nil, "다른 조작은 무시(실패 없음)")
|
||||
T.eq(Recipes.input(f, "tap", 1), "progress", "톡 1")
|
||||
T.eq(Recipes.input(f, "tap", 1), "progress", "톡 2")
|
||||
T.eq(Recipes.input(f, "tap", 1), "progress", "톡 3")
|
||||
T.eq(Recipes.fraction(f), (0 + 3 / 4) / 3, "전체 진행률")
|
||||
T.eq(Recipes.input(f, "tap", 1), "step", "톡 4 → 다음 단계")
|
||||
T.eq(f.step, 2, "2단계")
|
||||
T.eq(Recipes.input(f, "hold", 0.5), "progress", "꾹 0.5초")
|
||||
T.eq(Recipes.input(f, "hold", 0.6), "step", "꾹 1초 넘음 → 다음 단계")
|
||||
T.eq(Recipes.input(f, "rub", 0), nil, "움직임 0은 무시")
|
||||
T.eq(Recipes.input(f, "rub", 2), "progress", "문지르기 2")
|
||||
T.eq(Recipes.input(f, "rub", 5), "done", "문지르기 끝 → 완성")
|
||||
T.eq(f.phase, "done", "완성 상태")
|
||||
T.eq(Recipes.fraction(f), 1, "완성 진행률 1")
|
||||
T.eq(Recipes.input(f, "tap", 1), nil, "완성 뒤 입력 무시")
|
||||
Recipes.reset(f, 1)
|
||||
T.eq(f.phase, "menu", "다음 접시: 메뉴 고르기로")
|
||||
T.eq(f.cook, 1, "화구 수준 갱신")
|
||||
|
||||
T.done("Recipes.spec")
|
||||
249
bunsik-tycoon/tests/Shop.spec.luau
Normal file
@@ -0,0 +1,249 @@
|
||||
-- 가게 로직 검사: lune run tests/Shop.spec.luau
|
||||
local Economy = require("../src/shared/Economy")
|
||||
local Shop = require("../src/shared/Shop")
|
||||
local T = require("./check")
|
||||
|
||||
local function kinds(evs, kind)
|
||||
local out = {}
|
||||
for _, e in evs do
|
||||
if e.kind == kind then
|
||||
table.insert(out, e)
|
||||
end
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
-- 첫 손님은 바로 오고, 걸어서 자리에 앉습니다.
|
||||
local s = Shop.new({ money = 0, now = 100 })
|
||||
local ev = Shop.tick(s, 100)
|
||||
T.eq(#ev, 1, "접속하자마자 손님 1명")
|
||||
T.eq(ev[1].kind, "spawn", "spawn 이벤트")
|
||||
T.eq(ev[1].menu, "Tteokbokki", "첫 주문은 떡볶이")
|
||||
T.eq(Shop.nextCookMenu(s), "Tteokbokki", "걷는 중인 손님 주문도 미리 만들 수 있음")
|
||||
T.eq(Shop.serve(s, 1), nil, "앉기 전에는 서빙 불가")
|
||||
|
||||
-- 자리가 1개면 두 번째 손님은 못 들어옴
|
||||
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), 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, 120 + Economy.EAT + 0.1), "leave") == 1, "다 먹으면 나감")
|
||||
T.eq(s.customers[1], nil, "손님 목록에서 빠짐")
|
||||
|
||||
-- 갈래 업그레이드
|
||||
local b = Shop.new({ money = 100, now = 0 })
|
||||
local lv, err = Shop.buyLevel(b, "Menu")
|
||||
T.eq(lv and lv.value, "Gimbap", "메뉴 갈래 첫 단계 = 김밥")
|
||||
T.eq(err, nil, "구매 성공")
|
||||
T.eq(b.money, 60, "돈 차감")
|
||||
T.eq(#b.stats.menus, 2, "메뉴 2개")
|
||||
T.eq(select(2, Shop.buyLevel(b, "Tray")), "stage", "쟁반은 실내 분식집부터")
|
||||
T.eq(select(2, Shop.buyLevel(b, "Stage")), "money", "돈 모자람")
|
||||
b.money = 1e6
|
||||
for _ = 1, 3 do
|
||||
Shop.buyLevel(b, "Menu")
|
||||
end
|
||||
T.eq(#b.stats.menus, 3, "건물 단계가 낮으면 어묵은 못 삼")
|
||||
T.check(Shop.buyLevel(b, "Stage") ~= nil, "실내 확장")
|
||||
T.eq(b.stats.stage, 2, "2단계")
|
||||
Shop.buyLevel(b, "Menu")
|
||||
Shop.buyLevel(b, "Menu")
|
||||
T.eq(#b.stats.menus, 5, "2단계면 메뉴 5개까지")
|
||||
T.eq(select(2, Shop.buyLevel(b, "Menu")), "max", "다 삼")
|
||||
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, 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, 20), "spawn"), 1, "자리 2개면 두 번째 손님")
|
||||
Shop.setSeats(seats, 3)
|
||||
T.eq(seats.stats.seats, 3, "자리 3")
|
||||
T.check(seats.nextSpawn <= 21, "자리가 생기면 곧 손님")
|
||||
|
||||
-- 2배 수익
|
||||
local d = Shop.new({ money = 0, now = 0 })
|
||||
d.moneyMult = 2
|
||||
Shop.tick(d, 0)
|
||||
Shop.tick(d, 3)
|
||||
Shop.cook(d)
|
||||
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, 20)
|
||||
local counts = Shop.openCounts(pick)
|
||||
T.eq(counts.Tteokbokki, 1, "떡볶이 주문 1")
|
||||
T.eq(counts.Gimbap, 1, "김밥 주문 1")
|
||||
T.eq(Shop.cook(pick, "Sundae"), nil, "주문 없는 메뉴는 못 만듦")
|
||||
T.eq(Shop.cook(pick, "Gimbap"), "Gimbap", "나중에 온 손님 메뉴를 골라 만들 수 있음")
|
||||
T.eq(Shop.openCounts(pick).Gimbap, nil, "만든 김밥만큼 주문이 채워짐")
|
||||
T.eq(Shop.cook(pick, "Tteokbokki"), nil, "손이 꽉 차면 못 만듦")
|
||||
|
||||
-- 알바생: 잠김 → 열고 고용 → 요리 알바가 카운터에 접시
|
||||
local h = Shop.new({ money = 1000, now = 0 })
|
||||
T.eq(select(2, Shop.hire(h, "Cook")), "locked", "알바생 기능 전에는 고용 불가")
|
||||
Shop.buyLevel(h, "Staff")
|
||||
local before = h.money
|
||||
T.eq(Shop.hire(h, "Cook"), true, "요리 알바 고용")
|
||||
T.eq(h.money, before - 200, "고용비")
|
||||
Shop.hire(h, "Cook")
|
||||
T.eq(select(2, Shop.hire(h, "Cook")), "max", "요리 알바는 2명까지")
|
||||
T.eq(select(2, Shop.hire(h, "Boss")), "none", "없는 역할")
|
||||
local evs = Shop.tick(h, 0)
|
||||
T.eq(#kinds(evs, "counter"), 1, "요리 알바가 첫 주문을 바로 만듦(주문 1개)")
|
||||
T.eq(Shop.nextCookMenu(h), nil, "만들어 둔 접시가 주문을 덮음")
|
||||
T.eq(Shop.pickup(h), 1, "접시를 집음")
|
||||
Shop.tick(h, 3)
|
||||
T.check(Shop.serve(h, 1) ~= nil, "알바 접시로 서빙")
|
||||
|
||||
-- 시급: 1분마다, 모자라면 쉼
|
||||
local wage = Shop.new({ money = 0, now = 0, levels = { Staff = 1 }, staff = { Cook = 1 } })
|
||||
T.eq(#kinds(Shop.tick(wage, 1), "counter"), 1, "고용 직후 일함")
|
||||
local strike = kinds(Shop.tick(wage, Economy.WAGE_PERIOD + 0.1), "strike")
|
||||
T.eq(strike[1] and strike[1].on, true, "시급이 모자라면 쉼")
|
||||
T.eq(wage.money, 0, "빚은 지지 않음")
|
||||
Shop.tick(wage, Economy.WAGE_PERIOD + 20)
|
||||
T.eq(#wage.counter, 1, "쉬는 동안 안 만듦(처음 1개만)")
|
||||
wage.money = 100
|
||||
local paid = Shop.tick(wage, Economy.WAGE_PERIOD + 30)
|
||||
T.eq(kinds(paid, "wage")[1] and kinds(paid, "wage")[1].amount, 12, "돈이 생기면 시급 12")
|
||||
T.eq(kinds(paid, "strike")[1] and kinds(paid, "strike")[1].on, false, "다시 일함")
|
||||
T.eq(wage.money, 88, "시급 차감")
|
||||
T.eq(Shop.fire(wage, "Cook"), true, "해고")
|
||||
T.eq(Shop.fire(wage, "Cook"), false, "더 없음")
|
||||
|
||||
-- 서빙 알바: 카운터 접시를 손님에게
|
||||
local sv = Shop.new({ money = 0, now = 0, levels = { Staff = 1 }, staff = { Cook = 1, Server = 1 } })
|
||||
local e0 = Shop.tick(sv, 0) -- 손님 + 요리 알바 접시
|
||||
T.eq(#kinds(e0, "counter"), 1, "카운터 접시")
|
||||
T.eq(#kinds(Shop.tick(sv, 1), "deliver"), 0, "손님이 앉기 전에는 안 나름")
|
||||
local e2 = Shop.tick(sv, Economy.WALK_IN + 0.1)
|
||||
T.eq(#kinds(e2, "deliver"), 1, "앉으면 서빙 알바가 가져감")
|
||||
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, 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), 15, "홍보 알바 간격 x0.75")
|
||||
Shop.addRush(pr, 30)
|
||||
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, 20)
|
||||
Shop.tick(victim, 40)
|
||||
Shop.cook(victim) -- 1번 손님 떡볶이를 들고 있음
|
||||
local taken = Shop.takeCustomers(victim, 5)
|
||||
T.eq(#taken, 3, "3명 모두 데려감(아직 못 먹음)")
|
||||
T.eq(taken[1].id, 3, "늦게 온 손님부터")
|
||||
T.eq(next(victim.customers), nil, "손님 없음")
|
||||
-- 남은 떡볶이 접시: 다음 손님이 떡볶이를 주문
|
||||
victim.menuIndex = 1 -- 원래라면 다음은 김밥
|
||||
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 })
|
||||
local tc = Shop.addTransfer(thief, "Twigim", 7)
|
||||
T.eq(tc and tc.menu, "Tteokbokki", "우리 가게에 없는 메뉴면 우리 메뉴로")
|
||||
T.eq(tc and tc.transfer, true, "옆 가게 손님 표시")
|
||||
T.check(Shop.addTransfer(thief, "Tteokbokki", 7) ~= nil, "두 번째 자리")
|
||||
T.eq(Shop.addTransfer(thief, "Tteokbokki", 7), nil, "자리 없으면 못 옴")
|
||||
T.eq(Shop.freeSeatCount(thief), 0, "빈자리 0")
|
||||
|
||||
-- 새 메뉴를 사면 다음 손님이 1초 안에 와서 그 메뉴를 주문
|
||||
local nm = Shop.new({ money = 40, now = 0, seats = 2 })
|
||||
Shop.tick(nm, 0)
|
||||
Shop.buyLevel(nm, "Menu")
|
||||
local newOrder = kinds(Shop.tick(nm, 1), "spawn")
|
||||
T.eq(newOrder[1] and newOrder[1].menu, "Gimbap", "사자마자 다음 손님이 김밥 주문")
|
||||
|
||||
-- 세이브 값이 이상해도 안전
|
||||
local weird = Shop.new({ money = 5, now = 0, levels = { Menu = 99 } :: any, staff = { Cook = 99, Server = -3 } })
|
||||
T.eq(#weird.stats.menus, 5, "레벨은 최대값으로 자름")
|
||||
T.eq(weird.staff.Cook, 2, "알바 수는 최대값으로 자름")
|
||||
T.eq(weird.staff.Server, 0, "음수는 0")
|
||||
|
||||
-- 플레이어 손님: 빈자리에 바로 앉고, 2배 값을 내고, 다 먹으면 나감
|
||||
local g = Shop.new({ money = 0, now = 0, seats = 2 })
|
||||
Shop.tick(g, 0) -- NPC 손님 1명(1번 자리)
|
||||
local guest = Shop.addGuest(g, 777)
|
||||
T.check(guest ~= nil, "플레이어 손님 앉음")
|
||||
T.eq(guest and guest.seat, 2, "빈 2번 자리")
|
||||
T.eq(guest and guest.state, "waiting", "걷지 않고 바로 주문")
|
||||
T.eq(Shop.addGuest(g, 777), nil, "같은 플레이어는 한 번만")
|
||||
T.eq(Shop.addGuest(g, 888), nil, "빈자리가 없으면 못 앉음")
|
||||
T.eq(#kinds(Shop.tick(g, 20.5), "spawn"), 0, "플레이어 손님 자리에는 NPC가 안 옴")
|
||||
Shop.cook(g)
|
||||
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), 60, "플레이어 손님은 2배")
|
||||
local guestLeave = nil
|
||||
for _, e in Shop.tick(g, 20.5 + Economy.EAT + 0.1) do
|
||||
if e.kind == "leave" and e.guest then
|
||||
guestLeave = e
|
||||
end
|
||||
end
|
||||
T.eq(guestLeave and guestLeave.guest, 777, "다 먹으면 플레이어 손님도 나감")
|
||||
T.eq(guestLeave and guestLeave.served, true, "먹고 나감")
|
||||
T.eq(#Shop.takeCustomers(g, 5), 0, "플레이어 손님·먹는 손님은 못 데려감")
|
||||
|
||||
-- 음식을 너무 오래 못 받으면 일어남
|
||||
local w = Shop.new({ money = 0, now = 0 })
|
||||
local wg = Shop.addGuest(w, 5)
|
||||
T.check(wg ~= nil, "자리 1개에 플레이어 손님")
|
||||
local hungry = kinds(Shop.tick(w, Economy.GUEST_WAIT + 0.1), "leave")[1]
|
||||
T.eq(hungry and hungry.served, false, "못 먹고 나감")
|
||||
|
||||
-- 먼저 일어나면 자리만 비움
|
||||
local r = Shop.new({ money = 0, now = 0 })
|
||||
local rg = Shop.addGuest(r, 9) :: any
|
||||
T.eq(Shop.removeGuest(r, rg.id) and true, true, "일어남")
|
||||
T.eq(r.seatTaken[1], nil, "자리 비움")
|
||||
T.eq(Shop.removeGuest(r, rg.id), nil, "두 번은 안 됨")
|
||||
Shop.tick(r, 0)
|
||||
T.eq(Shop.removeGuest(r, 2), nil, "NPC 손님은 removeGuest로 못 뺌")
|
||||
|
||||
-- 자리 빼기(꾸미기에서 의자 삭제): 앉은 자리는 못 빼고, 뒤 번호 손님은 한 칸 당겨짐
|
||||
local rs = Shop.new({ money = 0, now = 0, seats = 3 })
|
||||
rs.seatWalk = { 2, 3, 4 }
|
||||
Shop.tick(rs, 0) -- 첫 손님
|
||||
local first = next(rs.customers)
|
||||
local c1 = first and rs.customers[first]
|
||||
T.check(c1 ~= nil, "손님 1명")
|
||||
if c1 then
|
||||
c1.seat = 3
|
||||
rs.seatTaken = { [3] = c1.id }
|
||||
T.check(not Shop.removeSeat(rs, 3), "손님이 있는 자리는 못 뺌")
|
||||
T.check(Shop.removeSeat(rs, 1), "빈 자리 빼기")
|
||||
T.eq(rs.stats.seats, 2, "자리 2")
|
||||
T.eq(c1.seat, 2, "뒤 손님 자리 번호가 당겨짐")
|
||||
T.eq(rs.seatTaken[2], c1.id, "앉은 자리 표시도 당겨짐")
|
||||
T.eq(rs.seatWalk[1], 3, "걷는 시간도 당겨짐")
|
||||
end
|
||||
local last = Shop.new({ money = 0, now = 0, seats = 1 })
|
||||
T.check(not Shop.removeSeat(last, 1), "마지막 자리는 못 뺌")
|
||||
|
||||
T.done("Shop.spec")
|
||||
33
bunsik-tycoon/tests/Sim.spec.luau
Normal file
@@ -0,0 +1,33 @@
|
||||
-- 봇 플레이로 구매 시점 목표를 검사: lune run tests/Sim.spec.luau
|
||||
local Sim = require("../tools/simlib")
|
||||
local T = require("./check")
|
||||
|
||||
local function at(log, id)
|
||||
for _, e in log do
|
||||
if e.id == id then
|
||||
return e.t
|
||||
end
|
||||
end
|
||||
return math.huge
|
||||
end
|
||||
|
||||
local base = Sim.run(1, 7200)
|
||||
T.check(#base >= 30, "봇이 2시간 안에 30번 넘게 삼(업그레이드가 잘게 나뉨)")
|
||||
T.check(base[1].t <= 10, "첫 구매 10초 안")
|
||||
T.check(at(base, "Stage1") >= 8 * 60 and at(base, "Stage1") <= 16 * 60, "실내 확장 8~16분")
|
||||
T.check(at(base, "Stage2") >= 40 * 60 and at(base, "Stage2") <= 70 * 60, "2층 40~70분")
|
||||
T.check(at(base, "Staff1") < at(base, "Stage1"), "알바생 기능은 확장 전에 열림")
|
||||
local prev = 0
|
||||
for i, e in base do
|
||||
if i > 1 and e.t < at(base, "Stage1") then
|
||||
T.check(e.t - prev <= 100, `1단계 #{i} {e.id} 구매 간격 100초 이하`)
|
||||
elseif i > 1 then
|
||||
T.check(e.t - prev <= 240, `#{i} {e.id} 구매 간격 4분 이하`)
|
||||
end
|
||||
prev = e.t
|
||||
end
|
||||
|
||||
local x2 = Sim.run(2, 7200)
|
||||
T.check(at(x2, "Stage1") < at(base, "Stage1") * 0.65, "2배 수익이면 확장이 훨씬 빠름")
|
||||
|
||||
T.done("Sim.spec")
|
||||
25
bunsik-tycoon/tests/check.luau
Normal file
@@ -0,0 +1,25 @@
|
||||
-- 아주 작은 테스트 도우미: check(조건, 메시지) 후 done(이름)
|
||||
local failures = 0
|
||||
local count = 0
|
||||
local M = {}
|
||||
|
||||
function M.check(cond: any, msg: string)
|
||||
count += 1
|
||||
if not cond then
|
||||
failures += 1
|
||||
print("FAIL " .. msg)
|
||||
end
|
||||
end
|
||||
|
||||
function M.eq(a: any, b: any, msg: string)
|
||||
M.check(a == b, `{msg} (기대 {tostring(b)}, 실제 {tostring(a)})`)
|
||||
end
|
||||
|
||||
function M.done(name: string)
|
||||
if failures > 0 then
|
||||
error(`{name}: {failures}/{count} failed`)
|
||||
end
|
||||
print(`{name}: {count} checks passed`)
|
||||
end
|
||||
|
||||
return M
|
||||
351
bunsik-tycoon/tests/cloud/dump_gui.luau
Normal file
@@ -0,0 +1,351 @@
|
||||
-- 화면 UI를 여러 상황(기기 크기, 창 열림)으로 서버에서 만들어 JSON으로 덤프합니다.
|
||||
-- python3 tools/cloud.py run tests/cloud/dump_gui.luau --version N → 출력의 JSON을 tools/gui_render.py로 그림
|
||||
local HttpService = game:GetService("HttpService")
|
||||
local StarterPlayer = game:GetService("StarterPlayer")
|
||||
|
||||
local Client = StarterPlayer.StarterPlayerScripts.Client
|
||||
local Hud = require(Client.Hud)
|
||||
local Decorate = require(Client.Decorate)
|
||||
local Layout = require(Client.Layout)
|
||||
local Icons = require(game:GetService("ReplicatedStorage").Shared.Icons)
|
||||
|
||||
local function c3(c: Color3): { number }
|
||||
return { c.R, c.G, c.B }
|
||||
end
|
||||
local function ud(u: UDim): { number }
|
||||
return { u.Scale, u.Offset }
|
||||
end
|
||||
local function ud2(u: UDim2): { { number } }
|
||||
return { ud(u.X), ud(u.Y) }
|
||||
end
|
||||
|
||||
local function gradient(g: UIGradient): { [string]: any }
|
||||
local colors = {}
|
||||
for _, kp in g.Color.Keypoints do
|
||||
table.insert(colors, { kp.Time, c3(kp.Value) })
|
||||
end
|
||||
local trans = {}
|
||||
for _, kp in g.Transparency.Keypoints do
|
||||
table.insert(trans, { kp.Time, kp.Value })
|
||||
end
|
||||
return {
|
||||
Color = colors,
|
||||
Transparency = trans,
|
||||
Rotation = g.Rotation,
|
||||
Offset = { g.Offset.X, g.Offset.Y },
|
||||
Enabled = g.Enabled,
|
||||
}
|
||||
end
|
||||
|
||||
local function fontName(f: Font): string
|
||||
return (f.Family:match("families/(.-)%.json") or "FredokaOne")
|
||||
end
|
||||
|
||||
local function dump(o: Instance, i: number): { [string]: any }?
|
||||
if not o:IsA("GuiBase2d") then
|
||||
return nil
|
||||
end
|
||||
local d: { [string]: any } = { ClassName = o.ClassName, Name = o.Name, _i = i }
|
||||
if o:IsA("GuiObject") then
|
||||
d.Visible = o.Visible
|
||||
d.Size = ud2(o.Size)
|
||||
d.Position = ud2(o.Position)
|
||||
d.AnchorPoint = { o.AnchorPoint.X, o.AnchorPoint.Y }
|
||||
d.Rotation = o.Rotation
|
||||
d.ZIndex = o.ZIndex
|
||||
d.LayoutOrder = o.LayoutOrder
|
||||
d.BackgroundColor3 = c3(o.BackgroundColor3)
|
||||
d.BackgroundTransparency = o.BackgroundTransparency
|
||||
d.ClipsDescendants = o.ClipsDescendants
|
||||
d.SizeConstraint = o.SizeConstraint.Name
|
||||
end
|
||||
if o:IsA("ScrollingFrame") then
|
||||
d.CanvasPosition = { o.CanvasPosition.X, o.CanvasPosition.Y }
|
||||
end
|
||||
if o:IsA("TextLabel") or o:IsA("TextButton") or o:IsA("TextBox") then
|
||||
d.Text = o.Text
|
||||
d.TextColor3 = c3(o.TextColor3)
|
||||
d.TextTransparency = o.TextTransparency
|
||||
d.TextScaled = o.TextScaled
|
||||
d.TextWrapped = o.TextWrapped
|
||||
d.TextSize = o.TextSize
|
||||
d.TextXAlignment = o.TextXAlignment.Name
|
||||
d.TextYAlignment = o.TextYAlignment.Name
|
||||
d.TextStrokeTransparency = o.TextStrokeTransparency
|
||||
d.TextStrokeColor3 = c3(o.TextStrokeColor3)
|
||||
d.Font = fontName(o.FontFace)
|
||||
d.Weight = o.FontFace.Weight.Name
|
||||
end
|
||||
if o:IsA("ImageLabel") or o:IsA("ImageButton") then
|
||||
d.Image = o.Image
|
||||
d.ImageColor3 = c3(o.ImageColor3)
|
||||
d.ImageTransparency = o.ImageTransparency
|
||||
d.ImageRectOffset = { o.ImageRectOffset.X, o.ImageRectOffset.Y }
|
||||
d.ImageRectSize = { o.ImageRectSize.X, o.ImageRectSize.Y }
|
||||
d.ScaleType = o.ScaleType.Name
|
||||
end
|
||||
local strokes = {}
|
||||
local children = {}
|
||||
for j, ch in o:GetChildren() do
|
||||
if ch:IsA("UICorner") then
|
||||
d.UICorner = ud(ch.CornerRadius)
|
||||
elseif ch:IsA("UIStroke") then
|
||||
local s: { [string]: any } = {
|
||||
Color = c3(ch.Color),
|
||||
Thickness = ch.Thickness,
|
||||
Transparency = ch.Transparency,
|
||||
ApplyStrokeMode = ch.ApplyStrokeMode.Name,
|
||||
Enabled = ch.Enabled,
|
||||
}
|
||||
local g = ch:FindFirstChildOfClass("UIGradient")
|
||||
if g then
|
||||
s.UIGradient = gradient(g)
|
||||
end
|
||||
table.insert(strokes, s)
|
||||
elseif ch:IsA("UIGradient") then
|
||||
if ch.Enabled then
|
||||
d.UIGradient = gradient(ch)
|
||||
end
|
||||
elseif ch:IsA("UIPadding") then
|
||||
d.UIPadding = {
|
||||
Left = ud(ch.PaddingLeft),
|
||||
Right = ud(ch.PaddingRight),
|
||||
Top = ud(ch.PaddingTop),
|
||||
Bottom = ud(ch.PaddingBottom),
|
||||
}
|
||||
elseif ch:IsA("UIListLayout") then
|
||||
d.UIListLayout = {
|
||||
FillDirection = ch.FillDirection.Name,
|
||||
Padding = ud(ch.Padding),
|
||||
HorizontalAlignment = ch.HorizontalAlignment.Name,
|
||||
VerticalAlignment = ch.VerticalAlignment.Name,
|
||||
SortOrder = ch.SortOrder.Name,
|
||||
}
|
||||
elseif ch:IsA("UIScale") then
|
||||
d.UIScale = ch.Scale
|
||||
elseif ch:IsA("UIAspectRatioConstraint") then
|
||||
d.UIAspectRatio = ch.AspectRatio
|
||||
elseif ch:IsA("UITextSizeConstraint") then
|
||||
d.MaxTextSize = ch.MaxTextSize
|
||||
else
|
||||
local cd = dump(ch, j)
|
||||
if cd then
|
||||
table.insert(children, cd)
|
||||
end
|
||||
end
|
||||
end
|
||||
if #strokes > 0 then
|
||||
d.UIStrokes = strokes
|
||||
end
|
||||
d.children = children
|
||||
return d
|
||||
end
|
||||
|
||||
local Recipes = require(game:GetService("ReplicatedStorage").Shared.Recipes)
|
||||
|
||||
-- kitchen = { menu, step, frac } 이면 요리 창을 열어 그 단계까지 진행합니다(step = "done"이면 완성 화면).
|
||||
local PHONE = { w = 750, h = 332, inset = 58, touch = true }
|
||||
local PC = { w = 1366, h = 710, inset = 58, touch = false }
|
||||
local function shot(name: string, dev: { [string]: any }, attrs: { [string]: any }, extra: { [string]: any }?)
|
||||
local t = { name = name, w = dev.w, h = dev.h, inset = dev.inset, touch = dev.touch, attrs = attrs }
|
||||
for k, v in extra or {} do
|
||||
t[k] = v
|
||||
end
|
||||
return t
|
||||
end
|
||||
-- 상태 묶음(NETWORK.md 플레이어 속성). 갈래 레벨은 Levels 글자로
|
||||
local function shopState(levels: string, seats: number, tables: number, extra: { [string]: any }): { [string]: any }
|
||||
local t: { [string]: any } = { Levels = levels, Seats = seats, Tables = tables }
|
||||
local stage = 1 + (tonumber(string.match(levels, "Stage=(%d)")) or 0)
|
||||
t.Stage = stage
|
||||
for k, v in extra do
|
||||
t[k] = v
|
||||
end
|
||||
return t
|
||||
end
|
||||
local EARLY = "Stage=0,Menu=1,Price=0,Speed=1,Stove=0,Tray=0,Staff=0"
|
||||
local MID = "Stage=1,Menu=2,Price=2,Speed=3,Stove=1,Tray=1,Staff=1"
|
||||
local LATE = "Stage=2,Menu=4,Price=4,Speed=5,Stove=3,Tray=2,Staff=1"
|
||||
local LAYOUT = '{"stove":{"x":0,"z":-26,"r":0},"tables":[{"x":-9,"z":-10,"f":1},{"x":9,"z":-10,"f":1}],'
|
||||
.. '"chairs":[{"t":1,"s":1},{"t":1,"s":3},{"t":2,"s":1}],"decor":[{"k":"Plant","x":-31,"z":-35,"f":1,"r":0}]}'
|
||||
local SHOTS = {
|
||||
shot(
|
||||
"phone_main",
|
||||
PHONE,
|
||||
shopState(EARLY, 2, 1, { Money = 85, Carry = 1, Hand = "Gimbap", Tut = 0 }),
|
||||
{ toast = true }
|
||||
),
|
||||
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_deco", PHONE, shopState(MID, 3, 2, { Money = 120, Layout = LAYOUT }), { deco = true }),
|
||||
shot("pc_deco", PC, shopState(MID, 3, 2, { Money = 120, Layout = LAYOUT }), { deco = true }),
|
||||
shot("pc_tut", PC, shopState("", 1, 1, { Money = 15, Tut = 3 })),
|
||||
shot(
|
||||
"phone_shop_staff",
|
||||
PHONE,
|
||||
shopState(MID, 3, 2, { Money = 600, Staff = "Cook=1,Server=0,Promoter=0", Wage = 18 }),
|
||||
{ open = "shop", tab = "staff" }
|
||||
),
|
||||
shot(
|
||||
"phone_shop_mine",
|
||||
PHONE,
|
||||
shopState(MID, 3, 2, { Money = 600, ShopName = "떡볶이 천국", Design = "Mint", RainbowOwned = false }),
|
||||
{ open = "shop", tab = "mine" }
|
||||
),
|
||||
shot("phone_promote", PHONE, shopState(EARLY, 2, 1, { Money = 150 }), { open = "promote" }),
|
||||
shot("phone_settings", PHONE, shopState(EARLY, 2, 1, { Money = 150 }), { open = "settings" }),
|
||||
shot(
|
||||
"phone_kitchen_menu",
|
||||
PHONE,
|
||||
shopState(EARLY, 2, 1, { Money = 300, Orders = "Tteokbokki=1,Gimbap=2", Tut = 1 }),
|
||||
{ kitchen = { menu = nil } }
|
||||
),
|
||||
shot(
|
||||
"phone_kitchen_tteok",
|
||||
PHONE,
|
||||
shopState(EARLY, 2, 1, { Money = 300, Orders = "Tteokbokki=1" }),
|
||||
{ kitchen = { menu = "Tteokbokki", step = 3, frac = 0.5 } }
|
||||
),
|
||||
shot("pc_main", PC, shopState(EARLY, 2, 1, { Money = 1234, Carry = 1, Hand = "Tteokbokki" }), { toast = true }),
|
||||
shot("pc_buyable", PC, shopState(EARLY, 2, 1, { Money = 160, Carry = 0, Tut = 0 })),
|
||||
shot("pc_shop", PC, shopState(MID, 4, 2, { Money = 760, Double = true }), { open = "shop" }),
|
||||
shot("pc_shop_staff_locked", PC, shopState(EARLY, 2, 1, { Money = 760 }), { open = "shop", tab = "staff" }),
|
||||
shot(
|
||||
"pc_shop_staff_strike",
|
||||
PC,
|
||||
shopState(LATE, 10, 4, { Money = 0, Staff = "Cook=2,Server=1,Promoter=1", Strike = true, Wage = 120 }),
|
||||
{ open = "shop", tab = "staff" }
|
||||
),
|
||||
shot(
|
||||
"pc_shop_mine",
|
||||
PC,
|
||||
shopState(
|
||||
LATE,
|
||||
10,
|
||||
4,
|
||||
{ Money = 760, Design = "Candy", DesignsOwned = "Candy", RainbowOwned = true, Rainbow = true }
|
||||
),
|
||||
{ open = "shop", tab = "mine" }
|
||||
),
|
||||
shot("pc_settings", PC, shopState(MID, 4, 2, { Money = 760, Dev = true }), { open = "settings" }),
|
||||
shot(
|
||||
"pc_kitchen_menu",
|
||||
PC,
|
||||
shopState(MID, 4, 2, { Money = 300, Orders = "Gimbap=1,Sundae=2,Eomuk=1" }),
|
||||
{ kitchen = { menu = nil } }
|
||||
),
|
||||
shot(
|
||||
"pc_kitchen_gimbap",
|
||||
PC,
|
||||
shopState(MID, 4, 2, { Money = 300, Orders = "Gimbap=1" }),
|
||||
{ kitchen = { menu = "Gimbap", step = 2, frac = 0.6 } }
|
||||
),
|
||||
shot(
|
||||
"pc_kitchen_sundae",
|
||||
PC,
|
||||
shopState(MID, 4, 2, { Money = 300, Orders = "Sundae=1" }),
|
||||
{ kitchen = { menu = "Sundae", step = 2, frac = 0.7 } }
|
||||
),
|
||||
shot(
|
||||
"pc_kitchen_eomuk",
|
||||
PC,
|
||||
shopState(LATE, 4, 2, { Money = 300, Orders = "Eomuk=1" }),
|
||||
{ kitchen = { menu = "Eomuk", step = 2, frac = 0.4 } }
|
||||
),
|
||||
shot(
|
||||
"pc_kitchen_twigim",
|
||||
PC,
|
||||
shopState(LATE, 4, 2, { Money = 300, Orders = "Twigim=1" }),
|
||||
{ kitchen = { menu = "Twigim", step = 3, frac = 0.5 } }
|
||||
),
|
||||
shot(
|
||||
"pc_kitchen_done",
|
||||
PC,
|
||||
shopState(EARLY, 2, 1, { Money = 300, Orders = "Tteokbokki=1" }),
|
||||
{ kitchen = { menu = "Tteokbokki", step = "done" } }
|
||||
),
|
||||
shot(
|
||||
"tablet_ipad",
|
||||
{ w = 1024, h = 710, inset = 58, touch = true },
|
||||
shopState(LATE, 10, 4, { Money = 98765, Carry = 2, Hand = "Eomuk,Sundae" })
|
||||
),
|
||||
}
|
||||
|
||||
local shots = {}
|
||||
-- 한 번에 다 그리면 5분 제한을 넘을 수 있어서, ONLY에 이름을 넣으면 그 장면만 그립니다(tools/preview.sh가 나눠서 부름).
|
||||
local ONLY: { string }? = nil
|
||||
for _, s in SHOTS do
|
||||
if ONLY and not table.find(ONLY, s.name) then
|
||||
continue
|
||||
end
|
||||
local state = Instance.new("Folder")
|
||||
state:SetAttribute("Lang", "ko")
|
||||
state:SetAttribute("Ready", true)
|
||||
for k, v in s.attrs do
|
||||
state:SetAttribute(k, v)
|
||||
end
|
||||
local holder = Instance.new("Folder")
|
||||
local hud = Hud.build(holder, state, function() end)
|
||||
hud.setLayout(Vector2.new(s.w, s.h), s.touch)
|
||||
if s.attrs.Tut == nil then
|
||||
state:SetAttribute("Tut", 0)
|
||||
end
|
||||
if s.toast then
|
||||
hud.notify("upgraded", { track = "Speed", level = 2 })
|
||||
end
|
||||
if s.open then
|
||||
hud.open(s.open, s.tab)
|
||||
end
|
||||
local k = s.kitchen
|
||||
if k then
|
||||
hud.open("kitchen")
|
||||
if k.menu then
|
||||
hud.kitchen.choose(k.menu)
|
||||
local r = Recipes.LIST[k.menu]
|
||||
local cook = hud.kitchen.flow().cook
|
||||
for i, st in r.steps do
|
||||
local need = Recipes.need(st, cook)
|
||||
if k.step == "done" or i < k.step then
|
||||
hud.kitchen.input(st.kind, need)
|
||||
elseif i == k.step then
|
||||
hud.kitchen.input(st.kind, need * k.frac)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
hud.refresh()
|
||||
local gui = hud.gui
|
||||
local deco = nil
|
||||
if s.deco then
|
||||
-- 꾸미기 모드: 화면 UI는 숨기고 꾸미기 화면만
|
||||
local plotStub = Instance.new("Model")
|
||||
plotStub:SetAttribute("Origin", CFrame.new())
|
||||
deco = Decorate.build(holder, state, plotStub, function() end)
|
||||
deco.setLayout(hud.layout())
|
||||
deco.open()
|
||||
gui = deco.gui
|
||||
end
|
||||
task.wait(0.3)
|
||||
local zones = Layout.touchZones(s.w, s.h)
|
||||
table.insert(shots, {
|
||||
name = s.name,
|
||||
width = s.w,
|
||||
height = s.h,
|
||||
inset = s.inset,
|
||||
touch = s.touch,
|
||||
zones = zones,
|
||||
gui = dump(gui, 1),
|
||||
})
|
||||
if deco then
|
||||
deco.destroy()
|
||||
end
|
||||
hud.destroy()
|
||||
end
|
||||
|
||||
local images = {}
|
||||
images[Icons.ASSET:match("%d+")] = "art/ui_icons.png"
|
||||
images[Icons.KITCHEN_ASSET:match("%d+")] = "art/kitchen.png"
|
||||
-- 결과가 커서(4MB 넘음) 바이너리 출력으로 돌려줍니다(tools/preview.sh가 --out 파일로 받음).
|
||||
local json = HttpService:JSONEncode({ shots = shots, images = images })
|
||||
return { BinaryOutput = buffer.fromstring(json), ReturnValues = { #shots } }
|
||||
112
bunsik-tycoon/tests/cloud/dump_scene.luau
Normal file
@@ -0,0 +1,112 @@
|
||||
-- 미리보기용 장면 덤프: 맵과 가게 두 곳(1단계 중간, 2단계 전부 산 상태)을 짓고 모든 파트를 JSON으로 돌려줍니다.
|
||||
-- python3 tools/cloud.py run tests/cloud/dump_scene.luau --version N --out .cache/scene.json
|
||||
-- python3 tools/render.py .cache/scene.json
|
||||
local HttpService = game:GetService("HttpService")
|
||||
local Players = game:GetService("Players")
|
||||
local ServerScriptService = game:GetService("ServerScriptService")
|
||||
local Server = ServerScriptService.Server
|
||||
|
||||
local World = require(Server.World)
|
||||
local Npc = require(Server.Npc)
|
||||
local PlotController = require(Server.PlotController)
|
||||
local PlotBuilder = require(Server.PlotBuilder)
|
||||
local Data = require(Server.Data)
|
||||
local Floor = require(game:GetService("ReplicatedStorage").Shared.Floor)
|
||||
|
||||
local slots = World.build()
|
||||
Npc.preload()
|
||||
|
||||
-- 예전 구매 수(bought)로 크기를 정하고, 단계(stage)·디자인을 맞춘 가게를 짓습니다.
|
||||
local function shop(slot, bought: number, stage: number, design: string, withChar: boolean, extra: number?)
|
||||
local data: any = table.clone(Data.TEMPLATE)
|
||||
data.PurchaseIdCache = {}
|
||||
data.Bought = bought
|
||||
data.TutorialDone = true
|
||||
Data.migrate(data, 1)
|
||||
data.Levels.Stage = stage - 1
|
||||
data.Levels.Staff = 1
|
||||
data.Staff = { Cook = 1, Server = 1, Promoter = 1 }
|
||||
data.Design = design
|
||||
data.Money = 1e9
|
||||
local owner = Instance.new("Folder")
|
||||
owner.Parent = ServerScriptService
|
||||
local char: Model? = nil
|
||||
local c = PlotController.new(slot, owner, {
|
||||
userId = slot.index,
|
||||
displayName = "Player" .. slot.index,
|
||||
data = data,
|
||||
now = 0,
|
||||
getCharacter = function()
|
||||
return char
|
||||
end,
|
||||
})
|
||||
c:setDesignOwned(design, true)
|
||||
c:setDesign(design)
|
||||
for _ = 1, extra or 0 do
|
||||
c:buyTable()
|
||||
c:buySeat(nil)
|
||||
end
|
||||
c:buyDecor("Plant")
|
||||
c:buyDecor("Balloons")
|
||||
c:buyDecor("Teddy")
|
||||
if withChar then
|
||||
char = Players:CreateHumanoidModelFromDescription(Instance.new("HumanoidDescription"), Enum.HumanoidRigType.R15)
|
||||
local cm = char :: Model
|
||||
cm.Parent = workspace
|
||||
local root = cm:FindFirstChild("HumanoidRootPart") :: BasePart
|
||||
root.Anchored = true
|
||||
local pos = PlotBuilder.stallPoint(slot.refs, Floor.STOVE_FRONT)
|
||||
local look = PlotBuilder.stallPoint(slot.refs, { x = 0, z = 12 })
|
||||
cm:PivotTo(CFrame.lookAt(pos + Vector3.new(0, 3, 0), look + Vector3.new(0, 3, 0)))
|
||||
end
|
||||
-- 손님을 채우고 몇 명은 먹는 중으로
|
||||
local t = 0
|
||||
for _ = 1, 300 do
|
||||
t += 0.1
|
||||
c:update(t)
|
||||
end
|
||||
if withChar then
|
||||
c.shop.counter = {}
|
||||
c:cook()
|
||||
end
|
||||
return c
|
||||
end
|
||||
|
||||
local mode = "all"
|
||||
shop(slots[1], 6, 1, "Basic", true, 1)
|
||||
shop(slots[2], 20, 2, "Candy", false, 2)
|
||||
shop(slots[3], 20, 3, "Hanok", false, 6)
|
||||
shop(slots[4], 14, 2, "Brick", false, 1)
|
||||
shop(slots[5], 14, 2, "Mint", false, 1)
|
||||
shop(slots[6], 20, 3, "Basic", false, 6)
|
||||
print("mode", mode)
|
||||
task.wait(0.5)
|
||||
|
||||
local parts = {}
|
||||
for _, d in workspace:GetDescendants() do
|
||||
if d:IsA("BasePart") and d.Transparency < 0.95 then
|
||||
local shape = "Block"
|
||||
if d:IsA("Part") then
|
||||
shape = d.Shape.Name
|
||||
elseif d:IsA("WedgePart") then
|
||||
shape = "Wedge"
|
||||
end
|
||||
local cf = d.CFrame
|
||||
local x, y, z, r00, r01, r02, r10, r11, r12, r20, r21, r22 = cf:GetComponents()
|
||||
local col = d.Color
|
||||
table.insert(parts, {
|
||||
s = shape,
|
||||
c = { x, y, z, r00, r01, r02, r10, r11, r12, r20, r21, r22 },
|
||||
z = { d.Size.X, d.Size.Y, d.Size.Z },
|
||||
k = { math.floor(col.R * 255), math.floor(col.G * 255), math.floor(col.B * 255) },
|
||||
t = d.Transparency,
|
||||
m = d.Material.Name,
|
||||
})
|
||||
end
|
||||
end
|
||||
print("parts", #parts)
|
||||
local json = HttpService:JSONEncode(parts)
|
||||
return {
|
||||
BinaryOutput = buffer.fromstring(json),
|
||||
ReturnValues = { #parts },
|
||||
}
|
||||
522
bunsik-tycoon/tests/cloud/integration.luau
Normal file
@@ -0,0 +1,522 @@
|
||||
-- 로블록스 서버(Open Cloud Luau Execution)에서 돌리는 화면 UI·클라이언트 모듈 통합 테스트(서버 로직은 server.luau).
|
||||
-- python3 tools/cloud.py run tests/cloud/integration.luau --version <저장 버전>
|
||||
-- 이 환경에서는 플레이어가 없고 물리가 돌지 않으며 Script가 자동 실행되지 않으므로,
|
||||
-- 모듈을 직접 불러 가짜 플레이어(Folder)와 가상 시계로 가게를 돌립니다.
|
||||
|
||||
local Players = game:GetService("Players")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local ServerScriptService = game:GetService("ServerScriptService")
|
||||
local StarterPlayer = game:GetService("StarterPlayer")
|
||||
|
||||
local Server = ServerScriptService.Server
|
||||
local failures = {}
|
||||
local count = 0
|
||||
local function check(cond: any, msg: string)
|
||||
count += 1
|
||||
if not cond then
|
||||
table.insert(failures, msg)
|
||||
print("FAIL " .. msg)
|
||||
end
|
||||
end
|
||||
local function eq(a: any, b: any, msg: string)
|
||||
check(a == b, `{msg} (기대 {tostring(b)}, 실제 {tostring(a)})`)
|
||||
end
|
||||
local function section(name: string)
|
||||
print("== " .. name)
|
||||
end
|
||||
|
||||
local Economy = require(ReplicatedStorage.Shared.Economy)
|
||||
local Icons = require(ReplicatedStorage.Shared.Icons)
|
||||
local Locale = require(ReplicatedStorage.Shared.Locale)
|
||||
local Recipes = require(ReplicatedStorage.Shared.Recipes)
|
||||
|
||||
section("맵·부지 글자·손님 버튼(클라이언트 모듈)")
|
||||
local World = require(Server.World)
|
||||
local slots = World.build()
|
||||
local Neighbor = require(Server.Neighbor)
|
||||
local Plots = require(StarterPlayer.StarterPlayerScripts.Client.Plots)
|
||||
local viewer = Instance.new("Folder")
|
||||
viewer:SetAttribute("Lang", "en")
|
||||
viewer:SetAttribute("KickCredits", 0)
|
||||
local nb2 = Neighbor.open(slots[6], 0)
|
||||
eq(Plots.nameText(slots[4].model, "en"), "Empty lot", "빈 자리 이름판")
|
||||
local detach = Plots.attach(slots[6].model, viewer, 999, function() end)
|
||||
local visitPrompt = slots[6].model.Base.VisitPoint:FindFirstChild("VisitPrompt") :: ProximityPrompt
|
||||
check(visitPrompt ~= nil and visitPrompt.Enabled, "이웃 가게 입구에 손님 버튼")
|
||||
eq(visitPrompt.ActionText, "Eat here as a customer", "손님 버튼 글자(영어)")
|
||||
local kickPrompt = slots[6].model.Base.VisitPoint:FindFirstChild("KickPrompt") :: ProximityPrompt
|
||||
check(kickPrompt ~= nil and kickPrompt.Enabled, "이웃 가게 입구에 쫓아내기 버튼")
|
||||
check(kickPrompt.KeyboardKeyCode ~= visitPrompt.KeyboardKeyCode, "두 버튼은 다른 키")
|
||||
local boardLabel = slots[6].model.Base.NameBoard:FindFirstChildOfClass("SurfaceGui"):FindFirstChildOfClass("TextLabel")
|
||||
check(string.find(boardLabel.Text, "Twigim King") ~= nil, `이름판 영어 ({boardLabel.Text})`)
|
||||
viewer:SetAttribute("Lang", "ja")
|
||||
check(string.find(boardLabel.Text, "天ぷら") ~= nil, `언어 바꾸면 이름판도 바뀜 ({boardLabel.Text})`)
|
||||
check(string.find(Plots.menuText(slots[6].model, "ko"), "떡볶이") ~= nil, "메뉴판(부지 속성 Menus)")
|
||||
-- 가게 이름·무지개: 이름판과 지붕·천막 간판(ShopNameLabel)에 보임
|
||||
slots[6].model:SetAttribute("ShopName", "Yummy Land")
|
||||
check(string.find(boardLabel.Text, "Yummy Land") ~= nil, `가게 이름이 이름판에 ({boardLabel.Text})`)
|
||||
local valance = slots[6].model.Base.Stall.Valance:FindFirstChild("ShopNameLabel", true) :: TextLabel
|
||||
eq(valance and valance.Text, "Yummy Land", "천막 간판에 가게 이름")
|
||||
slots[6].model:SetAttribute("Rainbow", true)
|
||||
task.wait(0.2)
|
||||
check(boardLabel:FindFirstChild("RainbowGradient") ~= nil, "무지개 이름(그러데이션)")
|
||||
slots[6].model:SetAttribute("Rainbow", false)
|
||||
task.wait(0.2)
|
||||
eq(boardLabel:FindFirstChild("RainbowGradient"), nil, "무지개 끄면 사라짐")
|
||||
slots[6].model:SetAttribute("ShieldUntil", workspace:GetServerTimeNow() + 60)
|
||||
task.wait(0.2)
|
||||
check(not kickPrompt.Enabled, "보호 중인 가게엔 쫓아내기 버튼 꺼짐")
|
||||
Neighbor.close(nb2)
|
||||
check(not visitPrompt.Enabled, "닫힌 가게엔 손님 버튼 없음")
|
||||
slots[6].model:SetAttribute("OwnerId", 999)
|
||||
check(not visitPrompt.Enabled and not kickPrompt.Enabled, "내 가게엔 버튼 없음")
|
||||
slots[6].model:SetAttribute("OwnerId", nil)
|
||||
detach()
|
||||
|
||||
section("마우스 회전 판단")
|
||||
local MouseLook = require(StarterPlayer.StarterPlayerScripts.Client.MouseLook)
|
||||
check(MouseLook.shouldLock(true, true, false, false), "켜짐 + 마우스 = 고정")
|
||||
check(not MouseLook.shouldLock(false, true, false, false), "설정 끄면 안 고정")
|
||||
check(not MouseLook.shouldLock(true, false, false, false), "마우스 없으면(모바일) 안 고정")
|
||||
check(not MouseLook.shouldLock(true, true, true, false), "Ctrl 누르면 커서 풀림")
|
||||
check(not MouseLook.shouldLock(true, true, false, true), "창 열리면 커서 풀림")
|
||||
|
||||
section("화면 UI(서버에서 생성)")
|
||||
local Hud = require(StarterPlayer.StarterPlayerScripts.Client.Hud)
|
||||
local Theme = require(StarterPlayer.StarterPlayerScripts.Client.Theme)
|
||||
local state = Instance.new("Folder")
|
||||
state:SetAttribute("Lang", "ko")
|
||||
state:SetAttribute("Money", 5)
|
||||
state:SetAttribute("Levels", "")
|
||||
state:SetAttribute("Stage", 1)
|
||||
state:SetAttribute("Seats", 1)
|
||||
state:SetAttribute("Tables", 1)
|
||||
state:SetAttribute("Staff", "")
|
||||
state:SetAttribute("Tut", 3)
|
||||
local sent = {}
|
||||
local holder = Instance.new("Folder")
|
||||
local hud = Hud.build(holder, state, function(kind, arg)
|
||||
table.insert(sent, { kind, arg })
|
||||
end)
|
||||
local root = hud.gui:FindFirstChild("Root") :: Frame
|
||||
local function label(o: Instance?): string?
|
||||
local t = o and o:FindFirstChild("Label", true) :: TextLabel?
|
||||
return t and t.Text
|
||||
end
|
||||
local moneyText = root:FindFirstChild("Money"):FindFirstChild("Text", true) :: TextLabel
|
||||
eq(moneyText.Text, "5", "돈 표시")
|
||||
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)
|
||||
check((listButton:FindFirstChild("Badge") :: Frame).Visible, "살 수 있으면 상점 버튼에 ! 배지")
|
||||
eq(
|
||||
(root:FindFirstChild("Gain") :: TextLabel?) and (root:FindFirstChild("Gain") :: TextLabel).Text,
|
||||
"+10",
|
||||
"늘어난 돈"
|
||||
)
|
||||
for _, name in { "Promote", "Rush", "Double", "Boost", "Settings" } do
|
||||
check(root:FindFirstChild(name) ~= nil, `버튼 {name}`)
|
||||
end
|
||||
state:SetAttribute("Lang", "en")
|
||||
eq(label(decoButton), "Decorate", "영어 가게 꾸미기 버튼")
|
||||
state:SetAttribute("Lang", "ko")
|
||||
state:SetAttribute("Tut", 0)
|
||||
check(
|
||||
not hintFrame.Visible and not (root:FindFirstChild("Pointer") :: ImageLabel).Visible,
|
||||
"튜토리얼 끝나면 아래 말풍선 없음"
|
||||
)
|
||||
|
||||
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", "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)
|
||||
check(card ~= nil, `갈래 카드 {id}`)
|
||||
local nm = card and card:FindFirstChild("Name", true) :: TextLabel?
|
||||
check(nm and nm.Text ~= "" and not string.find(nm.Text, "track_"), `갈래 이름 {id} ({nm and nm.Text})`)
|
||||
end
|
||||
local tray = page("upgrade"):FindFirstChild("Track_Tray", true) :: Frame
|
||||
check((tray:FindFirstChild("Lock", true) :: ImageLabel).Visible, "쟁반은 포장마차에서 잠김")
|
||||
check(root:FindFirstChild("DecorPanel") == nil, "가게 꾸미기 창 없음(바로 꾸미기 모드)")
|
||||
hud.open("shop", "staff")
|
||||
check((page("staff"):FindFirstChild("Locked", true) :: Frame).Visible, "알바생 기능 전에는 잠김")
|
||||
state:SetAttribute("Levels", "Staff=1")
|
||||
state:SetAttribute("Staff", "Cook=1,Server=0,Promoter=0")
|
||||
state:SetAttribute("Strike", true)
|
||||
check(not (page("staff"):FindFirstChild("Locked", true) :: Frame).Visible, "알바생 기능을 사면 열림")
|
||||
for _, r in Economy.ROLES do
|
||||
check(page("staff"):FindFirstChild("Role_" .. r.id, true) ~= nil, `알바 카드 {r.id}`)
|
||||
end
|
||||
hud.open("shop", "mine")
|
||||
check(page("mine"):FindFirstChild("NameBox", true) ~= nil, "가게 이름 입력칸")
|
||||
for n = 1, #Economy.NAME_COLORS do
|
||||
check(page("mine"):FindFirstChild("Color" .. n, true) ~= nil, `이름 색 {n}`)
|
||||
end
|
||||
local rainbowSw = page("mine"):FindFirstChild("Rainbow", true)
|
||||
check(rainbowSw ~= nil, "무지개 칸")
|
||||
state:SetAttribute("NameColor", 4)
|
||||
check((page("mine"):FindFirstChild("Color4", true) :: Frame):FindFirstChild("Done").Visible, "고른 색에 체크")
|
||||
check(
|
||||
not (page("mine"):FindFirstChild("Color3", true) :: Frame):FindFirstChild("Done").Visible,
|
||||
"안 고른 색은 체크 없음"
|
||||
)
|
||||
for _, d in Economy.DESIGNS do
|
||||
check(page("mine"):FindFirstChild("Design_" .. d.id, true) ~= nil, `디자인 {d.id}`)
|
||||
end
|
||||
hud.open("settings")
|
||||
local settingsPanel = root:FindFirstChild("SettingsPanel") :: Frame
|
||||
check(settingsPanel.Visible and not panel.Visible, "창은 하나만 열림")
|
||||
hud.open(nil)
|
||||
check(not hud.menuOpen(), "창 닫기")
|
||||
|
||||
section("알림 글자(모든 알림 키, 4개 언어)")
|
||||
local Info = require(StarterPlayer.StarterPlayerScripts.Client.Info)
|
||||
local SAMPLES = {
|
||||
upgraded = { track = "Speed", level = 2 },
|
||||
newMenu = { menu = "Gimbap" },
|
||||
expanded = {},
|
||||
floor2 = {},
|
||||
seatAdded = {},
|
||||
tableAdded = {},
|
||||
decorAdded = { kind = "Teddy" },
|
||||
noSpace = {},
|
||||
seatMax = {},
|
||||
tableMax = {},
|
||||
tableFull = {},
|
||||
needStage = {},
|
||||
placeFail = { why = "blocked" },
|
||||
hired = { role = "Cook" },
|
||||
fired = { role = "Server" },
|
||||
staffLocked = {},
|
||||
staffMax = {},
|
||||
strike = {},
|
||||
strikeOver = {},
|
||||
renamed = {},
|
||||
nameRejected = {},
|
||||
designSet = { design = "Hanok" },
|
||||
designLocked = {},
|
||||
promoted = { n = 2 },
|
||||
promoteNone = {},
|
||||
promoteFull = {},
|
||||
promoteWait = { sec = 30 },
|
||||
adUnavailable = {},
|
||||
kicked = { n = 3 },
|
||||
kickedBy = { name = "Mina" },
|
||||
shielded = {},
|
||||
kickOwn = {},
|
||||
rushOn = { min = 10 },
|
||||
notEnough = { need = "100" },
|
||||
doubleOwned = {},
|
||||
removed = { thing = "chair", money = "45" },
|
||||
removeFail = { why = "hasChairs" },
|
||||
devFreeOn = {},
|
||||
devFreeOff = {},
|
||||
}
|
||||
for _, lang in { "ko", "en", "ja", "zh" } do
|
||||
for key, args in SAMPLES do
|
||||
local text = Info.toast(lang, key, args)
|
||||
check(text ~= key and not string.find(text, "{") and text ~= "", `{lang} 알림 {key}: {text}`)
|
||||
end
|
||||
end
|
||||
state:SetAttribute("Lang", "en")
|
||||
hud.notify("upgraded", { track = "Speed", level = 2 })
|
||||
local toastText = root.Toasts:FindFirstChild("Toast"):FindFirstChild("Text") :: TextLabel
|
||||
check(string.find(toastText.Text, "Customer Speed") ~= nil, `알림에 갈래 이름(내 언어) ({toastText.Text})`)
|
||||
for _ = 1, 5 do
|
||||
hud.notify("seatAdded")
|
||||
end
|
||||
local toastCount = 0
|
||||
for _, ch in root.Toasts:GetChildren() do
|
||||
if ch:IsA("Frame") then
|
||||
toastCount += 1
|
||||
end
|
||||
end
|
||||
check(toastCount <= 3, `알림은 3개까지만 쌓임 ({toastCount})`)
|
||||
|
||||
section("휴대폰·PC 배치")
|
||||
local doubleBtn = root:FindFirstChild("Double") :: TextButton
|
||||
hud.setLayout(Vector2.new(750, 332), true)
|
||||
local lay = hud.layout()
|
||||
local scaleObj = root:FindFirstChildOfClass("UIScale") :: UIScale
|
||||
check(
|
||||
root.Size.X.Offset * scaleObj.Scale - 750 >= -1e-3 and root.Size.X.Offset * scaleObj.Scale - 750 < scaleObj.Scale,
|
||||
"휴대폰: 루트 너비 = 화면"
|
||||
)
|
||||
check(lay.double.y + lay.double.h < lay.height / 3, "휴대폰: 결제 버튼은 조이스틱 자리 위")
|
||||
check(not (settingsPanel:FindFirstChild("MouseLook") :: TextButton).Visible, "휴대폰: 마우스 회전 줄 숨김")
|
||||
eq(doubleBtn.Size.Y.Offset, lay.double.h, "휴대폰: 2배 수익 버튼 크기")
|
||||
hud.setLayout(Vector2.new(1366, 710), false)
|
||||
check((settingsPanel:FindFirstChild("MouseLook") :: TextButton).Visible, "PC: 마우스 회전 줄 보임")
|
||||
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(), "처음엔 닫힘")
|
||||
local items = droot:FindFirstChild("Items") :: ScrollingFrame
|
||||
check(items ~= nil, "아래 물건 줄")
|
||||
for _, it in Decorate.ITEMS do
|
||||
check(items:FindFirstChild("Item_" .. (it.k or it.kind)) ~= nil, `물건 줄 {it.k or it.kind}`)
|
||||
end
|
||||
deco.open()
|
||||
check(deco.isOpen() and items.Visible, "꾸미기 모드: 물건 줄 보임")
|
||||
check((droot:FindFirstChild("Move") :: GuiObject).Visible, "이동 버튼")
|
||||
check((droot:FindFirstChild("Delete") :: GuiObject).Visible, "삭제 버튼")
|
||||
check(not (droot:FindFirstChild("Place") :: GuiObject).Visible, "고를 때는 배치 버튼 숨김")
|
||||
local itemTable = items:FindFirstChild("Item_table") :: TextButton
|
||||
eq((itemTable:FindFirstChild("Price") :: TextLabel).Text, Locale.number(Economy.tableCost(1)), "테이블 값")
|
||||
local infoT = (droot:FindFirstChild("Info") :: Frame):FindFirstChild("Text") :: TextLabel
|
||||
check(string.find(infoT.Text, "이동") ~= nil, `안내 글 ({infoT.Text})`)
|
||||
deco.close()
|
||||
check(not deco.isOpen(), "나가기")
|
||||
deco.destroy()
|
||||
|
||||
section("요리 창(메뉴 고르기 → 조리 과정 → 완성)")
|
||||
local kstate = Instance.new("Folder")
|
||||
kstate:SetAttribute("Lang", "ko")
|
||||
kstate:SetAttribute("Money", 0)
|
||||
kstate:SetAttribute("Levels", "Menu=2") -- 떡볶이·김밥·순대 해금
|
||||
kstate:SetAttribute("Tut", 1)
|
||||
kstate:SetAttribute("Orders", "Gimbap=2")
|
||||
local ksent = {}
|
||||
local khud = Hud.build(Instance.new("Folder"), kstate, function(kind, arg)
|
||||
table.insert(ksent, { kind, arg })
|
||||
end)
|
||||
local kroot = khud.gui:FindFirstChild("Root") :: Frame
|
||||
local kitchen = khud.kitchen
|
||||
local kframe = kroot:FindFirstChild("Kitchen") :: Frame
|
||||
check(not kframe.Visible, "요리 창은 처음엔 닫힘")
|
||||
khud.open("kitchen")
|
||||
check(kframe.Visible and kitchen.isOpen() and khud.menuOpen(), "요리 창 열림(커서 풀림)")
|
||||
check((kroot:FindFirstChild("Dim") :: TextButton).Visible, "요리 창 뒤 어둡게")
|
||||
local menuPage = kframe:FindFirstChild("MenuPage", true) :: Frame
|
||||
check(menuPage.Visible, "처음엔 메뉴 고르기")
|
||||
local function menuCard(m: string): Frame
|
||||
return menuPage:FindFirstChild("Menu_" .. m, true) :: Frame
|
||||
end
|
||||
for _, m in Economy.MENU_ORDER do
|
||||
check(menuCard(m) ~= nil, `메뉴 카드 {m}`)
|
||||
end
|
||||
check((menuCard("Gimbap"):FindFirstChild("Orders", true) :: Frame).Visible, "주문 있는 김밥에 손님 표시")
|
||||
eq((menuCard("Gimbap"):FindFirstChild("Orders", true):FindFirstChild("Text") :: TextLabel).Text, "x2", "주문 수 2")
|
||||
check(
|
||||
not (menuCard("Tteokbokki"):FindFirstChild("Orders", true) :: Frame).Visible,
|
||||
"주문 없는 떡볶이는 표시 없음"
|
||||
)
|
||||
check((menuCard("Eomuk"):FindFirstChild("Lock", true) :: ImageLabel).Visible, "안 산 어묵은 자물쇠")
|
||||
check(not (menuCard("Sundae"):FindFirstChild("Lock", true) :: ImageLabel).Visible, "산 순대는 자물쇠 없음")
|
||||
check(
|
||||
(menuPage:FindFirstChild("Pointer") or menuCard("Gimbap"):FindFirstChild("Pointer", true)) ~= nil,
|
||||
"튜토리얼 손가락"
|
||||
)
|
||||
eq(kitchen.choose("Tteokbokki"), false, "주문 없는 메뉴는 못 고름")
|
||||
eq(kitchen.choose("Eomuk"), false, "안 산 메뉴는 못 고름")
|
||||
eq(kitchen.choose("Gimbap"), true, "김밥 고름")
|
||||
local cookPage = kframe:FindFirstChild("CookPage", true) :: Frame
|
||||
check(cookPage.Visible and not menuPage.Visible, "조리 화면으로")
|
||||
eq((cookPage:FindFirstChild("Instruction") :: TextLabel).Text, "김 위에 재료를 올려요", "1단계 안내")
|
||||
check(
|
||||
(cookPage:FindFirstChild("Base", true) :: ImageLabel).Image == Icons.KITCHEN_ASSET,
|
||||
"조리 도구 그림(도마)"
|
||||
)
|
||||
eq((cookPage:FindFirstChild("Base", true) :: ImageLabel).ImageRectOffset, Icons.KITCHEN.board, "김밥은 도마")
|
||||
local flowK = kitchen.flow()
|
||||
local need1 = flowK.need
|
||||
eq((cookPage:FindFirstChild("Gesture") :: TextLabel).Text, `톡톡! {need1}번`, "톡톡 남은 횟수")
|
||||
eq(kitchen.input("hold", 1), nil, "다른 동작은 무시")
|
||||
eq(kitchen.input("tap", 1), "progress", "톡 1")
|
||||
eq((cookPage:FindFirstChild("Gesture") :: TextLabel).Text, `톡톡! {need1 - 1}번`, "남은 횟수 줄어듦")
|
||||
local strip1 = cookPage:FindFirstChild("Strip1", true) :: Frame
|
||||
check(strip1 ~= nil and strip1.Visible, "누를 때마다 재료가 올라감")
|
||||
for _ = 2, need1 do
|
||||
kitchen.input("tap", 1)
|
||||
end
|
||||
eq(flowK.step, 2, "2단계(말기)")
|
||||
eq((cookPage:FindFirstChild("Instruction") :: TextLabel).Text, "돌돌 말아요", "2단계 안내")
|
||||
eq((cookPage:FindFirstChild("Gesture") :: TextLabel).Text, "문질문질!", "문지르기 안내")
|
||||
eq(kitchen.input("rub", flowK.need), "step", "다 문지름 → 3단계")
|
||||
check((cookPage:FindFirstChild("Roll", true) :: ImageLabel).Visible, "김밥이 말림")
|
||||
eq(#ksent, 1, "완성 전에는 시작만 보냄")
|
||||
eq(kitchen.input("tap", flowK.need), "done", "썰기 끝 → 완성")
|
||||
eq(ksent[1] and ksent[1][1], "cookStart", "메뉴를 고르면 서버에 cookStart")
|
||||
eq(ksent[1] and ksent[1][2], "Gimbap", "고른 메뉴로 시작")
|
||||
eq(ksent[2] and ksent[2][1], "cook", "다 만들면 서버에 cook")
|
||||
eq(ksent[2] and ksent[2][2], "Gimbap", "고른 메뉴를 보냄")
|
||||
local donePage = kframe:FindFirstChild("DonePage", true) :: Frame
|
||||
check(donePage.Visible, "완성 화면")
|
||||
eq((donePage:FindFirstChild("Dish") :: ImageLabel).ImageRectOffset, Icons.OFFSET.Gimbap, "완성 접시 그림")
|
||||
-- 주문이 남아 있고 손에 자리가 있으면 다시 메뉴 고르기, 아니면 닫힘
|
||||
kstate:SetAttribute("Orders", "Gimbap=1")
|
||||
kstate:SetAttribute("Carry", 0)
|
||||
task.wait(1.5)
|
||||
check(kitchen.isOpen() and menuPage.Visible, "주문이 남으면 다음 접시 고르기")
|
||||
kitchen.choose("Gimbap")
|
||||
for _ = 1, 20 do
|
||||
local st = Recipes.current(kitchen.flow())
|
||||
if not st then
|
||||
break
|
||||
end
|
||||
kitchen.input(st.kind, kitchen.flow().need)
|
||||
end
|
||||
kstate:SetAttribute("Carry", 1) -- 손이 꽉 참(쟁반 없음)
|
||||
kstate:SetAttribute("Orders", "")
|
||||
task.wait(1.5)
|
||||
check(not kitchen.isOpen() and not kframe.Visible, "더 만들 것이 없으면 창이 닫힘")
|
||||
check(not (kroot:FindFirstChild("Dim") :: TextButton).Visible, "닫히면 어둡게도 꺼짐")
|
||||
-- 메뉴마다 과정이 다르고 끝까지 갈 수 있음
|
||||
for _, m in Economy.MENU_ORDER do
|
||||
kstate:SetAttribute("Levels", "Stage=1,Menu=4")
|
||||
kstate:SetAttribute("Carry", 0)
|
||||
kstate:SetAttribute("Orders", `{m}=1`)
|
||||
khud.open("kitchen")
|
||||
check(kitchen.choose(m), `{m} 고름`)
|
||||
eq(
|
||||
(cookPage:FindFirstChild("Base", true) :: ImageLabel).ImageRectOffset,
|
||||
Icons.KITCHEN[Recipes.LIST[m].stage],
|
||||
`{m} 조리 도구 그림`
|
||||
)
|
||||
local guard = 0
|
||||
while kitchen.flow().phase == "cook" and guard < 10 do
|
||||
local st = Recipes.current(kitchen.flow()) :: Recipes.Step
|
||||
check(
|
||||
Icons.OFFSET[({ roll = "mat", fire = "flame", skewer = "Eomuk" } :: any)[st.tool] or st.tool] ~= nil,
|
||||
`{m} 도구 그림 {st.tool}`
|
||||
)
|
||||
kitchen.input(st.kind, kitchen.flow().need)
|
||||
guard += 1
|
||||
end
|
||||
eq(kitchen.flow().phase, "done", `{m} 완성`)
|
||||
eq(ksent[#ksent][1], "cook", `{m} 완성 보냄`)
|
||||
eq(ksent[#ksent][2], m, `{m} 서버에 보냄`)
|
||||
eq(ksent[#ksent - 1][1], "cookStart", `{m} 시작 보냄`)
|
||||
khud.open(nil)
|
||||
check(not kitchen.isOpen(), `{m} 창 닫기`)
|
||||
end
|
||||
-- 요리 창은 화면 안에(휴대폰)
|
||||
khud.setLayout(Vector2.new(667, 317), true)
|
||||
local kl = khud.layout().kitchen
|
||||
check(kl.x >= 0 and kl.y >= 0 and kl.x + kl.w <= khud.layout().width + 1e-6, "휴대폰: 요리 창 화면 안")
|
||||
khud.destroy()
|
||||
|
||||
section("조리대 버튼(클라이언트 모듈)")
|
||||
local Stove = require(StarterPlayer.StarterPlayerScripts.Client.Stove)
|
||||
local stove = slots[3].refs.stove
|
||||
local pstate = Instance.new("Folder")
|
||||
pstate:SetAttribute("Lang", "ko")
|
||||
local prompt = Stove.attach(stove, pstate, function() end)
|
||||
check(not prompt.Enabled, "주문 없으면 버튼 꺼짐")
|
||||
stove:SetAttribute("CookMenu", "Gimbap")
|
||||
check(prompt.Enabled, "주문 있으면 버튼 켜짐")
|
||||
eq(prompt.ActionText, "요리하기", "버튼 글자")
|
||||
eq(prompt.HoldDuration, 0, "누르면 바로 요리 창(꾹 누르지 않음)")
|
||||
prompt:Destroy()
|
||||
|
||||
section("효과음(직접 만든 오디오 에셋)")
|
||||
local Sounds = require(ReplicatedStorage.Shared.Sounds)
|
||||
for name, id in Sounds do
|
||||
local num = tonumber(string.match(id, "%d+"))
|
||||
local okInfo, info = pcall(function()
|
||||
return game:GetService("MarketplaceService"):GetProductInfoAsync(num :: number, Enum.InfoType.Asset)
|
||||
end)
|
||||
check(okInfo, `효과음 {name} 정보 조회`)
|
||||
if okInfo then
|
||||
eq(info.AssetTypeId, 3, `효과음 {name}은 오디오`)
|
||||
eq(info.Creator.CreatorTargetId, game.CreatorId, `효과음 {name}은 게임 주인 소유`)
|
||||
end
|
||||
end
|
||||
|
||||
section("UI 그림(직접 그린 이미지 에셋)")
|
||||
for _, asset in { Icons.ASSET, Icons.KITCHEN_ASSET } do
|
||||
local num = tonumber(string.match(asset, "%d+"))
|
||||
local okInfo, info = pcall(function()
|
||||
return game:GetService("MarketplaceService"):GetProductInfoAsync(num :: number, Enum.InfoType.Asset)
|
||||
end)
|
||||
check(okInfo, `그림 {num} 정보 조회`)
|
||||
if okInfo then
|
||||
eq(info.AssetTypeId, 1, `그림 {num}은 이미지`)
|
||||
eq(info.Creator.CreatorTargetId, game.CreatorId, `그림 {num}은 게임 주인 소유`)
|
||||
end
|
||||
end
|
||||
|
||||
section("Products(게임패스·개발자 상품)")
|
||||
local Products = require(ReplicatedStorage.Shared.Products)
|
||||
local MarketplaceService = game:GetService("MarketplaceService")
|
||||
for key, id in Products do
|
||||
check(id ~= 0, `{key} ID 있음`)
|
||||
local isPass = string.find(key, "_PASS$") ~= nil
|
||||
local okInfo, info = pcall(function()
|
||||
return MarketplaceService:GetProductInfoAsync(
|
||||
id,
|
||||
if isPass then Enum.InfoType.GamePass else Enum.InfoType.Product
|
||||
)
|
||||
end)
|
||||
check(okInfo, `{key} 정보 조회`)
|
||||
if okInfo then
|
||||
print(key, info.Name, info.PriceInRobux, info.IsForSale)
|
||||
check(info.PriceInRobux ~= nil and info.PriceInRobux > 0, `{key} 가격`)
|
||||
end
|
||||
end
|
||||
|
||||
section("Game.start(실제 서버 시작 순서)")
|
||||
local Game = require(Server.Game)
|
||||
local okStart, errStart = pcall(Game.start)
|
||||
check(okStart, `Game.start 오류 없음 ({errStart})`)
|
||||
task.wait(1)
|
||||
eq(#workspace.BunsikWorld.Plots:GetChildren(), 6, "시작 후 부지 6칸")
|
||||
for _, plot in workspace.BunsikWorld.Plots:GetChildren() do
|
||||
check(plot:GetAttribute("Npc") ~= nil, `{plot.Name}: 빈 부지에 이웃 가게`)
|
||||
end
|
||||
task.wait(3)
|
||||
local npcCustomers = 0
|
||||
for _, d in workspace.BunsikWorld.Plots:GetDescendants() do
|
||||
if d.Name == "Customer" then
|
||||
npcCustomers += 1
|
||||
end
|
||||
end
|
||||
print("이웃 가게 손님 수", npcCustomers)
|
||||
check(npcCustomers > 0, "이웃 가게에 손님이 옴(실제 Heartbeat)")
|
||||
|
||||
print(`통합 테스트: {count - #failures}/{count} 통과`)
|
||||
if #failures > 0 then
|
||||
error(`{#failures} failed: ` .. table.concat(failures, " | "))
|
||||
end
|
||||
return { passed = count }
|
||||
645
bunsik-tycoon/tests/cloud/server.luau
Normal file
@@ -0,0 +1,645 @@
|
||||
-- 로블록스 서버(Open Cloud Luau Execution)에서 돌리는 서버 통합 테스트(2026-10-14 개편 구조).
|
||||
-- python3 tools/cloud.py run tests/cloud/server.luau --version <저장 버전>
|
||||
-- 플레이어가 없고 물리가 돌지 않으며 Script가 자동 실행되지 않으므로,
|
||||
-- 모듈을 직접 불러 가짜 플레이어(Folder)와 가상 시계로 가게를 돌립니다.
|
||||
|
||||
local HttpService = game:GetService("HttpService")
|
||||
local Players = game:GetService("Players")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local ServerScriptService = game:GetService("ServerScriptService")
|
||||
|
||||
local Server = ServerScriptService.Server
|
||||
local failures = {}
|
||||
local count = 0
|
||||
local function check(cond: any, msg: string)
|
||||
count += 1
|
||||
if not cond then
|
||||
table.insert(failures, msg)
|
||||
print("FAIL " .. msg)
|
||||
end
|
||||
end
|
||||
local function eq(a: any, b: any, msg: string)
|
||||
check(a == b, `{msg} (기대 {tostring(b)}, 실제 {tostring(a)})`)
|
||||
end
|
||||
local function section(name: string)
|
||||
print("== " .. name)
|
||||
end
|
||||
|
||||
local Economy = require(ReplicatedStorage.Shared.Economy)
|
||||
local Floor = require(ReplicatedStorage.Shared.Floor)
|
||||
local Icons = require(ReplicatedStorage.Shared.Icons)
|
||||
local Recipes = require(ReplicatedStorage.Shared.Recipes)
|
||||
local Shop = require(ReplicatedStorage.Shared.Shop)
|
||||
|
||||
section("맵")
|
||||
local World = require(Server.World)
|
||||
local slots = World.build()
|
||||
eq(#slots, 6, "부지 6칸")
|
||||
for i, s in slots do
|
||||
check(s.refs.stove and s.refs.stove:IsDescendantOf(workspace), `부지 {i} 조리대`)
|
||||
check(typeof(s.model:GetAttribute("Origin")) == "CFrame", `부지 {i} Origin 속성`)
|
||||
for j, o in slots do
|
||||
if i < j then
|
||||
check((s.cf.Position - o.cf.Position).Magnitude >= 76, `부지 {i},{j} 겹치지 않음`)
|
||||
end
|
||||
end
|
||||
local front = s.cf:PointToWorldSpace(Vector3.new(0, 0, 40))
|
||||
check(math.abs(front.Z) < math.abs(s.cf.Position.Z), `부지 {i} 입구가 길 쪽`)
|
||||
end
|
||||
|
||||
section("NPC")
|
||||
local Npc = require(Server.Npc)
|
||||
Npc.preload()
|
||||
local npc = Npc.spawnCustomer(workspace, CFrame.new(0, 5, 0), Random.new(1))
|
||||
check(npc.model:FindFirstChild("HumanoidRootPart") ~= nil, "손님 NPC 몸")
|
||||
check(npc.tracks.walk ~= nil and npc.tracks.sit ~= nil and npc.tracks.idle ~= nil, "NPC 애니메이션 3종 로드")
|
||||
npc.model:Destroy()
|
||||
local tLooks = os.clock()
|
||||
Npc.preloadCustomers()
|
||||
local nHuman, nAnimal = Npc.lookCount()
|
||||
print(`손님 외형: 사람 {nHuman}벌, 동물 {nAnimal}종, {math.floor((os.clock() - tLooks) * 1000)}ms`)
|
||||
check(nHuman >= 10, `사람 외형 10벌 이상 ({nHuman})`)
|
||||
check(nAnimal >= 8, `동물 외형 8종 이상 ({nAnimal})`)
|
||||
local rngLook = Random.new(5)
|
||||
local animals, humans, accessories = 0, 0, 0
|
||||
local shown = {}
|
||||
for _ = 1, 200 do
|
||||
local h = Npc.spawnCustomer(workspace, CFrame.new(0, 300, 0), rngLook)
|
||||
local kind = h.model:GetAttribute("Animal")
|
||||
if kind then
|
||||
animals += 1
|
||||
shown[kind] = true
|
||||
else
|
||||
humans += 1
|
||||
end
|
||||
for _, d in h.model:GetChildren() do
|
||||
if d:IsA("Accessory") then
|
||||
accessories += 1
|
||||
end
|
||||
end
|
||||
check(h.tracks.walk ~= nil and h.tracks.sit ~= nil, "손님 애니메이션")
|
||||
check(h.model:FindFirstChildWhichIsA("Script", true) == nil, "손님 모형에 스크립트 없음")
|
||||
h.model:Destroy()
|
||||
end
|
||||
print(`손님 200명: 사람 {humans}, 동물 {animals}, 장신구 {accessories}`)
|
||||
check(humans > animals * 2, "사람 손님이 가장 많음")
|
||||
check(animals >= 25 and animals <= 75, `동물 손님은 가끔(약 25%) ({animals})`)
|
||||
check(accessories > 200, "머리·모자 장신구가 붙음")
|
||||
local kinds = 0
|
||||
for _ in shown do
|
||||
kinds += 1
|
||||
end
|
||||
check(kinds >= 6, `동물 종류 여러 가지 ({kinds})`)
|
||||
|
||||
local PlotController = require(Server.PlotController)
|
||||
local PlotBuilder = require(Server.PlotBuilder)
|
||||
local Data = require(Server.Data)
|
||||
local function newData()
|
||||
local d = table.clone(Data.TEMPLATE)
|
||||
d.PurchaseIdCache = {}
|
||||
d.Levels = {}
|
||||
d.Staff = {}
|
||||
d.Layout = {}
|
||||
return d
|
||||
end
|
||||
local function count_(folder: Instance, prefix: string): number
|
||||
local n = 0
|
||||
for _, ch in folder:GetChildren() do
|
||||
if string.sub(ch.Name, 1, #prefix) == prefix then
|
||||
n += 1
|
||||
end
|
||||
end
|
||||
return n
|
||||
end
|
||||
|
||||
section("가게 1: 튜토리얼 흐름")
|
||||
local owner = Instance.new("Folder")
|
||||
owner.Name = "FakePlayer"
|
||||
owner.Parent = ServerScriptService
|
||||
local notes = {}
|
||||
local data = newData()
|
||||
local c = PlotController.new(slots[1], owner, {
|
||||
userId = 111,
|
||||
displayName = "Tester",
|
||||
data = data,
|
||||
now = 0,
|
||||
notify = function(k, args)
|
||||
table.insert(notes, { k, args })
|
||||
end,
|
||||
})
|
||||
local function noted(key: string): boolean
|
||||
for _, n in notes do
|
||||
if n[1] == key then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
eq(owner:GetAttribute("Tut"), 1, "튜토리얼 1단계")
|
||||
eq(owner:GetAttribute("Money"), 0, "돈 0")
|
||||
eq(owner:GetAttribute("Stage"), 1, "포장마차")
|
||||
eq(owner:GetAttribute("Seats"), 1, "의자 1")
|
||||
eq(owner:GetAttribute("Tables"), 1, "테이블 1")
|
||||
eq(owner:GetAttribute("Levels"), "Stage=0,Menu=0,Price=0,Speed=0,Stove=0,Tray=0,Staff=0", "갈래 레벨 속성")
|
||||
check(typeof(owner:GetAttribute("Layout")) == "string", "배치 JSON 속성")
|
||||
local decoded = Floor.clean(HttpService:JSONDecode(owner:GetAttribute("Layout")))
|
||||
eq(#decoded.chairs, 1, "배치 JSON 읽기")
|
||||
eq(slots[1].model:GetAttribute("OwnerId"), 111, "부지 주인 속성")
|
||||
eq(slots[1].model:GetAttribute("Menus"), "Tteokbokki", "메뉴판 속성")
|
||||
local furniture = slots[1].refs.furniture
|
||||
check(
|
||||
furniture:FindFirstChild("Table1") ~= nil and furniture:FindFirstChild("Chair1") ~= nil,
|
||||
"테이블·의자 모형"
|
||||
)
|
||||
eq(furniture.Table1:GetAttribute("ItemKind"), "table", "꾸미기 선택 속성")
|
||||
eq(#slots[1].refs.building:GetChildren(), 0, "포장마차 단계엔 건물 없음")
|
||||
c:update(0)
|
||||
local dyn = slots[1].refs.dynamic
|
||||
eq(count_(dyn, "Customer"), 1, "첫 손님 NPC 1명")
|
||||
local bubble = dyn:FindFirstChild("Customer"):FindFirstChild("Order", true)
|
||||
local icon = bubble and bubble:FindFirstChild("Icon", true) :: ImageLabel?
|
||||
eq(icon and icon.ImageRectOffset, Icons.OFFSET.Tteokbokki, "말풍선에 떡볶이 그림")
|
||||
eq(slots[1].refs.stove:GetAttribute("CookMenu"), "Tteokbokki", "조리대에 떡볶이 주문")
|
||||
local walk = c.shop.seatWalk[1]
|
||||
check(walk and walk >= 1.5 and walk <= 9, `자리까지 걷는 시간 ({walk})`)
|
||||
c:update(walk + 0.1)
|
||||
eq(c.shop.customers[1].state, "waiting", "손님이 앉음")
|
||||
eq(c:finishCook("Tteokbokki", 10), nil, "메뉴를 고르지 않고 완성만 보내면 거절")
|
||||
check(c:startCook("Tteokbokki", 10), "주문 있는 메뉴로 시작")
|
||||
local minT = Recipes.minTime("Tteokbokki", c.shop.stats.cook)
|
||||
eq(c:finishCook("Tteokbokki", 10 + minT * 0.5), nil, "조리 과정 최소 시간보다 빠르면 거절")
|
||||
local t = walk + 0.1
|
||||
check(c:startCook("Tteokbokki", t - Recipes.expectedTime("Tteokbokki", c.shop.stats.cook)), "다시 시작")
|
||||
eq(c:finishCook("Tteokbokki", t), "Tteokbokki", "정상 시간이면 조리")
|
||||
eq(owner:GetAttribute("Tut"), 2, "튜토리얼 2단계")
|
||||
-- 접시가 똑바로 놓이는지(예전에 세로로 서던 문제)
|
||||
local held = dyn:FindFirstChild("Dish_Tteokbokki") :: Model
|
||||
check(held ~= nil, "접시 모형")
|
||||
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})`)
|
||||
local plate = onTable and onTable:FindFirstChild("Plate") :: BasePart?
|
||||
check(plate and math.abs(plate.CFrame.RightVector.Y) > 0.99, "접시 원기둥 축이 세로(평평한 접시)")
|
||||
eq(owner:GetAttribute("Tut"), 3, "튜토리얼 3단계")
|
||||
-- 첫 추천 구매: 의자(10원)
|
||||
local offers = Economy.offers(c.shop.levels, #c.layout.tables, #c.layout.chairs)
|
||||
eq(offers[1].id, "Seat", "처음 추천은 의자")
|
||||
check(c:buyOffer("Seat"), "의자 구매")
|
||||
eq(owner:GetAttribute("Seats"), 2, "의자 2")
|
||||
eq(c.shop.stats.seats, 2, "손님 자리 2")
|
||||
check(furniture:FindFirstChild("Chair2") ~= nil, "의자 모형")
|
||||
eq(owner:GetAttribute("Tut"), 0, "튜토리얼 끝")
|
||||
eq(data.TutorialDone, true, "튜토리얼 저장")
|
||||
eq(#data.Layout.chairs, 2, "세이브에 배치")
|
||||
|
||||
section("가게 1: 갈래 업그레이드")
|
||||
c:addMoney(40)
|
||||
check(c:upgrade("Menu"), "김밥 해금")
|
||||
check(slots[1].refs.stall.Extras:FindFirstChild("Menu_Gimbap") ~= nil, "김밥 진열대 모형")
|
||||
check(noted("newMenu"), "새 메뉴 알림")
|
||||
eq(slots[1].model:GetAttribute("Menus"), "Tteokbokki,Gimbap", "메뉴판 속성에 김밥")
|
||||
local ok, why = c:upgrade("Tray")
|
||||
check(not ok and why == "stage", "쟁반은 실내 분식집부터")
|
||||
check(noted("needStage"), "건물 단계 알림")
|
||||
c:addMoney(1_000_000)
|
||||
check(c:upgrade("Speed"), "손님 속도")
|
||||
check(c:upgrade("Speed"), "손님 속도 2")
|
||||
check(slots[1].refs.stall.Extras:FindFirstChild("Part") ~= nil, "수레 장식")
|
||||
check(c:upgrade("Stage"), "실내 분식집 확장")
|
||||
eq(owner:GetAttribute("Stage"), 2, "2단계")
|
||||
check(noted("expanded"), "확장 알림")
|
||||
check(slots[1].refs.building:FindFirstChild("Roof") ~= nil, "실내 건물 지붕")
|
||||
check(slots[1].refs.building:FindFirstChild("Ceiling") ~= nil, "실내 건물 천장")
|
||||
check(slots[1].refs.building:FindFirstChild("RoofSign") ~= nil, "지붕 간판")
|
||||
|
||||
section("가게 1: 꾸미기(테이블·의자·소품·옮기기)")
|
||||
for _ = 1, 4 do
|
||||
check(c:buyTable(), "테이블 구매")
|
||||
end
|
||||
eq(#c.layout.tables, 5, "테이블 5")
|
||||
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, "소품 모형")
|
||||
-- 옮기기
|
||||
local t1 = c.layout.tables[1]
|
||||
check(
|
||||
c:move({ kind = "table", i = 1, x = 25, z = 10 }) or c:move({ kind = "table", i = 1, x = 26, z = 12 }),
|
||||
"테이블 옮기기"
|
||||
)
|
||||
check(c.layout.tables[1].x ~= t1.x, "옮긴 자리 저장")
|
||||
check(not c:move({ kind = "table", i = 1, x = 0, z = 17 }), "문 앞에는 못 놓음")
|
||||
check(noted("placeFail"), "못 놓는 이유 알림")
|
||||
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을 다른 테이블의 빈 쪽으로 옮기기
|
||||
local sideMoved = false
|
||||
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 ~= 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, "의자 붙은 테이블 옮기기")
|
||||
-- 지우기(산 값 돌려받기)
|
||||
local decorN = #c.layout.decor
|
||||
local m0 = c.shop.money
|
||||
check(c:removeItem("decor", 1), "소품 지우기")
|
||||
eq(#c.layout.decor, decorN - 1, "소품 하나 줄어듦")
|
||||
check(c.shop.money > m0, "소품 값 돌려받음")
|
||||
check(noted("removed"), "지운 알림")
|
||||
check(not c:removeItem("stove", 1), "조리대는 못 지움")
|
||||
check(noted("removeFail"), "못 지우는 이유 알림")
|
||||
local freeChair = nil
|
||||
for ci in c.layout.chairs do
|
||||
if c.shop.seatTaken[ci] == nil then
|
||||
freeChair = ci
|
||||
end
|
||||
end
|
||||
local seatsN = #c.layout.chairs
|
||||
check(freeChair ~= nil and c:removeItem("chair", freeChair), "빈 의자 지우기")
|
||||
eq(owner:GetAttribute("Seats"), seatsN - 1, "자리 수 줄어듦")
|
||||
eq(c.shop.stats.seats, seatsN - 1, "손님 자리 수도 줄어듦")
|
||||
check(furniture:FindFirstChild("Chair" .. seatsN) == nil, "의자 모형도 줄어듦")
|
||||
local busy = next(c.shop.seatTaken)
|
||||
if busy then
|
||||
check(not c:removeItem("chair", busy), "손님이 앉은 의자는 못 지움")
|
||||
end
|
||||
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)
|
||||
|
||||
section("가게 1: 디자인")
|
||||
check(c:setDesign("Mint"), "무료 디자인")
|
||||
eq(slots[1].model:GetAttribute("Design"), "Mint", "디자인 속성")
|
||||
local okCandy, whyCandy = c:setDesign("Candy")
|
||||
check(not okCandy and whyCandy == "locked", "유료 디자인은 게임패스가 있어야")
|
||||
c:setDesignOwned("Candy", true)
|
||||
check(c:setDesign("Candy"), "게임패스 있으면 유료 디자인")
|
||||
check(slots[1].refs.building:FindFirstChild("Roof") ~= nil, "디자인 바꾼 건물")
|
||||
c:setDesignOwned("Hanok", true)
|
||||
check(c:setDesign("Hanok"), "한옥 디자인")
|
||||
|
||||
section("가게 1: 이름·무지개")
|
||||
c:setShopName("떡볶이 천국", "떡볶이 천국")
|
||||
eq(slots[1].model:GetAttribute("ShopName"), "떡볶이 천국", "모두에게 보이는 이름")
|
||||
eq(data.ShopName, "떡볶이 천국", "세이브에 이름")
|
||||
eq(slots[1].model:GetAttribute("Rainbow"), false, "게임패스 없으면 무지개 아님")
|
||||
c:setRainbowOwned(true)
|
||||
eq(slots[1].model:GetAttribute("Rainbow"), true, "게임패스 있으면 무지개")
|
||||
c:setRainbow(false)
|
||||
eq(slots[1].model:GetAttribute("Rainbow"), false, "무지개 끄기")
|
||||
c:setRainbow(true)
|
||||
c:setNameColor(3)
|
||||
eq(slots[1].model:GetAttribute("NameColor"), 3, "이름 색 속성(모두에게)")
|
||||
eq(owner:GetAttribute("NameColor"), 3, "이름 색 속성(내 화면)")
|
||||
eq(slots[1].model:GetAttribute("Rainbow"), false, "색을 고르면 무지개는 꺼짐")
|
||||
eq(data.NameColor, 3, "세이브에 이름 색")
|
||||
c:setNameColor(99)
|
||||
eq(owner:GetAttribute("NameColor"), 0, "없는 색은 기본색")
|
||||
local Game = require(Server.Game)
|
||||
eq(Game._cleanName(" 가나다\n라 "), "가나다 라", "이름 공백 정리")
|
||||
eq(utf8.len(Game._cleanName(string.rep("가", 30)) :: string), Economy.NAME_MAX, "이름 길이 자르기")
|
||||
|
||||
section("가게 1: 2층")
|
||||
check(c:upgrade("Stage"), "2층 확장")
|
||||
eq(owner:GetAttribute("Stage"), 3, "3단계")
|
||||
check(noted("floor2"), "2층 알림")
|
||||
check(slots[1].refs.building:FindFirstChild("Floor2") ~= nil, "2층 바닥")
|
||||
eq(Floor.validate(c.layout, 3), nil, "2층 건물에 맞게 배치 정리")
|
||||
local before2 = #c.layout.tables
|
||||
local placed2 = false
|
||||
for _ = 1, 7 do
|
||||
if c:buyTable() then
|
||||
placed2 = true
|
||||
end
|
||||
end
|
||||
check(placed2, "2층 건물에서 테이블 추가")
|
||||
local on2 = nil
|
||||
for i, tb in c.layout.tables do
|
||||
if tb.f == 2 then
|
||||
on2 = i
|
||||
end
|
||||
end
|
||||
check(#c.layout.tables > before2, "테이블 늘어남")
|
||||
check(on2 ~= nil, "2층에 테이블")
|
||||
if on2 then
|
||||
check(c:buySeat(on2), "2층 테이블에 의자")
|
||||
local chair2 = nil
|
||||
for ci in c.layout.chairs do
|
||||
if Floor.chairTable(c.layout, ci) == on2 then
|
||||
chair2 = ci
|
||||
end
|
||||
end
|
||||
local seatCf = PlotBuilder.seatCFrame(slots[1].cf, c.layout, chair2)
|
||||
check(seatCf.Position.Y > slots[1].cf.Position.Y + Floor.FLOOR2_Y, "2층 의자 높이")
|
||||
local path = c:entryPath(chair2)
|
||||
local top = 0
|
||||
for _, p in path do
|
||||
top = math.max(top, p.Y)
|
||||
end
|
||||
check(top > slots[1].cf.Position.Y + Floor.FLOOR2_Y - 1, "2층 손님 길이 계단을 올라감")
|
||||
end
|
||||
|
||||
section("가게 1: 알바생")
|
||||
check(not c:hire("Cook"), "알바생 기능 전에는 고용 못 함")
|
||||
check(noted("staffLocked"), "잠김 알림")
|
||||
check(c:upgrade("Staff"), "알바생 기능")
|
||||
check(c:hire("Cook"), "요리 알바")
|
||||
check(c:hire("Server"), "서빙 알바")
|
||||
check(c:hire("Promoter"), "홍보 알바")
|
||||
eq(owner:GetAttribute("Staff"), "Cook=1,Server=1,Promoter=1", "알바 속성")
|
||||
check(owner:GetAttribute("Wage") > 0, "시급 합계")
|
||||
check(dyn:FindFirstChild("Staff_Cook1") ~= nil, "요리 알바 NPC")
|
||||
check(dyn:FindFirstChild("Staff_Server1") ~= nil, "서빙 알바 NPC")
|
||||
check(dyn:FindFirstChild("Staff_Promoter1") ~= nil, "홍보 알바 NPC")
|
||||
check(c:fire("Promoter"), "해고")
|
||||
eq(dyn:FindFirstChild("Staff_Promoter1"), nil, "해고하면 NPC 사라짐")
|
||||
|
||||
section("가게 1: 가상 5분 영업(서빙 알바가 나름)")
|
||||
local now = 100
|
||||
c.shop.now = now
|
||||
c.shop.nextSpawn = now
|
||||
local served0 = c.shop.served
|
||||
local money0 = c.shop.money
|
||||
local delivered = false
|
||||
while now < 400 do
|
||||
now += 0.1
|
||||
c:update(now)
|
||||
if c.tripDish[1] then
|
||||
delivered = true
|
||||
end
|
||||
end
|
||||
local served = c.shop.served - served0
|
||||
print(`5분 영업(알바만): 서빙 {served}회, 돈 {c.shop.money - money0}`)
|
||||
check(delivered, "서빙 알바가 접시를 들고 감")
|
||||
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가 쌓이지 않음")
|
||||
|
||||
section("가게 2: 예전 세이브 옮기기 + 캐릭터 자동 서빙")
|
||||
local charModel =
|
||||
Players:CreateHumanoidModelFromDescription(Instance.new("HumanoidDescription"), Enum.HumanoidRigType.R15)
|
||||
charModel.Name = "FakeCharacter"
|
||||
charModel.Parent = workspace
|
||||
local hrp = charModel:FindFirstChild("HumanoidRootPart") :: BasePart
|
||||
hrp.Anchored = true
|
||||
local owner2 = Instance.new("Folder")
|
||||
owner2.Parent = ServerScriptService
|
||||
local old = newData()
|
||||
old.Bought = 8 -- 예전 구조: 알바생까지 산 상태
|
||||
old.Money = 5
|
||||
old.Version = nil
|
||||
Data.migrate(old, 1)
|
||||
eq(old.Version, 2, "버전 2로 옮김")
|
||||
eq(old.Levels.Staff, 1, "알바생 기능")
|
||||
eq(old.Staff.Cook, 1, "요리 알바 1명")
|
||||
eq(#old.Layout.chairs, 3, "자리 3")
|
||||
local c2 = PlotController.new(slots[2], owner2, {
|
||||
userId = 222,
|
||||
displayName = "Tester2",
|
||||
data = old,
|
||||
now = 0,
|
||||
getCharacter = function()
|
||||
return charModel
|
||||
end,
|
||||
})
|
||||
eq(owner2:GetAttribute("Money"), 5, "저장된 돈 불러옴")
|
||||
c2:update(0)
|
||||
eq(#c2.shop.counter, 1, "요리 알바가 카운터에 접시")
|
||||
hrp.CFrame = slots[2].refs.counter.CFrame + Vector3.new(0, 3, 4)
|
||||
c2:update(0.2)
|
||||
eq(#c2.shop.hand, 1, "카운터 근처에서 자동으로 집음")
|
||||
eq(count_(charModel, "Dish_"), 1, "손에 접시 모형")
|
||||
local held2 = charModel:FindFirstChild("Dish_Tteokbokki") :: Model?
|
||||
check(held2 and held2:GetPivot().UpVector.Y > 0.99, "손에 든 접시도 똑바로")
|
||||
c2:update(5)
|
||||
local seat = c2.shop.customers[1].seat
|
||||
hrp.CFrame = PlotBuilder.seatCFrame(slots[2].cf, c2.layout, seat) + Vector3.new(0, 2, 2)
|
||||
local before = c2.shop.money
|
||||
c2:update(5.2)
|
||||
check(c2.shop.money > before, "손님 근처에서 자동 서빙")
|
||||
c2:rebuildHand()
|
||||
|
||||
section("홍보·쫓아내기(옆 가게 손님 데려오기)")
|
||||
local Neighbor = require(Server.Neighbor)
|
||||
local Transfers = require(Server.Transfers)
|
||||
local nb = Neighbor.open(slots[5], 0)
|
||||
eq(slots[5].model:GetAttribute("Npc"), 5, "이웃 가게 속성")
|
||||
check(slots[5].refs.dynamic:FindFirstChild("Keeper") ~= nil, "사장님 NPC")
|
||||
-- 이웃 가게에 손님이 찰 때까지
|
||||
local nt = 0
|
||||
while nt < 15 do
|
||||
nt += 0.1
|
||||
nb.controller:update(nt)
|
||||
end
|
||||
local waiting = 0
|
||||
for _, cust in nb.controller.shop.customers do
|
||||
if cust.state ~= "eating" then
|
||||
waiting += 1
|
||||
end
|
||||
end
|
||||
check(waiting >= 1, `이웃 가게 손님 ({waiting})`)
|
||||
-- 가게 2 자리를 비워 둡니다.
|
||||
for id in c2.shop.customers do
|
||||
c2.shop.customers[id] = nil
|
||||
end
|
||||
table.clear(c2.shop.seatTaken)
|
||||
c2.shop.now = 20
|
||||
local got = Transfers.promote(c2, { nb.controller })
|
||||
check(got >= 1, `홍보로 손님이 옴 ({got})`)
|
||||
local transferred = 0
|
||||
for _, cust in c2.shop.customers do
|
||||
if cust.transfer then
|
||||
transferred += 1
|
||||
check(c2.views[cust.id] and c2.views[cust.id].npc ~= nil, "데려온 손님 NPC")
|
||||
check(
|
||||
c2.views[cust.id].npc.model:IsDescendantOf(slots[2].refs.dynamic),
|
||||
"NPC가 우리 가게 폴더로 옮겨짐"
|
||||
)
|
||||
end
|
||||
end
|
||||
eq(transferred, got, "데려온 손님 수")
|
||||
-- 데려온 손님도 걸어와서 앉음
|
||||
local tt = 20
|
||||
while tt < 40 do
|
||||
tt += 0.2
|
||||
c2:update(tt)
|
||||
end
|
||||
for _, cust in c2.shop.customers do
|
||||
if cust.transfer then
|
||||
check(cust.state ~= "walking", "데려온 손님이 자리에 도착")
|
||||
end
|
||||
end
|
||||
-- 자리가 꽉 차면 홍보 실패
|
||||
local full = Shop.freeSeatCount(c2.shop)
|
||||
for _ = 1, full do
|
||||
Shop.addTransfer(c2.shop, "Tteokbokki", 1)
|
||||
end
|
||||
local got2, why2 = Transfers.promote(c2, { nb.controller })
|
||||
eq(got2, 0, "빈자리 없으면 못 데려옴")
|
||||
eq(why2, "full", "이유 full")
|
||||
-- 쫓아내기: 가게 1(빈자리 많음)이 이웃 가게 손님을 쫓아냄
|
||||
while nt < 60 do
|
||||
nt += 0.1
|
||||
nb.controller:update(nt)
|
||||
end
|
||||
c.shop.now = now
|
||||
local kicked, came = Transfers.kick(c, nb.controller)
|
||||
print(`쫓아내기: {kicked}명 쫓아냄, {came}명 옴`)
|
||||
check(kicked >= 0 and came <= kicked, "쫓아낸 수 >= 온 수")
|
||||
for _, cust in nb.controller.shop.customers do
|
||||
check(cust.state == "eating", "이웃 가게에는 먹는 손님만 남음")
|
||||
end
|
||||
task.wait(5)
|
||||
c2:destroy()
|
||||
charModel:Destroy()
|
||||
Neighbor.close(nb)
|
||||
|
||||
section("다른 플레이어가 손님으로 방문")
|
||||
local guestChar =
|
||||
Players:CreateHumanoidModelFromDescription(Instance.new("HumanoidDescription"), Enum.HumanoidRigType.R15)
|
||||
guestChar.Parent = workspace
|
||||
local hostOwner = Instance.new("Folder")
|
||||
hostOwner.Parent = ServerScriptService
|
||||
local hostData = newData()
|
||||
hostData.TutorialDone = true
|
||||
hostData.Layout = Floor.default()
|
||||
Floor.addChair(hostData.Layout, 1)
|
||||
Floor.addChair(hostData.Layout, 1)
|
||||
local guestEvents = {}
|
||||
local host = PlotController.new(slots[3], hostOwner, {
|
||||
userId = 333,
|
||||
displayName = "Host",
|
||||
data = hostData,
|
||||
now = 0,
|
||||
guestEvent = function(kind, userId, info)
|
||||
table.insert(guestEvents, { kind, userId, info })
|
||||
end,
|
||||
})
|
||||
eq(host.shop.stats.seats, 3, "자리 3")
|
||||
local gc = host:addGuest(444, guestChar)
|
||||
check(gc ~= nil, "빈자리에 손님으로 앉음")
|
||||
host.shop.now = 0.5
|
||||
eq(host:cook(), gc and gc.menu, "손님 메뉴 조리")
|
||||
local guestEarn = host:serve(gc.id)
|
||||
eq(guestEarn, Economy.dishPrice(gc.menu, host.shop.stats, 1) * Economy.GUEST_MULT, "손님 접시는 2배 값")
|
||||
eq(guestEvents[1] and guestEvents[1][1], "served", "손님에게 서빙 소식")
|
||||
host:update(0.6 + Economy.EAT + 0.5)
|
||||
eq(guestEvents[2] and guestEvents[2][3].reason, "ate", "다 먹고 일어남")
|
||||
check(host:addGuest(444, guestChar) ~= nil, "다시 앉음")
|
||||
host:destroy()
|
||||
eq(guestEvents[#guestEvents][3].reason, "closed", "가게가 닫히면 일어남")
|
||||
guestChar:Destroy()
|
||||
|
||||
section("이웃 가게 스스로 영업")
|
||||
local nb2 = Neighbor.open(slots[6], 0)
|
||||
local n2 = 0
|
||||
while n2 < 90 do
|
||||
n2 += 0.1
|
||||
Neighbor.update(nb2, n2)
|
||||
end
|
||||
print(`이웃 가게 90초: 서빙 {nb2.controller.shop.served}회`)
|
||||
check(nb2.controller.shop.served >= 5, "이웃 가게가 스스로 서빙")
|
||||
Neighbor.close(nb2)
|
||||
eq(slots[6].model:GetAttribute("Npc"), nil, "닫으면 속성 해제")
|
||||
eq(#slots[6].refs.dynamic:GetChildren(), 0, "닫으면 가게 비움")
|
||||
eq(#slots[6].refs.furniture:GetChildren(), 0, "닫으면 배치 물건 비움")
|
||||
|
||||
section("파트 수·Union")
|
||||
local parts = 0
|
||||
for _, d in workspace.BunsikWorld:GetDescendants() do
|
||||
if d:IsA("BasePart") then
|
||||
parts += 1
|
||||
check(not d:IsA("PartOperation"), "Union 없음(업로드 제한)")
|
||||
end
|
||||
end
|
||||
print("맵 파트 수(가게 1 2층·한옥 포함)", parts)
|
||||
check(parts < 12000, "파트 12000개 미만")
|
||||
|
||||
section("결제(Game.processReceipt, 플레이어 없음)")
|
||||
eq(
|
||||
Game.processReceipt({ PlayerId = 1, PurchaseId = "x", ProductId = 1 }),
|
||||
Enum.ProductPurchaseDecision.NotProcessedYet,
|
||||
"플레이어가 없으면 나중에"
|
||||
)
|
||||
|
||||
c:destroy()
|
||||
print(`checks: {count}, failures: {#failures}`)
|
||||
if #failures > 0 then
|
||||
error(`{#failures} failures:\n` .. table.concat(failures, "\n"))
|
||||
end
|
||||
363
bunsik-tycoon/tools/art.py
Normal file
@@ -0,0 +1,363 @@
|
||||
#!/usr/bin/env python3
|
||||
"""게임패스·개발자 상품 아이콘(512x512), 게임 아이콘(512x512), 썸네일(1920x1080)을 그립니다.
|
||||
외부 그림을 쓰지 않아 저작권 걱정이 없습니다.
|
||||
|
||||
python3 tools/art.py # art/*.png 생성
|
||||
"""
|
||||
import math
|
||||
import os
|
||||
|
||||
import numpy as np
|
||||
from PIL import Image, ImageDraw, ImageFilter, ImageFont
|
||||
|
||||
OUT = os.path.join(os.path.dirname(__file__), "..", "art")
|
||||
BOLD = "/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc"
|
||||
S = 512
|
||||
|
||||
|
||||
def font(size):
|
||||
return ImageFont.truetype(BOLD, size, index=1) # KR
|
||||
|
||||
|
||||
def background(c1, c2):
|
||||
img = Image.new("RGBA", (S, S))
|
||||
d = ImageDraw.Draw(img)
|
||||
for y in range(S):
|
||||
t = y / S
|
||||
col = tuple(int(c1[i] * (1 - t) + c2[i] * t) for i in range(3)) + (255,)
|
||||
d.line([(0, y), (S, y)], fill=col)
|
||||
# 햇살 무늬
|
||||
rays = Image.new("RGBA", (S, S), (0, 0, 0, 0))
|
||||
rd = ImageDraw.Draw(rays)
|
||||
for i in range(16):
|
||||
a0 = i * math.pi / 8
|
||||
a1 = a0 + math.pi / 16
|
||||
rd.polygon([(S / 2, S / 2), (S / 2 + 800 * math.cos(a0), S / 2 + 800 * math.sin(a0)),
|
||||
(S / 2 + 800 * math.cos(a1), S / 2 + 800 * math.sin(a1))], fill=(255, 255, 255, 40))
|
||||
img.alpha_composite(rays)
|
||||
mask = Image.new("L", (S, S), 0)
|
||||
ImageDraw.Draw(mask).rounded_rectangle([0, 0, S - 1, S - 1], radius=90, fill=255)
|
||||
out = Image.new("RGBA", (S, S), (0, 0, 0, 0))
|
||||
out.paste(img, (0, 0), mask)
|
||||
return out
|
||||
|
||||
|
||||
def coin(d, cx, cy, r):
|
||||
d.ellipse([cx - r, cy - r, cx + r, cy + r], fill=(255, 200, 40), outline=(190, 120, 10), width=max(4, r // 8))
|
||||
d.ellipse([cx - r * 0.65, cy - r * 0.65, cx + r * 0.65, cy + r * 0.65], outline=(230, 160, 20), width=max(3, r // 12))
|
||||
f = font(int(r * 1.0))
|
||||
d.text((cx, cy - r * 0.05), "₩", font=f, fill=(190, 120, 10), anchor="mm")
|
||||
|
||||
|
||||
def outlined(d, xy, text, f, fill, stroke, width):
|
||||
d.text(xy, text, font=f, fill=fill, anchor="mm", stroke_width=width, stroke_fill=stroke)
|
||||
|
||||
|
||||
def shadow(img):
|
||||
sh = img.copy().filter(ImageFilter.GaussianBlur(6))
|
||||
return sh
|
||||
|
||||
|
||||
def double_money():
|
||||
img = background((170, 90, 230), (90, 40, 170))
|
||||
d = ImageDraw.Draw(img)
|
||||
for (x, y, r) in [(140, 330, 80), (370, 350, 70), (255, 395, 90)]:
|
||||
coin(d, x, y, r)
|
||||
outlined(d, (256, 190), "x2", font(250), (255, 230, 60), (90, 30, 120), 14)
|
||||
return img
|
||||
|
||||
|
||||
def money_boost():
|
||||
img = background((255, 190, 60), (240, 110, 30))
|
||||
d = ImageDraw.Draw(img)
|
||||
for (x, y, r) in [(130, 380, 70), (385, 380, 70), (256, 410, 80)]:
|
||||
coin(d, x, y, r)
|
||||
bolt = [(290, 40), (150, 270), (245, 270), (205, 430), (360, 200), (265, 200), (320, 40)]
|
||||
d.polygon(bolt, fill=(255, 250, 120), outline=(160, 70, 0))
|
||||
d.line(bolt + [bolt[0]], fill=(160, 70, 0), width=12, joint="curve")
|
||||
return img
|
||||
|
||||
|
||||
def stall_scene(W, H, scale):
|
||||
"""포장마차와 떡볶이 판 그림(W x H, 크게 그린 뒤 줄여서 부드럽게)."""
|
||||
k = scale
|
||||
img = Image.new("RGBA", (W, H))
|
||||
d = ImageDraw.Draw(img)
|
||||
# 저녁 하늘
|
||||
for y in range(H):
|
||||
tt = y / H
|
||||
c = (int(255 * (1 - tt) + 255 * tt), int(170 * (1 - tt) + 120 * tt), int(90 * (1 - tt) + 140 * tt), 255)
|
||||
d.line([(0, y), (W, y)], fill=c)
|
||||
rays = Image.new("RGBA", (W, H), (0, 0, 0, 0))
|
||||
rd = ImageDraw.Draw(rays)
|
||||
cx, cy = W / 2, H * 0.55
|
||||
for i in range(24):
|
||||
a0 = i * math.pi / 12
|
||||
a1 = a0 + math.pi / 24
|
||||
rd.polygon([(cx, cy), (cx + 4000 * math.cos(a0), cy + 4000 * math.sin(a0)),
|
||||
(cx + 4000 * math.cos(a1), cy + 4000 * math.sin(a1))], fill=(255, 255, 255, 28))
|
||||
img.alpha_composite(rays)
|
||||
d = ImageDraw.Draw(img)
|
||||
# 바닥
|
||||
d.rectangle([0, H * 0.82, W, H], fill=(120, 95, 80))
|
||||
# 천막 기둥
|
||||
left, right = W / 2 - 330 * k, W / 2 + 330 * k
|
||||
top = H * 0.30
|
||||
for x in (left + 30 * k, right - 30 * k):
|
||||
d.rectangle([x - 9 * k, top, x + 9 * k, H * 0.84], fill=(180, 180, 190))
|
||||
# 수레(나무)
|
||||
d.rounded_rectangle([left + 10 * k, H * 0.58, right - 10 * k, H * 0.84], radius=18 * k, fill=(165, 105, 60),
|
||||
outline=(110, 65, 35), width=int(8 * k))
|
||||
for i in range(1, 6):
|
||||
x = left + 10 * k + i * (right - left - 20 * k) / 6
|
||||
d.line([(x, H * 0.60), (x, H * 0.82)], fill=(140, 85, 45), width=int(5 * k))
|
||||
d.rounded_rectangle([left - 10 * k, H * 0.55, right + 10 * k, H * 0.60], radius=10 * k, fill=(215, 220, 225),
|
||||
outline=(150, 150, 160), width=int(5 * k))
|
||||
# 줄무늬 천막과 물결 테두리
|
||||
roof = [(left - 60 * k, top + 110 * k), (W / 2, top - 40 * k), (right + 60 * k, top + 110 * k)]
|
||||
d.polygon(roof, fill=(245, 110, 40), outline=(170, 60, 20))
|
||||
n = 8
|
||||
for i in range(n):
|
||||
if i % 2 == 0:
|
||||
x0 = left - 60 * k + i * (right - left + 120 * k) / n
|
||||
x1 = x0 + (right - left + 120 * k) / n
|
||||
d.polygon([(W / 2, top - 40 * k), (x0, top + 110 * k), (x1, top + 110 * k)], fill=(255, 235, 205))
|
||||
d.line(roof + [roof[0]], fill=(170, 60, 20), width=int(8 * k), joint="curve")
|
||||
sw = (right - left + 120 * k) / n
|
||||
for i in range(n):
|
||||
x0 = left - 60 * k + i * sw
|
||||
col = (245, 110, 40) if i % 2 == 0 else (255, 235, 205)
|
||||
d.pieslice([x0, top + 70 * k, x0 + sw, top + 150 * k], 0, 180, fill=col, outline=(170, 60, 20), width=int(5 * k))
|
||||
# 전구
|
||||
for i in range(9):
|
||||
x = left - 20 * k + i * (right - left + 40 * k) / 8
|
||||
d.ellipse([x - 14 * k, top + 150 * k, x + 14 * k, top + 178 * k], fill=(255, 230, 140), outline=(230, 170, 60),
|
||||
width=int(3 * k))
|
||||
# 큰 떡볶이 판
|
||||
px, py, pr = W / 2, H * 0.60, 250 * k
|
||||
d.ellipse([px - pr, py - pr * 0.42, px + pr, py + pr * 0.42], fill=(45, 45, 50))
|
||||
d.ellipse([px - pr * 0.9, py - pr * 0.36, px + pr * 0.9, py + pr * 0.36], fill=(215, 45, 25))
|
||||
r2 = random_state = np.random.default_rng(3) # noqa: F841
|
||||
for _ in range(26):
|
||||
a = r2.uniform(0, 2 * math.pi)
|
||||
rr = r2.uniform(0, 0.78)
|
||||
x = px + math.cos(a) * pr * 0.85 * rr
|
||||
y = py + math.sin(a) * pr * 0.32 * rr
|
||||
ang = r2.uniform(-0.6, 0.6)
|
||||
tl, tw = 70 * k, 22 * k
|
||||
pts = [(-tl / 2, -tw / 2), (tl / 2, -tw / 2), (tl / 2, tw / 2), (-tl / 2, tw / 2)]
|
||||
pts = [(x + px_ * math.cos(ang) - py_ * math.sin(ang), y + px_ * math.sin(ang) + py_ * math.cos(ang))
|
||||
for px_, py_ in pts]
|
||||
d.polygon(pts, fill=(250, 120, 80), outline=(170, 40, 20))
|
||||
d.line([pts[0], pts[1]], fill=(255, 190, 160), width=int(4 * k))
|
||||
for _ in range(4):
|
||||
x = px + r2.uniform(-0.6, 0.6) * pr
|
||||
y = py + r2.uniform(-0.2, 0.15) * pr
|
||||
d.polygon([(x - 40 * k, y + 15 * k), (x + 40 * k, y + 15 * k), (x, y - 40 * k)], fill=(240, 200, 130),
|
||||
outline=(170, 120, 60))
|
||||
# 김
|
||||
steam = Image.new("RGBA", (W, H), (0, 0, 0, 0))
|
||||
sd = ImageDraw.Draw(steam)
|
||||
for j, off in enumerate((-110, 0, 110)):
|
||||
pts = []
|
||||
for i in range(30):
|
||||
yy = py - pr * 0.4 - i * 9 * k
|
||||
xx = px + off * k + math.sin(i / 4 + j) * 26 * k
|
||||
pts.append((xx, yy))
|
||||
sd.line(pts, fill=(255, 255, 255, 170), width=int(22 * k), joint="curve")
|
||||
steam = steam.filter(ImageFilter.GaussianBlur(8 * k))
|
||||
img.alpha_composite(steam)
|
||||
return img
|
||||
|
||||
|
||||
def title(img, cx, cy, size, sub=True):
|
||||
d = ImageDraw.Draw(img)
|
||||
outlined(d, (cx, cy), "분식 타이쿤", font(size), (255, 245, 120), (150, 40, 20), max(6, size // 10))
|
||||
if sub:
|
||||
outlined(d, (cx, cy + size * 0.95), "BUNSIK TYCOON", font(int(size * 0.45)), (255, 255, 255), (150, 40, 20),
|
||||
max(4, size // 18))
|
||||
|
||||
|
||||
def game_icon():
|
||||
big = stall_scene(1024, 1024, 1.25)
|
||||
title(big, 512, 150, 150)
|
||||
img = big.resize((S, S), Image.LANCZOS)
|
||||
mask = Image.new("L", (S, S), 0)
|
||||
ImageDraw.Draw(mask).rounded_rectangle([0, 0, S - 1, S - 1], radius=90, fill=255)
|
||||
out = Image.new("RGBA", (S, S), (0, 0, 0, 0))
|
||||
out.paste(img, (0, 0), mask)
|
||||
return out
|
||||
|
||||
|
||||
def thumbnail():
|
||||
big = stall_scene(1920, 1080, 1.35)
|
||||
d = ImageDraw.Draw(big)
|
||||
title(big, 960, 120, 130)
|
||||
# 메뉴 말풍선
|
||||
for (x, y, label) in [(250, 560, "떡볶이"), (1670, 560, "김밥"), (300, 860, "순대"), (1620, 860, "어묵")]:
|
||||
d.rounded_rectangle([x - 150, y - 60, x + 150, y + 60], radius=40, fill=(255, 255, 255), outline=(255, 140, 60),
|
||||
width=8)
|
||||
d.text((x, y), label, font=font(64), fill=(200, 60, 30), anchor="mm")
|
||||
outlined(d, (960, 1010), "손님을 받고 가게를 키우세요! Serve customers & grow your shop!", font(48),
|
||||
(255, 255, 255), (90, 40, 20), 6)
|
||||
return big.convert("RGB")
|
||||
|
||||
|
||||
RAINBOW = [(255, 80, 80), (255, 160, 40), (255, 220, 50), (80, 200, 100), (60, 160, 255), (150, 90, 230)]
|
||||
|
||||
|
||||
def rainbow_fill(size):
|
||||
w, h = size
|
||||
arr = np.zeros((h, w, 4), dtype=np.uint8)
|
||||
n = len(RAINBOW) - 1
|
||||
for x in range(w):
|
||||
t = x / max(1, w - 1) * n
|
||||
i = min(int(t), n - 1)
|
||||
f = t - i
|
||||
c = [int(RAINBOW[i][k] * (1 - f) + RAINBOW[i + 1][k] * f) for k in range(3)]
|
||||
arr[:, x, :3] = c
|
||||
arr[:, x, 3] = 255
|
||||
return Image.fromarray(arr, "RGBA")
|
||||
|
||||
|
||||
def rainbow_name():
|
||||
img = background((120, 200, 255), (60, 120, 230))
|
||||
d = ImageDraw.Draw(img)
|
||||
# 이름판
|
||||
d.rounded_rectangle([40, 150, 472, 360], radius=50, fill=(255, 250, 240), outline=(120, 70, 40), width=14)
|
||||
f = font(150)
|
||||
mask = Image.new("L", (S, S), 0)
|
||||
ImageDraw.Draw(mask).text((256, 250), "가게", font=f, fill=255, anchor="mm")
|
||||
outline = Image.new("L", (S, S), 0)
|
||||
ImageDraw.Draw(outline).text((256, 250), "가게", font=f, fill=255, anchor="mm", stroke_width=10, stroke_fill=255)
|
||||
img.paste((90, 40, 120, 255), (0, 0), outline)
|
||||
img.paste(rainbow_fill((S, S)), (0, 0), mask)
|
||||
for (x, y, r) in [(80, 110, 22), (430, 100, 28), (450, 400, 20), (70, 410, 26)]:
|
||||
star(d, x, y, r, (255, 255, 200))
|
||||
return img
|
||||
|
||||
|
||||
def star(d, cx, cy, r, color):
|
||||
pts = []
|
||||
for i in range(8):
|
||||
a = i * math.pi / 4 - math.pi / 2
|
||||
rr = r if i % 2 == 0 else r * 0.35
|
||||
pts.append((cx + rr * math.cos(a), cy + rr * math.sin(a)))
|
||||
d.polygon(pts, fill=color)
|
||||
|
||||
|
||||
def house(d, x0, y0, x1, y1, wall, trim, door):
|
||||
d.rectangle([x0, y0, x1, y1], fill=wall, outline=trim, width=10)
|
||||
cx = (x0 + x1) / 2
|
||||
d.rounded_rectangle([cx - 40, y1 - 110, cx + 40, y1], radius=18, fill=door, outline=trim, width=8)
|
||||
for wx in (x0 + 30, x1 - 110):
|
||||
d.rounded_rectangle([wx, y0 + 40, wx + 80, y0 + 110], radius=12, fill=(200, 235, 255), outline=trim, width=8)
|
||||
|
||||
|
||||
def candy_design():
|
||||
img = background((255, 200, 230), (255, 130, 180))
|
||||
d = ImageDraw.Draw(img)
|
||||
house(d, 96, 230, 416, 450, (255, 210, 232), (255, 100, 160), (255, 140, 190))
|
||||
# 줄무늬 차양
|
||||
for i in range(8):
|
||||
col = (255, 110, 165) if i % 2 == 0 else (255, 255, 255)
|
||||
d.polygon([(80 + i * 44, 180), (124 + i * 44, 180), (124 + i * 44, 240), (80 + i * 44, 240)], fill=col)
|
||||
d.rounded_rectangle([80, 170, 432, 250], radius=20, outline=(220, 70, 130), width=10)
|
||||
# 하트 간판
|
||||
d.ellipse([200, 70, 262, 132], fill=(255, 70, 130))
|
||||
d.ellipse([250, 70, 312, 132], fill=(255, 70, 130))
|
||||
d.polygon([(204, 112), (308, 112), (256, 170)], fill=(255, 70, 130))
|
||||
# 막대사탕
|
||||
for x in (50, 462):
|
||||
d.line([(x, 470), (x, 330)], fill=(255, 255, 255), width=12)
|
||||
d.ellipse([x - 40, 270, x + 40, 350], fill=(150, 110, 255), outline=(255, 255, 255), width=8)
|
||||
for (x, y, r) in [(120, 90, 18), (400, 80, 24), (440, 200, 14)]:
|
||||
star(d, x, y, r, (255, 255, 255))
|
||||
return img
|
||||
|
||||
|
||||
def hanok_design():
|
||||
img = background((255, 225, 170), (230, 150, 90))
|
||||
d = ImageDraw.Draw(img)
|
||||
house(d, 110, 250, 402, 450, (248, 238, 216), (95, 60, 40), (150, 100, 60))
|
||||
# 나무 기둥
|
||||
for x in (110, 256, 402):
|
||||
d.rectangle([x - 10, 250, x + 10, 450], fill=(95, 60, 40))
|
||||
# 기와지붕(처마가 위로 휜 모양)
|
||||
roof = [(40, 250), (70, 215), (140, 150), (372, 150), (442, 215), (472, 250), (420, 235), (256, 230), (92, 235)]
|
||||
d.polygon(roof, fill=(60, 66, 80), outline=(30, 34, 42))
|
||||
d.line([(140, 150), (372, 150)], fill=(30, 34, 42), width=14)
|
||||
for i in range(9):
|
||||
x = 110 + i * 37
|
||||
d.line([(x, 160), (x - 8, 225)], fill=(85, 92, 108), width=6)
|
||||
# 등롱
|
||||
for x in (60, 452):
|
||||
d.line([(x, 250), (x, 290)], fill=(40, 30, 20), width=5)
|
||||
d.ellipse([x - 32, 285, x + 32, 365], fill=(225, 50, 40), outline=(120, 20, 20), width=6)
|
||||
d.line([(x - 30, 325), (x + 30, 325)], fill=(255, 200, 80), width=4)
|
||||
return img
|
||||
|
||||
|
||||
def face(d, cx, cy, r, skin=(255, 220, 190)):
|
||||
d.ellipse([cx - r, cy - r, cx + r, cy + r], fill=skin, outline=(90, 50, 30), width=max(4, r // 8))
|
||||
d.ellipse([cx - r * 0.4 - 6, cy - r * 0.15 - 6, cx - r * 0.4 + 6, cy - r * 0.15 + 6], fill=(40, 25, 20))
|
||||
d.ellipse([cx + r * 0.4 - 6, cy - r * 0.15 - 6, cx + r * 0.4 + 6, cy - r * 0.15 + 6], fill=(40, 25, 20))
|
||||
d.arc([cx - r * 0.45, cy - r * 0.2, cx + r * 0.45, cy + r * 0.5], 20, 160, fill=(150, 50, 40), width=6)
|
||||
|
||||
|
||||
def rush():
|
||||
img = background((120, 230, 180), (40, 170, 130))
|
||||
d = ImageDraw.Draw(img)
|
||||
for i, (x, y, r, skin) in enumerate([(330, 200, 70, (255, 220, 190)), (210, 290, 64, (230, 180, 140)),
|
||||
(350, 380, 58, (200, 150, 110))]):
|
||||
for k in range(3):
|
||||
d.line([(x - r - 30 - k * 10, y - 25 + k * 25), (x - r - 110 - k * 10, y - 25 + k * 25)],
|
||||
fill=(255, 255, 255), width=12)
|
||||
face(d, x, y, r, skin)
|
||||
outlined(d, (120, 120), "x2", font(140), (255, 240, 80), (20, 100, 70), 12)
|
||||
return img
|
||||
|
||||
|
||||
def kick():
|
||||
img = background((255, 170, 120), (235, 90, 70))
|
||||
d = ImageDraw.Draw(img)
|
||||
# 오른쪽 우리 가게, 왼쪽에서 손님이 화살표를 따라 옴
|
||||
d.rectangle([300, 230, 470, 430], fill=(255, 245, 225), outline=(120, 60, 40), width=10)
|
||||
d.polygon([(280, 240), (385, 150), (490, 240)], fill=(255, 90, 120), outline=(120, 60, 40))
|
||||
d.rounded_rectangle([355, 330, 415, 430], radius=12, fill=(255, 190, 90), outline=(120, 60, 40), width=8)
|
||||
arrow = [(70, 320), (210, 320), (210, 280), (280, 345), (210, 410), (210, 370), (70, 370)]
|
||||
d.polygon(arrow, fill=(255, 255, 255), outline=(150, 50, 30))
|
||||
face(d, 110, 200, 62)
|
||||
face(d, 215, 160, 50, (230, 180, 140))
|
||||
return img
|
||||
|
||||
|
||||
def promote_ad():
|
||||
img = background((255, 230, 110), (255, 160, 60))
|
||||
d = ImageDraw.Draw(img)
|
||||
horn = [(120, 220), (330, 110), (330, 400), (120, 290)]
|
||||
d.polygon(horn, fill=(255, 90, 120), outline=(120, 30, 50))
|
||||
d.rounded_rectangle([70, 205, 140, 305], radius=16, fill=(255, 255, 255), outline=(120, 30, 50), width=8)
|
||||
d.line([(150, 300), (190, 400)], fill=(120, 30, 50), width=22)
|
||||
for k, r in enumerate((60, 110, 160)):
|
||||
d.arc([330 - r, 255 - r, 330 + r, 255 + r], -40, 40, fill=(255, 255, 255), width=14)
|
||||
for (x, y, r) in [(420, 90, 22), (450, 420, 18), (80, 100, 16)]:
|
||||
star(d, x, y, r, (255, 255, 255))
|
||||
return img
|
||||
|
||||
|
||||
def main():
|
||||
os.makedirs(OUT, exist_ok=True)
|
||||
game_icon().save(os.path.join(OUT, "game_icon.png"))
|
||||
thumbnail().save(os.path.join(OUT, "thumbnail_1.png"))
|
||||
print(os.path.join(OUT, "game_icon.png"), os.path.join(OUT, "thumbnail_1.png"))
|
||||
for name, fn in [("double_money", double_money), ("money_boost", money_boost), ("rainbow_name", rainbow_name),
|
||||
("candy_design", candy_design), ("hanok_design", hanok_design), ("rush", rush),
|
||||
("kick", kick), ("promote_ad", promote_ad)]:
|
||||
path = os.path.join(OUT, name + ".png")
|
||||
fn().save(path)
|
||||
print(path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
22
bunsik-tycoon/tools/check.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
# 코드 스타일·린트·타입 검사·단위 테스트·빌드를 한 번에 돌립니다. 실패하면 0이 아닌 값으로 끝납니다.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
export PATH="$HOME/.rokit/bin:$PATH"
|
||||
|
||||
stylua --check src tests tools
|
||||
selene src
|
||||
mkdir -p .cache build
|
||||
if [ ! -s .cache/globalTypes.d.luau ]; then
|
||||
curl -sfL https://raw.githubusercontent.com/JohnnyMorganz/luau-lsp/main/scripts/globalTypes.d.luau -o .cache/globalTypes.d.luau
|
||||
fi
|
||||
rojo sourcemap default.project.json -o .cache/sourcemap.json
|
||||
out=$(luau-lsp analyze --platform=roblox --sourcemap=.cache/sourcemap.json \
|
||||
--definitions=@roblox=.cache/globalTypes.d.luau --ignore="vendor/**" src 2>&1 | grep -v '^\[' || true)
|
||||
if [ -n "$out" ]; then
|
||||
echo "$out"
|
||||
exit 1
|
||||
fi
|
||||
for t in tests/*.spec.luau; do lune run "$t"; done
|
||||
rojo build default.project.json -o build/BunsikTycoon.rbxl
|
||||
echo "check: OK"
|
||||
240
bunsik-tycoon/tools/cloud.py
Normal file
@@ -0,0 +1,240 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Open Cloud 도구: 게임 파일 업로드, 로블록스 서버에서 Luau 실행.
|
||||
|
||||
python3 tools/cloud.py publish build/BunsikTycoon.rbxl [--published]
|
||||
python3 tools/cloud.py run script.luau [--version N] [--out file] # 기본: 가장 최근 저장 버전
|
||||
python3 tools/cloud.py products # 게임패스·개발자 상품 만들기(이미 있으면 건너뜀)
|
||||
python3 tools/cloud.py place # 서버 인원 6명, 설명 설정
|
||||
python3 tools/cloud.py audio sfx/coin.ogg "이름" # 효과음 업로드, 에셋 ID 출력
|
||||
python3 tools/cloud.py image art/kitchen.png "이름" # 그림 업로드, 에셋 ID 출력
|
||||
|
||||
API 키는 ~/.config/ejclaw/secrets.json 의 roblox.opencloud/bunsik-tycoon 에서 읽습니다.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
UNIVERSE = 10770390863
|
||||
CREATOR_USER = 4054147118 # tkrmagid
|
||||
PLACE = 98118751156219
|
||||
SECRETS = os.path.expanduser("~/.config/ejclaw/secrets.json")
|
||||
|
||||
|
||||
def api_key():
|
||||
with open(SECRETS) as f:
|
||||
return json.load(f)["credentials"]["roblox.opencloud/bunsik-tycoon"]["token"]
|
||||
|
||||
|
||||
def request(method, url, body=None, ctype="application/json", tries=5):
|
||||
data = body
|
||||
if body is not None and ctype == "application/json":
|
||||
data = json.dumps(body).encode()
|
||||
for attempt in range(tries):
|
||||
req = urllib.request.Request(url, data=data, method=method)
|
||||
req.add_header("x-api-key", api_key())
|
||||
if data is not None:
|
||||
req.add_header("Content-Type", ctype)
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=120) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
except urllib.error.HTTPError as e:
|
||||
msg = e.read().decode(errors="replace")
|
||||
if e.code in (429, 500, 502, 503, 504) and attempt < tries - 1:
|
||||
time.sleep(5 * (attempt + 1))
|
||||
continue
|
||||
raise SystemExit(f"HTTP {e.code} {method} {url}\n{msg}")
|
||||
|
||||
|
||||
def publish(path, published=False):
|
||||
vt = "Published" if published else "Saved"
|
||||
with open(path, "rb") as f:
|
||||
body = f.read()
|
||||
url = f"https://apis.roblox.com/universes/v1/{UNIVERSE}/places/{PLACE}/versions?versionType={vt}"
|
||||
res = request("POST", url, body, "application/octet-stream")
|
||||
return res["versionNumber"]
|
||||
|
||||
|
||||
def run(script, version=None, timeout_s=300, binary_out=None):
|
||||
base = f"https://apis.roblox.com/cloud/v2/universes/{UNIVERSE}/places/{PLACE}"
|
||||
if version:
|
||||
base += f"/versions/{version}"
|
||||
body = {"script": script, "timeout": f"{timeout_s}s"}
|
||||
if binary_out:
|
||||
body["enableBinaryOutput"] = True
|
||||
task = request("POST", base + "/luau-execution-session-tasks", body)
|
||||
path = task["path"]
|
||||
while task.get("state") not in ("COMPLETE", "FAILED", "CANCELLED"):
|
||||
time.sleep(3)
|
||||
task = request("GET", f"https://apis.roblox.com/cloud/v2/{path}")
|
||||
if binary_out and task.get("binaryOutputUri"):
|
||||
with urllib.request.urlopen(task["binaryOutputUri"], timeout=120) as r, open(binary_out, "wb") as f:
|
||||
f.write(r.read())
|
||||
logs = request("GET", f"https://apis.roblox.com/cloud/v2/{path}/logs?maxPageSize=10000")
|
||||
lines = []
|
||||
for page in logs.get("luauExecutionSessionTaskLogs", []):
|
||||
lines.extend(page.get("messages", []))
|
||||
return task, lines
|
||||
|
||||
|
||||
def multipart(fields, files):
|
||||
boundary = "----bunsik" + str(int(time.time() * 1000))
|
||||
out = b""
|
||||
for k, v in fields.items():
|
||||
out += f"--{boundary}\r\nContent-Disposition: form-data; name=\"{k}\"\r\n\r\n{v}\r\n".encode()
|
||||
for k, path in files.items():
|
||||
with open(path, "rb") as f:
|
||||
data = f.read()
|
||||
name = os.path.basename(path)
|
||||
out += (f"--{boundary}\r\nContent-Disposition: form-data; name=\"{k}\"; filename=\"{name}\"\r\n"
|
||||
f"Content-Type: image/png\r\n\r\n").encode() + data + b"\r\n"
|
||||
out += f"--{boundary}--\r\n".encode()
|
||||
return out, f"multipart/form-data; boundary={boundary}"
|
||||
|
||||
|
||||
ART = os.path.join(os.path.dirname(__file__), "..", "art")
|
||||
PRODUCTS = [
|
||||
# (종류, 이름, 설명, 가격, 그림, Products.luau 키)
|
||||
("game-passes", "Double Money (2배 수익)",
|
||||
"All sales are doubled forever! 모든 판매 금액이 영원히 2배!", 199, "double_money.png", "DOUBLE_MONEY_PASS"),
|
||||
("developer-products", "Money Boost (돈 부스트)",
|
||||
"Get 10 minutes of your current sales right now. 지금 매출 10분치를 바로 받아요.", 25, "money_boost.png",
|
||||
"MONEY_BOOST_PRODUCT"),
|
||||
("game-passes", "Rainbow Shop Name (무지개 가게 이름)",
|
||||
"Your shop name shines in rainbow colors for everyone! 가게 이름이 무지개색으로 반짝여요!", 99,
|
||||
"rainbow_name.png", "RAINBOW_NAME_PASS"),
|
||||
("game-passes", "Candy Castle Design (사탕 궁전 디자인)",
|
||||
"A pastel candy shop with hearts and lollipops. 하트와 막대사탕이 있는 사탕 궁전 가게 디자인", 149,
|
||||
"candy_design.png", "CANDY_DESIGN_PASS"),
|
||||
("game-passes", "Hanok Design (한옥 분식집 디자인)",
|
||||
"A traditional Korean hanok shop with a tiled roof and lanterns. 기와지붕과 등롱이 있는 한옥 가게 디자인", 149,
|
||||
"hanok_design.png", "HANOK_DESIGN_PASS"),
|
||||
("developer-products", "Customer Rush (손님 러시)",
|
||||
"Customers come twice as fast for 10 minutes. 10분 동안 손님이 2배 빨리 와요.", 15, "rush.png",
|
||||
"RUSH_PRODUCT"),
|
||||
("developer-products", "Bring Customers (옆 가게 손님 데려오기)",
|
||||
"Customers waiting at a neighbor shop come to your shop. 옆 가게에서 기다리던 손님이 우리 가게로 와요.", 15,
|
||||
"kick.png", "KICK_PRODUCT"),
|
||||
("developer-products", "Promotion Ad Reward (홍보 광고 보상)",
|
||||
"Reward for watching an ad: neighbor customers visit your shop. 광고를 보면 옆 가게 손님이 와요.", 5,
|
||||
"promote_ad.png", "PROMOTE_AD_PRODUCT"),
|
||||
]
|
||||
|
||||
|
||||
def products():
|
||||
found = {}
|
||||
for kind, name, desc, price, image, key in PRODUCTS:
|
||||
if kind == "game-passes":
|
||||
base = f"https://apis.roblox.com/game-passes/v1/universes/{UNIVERSE}/game-passes"
|
||||
listing = request("GET", base + "/creator?pageSize=100")
|
||||
items = listing.get("gamePasses", [])
|
||||
id_key = "gamePassId"
|
||||
else:
|
||||
base = f"https://apis.roblox.com/developer-products/v2/universes/{UNIVERSE}/developer-products"
|
||||
listing = request("GET", base + "/creator?pageSize=100")
|
||||
items = listing.get("developerProducts", [])
|
||||
id_key = "productId"
|
||||
existing = [i for i in items if i.get("name") == name]
|
||||
if existing:
|
||||
found[key] = existing[0][id_key]
|
||||
print(f"{key}: 이미 있음 {found[key]}")
|
||||
continue
|
||||
body, ctype = multipart(
|
||||
{"name": name, "description": desc, "price": str(price), "isForSale": "true",
|
||||
"isRegionalPricingEnabled": "false"},
|
||||
{"imageFile": os.path.join(ART, image)},
|
||||
)
|
||||
res = request("POST", base, body, ctype)
|
||||
found[key] = res[id_key]
|
||||
print(f"{key}: 만듦 {found[key]}")
|
||||
return found
|
||||
|
||||
|
||||
def place():
|
||||
url = (f"https://apis.roblox.com/cloud/v2/universes/{UNIVERSE}/places/{PLACE}"
|
||||
"?updateMask=serverSize,description")
|
||||
body = {
|
||||
"serverSize": 6,
|
||||
"description": "떡볶이 포장마차에서 시작해 분식 제국을 키우는 타이쿤! "
|
||||
"Grow your tiny tteokbokki street stall into a K-food empire!",
|
||||
}
|
||||
return request("PATCH", url, body)
|
||||
|
||||
|
||||
def upload_audio(path, name, asset_type="Audio", mime="audio/ogg",
|
||||
description="Bunsik Tycoon sound effect (synthesized, original)."):
|
||||
meta = {
|
||||
"assetType": asset_type,
|
||||
"displayName": name,
|
||||
"description": description,
|
||||
"creationContext": {"creator": {"userId": str(CREATOR_USER)}},
|
||||
}
|
||||
boundary = "----bunsik" + str(int(time.time() * 1000))
|
||||
with open(path, "rb") as f:
|
||||
data = f.read()
|
||||
body = (f"--{boundary}\r\nContent-Disposition: form-data; name=\"request\"\r\n"
|
||||
f"Content-Type: application/json\r\n\r\n{json.dumps(meta)}\r\n").encode()
|
||||
body += (f"--{boundary}\r\nContent-Disposition: form-data; name=\"fileContent\"; "
|
||||
f"filename=\"{os.path.basename(path)}\"\r\nContent-Type: {mime}\r\n\r\n").encode()
|
||||
body += data + f"\r\n--{boundary}--\r\n".encode()
|
||||
op = request("POST", "https://apis.roblox.com/assets/v1/assets", body, f"multipart/form-data; boundary={boundary}")
|
||||
for _ in range(60):
|
||||
if op.get("done"):
|
||||
break
|
||||
time.sleep(3)
|
||||
op = request("GET", f"https://apis.roblox.com/assets/v1/{op['path']}")
|
||||
if op.get("error"):
|
||||
raise SystemExit(f"업로드 실패: {op['error']}")
|
||||
return op.get("response", {}).get("assetId")
|
||||
|
||||
|
||||
def asset_status(asset_id):
|
||||
return request("GET", f"https://apis.roblox.com/assets/v1/assets/{asset_id}?readMask=moderationResult,state")
|
||||
|
||||
|
||||
def main(argv):
|
||||
if argv[:1] == ["audio"]:
|
||||
print(upload_audio(argv[1], argv[2]))
|
||||
return 0
|
||||
if argv[:1] == ["image"]:
|
||||
# 그림 업로드(화면 UI 그림 모음). 에셋 ID 출력
|
||||
print(upload_audio(argv[1], argv[2], "Image", "image/png", "Bunsik Tycoon UI art (drawn in code, original)."))
|
||||
return 0
|
||||
if argv[:1] == ["asset"]:
|
||||
print(json.dumps(asset_status(argv[1]), ensure_ascii=False))
|
||||
return 0
|
||||
if argv[:1] == ["products"]:
|
||||
print(json.dumps(products()))
|
||||
return 0
|
||||
if argv[:1] == ["place"]:
|
||||
print(json.dumps(place(), ensure_ascii=False))
|
||||
return 0
|
||||
if len(argv) >= 2 and argv[0] == "publish":
|
||||
v = publish(argv[1], "--published" in argv)
|
||||
print(f"version {v}")
|
||||
return 0
|
||||
if len(argv) >= 2 and argv[0] == "run":
|
||||
version = None
|
||||
if "--version" in argv:
|
||||
version = int(argv[argv.index("--version") + 1])
|
||||
with open(argv[1]) as f:
|
||||
script = f.read()
|
||||
out = argv[argv.index("--out") + 1] if "--out" in argv else None
|
||||
task, lines = run(script, version, binary_out=out)
|
||||
for line in lines:
|
||||
print(line)
|
||||
print(f"state: {task['state']}")
|
||||
if task["state"] == "COMPLETE":
|
||||
print("output:", json.dumps(task.get("output", {}), ensure_ascii=False))
|
||||
return 0
|
||||
print("error:", json.dumps(task.get("error", {}), ensure_ascii=False))
|
||||
return 1
|
||||
print(__doc__)
|
||||
return 2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
@@ -1,93 +0,0 @@
|
||||
"""분식집 타이쿤 첫 10분 경제 시뮬레이터.
|
||||
|
||||
ECONOMY.md 표의 숫자를 바꾸면 이 파일의 표도 같이 바꾸고 다시 돌려서
|
||||
구매 시점이 목표 범위에 드는지 확인한다.
|
||||
|
||||
python3 bunsik-tycoon/tools/economy_sim.py # 기본
|
||||
python3 bunsik-tycoon/tools/economy_sim.py --x2 # 2배 수익 게임패스
|
||||
|
||||
모델(1초 단위, 결정적):
|
||||
- 손님은 SPAWN초마다 1명 오고, 빈자리가 없으면 돌아간다.
|
||||
- 플레이어는 한 번에 한 접시: 조리(cook초) + 왕복(WALK초) 후 서빙.
|
||||
- 접시가 도착하면 바로 계산되고, 손님은 EAT초 먹고 나간다. 자리는 그때 빈다.
|
||||
- 알바생을 고용하면 조리는 알바생이 하고 플레이어는 나르기만 한다.
|
||||
- 돈이 다음 구매 비용 이상이 되면 즉시 산다(가장 빠른 플레이어 기준).
|
||||
"""
|
||||
import sys
|
||||
|
||||
WALK = 5 # 조리대 -> 테이블 -> 조리대 왕복(초)
|
||||
EAT = 6 # 먹는 시간(초)
|
||||
|
||||
MENUS = {"떡볶이": 10, "김밥": 20, "순대": 35} # 한 접시 기본 가격
|
||||
|
||||
# (이름, 비용, 효과) seats=테이블 수, spawn=손님 간격(초), cook=조리 시간(초),
|
||||
# price=가격 배율, helper=알바생(조리 자동)
|
||||
PURCHASES = [
|
||||
("테이블 2", 10, {"seats": 2}),
|
||||
("김밥 해금", 40, {"menu": "김밥"}),
|
||||
("간판 Lv1", 70, {"spawn": 5}),
|
||||
("화구 Lv1", 90, {"cook": 1.5}),
|
||||
("테이블 3", 120, {"seats": 3}),
|
||||
("순대 해금", 160, {"menu": "순대"}),
|
||||
("양념 비법 Lv1", 240, {"price": 1.5}),
|
||||
("알바생 고용", 360, {"helper": True}),
|
||||
("테이블 4", 480, {"seats": 4, "spawn": 4}),
|
||||
("실내 분식집 확장", 600, {}),
|
||||
]
|
||||
|
||||
|
||||
def simulate(mult=1.0, limit=1200):
|
||||
st = {"seats": 1, "spawn": 6, "cook": 2.5, "helper": False, "price": 1.0,
|
||||
"menus": ["떡볶이"]}
|
||||
money = 0.0
|
||||
t = 0
|
||||
next_spawn = 0
|
||||
waiting = [] # 주문하고 기다리는 손님 수(카운트)
|
||||
eating = [] # 식사 끝나는 시각 목록
|
||||
busy_until = 0 # 들고 있는 접시가 손님에게 도착하는 시각
|
||||
carrying = None # 들고 있는 접시 가격
|
||||
menu_i = 0
|
||||
log = []
|
||||
nxt = 0
|
||||
while t < limit and nxt < len(PURCHASES):
|
||||
# 식사 끝난 손님 퇴장(자리 반환)
|
||||
eating = [e for e in eating if e > t]
|
||||
# 손님 입장
|
||||
if t >= next_spawn:
|
||||
if len(waiting) + len(eating) + (carrying is not None) < st["seats"]:
|
||||
waiting.append(t)
|
||||
next_spawn = t + st["spawn"]
|
||||
# 배달 완료 -> 계산
|
||||
if carrying is not None and t >= busy_until:
|
||||
money += carrying * st["price"] * mult
|
||||
eating.append(t + EAT)
|
||||
carrying = None
|
||||
# 다음 접시 시작
|
||||
if carrying is None and waiting:
|
||||
waiting.pop(0)
|
||||
cook = 0 if st["helper"] else st["cook"]
|
||||
busy_until = t + cook + WALK
|
||||
carrying = MENUS[st["menus"][menu_i % len(st["menus"])]]
|
||||
menu_i += 1
|
||||
# 구매
|
||||
name, cost, eff = PURCHASES[nxt]
|
||||
if money >= cost:
|
||||
money -= cost
|
||||
if "menu" in eff:
|
||||
st["menus"].append(eff["menu"])
|
||||
for k in ("seats", "spawn", "cook", "helper", "price"):
|
||||
if k in eff:
|
||||
st[k] = eff[k]
|
||||
log.append((t, name, cost))
|
||||
nxt += 1
|
||||
t += 1
|
||||
return log
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
mult = 2.0 if "--x2" in sys.argv else 1.0
|
||||
prev = 0
|
||||
print(f"수익 배율 x{mult:g}")
|
||||
for t, name, cost in simulate(mult):
|
||||
print(f"{t//60:2d}:{t%60:02d} (+{t-prev:3d}s) {name:<12} {cost:>5}원")
|
||||
prev = t
|
||||
489
bunsik-tycoon/tools/gui_render.py
Normal file
@@ -0,0 +1,489 @@
|
||||
#!/usr/bin/env python3
|
||||
"""화면 UI 미리보기 그리기: 로블록스 서버에서 만든 ScreenGui를 JSON으로 덤프한 것(tests/cloud/dump_gui.luau)을
|
||||
cairo로 그립니다. 서버에서는 실제 화면을 볼 수 없어서 배치·색·글자 크기를 눈으로 확인하는 용도입니다.
|
||||
로블록스 렌더러와 똑같지는 않습니다(글꼴 대체, 글자 크기 맞춤, 3D 배경 없음).
|
||||
|
||||
지원: Frame/TextLabel/TextButton/ImageLabel/ImageButton/ScrollingFrame, UDim2·AnchorPoint·Rotation·ZIndex,
|
||||
UICorner, UIStroke(테두리·글자), UIGradient(색·투명도·회전·오프셋), UIPadding, UIListLayout, UIScale,
|
||||
UITextSizeConstraint, SizeConstraint, TextScaled/TextWrapped/정렬, ImageRectOffset/Size, ClipsDescendants.
|
||||
|
||||
python3 tools/gui_render.py dump.json out_dir [--bg scene.png]
|
||||
"""
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
import sys
|
||||
|
||||
import ctypes
|
||||
|
||||
import cairo
|
||||
|
||||
ROOT_UNUSED = None
|
||||
|
||||
|
||||
class _Rect(ctypes.Structure):
|
||||
_fields_ = [("x", ctypes.c_int), ("y", ctypes.c_int), ("width", ctypes.c_int), ("height", ctypes.c_int)]
|
||||
|
||||
|
||||
class PangoLib:
|
||||
"""python3-gi-cairo가 없어서 libpangocairo를 ctypes로 직접 부릅니다(쓰는 함수만)."""
|
||||
|
||||
SCALE = 1024
|
||||
|
||||
def __init__(self):
|
||||
self.pc = ctypes.CDLL("libpangocairo-1.0.so.0")
|
||||
self.p = ctypes.CDLL("libpango-1.0.so.0")
|
||||
self.g = ctypes.CDLL("libgobject-2.0.so.0")
|
||||
vp, ci, cs = ctypes.c_void_p, ctypes.c_int, ctypes.c_char_p
|
||||
for lib, name, res, args in (
|
||||
(self.pc, "pango_cairo_create_layout", vp, [vp]),
|
||||
(self.pc, "pango_cairo_show_layout", None, [vp, vp]),
|
||||
(self.pc, "pango_cairo_layout_path", None, [vp, vp]),
|
||||
(self.p, "pango_layout_set_text", None, [vp, cs, ci]),
|
||||
(self.p, "pango_layout_set_width", None, [vp, ci]),
|
||||
(self.p, "pango_layout_set_wrap", None, [vp, ci]),
|
||||
(self.p, "pango_layout_set_alignment", None, [vp, ci]),
|
||||
(self.p, "pango_layout_set_font_description", None, [vp, vp]),
|
||||
(self.p, "pango_layout_get_pixel_extents", None, [vp, ctypes.POINTER(_Rect), ctypes.POINTER(_Rect)]),
|
||||
(self.p, "pango_layout_get_line_count", ci, [vp]),
|
||||
(self.p, "pango_font_description_from_string", vp, [cs]),
|
||||
(self.p, "pango_font_description_set_weight", None, [vp, ci]),
|
||||
(self.p, "pango_font_description_set_absolute_size", None, [vp, ctypes.c_double]),
|
||||
(self.p, "pango_font_description_free", None, [vp]),
|
||||
(self.g, "g_object_unref", None, [vp]),
|
||||
):
|
||||
f = getattr(lib, name)
|
||||
f.restype = res
|
||||
f.argtypes = args
|
||||
|
||||
@staticmethod
|
||||
def cr(ctx):
|
||||
# pycairo Context 객체 안의 cairo_t 포인터(PyObject 머리 16바이트 다음)
|
||||
return ctypes.c_void_p.from_address(id(ctx) + 16).value
|
||||
|
||||
|
||||
PANGO = PangoLib()
|
||||
ALIGN = {"Left": 0, "Center": 1, "Right": 2}
|
||||
WEIGHT = {"SemiBold": 600, "Bold": 700, "Heavy": 900, "Black": 900}
|
||||
|
||||
|
||||
class Layout:
|
||||
def __init__(self, ctx, family, weight, size, text, width, wrap, align):
|
||||
P = PANGO
|
||||
self.ctx = ctx
|
||||
self.ptr = P.pc.pango_cairo_create_layout(P.cr(ctx))
|
||||
desc = P.p.pango_font_description_from_string(f"{family}, {FALLBACK}".encode())
|
||||
P.p.pango_font_description_set_weight(desc, weight)
|
||||
P.p.pango_font_description_set_absolute_size(desc, max(1.0, size) * P.SCALE)
|
||||
P.p.pango_layout_set_font_description(self.ptr, desc)
|
||||
P.p.pango_font_description_free(desc)
|
||||
P.p.pango_layout_set_text(self.ptr, text.encode(), -1)
|
||||
if wrap:
|
||||
P.p.pango_layout_set_width(self.ptr, int(max(1, width) * P.SCALE))
|
||||
P.p.pango_layout_set_wrap(self.ptr, 2) # WORD_CHAR
|
||||
P.p.pango_layout_set_alignment(self.ptr, ALIGN.get(align, 1))
|
||||
|
||||
def extents(self):
|
||||
ink, logical = _Rect(), _Rect()
|
||||
PANGO.p.pango_layout_get_pixel_extents(self.ptr, ctypes.byref(ink), ctypes.byref(logical))
|
||||
return ink, logical
|
||||
|
||||
def lines(self):
|
||||
return PANGO.p.pango_layout_get_line_count(self.ptr)
|
||||
|
||||
def path(self, ctx):
|
||||
PANGO.pc.pango_cairo_layout_path(PANGO.cr(ctx), self.ptr)
|
||||
|
||||
def show(self, ctx):
|
||||
PANGO.pc.pango_cairo_show_layout(PANGO.cr(ctx), self.ptr)
|
||||
|
||||
def __del__(self):
|
||||
PANGO.g.g_object_unref(self.ptr)
|
||||
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
IMAGES = {} # rbxassetid 숫자 -> 로컬 png 경로 (Icons.luau의 ID와 art/ui_icons.png)
|
||||
|
||||
FONT_FAMILY = {
|
||||
"FredokaOne": "Fredoka SemiBold",
|
||||
"LuckiestGuy": "Luckiest Guy",
|
||||
"Bangers": "Luckiest Guy",
|
||||
"GothamBlack": "Noto Sans Black",
|
||||
"BuilderSans": "Noto Sans",
|
||||
"Montserrat": "Noto Sans",
|
||||
}
|
||||
# 한글·한자·이모지는 로블록스도 대체 글꼴로 그립니다.
|
||||
FALLBACK = "Noto Sans CJK KR, Noto Color Emoji"
|
||||
|
||||
|
||||
def surface_png(path):
|
||||
return cairo.ImageSurface.create_from_png(path)
|
||||
|
||||
|
||||
_img_cache = {}
|
||||
|
||||
|
||||
def image_surface(asset):
|
||||
num = "".join(ch for ch in str(asset) if ch.isdigit())
|
||||
path = IMAGES.get(num)
|
||||
if not path:
|
||||
return None
|
||||
if path not in _img_cache:
|
||||
_img_cache[path] = surface_png(path)
|
||||
return _img_cache[path]
|
||||
|
||||
|
||||
def udim(u, size, k):
|
||||
return u[0] * size + u[1] * k
|
||||
|
||||
|
||||
def round_rect(c, x, y, w, h, r):
|
||||
r = max(0, min(r, w / 2, h / 2))
|
||||
if r <= 0.01:
|
||||
c.rectangle(x, y, w, h)
|
||||
return
|
||||
c.new_sub_path()
|
||||
c.arc(x + w - r, y + r, r, -math.pi / 2, 0)
|
||||
c.arc(x + w - r, y + h - r, r, 0, math.pi / 2)
|
||||
c.arc(x + r, y + h - r, r, math.pi / 2, math.pi)
|
||||
c.arc(x + r, y + r, r, math.pi, 3 * math.pi / 2)
|
||||
c.close_path()
|
||||
|
||||
|
||||
def gradient_pattern(g, x, y, w, h, base, alpha):
|
||||
"""UIGradient를 cairo 패턴으로. base(색)·alpha(불투명도)에 곱합니다."""
|
||||
rot = math.radians(g.get("Rotation", 0))
|
||||
ox, oy = g.get("Offset", [0, 0])
|
||||
cx, cy = x + w / 2 + ox * w, y + h / 2 + oy * h
|
||||
dx, dy = math.cos(rot), math.sin(rot)
|
||||
# 회전된 방향으로 상자를 덮는 길이
|
||||
half = (abs(dx) * w + abs(dy) * h) / 2
|
||||
pat = cairo.LinearGradient(cx - dx * half, cy - dy * half, cx + dx * half, cy + dy * half)
|
||||
colors = g.get("Color") or [[0, [1, 1, 1]], [1, [1, 1, 1]]]
|
||||
trans = g.get("Transparency") or [[0, 0], [1, 0]]
|
||||
times = sorted(set([t for t, _ in colors] + [t for t, _ in trans]))
|
||||
|
||||
def at(seq, t):
|
||||
for i in range(len(seq) - 1):
|
||||
t0, v0 = seq[i]
|
||||
t1, v1 = seq[i + 1]
|
||||
if t0 <= t <= t1:
|
||||
f = 0 if t1 == t0 else (t - t0) / (t1 - t0)
|
||||
if isinstance(v0, list):
|
||||
return [v0[j] + (v1[j] - v0[j]) * f for j in range(3)]
|
||||
return v0 + (v1 - v0) * f
|
||||
return seq[-1][1] if t >= seq[-1][0] else seq[0][1]
|
||||
|
||||
for t in times:
|
||||
col = at(colors, t)
|
||||
tr = at(trans, t)
|
||||
pat.add_color_stop_rgba(t, base[0] * col[0], base[1] * col[1], base[2] * col[2], alpha * (1 - tr))
|
||||
return pat
|
||||
|
||||
|
||||
class Renderer:
|
||||
def __init__(self, c):
|
||||
self.c = c
|
||||
|
||||
# ---------------------------------------------------------------- 배치
|
||||
def children_rects(self, node, rect, k):
|
||||
"""자식 GuiObject의 (자식, x, y, w, h, k) 목록. UIListLayout·UIPadding·UIScale 반영."""
|
||||
x, y, w, h = rect
|
||||
pad = node.get("UIPadding")
|
||||
if pad:
|
||||
pl = udim(pad["Left"], w, k)
|
||||
pr = udim(pad["Right"], w, k)
|
||||
pt = udim(pad["Top"], h, k)
|
||||
pb = udim(pad["Bottom"], h, k)
|
||||
x, y, w, h = x + pl, y + pt, w - pl - pr, h - pt - pb
|
||||
out = []
|
||||
kids = [ch for ch in node.get("children", []) if ch.get("Visible", True)]
|
||||
for ch in kids:
|
||||
s = ch.get("UIScale", 1)
|
||||
sc = ch.get("SizeConstraint", "RelativeXY")
|
||||
cw = udim(ch["Size"][0], h if sc == "RelativeYY" else w, k) * s
|
||||
chh = udim(ch["Size"][1], w if sc == "RelativeXX" else h, k) * s
|
||||
ar = ch.get("UIAspectRatio")
|
||||
if ar:
|
||||
if cw / max(chh, 1e-6) > ar:
|
||||
cw = chh * ar
|
||||
else:
|
||||
chh = cw / ar
|
||||
out.append([ch, cw, chh, k * s])
|
||||
lay = node.get("UIListLayout")
|
||||
if lay:
|
||||
horiz = lay.get("FillDirection") == "Horizontal"
|
||||
gap = udim(lay.get("Padding", [0, 0]), w if horiz else h, k)
|
||||
items = sorted(out, key=lambda o: (o[0].get("LayoutOrder", 0), o[0].get("_i", 0))) \
|
||||
if lay.get("SortOrder") == "LayoutOrder" else sorted(out, key=lambda o: o[0].get("Name", ""))
|
||||
total = sum((o[1] if horiz else o[2]) for o in items) + gap * max(0, len(items) - 1)
|
||||
ha = lay.get("HorizontalAlignment", "Left")
|
||||
va = lay.get("VerticalAlignment", "Top")
|
||||
if horiz:
|
||||
cur = x + {"Left": 0, "Center": (w - total) / 2, "Right": w - total}[ha]
|
||||
else:
|
||||
cur = y + {"Top": 0, "Center": (h - total) / 2, "Bottom": h - total}[va]
|
||||
res = []
|
||||
for ch, cw, chh, kk in items:
|
||||
if horiz:
|
||||
cy = y + {"Top": 0, "Center": (h - chh) / 2, "Bottom": h - chh}[va]
|
||||
res.append((ch, cur, cy, cw, chh, kk))
|
||||
cur += cw + gap
|
||||
else:
|
||||
cx = x + {"Left": 0, "Center": (w - cw) / 2, "Right": w - cw}[ha]
|
||||
res.append((ch, cx, cur, cw, chh, kk))
|
||||
cur += chh + gap
|
||||
return res
|
||||
res = []
|
||||
for ch, cw, chh, kk in out:
|
||||
s = ch.get("UIScale", 1)
|
||||
# UIScale은 AnchorPoint를 기준으로 크기를 바꿉니다.
|
||||
bw, bh = cw / s, chh / s
|
||||
ax, ay = ch.get("AnchorPoint", [0, 0])
|
||||
px = x + udim(ch["Position"][0], w, k) - ax * bw
|
||||
py = y + udim(ch["Position"][1], h, k) - ay * bh
|
||||
px -= (cw - bw) * ax
|
||||
py -= (chh - bh) * ay
|
||||
res.append((ch, px, py, cw, chh, kk))
|
||||
return res
|
||||
|
||||
# ---------------------------------------------------------------- 그리기
|
||||
def draw_node(self, node, x, y, w, h, k):
|
||||
c = self.c
|
||||
c.save()
|
||||
rot = node.get("Rotation", 0)
|
||||
if rot:
|
||||
c.translate(x + w / 2, y + h / 2)
|
||||
c.rotate(math.radians(rot))
|
||||
c.translate(-(x + w / 2), -(y + h / 2))
|
||||
corner = node.get("UICorner")
|
||||
r = udim(corner, min(w, h), k) if corner else 0
|
||||
grad = node.get("UIGradient")
|
||||
bt = node.get("BackgroundTransparency", 1)
|
||||
if bt < 1 and node["ClassName"] not in ("ScreenGui",):
|
||||
base = node.get("BackgroundColor3", [1, 1, 1])
|
||||
round_rect(c, x, y, w, h, r)
|
||||
if grad:
|
||||
c.set_source(gradient_pattern(grad, x, y, w, h, base, 1 - bt))
|
||||
else:
|
||||
c.set_source_rgba(*base, 1 - bt)
|
||||
c.fill()
|
||||
img = node.get("Image")
|
||||
if img:
|
||||
self.draw_image(node, x, y, w, h, r, grad)
|
||||
if "Text" in node and node.get("Text"):
|
||||
self.draw_text(node, x, y, w, h, k, grad)
|
||||
for st in node.get("UIStrokes", []):
|
||||
if st.get("ApplyStrokeMode") == "Border" and st.get("Enabled", True):
|
||||
t = st["Thickness"] * k
|
||||
round_rect(c, x - t / 2, y - t / 2, w + t, h + t, r + t / 2 if r > 0 else 0)
|
||||
c.set_line_width(t)
|
||||
c.set_line_join(cairo.LINE_JOIN_ROUND)
|
||||
sg = st.get("UIGradient")
|
||||
if sg:
|
||||
c.set_source(gradient_pattern(sg, x, y, w, h, st["Color"], 1 - st.get("Transparency", 0)))
|
||||
else:
|
||||
c.set_source_rgba(*st["Color"], 1 - st.get("Transparency", 0))
|
||||
c.stroke()
|
||||
if node.get("ClipsDescendants") or node["ClassName"] == "ScrollingFrame":
|
||||
round_rect(c, x, y, w, h, r)
|
||||
c.clip()
|
||||
cpx, cpy = node.get("CanvasPosition", [0, 0])
|
||||
kids = self.children_rects(node, (x - cpx * k, y - cpy * k, w, h), k)
|
||||
kids.sort(key=lambda t: (t[0].get("ZIndex", 1), t[0].get("_i", 0)))
|
||||
for ch, cx, cy, cw, chh, kk in kids:
|
||||
self.draw_node(ch, cx, cy, cw, chh, kk)
|
||||
c.restore()
|
||||
|
||||
def draw_image(self, node, x, y, w, h, r, grad):
|
||||
surf = image_surface(node["Image"])
|
||||
c = self.c
|
||||
if surf is None:
|
||||
c.rectangle(x, y, w, h)
|
||||
c.set_source_rgba(1, 0, 1, 0.5)
|
||||
c.fill()
|
||||
return
|
||||
ox, oy = node.get("ImageRectOffset", [0, 0])
|
||||
sw, sh = node.get("ImageRectSize", [0, 0])
|
||||
if sw == 0 or sh == 0:
|
||||
sw, sh = surf.get_width(), surf.get_height()
|
||||
dw, dh = w, h
|
||||
if node.get("ScaleType") == "Fit":
|
||||
s = min(w / sw, h / sh)
|
||||
dw, dh = sw * s, sh * s
|
||||
dx, dy = x + (w - dw) / 2, y + (h - dh) / 2
|
||||
c.save()
|
||||
round_rect(c, x, y, w, h, r)
|
||||
c.clip()
|
||||
c.translate(dx, dy)
|
||||
c.scale(dw / sw, dh / sh)
|
||||
c.translate(-ox, -oy)
|
||||
alpha = 1 - node.get("ImageTransparency", 0)
|
||||
col = node.get("ImageColor3", [1, 1, 1])
|
||||
c.rectangle(ox, oy, sw, sh)
|
||||
c.clip()
|
||||
if col != [1, 1, 1] or grad:
|
||||
# 색 곱하기: 그림을 마스크로 쓰고 색을 곱한 그림을 그립니다.
|
||||
tmp = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(sw), int(sh))
|
||||
tc = cairo.Context(tmp)
|
||||
tc.set_source_surface(surf, -ox, -oy)
|
||||
tc.paint()
|
||||
tc.set_operator(cairo.OPERATOR_MULTIPLY)
|
||||
if grad:
|
||||
tc.set_source(gradient_pattern(grad, 0, 0, sw, sh, col, 1))
|
||||
else:
|
||||
tc.set_source_rgb(*col)
|
||||
tc.paint()
|
||||
tc.set_operator(cairo.OPERATOR_DEST_IN)
|
||||
tc.set_source_surface(surf, -ox, -oy)
|
||||
tc.paint()
|
||||
c.set_source_surface(tmp, ox, oy)
|
||||
else:
|
||||
c.set_source_surface(surf, 0, 0)
|
||||
c.get_source().set_filter(cairo.FILTER_GOOD)
|
||||
c.paint_with_alpha(alpha)
|
||||
c.restore()
|
||||
|
||||
def layout_text(self, node, size, width, wrap):
|
||||
fam = FONT_FAMILY.get(node.get("Font", "FredokaOne"), "Noto Sans")
|
||||
weight = WEIGHT.get(node.get("Weight", ""), 400)
|
||||
if fam.startswith("Fredoka"):
|
||||
weight = 600
|
||||
elif "Black" in fam:
|
||||
weight = 900
|
||||
align = node.get("TextXAlignment", "Center")
|
||||
return Layout(self.c, fam.replace(" SemiBold", "").replace(" Black", ""), weight, size, node["Text"], width,
|
||||
wrap, align)
|
||||
|
||||
def draw_text(self, node, x, y, w, h, k, grad):
|
||||
c = self.c
|
||||
pad = node.get("UIPadding")
|
||||
if pad:
|
||||
pl, pr = udim(pad["Left"], w, k), udim(pad["Right"], w, k)
|
||||
pt, pb = udim(pad["Top"], h, k), udim(pad["Bottom"], h, k)
|
||||
x, y, w, h = x + pl, y + pt, w - pl - pr, h - pt - pb
|
||||
wrap = node.get("TextWrapped", False) or node.get("TextScaled", False)
|
||||
maxsize = node.get("MaxTextSize", 100)
|
||||
if node.get("TextScaled"):
|
||||
lo, hi = 1, min(maxsize, 100) * k
|
||||
best = lo
|
||||
while hi - lo > 0.5:
|
||||
mid = (lo + hi) / 2
|
||||
lay = self.layout_text(node, mid, w, wrap)
|
||||
ink, logical = lay.extents()
|
||||
# 단어 중간에서 줄이 끊기면 안 맞는 것으로 봅니다(로블록스 TextScaled와 비슷하게).
|
||||
words_ok = lay.lines() <= max(1, len(node["Text"].split())) + node["Text"].count("\n")
|
||||
if logical.width <= w + 0.5 and logical.height <= h + 0.5 and words_ok:
|
||||
best = mid
|
||||
lo = mid
|
||||
else:
|
||||
hi = mid
|
||||
size = best
|
||||
else:
|
||||
size = node.get("TextSize", 14) * k
|
||||
lay = self.layout_text(node, size, w, wrap)
|
||||
ink, logical = lay.extents()
|
||||
ya = node.get("TextYAlignment", "Center")
|
||||
ty = y + {"Top": 0, "Center": (h - logical.height) / 2, "Bottom": h - logical.height}[ya]
|
||||
tx = x
|
||||
if not wrap:
|
||||
xa = node.get("TextXAlignment", "Center")
|
||||
tx = x + {"Left": 0, "Center": (w - logical.width) / 2, "Right": w - logical.width}[xa]
|
||||
c.save()
|
||||
c.move_to(tx, ty)
|
||||
lay.path(c)
|
||||
alpha = 1 - node.get("TextTransparency", 0)
|
||||
for st in node.get("UIStrokes", []):
|
||||
if st.get("ApplyStrokeMode", "Contextual") == "Contextual" and st.get("Enabled", True):
|
||||
c.set_line_width(st["Thickness"] * k * 2)
|
||||
c.set_line_join(cairo.LINE_JOIN_ROUND)
|
||||
c.set_source_rgba(*st["Color"], alpha * (1 - st.get("Transparency", 0)))
|
||||
c.stroke_preserve()
|
||||
if node.get("TextStrokeTransparency", 1) < 1:
|
||||
c.set_line_width(2 * k)
|
||||
c.set_source_rgba(*node.get("TextStrokeColor3", [0, 0, 0]), alpha * (1 - node["TextStrokeTransparency"]))
|
||||
c.stroke_preserve()
|
||||
c.new_path()
|
||||
c.restore()
|
||||
# 글자 채우기(이모지 색을 살리려고 path 대신 show_layout)
|
||||
c.save()
|
||||
col = node.get("TextColor3", [0, 0, 0])
|
||||
if grad and node.get("TextGradient", True):
|
||||
c.push_group()
|
||||
c.move_to(tx, ty)
|
||||
c.set_source_rgba(1, 1, 1, alpha)
|
||||
lay.show(c)
|
||||
mask = c.pop_group()
|
||||
c.set_source(gradient_pattern(grad, x, y, w, h, col, 1))
|
||||
c.mask(mask)
|
||||
else:
|
||||
c.move_to(tx, ty)
|
||||
c.set_source_rgba(*col, alpha)
|
||||
lay.show(c)
|
||||
c.restore()
|
||||
|
||||
|
||||
def render(dump, out, bg=None):
|
||||
W, H, inset = dump["width"], dump["height"], dump.get("inset", 0)
|
||||
surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(W), int(H + inset))
|
||||
c = cairo.Context(surf)
|
||||
if bg and os.path.exists(bg):
|
||||
b = surface_png(bg)
|
||||
c.save()
|
||||
c.scale(W / b.get_width(), (H + inset) / b.get_height())
|
||||
c.set_source_surface(b, 0, 0)
|
||||
c.paint()
|
||||
c.restore()
|
||||
else:
|
||||
g = cairo.LinearGradient(0, 0, 0, H + inset)
|
||||
g.add_color_stop_rgb(0, 0.55, 0.78, 0.95)
|
||||
g.add_color_stop_rgb(0.55, 0.75, 0.88, 0.98)
|
||||
g.add_color_stop_rgb(0.56, 0.42, 0.66, 0.36)
|
||||
g.add_color_stop_rgb(1, 0.33, 0.55, 0.28)
|
||||
c.set_source(g)
|
||||
c.paint()
|
||||
# 로블록스 상단 바(대략)
|
||||
if inset:
|
||||
c.set_source_rgba(0, 0, 0, 0.25)
|
||||
for i, x in enumerate((12, 60)):
|
||||
round_rect(c, x, 10, 40, 40, 10)
|
||||
c.fill()
|
||||
touch = dump.get("touch")
|
||||
if touch and dump.get("zones"):
|
||||
for z in dump["zones"].values():
|
||||
c.set_source_rgba(1, 1, 1, 0.12)
|
||||
c.rectangle(z["x"], z["y"] + inset, z["w"], z["h"])
|
||||
c.fill()
|
||||
# 조이스틱·점프 버튼 모양(대략)
|
||||
st = dump["zones"]["stick"]
|
||||
c.arc(st["x"] + 110, inset + H - 110, 60, 0, 2 * math.pi)
|
||||
c.set_source_rgba(0, 0, 0, 0.3)
|
||||
c.fill()
|
||||
jp = dump["zones"]["jump"]
|
||||
jr = min(jp["w"], jp["h"]) * 0.3
|
||||
c.arc(jp["x"] + jp["w"] * 0.55, inset + jp["y"] + jp["h"] * 0.55, jr, 0, 2 * math.pi)
|
||||
c.fill()
|
||||
r = Renderer(c)
|
||||
gui = dump["gui"]
|
||||
c.translate(0, inset)
|
||||
for ch, x, y, w, h, k in r.children_rects(gui, (0, 0, W, H), 1):
|
||||
r.draw_node(ch, x, y, w, h, k)
|
||||
surf.write_to_png(out)
|
||||
|
||||
|
||||
def main(argv):
|
||||
src, outdir = argv[0], argv[1]
|
||||
bg = argv[argv.index("--bg") + 1] if "--bg" in argv else None
|
||||
with open(src) as f:
|
||||
data = json.load(f)
|
||||
for num, path in data.get("images", {}).items():
|
||||
IMAGES[str(num)] = os.path.join(ROOT, path)
|
||||
os.makedirs(outdir, exist_ok=True)
|
||||
for shot in data["shots"]:
|
||||
out = os.path.join(outdir, shot["name"] + ".png")
|
||||
render(shot, out, bg)
|
||||
print(out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
||||
11
bunsik-tycoon/tools/hud_layout.luau
Normal file
@@ -0,0 +1,11 @@
|
||||
-- 화면 UI 배치를 JSON으로 출력합니다(tools/hud_preview.py가 그림으로 그림). lune run tools/hud_layout.luau 너비 높이 touch|pc
|
||||
local process = require("@lune/process")
|
||||
local serde = require("@lune/serde")
|
||||
local Layout = require("../src/client/Layout")
|
||||
|
||||
local w = tonumber(process.args[1]) or 750
|
||||
local h = tonumber(process.args[2]) or 332
|
||||
local touch = process.args[3] == "touch"
|
||||
local out = Layout.compute(w, h, touch, true) :: any
|
||||
out.zones = Layout.touchZones(w, h)
|
||||
print(serde.encode("json", out))
|
||||
90
bunsik-tycoon/tools/hud_preview.py
Normal file
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env python3
|
||||
"""화면 UI 배치 미리보기: 기기 화면 크기별로 UI 상자와 로블록스 조이스틱·점프 버튼 자리를 그립니다.
|
||||
실제 글자·색은 아니고 위치·크기만 맞습니다.
|
||||
|
||||
python3 tools/hud_preview.py out.png
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
DEVICES = [
|
||||
("iPhone SE", 667, 375 - 58, True),
|
||||
("iPhone 15", 844 - 94, 390 - 58, True),
|
||||
("Android 800x360", 800, 360 - 58, True),
|
||||
("iPad 1024x768", 1024, 768 - 58, True),
|
||||
("PC 1366x768", 1366, 768 - 58, False),
|
||||
]
|
||||
BOXES = [
|
||||
("money", "돈", (255, 130, 50)),
|
||||
("carry", "들고 있는 접시", (200, 160, 120)),
|
||||
("hint", "튜토리얼 안내", (255, 235, 120)),
|
||||
("toasts", "알림 자리", (120, 120, 150)),
|
||||
("card", "다음 업그레이드", (255, 248, 235)),
|
||||
("buy", "사기", (70, 190, 90)),
|
||||
("settings", "설정", (80, 140, 230)),
|
||||
("list", "업그레이드 목록", (255, 130, 50)),
|
||||
("double", "2배 수익", (150, 80, 220)),
|
||||
("boost", "돈 부스트", (240, 170, 30)),
|
||||
("promote", "홍보", (74, 172, 255)),
|
||||
("rush", "손님 러시", (255, 196, 48)),
|
||||
]
|
||||
|
||||
|
||||
def font(size):
|
||||
for path in ("/usr/share/fonts/truetype/nanum/NanumGothicBold.ttf",
|
||||
"/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc",
|
||||
"/usr/share/fonts/truetype/noto/NotoSansCJK-Bold.ttc"):
|
||||
if os.path.exists(path):
|
||||
return ImageFont.truetype(path, size)
|
||||
return ImageFont.load_default()
|
||||
|
||||
|
||||
def layout(w, h, touch):
|
||||
out = subprocess.run(["lune", "run", "tools/hud_layout.luau", str(w), str(h), "touch" if touch else "pc"],
|
||||
cwd=ROOT, capture_output=True, text=True, check=True).stdout
|
||||
return json.loads(out)
|
||||
|
||||
|
||||
def draw_device(name, w, h, touch):
|
||||
L = layout(w, h, touch)
|
||||
s = L["scale"]
|
||||
img = Image.new("RGB", (w, h + 30), (40, 40, 40))
|
||||
d = ImageDraw.Draw(img, "RGBA")
|
||||
d.rectangle([0, 30, w - 1, h + 29], fill=(110, 160, 110))
|
||||
d.text((6, 4), f"{name} UI 영역 {w}x{h} 배율 {s:.2f}", fill=(255, 255, 255), font=font(18))
|
||||
if touch:
|
||||
for key, label in (("stick", "조이스틱 자리"), ("jump", "점프 버튼 자리")):
|
||||
z = L["zones"][key]
|
||||
d.rectangle([z["x"], z["y"] + 30, z["x"] + z["w"], z["y"] + z["h"] + 30], fill=(255, 0, 0, 60),
|
||||
outline=(255, 60, 60), width=2)
|
||||
d.text((z["x"] + 6, z["y"] + z["h"] + 30 - 22), label, fill=(255, 220, 220), font=font(14))
|
||||
for key, label, color in BOXES:
|
||||
r = L[key]
|
||||
x0, y0 = r["x"] * s, r["y"] * s + 30
|
||||
x1, y1 = x0 + r["w"] * s, y0 + r["h"] * s
|
||||
alpha = 90 if key == "toasts" else 230
|
||||
d.rounded_rectangle([x0, y0, x1, y1], radius=6, fill=color + (alpha,), outline=(255, 255, 255), width=2)
|
||||
d.text((x0 + 4, y0 + 2), label, fill=(20, 20, 20), font=font(max(10, int(15 * s))))
|
||||
return img
|
||||
|
||||
|
||||
def main(argv):
|
||||
out = argv[1] if len(argv) > 1 else "hud_preview.png"
|
||||
imgs = [draw_device(*dev) for dev in DEVICES]
|
||||
width = max(i.width for i in imgs)
|
||||
sheet = Image.new("RGB", (width, sum(i.height + 10 for i in imgs)), (25, 25, 25))
|
||||
y = 0
|
||||
for i in imgs:
|
||||
sheet.paste(i, (0, y))
|
||||
y += i.height + 10
|
||||
sheet.save(out)
|
||||
print(out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
||||
1127
bunsik-tycoon/tools/icons.py
Normal file
322
bunsik-tycoon/tools/kitchen_art.py
Normal file
@@ -0,0 +1,322 @@
|
||||
#!/usr/bin/env python3
|
||||
"""요리 화면의 큰 그림(조리 도구, 마스코트 떡이)을 256px 칸 4x4 한 장(art/kitchen.png)으로 직접 그립니다.
|
||||
칸 이름과 위치는 src/shared/Icons.luau 의 KITCHEN 표와 같아야 합니다(--luau 로 확인).
|
||||
|
||||
python3 tools/kitchen_art.py # art/kitchen.png
|
||||
python3 tools/kitchen_art.py --sheet x.png
|
||||
"""
|
||||
import math
|
||||
import os
|
||||
import sys
|
||||
|
||||
import cairo
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
from icons import INK, ellipse, fill_stroke, lin, rad, rgb, rrect, shine # noqa: E402
|
||||
|
||||
OUT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "art", "kitchen.png")
|
||||
CELL = 256
|
||||
GRID = 4
|
||||
LW = 9
|
||||
|
||||
|
||||
def fs(c, paint, lw=LW):
|
||||
fill_stroke(c, paint, lw)
|
||||
|
||||
|
||||
def flame_row(c, y=236, n=4):
|
||||
# 그릇 바닥을 핥는 작은 불꽃(그릇을 그린 다음에 그림)
|
||||
for i in range(n):
|
||||
x = 128 + (i - (n - 1) / 2) * 40
|
||||
c.move_to(x, y)
|
||||
c.curve_to(x - 16, y - 4, x - 12, y - 22, x - 3, y - 32)
|
||||
c.curve_to(x, y - 22, x + 8, y - 24, x + 6, y - 36)
|
||||
c.curve_to(x + 18, y - 20, x + 16, y - 4, x, y)
|
||||
c.close_path()
|
||||
fs(c, lin(0, y - 36, 0, y, "#fff36b", "#ffa51f", "#ff5a1f"), 5)
|
||||
|
||||
|
||||
def burner(c):
|
||||
# 가스 화구 받침(불꽃 아래)
|
||||
rrect(c, 44, 228, 168, 22, 10)
|
||||
fs(c, lin(0, 228, 0, 250, "#94a3b8", "#475569"), 7)
|
||||
|
||||
|
||||
def pan(c):
|
||||
pan_body(c)
|
||||
flame_row(c)
|
||||
burner(c)
|
||||
|
||||
|
||||
def pan_body(c):
|
||||
# 손잡이
|
||||
rrect(c, 196, 132, 58, 22, 10)
|
||||
fs(c, lin(0, 132, 0, 154, "#7c4a24", "#4a2a12"))
|
||||
# 팬(위에서 비스듬히)
|
||||
ellipse(c, 118, 150, 108, 52)
|
||||
fs(c, lin(0, 98, 0, 202, "#4b5563", "#1f2937"))
|
||||
ellipse(c, 118, 144, 92, 40)
|
||||
c.set_source(lin(0, 104, 0, 184, "#6b7280", "#374151"))
|
||||
c.fill()
|
||||
shine(c, 70, 124, 22, 7, 0.35)
|
||||
|
||||
|
||||
def board(c):
|
||||
# 나무 도마 + 김 + 밥
|
||||
rrect(c, 8, 70, 240, 150, 26)
|
||||
fs(c, lin(0, 70, 0, 220, "#f5c98a", "#d99a52"))
|
||||
for y in (100, 140, 180):
|
||||
c.move_to(24, y)
|
||||
c.curve_to(90, y - 8, 160, y + 8, 232, y)
|
||||
c.set_source_rgba(*INK, 0.12)
|
||||
c.set_line_width(3)
|
||||
c.stroke()
|
||||
rrect(c, 36, 84, 184, 122, 10)
|
||||
fs(c, lin(0, 84, 0, 206, "#2e3b2e", "#141c14"), 6)
|
||||
rrect(c, 46, 94, 164, 86, 18)
|
||||
c.set_source(lin(0, 94, 0, 180, "#ffffff", "#f1ede4"))
|
||||
c.fill()
|
||||
for x, y in ((70, 110), (100, 130), (140, 112), (170, 140), (120, 160), (80, 158), (190, 108)):
|
||||
ellipse(c, x, y, 6, 3.5)
|
||||
c.set_source_rgba(*INK, 0.08)
|
||||
c.fill()
|
||||
|
||||
|
||||
def steamer(c):
|
||||
steamer_body(c)
|
||||
flame_row(c)
|
||||
burner(c)
|
||||
|
||||
|
||||
def steamer_body(c):
|
||||
# 냄비 몸통 + 대나무 찜기 테두리 + 뚜껑 없음(속이 보임)
|
||||
rrect(c, 34, 112, 188, 92, 22)
|
||||
fs(c, lin(0, 112, 0, 204, "#e2e8f0", "#94a3b8"))
|
||||
rrect(c, 22, 96, 212, 40, 18)
|
||||
fs(c, lin(0, 96, 0, 136, "#f6d58e", "#d9a24a"))
|
||||
for x in range(40, 230, 24):
|
||||
c.move_to(x, 100)
|
||||
c.line_to(x, 132)
|
||||
c.set_source_rgba(*INK, 0.25)
|
||||
c.set_line_width(3)
|
||||
c.stroke()
|
||||
ellipse(c, 128, 100, 96, 22)
|
||||
fs(c, lin(0, 78, 0, 122, "#fff3d0", "#e9c983"), 6)
|
||||
for x in range(48, 212, 18):
|
||||
c.move_to(x, 88)
|
||||
c.line_to(x, 112)
|
||||
c.set_source_rgba(*INK, 0.15)
|
||||
c.set_line_width(2)
|
||||
c.stroke()
|
||||
|
||||
|
||||
def pot(c):
|
||||
pot_body(c)
|
||||
flame_row(c)
|
||||
burner(c)
|
||||
|
||||
|
||||
def pot_body(c):
|
||||
rrect(c, 12, 118, 24, 22, 8)
|
||||
fs(c, rgb("#7c4a24"), 6)
|
||||
rrect(c, 220, 118, 24, 22, 8)
|
||||
fs(c, rgb("#7c4a24"), 6)
|
||||
rrect(c, 30, 100, 196, 106, 30)
|
||||
fs(c, lin(0, 100, 0, 206, "#ff8a6a", "#d92f1c"))
|
||||
ellipse(c, 128, 102, 98, 26)
|
||||
fs(c, lin(0, 76, 0, 128, "#ffe08a", "#f2b046"), 7)
|
||||
for x, y in ((90, 98), (150, 108), (176, 94)):
|
||||
c.arc(x, y, 5, 0, 2 * math.pi)
|
||||
c.set_source_rgba(1, 1, 1, 0.7)
|
||||
c.fill()
|
||||
# 파 송송
|
||||
for x, y in ((70, 104), (120, 92), (196, 104), (140, 114)):
|
||||
c.arc(x, y, 6, 0, 2 * math.pi)
|
||||
fs(c, rgb("#5cc95c"), 3)
|
||||
shine(c, 60, 150, 10, 22, 0.35)
|
||||
|
||||
|
||||
def fryer(c):
|
||||
fryer_body(c)
|
||||
flame_row(c)
|
||||
burner(c)
|
||||
|
||||
|
||||
def fryer_body(c):
|
||||
rrect(c, 26, 96, 204, 112, 26)
|
||||
fs(c, lin(0, 96, 0, 208, "#cbd5e1", "#64748b"))
|
||||
ellipse(c, 128, 100, 100, 26)
|
||||
fs(c, lin(0, 74, 0, 126, "#ffe58a", "#f5b52a"), 7)
|
||||
for x, y, r in ((80, 100, 6), (120, 92, 4), (164, 104, 5), (190, 96, 4), (100, 110, 3)):
|
||||
c.arc(x, y, r, 0, 2 * math.pi)
|
||||
c.set_source_rgba(1, 1, 1, 0.75)
|
||||
c.fill()
|
||||
shine(c, 56, 150, 10, 24, 0.4)
|
||||
|
||||
|
||||
def mascot_body(c, cheer):
|
||||
# 떡이: 하얀 가래떡 몸 + 요리사 모자 + 빨간 앞치마
|
||||
arm_y = 70 if cheer else 150
|
||||
c.set_line_cap(cairo.LINE_CAP_ROUND)
|
||||
for x0, x1 in ((62, 22), (194, 234)):
|
||||
for w, col in ((26 + LW, INK), (26, rgb("#fff7ef"))):
|
||||
c.move_to(x0, 150)
|
||||
c.line_to(x1, arm_y)
|
||||
c.set_line_width(w)
|
||||
c.set_source_rgb(*col)
|
||||
c.stroke()
|
||||
rrect(c, 52, 70, 152, 176, 64)
|
||||
fs(c, lin(0, 70, 0, 246, "#ffffff", "#ffe6da"))
|
||||
# 앞치마
|
||||
c.move_to(76, 176)
|
||||
c.line_to(180, 176)
|
||||
c.line_to(176, 234)
|
||||
c.curve_to(150, 248, 106, 248, 80, 234)
|
||||
c.close_path()
|
||||
fs(c, lin(0, 176, 0, 244, "#ff7a8a", "#ff4d6a"), 6)
|
||||
c.arc(128, 206, 10, 0, 2 * math.pi)
|
||||
fs(c, rgb("#ffd23a"), 4)
|
||||
# 모자
|
||||
for x, y, r in ((88, 54, 34), (128, 38, 40), (168, 54, 34)):
|
||||
c.arc(x, y, r, 0, 2 * math.pi)
|
||||
fs(c, rgb("#ffffff"), 7)
|
||||
rrect(c, 70, 58, 116, 32, 10)
|
||||
fs(c, rgb("#ffffff"), 7)
|
||||
rrect(c, 76, 52, 104, 30, 8)
|
||||
c.set_source_rgb(1, 1, 1)
|
||||
c.fill()
|
||||
# 얼굴
|
||||
for x in (102, 154):
|
||||
if cheer:
|
||||
c.arc(x, 130, 11, math.pi, 2 * math.pi)
|
||||
c.set_source_rgb(*INK)
|
||||
c.set_line_width(7)
|
||||
c.stroke()
|
||||
else:
|
||||
ellipse(c, x, 128, 10, 13)
|
||||
c.set_source_rgb(*INK)
|
||||
c.fill()
|
||||
c.arc(x + 3, 122, 4, 0, 2 * math.pi)
|
||||
c.set_source_rgb(1, 1, 1)
|
||||
c.fill()
|
||||
c.move_to(112, 146)
|
||||
c.curve_to(116, 166 if cheer else 160, 140, 166 if cheer else 160, 144, 146)
|
||||
c.close_path()
|
||||
fs(c, rgb("#ff6b6b"), 5)
|
||||
for x in (82, 174):
|
||||
ellipse(c, x, 150, 14, 9)
|
||||
c.set_source_rgba(1, 0.45, 0.5, 0.55)
|
||||
c.fill()
|
||||
if cheer:
|
||||
for x, y in ((24, 40), (232, 36), (14, 120), (242, 118)):
|
||||
c.move_to(x, y - 16)
|
||||
c.line_to(x + 5, y - 5)
|
||||
c.line_to(x + 16, y)
|
||||
c.line_to(x + 5, y + 5)
|
||||
c.line_to(x, y + 16)
|
||||
c.line_to(x - 5, y + 5)
|
||||
c.line_to(x - 16, y)
|
||||
c.line_to(x - 5, y - 5)
|
||||
c.close_path()
|
||||
fs(c, rgb("#ffd23a"), 4)
|
||||
|
||||
|
||||
def mascot(c):
|
||||
mascot_body(c, False)
|
||||
|
||||
|
||||
def mascot_cheer(c):
|
||||
mascot_body(c, True)
|
||||
|
||||
|
||||
def gimbap_roll(c):
|
||||
# 돌돌 만 김밥 한 줄(옆), 오른쪽 끝 단면
|
||||
rrect(c, 10, 92, 220, 72, 36)
|
||||
fs(c, lin(0, 92, 0, 164, "#3a4a3a", "#141c14"))
|
||||
shine(c, 90, 106, 60, 6, 0.25)
|
||||
c.arc(212, 128, 38, 0, 2 * math.pi)
|
||||
fs(c, rgb("#1f2a1f"), 7)
|
||||
c.arc(212, 128, 29, 0, 2 * math.pi)
|
||||
c.set_source_rgb(1, 1, 1)
|
||||
c.fill()
|
||||
for dx, dy, col in ((-9, -8, "#ff8c1a"), (9, -7, "#ffd23a"), (0, 9, "#3fae49"), (-11, 9, "#ff8fa3"), (11, 9, "#fff3a0")):
|
||||
c.arc(212 + dx, 128 + dy, 7, 0, 2 * math.pi)
|
||||
c.set_source_rgb(*rgb(col))
|
||||
c.fill()
|
||||
|
||||
|
||||
def plate_big(c):
|
||||
# 완성 접시 받침(위에서 비스듬히)
|
||||
ellipse(c, 128, 150, 116, 58)
|
||||
fs(c, lin(0, 92, 0, 208, "#ffffff", "#d7dde6"))
|
||||
ellipse(c, 128, 146, 82, 38)
|
||||
c.set_source_rgba(*INK, 0.15)
|
||||
c.set_line_width(4)
|
||||
c.stroke()
|
||||
|
||||
|
||||
def burst(c):
|
||||
# 완성 축하 빛(테두리 없음)
|
||||
for i in range(12):
|
||||
a0 = i * math.pi / 6
|
||||
a1 = a0 + math.pi / 12
|
||||
c.move_to(128, 128)
|
||||
c.line_to(128 + 130 * math.cos(a0), 128 + 130 * math.sin(a0))
|
||||
c.line_to(128 + 130 * math.cos(a1), 128 + 130 * math.sin(a1))
|
||||
c.close_path()
|
||||
g = cairo.RadialGradient(128, 128, 10, 128, 128, 128)
|
||||
g.add_color_stop_rgba(0, 1, 0.95, 0.6, 1)
|
||||
g.add_color_stop_rgba(1, 1, 0.85, 0.3, 0)
|
||||
c.set_source(g)
|
||||
c.fill()
|
||||
|
||||
|
||||
BIG = [
|
||||
("pan", pan), ("board", board), ("steamer", steamer), ("pot", pot),
|
||||
("fryer", fryer), ("mascot", mascot), ("mascotCheer", mascot_cheer), ("gimbapRoll", gimbap_roll),
|
||||
("plateBig", plate_big), ("burst", burst),
|
||||
]
|
||||
|
||||
|
||||
def draw():
|
||||
surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, CELL * GRID, CELL * GRID)
|
||||
for i, (name, fn) in enumerate(BIG):
|
||||
c = cairo.Context(surf)
|
||||
c.translate((i % GRID) * CELL, (i // GRID) * CELL)
|
||||
c.rectangle(0, 0, CELL, CELL)
|
||||
c.clip()
|
||||
c.translate(128, 128)
|
||||
c.scale(0.94, 0.94)
|
||||
c.translate(-128, -128)
|
||||
fn(c)
|
||||
return surf
|
||||
|
||||
|
||||
def main(argv):
|
||||
surf = draw()
|
||||
if "--luau" in argv:
|
||||
for i, (name, _) in enumerate(BIG):
|
||||
print(f"\t{name} = Vector2.new({(i % GRID) * CELL}, {(i // GRID) * CELL}),")
|
||||
return
|
||||
if "--sheet" in argv:
|
||||
out = argv[argv.index("--sheet") + 1]
|
||||
sheet = cairo.ImageSurface(cairo.FORMAT_ARGB32, CELL * GRID, CELL * GRID)
|
||||
c = cairo.Context(sheet)
|
||||
c.set_source_rgb(0.55, 0.75, 0.6)
|
||||
c.paint()
|
||||
c.set_source_surface(surf, 0, 0)
|
||||
c.paint()
|
||||
for i, (name, _) in enumerate(BIG):
|
||||
c.set_source_rgb(0, 0, 0)
|
||||
c.move_to((i % GRID) * CELL + 6, (i // GRID) * CELL + 18)
|
||||
c.set_font_size(16)
|
||||
c.show_text(name)
|
||||
sheet.write_to_png(out)
|
||||
print(out)
|
||||
return
|
||||
surf.write_to_png(OUT)
|
||||
print(os.path.normpath(OUT))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
||||
84
bunsik-tycoon/tools/npc_inspect_models.luau
Normal file
@@ -0,0 +1,84 @@
|
||||
-- Creator Store 동물 모델 후보를 로블록스 서버에서 불러와 내용을 살펴봅니다(저장은 안 함).
|
||||
-- python3 tools/cloud.py run tools/npc_inspect_models.luau
|
||||
-- 불러오기: AssetService:LoadAssetAsync 먼저, 실패하면 InsertService:LoadAsset.
|
||||
-- 결과(2026-10-14): 남이 만든 무료 모델은 12개 모두 두 방법 다 "User is not authorized to access Asset."
|
||||
-- 로블록스가 만든 에셋(예: 1374269)은 둘 다 성공. 그래서 손님은 HumanoidDescription 방식(assets/npc_assets.md)을 씁니다.
|
||||
local AssetService = game:GetService("AssetService")
|
||||
local InsertService = game:GetService("InsertService")
|
||||
local HttpService = game:GetService("HttpService")
|
||||
|
||||
local IDS = {
|
||||
95757394637739, -- Poly Block Cute Animals Pack - 20 Assets (asasinatra)
|
||||
97050466582003, -- Stud-Themed Animal Pack [LITE] (DropKit)
|
||||
7902208283, -- Animal Pack (MRNOOB_504)
|
||||
8780565023, -- Cute Penguin (Calestelle)
|
||||
3676024481, -- House Cat (OscarAlhinho)
|
||||
2374016425, -- Dog (Low Poly) (PeppiIy)
|
||||
2374002814, -- Panda (Low Poly) (PeppiIy)
|
||||
12502111157, -- Fluffy Bunny Toy (Astrra)
|
||||
12549463718, -- Penguin Plushie (Astrra)
|
||||
12009487310, -- Cat with Animations - Rigged (KashTheKing)
|
||||
9415314422, -- Staring cat plush
|
||||
159064405, -- Sheep (SmilingGalactic)
|
||||
}
|
||||
|
||||
local function load(id: number): (Instance?, string)
|
||||
local ok, res = pcall(function()
|
||||
return AssetService:LoadAssetAsync(id)
|
||||
end)
|
||||
if ok and res then
|
||||
return res, "AssetService:LoadAssetAsync"
|
||||
end
|
||||
local ok2, res2 = pcall(function()
|
||||
return InsertService:LoadAsset(id)
|
||||
end)
|
||||
if ok2 and res2 then
|
||||
return res2, "InsertService:LoadAsset (AssetService err: " .. tostring(res) .. ")"
|
||||
end
|
||||
return nil, "both failed: " .. tostring(res) .. " | " .. tostring(res2)
|
||||
end
|
||||
|
||||
local out = {}
|
||||
for _, id in IDS do
|
||||
local inst, how = load(id)
|
||||
local r: { [string]: any } = { id = id, how = how }
|
||||
if inst then
|
||||
local counts: { [string]: number } = {}
|
||||
local maxPart = 0
|
||||
for _, d in inst:GetDescendants() do
|
||||
counts[d.ClassName] = (counts[d.ClassName] or 0) + 1
|
||||
if d:IsA("BasePart") then
|
||||
maxPart = math.max(maxPart, d.Size.Magnitude)
|
||||
end
|
||||
end
|
||||
local top = {}
|
||||
for _, c in inst:GetChildren() do
|
||||
local s = c.ClassName .. ":" .. c.Name
|
||||
if c:IsA("Model") or c:IsA("Folder") then
|
||||
local n = 0
|
||||
for _, d in c:GetDescendants() do
|
||||
if d:IsA("BasePart") then
|
||||
n += 1
|
||||
end
|
||||
end
|
||||
local sz = c:IsA("Model") and (c :: Model):GetExtentsSize() or Vector3.zero
|
||||
s ..= string.format("(%d parts, %.1fx%.1fx%.1f)", n, sz.X, sz.Y, sz.Z)
|
||||
local sub = {}
|
||||
for _, g in c:GetChildren() do
|
||||
if #sub < 25 then
|
||||
table.insert(sub, g.ClassName .. ":" .. g.Name)
|
||||
end
|
||||
end
|
||||
s ..= " [" .. table.concat(sub, ", ") .. "]"
|
||||
end
|
||||
table.insert(top, s)
|
||||
end
|
||||
r.counts = counts
|
||||
r.top = top
|
||||
r.maxPartDiag = math.floor(maxPart * 10) / 10
|
||||
inst:Destroy()
|
||||
end
|
||||
print(HttpService:JSONEncode(r))
|
||||
table.insert(out, r)
|
||||
end
|
||||
return #out
|
||||
100
bunsik-tycoon/tools/npc_search.py
Normal file
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env python3
|
||||
"""손님 NPC 에셋 찾기(인증 없이 공개 API만 씀).
|
||||
|
||||
python3 tools/npc_search.py store "low poly cat" [more queries...] # Creator Store 모델 검색
|
||||
python3 tools/npc_search.py catalog "hair" [--free] [--bundles] # 아바타 상점(Roblox 제작) 검색
|
||||
python3 tools/npc_search.py bundle 284 [...] # 번들 구성품 ID 보기
|
||||
|
||||
store: 무료·스크립트 없음만 보여 줍니다. 열: id, 투표(찬성/전체), 메시파트 수, 삼각형 수, 크리에이터, 이름.
|
||||
catalog/bundle 은 요청이 많으면 429/빈 오류가 나서 요청마다 몇 초씩 쉽니다.
|
||||
"""
|
||||
import json
|
||||
import sys
|
||||
import time
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
|
||||
def get(url, tries=4):
|
||||
for attempt in range(tries):
|
||||
try:
|
||||
req = urllib.request.Request(url, headers={"User-Agent": "bunsik-tycoon-tools"})
|
||||
with urllib.request.urlopen(req, timeout=60) as r:
|
||||
return json.loads(r.read())
|
||||
except Exception as e: # 429 등은 잠깐 쉬고 다시
|
||||
if attempt == tries - 1:
|
||||
return {"errors": [str(e)]}
|
||||
time.sleep(8 * (attempt + 1))
|
||||
|
||||
|
||||
def store(query, pages=2):
|
||||
rows = []
|
||||
token = ""
|
||||
for _ in range(pages):
|
||||
url = ("https://apis.roblox.com/toolbox-service/v2/assets:search?searchCategoryType=Model&maxPageSize=100&query="
|
||||
+ urllib.parse.quote(query) + (f"&pageToken={urllib.parse.quote(token)}" if token else ""))
|
||||
d = get(url)
|
||||
for it in d.get("creatorStoreAssets", []):
|
||||
a = it["asset"]
|
||||
price = it.get("creatorStoreProduct", {}).get("purchasePrice", {}).get("quantity", {}).get("significand", 0)
|
||||
if a.get("hasScripts") or price:
|
||||
continue
|
||||
v = it.get("voting", {})
|
||||
rows.append((a["id"], v.get("upVotes", 0), v.get("voteCount", 0),
|
||||
a.get("instanceCounts", {}).get("meshPart", 0),
|
||||
a.get("objectMeshSummary", {}).get("triangles", 0),
|
||||
it["creator"].get("name"), a["name"]))
|
||||
token = d.get("nextPageToken")
|
||||
if not token:
|
||||
break
|
||||
return rows
|
||||
|
||||
|
||||
def catalog(keyword, free=False, bundles=False):
|
||||
q = {"keyword": keyword, "creatorName": "Roblox", "limit": 120}
|
||||
if free:
|
||||
q["maxPrice"] = 0
|
||||
d = get("https://catalog.roblox.com/v2/search/items/details?" + urllib.parse.urlencode(q))
|
||||
out = []
|
||||
for x in d.get("data", []):
|
||||
if bundles and x["itemType"] != "Bundle":
|
||||
continue
|
||||
out.append((x["itemType"], x.get("assetType", x.get("bundleType")), x["id"], x["name"], x.get("price"),
|
||||
x.get("favoriteCount")))
|
||||
return out, d.get("errors")
|
||||
|
||||
|
||||
def bundle(bid):
|
||||
d = get(f"https://catalog.roblox.com/v1/bundles/{bid}/details")
|
||||
return d.get("name"), [(i["type"], i["id"], i["name"]) for i in d.get("items", [])]
|
||||
|
||||
|
||||
def main(argv):
|
||||
if not argv:
|
||||
print(__doc__)
|
||||
return 2
|
||||
cmd, args = argv[0], [a for a in argv[1:] if not a.startswith("--")]
|
||||
if cmd == "store":
|
||||
for q in args:
|
||||
print(f"== {q}")
|
||||
for r in sorted(store(q), key=lambda r: -r[2])[:40]:
|
||||
print(f"{r[0]}\t{r[1]}/{r[2]}\tmp={r[3]}\ttri={r[4]}\t{r[5]}\t{r[6]}")
|
||||
elif cmd == "catalog":
|
||||
for q in args:
|
||||
rows, err = catalog(q, "--free" in argv, "--bundles" in argv)
|
||||
print(f"== {q} {err or ''}")
|
||||
for r in rows:
|
||||
print("\t".join(str(c) for c in r))
|
||||
time.sleep(6)
|
||||
elif cmd == "bundle":
|
||||
for b in args:
|
||||
name, items = bundle(b)
|
||||
print(f"== {b} {name}")
|
||||
for t in items:
|
||||
print("\t".join(str(c) for c in t))
|
||||
time.sleep(3)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
509
bunsik-tycoon/tools/npc_verify_avatars.luau
Normal file
@@ -0,0 +1,509 @@
|
||||
-- 손님 외형(사람·동물) 최종 확인. 로블록스 서버에서 HumanoidDescription으로 실제 모델을 만들어 봅니다.
|
||||
-- python3 tools/cloud.py run tools/npc_verify_avatars.luau --out assets/npc_animals.rbxm
|
||||
-- 확인 항목: 생성 성공, 장신구·옷 개수, 크기·HipHeight, 동물 머리 모자가 사람 머리를 덮는 정도,
|
||||
-- R15 관절 15개 이름, 걷기·대기·앉기 애니메이션 로드(Length>0).
|
||||
-- 주의: Luau Execution은 시뮬레이션을 돌리지 않아(RunService:IsRunning()=false) 관절이 실제로 움직이는지는 못 봅니다.
|
||||
-- 마지막에 동물 프리셋 모델을 .rbxm(BinaryOutput)으로 내보내고, 다시 읽어 개수를 확인합니다.
|
||||
local Players = game:GetService("Players")
|
||||
local HttpService = game:GetService("HttpService")
|
||||
local SerializationService = game:GetService("SerializationService")
|
||||
local RunService = game:GetService("RunService")
|
||||
|
||||
local function rgb(r, g, b)
|
||||
return Color3.fromRGB(r, g, b)
|
||||
end
|
||||
|
||||
-- ===== 데이터(npc_assets.md 와 같음) =====
|
||||
local HAIR = {
|
||||
63690008,
|
||||
451221329,
|
||||
376526888,
|
||||
376524487,
|
||||
376548738,
|
||||
376527350,
|
||||
451220849,
|
||||
62234425,
|
||||
2956239660,
|
||||
3814476174,
|
||||
24910539,
|
||||
7193442167,
|
||||
9244095135,
|
||||
6993754725,
|
||||
7193448258,
|
||||
9243987340,
|
||||
7193450455,
|
||||
7193452166,
|
||||
9244148336,
|
||||
430063008,
|
||||
727320877,
|
||||
}
|
||||
local HATS = {
|
||||
1028606,
|
||||
607702162,
|
||||
321570512,
|
||||
10911990,
|
||||
67291394,
|
||||
3756496643,
|
||||
100932329,
|
||||
150337770,
|
||||
118280079,
|
||||
215724779,
|
||||
116778296,
|
||||
833771553,
|
||||
3756447657,
|
||||
439943629,
|
||||
1536057124,
|
||||
}
|
||||
local SHIRTS = {
|
||||
144076358,
|
||||
607785314,
|
||||
398633584,
|
||||
144076436,
|
||||
398634295,
|
||||
3670737444,
|
||||
382538059,
|
||||
398635081,
|
||||
382537702,
|
||||
382537085,
|
||||
382538295,
|
||||
4047884939,
|
||||
4047884046,
|
||||
4047886060,
|
||||
}
|
||||
local PANTS = { 144076760, 398634487, 398633812, 398635338, 382537806, 382538503, 382537569, 382537950 }
|
||||
local FACE_HEADS = {
|
||||
10725626210,
|
||||
10725826963,
|
||||
11308945948,
|
||||
15938951781,
|
||||
10687288296,
|
||||
10638267973,
|
||||
10723855306,
|
||||
13692975981,
|
||||
11163789916,
|
||||
12954264879,
|
||||
13682064263,
|
||||
130433936882245,
|
||||
11159990982,
|
||||
11180212350,
|
||||
16042049101,
|
||||
}
|
||||
local SKIN = { rgb(255, 220, 190), rgb(240, 200, 160), rgb(205, 160, 120), rgb(150, 105, 75) }
|
||||
|
||||
type Animal = {
|
||||
name: string,
|
||||
body: { number }?, -- Torso, LeftArm, RightArm, LeftLeg, RightLeg
|
||||
head: number?, -- Head(다이내믹 헤드)
|
||||
hat: string?, -- HatAccessory(동물 머리 모양 모자)
|
||||
ears: string?,
|
||||
tail: string?,
|
||||
colors: { Color3 }, -- Head, Torso, LeftArm, RightArm, LeftLeg, RightLeg
|
||||
shirt: number?,
|
||||
pants: number?,
|
||||
hideHead: boolean?, -- 모자가 머리를 통째로 덮으면 사람 얼굴이 비치지 않게 Head 투명
|
||||
lowerHat: boolean?, -- 머리 "위에" 얹히는 모자(아랫면이 머리 꼭대기 근처)를 목까지 내림
|
||||
}
|
||||
local W, G = rgb(245, 245, 245), rgb(163, 162, 165)
|
||||
local ANIMALS: { Animal } = {
|
||||
{
|
||||
name = "Penguin",
|
||||
body = { 46358991, 46359095, 46359040, 46359181, 46359241 },
|
||||
hat = "15967866",
|
||||
colors = { W, W, W, W, W, W },
|
||||
hideHead = true,
|
||||
},
|
||||
{
|
||||
name = "Bear",
|
||||
body = { 27132957, 27133013, 27132990, 27133040, 27133055 },
|
||||
hat = "28998435",
|
||||
lowerHat = true,
|
||||
colors = {
|
||||
rgb(160, 110, 80),
|
||||
rgb(160, 110, 80),
|
||||
rgb(110, 75, 55),
|
||||
rgb(110, 75, 55),
|
||||
rgb(110, 75, 55),
|
||||
rgb(110, 75, 55),
|
||||
},
|
||||
hideHead = true,
|
||||
},
|
||||
{
|
||||
name = "PolarBear",
|
||||
body = { 137715759, 137715036, 137715073, 137715120, 137715151 },
|
||||
hat = "137714793",
|
||||
colors = {
|
||||
rgb(248, 248, 248),
|
||||
rgb(248, 248, 248),
|
||||
rgb(248, 248, 248),
|
||||
rgb(248, 248, 248),
|
||||
rgb(248, 248, 248),
|
||||
rgb(248, 248, 248),
|
||||
},
|
||||
hideHead = true,
|
||||
},
|
||||
{
|
||||
name = "Cat",
|
||||
body = { 146176562, 146176342, 146176447, 146176406, 146176511 },
|
||||
hat = "146176716",
|
||||
colors = { G, G, G, G, G, G },
|
||||
hideHead = true,
|
||||
},
|
||||
{
|
||||
name = "Dog",
|
||||
body = { 1796148633, 1796137813, 1796141971, 1796143895, 1796146180 },
|
||||
hat = "1796135151",
|
||||
colors = { G, G, G, G, G, G },
|
||||
hideHead = true,
|
||||
},
|
||||
{
|
||||
name = "Panda",
|
||||
body = { 27132957, 27133013, 27132990, 27133040, 27133055 },
|
||||
hat = "27369187",
|
||||
colors = {
|
||||
rgb(242, 242, 242),
|
||||
rgb(242, 242, 242),
|
||||
rgb(30, 30, 30),
|
||||
rgb(30, 30, 30),
|
||||
rgb(30, 30, 30),
|
||||
rgb(30, 30, 30),
|
||||
},
|
||||
hideHead = true,
|
||||
},
|
||||
{
|
||||
name = "Fox",
|
||||
hat = "61773267",
|
||||
lowerHat = true,
|
||||
tail = "187846604",
|
||||
colors = {
|
||||
rgb(235, 120, 40),
|
||||
rgb(235, 120, 40),
|
||||
rgb(235, 120, 40),
|
||||
rgb(235, 120, 40),
|
||||
rgb(250, 240, 230),
|
||||
rgb(250, 240, 230),
|
||||
},
|
||||
shirt = 382537702,
|
||||
pants = 382537806,
|
||||
hideHead = true,
|
||||
},
|
||||
{
|
||||
name = "Mouse",
|
||||
hat = "439943629",
|
||||
colors = {
|
||||
rgb(170, 185, 215),
|
||||
rgb(170, 185, 215),
|
||||
rgb(170, 185, 215),
|
||||
rgb(170, 185, 215),
|
||||
rgb(170, 185, 215),
|
||||
rgb(170, 185, 215),
|
||||
},
|
||||
shirt = 398635081,
|
||||
pants = 144076760,
|
||||
hideHead = true,
|
||||
},
|
||||
{
|
||||
name = "Bunny",
|
||||
head = 119665103921086,
|
||||
ears = "1080949",
|
||||
tail = "738679517",
|
||||
colors = { W, W, W, W, W, W },
|
||||
shirt = 4047886060,
|
||||
pants = 382537950,
|
||||
},
|
||||
{
|
||||
name = "Kitty",
|
||||
head = 82082995456115,
|
||||
ears = "1374269",
|
||||
tail = "187846604",
|
||||
colors = {
|
||||
rgb(250, 200, 140),
|
||||
rgb(250, 200, 140),
|
||||
rgb(250, 200, 140),
|
||||
rgb(250, 200, 140),
|
||||
rgb(250, 200, 140),
|
||||
rgb(250, 200, 140),
|
||||
},
|
||||
shirt = 382537085,
|
||||
pants = 398634487,
|
||||
},
|
||||
{
|
||||
name = "Puppy",
|
||||
head = 138526270057654,
|
||||
ears = "11142487",
|
||||
colors = {
|
||||
rgb(220, 180, 130),
|
||||
rgb(220, 180, 130),
|
||||
rgb(220, 180, 130),
|
||||
rgb(220, 180, 130),
|
||||
rgb(220, 180, 130),
|
||||
rgb(220, 180, 130),
|
||||
},
|
||||
shirt = 144076436,
|
||||
pants = 382538503,
|
||||
},
|
||||
}
|
||||
|
||||
-- ===== 만드는 함수(게임 코드에 그대로 옮길 수 있는 모양) =====
|
||||
local function setColors(d: HumanoidDescription, c: { Color3 })
|
||||
d.HeadColor, d.TorsoColor, d.LeftArmColor, d.RightArmColor, d.LeftLegColor, d.RightLegColor =
|
||||
c[1], c[2], c[3], c[4], c[5], c[6]
|
||||
end
|
||||
|
||||
local function humanDesc(rng: Random): HumanoidDescription
|
||||
local d = Instance.new("HumanoidDescription")
|
||||
d.HairAccessory = tostring(HAIR[rng:NextInteger(1, #HAIR)])
|
||||
if rng:NextNumber() < 0.35 then
|
||||
d.HatAccessory = tostring(HATS[rng:NextInteger(1, #HATS)])
|
||||
end
|
||||
d.Shirt = SHIRTS[rng:NextInteger(1, #SHIRTS)]
|
||||
d.Pants = PANTS[rng:NextInteger(1, #PANTS)]
|
||||
d.Head = FACE_HEADS[rng:NextInteger(1, #FACE_HEADS)]
|
||||
local s = SKIN[rng:NextInteger(1, #SKIN)]
|
||||
setColors(d, { s, s, s, s, s, s })
|
||||
local h = 0.85 + rng:NextNumber() * 0.15 -- 어린이~어른 키 섞기
|
||||
d.HeightScale, d.WidthScale, d.DepthScale, d.HeadScale = h, 0.9, 0.9, 1
|
||||
return d
|
||||
end
|
||||
|
||||
local function animalDesc(a: Animal): HumanoidDescription
|
||||
local d = Instance.new("HumanoidDescription")
|
||||
if a.body then
|
||||
d.Torso, d.LeftArm, d.RightArm, d.LeftLeg, d.RightLeg = a.body[1], a.body[2], a.body[3], a.body[4], a.body[5]
|
||||
end
|
||||
if a.head then
|
||||
d.Head = a.head
|
||||
end
|
||||
d.HatAccessory = a.hat or a.ears or ""
|
||||
d.WaistAccessory = a.tail or ""
|
||||
d.Shirt = a.shirt or 0
|
||||
d.Pants = a.pants or 0
|
||||
setColors(d, a.colors)
|
||||
return d
|
||||
end
|
||||
|
||||
-- 모델을 Workspace에 넣고 한 프레임 지난 뒤(장신구 용접이 자리 잡은 뒤) 호출합니다.
|
||||
local function finishAnimal(m: Model, a: Animal)
|
||||
local head = m:FindFirstChild("Head") :: BasePart
|
||||
local hum = m:FindFirstChildOfClass("Humanoid") :: Humanoid
|
||||
if a.lowerHat then
|
||||
for _, acc in m:GetChildren() do
|
||||
if acc:IsA("Accessory") and acc.AccessoryType == Enum.AccessoryType.Hat then
|
||||
local h = acc:FindFirstChild("Handle") :: BasePart
|
||||
local drop = (h.Position.Y - h.Size.Y / 2) - (head.Position.Y - head.Size.Y / 2)
|
||||
local att = h:FindFirstChild("HatAttachment") :: Attachment?
|
||||
if drop > 0.1 and att then
|
||||
-- 손잡이 쪽 Attachment를 올리고 다시 붙이면 모자가 그만큼 내려갑니다.
|
||||
-- (붙이는 관절은 Handle.AccessoryRigidConstraint. Attachment만 옮기면 물리가 돌 때까지 반영이 안 됨)
|
||||
att.Position += Vector3.new(0, drop, 0)
|
||||
acc.Parent = nil
|
||||
hum:AddAccessory(acc)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if a.hideHead then
|
||||
head.Transparency = 1
|
||||
for _, x in head:GetChildren() do
|
||||
if x:IsA("Decal") then
|
||||
x.Transparency = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- ===== 확인 =====
|
||||
local R15_JOINTS = {
|
||||
"Root",
|
||||
"Waist",
|
||||
"Neck",
|
||||
"LeftShoulder",
|
||||
"LeftElbow",
|
||||
"LeftWrist",
|
||||
"RightShoulder",
|
||||
"RightElbow",
|
||||
"RightWrist",
|
||||
"LeftHip",
|
||||
"LeftKnee",
|
||||
"LeftAnkle",
|
||||
"RightHip",
|
||||
"RightKnee",
|
||||
"RightAnkle",
|
||||
}
|
||||
local ANIM = { walk = "rbxassetid://507777826", idle = "rbxassetid://507766388", sit = "rbxassetid://2506281703" }
|
||||
|
||||
local function hatFit(m: Model): { number }?
|
||||
-- {모자 아랫면 - 머리 아랫면, 모자 윗면 - 머리 윗면} (스터드). 아랫면 차이가 0 근처면 머리를 다 덮음
|
||||
local head = m:FindFirstChild("Head") :: BasePart
|
||||
for _, acc in m:GetChildren() do
|
||||
if acc:IsA("Accessory") and acc.AccessoryType == Enum.AccessoryType.Hat then
|
||||
local h = acc:FindFirstChild("Handle") :: BasePart
|
||||
if h then
|
||||
local hb, ht = h.Position.Y - h.Size.Y / 2, h.Position.Y + h.Size.Y / 2
|
||||
local b, t = head.Position.Y - head.Size.Y / 2, head.Position.Y + head.Size.Y / 2
|
||||
return { math.round((hb - b) * 100) / 100, math.round((ht - t) * 100) / 100 }
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local built: { Model } = {}
|
||||
local summary = { ok = 0, fail = 0 }
|
||||
local function check(label: string, d: HumanoidDescription, after: ((Model) -> ())?, keep: boolean?)
|
||||
local t0 = os.clock()
|
||||
local ok, model = pcall(Players.CreateHumanoidModelFromDescription, Players, d, Enum.HumanoidRigType.R15)
|
||||
if not ok then
|
||||
summary.fail += 1
|
||||
print(HttpService:JSONEncode({ n = label, ok = false, err = tostring(model) }))
|
||||
return
|
||||
end
|
||||
local m = model :: Model
|
||||
m.Name = label
|
||||
local anim = m:FindFirstChild("Animate", true)
|
||||
if anim then
|
||||
anim:Destroy() -- 플레이어용 LocalScript(서버 NPC에선 안 돌아감)
|
||||
end
|
||||
m:PivotTo(CFrame.new(#built * 8, 20, 0))
|
||||
m.Parent = workspace;
|
||||
(m:FindFirstChild("HumanoidRootPart") :: BasePart).Anchored = true
|
||||
RunService.Heartbeat:Wait()
|
||||
if after then
|
||||
after(m)
|
||||
RunService.Heartbeat:Wait()
|
||||
end
|
||||
local hum = m:FindFirstChildOfClass("Humanoid") :: Humanoid
|
||||
local acc, parts, scripts, sa = {}, 0, 0, 0
|
||||
for _, x in m:GetDescendants() do
|
||||
if x:IsA("Accessory") then
|
||||
table.insert(acc, x.Name)
|
||||
elseif x:IsA("BasePart") then
|
||||
parts += 1
|
||||
elseif x:IsA("LuaSourceContainer") then
|
||||
scripts += 1
|
||||
elseif x:IsA("SurfaceAppearance") then
|
||||
sa += 1
|
||||
end
|
||||
end
|
||||
local missing = {}
|
||||
for _, j in R15_JOINTS do
|
||||
if not m:FindFirstChild(j, true) then
|
||||
table.insert(missing, j)
|
||||
end
|
||||
end
|
||||
local animator = hum:FindFirstChildOfClass("Animator") or Instance.new("Animator", hum)
|
||||
local lens = {}
|
||||
for k, id in ANIM do
|
||||
local a = Instance.new("Animation")
|
||||
a.AnimationId = id
|
||||
local tr = animator:LoadAnimation(a)
|
||||
local w0 = os.clock()
|
||||
while tr.Length == 0 and os.clock() - w0 < 3 do
|
||||
task.wait(0.05)
|
||||
end
|
||||
lens[k] = math.round(tr.Length * 100) / 100
|
||||
tr:Destroy()
|
||||
end
|
||||
local _, size = m:GetBoundingBox()
|
||||
summary.ok += 1
|
||||
print(HttpService:JSONEncode({
|
||||
n = label,
|
||||
ok = true,
|
||||
acc = acc,
|
||||
shirt = m:FindFirstChildOfClass("Shirt") ~= nil,
|
||||
pants = m:FindFirstChildOfClass("Pants") ~= nil,
|
||||
parts = parts,
|
||||
scripts = scripts,
|
||||
surfaceAppearance = sa,
|
||||
missingJoints = missing,
|
||||
anim = lens,
|
||||
size = string.format("%.1fx%.1fx%.1f", size.X, size.Y, size.Z),
|
||||
hip = math.round(hum.HipHeight * 100) / 100,
|
||||
rootY = (m:FindFirstChild("HumanoidRootPart") :: BasePart).Size.Y,
|
||||
hatFit = hatFit(m),
|
||||
sec = math.round((os.clock() - t0) * 100) / 100,
|
||||
}))
|
||||
if keep then
|
||||
table.insert(built, m)
|
||||
else
|
||||
m:Destroy()
|
||||
end
|
||||
end
|
||||
|
||||
-- 1) 아이템마다 한 번씩(모두 실제로 붙는지): 사람 기본 몸에 하나씩 넣어 봄
|
||||
local itemFails = {}
|
||||
local function itemCheck(kind: string, id: number, apply: (HumanoidDescription) -> ())
|
||||
local d = Instance.new("HumanoidDescription")
|
||||
apply(d)
|
||||
local ok, m = pcall(Players.CreateHumanoidModelFromDescription, Players, d, Enum.HumanoidRigType.R15)
|
||||
if not ok then
|
||||
table.insert(itemFails, kind .. " " .. id .. " " .. tostring(m))
|
||||
return
|
||||
end
|
||||
local good
|
||||
if kind == "hair" or kind == "hat" then
|
||||
good = m:FindFirstChildOfClass("Accessory") ~= nil
|
||||
elseif kind == "shirt" then
|
||||
good = m:FindFirstChildOfClass("Shirt") ~= nil
|
||||
elseif kind == "pants" then
|
||||
good = m:FindFirstChildOfClass("Pants") ~= nil
|
||||
else
|
||||
local head = m:FindFirstChild("Head") :: MeshPart
|
||||
good = head:IsA("MeshPart") and head.MeshId ~= "" and not string.find(head.MeshId, "123480233606534")
|
||||
end
|
||||
if not good then
|
||||
table.insert(itemFails, kind .. " " .. id .. " not applied")
|
||||
end
|
||||
m:Destroy()
|
||||
end
|
||||
for _, id in HAIR do
|
||||
itemCheck("hair", id, function(d)
|
||||
d.HairAccessory = tostring(id)
|
||||
end)
|
||||
end
|
||||
for _, id in HATS do
|
||||
itemCheck("hat", id, function(d)
|
||||
d.HatAccessory = tostring(id)
|
||||
end)
|
||||
end
|
||||
for _, id in SHIRTS do
|
||||
itemCheck("shirt", id, function(d)
|
||||
d.Shirt = id
|
||||
end)
|
||||
end
|
||||
for _, id in PANTS do
|
||||
itemCheck("pants", id, function(d)
|
||||
d.Pants = id
|
||||
end)
|
||||
end
|
||||
for _, id in FACE_HEADS do
|
||||
itemCheck("faceHead", id, function(d)
|
||||
d.Head = id
|
||||
end)
|
||||
end
|
||||
print(HttpService:JSONEncode({
|
||||
items = #HAIR + #HATS + #SHIRTS + #PANTS + #FACE_HEADS,
|
||||
itemFails = itemFails,
|
||||
}))
|
||||
|
||||
-- 2) 사람 무작위 조합 6개
|
||||
local rng = Random.new(7)
|
||||
for i = 1, 6 do
|
||||
check("Human" .. i, humanDesc(rng), nil, i == 1)
|
||||
end
|
||||
|
||||
-- 3) 동물 프리셋
|
||||
for _, a in ANIMALS do
|
||||
check(a.name, animalDesc(a), function(m)
|
||||
finishAnimal(m, a)
|
||||
end, true)
|
||||
end
|
||||
|
||||
-- 4) .rbxm 으로 내보내고 다시 읽어 보기
|
||||
for _, m in built do
|
||||
m.Parent = nil
|
||||
(m:FindFirstChild("HumanoidRootPart") :: BasePart).Anchored = false
|
||||
end
|
||||
local buf = SerializationService:SerializeInstancesAsync(built)
|
||||
local back = SerializationService:DeserializeInstancesAsync(buf)
|
||||
print(HttpService:JSONEncode({ rbxmBytes = buffer.len(buf), models = #built, roundTrip = #back }))
|
||||
return { BinaryOutput = buf, ReturnValues = { summary.ok, summary.fail, #itemFails } }
|
||||
43
bunsik-tycoon/tools/preview.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
# 화면 UI 미리보기: 빌드 → 저장 버전 업로드 → 로블록스 서버에서 UI 덤프(장면 6개씩 나눠서) → 그림(PNG)으로.
|
||||
# tools/preview.sh 출력폴더 [장면이름...]
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
export PATH="$HOME/.rokit/bin:$PATH"
|
||||
out=${1:-.cache/preview}
|
||||
shift || true
|
||||
mkdir -p .cache "$out"
|
||||
rojo build default.project.json -o build/BunsikTycoon.rbxl >/dev/null
|
||||
ver=$(python3 tools/cloud.py publish build/BunsikTycoon.rbxl | awk '{print $2}')
|
||||
if [ $# -gt 0 ]; then
|
||||
names="$*"
|
||||
else
|
||||
names=$(grep -o 'shot(\s*"[a-z_0-9]*"\|^\s*"[a-z_0-9]*",$' tests/cloud/dump_gui.luau | grep -o '"[a-z_0-9]*"' | tr -d '"' | tr '\n' ' ')
|
||||
fi
|
||||
rm -f .cache/gui_part_*.json
|
||||
i=0
|
||||
batch=()
|
||||
run_batch() {
|
||||
local list
|
||||
list=$(printf '"%s",' "${batch[@]}")
|
||||
sed "s/^local ONLY: { string }? = nil/local ONLY: { string }? = { ${list%,} }/" tests/cloud/dump_gui.luau >.cache/dump_gui_batch.luau
|
||||
python3 tools/cloud.py run .cache/dump_gui_batch.luau --version "$ver" --out ".cache/gui_part_$i.json" >.cache/dump_raw.txt ||
|
||||
{ tail -20 .cache/dump_raw.txt; exit 1; }
|
||||
i=$((i + 1))
|
||||
batch=()
|
||||
}
|
||||
for n in $names; do
|
||||
batch+=("$n")
|
||||
if [ ${#batch[@]} -ge 6 ]; then run_batch; fi
|
||||
done
|
||||
if [ ${#batch[@]} -gt 0 ]; then run_batch; fi
|
||||
python3 - <<'PY'
|
||||
import glob, json
|
||||
shots, images = [], {}
|
||||
for f in sorted(glob.glob(".cache/gui_part_*.json")):
|
||||
d = json.load(open(f))
|
||||
shots += d["shots"]
|
||||
images.update(d["images"])
|
||||
json.dump({"shots": shots, "images": images}, open(".cache/gui_dump.json", "w"))
|
||||
PY
|
||||
python3 tools/gui_render.py .cache/gui_dump.json "$out"
|
||||
173
bunsik-tycoon/tools/render.py
Normal file
@@ -0,0 +1,173 @@
|
||||
#!/usr/bin/env python3
|
||||
"""장면 덤프(JSON)를 간단한 3D 그림으로 그립니다. 서버에서 화면을 볼 수 없어 배치 확인용으로 씁니다.
|
||||
로블록스 렌더링과 다르고(조명·질감·애니메이션 없음), 파트 위치·크기·색만 맞습니다.
|
||||
|
||||
python3 tools/render.py .cache/scene.json out.png --eye x,y,z --at x,y,z [--size 1280x720]
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
import math
|
||||
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
|
||||
|
||||
def box_mesh():
|
||||
v = np.array([[x, y, z] for x in (-0.5, 0.5) for y in (-0.5, 0.5) for z in (-0.5, 0.5)])
|
||||
f = [(0, 1, 3), (0, 3, 2), (4, 6, 7), (4, 7, 5), (0, 4, 5), (0, 5, 1),
|
||||
(2, 3, 7), (2, 7, 6), (0, 2, 6), (0, 6, 4), (1, 5, 7), (1, 7, 3)]
|
||||
return v, f
|
||||
|
||||
|
||||
def wedge_mesh():
|
||||
# 로블록스 WedgePart: 아래 면 전체, 뒤(-Z) 면 전체, 경사면은 위-뒤에서 아래-앞으로
|
||||
v = np.array([[-0.5, -0.5, -0.5], [0.5, -0.5, -0.5], [-0.5, -0.5, 0.5], [0.5, -0.5, 0.5],
|
||||
[-0.5, 0.5, -0.5], [0.5, 0.5, -0.5]])
|
||||
f = [(0, 1, 3), (0, 3, 2), (0, 4, 5), (0, 5, 1), (2, 3, 5), (2, 5, 4), (0, 2, 4), (1, 5, 3)]
|
||||
return v, f
|
||||
|
||||
|
||||
def cyl_mesh(n=14):
|
||||
# 축은 X
|
||||
v = []
|
||||
for x in (-0.5, 0.5):
|
||||
for i in range(n):
|
||||
a = 2 * math.pi * i / n
|
||||
v.append([x, 0.5 * math.cos(a), 0.5 * math.sin(a)])
|
||||
v.append([-0.5, 0, 0])
|
||||
v.append([0.5, 0, 0])
|
||||
f = []
|
||||
for i in range(n):
|
||||
j = (i + 1) % n
|
||||
f += [(i, j, n + j), (i, n + j, n + i), (2 * n, j, i), (2 * n + 1, n + i, n + j)]
|
||||
return np.array(v), f
|
||||
|
||||
|
||||
def ball_mesh(lat=7, lon=12):
|
||||
v = []
|
||||
for i in range(lat + 1):
|
||||
th = math.pi * i / lat
|
||||
for j in range(lon):
|
||||
ph = 2 * math.pi * j / lon
|
||||
v.append([0.5 * math.sin(th) * math.cos(ph), 0.5 * math.cos(th), 0.5 * math.sin(th) * math.sin(ph)])
|
||||
f = []
|
||||
for i in range(lat):
|
||||
for j in range(lon):
|
||||
a = i * lon + j
|
||||
b = i * lon + (j + 1) % lon
|
||||
c = (i + 1) * lon + j
|
||||
d = (i + 1) * lon + (j + 1) % lon
|
||||
f += [(a, c, d), (a, d, b)]
|
||||
return np.array(v), f
|
||||
|
||||
|
||||
MESHES = {"Block": box_mesh(), "Wedge": wedge_mesh(), "Cylinder": cyl_mesh(), "Ball": ball_mesh()}
|
||||
|
||||
|
||||
def triangles(parts):
|
||||
tris, cols = [], []
|
||||
for p in parts:
|
||||
v, f = MESHES.get(p["s"], MESHES["Block"])
|
||||
c = p["c"]
|
||||
pos = np.array(c[:3])
|
||||
rot = np.array(c[3:]).reshape(3, 3)
|
||||
size = np.array(p["z"])
|
||||
w = (v * size) @ rot.T + pos
|
||||
col = np.array(p["k"], dtype=float)
|
||||
if p["m"] == "Neon":
|
||||
col = np.minimum(col * 1.25 + 30, 255)
|
||||
for a, b, d in f:
|
||||
tris.append(w[[a, b, d]])
|
||||
cols.append((col, p["t"], p["m"] == "Neon"))
|
||||
return np.array(tris), cols
|
||||
|
||||
|
||||
def render(parts, eye, at, w, h, fov=55):
|
||||
tris, cols = triangles(parts)
|
||||
eye, at = np.array(eye, float), np.array(at, float)
|
||||
fwd = at - eye
|
||||
fwd /= np.linalg.norm(fwd)
|
||||
right = np.cross(fwd, [0, 1, 0])
|
||||
right /= np.linalg.norm(right)
|
||||
up = np.cross(right, fwd)
|
||||
rel = tris - eye
|
||||
cx = rel @ right
|
||||
cy = rel @ up
|
||||
cz = rel @ fwd
|
||||
f = 0.5 * h / math.tan(math.radians(fov) / 2)
|
||||
img = np.zeros((h, w, 3))
|
||||
# 하늘
|
||||
for y in range(h):
|
||||
t = y / h
|
||||
img[y] = np.array([150, 200, 250]) * (1 - t) + np.array([210, 230, 250]) * t
|
||||
zbuf = np.full((h, w), np.inf)
|
||||
light = np.array([0.4, 0.85, 0.35])
|
||||
light /= np.linalg.norm(light)
|
||||
order = np.argsort([1 if c[1] > 0.3 else 0 for c in cols], kind="stable") # 투명은 나중에
|
||||
for i in order:
|
||||
z = cz[i]
|
||||
if np.any(z < 0.5):
|
||||
continue
|
||||
sx = w / 2 + f * cx[i] / z
|
||||
sy = h / 2 - f * cy[i] / z
|
||||
x0, x1 = int(max(0, math.floor(sx.min()))), int(min(w - 1, math.ceil(sx.max())))
|
||||
y0, y1 = int(max(0, math.floor(sy.min()))), int(min(h - 1, math.ceil(sy.max())))
|
||||
if x0 > x1 or y0 > y1:
|
||||
continue
|
||||
t = tris[i]
|
||||
n = np.cross(t[1] - t[0], t[2] - t[0])
|
||||
nn = np.linalg.norm(n)
|
||||
if nn == 0:
|
||||
continue
|
||||
n /= nn
|
||||
if np.dot(n, eye - t[0]) < 0:
|
||||
n = -n
|
||||
col, tr, neon = cols[i]
|
||||
shade = 1.0 if neon else 0.55 + 0.45 * max(0.0, float(np.dot(n, light)))
|
||||
rgb = np.clip(col * shade, 0, 255)
|
||||
xs, ys = np.meshgrid(np.arange(x0, x1 + 1) + 0.5, np.arange(y0, y1 + 1) + 0.5)
|
||||
(ax, bx, cx_), (ay, by, cy_) = sx, sy
|
||||
den = (by - cy_) * (ax - cx_) + (cx_ - bx) * (ay - cy_)
|
||||
if abs(den) < 1e-9:
|
||||
continue
|
||||
l1 = ((by - cy_) * (xs - cx_) + (cx_ - bx) * (ys - cy_)) / den
|
||||
l2 = ((cy_ - ay) * (xs - cx_) + (ax - cx_) * (ys - cy_)) / den
|
||||
l3 = 1 - l1 - l2
|
||||
inside = (l1 >= -1e-6) & (l2 >= -1e-6) & (l3 >= -1e-6)
|
||||
if not inside.any():
|
||||
continue
|
||||
iz = l1 / z[0] + l2 / z[1] + l3 / z[2]
|
||||
depth = 1 / np.where(iz > 0, iz, 1e-9)
|
||||
sub = zbuf[y0:y1 + 1, x0:x1 + 1]
|
||||
m = inside & (depth < sub)
|
||||
if tr > 0.3:
|
||||
a = 1 - tr
|
||||
region = img[y0:y1 + 1, x0:x1 + 1]
|
||||
region[m] = region[m] * (1 - a) + rgb * a
|
||||
else:
|
||||
sub[m] = depth[m]
|
||||
img[y0:y1 + 1, x0:x1 + 1][m] = rgb
|
||||
return Image.fromarray(img.astype(np.uint8))
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("scene")
|
||||
ap.add_argument("out")
|
||||
ap.add_argument("--eye", default="0,120,160")
|
||||
ap.add_argument("--at", default="0,0,0")
|
||||
ap.add_argument("--size", default="1280x720")
|
||||
ap.add_argument("--fov", type=float, default=55)
|
||||
a = ap.parse_args()
|
||||
with open(a.scene) as f:
|
||||
parts = json.load(f)
|
||||
w, h = map(int, a.size.split("x"))
|
||||
eye = [float(x) for x in a.eye.split(",")]
|
||||
at = [float(x) for x in a.at.split(",")]
|
||||
# 큰 것(바닥)부터 그려도 z-버퍼가 있으니 순서는 상관없음
|
||||
render(parts, eye, at, w, h, a.fov).save(a.out)
|
||||
print(a.out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
131
bunsik-tycoon/tools/sfx.py
Normal file
@@ -0,0 +1,131 @@
|
||||
#!/usr/bin/env python3
|
||||
"""효과음을 직접 합성합니다(외부 음원 없음, 저작권 걱정 없음). sfx/*.ogg 로 저장합니다.
|
||||
|
||||
python3 tools/sfx.py
|
||||
"""
|
||||
import os
|
||||
import subprocess
|
||||
import wave
|
||||
|
||||
import numpy as np
|
||||
|
||||
SR = 44100
|
||||
OUT = os.path.join(os.path.dirname(__file__), "..", "sfx")
|
||||
rng = np.random.default_rng(7)
|
||||
|
||||
|
||||
def t(sec):
|
||||
return np.arange(int(SR * sec)) / SR
|
||||
|
||||
|
||||
def env(n, attack=0.005, decay=0.3):
|
||||
x = np.arange(n) / SR
|
||||
a = np.clip(x / attack, 0, 1)
|
||||
return a * np.exp(-x / decay)
|
||||
|
||||
|
||||
def bell(freq, sec, decay):
|
||||
x = t(sec)
|
||||
# 맑은 종소리: 기본음 + 배음(조금 어긋난 비율)
|
||||
s = (np.sin(2 * np.pi * freq * x) + 0.45 * np.sin(2 * np.pi * freq * 2.01 * x)
|
||||
+ 0.2 * np.sin(2 * np.pi * freq * 3.03 * x))
|
||||
return s * env(len(x), 0.002, decay)
|
||||
|
||||
|
||||
def place(buf, sig, at):
|
||||
i = int(at * SR)
|
||||
end = min(len(buf), i + len(sig))
|
||||
buf[i:end] += sig[: end - i]
|
||||
|
||||
|
||||
def coin():
|
||||
buf = np.zeros(int(SR * 0.6))
|
||||
place(buf, bell(1318.5, 0.6, 0.09), 0.0) # E6
|
||||
place(buf, bell(1975.5, 0.55, 0.18), 0.07) # B6
|
||||
return buf
|
||||
|
||||
|
||||
def buy():
|
||||
# 도-미-솔-높은도 빠른 아르페지오 + 반짝임
|
||||
buf = np.zeros(int(SR * 1.0))
|
||||
for i, f in enumerate([523.25, 659.25, 783.99, 1046.5]):
|
||||
place(buf, bell(f, 0.7, 0.22), i * 0.075)
|
||||
sparkle = rng.standard_normal(int(SR * 0.4))
|
||||
sparkle = np.convolve(sparkle, np.ones(3) / 3, "same") * env(len(sparkle), 0.01, 0.12) * 0.08
|
||||
place(buf, sparkle * np.sin(2 * np.pi * 6000 * t(0.4)), 0.3)
|
||||
return buf
|
||||
|
||||
|
||||
def levelup():
|
||||
# 확장 축하: 두 박자 팡파레(사각파 느낌을 배음으로)
|
||||
buf = np.zeros(int(SR * 1.6))
|
||||
notes = [(523.25, 0.0, 0.15), (659.25, 0.15, 0.15), (783.99, 0.3, 0.15), (1046.5, 0.45, 0.6)]
|
||||
for f, at, d in notes:
|
||||
x = t(d + 0.4)
|
||||
s = sum(np.sin(2 * np.pi * f * k * x) / k for k in (1, 3, 5)) * 0.6
|
||||
s += 0.5 * np.sin(2 * np.pi * f * 2 * x)
|
||||
e = env(len(x), 0.01, 0.35 if d > 0.3 else 0.12)
|
||||
place(buf, s * e, at)
|
||||
return buf
|
||||
|
||||
|
||||
def sizzle(sec=3.0):
|
||||
n = int(SR * sec)
|
||||
noise = rng.standard_normal(n)
|
||||
# 고역 위주(지글지글): 1차 고역 통과
|
||||
hp = np.empty(n)
|
||||
a = 0.92
|
||||
prev_x = prev_y = 0.0
|
||||
for i in range(n):
|
||||
y = a * (prev_y + noise[i] - prev_x)
|
||||
hp[i] = y
|
||||
prev_x, prev_y = noise[i], y
|
||||
# 천천히 출렁이는 세기
|
||||
x = t(sec)
|
||||
mod = 0.55 + 0.25 * np.sin(2 * np.pi * 0.7 * x) + 0.2 * np.sin(2 * np.pi * 1.9 * x + 1)
|
||||
s = hp * mod * 0.25
|
||||
# 기름 튀는 소리(짧은 딱딱)
|
||||
for at in rng.uniform(0, sec, 70):
|
||||
click = rng.standard_normal(int(SR * 0.012)) * env(int(SR * 0.012), 0.0005, 0.003)
|
||||
place(s, click * rng.uniform(0.3, 0.9), at)
|
||||
# 이음매 없이 반복되게 앞뒤를 겹칩니다.
|
||||
fade = int(SR * 0.3)
|
||||
w = np.linspace(0, 1, fade)
|
||||
s[:fade] = s[:fade] * w + s[-fade:] * (1 - w)
|
||||
return s[:-fade]
|
||||
|
||||
|
||||
def pop():
|
||||
# 요리 화면 톡톡: 통통 튀는 짧은 소리(높은 음에서 빠르게 내려감)
|
||||
x = t(0.12)
|
||||
f = 900 * np.exp(-x * 18) + 380
|
||||
phase = 2 * np.pi * np.cumsum(f) / SR
|
||||
return np.sin(phase) * env(len(x), 0.001, 0.035)
|
||||
|
||||
|
||||
def save(name, sig):
|
||||
sig = sig / max(1e-9, np.max(np.abs(sig))) * 0.85
|
||||
pcm = (sig * 32767).astype(np.int16)
|
||||
wav = os.path.join(OUT, name + ".wav")
|
||||
with wave.open(wav, "wb") as f:
|
||||
f.setnchannels(1)
|
||||
f.setsampwidth(2)
|
||||
f.setframerate(SR)
|
||||
f.writeframes(pcm.tobytes())
|
||||
ogg = os.path.join(OUT, name + ".ogg")
|
||||
subprocess.run(["ffmpeg", "-y", "-loglevel", "error", "-i", wav, "-c:a", "libvorbis", "-q:a", "5", ogg], check=True)
|
||||
os.remove(wav)
|
||||
print(ogg)
|
||||
|
||||
|
||||
def main():
|
||||
os.makedirs(OUT, exist_ok=True)
|
||||
save("coin", coin())
|
||||
save("buy", buy())
|
||||
save("levelup", levelup())
|
||||
save("sizzle", sizzle())
|
||||
save("pop", pop())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
14
bunsik-tycoon/tools/sim.luau
Normal file
@@ -0,0 +1,14 @@
|
||||
-- 경제 시뮬레이터 실행
|
||||
-- lune run tools/sim.luau # 기본
|
||||
-- lune run tools/sim.luau x2 # 2배 수익 게임패스
|
||||
local process = require("@lune/process")
|
||||
local Sim = require("./simlib")
|
||||
|
||||
local mult = if table.find(process.args, "x2") then 2 else 1
|
||||
print(`수익 배율 x{mult}`)
|
||||
local prev = 0
|
||||
for i, e in Sim.run(mult, 7200) do
|
||||
local s = math.floor(e.t + 0.5)
|
||||
print(string.format("%2d %2d:%02d (+%3ds) %-12s %6d", i, s // 60, s % 60, s - prev, e.id, e.cost))
|
||||
prev = s
|
||||
end
|
||||
109
bunsik-tycoon/tools/simlib.luau
Normal file
@@ -0,0 +1,109 @@
|
||||
-- 경제 시뮬레이터 본체: 실제 게임 로직(src/shared/Shop)을 봇이 쉬지 않고 플레이합니다.
|
||||
-- 실행은 tools/sim.luau, 검사는 tests/Sim.spec.luau
|
||||
-- 봇 가정: 조리대 <-> 테이블 편도 WALK/2초, 요리 알바가 있으면 직접 조리하지 않고 나르기만 합니다.
|
||||
-- 조리 시간은 요리 화면을 쉬지 않고 했을 때의 시간(Recipes.expectedTime: 메뉴 고르기 + 단계 + 완성 연출)입니다.
|
||||
-- 사는 순서: 지금 살 수 있는 것(업그레이드 갈래 다음 단계, 의자, 테이블, 알바생 고용) 중 가장 싼 것부터.
|
||||
local Economy = require("../src/shared/Economy")
|
||||
local Recipes = require("../src/shared/Recipes")
|
||||
local Shop = require("../src/shared/Shop")
|
||||
|
||||
local Sim = {}
|
||||
|
||||
export type Entry = { t: number, id: string, cost: number, kind: string }
|
||||
|
||||
-- 봇이 다음에 살 것(가장 싼 것)
|
||||
local function nextBuy(shop, tables: number): { kind: string, id: string, cost: number }?
|
||||
local offers = Economy.offers(shop.levels, tables, shop.stats.seats)
|
||||
local list = {}
|
||||
for _, o in offers do
|
||||
table.insert(list, { kind = o.kind, id = o.id, cost = o.cost })
|
||||
end
|
||||
if shop.stats.staffUnlocked then
|
||||
for _, r in Economy.ROLES do
|
||||
-- 서빙·홍보 알바는 실내 분식집부터 고용(봇 가정)
|
||||
local want = if r.id == "Cook" then 1 elseif shop.stats.stage >= 2 then r.max else 0
|
||||
if (shop.staff[r.id] or 0) < want then
|
||||
table.insert(list, { kind = "hire", id = r.id, cost = r.hire })
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort(list, function(a, b)
|
||||
return a.cost < b.cost
|
||||
end)
|
||||
return list[1]
|
||||
end
|
||||
|
||||
function Sim.run(mult: number, limit: number, untilStage: number?): { Entry }
|
||||
local shop = Shop.new({ money = 0, now = 0 })
|
||||
shop.moneyMult = mult
|
||||
local tables = 1
|
||||
local dt = 0.1
|
||||
local t = 0
|
||||
local at = "stove"
|
||||
local busyUntil = 0
|
||||
local pending: string? = nil -- 끝나면 할 일: "cook" | "arrive_tables" | "arrive_stove"
|
||||
local log: { Entry } = {}
|
||||
local goal = untilStage or 3
|
||||
while t < limit do
|
||||
Shop.tick(shop, t)
|
||||
if t >= busyUntil then
|
||||
if pending == "cook" then
|
||||
Shop.cook(shop)
|
||||
elseif pending == "arrive_tables" then
|
||||
at = "tables"
|
||||
elseif pending == "arrive_stove" then
|
||||
at = "stove"
|
||||
end
|
||||
pending = nil
|
||||
if at == "stove" then
|
||||
Shop.pickup(shop)
|
||||
local cooks = shop.staff.Cook or 0
|
||||
local canCook = cooks == 0 and not Shop.handFull(shop) and Shop.nextCookMenu(shop) ~= nil
|
||||
if canCook then
|
||||
pending = "cook"
|
||||
local menu = Shop.nextCookMenu(shop) :: string
|
||||
busyUntil = t + Recipes.expectedTime(menu, shop.stats.cook)
|
||||
elseif #shop.hand > 0 and (Shop.handFull(shop) or #shop.counter == 0) then
|
||||
pending = "arrive_tables"
|
||||
busyUntil = t + Economy.WALK / 2
|
||||
end
|
||||
else
|
||||
for id, c in shop.customers do
|
||||
if c.state == "waiting" then
|
||||
Shop.serve(shop, id)
|
||||
end
|
||||
end
|
||||
if #shop.hand == 0 then
|
||||
pending = "arrive_stove"
|
||||
busyUntil = t + Economy.WALK / 2
|
||||
end
|
||||
end
|
||||
end
|
||||
local b = nextBuy(shop, tables)
|
||||
-- 시급 낼 돈은 남겨 둡니다.
|
||||
local reserve = Economy.totalWage(shop.staff, shop.stats)
|
||||
if b and shop.money >= b.cost + reserve then
|
||||
if b.kind == "track" then
|
||||
Shop.buyLevel(shop, b.id)
|
||||
elseif b.kind == "hire" then
|
||||
Shop.hire(shop, b.id)
|
||||
else
|
||||
Shop.spend(shop, b.cost)
|
||||
if b.kind == "table" then
|
||||
tables += 1
|
||||
else
|
||||
Shop.setSeats(shop, shop.stats.seats + 1)
|
||||
end
|
||||
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 })
|
||||
if shop.stats.stage >= goal and b.id == "Stage" then
|
||||
break
|
||||
end
|
||||
end
|
||||
t += dt
|
||||
end
|
||||
return log
|
||||
end
|
||||
|
||||
return Sim
|
||||
201
bunsik-tycoon/vendor/ProfileStore.LICENSE.txt
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
2243
bunsik-tycoon/vendor/ProfileStore.luau
vendored
Normal file
9
rokit.toml
Normal file
@@ -0,0 +1,9 @@
|
||||
# 이 리포에서 쓰는 Roblox 개발 도구 버전 고정 (https://github.com/rojo-rbx/rokit)
|
||||
# 설치: rokit install
|
||||
|
||||
[tools]
|
||||
rojo = "rojo-rbx/rojo@7.7.1"
|
||||
selene = "Kampfkarren/selene@0.32.0"
|
||||
stylua = "JohnnyMorganz/StyLua@2.6.0"
|
||||
lune = "lune-org/lune@0.11.0"
|
||||
luau-lsp = "JohnnyMorganz/luau-lsp@1.70.1"
|
||||
3
stylua.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
column_width = 120
|
||||
indent_type = "Tabs"
|
||||
quote_style = "AutoPreferDouble"
|
||||