Compare commits

..
Author SHA1 Message Date
Ratdoku Builder f6fd807e9a v0.3.0-alpha: thirty rooms and unique guests
30 verified rooms with a unique guest head token per room, plus the level generator and tests.
2026-12-02 10:33:33 -06:00
Ratdoku Builder f957cd3c4e v0.2.0-alpha: Guest Book and House Rules
Adds the Guest Book, Settings, House Rules, and guest unlocks on the 20-room board. Rats still use the shared Crumb token.
2026-12-02 10:32:45 -06:00
30 changed files with 3940 additions and 1150 deletions

No files matched your search

+17
View File
@@ -2,6 +2,23 @@
All notable alpha milestones for Ratdoku.
## v0.3.0-alpha — Thirty Rooms & Unique Guests
- 30 verified 8×8 rooms: 20 guest rooms plus 10 bonus rooms.
- Unique guest head token per room on the board, deterministic per level.
- Rooms 21–30 reuse the 25-guest cast on the board without unlocking new Guest Book entries.
- Android debug APK rebuilt at version `0.3.0` (version code 3).
- Includes the level generator and smoke/UI tests under `tools/`.
## v0.2.0-alpha — Guest Book & House Rules
- 20 verified 8×8 rooms and the 25-guest cast.
- Guest Book gallery with five residents unlocked from the start and one guest unlocked per room.
- Settings screen: region patterns, timer, reduce motion, hold-time slider, reset progress.
- House Rules screen with illustrated rules, controls, tips, FAQ, and a 5×5 practice board.
- Win overlay shows the newly unlocked guest.
- Rats still use the shared Crumb head token; per-room guest tokens were not in this build.
## v0.1.0-alpha — First playable
- 20 verified 8×8 rooms.
+146 -29
View File
@@ -1,9 +1,7 @@
# Ratdoku — v0.1.0-alpha "First playable"
# Ratdoku
A cozy rat-hotel logic puzzle. Every guest gets a room, a floor, a corridor, and a little space from the neighbours.
This is the reconstructed first playable alpha: **20 rooms**, the Crumb head token on the board, and the core Home → Game loop. The Guest Book, Settings, and House Rules screens did not exist yet.
## Run it
1. Install **Godot 4.7 or newer** (standard edition, not .NET).
@@ -15,55 +13,174 @@ The project uses a portrait 720×1280 canvas, scaled to a 540×960 desktop windo
## How to play
- **Tap / left-click** a cell to mark it with an X. Tap an X or a guest to clear it.
- **Press and hold** (mobile) or **right-click** (PC) to check a guest in.
- **Press and hold** (mobile) or **right-click** (PC) to check a guest in. Hold or right-click a guest to check them out.
- A gold ring fills while you hold; at the hold threshold (default 0.35 s) the guest is placed.
- **Undo**, **Restart**, and **Hint** are at the bottom.
- A **gold ring** around a guest means they are already checked in and cannot be moved.
- Win when every room, floor, and corridor has exactly one rat and no two rats touch — even diagonally.
- **No guessing is required.** Every room has exactly one solution.
Every rat uses Crumb's head token in this alpha; per-room guest tokens arrived with the Guest Book.
## Each room has its own guest
Every level assigns **eight distinct guests** to its eight coloured rooms. The guest is the same across the whole room, so a blue room is always one specific rat, the yellow room another, and so on. The assignment is deterministic per level, and a level never repeats a guest across two rooms.
The board uses circular **head tokens** from `art/guests/heads/`. Crumb remains the host and appears on Home and in the win overlay.
## Screens
- **Home** — Crumb, Check in, Guest Book, House Rules, Settings.
- **Game** — board, timer, undo/restart/hint, win overlay.
- **The Guest Book** — 25 guests: five residents unlocked from the start, the other 20 unlocked one per room. Locked cards show a very faint portrait under `???` and their room number.
- **Settings** — region patterns, timer, reduce motion, hold-time slider, reset progress.
- **House Rules** — four illustrated rules, controls, tips, FAQ, and an interactive 5×5 practice board.
## Unlocks
- **Residents** (available from the start): Miso, Hilde, Pip, Nana Fig, Biscuit.
- **Room guests**: Pepper (Room 1) through Marmalade (Room 20).
- **Rooms 21–30** are bonus rooms. They use the same guest cast on the board but do not unlock a new Guest Book entry.
- Completing a room unlocks its guest and adds a “New guest” card to the win overlay.
- Crumb is the host and has a pinned card; she is not one of the 25.
## Levels
`data/levels.json` contains **20 verified 8×8 puzzles**, each starting with three gold-ringed guests.
`data/levels.json` contains **30 verified 8×8 puzzles**: 20 guest rooms plus 10 bonus rooms. Every board is generated from a legal solution, split into eight connected rooms, and checked for a single solution. Each starts with three gold-ringed guests.
## Project layout
```
scenes/
Main.tscn entry point + screen navigation
Home.tscn title screen
Game.tscn board screen + HUD + win overlay
Board.tscn custom-drawn board
Main.tscn entry point + screen navigation
Home.tscn title screen
Game.tscn board screen + HUD + win overlay
Board.tscn custom-drawn board
GuestBook.tscn gallery
Settings.tscn settings
Rulebook.tscn house rules + interactive tutorial
scripts/
Main.gd navigation/back stack
Home.gd home screen
Game.gd level flow, timer, win overlay
Board.gd drawing, input, undo, hints
Rules.gd pure win/conflict rules
Levels.gd JSON level loader
Guests.gd guest manifest loader
SaveGame.gd autoload: settings + progress
Palette.gd colours
UI.gd button/label/panel helpers
RatPortrait.gd fallback vector mascot
Main.gd navigation/back stack
Home.gd home screen
Game.gd level flow, timer, unlock flow, win overlay
Board.gd drawing, input, undo, hints, per-room guests, settings
Rules.gd pure win/conflict rules
Levels.gd JSON level loader
Guests.gd guest manifest loader
SaveGame.gd autoload: settings + progress
GuestBook.gd gallery, locked cards, detail sheet
Settings.gd settings toggles + reset
Rulebook.gd handbook content + 5×5 tutorial
MiniDiagram.gd rule illustrations
Palette.gd colours
UI.gd button/label/panel helpers
RatPortrait.gd fallback vector mascot
art/
crumb.png, crumb_head.png
guests/{cards,thumbs,heads}/<id>.png
crumb.png full mascot
crumb_head.png circular head token used on Home/win
guests/
cards/<id>.png 512 detail portraits
thumbs/<id>.png 256 gallery thumbnails
heads/<id>.png 256 circular board tokens
source/ 1024 originals, raw renders, contact sheets (ignored by Godot/export)
data/
levels.json 20 verified 8×8 puzzles
guests.json 25 guest entries
tutorial.json 5×5 practice puzzle
levels.json 30 verified 8×8 puzzles
guests.json 25 guest entries
tutorial.json 5×5 practice puzzle
tools/
generate_levels.gd headless 8×8 generator (appends new rooms)
smoke_test.gd rules/board smoke test
ui_test.gd settings/gallery/unlock/tutorial test
screenshot.gd dev screenshots
build_android.ps1 Android export helper
workflows/ Krea2 guest-generation variants
export_presets.cfg Android debug preset
build/Ratdoku-v0.3.0-alpha.apk installable debug APK
```
## Save data
`user://ratdoku_save.json` stores completed rooms, `last_room`, and settings.
`user://ratdoku_save.json` stores completed rooms, unlocked guests, `last_room`, and settings. “Reset progress” clears rooms and unlocks but keeps settings.
## Regenerate levels
```powershell
& "C:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe" `
--headless --path . --script res://tools/generate_levels.gd
```
The generator appends until `data/levels.json` contains 30 rooms. It keeps the existing pack and only creates the missing rooms.
## Guest art
The 25 guest portraits were generated from the `Krea2_Turbo_Uncensored` ComfyUI workflow with a shared chibi/gouache prompt and per-character props. The final prompt variants are in `tools/workflows/final_guests/`.
Runtime assets:
- `art/guests/heads/<id>.png` — board tokens
- `art/guests/cards/<id>.png` — detail portraits
- `art/guests/thumbs/<id>.png` — gallery thumbnails
Source 1024 renders and contact sheets live in `art/guests/source/` and are excluded from the Android export.
## Android APK
`build/Ratdoku-v0.1.0-alpha.apk` is a debug-signed, arm64-v8a build:
The current APK is:
```
build/Ratdoku-v0.3.0-alpha.apk
```
It is a **debug-signed, arm64-v8a** APK:
- Package: `com.ratdoku.game`
- Version: `0.1.0` (version code 1)
- Version: `0.3.0` (version code 3)
- Min SDK: 24 (Android 7.0)
- Target SDK: 36
- Size: about 41 MB
- Portrait orientation
To install, copy the APK to the phone, open it, and allow “Install unknown apps” for the file manager/browser. Or with a USB-connected phone and USB debugging:
```powershell
& "E:\AndroidTools\sdk\platform-tools\adb.exe" install -r "build\Ratdoku-v0.3.0-alpha.apk"
```
### Toolchain
The local Android build uses:
- JDK: `E:\AndroidTools\jdk-17.0.21.1+2`
- Android SDK: `E:\AndroidTools\sdk`
- Build tools: `35.0.0`
- Godot editor settings: `export/android/android_sdk_path`, `java_sdk_path`, debug keystore.
Rebuild with:
```powershell
.\tools\build_android.ps1
```
If you want a Play Store build, switch `gradle_build/export_format` to AAB, use a release keystore, and set `package/signed` appropriately. The current APK is for direct testing, not store upload.
## Tests
```powershell
& "C:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe" `
--headless --path . --script res://tools/smoke_test.gd
```
```powershell
& "C:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe" `
--headless --path . --script res://tools/ui_test.gd
```
`ui_test.gd` checks settings propagation, room-1 → Pepper unlock, gallery progress, and the interactive 5×5 tutorial. Both tests reset the save when they finish.
## Current scope
- 30 verified 8×8 rooms (20 guest rooms + 10 bonus)
- Unique guest per room per level
- Interactive 5×5 tutorial
- 25 guest portraits + Crumb
- Settings, gallery, rulebook, unlock flow
- Installable Android debug APK
- No audio yet, no daily puzzle, no release keystore/AAB yet
+2210 -1110
View File
File diff suppressed because it is too large. Load diff
+3 -3
View File
@@ -9,7 +9,7 @@ custom_features=""
export_filter="all_resources"
include_filter="data/*.json"
exclude_filter="art/guests/source/*"
export_path="build/Ratdoku-v0.1.0-alpha.apk"
export_path="build/Ratdoku-v0.3.0-alpha.apk"
encryption_include_filters=""
encryption_exclude_filters=""
seed=0
@@ -32,8 +32,8 @@ architectures/armeabi-v7a=false
architectures/arm64-v8a=true
architectures/x86=false
architectures/x86_64=false
version/code=1
version/name="0.1.0"
version/code=3
version/name="0.3.0"
package/unique_name="com.ratdoku.game"
package/name="Ratdoku"
package/signed=true
+1 -1
View File
@@ -12,7 +12,7 @@ config_version=5
config/name="Ratdoku"
run/main_scene="res://scenes/Main.tscn"
config/version="0.1.0-alpha"
config/version="0.3.0-alpha"
config/features=PackedStringArray("4.7", "GL Compatibility")
config/icon="res://icon.png"
+12
View File
@@ -0,0 +1,12 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://scripts/GuestBook.gd" id="1_guestbook"]
[node name="GuestBook" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_guestbook")
+12
View File
@@ -0,0 +1,12 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://scripts/Rulebook.gd" id="1_rulebook"]
[node name="Rulebook" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_rulebook")
+12
View File
@@ -0,0 +1,12 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://scripts/Settings.gd" id="1_settings"]
[node name="Settings" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_settings")
-5
View File
@@ -249,11 +249,6 @@ func _draw_x(rect: Rect2, color: Color) -> void:
func _assign_region_rats() -> void:
# v0.1.0-alpha: no per-room guest tokens yet. Leave the table empty so every
# rat on the board falls back to the shared Crumb head token.
if true:
return
region_rats.clear()
region_textures.clear()
+36 -2
View File
@@ -1,6 +1,7 @@
extends Control
signal back_pressed
signal guest_book_pressed
const BoardScene = preload("res://scenes/Board.tscn")
const DEFAULT_STATUS := "One guest per room, floor and corridor.\nTap = X · Hold or right-click = check in."
@@ -18,6 +19,9 @@ var timer_label: Label
var status_label: Label
var win_detail: Label
var overlay: ColorRect
var new_guest_box: HBoxContainer
var new_guest_label: Label
var new_guest_portrait: TextureRect
func _ready() -> void:
@@ -130,10 +134,32 @@ func _build_win_overlay() -> void:
box.add_child(win_detail)
box.add_child(UI.label("Sweet dreams, little guests.", 18, Palette.MUTED))
new_guest_box = HBoxContainer.new()
new_guest_box.alignment = BoxContainer.ALIGNMENT_CENTER
new_guest_box.add_theme_constant_override("separation", 8)
new_guest_box.visible = false
box.add_child(new_guest_box)
new_guest_portrait = TextureRect.new()
new_guest_portrait.custom_minimum_size = Vector2(64, 64)
new_guest_portrait.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
new_guest_portrait.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
new_guest_box.add_child(new_guest_portrait)
new_guest_label = UI.label("", 14, Palette.INK)
new_guest_label.custom_minimum_size = Vector2(250, 0)
new_guest_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
new_guest_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
new_guest_box.add_child(new_guest_label)
var next := UI.button("Next room", true, 56)
box.add_child(next)
next.pressed.connect(_on_next)
var book := UI.button("Guest Book", false, 46)
box.add_child(book)
book.pressed.connect(func() -> void: guest_book_pressed.emit())
func _make_win_portrait() -> Control:
if ResourceLoader.exists("res://art/crumb_head.png"):
@@ -147,7 +173,7 @@ func _make_win_portrait() -> Control:
func start_level(index: int) -> void:
if levels.is_empty():
status_label.text = "No rooms found — check data/levels.json."
status_label.text = "No rooms yet — run tools/generate_levels.gd in Godot."
status_label.add_theme_color_override("font_color", Palette.RED)
return
@@ -161,6 +187,7 @@ func start_level(index: int) -> void:
elapsed_ms = 0
win_shown = false
overlay.visible = false
new_guest_box.visible = false
if level.get("clues", []).size() > 0:
status_label.text = "Gold-ringed guests are already checked in.\nTap = X · Hold or right-click = check in."
else:
@@ -203,7 +230,14 @@ func _on_solved() -> void:
status_label.add_theme_color_override("font_color", Palette.INK)
win_detail.text = "Room %d · %s" % [level_index + 1, _format_time(elapsed_ms)]
SaveGame.complete_room(current_level_id, level_index + 1)
var unlocked_id := SaveGame.complete_room(current_level_id, level_index + 1)
if unlocked_id != "":
var guest := Guests.by_id(unlocked_id)
new_guest_label.text = "New guest: %s the %s" % [str(guest.get("name", "")), str(guest.get("role", ""))]
new_guest_portrait.texture = load(Guests.portrait(unlocked_id, "thumbs"))
new_guest_box.visible = true
else:
new_guest_box.visible = false
await get_tree().create_timer(0.45).timeout
if win_shown:
+254
View File
@@ -0,0 +1,254 @@
extends Control
signal back_pressed
var grid: GridContainer
var progress_label: Label
var status_label: Label
var detail_layer: ColorRect
var detail_portrait: TextureRect
var detail_name: Label
var detail_role: Label
var detail_meta: Label
var detail_bio: Label
var detail_snack: Label
var detail_status: Label
func _ready() -> void:
var margin := MarginContainer.new()
margin.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
margin.add_theme_constant_override("margin_left", 20)
margin.add_theme_constant_override("margin_right", 20)
margin.add_theme_constant_override("margin_top", 16)
margin.add_theme_constant_override("margin_bottom", 16)
add_child(margin)
var column := VBoxContainer.new()
column.add_theme_constant_override("separation", 10)
margin.add_child(column)
var top := HBoxContainer.new()
top.add_theme_constant_override("separation", 10)
column.add_child(top)
var back := UI.button("‹", false, 44)
back.custom_minimum_size = Vector2(48, 44)
back.add_theme_font_size_override("font_size", 30)
back.pressed.connect(func() -> void: back_pressed.emit())
top.add_child(back)
var title := UI.label("The Guest Book", 30)
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
title.size_flags_horizontal = Control.SIZE_EXPAND_FILL
top.add_child(title)
progress_label = UI.label("5 of 25 checked in", 15, Palette.MUTED)
progress_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
progress_label.autowrap_mode = TextServer.AUTOWRAP_OFF
progress_label.custom_minimum_size = Vector2(150, 0)
progress_label.size_flags_horizontal = Control.SIZE_SHRINK_END
top.add_child(progress_label)
var crumb := _make_crumb_card()
column.add_child(crumb)
status_label = UI.label("Tap a guest to read their card.", 14, Palette.MUTED)
status_label.custom_minimum_size = Vector2(0, 28)
column.add_child(status_label)
var scroll := ScrollContainer.new()
scroll.size_flags_horizontal = Control.SIZE_EXPAND_FILL
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
column.add_child(scroll)
grid = GridContainer.new()
grid.columns = 3
grid.size_flags_horizontal = Control.SIZE_EXPAND_FILL
grid.add_theme_constant_override("h_separation", 8)
grid.add_theme_constant_override("v_separation", 8)
scroll.add_child(grid)
_build_detail()
SaveGame.progress_changed.connect(refresh)
refresh()
func _make_crumb_card() -> PanelContainer:
var panel := UI.panel(Palette.PAPER, 20, 12)
var row := HBoxContainer.new()
row.add_theme_constant_override("separation", 12)
panel.add_child(row)
var portrait := TextureRect.new()
portrait.custom_minimum_size = Vector2(86, 86)
portrait.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
portrait.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
if ResourceLoader.exists("res://art/crumb_head.png"):
portrait.texture = load("res://art/crumb_head.png")
elif ResourceLoader.exists("res://art/crumb.png"):
portrait.texture = load("res://art/crumb.png")
row.add_child(portrait)
var text := VBoxContainer.new()
text.size_flags_horizontal = Control.SIZE_EXPAND_FILL
text.alignment = BoxContainer.ALIGNMENT_CENTER
row.add_child(text)
var name := UI.label("Crumb", 22)
name.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
text.add_child(name)
var role := UI.label("Innkeeper · always in", 14, Palette.MUTED)
role.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
text.add_child(role)
return panel
func refresh() -> void:
if grid == null:
return
for child in grid.get_children():
child.free()
var guests := Guests.all()
var unlocked := SaveGame.unlocked_count(guests)
progress_label.text = "%d of %d checked in" % [unlocked, guests.size()]
for guest in guests:
grid.add_child(_make_card(guest))
func _make_card(guest: Dictionary) -> PanelContainer:
var id := str(guest["id"])
var locked := not SaveGame.is_guest_unlocked(id)
var accent := Color(str(guest.get("accent", "#8c7460")))
var panel := UI.panel(Palette.PAPER, 18, 8)
panel.custom_minimum_size = Vector2(188, 224)
panel.size_flags_horizontal = Control.SIZE_EXPAND_FILL
panel.mouse_filter = Control.MOUSE_FILTER_STOP
panel.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
panel.gui_input.connect(_on_card_input.bind(guest, locked))
var box := VBoxContainer.new()
box.add_theme_constant_override("separation", 2)
box.mouse_filter = Control.MOUSE_FILTER_IGNORE
panel.add_child(box)
var portrait := Control.new()
portrait.custom_minimum_size = Vector2(170, 170)
portrait.mouse_filter = Control.MOUSE_FILTER_IGNORE
box.add_child(portrait)
var texture := TextureRect.new()
texture.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
texture.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
texture.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
texture.mouse_filter = Control.MOUSE_FILTER_IGNORE
texture.texture = load(Guests.portrait(id, "thumbs"))
portrait.add_child(texture)
if locked:
texture.modulate = Color(1.0, 1.0, 1.0, 0.18)
var veil := ColorRect.new()
veil.color = Color(0.98, 0.93, 0.84, 0.78)
veil.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
veil.mouse_filter = Control.MOUSE_FILTER_IGNORE
portrait.add_child(veil)
var mystery := UI.label("???", 34, Palette.INK)
mystery.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
mystery.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
mystery.mouse_filter = Control.MOUSE_FILTER_IGNORE
portrait.add_child(mystery)
var name_label := UI.label("???" if locked else str(guest["name"]), 17)
name_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
box.add_child(name_label)
var role_text := "Room %d" % int(guest.get("unlock_room", 0)) if locked else str(guest["role"])
var role_label := UI.label(role_text, 13, Palette.MUTED if locked else accent)
role_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
box.add_child(role_label)
return panel
func _on_card_input(event: InputEvent, guest: Dictionary, locked: bool) -> void:
if not (event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT):
return
if locked:
var room := int(guest.get("unlock_room", 0))
status_label.text = "Check in a guest from Room %d to meet them." % room
status_label.add_theme_color_override("font_color", Palette.RED)
else:
status_label.text = "Tap a guest to read their card."
status_label.add_theme_color_override("font_color", Palette.MUTED)
_show_detail(guest)
func _build_detail() -> void:
detail_layer = ColorRect.new()
detail_layer.color = Color(0.18, 0.12, 0.08, 0.52)
detail_layer.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
detail_layer.mouse_filter = Control.MOUSE_FILTER_STOP
detail_layer.visible = false
add_child(detail_layer)
var center := CenterContainer.new()
center.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
detail_layer.add_child(center)
var panel := UI.panel(Palette.CREAM, 32, 24)
panel.custom_minimum_size = Vector2(420, 0)
center.add_child(panel)
var box := VBoxContainer.new()
box.add_theme_constant_override("separation", 8)
panel.add_child(box)
detail_portrait = TextureRect.new()
detail_portrait.custom_minimum_size = Vector2(300, 300)
detail_portrait.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
detail_portrait.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
box.add_child(detail_portrait)
detail_name = UI.label("Name", 30)
box.add_child(detail_name)
detail_role = UI.label("Role", 18, Palette.MUTED)
box.add_child(detail_role)
detail_meta = UI.label("Variety", 15, Palette.MUTED)
box.add_child(detail_meta)
detail_bio = UI.label("", 17)
detail_bio.custom_minimum_size = Vector2(0, 52)
box.add_child(detail_bio)
detail_snack = UI.label("", 15, Palette.MUTED)
box.add_child(detail_snack)
detail_status = UI.label("", 14, Palette.MUTED)
box.add_child(detail_status)
var close := UI.button("Close", false, 50)
close.pressed.connect(func() -> void: detail_layer.visible = false)
box.add_child(close)
func _show_detail(guest: Dictionary) -> void:
var id := str(guest["id"])
var accent := Color(str(guest.get("accent", "#8c7460")))
detail_portrait.texture = load(Guests.portrait(id, "cards"))
detail_name.text = str(guest["name"])
detail_role.text = "%s · %s" % [str(guest["role"]), str(guest.get("pronouns", ""))]
detail_role.add_theme_color_override("font_color", accent)
detail_meta.text = "%s coat · %s" % [str(guest.get("variety", "")), str(guest.get("coat", ""))]
detail_bio.text = str(guest.get("personality", ""))
detail_snack.text = "Favourite snack: %s" % str(guest.get("snack", ""))
detail_status.text = "Checked in · Room %d" % int(guest.get("unlock_room", 0))
if int(guest.get("unlock_room", 0)) == 0:
detail_status.text = "Resident · always in"
detail_layer.visible = true
+1
View File
@@ -0,0 +1 @@
uid://cfdurhj51k6me
+28
View File
@@ -1,6 +1,9 @@
extends Control
signal play_pressed
signal guest_book_pressed
signal settings_pressed
signal rules_pressed
func _ready() -> void:
@@ -49,8 +52,33 @@ func _ready() -> void:
column.add_child(play_center)
play.pressed.connect(func() -> void: play_pressed.emit())
var secondary := HBoxContainer.new()
secondary.alignment = BoxContainer.ALIGNMENT_CENTER
secondary.add_theme_constant_override("separation", 10)
column.add_child(secondary)
var book := UI.button("Guest Book", false, 52)
book.custom_minimum_size = Vector2(150, 52)
book.pressed.connect(func() -> void: guest_book_pressed.emit())
secondary.add_child(book)
var rules := UI.button("House Rules", false, 52)
rules.custom_minimum_size = Vector2(160, 52)
rules.pressed.connect(func() -> void: rules_pressed.emit())
secondary.add_child(rules)
column.add_child(UI.label("No ads. No lives. Just rats.", 16, Palette.MUTED))
var settings := UI.button("Settings", false, 40)
settings.add_theme_font_size_override("font_size", 16)
settings.set_anchors_preset(Control.PRESET_TOP_RIGHT)
settings.offset_left = -150
settings.offset_top = 24
settings.offset_right = -24
settings.offset_bottom = 64
settings.pressed.connect(func() -> void: settings_pressed.emit())
add_child(settings)
func _make_mascot() -> Control:
if ResourceLoader.exists("res://art/crumb.png"):
+31
View File
@@ -2,9 +2,15 @@ extends Control
const HomeScene = preload("res://scenes/Home.tscn")
const GameScene = preload("res://scenes/Game.tscn")
const GuestBookScene = preload("res://scenes/GuestBook.tscn")
const SettingsScene = preload("res://scenes/Settings.tscn")
const RulebookScene = preload("res://scenes/Rulebook.tscn")
var home
var game
var guest_book
var settings
var rulebook
var screens := {}
var current := "home"
var nav_stack: Array[String] = []
@@ -20,14 +26,34 @@ func _ready() -> void:
home = HomeScene.instantiate()
_add_screen(home)
home.play_pressed.connect(_on_play)
home.guest_book_pressed.connect(func() -> void: show_screen("guest_book"))
home.settings_pressed.connect(func() -> void: show_screen("settings"))
home.rules_pressed.connect(func() -> void: show_screen("rules"))
game = GameScene.instantiate()
_add_screen(game)
game.back_pressed.connect(go_back)
game.guest_book_pressed.connect(func() -> void: show_screen("guest_book"))
guest_book = GuestBookScene.instantiate()
_add_screen(guest_book)
guest_book.back_pressed.connect(go_back)
settings = SettingsScene.instantiate()
_add_screen(settings)
settings.back_pressed.connect(go_back)
settings.rules_pressed.connect(func() -> void: show_screen("rules"))
rulebook = RulebookScene.instantiate()
_add_screen(rulebook)
rulebook.back_pressed.connect(go_back)
screens = {
"home": home,
"game": game,
"guest_book": guest_book,
"settings": settings,
"rules": rulebook,
}
show_screen("home", false)
@@ -53,6 +79,11 @@ func show_screen(name: String, push: bool = true) -> void:
current = name
if name == "guest_book":
guest_book.refresh()
elif name == "settings":
settings.refresh()
func go_back() -> void:
if nav_stack.is_empty():
+104
View File
@@ -0,0 +1,104 @@
class_name MiniDiagram
extends Control
## Tiny 5x5 rule illustrations for the House Rules page.
const REGIONS := [
[0, 0, 0, 0, 0],
[1, 1, 1, 1, 0],
[3, 1, 4, 2, 2],
[3, 3, 4, 2, 2],
[3, 4, 4, 4, 2],
]
var mode := "row"
func _ready() -> void:
mouse_filter = Control.MOUSE_FILTER_IGNORE
custom_minimum_size = Vector2(150, 150)
func _draw() -> void:
var side: float = min(size.x, size.y)
var cell := side / 5.0
var origin := (size - Vector2(side, side)) * 0.5
var board := Rect2(origin, Vector2(side, side))
for r in 5:
for c in 5:
var rect := Rect2(origin + Vector2(c * cell, r * cell), Vector2(cell, cell))
var region := int(REGIONS[r][c])
var color: Color = Palette.REGION_COLORS[region % Palette.REGION_COLORS.size()]
draw_rect(rect.grow(0.5), color)
# Highlight
var accent := Color(0.91, 0.71, 0.36, 0.38)
if mode == "row":
draw_rect(Rect2(origin + Vector2(0, 2 * cell), Vector2(side, cell)), accent)
elif mode == "col":
draw_rect(Rect2(origin + Vector2(2 * cell, 0), Vector2(cell, side)), accent)
elif mode == "region":
for r in 5:
for c in 5:
if int(REGIONS[r][c]) == 0:
draw_rect(Rect2(origin + Vector2(c * cell, r * cell), Vector2(cell, cell)), accent)
# Grid and room walls
for i in range(6):
var x := origin.x + i * cell
var y := origin.y + i * cell
draw_line(Vector2(x, origin.y), Vector2(x, origin.y + side), Palette.GRID, 1.0, true)
draw_line(Vector2(origin.x, y), Vector2(origin.x + side, y), Palette.GRID, 1.0, true)
for r in 5:
for c in 5:
var rect := Rect2(origin + Vector2(c * cell, r * cell), Vector2(cell, cell))
if c == 4 or int(REGIONS[r][c]) != int(REGIONS[r][c + 1]):
draw_line(rect.position + Vector2(cell, 0), rect.position + Vector2(cell, cell), Palette.WALL, 3.0, true)
if r == 4 or int(REGIONS[r][c]) != int(REGIONS[r + 1][c]):
draw_line(rect.position + Vector2(0, cell), rect.position + Vector2(cell, cell), Palette.WALL, 3.0, true)
draw_rect(board, Palette.WALL, false, 4.0, true)
var rat_cell := Vector2i(2, 2)
if mode == "region":
rat_cell = Vector2i(0, 2)
_draw_rat(origin, cell, rat_cell)
if mode == "touch":
for dr in range(-1, 2):
for dc in range(-1, 2):
if dr == 0 and dc == 0:
continue
var r := rat_cell.x + dr
var c := rat_cell.y + dc
if r >= 0 and r < 5 and c >= 0 and c < 5:
_draw_x(origin, cell, Vector2i(r, c))
var center := origin + (Vector2(rat_cell) + Vector2(0.5, 0.5)) * cell
draw_arc(center, cell * 0.40, 0.0, TAU, 24, Palette.RED, 2.5, true)
func _draw_rat(origin: Vector2, cell: float, at: Vector2i) -> void:
var c := origin + (Vector2(at) + Vector2(0.5, 0.5)) * cell
var fur := Color("8f6a4a")
var ear := Color("e0a29a")
draw_circle(c + Vector2(-0.16, -0.14) * cell, cell * 0.12, fur)
draw_circle(c + Vector2(0.16, -0.14) * cell, cell * 0.12, fur)
draw_circle(c + Vector2(-0.16, -0.14) * cell, cell * 0.07, ear)
draw_circle(c + Vector2(0.16, -0.14) * cell, cell * 0.07, ear)
draw_circle(c, cell * 0.22, fur)
draw_circle(c + Vector2(0, 0.08) * cell, cell * 0.12, Color("f6e4c6"))
draw_circle(c + Vector2(-0.08, -0.02) * cell, cell * 0.025, Palette.INK)
draw_circle(c + Vector2(0.08, -0.02) * cell, cell * 0.025, Palette.INK)
draw_circle(c + Vector2(0, 0.08) * cell, cell * 0.02, Color("c9736b"))
func _draw_x(origin: Vector2, cell: float, at: Vector2i) -> void:
var rect := Rect2(origin + Vector2(at.x * cell, at.y * cell), Vector2(cell, cell))
var inset := cell * 0.30
var a := rect.position + Vector2(inset, inset)
var b := rect.position + Vector2(cell - inset, cell - inset)
var c := rect.position + Vector2(cell - inset, inset)
var d := rect.position + Vector2(inset, cell - inset)
draw_line(a, b, Palette.RED, 2.0, true)
draw_line(c, d, Palette.RED, 2.0, true)
+1
View File
@@ -0,0 +1 @@
uid://pss1icj4438q
+178
View File
@@ -0,0 +1,178 @@
extends Control
signal back_pressed
const BoardScene = preload("res://scenes/Board.tscn")
var tutorial_board: Board
var tutorial_status: Label
func _ready() -> void:
var margin := MarginContainer.new()
margin.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
margin.add_theme_constant_override("margin_left", 24)
margin.add_theme_constant_override("margin_right", 24)
margin.add_theme_constant_override("margin_top", 18)
margin.add_theme_constant_override("margin_bottom", 18)
add_child(margin)
var column := VBoxContainer.new()
column.add_theme_constant_override("separation", 12)
margin.add_child(column)
var top := HBoxContainer.new()
top.add_theme_constant_override("separation", 10)
column.add_child(top)
var back := UI.button("‹", false, 44)
back.custom_minimum_size = Vector2(48, 44)
back.add_theme_font_size_override("font_size", 30)
back.pressed.connect(func() -> void: back_pressed.emit())
top.add_child(back)
var title := UI.label("House Rules", 30)
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
title.size_flags_horizontal = Control.SIZE_EXPAND_FILL
top.add_child(title)
var scroll := ScrollContainer.new()
scroll.size_flags_horizontal = Control.SIZE_EXPAND_FILL
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
column.add_child(scroll)
var content := VBoxContainer.new()
content.size_flags_horizontal = Control.SIZE_EXPAND_FILL
content.add_theme_constant_override("separation", 10)
scroll.add_child(content)
content.add_child(_heading("Welcome to the Rat Hotel"))
content.add_child(_body("Crumb runs a small hotel for travelling rats. Every guest wants a room of their own — and a little space from the neighbours."))
content.add_child(_heading("The four house rules"))
content.add_child(_rule_row("One guest per room", "Each coloured room holds exactly one rat.", "region"))
content.add_child(_rule_row("One guest per floor", "Each row holds exactly one rat.", "row"))
content.add_child(_rule_row("One guest per corridor", "Each column holds exactly one rat.", "col"))
content.add_child(_rule_row("No shared walls or corners", "Rats cannot touch, not even diagonally.", "touch"))
content.add_child(_heading("Checking in"))
content.add_child(_body("Tap or left-click to mark a cell with an X. Tap an X or a guest to clear it. Press and hold on mobile, or right-click on PC, to check a guest in. A gold ring fills while you hold."))
content.add_child(_body("Gold-ringed guests are already checked in and cannot be moved. Undo is unlimited."))
content.add_child(_heading("Try a tiny room"))
content.add_child(_body("One guest is already checked in. Place the other four. No guessing required."))
var board_center := CenterContainer.new()
content.add_child(board_center)
tutorial_board = BoardScene.instantiate() as Board
tutorial_board.custom_minimum_size = Vector2(300, 300)
tutorial_board.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
tutorial_board.solved.connect(_on_tutorial_solved)
board_center.add_child(tutorial_board)
var controls := HBoxContainer.new()
controls.alignment = BoxContainer.ALIGNMENT_CENTER
controls.add_theme_constant_override("separation", 10)
content.add_child(controls)
var reset := UI.button("Reset", false, 48)
reset.custom_minimum_size = Vector2(120, 48)
reset.pressed.connect(_on_tutorial_reset)
controls.add_child(reset)
var hint := UI.button("Hint", true, 48)
hint.custom_minimum_size = Vector2(120, 48)
hint.pressed.connect(_on_tutorial_hint)
controls.add_child(hint)
tutorial_status = UI.label("Tap a cell to mark X. Hold or right-click to check in.", 14, Palette.MUTED)
content.add_child(tutorial_status)
content.add_child(_heading("Housekeeping tips"))
content.add_child(_body("Start with the smallest room. Mark Xs as you place guests — the board does it for you. If a room's open cells all sit in one row, that row's guest belongs to that room. Every room has exactly one solution, and it never requires guessing."))
content.add_child(_body("If you get stuck, the Hint button reveals one correct guest. In the real rooms, Crumb's hints are always free."))
content.add_child(_heading("Questions"))
content.add_child(_body("Why can't the rats touch? Every guest is a little grumpy after a long journey and wants their own space."))
content.add_child(_body("Why do some guests have gold rings? They checked in early. They are part of the puzzle, not a mistake."))
var gap := Control.new()
gap.custom_minimum_size = Vector2(0, 20)
content.add_child(gap)
var tutorial := _load_tutorial()
if not tutorial.is_empty():
tutorial_board.set_level(tutorial)
func _heading(text: String) -> Label:
var label := UI.label(text, 24)
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
return label
func _body(text: String, font_size: int = 16) -> Label:
var label := UI.label(text, font_size, Palette.MUTED)
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
return label
func _rule_row(title: String, body: String, mode: String) -> PanelContainer:
var panel := UI.panel(Palette.PAPER, 20, 12)
var row := HBoxContainer.new()
row.add_theme_constant_override("separation", 12)
panel.add_child(row)
var diagram := MiniDiagram.new()
diagram.mode = mode
diagram.custom_minimum_size = Vector2(130, 130)
row.add_child(diagram)
var text := VBoxContainer.new()
text.size_flags_horizontal = Control.SIZE_EXPAND_FILL
text.alignment = BoxContainer.ALIGNMENT_CENTER
row.add_child(text)
var heading := UI.label(title, 19)
heading.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
text.add_child(heading)
var detail := UI.label(body, 14, Palette.MUTED)
detail.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
text.add_child(detail)
return panel
func _load_tutorial() -> Dictionary:
if not FileAccess.file_exists("res://data/tutorial.json"):
return {}
var file := FileAccess.open("res://data/tutorial.json", FileAccess.READ)
if file == null:
return {}
var parsed = JSON.parse_string(file.get_as_text())
file.close()
if typeof(parsed) == TYPE_DICTIONARY:
return parsed
return {}
func _on_tutorial_reset() -> void:
tutorial_board.restart()
tutorial_status.text = "Tap a cell to mark X. Hold or right-click to check in."
tutorial_status.add_theme_color_override("font_color", Palette.MUTED)
func _on_tutorial_hint() -> void:
if tutorial_board.hint():
tutorial_status.text = "Crumb tapped the right room."
tutorial_status.add_theme_color_override("font_color", Palette.MUTED)
else:
tutorial_status.text = "Everyone is already checked in."
tutorial_status.add_theme_color_override("font_color", Palette.MUTED)
func _on_tutorial_solved() -> void:
tutorial_status.text = "Everyone checked in. Nicely done."
tutorial_status.add_theme_color_override("font_color", Palette.INK)
+1
View File
@@ -0,0 +1 @@
uid://0wfmdeab7oh3
+169
View File
@@ -0,0 +1,169 @@
extends Control
signal back_pressed
signal rules_pressed
var toggles := {}
var hold_slider: HSlider
var hold_value: Label
var reset_status: Label
var reset_dialog: ConfirmationDialog
func _ready() -> void:
var margin := MarginContainer.new()
margin.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
margin.add_theme_constant_override("margin_left", 24)
margin.add_theme_constant_override("margin_right", 24)
margin.add_theme_constant_override("margin_top", 18)
margin.add_theme_constant_override("margin_bottom", 18)
add_child(margin)
var column := VBoxContainer.new()
column.add_theme_constant_override("separation", 14)
margin.add_child(column)
var top := HBoxContainer.new()
top.add_theme_constant_override("separation", 10)
column.add_child(top)
var back := UI.button("‹", false, 44)
back.custom_minimum_size = Vector2(48, 44)
back.add_theme_font_size_override("font_size", 30)
back.pressed.connect(func() -> void: back_pressed.emit())
top.add_child(back)
var title := UI.label("Settings", 30)
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
title.size_flags_horizontal = Control.SIZE_EXPAND_FILL
top.add_child(title)
var scroll := ScrollContainer.new()
scroll.size_flags_horizontal = Control.SIZE_EXPAND_FILL
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
column.add_child(scroll)
var list := VBoxContainer.new()
list.size_flags_horizontal = Control.SIZE_EXPAND_FILL
list.add_theme_constant_override("separation", 10)
scroll.add_child(list)
_add_toggle(list, "Region patterns", "Dots and stripes on the coloured rooms. Helps with colour blindness.", "patterns")
_add_toggle(list, "Show timer", "Keep the clock visible while you solve.", "show_timer")
_add_toggle(list, "Reduce motion", "Stop the rat bob and placement pop. The hold ring still works.", "reduce_motion")
_add_hold_row(list)
list.add_child(UI.label("House Rules", 18, Palette.MUTED))
var rules := UI.button("Open the handbook", false, 52)
rules.pressed.connect(func() -> void: rules_pressed.emit())
list.add_child(rules)
list.add_child(UI.label("Progress", 18, Palette.MUTED))
var reset := UI.button("Reset progress", false, 52)
reset.add_theme_color_override("font_color", Palette.RED)
reset.add_theme_color_override("font_hover_color", Palette.RED)
reset.pressed.connect(_on_reset_pressed)
list.add_child(reset)
reset_status = UI.label("Completed rooms and unlocked guests will be cleared. Settings stay.", 15, Palette.MUTED)
list.add_child(reset_status)
list.add_child(UI.label("Ratdoku 0.2 · made with Godot · no ads, no tracking", 14, Palette.MUTED))
reset_dialog = ConfirmationDialog.new()
reset_dialog.title = "Reset progress?"
reset_dialog.dialog_text = "This clears completed rooms and unlocked guests. Your settings stay as they are."
reset_dialog.confirmed.connect(_on_reset_confirmed)
add_child(reset_dialog)
refresh()
func _add_toggle(parent: VBoxContainer, title: String, subtitle: String, key: String) -> void:
var panel := UI.panel(Palette.PAPER, 20, 14)
var row := HBoxContainer.new()
row.add_theme_constant_override("separation", 10)
panel.add_child(row)
var text := VBoxContainer.new()
text.size_flags_horizontal = Control.SIZE_EXPAND_FILL
text.add_theme_constant_override("separation", 2)
row.add_child(text)
var label := UI.label(title, 19)
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
text.add_child(label)
var detail := UI.label(subtitle, 14, Palette.MUTED)
detail.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
text.add_child(detail)
var check := CheckButton.new()
check.button_pressed = bool(SaveGame.get_setting(key))
check.add_theme_font_size_override("font_size", 18)
check.add_theme_color_override("font_color", Palette.INK)
check.toggled.connect(func(on: bool) -> void: SaveGame.set_setting(key, on))
row.add_child(check)
toggles[key] = check
parent.add_child(panel)
func _add_hold_row(parent: VBoxContainer) -> void:
var panel := UI.panel(Palette.PAPER, 20, 14)
var column := VBoxContainer.new()
column.add_theme_constant_override("separation", 6)
panel.add_child(column)
var title := UI.label("Hold time", 19)
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
column.add_child(title)
var detail := UI.label("How long to press before a guest checks in.", 14, Palette.MUTED)
detail.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
column.add_child(detail)
var row := HBoxContainer.new()
row.add_theme_constant_override("separation", 10)
column.add_child(row)
hold_slider = HSlider.new()
hold_slider.min_value = 0.20
hold_slider.max_value = 0.50
hold_slider.step = 0.05
hold_slider.value = float(SaveGame.get_setting("hold_seconds"))
hold_slider.size_flags_horizontal = Control.SIZE_EXPAND_FILL
hold_slider.custom_minimum_size = Vector2(180, 32)
hold_slider.value_changed.connect(_on_hold_changed)
row.add_child(hold_slider)
hold_value = UI.label("%.2f s" % hold_slider.value, 16, Palette.MUTED)
hold_value.custom_minimum_size = Vector2(64, 0)
row.add_child(hold_value)
parent.add_child(panel)
func refresh() -> void:
for key in toggles:
toggles[key].button_pressed = bool(SaveGame.get_setting(key))
if hold_slider != null:
hold_slider.set_value_no_signal(float(SaveGame.get_setting("hold_seconds")))
hold_value.text = "%.2f s" % hold_slider.value
func _on_hold_changed(value: float) -> void:
var snapped: float = snapped(value, 0.05)
hold_value.text = "%.2f s" % snapped
SaveGame.set_setting("hold_seconds", snapped)
func _on_reset_pressed() -> void:
reset_dialog.popup_centered()
func _on_reset_confirmed() -> void:
SaveGame.reset_progress()
reset_status.text = "Progress reset. Every guest is waiting to be met again."
reset_status.add_theme_color_override("font_color", Palette.INK)
+1
View File
@@ -0,0 +1 @@
uid://mtpyejbc4p2q
+25
View File
@@ -0,0 +1,25 @@
param(
[string]$Godot = "C:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe",
[string]$Jdk = "E:\AndroidTools\jdk-17.0.21.1+2",
[string]$Sdk = "E:\AndroidTools\sdk",
[string]$Out = "build/Ratdoku.apk"
)
$ErrorActionPreference = "Stop"
$project = Split-Path $PSScriptRoot -Parent
$env:JAVA_HOME = $Jdk
$env:ANDROID_HOME = $Sdk
$env:ANDROID_SDK_ROOT = $Sdk
$env:Path = "$Jdk\bin;$Sdk\platform-tools;$Sdk\build-tools\35.0.0;$env:Path"
New-Item -ItemType Directory -Force -Path (Join-Path $project "build") | Out-Null
Write-Host "Exporting $Out ..."
& $Godot --headless --path $project --export-debug "Android" $Out
$apk = Join-Path $project $Out
if (Test-Path $apk) {
Get-Item $apk | Select-Object FullName, Length, LastWriteTime
} else {
throw "Export did not produce $apk"
}
+359
View File
@@ -0,0 +1,359 @@
extends SceneTree
## Headless puzzle generator.
## Run from the project folder:
## <godot> --headless --script res://tools/generate_levels.gd
##
## Writes data/levels.json.
##
## How it works:
## 1. Pick a legal solution (one rat per row and column, none touching).
## 2. Grow eight connected rooms around those eight rats.
## 3. Ask the solver for alternate solutions.
## 4. If the board is ambiguous, pin down a few of the intended rats as
## "already checked in" clues until the solution is unique.
##
## Clues are capped at three. If a board needs more than that, it is rejected
## and we start over. A later version can replace clues with room-shape
## refinement, but for the prototype this keeps every puzzle provably unique.
const N := 8
const COUNT := 30
const MAX_CLUES := 3
const OUT := "res://data/levels.json"
const DIRS := [Vector2i(1, 0), Vector2i(-1, 0), Vector2i(0, 1), Vector2i(0, -1)]
var _n := 0
var _regions: Array = []
var _cap := 2
var _found: Array = []
var _used_cols := {}
var _used_regions := {}
var _clue_cols := {}
func _init() -> void:
var rng := RandomNumberGenerator.new()
rng.seed = 20261201
DirAccess.make_dir_recursive_absolute(ProjectSettings.globalize_path("res://data"))
var levels: Array = []
var attempts := 0
var rejected_ambiguous := 0
var rejected_shape := 0
# Append to an existing pack instead of replacing it.
if FileAccess.file_exists(OUT):
var existing := FileAccess.open(OUT, FileAccess.READ)
if existing != null:
var parsed = JSON.parse_string(existing.get_as_text())
existing.close()
if typeof(parsed) == TYPE_ARRAY:
levels = parsed
var starting_count := levels.size()
print("Existing levels: %d, target: %d" % [starting_count, COUNT])
while levels.size() < COUNT and attempts < 60000:
attempts += 1
var sol := _sample_solution(rng)
if sol.is_empty():
continue
var regs := _grow_regions(sol, rng)
if regs.is_empty():
continue
if not _shape_ok(regs, sol):
rejected_shape += 1
continue
var clues = _find_clue_set(regs, sol, MAX_CLUES)
if clues == null:
rejected_ambiguous += 1
continue
if typeof(clues) != TYPE_ARRAY:
rejected_ambiguous += 1
continue
levels.append({
"id": "room-%02d" % (levels.size() + 1),
"n": N,
"regions": regs,
"solution": sol,
"clues": clues,
})
if levels.size() % 5 == 0:
print("Accepted %d rooms after %d attempts." % [levels.size(), attempts])
var file := FileAccess.open(OUT, FileAccess.WRITE)
if file == null:
push_error("Could not write %s" % OUT)
quit(1)
return
file.store_string(JSON.stringify(levels, "\t"))
file.close()
print("Generated %d levels in %d attempts -> %s" % [levels.size(), attempts, OUT])
print("New rooms this run: %d" % (levels.size() - starting_count))
print("Rejects: shape=%d ambiguous=%d" % [rejected_shape, rejected_ambiguous])
quit()
func _sample_solution(rng: RandomNumberGenerator) -> Array:
for attempt in range(600):
var cols := []
for i in N:
cols.append(i)
_shuffle(cols, rng)
var ok := true
for i in range(N - 1):
if abs(int(cols[i + 1]) - int(cols[i])) < 2:
ok = false
break
if ok:
return cols
return []
func _grow_regions(sol: Array, rng: RandomNumberGenerator) -> Array:
var regions := []
for r in N:
var row := []
for c in N:
row.append(-1)
regions.append(row)
var sizes := []
for i in N:
sizes.append(1)
for r in N:
regions[r][int(sol[r])] = r
var remaining := N * N - N
var guard := 0
while remaining > 0 and guard < 4000:
guard += 1
var order := []
for i in N:
order.append(i)
_shuffle(order, rng)
for region in order:
var candidates := _frontier(regions, region)
if candidates.is_empty():
continue
var pick: Vector2i = candidates[rng.randi_range(0, candidates.size() - 1)]
regions[pick.x][pick.y] = region
sizes[region] += 1
remaining -= 1
# Fill any enclosed pocket with its smallest neighbouring region.
var progress := true
while remaining > 0 and progress:
progress = false
for r in N:
for c in N:
if int(regions[r][c]) != -1:
continue
var neighbours := {}
for d in DIRS:
var nr: int = r + d.x
var nc: int = c + d.y
if nr >= 0 and nr < N and nc >= 0 and nc < N and int(regions[nr][nc]) >= 0:
neighbours[int(regions[nr][nc])] = true
if neighbours.is_empty():
continue
var best := -1
var best_size := 9999
for reg in neighbours.keys():
if int(sizes[reg]) < best_size:
best_size = int(sizes[reg])
best = int(reg)
regions[r][c] = best
sizes[best] += 1
remaining -= 1
progress = true
if remaining != 0:
return []
return regions
func _frontier(regions: Array, region: int) -> Array:
var out: Array[Vector2i] = []
for r in N:
for c in N:
if int(regions[r][c]) != region:
continue
for d in DIRS:
var nr: int = r + d.x
var nc: int = c + d.y
if nr >= 0 and nr < N and nc >= 0 and nc < N and int(regions[nr][nc]) == -1:
var cell := Vector2i(nr, nc)
if not out.has(cell):
out.append(cell)
return out
func _sizes(regions: Array) -> Array:
var sizes := []
for i in N:
sizes.append(0)
for r in N:
for c in N:
var region := int(regions[r][c])
if region >= 0:
sizes[region] += 1
return sizes
func _shape_ok(regions: Array, sol: Array) -> bool:
var sizes := _sizes(regions)
var total := 0
for s in sizes:
if int(s) < 3 or int(s) > 18:
return false
total += int(s)
var mean := float(total) / float(N)
for s in sizes:
if float(s) / mean > 2.4:
return false
var seeds := {}
for r in N:
var reg := int(regions[r][int(sol[r])])
if seeds.has(reg):
return false
seeds[reg] = true
return seeds.size() == N
func _find_clue_set(regions: Array, sol: Array, max_clues: int) -> Variant:
# Prefer zero clues, then one, then two, then three.
if _find_solutions(regions, [], 2).size() == 1:
return []
if max_clues >= 1:
for r1 in N:
var one := [[r1, int(sol[r1])]]
if _find_solutions(regions, one, 2).size() == 1:
return one
if max_clues >= 2:
for r1 in N:
for r2 in range(r1 + 1, N):
var two := [[r1, int(sol[r1])], [r2, int(sol[r2])]]
if _find_solutions(regions, two, 2).size() == 1:
return two
if max_clues >= 3:
for r1 in N:
for r2 in range(r1 + 1, N):
for r3 in range(r2 + 1, N):
var three := [[r1, int(sol[r1])], [r2, int(sol[r2])], [r3, int(sol[r3])]]
if _find_solutions(regions, three, 2).size() == 1:
return three
return null
func _find_solutions(regions: Array, clues: Array, cap: int) -> Array:
_regions = regions
_n = N
_cap = cap
_found = []
_used_cols = {}
_used_regions = {}
_clue_cols = {}
for clue in clues:
_clue_cols[int(clue[0])] = int(clue[1])
_collect(0, -1, [])
return _found
func _collect(row: int, prev_col: int, current: Array) -> void:
if _found.size() >= _cap:
return
if row == _n:
_found.append(current.duplicate())
return
if _clue_cols.has(row):
var fixed_col := int(_clue_cols[row])
if _can_place(row, fixed_col, prev_col):
_place(row, fixed_col)
current.append(fixed_col)
_collect(row + 1, fixed_col, current)
current.pop_back()
_unplace(row, fixed_col)
return
for c in range(_n):
if not _can_place(row, c, prev_col):
continue
_place(row, c)
current.append(c)
_collect(row + 1, c, current)
current.pop_back()
_unplace(row, c)
func _can_place(row: int, c: int, prev_col: int) -> bool:
if _used_cols.has(c):
return false
var region := int(_regions[row][c])
if _used_regions.has(region):
return false
if row > 0 and abs(c - prev_col) < 2:
return false
return true
func _place(row: int, c: int) -> void:
_used_cols[c] = true
_used_regions[int(_regions[row][c])] = true
func _unplace(row: int, c: int) -> void:
_used_cols.erase(c)
_used_regions.erase(int(_regions[row][c]))
func _same_solution(a: Array, b: Array) -> bool:
for i in N:
if int(a[i]) != int(b[i]):
return false
return true
func _alternate(solutions: Array, intended: Array) -> Array:
for candidate in solutions:
var same := true
for i in N:
if int(candidate[i]) != int(intended[i]):
same = false
break
if not same:
return candidate
return []
func _shuffle(arr: Array, rng: RandomNumberGenerator) -> void:
for i in range(arr.size() - 1, 0, -1):
var j := rng.randi_range(0, i)
var tmp = arr[i]
arr[i] = arr[j]
arr[j] = tmp
+1
View File
@@ -0,0 +1 @@
uid://oy3sanp8disa
+84
View File
@@ -0,0 +1,84 @@
extends SceneTree
## Development helper: boots the game, saves one screenshot per screen, quits.
## Run without --headless:
## <godot> --path . --script res://tools/screenshot.gd
func _init() -> void:
call_deferred("_run")
func _run() -> void:
var err := change_scene_to_file("res://scenes/Main.tscn")
if err != OK:
print("Could not load Main.tscn: ", err)
quit(1)
return
await process_frame
await process_frame
await RenderingServer.frame_post_draw
_save("res://screenshots/home.png")
var main = current_scene
_reset_save()
main.show_screen("guest_book")
await _settle()
_save("res://screenshots/guest_book.png")
main.show_screen("settings")
await _settle()
_save("res://screenshots/settings.png")
main.show_screen("rules")
await _settle()
_save("res://screenshots/rules.png")
var scrolls = main.rulebook.find_children("*", "ScrollContainer", true, false)
if scrolls.size() > 0:
scrolls[0].scroll_vertical = 1400
await _settle()
_save("res://screenshots/rules_tutorial.png")
main.show_screen("game")
main.game.start_level(0)
await _settle()
_save("res://screenshots/game.png")
var game = main.game
for i in range(12):
if game.win_shown:
break
game.board.hint()
await process_frame
await create_timer(0.8).timeout
await RenderingServer.frame_post_draw
_save("res://screenshots/win.png")
_reset_save()
quit()
func _reset_save() -> void:
var save = root.get_node_or_null("SaveGame")
if save != null:
save.reset_progress()
func _settle() -> void:
await process_frame
await process_frame
await RenderingServer.frame_post_draw
func _save(path: String) -> void:
var image := root.get_texture().get_image()
if image == null:
print("No viewport image yet.")
return
var absolute := ProjectSettings.globalize_path(path)
DirAccess.make_dir_recursive_absolute(absolute.get_base_dir())
image.save_png(absolute)
print("Saved %s (%dx%d)" % [absolute, image.get_width(), image.get_height()])
+1
View File
@@ -0,0 +1 @@
uid://dew8388i54gfs
+165
View File
@@ -0,0 +1,165 @@
extends SceneTree
## Headless smoke test for the rules and the board's public-ish operations.
## <godot> --headless --path . --script res://tools/smoke_test.gd
var solved_flag := false
func _init() -> void:
call_deferred("_run")
func _run() -> void:
var levels: Array = Levels.load_all()
if levels.is_empty():
print("FAIL: no levels")
quit(1)
return
var board := Board.new()
root.add_child(board)
board.size = Vector2(640, 640)
board.solved.connect(_on_solved)
var all_ok := true
for i in levels.size():
var level: Dictionary = levels[i]
board.set_level(level)
solved_flag = false
var fixed_count: int = board.fixed.size()
var seen := {}
for r in board.n:
var c := int(level["solution"][r])
var cell := Vector2i(r, c)
if board.fixed.has(cell):
continue
# Check the guest in directly.
board._toggle_rat(cell)
seen[cell] = true
var valid: bool = Rules.is_valid(board.cells, board.regions)
var rats: int = Rules.count_rats(board.cells)
var conflicts: int = board.conflict_cells.size()
if not valid or rats != board.n or conflicts != 0 or not solved_flag:
all_ok = false
print("FAIL %s: valid=%s rats=%d/%d conflicts=%d solved=%s fixed=%d" % [
level["id"], valid, rats, board.n, conflicts, solved_flag, fixed_count
])
# Undo / restart / hint on the first level.
var first: Dictionary = levels[0]
board.set_level(first)
var before: int = Rules.count_rats(board.cells)
var target := _first_empty_solution(board, first)
if target.x >= 0:
board._toggle_rat(target)
var placed: int = Rules.count_rats(board.cells)
board.undo()
var undone: int = Rules.count_rats(board.cells)
if placed != before + 1 or undone != before:
all_ok = false
print("FAIL undo: before=%d placed=%d undone=%d" % [before, placed, undone])
board.set_level(first)
if target.x >= 0:
board._toggle_rat(target)
board.restart()
if Rules.count_rats(board.cells) != board.fixed.size():
all_ok = false
print("FAIL restart: rats=%d fixed=%d" % [Rules.count_rats(board.cells), board.fixed.size()])
board.set_level(first)
solved_flag = false
var guard := 0
while guard < 12:
guard += 1
if not board.hint():
break
if not solved_flag:
all_ok = false
print("FAIL hint: board not solved after %d hints" % guard)
# Coordinate mapping: the centre of a cell must map back to that cell.
board.size = Vector2(640, 640)
board._update_layout()
var mapped: Vector2i = board._pos_to_cell(board._cell_rect(3, 4).get_center())
if mapped != Vector2i(3, 4):
all_ok = false
print("FAIL mapping: expected (3,4), got %s" % str(mapped))
# Tap marks X, right-click checks in, and hold checks in without a tap.
board.set_level(first)
board._update_layout()
var tap_cell := _find_empty_cell(board)
if tap_cell.x >= 0:
_left_click(board, tap_cell, true)
_left_click(board, tap_cell, false)
if int(board.cells[tap_cell.x][tap_cell.y]) != Board.X:
all_ok = false
print("FAIL tap: expected X, got %d" % int(board.cells[tap_cell.x][tap_cell.y]))
_right_click(board, tap_cell)
if int(board.cells[tap_cell.x][tap_cell.y]) != Board.RAT:
all_ok = false
print("FAIL right-click: expected RAT, got %d" % int(board.cells[tap_cell.x][tap_cell.y]))
board.set_level(first)
board._update_layout()
var hold_cell := _find_empty_cell(board)
if hold_cell.x >= 0:
_left_click(board, hold_cell, true)
board._process(board.hold_seconds + 0.05)
if int(board.cells[hold_cell.x][hold_cell.y]) != Board.RAT:
all_ok = false
print("FAIL hold: expected RAT, got %d" % int(board.cells[hold_cell.x][hold_cell.y]))
_left_click(board, hold_cell, false)
if int(board.cells[hold_cell.x][hold_cell.y]) != Board.RAT:
all_ok = false
print("FAIL hold release: guest was removed")
print("SMOKE TEST: %s" % ("PASS" if all_ok else "FAIL"))
quit(0 if all_ok else 1)
func _on_solved() -> void:
solved_flag = true
func _find_empty_cell(board: Board) -> Vector2i:
for r in board.n:
for c in board.n:
var cell := Vector2i(r, c)
if board.fixed.has(cell):
continue
if int(board.cells[r][c]) == Board.EMPTY and not board.auto_x[r][c]:
return cell
return Vector2i(-1, -1)
func _left_click(board: Board, cell: Vector2i, pressed: bool) -> void:
var event := InputEventMouseButton.new()
event.button_index = MOUSE_BUTTON_LEFT
event.pressed = pressed
event.position = board._cell_rect(cell.x, cell.y).get_center()
board._gui_input(event)
func _right_click(board: Board, cell: Vector2i) -> void:
var event := InputEventMouseButton.new()
event.button_index = MOUSE_BUTTON_RIGHT
event.pressed = true
event.position = board._cell_rect(cell.x, cell.y).get_center()
board._gui_input(event)
func _first_empty_solution(board: Board, level: Dictionary) -> Vector2i:
for r in board.n:
var cell := Vector2i(r, int(level["solution"][r]))
if not board.fixed.has(cell):
return cell
return Vector2i(-1, -1)
+1
View File
@@ -0,0 +1 @@
uid://dfbmnhb4buk40
+85
View File
@@ -0,0 +1,85 @@
extends SceneTree
## Headless UI/save integration test.
## <godot> --headless --path . --script res://tools/ui_test.gd
var failures := 0
func _init() -> void:
call_deferred("_run")
func _check(condition: bool, message: String) -> void:
if not condition:
failures += 1
print("FAIL: ", message)
func _run() -> void:
var err := change_scene_to_file("res://scenes/Main.tscn")
if err != OK:
print("FAIL: could not load Main")
quit(1)
return
await process_frame
await process_frame
var main = current_scene
var save = root.get_node_or_null("SaveGame")
_check(save != null, "SaveGame autoload missing")
if save == null:
quit(1)
return
save.reset_progress()
main.game.start_level(0)
await process_frame
save.set_setting("patterns", false)
_check(not main.game.board.show_patterns, "patterns setting did not reach Board")
save.set_setting("patterns", true)
_check(main.game.board.show_patterns, "patterns setting did not restore")
save.set_setting("show_timer", false)
main.show_screen("game")
await process_frame
_check(not main.game.timer_label.visible, "show_timer setting did not hide timer")
save.set_setting("show_timer", true)
save.set_setting("hold_seconds", 0.50)
_check(abs(main.game.board.hold_seconds - 0.50) < 0.001, "hold_seconds did not reach Board")
save.set_setting("hold_seconds", 0.35)
var unlocked: String = save.complete_room("room-01", 1)
_check(unlocked == "pepper", "room 1 should unlock Pepper")
_check(save.is_guest_unlocked("pepper"), "Pepper should be unlocked")
_check(save.is_guest_unlocked("miso"), "Miso should be unlocked as a resident")
main.show_screen("guest_book")
await process_frame
await process_frame
_check(main.guest_book != null, "Guest Book missing")
if main.guest_book != null and main.guest_book.progress_label != null:
_check(main.guest_book.progress_label.text.find("6 of 25") >= 0, "Guest Book progress should be 6 of 25")
main.show_screen("rules")
await process_frame
var tutorial_board = main.rulebook.tutorial_board
_check(tutorial_board != null, "Tutorial board missing")
if tutorial_board != null:
for i in range(8):
tutorial_board.hint()
await process_frame
_check(Rules.is_valid(tutorial_board.cells, tutorial_board.regions), "Tutorial puzzle did not solve")
save.reset_progress()
save.set_setting("patterns", true)
save.set_setting("show_timer", true)
save.set_setting("reduce_motion", false)
save.set_setting("hold_seconds", 0.35)
print("UI TEST: ", "PASS" if failures == 0 else "FAIL (%d)" % failures)
quit(0 if failures == 0 else 1)
+1
View File
@@ -0,0 +1 @@
uid://ccl6uk1425kix
+1
View File
@@ -0,0 +1 @@
{"id":"08988737-a544-4ab1-99fb-22d67b7c36e3","revision":0,"last_node_id":52,"last_link_id":85,"nodes":[{"id":29,"type":"SaveImage","pos":[521.2820256118092,-86.65135385501759],"size":[879.953125,1019.953125],"flags":{},"order":5,"mode":0,"inputs":[{"localized_name":"images","name":"images","type":"IMAGE","link":44},{"localized_name":"filename_prefix","name":"filename_prefix","type":"STRING","widget":{"name":"filename_prefix"},"link":null}],"outputs":[{"localized_name":"images","name":"images","type":"IMAGE","links":null}],"properties":{"Node name for S&R":"SaveImage","cnr_id":"comfy-core","ver":"0.25.0"},"widgets_values":["Krea2_turbo"],"widgets_values_named":{"filename_prefix":"Krea2_turbo"}},{"id":30,"type":"b0e5ca93-2731-42b9-8e0a-d28ea851ff81","pos":[-140,-110],"size":[559.953125,1009.953125],"flags":{},"order":4,"mode":0,"inputs":[{"label":"prompt","name":"value","type":"STRING","widget":{"name":"value"},"link":null},{"label":"prompt_enhance","name":"value_1","type":"BOOLEAN","widget":{"name":"value_1"},"link":null},{"label":"LLM_max_token","name":"max_length","type":"INT","widget":{"name":"max_length"},"link":null},{"label":"LLM_thinking_mode","name":"thinking","shape":7,"type":"BOOLEAN","widget":{"name":"thinking"},"link":null},{"label":"width","name":"width_1","type":"INT","widget":{"name":"width_1"},"link":84},{"label":"height","name":"height_1","type":"INT","widget":{"name":"height_1"},"link":85},{"label":"seed","name":"seed_1","type":"INT","widget":{"name":"seed_1"},"link":null},{"label":"enable_lora","name":"value_3","type":"BOOLEAN","widget":{"name":"value_3"},"link":null},{"label":"lora_name","name":"lora_name_1","type":"COMBO","widget":{"name":"lora_name_1"},"link":null},{"label":"lora_strength","name":"strength_model_1","type":"FLOAT","widget":{"name":"strength_model_1"},"link":null},{"label":"lora_trigger_word","name":"string_b_1","type":"STRING","widget":{"name":"string_b_1"},"link":null},{"label":"unet_name","name":"unet_name_1","type":"COMBO","widget":{"name":"unet_name_1"},"link":null},{"label":"clip_name","name":"clip_name_1","type":"COMBO","widget":{"name":"clip_name_1"},"link":null},{"label":"vae_name","name":"vae_name_1","type":"COMBO","widget":{"name":"vae_name_1"},"link":null}],"outputs":[{"localized_name":"IMAGE","name":"IMAGE","type":"IMAGE","links":[44]}],"properties":{"cnr_id":"comfy-core","ver":"0.25.0","previewExposures":[{"name":"$$canvas-image-preview","sourceNodeId":"3","sourcePreviewName":"$$canvas-image-preview"}]},"widgets_values":["A cozy children's-book character illustration of Crumb, a round dumbo-eared fancy rat innkeeper. Plump pear-shaped body, soft fawn-and-cream hooded fur, huge low-set round ears, tiny pink paws, long delicate whiskers, bright curious eyes, one small notch in her left ear. She wears a tiny flour-dusted linen apron with a cheese-wedge pocket and holds a little clipboard. Standing three-quarter view, full body, centered, friendly slightly flustered expression. Hand-painted gouache texture, visible soft brush strokes, warm cream, ochre and dusty rose palette, gentle rim light, soft contact shadow, plain warm cream background, clean sticker-like silhouette, no text, no logo, 1:1.\n\n",false,512,false,1024,1024,107158940777715,true,"krea2_refusal_compact.safetensors",0.8,"","krea2_turbo_int8_convrot.safetensors","qwen3vl_4b_fp8_scaled.safetensors","qwen_image_vae.safetensors"],"widgets_values_named":{"value":"A cozy children's-book character illustration of Crumb, a round dumbo-eared fancy rat innkeeper. Plump pear-shaped body, soft fawn-and-cream hooded fur, huge low-set round ears, tiny pink paws, long delicate whiskers, bright curious eyes, one small notch in her left ear. She wears a tiny flour-dusted linen apron with a cheese-wedge pocket and holds a little clipboard. Standing three-quarter view, full body, centered, friendly slightly flustered expression. Hand-painted gouache texture, visible soft brush strokes, warm cream, ochre and dusty rose palette, gentle rim light, soft contact shadow, plain warm cream background, clean sticker-like silhouette, no text, no logo, 1:1.\n\n","value_1":false,"max_length":512,"thinking":false,"width_1":1024,"height_1":1024,"seed_1":107158940777715,"value_3":true,"lora_name_1":"krea2_refusal_compact.safetensors","strength_model_1":0.8,"string_b_1":"","unet_name_1":"krea2_turbo_int8_convrot.safetensors","clip_name_1":"qwen3vl_4b_fp8_scaled.safetensors","vae_name_1":"qwen_image_vae.safetensors"}},{"id":47,"type":"MarkdownNote","pos":[-1200,970],"size":[689.953125,509.953125],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[],"title":"LoRA Trigger Words and Settings","properties":{},"widgets_values":["## Model Links\n\n- [Hugging Face:Comfy-Org/Krea-2](https://huggingface.co/Comfy-Org/Krea-2)\n- [ModelScope:Comfy-Org/Krea-2](https://modelscope.cn/models/Comfy-Org/Krea-2)\n\nDownload the style LoRAs used in this workflow from [Comfy-Org/Krea-2/loras](https://huggingface.co/Comfy-Org/Krea-2/tree/main/loras).Line truncated