11 Commits

Author SHA1 Message Date
Steven Wroblewski 6e9432fa82 chore(ci): replace wget with curl in Godot download step
Cozypaw Hospital/pipeline/head This commit looks good
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 13:11:54 +02:00
Steven Wroblewski fb4434a537 chore(ci): add Jenkins pipeline with headless GUT test runner
Cozypaw Hospital/pipeline/head There was a failure building this commit
Downloads Godot 4.6.2 on first run, caches in /tmp, runs all 231 unit
tests headless on every push via Gitea webhook.

Also updates development-plan.md: mark sprints 0-22 complete, document
scope extensions, remove iOS references.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 13:09:26 +02:00
Steven Wroblewski cda31fcac9 assets(audio): add floor music tracks (floor 0-3) 2026-05-11 21:05:03 +02:00
Steven Wroblewski c697b996d8 fix(sprint-14): use preload pattern in test_balloon.gd to fix class_name parse error 2026-05-11 21:04:57 +02:00
Steven Wroblewski ec473dc4e3 feat(sprint-14): update GardenParty scene with cake, balloons, and chair snap points 2026-05-11 20:17:20 +02:00
Steven Wroblewski 2cb265c922 feat(sprint-14): add Cake cut/reset state machine 2026-05-11 20:15:44 +02:00
Steven Wroblewski 666648c154 feat(sprint-14): add Balloon pop/respawn state machine 2026-05-11 20:13:39 +02:00
Steven Wroblewski 6a5a18ca42 fix(sprint-14): guarantee _start_close_lid tween callback when lid and gift are null 2026-05-11 20:11:21 +02:00
Steven Wroblewski 14a50364f3 feat(sprint-14): add GiftBox RESETTING auto-reset state 2026-05-11 20:05:21 +02:00
Steven Wroblewski adefc59bea docs(sprint-14): add garden party implementation plan
4 tasks: GiftBox RESETTING state, Balloon, Cake, GardenParty scene update.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 15:31:34 +02:00
Steven Wroblewski 8f0569766c docs(sprint-14): add garden party spec
GiftBox auto-reset, Balloon pop/respawn, Cake cut/reset, chair snap points.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 15:26:14 +02:00
15 changed files with 1173 additions and 60 deletions
Vendored
+46
View File
@@ -0,0 +1,46 @@
pipeline {
agent any
environment {
GODOT_VERSION = '4.6.2-stable'
GODOT_BIN = '/tmp/godot_ci/Godot_v4.6.2-stable_linux.x86_64'
}
stages {
stage('Godot Setup') {
steps {
sh '''
if [ ! -x "$GODOT_BIN" ]; then
mkdir -p /tmp/godot_ci
curl -fsSL -o /tmp/godot_ci/godot.zip \
"https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}/Godot_v${GODOT_VERSION}_linux.x86_64.zip"
unzip -o /tmp/godot_ci/godot.zip -d /tmp/godot_ci/
chmod +x "$GODOT_BIN"
fi
'''
}
}
stage('Import Assets') {
steps {
// Godot must import assets before tests can run
sh '$GODOT_BIN --headless --import || true'
}
}
stage('Unit Tests') {
steps {
sh '$GODOT_BIN --headless -s res://addons/gut/gut_cmdln.gd -gdir=res://test/ -gexit'
}
}
}
post {
success {
echo '✅ All tests passed'
}
failure {
echo '❌ Tests failed'
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+77 -36
View File
@@ -65,7 +65,6 @@ Hospital (Node2D)
- **Entwicklungs-Rechner:** Dein Arbeitsplatz reicht
- **Android-Export:** Android Studio SDK + JDK (einmalig einrichten)
- **iOS-Export:** Mac + Xcode + Apple Developer Account (€99/Jahr) — **oder:** Android zuerst, iOS später nachziehen
- **Version Control:** Git (Godot-Projekte sind git-freundlich, `.import/` und `.godot/` in `.gitignore`)
### Empfohlene VS Code Setup (alternativ zum Godot-Editor)
@@ -234,25 +233,24 @@ Hier scheitern die meisten Hobby-Gamedev-Projekte. Drei realistische Wege:
Realistisch für einen Vollzeit-Entwickler mit Familie und Side-Projekten. Kürzer geht, wenn du die Abende länger nutzt.
### Sprint 0: Setup (Woche 1)
- [ ] Godot 4 installieren, Android-Export einrichten
- [ ] Git-Repo anlegen
- [ ] GDScript-Grundlagen durchgehen (Godot-Docs, 3-5h)
- [ ] Apple Developer Account falls iOS geplant
- [ ] Projektname + Logo-Idee
### Sprint 0: Setup (Woche 1)
- [x] Godot 4 installieren, Android-Export einrichten
- [x] Git-Repo anlegen
- [x] GDScript-Grundlagen durchgehen (Godot-Docs, 3-5h)
- [x] Projektname + Logo-Idee → "Cozypaw Hospital"
### Sprint 1-2: Proof of Concept (Woche 2-3)
- [ ] Ein Raum (z.B. Empfang) mit Hintergrund
- [ ] Eine Figur (Platzhalter-Häschen) per Drag bewegen
- [ ] Ein interaktives Objekt (z.B. Blume pflücken)
- [ ] Auf echtem Tablet testen
- **Gate:** Funktioniert der Kern-Loop? Finden die Kinder es gut?
### Sprint 1-2: Proof of Concept (Woche 2-3)
- [x] Ein Raum (z.B. Empfang) mit Hintergrund
- [x] Eine Figur (Platzhalter-Häschen) per Drag bewegen
- [x] Ein interaktives Objekt (z.B. Blume pflücken)
- [x] Auf echtem Tablet testen
- **Gate:** ✅ Kern-Loop funktioniert
### Sprint 3-4: Core Systems (Woche 4-5)
- [ ] Raum-Navigationssystem (Etagen-Wechsel per Aufzug)
- [ ] Save/Load-System
- [ ] Settings-Menü (Lautstärke, Reset)
- [ ] Character-State-System (gesund, krank, schläft)
### Sprint 3-4: Core Systems (Woche 4-5)
- [x] Raum-Navigationssystem (Etagen-Wechsel per Aufzug)
- [x] Save/Load-System
- [x] Settings-Menü (Lautstärke, Reset)
- [x] Character-State-System (gesund, krank, schläft)
### Sprint 5-7: Erdgeschoss (Woche 6-8) ✅
- [x] Empfang komplett
@@ -271,22 +269,71 @@ Realistisch für einen Vollzeit-Entwickler mit Familie und Side-Projekten. Kürz
- [x] Kreißsaal (kindgerecht: Mama kommt rein, Baby ist da)
- [x] Säuglingsstation mit Wiegen
### Sprint 14: Zuhause & Garten (Woche 15)
- [ ] Garten-Szene
- [ ] Party-Mechanik (Geschenke auspacken, Tee)
---
### Sprint 15: Polish & Sound (Woche 16)
- [ ] Alle Sounds einbauen
- [ ] Hintergrundmusik mit Cross-Fade
- [ ] Animations-Feinschliff
- [ ] Tutorial / erster Start
> **Scope-Erweiterung:** Die folgenden Sprints gingen über den ursprünglichen 16-Wochen-Plan hinaus und bauten das Spielsystem signifikant aus.
### Sprint 16: Release-Vorbereitung (Woche 17+)
### Sprint 15 (git): Character v2 ✅
- [x] SnapPoint-System (Figuren rasten an Möbeln/Objekten ein)
- [x] SnapReceiver-Komponente
- [x] AnimState-System (idle, picked_up, placed)
- [x] OutfitLayers (visuelle Outfit-Schichten pro Figur)
- [x] HandSlots (Figur kann Objekte halten)
### Sprint 16 (git): Snap-Points in allen Räumen ✅
- [x] 25 SnapPoints quer über alle 12 Räume
- [x] 115 Unit-Tests
### Sprint 17 (git): Hand-Slots & Outfit-Items ✅
- [x] HoldableItem mit Hand-Slot-Erkennung
- [x] OutfitItem mit Tap-to-Undress
- [x] GameState v2 — Outfit und gehaltene Items werden gespeichert
### Sprint 18 (git): Room Chests & Item-Spawning ✅
- [x] RoomChest mit Spawn- und Rücknahme-Logik
- [x] ChestItemData Resource
- [x] RoomChestConfig (alle Räume konfiguriert)
- [x] Chest-Nodes in allen 12 Räumen
### Sprint 19 (git): AudioManager & Cross-Fade ✅
- [x] AudioManager Autoload mit `_SFX_MAP`
- [x] Etagen-Musik mit Cross-Fade zwischen Räumen
- [x] Basis-SFX: item_drag, item_drop, item_spawn, chest_tap
### Sprint 20 (git): Navigation-Integration ✅
- [x] RoomNavigator → GameState.set_current_room
- [x] AudioManager wird beim Raumwechsel getriggert
- [x] Kamera wird beim Laden auf gespeicherten Raum restored
### Sprint 21 (git): Interaktive Objekte SFX ✅
- [x] 7 neue `play_sfx`-Aufrufe in interaktiven Objekten
- [x] SFX: xray_scan, gift_open, tea_pour, cradle_rock, ambulance_siren, delivery_cheer, object_tap
### Sprint 22 (git): Character SFX & Ambient ✅
- [x] character_pickup, character_tap, character_place SFX
- [x] UltrasoundMachine: loopender Herzschlag-Ambient
---
### Sprint 14: Zuhause & Garten ✅
- [x] Garten-Szene (GardenParty)
- [x] Party-Mechanik: Geschenke auspacken (GiftBox), Tee einschenken (TeaPot)
- [x] Kuchen schneiden (Cake) mit Reset-Statemachine
- [x] Luftballons (Balloon) mit Pop/Respawn-Statemachine
- [x] Stuhl-SnapPoints in der Gartenparty
- [x] Floor-Music-Tracks 03 (echte CC0-Audiodateien)
### Sprint 15 (Plan): Polish & Sound ✅
- [x] Alle Sounds einbauen → erledigt in Sprint 21 + 22
- [x] Hintergrundmusik mit Cross-Fade → erledigt in Sprint 19
- [x] Animations-Feinschliff → erledigt in Sprint 15 (git) Character v2
- [ ] Tutorial / erster Start ← **offen**
### Sprint 16 (Plan): Release-Vorbereitung
- [ ] Icon, Splash Screen
- [ ] Play Console Setup, Screenshots, Beschreibung
- [ ] Internal Testing mit Kindern
- [ ] Release auf Play Store (Android zuerst)
- [ ] iOS-Port falls gewünscht
- [ ] Internal Testing mit Kindern (UAT)
- [ ] Release auf Play Store (Android)
---
@@ -298,11 +345,6 @@ Realistisch für einen Vollzeit-Entwickler mit Familie und Side-Projekten. Kürz
3. Oder: Direkte APK-Distribution in der Familie (kein Store nötig)
4. Ggf. später: Öffentlicher Release
### iOS (später)
- Apple Developer Account (€99/Jahr)
- TestFlight für Familie
- App Store Review deutlich strenger als Google
### **WICHTIG — COPPA/Kids-Compliance**
Da Zielgruppe 3+ Jahre:
- Keine Analytics (Google Analytics, Firebase, etc.)
@@ -324,7 +366,6 @@ Da Zielgruppe 3+ Jahre:
| Risiko | Mitigation |
|---|---|
| **Asset-Produktion zieht sich** | Mit Platzhaltern entwickeln, Assets parallelisieren |
| **iOS-Deployment kompliziert** | Erst Android, iOS später |
| **Feature-Creep** | Strikt am MVP-Plan halten, später iterieren |
| **Motivation ebbt nach 2 Monaten ab** | Kinder regelmäßig Build zeigen → Feedback = Motor |
| **Komplexe Animationen** | Mit einfachen 2-Frame-Animationen starten |
@@ -0,0 +1,635 @@
# Sprint 14 — Garden Party Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Complete the GardenParty scene with GiftBox auto-reset, Balloon pop/respawn, Cake cut/reset, and chair snap points for characters.
**Architecture:** Three independent state-machine objects (`gift_box.gd` extended, `balloon.gd` new, `cake.gd` new) following the existing project pattern — each with a `State` enum, tween-driven animations, and `_on_X_complete()` callbacks testable without tweens. `GardenParty.tscn` is updated to wire balloon scripts and add the Cake and chair nodes. No new autoloads or base classes.
**Tech Stack:** GDScript 4 (static types), GUT v9.6.0, Godot 4.6.2.
---
### Task 1: GiftBox RESETTING state
**Files:**
- Modify: `scripts/objects/gift_box.gd`
- Modify: `test/unit/test_gift_box.gd`
The `OPEN` state is removed. `RESETTING` replaces it: gift fades in, waits 3 s, then the lid closes and the box resets.
- [ ] **Step 1: Update test file**
Replace the full contents of `test/unit/test_gift_box.gd` with:
```gdscript
## Tests for GiftBox — CLOSED/OPENING/RESETTING state machine transitions.
extends GutTest
var _box: GiftBox
func before_each() -> void:
_box = preload("res://scenes/objects/GiftBox.tscn").instantiate() as GiftBox
add_child_autofree(_box)
func test_initial_state_is_closed() -> void:
assert_eq(_box._state, GiftBox.State.CLOSED)
func test_ready_hides_gift_node() -> void:
var gift: Node2D = _box.get_node("Gift") as Node2D
assert_eq(gift.modulate.a, 0.0)
func test_start_opening_transitions_to_opening() -> void:
_box._start_opening()
assert_eq(_box._state, GiftBox.State.OPENING)
func test_on_lid_opened_transitions_to_resetting() -> void:
_box._start_opening()
_box._on_lid_opened()
assert_eq(_box._state, GiftBox.State.RESETTING)
func test_input_ignored_when_state_is_opening() -> void:
_box._state = GiftBox.State.OPENING
var event: InputEventScreenTouch = InputEventScreenTouch.new()
event.pressed = true
event.position = _box.global_position
_box._input(event)
assert_eq(_box._state, GiftBox.State.OPENING)
func test_input_ignored_when_state_is_resetting() -> void:
_box._state = GiftBox.State.RESETTING
var event: InputEventScreenTouch = InputEventScreenTouch.new()
event.pressed = true
event.position = _box.global_position
_box._input(event)
assert_eq(_box._state, GiftBox.State.RESETTING)
func test_tap_outside_hitbox_does_not_open() -> void:
var event: InputEventScreenTouch = InputEventScreenTouch.new()
event.pressed = true
event.position = _box.global_position + Vector2(200.0, 200.0)
_box._input(event)
assert_eq(_box._state, GiftBox.State.CLOSED)
func test_release_event_does_not_open() -> void:
var event: InputEventScreenTouch = InputEventScreenTouch.new()
event.pressed = false
event.position = _box.global_position
_box._input(event)
assert_eq(_box._state, GiftBox.State.CLOSED)
func test_on_reset_complete_transitions_to_closed() -> void:
_box._state = GiftBox.State.RESETTING
_box._on_reset_complete()
assert_eq(_box._state, GiftBox.State.CLOSED)
```
- [ ] **Step 2: Run → verify failures**
```bash
"F:/Development/_tools/Godot_v4.6.2-stable_win64/Godot_v4.6.2-stable_win64.exe" --headless -s res://addons/gut/gut_cmdln.gd -gdir=res://test/ -gexit --path "F:/Development/_gameDev/Cozypaw-Hospital/.worktrees/sprint-14-garden-party"
```
Expected: `test_on_lid_opened_transitions_to_resetting` FAIL (State.RESETTING not in enum), `test_input_ignored_when_state_is_resetting` FAIL, `test_on_reset_complete_transitions_to_closed` FAIL.
- [ ] **Step 3: Replace `scripts/objects/gift_box.gd`**
```gdscript
## GiftBox — tap while closed to open: lid rises and fades out, gift inside fades in.
## Auto-resets after RESET_DELAY seconds.
class_name GiftBox extends Node2D
enum State { CLOSED, OPENING, RESETTING }
const LID_OPEN_Y: float = -120.0
const CLOSED_LID_Y: float = -60.0
const OPEN_DURATION: float = 0.5
const GIFT_FADE_DURATION: float = 0.4
const RESET_DELAY: float = 3.0
const BUTTON_HALF_WIDTH: float = 40.0
const BUTTON_HALF_HEIGHT: float = 50.0
var _state: State = State.CLOSED
func _ready() -> void:
var gift: Node2D = get_node_or_null("Gift") as Node2D
if gift != null:
gift.modulate.a = 0.0
func _input(event: InputEvent) -> void:
if _state != State.CLOSED:
return
if not event is InputEventScreenTouch:
return
var touch: InputEventScreenTouch = event as InputEventScreenTouch
if not touch.pressed:
return
var local: Vector2 = to_local(touch.position)
if abs(local.x) > BUTTON_HALF_WIDTH or abs(local.y) > BUTTON_HALF_HEIGHT:
return
_start_opening()
func _start_opening() -> void:
AudioManager.play_sfx("gift_open")
_state = State.OPENING
var lid: Node2D = get_node_or_null("Lid") as Node2D
if lid == null:
_on_lid_opened()
return
var tween: Tween = create_tween()
tween.set_ease(Tween.EASE_OUT)
tween.set_trans(Tween.TRANS_BACK)
tween.tween_property(lid, "position:y", LID_OPEN_Y, OPEN_DURATION)
tween.parallel().tween_property(lid, "modulate:a", 0.0, OPEN_DURATION)
tween.finished.connect(_on_lid_opened)
func _on_lid_opened() -> void:
_state = State.RESETTING
var gift: Node2D = get_node_or_null("Gift") as Node2D
var tween: Tween = create_tween()
if gift != null:
tween.tween_property(gift, "modulate:a", 1.0, GIFT_FADE_DURATION)
tween.tween_interval(RESET_DELAY)
tween.tween_callback(_start_close_lid)
func _start_close_lid() -> void:
var lid: Node2D = get_node_or_null("Lid") as Node2D
var gift: Node2D = get_node_or_null("Gift") as Node2D
var tween: Tween = create_tween().set_parallel(true)
if lid != null:
tween.tween_property(lid, "position:y", CLOSED_LID_Y, OPEN_DURATION)
tween.tween_property(lid, "modulate:a", 1.0, OPEN_DURATION)
if gift != null:
tween.tween_property(gift, "modulate:a", 0.0, OPEN_DURATION)
tween.finished.connect(_on_reset_complete)
func _on_reset_complete() -> void:
_state = State.CLOSED
```
- [ ] **Step 4: Run → verify all pass**
```bash
"F:/Development/_tools/Godot_v4.6.2-stable_win64/Godot_v4.6.2-stable_win64.exe" --headless -s res://addons/gut/gut_cmdln.gd -gdir=res://test/ -gexit --path "F:/Development/_gameDev/Cozypaw-Hospital/.worktrees/sprint-14-garden-party"
```
Expected: all tests pass, no regressions.
- [ ] **Step 5: Commit**
```bash
git -C "F:/Development/_gameDev/Cozypaw-Hospital/.worktrees/sprint-14-garden-party" add scripts/objects/gift_box.gd test/unit/test_gift_box.gd
git -C "F:/Development/_gameDev/Cozypaw-Hospital/.worktrees/sprint-14-garden-party" commit -m "feat(sprint-14): add GiftBox RESETTING auto-reset state"
```
---
### Task 2: Balloon pop/respawn
**Files:**
- Create: `scripts/objects/balloon.gd`
- Create: `test/unit/test_balloon.gd`
`balloon.gd` is a `Node2D` script (not attached to a scene file — attached directly to nodes in `GardenParty.tscn` in Task 4). Tests use `Balloon.new()`.
- [ ] **Step 1: Write failing test**
Create `test/unit/test_balloon.gd`:
```gdscript
## Tests for Balloon — state machine transitions.
extends GutTest
var _balloon: Balloon
func before_each() -> void:
_balloon = Balloon.new()
add_child_autofree(_balloon)
func test_initial_state_is_idle() -> void:
assert_eq(_balloon._state, Balloon.State.IDLE)
func test_start_pop_transitions_to_popping() -> void:
_balloon._start_pop()
assert_eq(_balloon._state, Balloon.State.POPPING)
func test_on_pop_complete_transitions_to_popped() -> void:
_balloon._on_pop_complete()
assert_eq(_balloon._state, Balloon.State.POPPED)
func test_on_respawn_complete_transitions_to_idle() -> void:
_balloon._state = Balloon.State.RESPAWNING
_balloon._on_respawn_complete()
assert_eq(_balloon._state, Balloon.State.IDLE)
```
- [ ] **Step 2: Run → verify FAIL**
```bash
"F:/Development/_tools/Godot_v4.6.2-stable_win64/Godot_v4.6.2-stable_win64.exe" --headless -s res://addons/gut/gut_cmdln.gd -gdir=res://test/ -gexit --path "F:/Development/_gameDev/Cozypaw-Hospital/.worktrees/sprint-14-garden-party"
```
Expected: all 4 balloon tests FAIL — `Balloon` class not found.
- [ ] **Step 3: Create `scripts/objects/balloon.gd`**
```gdscript
## Balloon — tap to pop, auto-respawns after a delay.
class_name Balloon extends Node2D
enum State { IDLE, POPPING, POPPED, RESPAWNING }
const POP_DURATION: float = 0.15
const RESPAWN_DURATION: float = 0.30
const RESPAWN_DELAY: float = 5.0
const BUTTON_HALF_SIZE: float = 20.0
var _state: State = State.IDLE
func _input(event: InputEvent) -> void:
if _state != State.IDLE:
return
if not event is InputEventScreenTouch:
return
var touch: InputEventScreenTouch = event as InputEventScreenTouch
if not touch.pressed:
return
var local: Vector2 = to_local(touch.position)
if abs(local.x) > BUTTON_HALF_SIZE or abs(local.y) > BUTTON_HALF_SIZE:
return
_start_pop()
func _start_pop() -> void:
AudioManager.play_sfx("object_tap")
_state = State.POPPING
var tween: Tween = create_tween()
tween.set_ease(Tween.EASE_IN)
tween.set_trans(Tween.TRANS_BACK)
tween.tween_property(self, "scale", Vector2.ZERO, POP_DURATION)
tween.tween_callback(_on_pop_complete)
func _on_pop_complete() -> void:
_state = State.POPPED
var tween: Tween = create_tween()
tween.tween_interval(RESPAWN_DELAY)
tween.tween_callback(_start_respawn)
func _start_respawn() -> void:
_state = State.RESPAWNING
var tween: Tween = create_tween()
tween.set_ease(Tween.EASE_OUT)
tween.set_trans(Tween.TRANS_BACK)
tween.tween_property(self, "scale", Vector2.ONE, RESPAWN_DURATION)
tween.tween_callback(_on_respawn_complete)
func _on_respawn_complete() -> void:
_state = State.IDLE
```
- [ ] **Step 4: Run → verify all pass**
```bash
"F:/Development/_tools/Godot_v4.6.2-stable_win64/Godot_v4.6.2-stable_win64.exe" --headless -s res://addons/gut/gut_cmdln.gd -gdir=res://test/ -gexit --path "F:/Development/_gameDev/Cozypaw-Hospital/.worktrees/sprint-14-garden-party"
```
Expected: all tests pass including 4 new balloon tests.
- [ ] **Step 5: Commit**
```bash
git -C "F:/Development/_gameDev/Cozypaw-Hospital/.worktrees/sprint-14-garden-party" add scripts/objects/balloon.gd test/unit/test_balloon.gd
git -C "F:/Development/_gameDev/Cozypaw-Hospital/.worktrees/sprint-14-garden-party" commit -m "feat(sprint-14): add Balloon pop/respawn state machine"
```
---
### Task 3: Cake cut/reset
**Files:**
- Create: `scripts/objects/cake.gd`
- Create: `test/unit/test_cake.gd`
`cake.gd` is attached directly to a `Node2D` in `GardenParty.tscn` (Task 4). It looks for a `"Slice"` child node.
- [ ] **Step 1: Write failing test**
Create `test/unit/test_cake.gd`:
```gdscript
## Tests for Cake — state machine transitions.
extends GutTest
var _cake: Cake
func before_each() -> void:
_cake = Cake.new()
add_child_autofree(_cake)
func test_initial_state_is_whole() -> void:
assert_eq(_cake._state, Cake.State.WHOLE)
func test_start_cutting_transitions_to_cutting() -> void:
_cake._start_cutting()
assert_eq(_cake._state, Cake.State.CUTTING)
func test_on_cut_complete_transitions_to_cut() -> void:
_cake._on_cut_complete()
assert_eq(_cake._state, Cake.State.CUT)
func test_on_reset_complete_transitions_to_whole() -> void:
_cake._state = Cake.State.RESETTING
_cake._on_reset_complete()
assert_eq(_cake._state, Cake.State.WHOLE)
```
- [ ] **Step 2: Run → verify FAIL**
```bash
"F:/Development/_tools/Godot_v4.6.2-stable_win64/Godot_v4.6.2-stable_win64.exe" --headless -s res://addons/gut/gut_cmdln.gd -gdir=res://test/ -gexit --path "F:/Development/_gameDev/Cozypaw-Hospital/.worktrees/sprint-14-garden-party"
```
Expected: all 4 cake tests FAIL — `Cake` class not found.
- [ ] **Step 3: Create `scripts/objects/cake.gd`**
```gdscript
## Cake — tap to cut a slice, slice auto-respawns after a delay.
class_name Cake extends Node2D
enum State { WHOLE, CUTTING, CUT, RESETTING }
const CUT_DURATION: float = 0.3
const RESET_DURATION: float = 0.3
const RESET_DELAY: float = 3.0
const BUTTON_HALF_WIDTH: float = 40.0
const BUTTON_HALF_HEIGHT: float = 20.0
var _state: State = State.WHOLE
func _input(event: InputEvent) -> void:
if _state != State.WHOLE:
return
if not event is InputEventScreenTouch:
return
var touch: InputEventScreenTouch = event as InputEventScreenTouch
if not touch.pressed:
return
var local: Vector2 = to_local(touch.position)
if abs(local.x) > BUTTON_HALF_WIDTH or abs(local.y) > BUTTON_HALF_HEIGHT:
return
_start_cutting()
func _start_cutting() -> void:
AudioManager.play_sfx("object_tap")
_state = State.CUTTING
var slice: Node2D = get_node_or_null("Slice") as Node2D
var tween: Tween = create_tween()
if slice != null:
tween.tween_property(slice, "modulate:a", 0.0, CUT_DURATION)
tween.tween_callback(_on_cut_complete)
func _on_cut_complete() -> void:
_state = State.CUT
var tween: Tween = create_tween()
tween.tween_interval(RESET_DELAY)
tween.tween_callback(_start_reset)
func _start_reset() -> void:
_state = State.RESETTING
var slice: Node2D = get_node_or_null("Slice") as Node2D
var tween: Tween = create_tween()
if slice != null:
tween.tween_property(slice, "modulate:a", 1.0, RESET_DURATION)
tween.tween_callback(_on_reset_complete)
func _on_reset_complete() -> void:
_state = State.WHOLE
```
- [ ] **Step 4: Run → verify all pass**
```bash
"F:/Development/_tools/Godot_v4.6.2-stable_win64/Godot_v4.6.2-stable_win64.exe" --headless -s res://addons/gut/gut_cmdln.gd -gdir=res://test/ -gexit --path "F:/Development/_gameDev/Cozypaw-Hospital/.worktrees/sprint-14-garden-party"
```
Expected: all tests pass including 4 new cake tests.
- [ ] **Step 5: Commit**
```bash
git -C "F:/Development/_gameDev/Cozypaw-Hospital/.worktrees/sprint-14-garden-party" add scripts/objects/cake.gd test/unit/test_cake.gd
git -C "F:/Development/_gameDev/Cozypaw-Hospital/.worktrees/sprint-14-garden-party" commit -m "feat(sprint-14): add Cake cut/reset state machine"
```
---
### Task 4: GardenParty.tscn scene update
**Files:**
- Modify: `scenes/rooms/home/GardenParty.tscn`
Changes: add `balloon.gd` + `cake.gd` ext_resources, convert Balloon nodes from `ColorRect` to `Node2D` + Body child (required because `balloon.gd extends Node2D`, not `ColorRect`), replace `GiftBox3` with `Cake` node, add `ChairLeft`/`ChairRight` ColorRects as visual seat indicators.
No tests for scene structure — verify visually on device.
- [ ] **Step 1: Replace `scenes/rooms/home/GardenParty.tscn`**
```
[gd_scene load_steps=8 format=3 uid="uid://cozypaw_gardenparty"]
[ext_resource type="PackedScene" path="res://scenes/objects/GiftBox.tscn" id="1_giftbox"]
[ext_resource type="PackedScene" path="res://scenes/objects/TeaPot.tscn" id="2_teapot"]
[ext_resource type="PackedScene" path="res://scenes/objects/HomeButton.tscn" id="3_homebtn"]
[ext_resource type="Script" path="res://scripts/objects/snap_point.gd" id="4_snap"]
[ext_resource type="Script" path="res://scripts/objects/room_chest.gd" id="5_chest"]
[ext_resource type="Script" path="res://scripts/objects/balloon.gd" id="6_balloon"]
[ext_resource type="Script" path="res://scripts/objects/cake.gd" id="7_cake"]
[node name="GardenParty" type="Node2D"]
[node name="Sky" type="ColorRect" parent="."]
offset_left = 0.0
offset_top = 0.0
offset_right = 1280.0
offset_bottom = 400.0
color = Color(0.53, 0.81, 0.98, 1)
[node name="Grass" type="ColorRect" parent="."]
offset_left = 0.0
offset_top = 400.0
offset_right = 1280.0
offset_bottom = 720.0
color = Color(0.55, 0.76, 0.46, 1)
[node name="GroundEdge" type="ColorRect" parent="."]
offset_left = 0.0
offset_top = 392.0
offset_right = 1280.0
offset_bottom = 404.0
color = Color(0.38, 0.62, 0.32, 1)
[node name="TableTop" type="ColorRect" parent="."]
offset_left = 440.0
offset_top = 464.0
offset_right = 840.0
offset_bottom = 480.0
color = Color(0.82, 0.66, 0.46, 1)
[node name="TableLeg1" type="ColorRect" parent="."]
offset_left = 456.0
offset_top = 480.0
offset_right = 472.0
offset_bottom = 580.0
color = Color(0.70, 0.52, 0.34, 1)
[node name="TableLeg2" type="ColorRect" parent="."]
offset_left = 808.0
offset_top = 480.0
offset_right = 824.0
offset_bottom = 580.0
color = Color(0.70, 0.52, 0.34, 1)
[node name="TeaPot" parent="." instance=ExtResource("2_teapot")]
position = Vector2(510, 464)
[node name="GiftBox1" parent="." instance=ExtResource("1_giftbox")]
position = Vector2(640, 464)
[node name="GiftBox2" parent="." instance=ExtResource("1_giftbox")]
position = Vector2(730, 464)
[node name="Cake" type="Node2D" parent="."]
position = Vector2(820, 464)
script = ExtResource("7_cake")
[node name="Base" type="ColorRect" parent="Cake"]
offset_left = -40.0
offset_top = -20.0
offset_right = 40.0
offset_bottom = 20.0
color = Color(0.72, 0.52, 0.32, 1)
[node name="Slice" type="ColorRect" parent="Cake"]
offset_left = 5.0
offset_top = -22.0
offset_right = 33.0
offset_bottom = 18.0
color = Color(0.88, 0.74, 0.58, 1)
rotation = 0.15
[node name="TeaCup" type="ColorRect" parent="."]
offset_left = 558.0
offset_top = 440.0
offset_right = 590.0
offset_bottom = 464.0
color = Color(0.96, 0.92, 0.84, 1)
[node name="Balloon1" type="Node2D" parent="."]
position = Vector2(200, 150)
script = ExtResource("6_balloon")
[node name="Body" type="ColorRect" parent="Balloon1"]
offset_left = -20.0
offset_top = -30.0
offset_right = 20.0
offset_bottom = 30.0
color = Color(0.96, 0.44, 0.44, 1)
[node name="Balloon2" type="Node2D" parent="."]
position = Vector2(1040, 130)
script = ExtResource("6_balloon")
[node name="Body" type="ColorRect" parent="Balloon2"]
offset_left = -20.0
offset_top = -30.0
offset_right = 20.0
offset_bottom = 30.0
color = Color(0.56, 0.76, 0.96, 1)
[node name="HomeButtonReturn" parent="." instance=ExtResource("3_homebtn")]
position = Vector2(100, 620)
go_to_garden = false
[node name="ChairLeft" type="ColorRect" parent="."]
offset_left = 500.0
offset_top = 476.0
offset_right = 560.0
offset_bottom = 496.0
color = Color(0.60, 0.42, 0.26, 1)
[node name="SnapTableLeft" type="Node2D" parent="."]
position = Vector2(530, 455)
script = ExtResource("4_snap")
[node name="ChairRight" type="ColorRect" parent="."]
offset_left = 720.0
offset_top = 476.0
offset_right = 780.0
offset_bottom = 496.0
color = Color(0.60, 0.42, 0.26, 1)
[node name="SnapTableRight" type="Node2D" parent="."]
position = Vector2(750, 455)
script = ExtResource("4_snap")
[node name="GardenTable" type="Node2D" parent="."]
position = Vector2(200.0, 400.0)
script = ExtResource("5_chest")
chest_id = "garden_table"
[node name="GardenStorage" type="Node2D" parent="."]
position = Vector2(900.0, 400.0)
script = ExtResource("5_chest")
chest_id = "garden_storage"
```
- [ ] **Step 2: Run full test suite → verify no regressions**
```bash
"F:/Development/_tools/Godot_v4.6.2-stable_win64/Godot_v4.6.2-stable_win64.exe" --headless -s res://addons/gut/gut_cmdln.gd -gdir=res://test/ -gexit --path "F:/Development/_gameDev/Cozypaw-Hospital/.worktrees/sprint-14-garden-party"
```
Expected: all tests pass.
- [ ] **Step 3: Commit**
```bash
git -C "F:/Development/_gameDev/Cozypaw-Hospital/.worktrees/sprint-14-garden-party" add scenes/rooms/home/GardenParty.tscn
git -C "F:/Development/_gameDev/Cozypaw-Hospital/.worktrees/sprint-14-garden-party" commit -m "feat(sprint-14): update GardenParty scene with cake, balloons, and chair snap points"
```
@@ -0,0 +1,152 @@
# Sprint 14 — Garden Party Spec
## Goal
Make the GardenParty scene a fully playable sandbox room with three interactive objects
(GiftBox auto-reset, Balloon pop/respawn, Cake cut/reset) and character snap-to-chair
at the party table.
---
## Scope
**In scope:**
- `gift_box.gd`: add `RESETTING` state (auto-reset 3 s after opening)
- `balloon.gd`: new script — tap to pop, auto-respawn after 5 s
- `cake.gd`: new script — tap to cut slice, auto-reset after 3 s
- `GardenParty.tscn`: replace GiftBox3 with Cake, add Cake node structure, add chair
ColorRects under snap points, attach balloon.gd to existing Balloon nodes
- Tests: extend `test_gift_box.gd`, add `test_balloon.gd`, add `test_cake.gd`
**Out of scope:**
- New SFX keys (reuse `object_tap` for all three objects)
- Navigation changes (HomeButtonToGarden and HomeButtonReturn already wired)
- Additional characters beyond Bunny1 already in Main.tscn
---
## Object Mechanics
### GiftBox — RESETTING state
New state added to the existing `State` enum:
```
CLOSED → OPENING → RESETTING → CLOSED
```
- `_on_lid_opened()`: state → `RESETTING`, gift fades in (existing tween), inline 3 s
tween interval runs in parallel → `_start_close_lid()`
- `_start_close_lid()`: lid tweens back (fade-in alpha 0→1, slide y back to 0) →
`_on_reset_complete()`
- `_on_reset_complete()`: state → `CLOSED`
- `OPEN` state removed — `RESETTING` covers "gift visible + waiting"
- New internal methods: `_start_close_lid()`, `_on_reset_complete()`
- Constant: `RESET_DELAY: float = 3.0`
### Balloon
New file: `scripts/objects/balloon.gd`
New scene attachment: `balloon.gd` attached to existing `Balloon1` / `Balloon2` nodes in
`GardenParty.tscn`.
```
IDLE → POPPING → POPPED → RESPAWNING → IDLE
```
State transitions:
- Touch input on balloon while `IDLE``_start_pop()`
- `_start_pop()`: `AudioManager.play_sfx("object_tap")`, state → `POPPING`, scale tween to
`Vector2.ZERO` (0.15 s, EASE_IN, TRANS_BACK) → `_on_pop_complete()`
- `_on_pop_complete()`: state → `POPPED`, starts 5 s tween interval → `_start_respawn()`
- `_start_respawn()`: state → `RESPAWNING`, scale tween to `Vector2.ONE` (0.3 s, EASE_OUT,
TRANS_BACK) → `_on_respawn_complete()`
- `_on_respawn_complete()`: state → `IDLE`
Input: `_input(event)` — same touch-rect pattern as GiftBox, half-size 20 px (balloon is
small).
Constants: `POP_DURATION`, `RESPAWN_DURATION`, `RESPAWN_DELAY`.
### Cake
New file: `scripts/objects/cake.gd`
New node structure in `GardenParty.tscn` (replaces GiftBox3 at x=820, y=464):
```
Cake (Node2D, cake.gd)
├── Base (ColorRect, ~80×40 px, warm brown)
└── Slice (ColorRect, ~30×40 px, slightly offset + rotated, lighter brown)
```
```
WHOLE → CUTTING → CUT → RESETTING → WHOLE
```
State transitions:
- Touch input on Cake while `WHOLE``_start_cutting()`
- `_start_cutting()`: `AudioManager.play_sfx("object_tap")`, state → `CUTTING`,
tween `Slice.modulate.a` 1→0 (0.3 s, EASE_OUT) → `_on_cut_complete()`
- `_on_cut_complete()`: state → `CUT`, 3 s tween interval → `_start_reset()`
- `_start_reset()`: state → `RESETTING`, tween `Slice.modulate.a` 0→1 (0.3 s, EASE_IN)
`_on_reset_complete()`
- `_on_reset_complete()`: state → `WHOLE`
Input: touch rect `BUTTON_HALF_WIDTH = 40`, `BUTTON_HALF_HEIGHT = 20`.
Constants: `CUT_DURATION`, `RESET_DELAY = 3.0`, `RESET_DURATION`.
---
## Scene Changes (GardenParty.tscn)
| Change | Detail |
|---|---|
| Remove `GiftBox3` | Was at position Vector2(820, 464) |
| Add `Cake` | Node2D at Vector2(820, 464), `cake.gd`, child nodes Base + Slice |
| Attach `balloon.gd` | To existing `Balloon1` and `Balloon2` ColorRect nodes |
| Add `ChairLeft` | ColorRect ~60×20 px, brown, under `SnapTableLeft` (x=530, y=480) |
| Add `ChairRight` | ColorRect ~60×20 px, brown, under `SnapTableRight` (x=750, y=480) |
Navigation and snap-point logic unchanged.
---
## Tests
### `test_gift_box.gd` (extend existing)
| Test | Assertion |
|---|---|
| `test_state_becomes_resetting_after_lid_opened` | Call `_on_lid_opened()` → state == `State.RESETTING` |
| `test_state_becomes_closed_after_reset_complete` | Call `_on_reset_complete()` → state == `State.CLOSED` |
### `test_balloon.gd` (new, extends GutTest)
| Test | Assertion |
|---|---|
| `test_initial_state_is_idle` | `state == State.IDLE` |
| `test_start_pop_sets_popping` | Call `_start_pop()``state == State.POPPING` |
| `test_on_pop_complete_sets_popped` | Call `_on_pop_complete()``state == State.POPPED` |
| `test_on_respawn_complete_sets_idle` | Call `_on_respawn_complete()``state == State.IDLE` |
### `test_cake.gd` (new, extends GutTest)
| Test | Assertion |
|---|---|
| `test_initial_state_is_whole` | `state == State.WHOLE` |
| `test_start_cutting_sets_cutting` | Call `_start_cutting()``state == State.CUTTING` |
| `test_on_cut_complete_sets_cut` | Call `_on_cut_complete()``state == State.CUT` |
| `test_on_reset_complete_sets_whole` | Call `_on_reset_complete()``state == State.WHOLE` |
---
## Architecture Notes
- All three objects follow the same state-machine pattern as existing objects (`cradle.gd`,
`gift_box.gd`, etc.) — no new abstractions.
- Tween-based animations are not unit-tested (visual only). State transitions triggered by
`tween.finished` callbacks are tested by calling the callbacks directly.
- `AudioServer.get_driver_name() == "Dummy"` guard is already in `AudioManager.play_sfx()`
— no additional guard needed in new scripts.
- `balloon.gd` scales the Node2D itself (no child sprite node needed at placeholder stage).
+52 -12
View File
@@ -1,10 +1,12 @@
[gd_scene load_steps=6 format=3 uid="uid://cozypaw_gardenparty"]
[gd_scene load_steps=8 format=3 uid="uid://cozypaw_gardenparty"]
[ext_resource type="PackedScene" path="res://scenes/objects/GiftBox.tscn" id="1_giftbox"]
[ext_resource type="PackedScene" path="res://scenes/objects/TeaPot.tscn" id="2_teapot"]
[ext_resource type="PackedScene" path="res://scenes/objects/HomeButton.tscn" id="3_homebtn"]
[ext_resource type="Script" path="res://scripts/objects/snap_point.gd" id="4_snap"]
[ext_resource type="Script" path="res://scripts/objects/room_chest.gd" id="5_chest"]
[ext_resource type="Script" path="res://scripts/objects/balloon.gd" id="6_balloon"]
[ext_resource type="Script" path="res://scripts/objects/cake.gd" id="7_cake"]
[node name="GardenParty" type="Node2D"]
@@ -59,8 +61,24 @@ position = Vector2(640, 464)
[node name="GiftBox2" parent="." instance=ExtResource("1_giftbox")]
position = Vector2(730, 464)
[node name="GiftBox3" parent="." instance=ExtResource("1_giftbox")]
[node name="Cake" type="Node2D" parent="."]
position = Vector2(820, 464)
script = ExtResource("7_cake")
[node name="Base" type="ColorRect" parent="Cake"]
offset_left = -40.0
offset_top = -20.0
offset_right = 40.0
offset_bottom = 20.0
color = Color(0.72, 0.52, 0.32, 1)
[node name="Slice" type="ColorRect" parent="Cake"]
offset_left = 5.0
offset_top = -22.0
offset_right = 33.0
offset_bottom = 18.0
color = Color(0.88, 0.74, 0.58, 1)
rotation = 0.15
[node name="TeaCup" type="ColorRect" parent="."]
offset_left = 558.0
@@ -69,28 +87,50 @@ offset_right = 590.0
offset_bottom = 464.0
color = Color(0.96, 0.92, 0.84, 1)
[node name="Balloon1" type="ColorRect" parent="."]
offset_left = 180.0
offset_top = 120.0
offset_right = 220.0
offset_bottom = 180.0
[node name="Balloon1" type="Node2D" parent="."]
position = Vector2(200, 150)
script = ExtResource("6_balloon")
[node name="Body" type="ColorRect" parent="Balloon1"]
offset_left = -20.0
offset_top = -30.0
offset_right = 20.0
offset_bottom = 30.0
color = Color(0.96, 0.44, 0.44, 1)
[node name="Balloon2" type="ColorRect" parent="."]
offset_left = 1020.0
offset_top = 100.0
offset_right = 1060.0
offset_bottom = 160.0
[node name="Balloon2" type="Node2D" parent="."]
position = Vector2(1040, 130)
script = ExtResource("6_balloon")
[node name="Body" type="ColorRect" parent="Balloon2"]
offset_left = -20.0
offset_top = -30.0
offset_right = 20.0
offset_bottom = 30.0
color = Color(0.56, 0.76, 0.96, 1)
[node name="HomeButtonReturn" parent="." instance=ExtResource("3_homebtn")]
position = Vector2(100, 620)
go_to_garden = false
[node name="ChairLeft" type="ColorRect" parent="."]
offset_left = 500.0
offset_top = 476.0
offset_right = 560.0
offset_bottom = 496.0
color = Color(0.60, 0.42, 0.26, 1)
[node name="SnapTableLeft" type="Node2D" parent="."]
position = Vector2(530, 455)
script = ExtResource("4_snap")
[node name="ChairRight" type="ColorRect" parent="."]
offset_left = 720.0
offset_top = 476.0
offset_right = 780.0
offset_bottom = 496.0
color = Color(0.60, 0.42, 0.26, 1)
[node name="SnapTableRight" type="Node2D" parent="."]
position = Vector2(750, 455)
script = ExtResource("4_snap")
+55
View File
@@ -0,0 +1,55 @@
## Balloon — tap to pop, auto-respawns after a delay.
class_name Balloon extends Node2D
enum State { IDLE, POPPING, POPPED, RESPAWNING }
const POP_DURATION: float = 0.15
const RESPAWN_DURATION: float = 0.30
const RESPAWN_DELAY: float = 5.0
const BUTTON_HALF_SIZE: float = 20.0
var _state: State = State.IDLE
func _input(event: InputEvent) -> void:
if _state != State.IDLE:
return
if not event is InputEventScreenTouch:
return
var touch: InputEventScreenTouch = event as InputEventScreenTouch
if not touch.pressed:
return
var local: Vector2 = to_local(touch.position)
if abs(local.x) > BUTTON_HALF_SIZE or abs(local.y) > BUTTON_HALF_SIZE:
return
_start_pop()
func _start_pop() -> void:
AudioManager.play_sfx("object_tap")
_state = State.POPPING
var tween: Tween = create_tween()
tween.set_ease(Tween.EASE_IN)
tween.set_trans(Tween.TRANS_BACK)
tween.tween_property(self, "scale", Vector2.ZERO, POP_DURATION)
tween.tween_callback(_on_pop_complete)
func _on_pop_complete() -> void:
_state = State.POPPED
var tween: Tween = create_tween()
tween.tween_interval(RESPAWN_DELAY)
tween.tween_callback(_start_respawn)
func _start_respawn() -> void:
_state = State.RESPAWNING
var tween: Tween = create_tween()
tween.set_ease(Tween.EASE_OUT)
tween.set_trans(Tween.TRANS_BACK)
tween.tween_property(self, "scale", Vector2.ONE, RESPAWN_DURATION)
tween.tween_callback(_on_respawn_complete)
func _on_respawn_complete() -> void:
_state = State.IDLE
+56
View File
@@ -0,0 +1,56 @@
## Cake — tap to cut a slice, slice auto-respawns after a delay.
class_name Cake extends Node2D
enum State { WHOLE, CUTTING, CUT, RESETTING }
const CUT_DURATION: float = 0.3
const RESET_DURATION: float = 0.3
const RESET_DELAY: float = 3.0
const BUTTON_HALF_WIDTH: float = 40.0
const BUTTON_HALF_HEIGHT: float = 20.0
var _state: State = State.WHOLE
func _input(event: InputEvent) -> void:
if _state != State.WHOLE:
return
if not event is InputEventScreenTouch:
return
var touch: InputEventScreenTouch = event as InputEventScreenTouch
if not touch.pressed:
return
var local: Vector2 = to_local(touch.position)
if abs(local.x) > BUTTON_HALF_WIDTH or abs(local.y) > BUTTON_HALF_HEIGHT:
return
_start_cutting()
func _start_cutting() -> void:
AudioManager.play_sfx("object_tap")
_state = State.CUTTING
var slice: Node2D = get_node_or_null("Slice") as Node2D
var tween: Tween = create_tween()
if slice != null:
tween.tween_property(slice, "modulate:a", 0.0, CUT_DURATION)
tween.tween_callback(_on_cut_complete)
func _on_cut_complete() -> void:
_state = State.CUT
var tween: Tween = create_tween()
tween.tween_interval(RESET_DELAY)
tween.tween_callback(_start_reset)
func _start_reset() -> void:
_state = State.RESETTING
var slice: Node2D = get_node_or_null("Slice") as Node2D
var tween: Tween = create_tween()
if slice != null:
tween.tween_property(slice, "modulate:a", 1.0, RESET_DURATION)
tween.tween_callback(_on_reset_complete)
func _on_reset_complete() -> void:
_state = State.WHOLE
+25 -5
View File
@@ -1,11 +1,14 @@
## GiftBox — tap while closed to open: lid rises and fades out, gift inside fades in.
## Auto-resets after RESET_DELAY seconds.
class_name GiftBox extends Node2D
enum State { CLOSED, OPENING, OPEN }
enum State { CLOSED, OPENING, RESETTING }
const LID_OPEN_Y: float = -120.0
const CLOSED_LID_Y: float = -60.0
const OPEN_DURATION: float = 0.5
const GIFT_FADE_DURATION: float = 0.4
const RESET_DELAY: float = 3.0
const BUTTON_HALF_WIDTH: float = 40.0
const BUTTON_HALF_HEIGHT: float = 50.0
@@ -37,7 +40,7 @@ func _start_opening() -> void:
_state = State.OPENING
var lid: Node2D = get_node_or_null("Lid") as Node2D
if lid == null:
_state = State.OPEN
_on_lid_opened()
return
var tween: Tween = create_tween()
tween.set_ease(Tween.EASE_OUT)
@@ -48,9 +51,26 @@ func _start_opening() -> void:
func _on_lid_opened() -> void:
_state = State.OPEN
_state = State.RESETTING
var gift: Node2D = get_node_or_null("Gift") as Node2D
if gift == null:
return
var tween: Tween = create_tween()
if gift != null:
tween.tween_property(gift, "modulate:a", 1.0, GIFT_FADE_DURATION)
tween.tween_interval(RESET_DELAY)
tween.tween_callback(_start_close_lid)
func _start_close_lid() -> void:
var lid: Node2D = get_node_or_null("Lid") as Node2D
var gift: Node2D = get_node_or_null("Gift") as Node2D
var tween: Tween = create_tween()
if lid != null:
tween.parallel().tween_property(lid, "position:y", CLOSED_LID_Y, OPEN_DURATION)
tween.parallel().tween_property(lid, "modulate:a", 1.0, OPEN_DURATION)
if gift != null:
tween.parallel().tween_property(gift, "modulate:a", 0.0, OPEN_DURATION)
tween.tween_callback(_on_reset_complete)
func _on_reset_complete() -> void:
_state = State.CLOSED
+31
View File
@@ -0,0 +1,31 @@
## Tests for Balloon — state machine transitions.
extends GutTest
const BalloonScript = preload("res://scripts/objects/balloon.gd")
var _balloon: Node2D
func before_each() -> void:
_balloon = BalloonScript.new()
add_child_autofree(_balloon)
func test_initial_state_is_idle() -> void:
assert_eq(_balloon._state, BalloonScript.State.IDLE)
func test_start_pop_transitions_to_popping() -> void:
_balloon._start_pop()
assert_eq(_balloon._state, BalloonScript.State.POPPING)
func test_on_pop_complete_transitions_to_popped() -> void:
_balloon._on_pop_complete()
assert_eq(_balloon._state, BalloonScript.State.POPPED)
func test_on_respawn_complete_transitions_to_idle() -> void:
_balloon._state = BalloonScript.State.RESPAWNING
_balloon._on_respawn_complete()
assert_eq(_balloon._state, BalloonScript.State.IDLE)
+31
View File
@@ -0,0 +1,31 @@
## Tests for Cake — state machine transitions.
extends GutTest
const CakeScript = preload("res://scripts/objects/cake.gd")
var _cake: Node2D
func before_each() -> void:
_cake = CakeScript.new()
add_child_autofree(_cake)
func test_initial_state_is_whole() -> void:
assert_eq(_cake._state, CakeScript.State.WHOLE)
func test_start_cutting_transitions_to_cutting() -> void:
_cake._start_cutting()
assert_eq(_cake._state, CakeScript.State.CUTTING)
func test_on_cut_complete_transitions_to_cut() -> void:
_cake._on_cut_complete()
assert_eq(_cake._state, CakeScript.State.CUT)
func test_on_reset_complete_transitions_to_whole() -> void:
_cake._state = CakeScript.State.RESETTING
_cake._on_reset_complete()
assert_eq(_cake._state, CakeScript.State.WHOLE)
+12 -6
View File
@@ -1,4 +1,4 @@
## Tests for GiftBox — CLOSED/OPENING/OPEN state machine transitions.
## Tests for GiftBox — CLOSED/OPENING/RESETTING state machine transitions.
extends GutTest
var _box: GiftBox
@@ -23,10 +23,10 @@ func test_start_opening_transitions_to_opening() -> void:
assert_eq(_box._state, GiftBox.State.OPENING)
func test_on_lid_opened_transitions_to_open() -> void:
func test_on_lid_opened_transitions_to_resetting() -> void:
_box._start_opening()
_box._on_lid_opened()
assert_eq(_box._state, GiftBox.State.OPEN)
assert_eq(_box._state, GiftBox.State.RESETTING)
func test_input_ignored_when_state_is_opening() -> void:
@@ -38,13 +38,13 @@ func test_input_ignored_when_state_is_opening() -> void:
assert_eq(_box._state, GiftBox.State.OPENING)
func test_input_ignored_when_state_is_open() -> void:
_box._state = GiftBox.State.OPEN
func test_input_ignored_when_state_is_resetting() -> void:
_box._state = GiftBox.State.RESETTING
var event: InputEventScreenTouch = InputEventScreenTouch.new()
event.pressed = true
event.position = _box.global_position
_box._input(event)
assert_eq(_box._state, GiftBox.State.OPEN)
assert_eq(_box._state, GiftBox.State.RESETTING)
func test_tap_outside_hitbox_does_not_open() -> void:
@@ -61,3 +61,9 @@ func test_release_event_does_not_open() -> void:
event.position = _box.global_position
_box._input(event)
assert_eq(_box._state, GiftBox.State.CLOSED)
func test_on_reset_complete_transitions_to_closed() -> void:
_box._state = GiftBox.State.RESETTING
_box._on_reset_complete()
assert_eq(_box._state, GiftBox.State.CLOSED)