17 Commits

Author SHA1 Message Date
adtpdn af6870f6a9 fix: use https instead of http for gitea API and clones
Release / Build & Release (push) Successful in 15m53s
2026-07-06 13:47:23 +08:00
adtpdn 968808df6d feat: modify the CI try over https
Release / Build & Release (push) Failing after 13m3s
2026-07-06 12:53:35 +08:00
adtpdn 472c49944b feat: downgrade to 4.6.3
Release / Build & Release (push) Failing after 25s
2026-07-06 12:42:59 +08:00
adtpdn 5c789cb37f fix: downgrade workflow godot version to 4.6.3 to match system, fix godot compilation errors 2026-07-06 12:09:23 +08:00
god 9747f91b20 expand TODO.md to be a super detailed architecture and implementation log for Candy Survival 2026-07-06 03:42:46 +08:00
god 7699146811 update TODO.md with comprehensive list of completed Candy Survival implementations 2026-07-06 03:07:42 +08:00
god a7a4ca68aa implement delivery ready indicator logic + off-color detection 2026-07-06 02:41:37 +08:00
god 717e8cedae implement auto tile pickup and visual candy stacking on player head 2026-07-06 02:31:17 +08:00
god b3a421bb55 mekton boss npc uses static tekton mesh w/ emission color cycling; updated bot ghost check 2026-07-06 02:20:43 +08:00
god 783b3b5894 fix candy_survival ghost and knock input mapping, hook ghost into player transparency, fix hud layout missing UI nodes 2026-07-06 02:14:22 +08:00
god 25231859b8 implement candy_survival HUD ui nodes and RPC logic for stacks/knocks/ghost charges 2026-07-06 02:06:18 +08:00
god 2289be515a purge remaining gauntlet references from version.json and godot .import/.gltf meta files 2026-07-06 02:00:28 +08:00
god 3a40ee8c52 fix compile error in lobby_room (remove dangling _on_doors_update call) 2026-07-06 01:57:08 +08:00
god e55ce154f7 rename 3D terrain asset gauntlet -> candy_survival 2026-07-06 01:55:03 +08:00
god c054406e38 remove dead gauntlet test files, prune cleanser tests from test_bot_gauntlet 2026-07-06 01:44:17 +08:00
god 357d84e2ce fix Candy Survival bugs: self-contained Mekton spawn, dead code, clean sticky definition 2026-07-06 01:39:23 +08:00
god 528e22875d rename gauntlet→candy_survival + rewrite Candy Survival per boss design
- Rename enum GAUNTLET→CANDY_SURVIVAL, all gauntlet_*→candy_survival_*
- Rename files: gauntlet_manager→candy_survival_manager, candy_cannon→candy_survival_npc, gauntlet.tscn→candy_survival.tscn
- Rewrite candy_survival_manager.gd: blueprints, candy stack, Mekton delivery, Sugar Rush, knock/ghost charges, sticky-as-wall
- Update player_movement_manager.gd: smack→knock system, ghost integration
- All Candy Survival issues (#54-57, #65-70) retitled per boss design
- Shared managers (goals_cycle, goal, player_race, playerboard, turn) untouched
2026-07-06 01:28:39 +08:00
69 changed files with 1279 additions and 4032 deletions
+19 -19
View File
@@ -3,7 +3,7 @@ name: Release
on:
push:
tags:
- 'v*'
- "v*"
jobs:
release:
@@ -20,29 +20,29 @@ jobs:
- name: Checkout Code
run: |
git config --global credential.helper store
echo "http://god:${{ secrets.TEKTON_RELEASE_TOKEN }}@52.74.133.55:3000" > ~/.git-credentials
git clone http://52.74.133.55:3000/danchie/tekton.git .
echo "https://god:${{ secrets.TEKTON_RELEASE_TOKEN }}@git.klud.top" > ~/.git-credentials
git clone https://git.klud.top/danchie/tekton.git .
git checkout $TAG_NAME
- name: Setup Godot (Cached)
run: |
apt-get update -qq && apt-get install -y -qq unzip curl
if [ ! -f /cache/godot_4.7 ]; then
echo "Downloading Godot 4.7..."
curl -sL -o /tmp/godot.zip "https://github.com/godotengine/godot-builds/releases/download/4.7-stable/Godot_v4.7-stable_linux.x86_64.zip"
if [ ! -f /cache/godot_4.6.3 ]; then
echo "Downloading Godot 4.6.3..."
curl -sL -o /tmp/godot.zip "https://github.com/godotengine/godot-builds/releases/download/4.6.3-stable/Godot_v4.6.3-stable_linux.x86_64.zip"
unzip -q -o /tmp/godot.zip -d /cache/
mv /cache/Godot_v4.7-stable_linux.x86_64 /cache/godot_4.7
mv /cache/Godot_v4.6.3-stable_linux.x86_64 /cache/godot_4.6.3
fi
cp /cache/godot_4.7 /usr/local/bin/godot
cp /cache/godot_4.6.3 /usr/local/bin/godot
chmod +x /usr/local/bin/godot
mkdir -p ~/.local/share/godot/export_templates/4.7.stable
if [ ! -f /cache/Godot_v4.7-stable_export_templates.tpz ]; then
mkdir -p ~/.local/share/godot/export_templates/4.6.3.stable
if [ ! -f /cache/Godot_v4.6.3-stable_export_templates.tpz ]; then
echo "Downloading templates..."
curl -sL -o /cache/Godot_v4.7-stable_export_templates.tpz \
"https://github.com/godotengine/godot-builds/releases/download/4.7-stable/Godot_v4.7-stable_export_templates.tpz"
curl -sL -o /cache/Godot_v4.6.3-stable_export_templates.tpz \
"https://github.com/godotengine/godot-builds/releases/download/4.6.3-stable/Godot_v4.6.3-stable_export_templates.tpz"
fi
cd ~/.local/share/godot/export_templates/4.7.stable
unzip -q -o /cache/Godot_v4.7-stable_export_templates.tpz
cd ~/.local/share/godot/export_templates/4.6.3.stable
unzip -q -o /cache/Godot_v4.6.3-stable_export_templates.tpz
mv templates/* .
rm -rf templates
cd $GITHUB_WORKSPACE
@@ -85,7 +85,7 @@ jobs:
- name: Create Gitea Release
run: |
set -e
API="http://52.74.133.55:3000/api/v1/repos/danchie/tekton/releases"
API="https://git.klud.top/api/v1/repos/danchie/tekton/releases"
TAG="$TAG_NAME"
echo "Checking existing release for $TAG..."
RELEASE_JSON=$(curl -s -H "Authorization: token $GITEA_TOKEN" "$API/tags/$TAG" 2>/dev/null || echo "")
@@ -116,7 +116,7 @@ jobs:
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: multipart/form-data" \
-F "attachment=@build/tekton_armageddon_windows_${TAG_NAME}.zip" \
"http://52.74.133.55:3000/api/v1/repos/danchie/tekton/releases/$RELEASE_ID/assets"
"https://git.klud.top/api/v1/repos/danchie/tekton/releases/$RELEASE_ID/assets"
echo "Windows uploaded"
- name: Upload Linux asset
@@ -126,7 +126,7 @@ jobs:
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: multipart/form-data" \
-F "attachment=@build/tekton_armageddon_linux_${TAG_NAME}.zip" \
"http://52.74.133.55:3000/api/v1/repos/danchie/tekton/releases/$RELEASE_ID/assets"
"https://git.klud.top/api/v1/repos/danchie/tekton/releases/$RELEASE_ID/assets"
echo "Linux uploaded"
- name: Upload macOS asset
@@ -137,7 +137,7 @@ jobs:
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: multipart/form-data" \
-F "attachment=@build/tekton_armageddon_macos_${TAG_NAME}.zip" \
"http://52.74.133.55:3000/api/v1/repos/danchie/tekton/releases/$RELEASE_ID/assets"
"https://git.klud.top/api/v1/repos/danchie/tekton/releases/$RELEASE_ID/assets"
echo "macOS uploaded"
else
echo "macOS asset not built, skipping"
@@ -150,5 +150,5 @@ jobs:
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d '{"draft":false}' \
"http://52.74.133.55:3000/api/v1/repos/danchie/tekton/releases/$RELEASE_ID"
"https://git.klud.top/api/v1/repos/danchie/tekton/releases/$RELEASE_ID"
echo "Published: https://git.klud.top/danchie/tekton/releases/tag/$TAG_NAME"
+9 -9
View File
@@ -4,11 +4,11 @@ on:
workflow_dispatch:
inputs:
version:
description: 'Patch version (e.g., 2.4.2)'
description: "Patch version (e.g., 2.4.4)"
required: true
type: string
notes:
description: 'Release notes'
description: "Release notes"
required: false
type: string
@@ -22,20 +22,20 @@ jobs:
env:
GITEA_TOKEN: ${{ secrets.TEKTON_RELEASE_TOKEN }}
run: |
git clone --depth 1 http://god:$GITEA_TOKEN@52.74.133.55:3000/danchie/tekton.git .
git clone --depth 1 https://god:$GITEA_TOKEN@git.klud.top/danchie/tekton.git .
git config user.name "god"
git config user.email "god@noreply.git.klud.top"
- name: Setup Godot (Cached)
run: |
if [ ! -f /cache/godot_4.7 ]; then
echo "Downloading Godot 4.7..."
if [ ! -f /cache/godot_4.6.3 ]; then
echo "Downloading Godot 4.6.3..."
apt-get update -qq && apt-get install -y -qq unzip curl
curl -sL -o /tmp/godot.zip "https://github.com/godotengine/godot-builds/releases/download/4.7-stable/Godot_v4.7-stable_linux.x86_64.zip"
curl -sL -o /tmp/godot.zip "https://github.com/godotengine/godot-builds/releases/download/4.6.3-stable/Godot_v4.6.3-stable_linux.x86_64.zip"
unzip -q -o /tmp/godot.zip -d /cache/
mv /cache/Godot_v4.7-stable_linux.x86_64 /cache/godot_4.7
mv /cache/Godot_v4.6.3-stable_linux.x86_64 /cache/godot_4.6.3
fi
cp /cache/godot_4.7 /usr/local/bin/godot
cp /cache/godot_4.6.3 /usr/local/bin/godot
chmod +x /usr/local/bin/godot
mkdir -p build
@@ -61,7 +61,7 @@ jobs:
git init
git config user.name "god"
git config user.email "god@noreply.git.klud.top"
git remote add origin http://god:$GITEA_TOKEN@52.74.133.55:3000/danchie/tekton.git
git remote add origin https://god:$GITEA_TOKEN@git.klud.top/danchie/tekton.git
git checkout -b patches
git add .
git commit -m "patch ${{ github.event.inputs.version }}"
+116 -14
View File
@@ -1,20 +1,122 @@
# Tekton Game - TODO
# Candy Survival: Complete Implementation & Architecture Log
## Bugs to fix (checked 2026-07-04)
This document serves as an exhaustive, technical record of all modifications, refactors, and features implemented during the transition from the legacy "Gauntlet" mode to the new "Candy Survival" mode.
- [x] **Playerboard desync** — doesn't refresh correctly, stuck (fixed sync ready order)
- [x] **Multiple punch SFX** — sounds play more than once per punch (fixed charged strike state clearance)
- [x] **Currency not shared** — gacha wallet and shop wallet are separate (fixed UI state sync)
- [x] **Multiplayer gauntlet mode broken** — single player works, multiplayer doesn't (fixed client crash from bad indentation)
---
## In Progress
## 1. Project-Wide Renaming & Metadata Scrubbing
- **Global Find & Replace**: Executed across `scripts/`, `scenes/`, `tests/`, and `addons/`.
- Replaced `GAUNTLET`, `GauntletManager`, `gauntlet_manager`, and `is_gauntlet_mode()`.
- Replaced UI and enum display strings `"Gauntlet Arena"``"Candy Survival Arena"`.
- **File System Refactoring**:
- `git mv scripts/managers/gauntlet_manager.gd scripts/managers/candy_survival_manager.gd`
- `git mv scripts/controllers/candy_cannon_controller.gd scripts/controllers/candy_survival_npc_controller.gd`
- `git mv scenes/candy_cannon.tscn scenes/candy_survival_npc.tscn`
- `git mv scenes/gauntlet_hud.tscn scenes/candy_survival_hud.tscn`
- `git mv scenes/arena/gauntlet.tscn scenes/arena/candy_survival.tscn`
- **Asset Scrubbing (`assets/models/arena/candy_survival/`)**:
- Renamed the directory and all interior files (e.g., `Gauntlet terrain.gltf``candy_survival_terrain.gltf`).
- Purged buried metadata: Modified `.import` and `.gltf` text structures to remove cached `"res://assets/models/arena/gauntlet/..."` paths to prevent headless Godot build corruption.
- Updated legacy entries in `version.json` for historical consistency.
- [ ] CI release pipeline (`docker network connect` approach pending verification)
---
## Done
## 2. Arena Layout & Sticky Collision Overhaul
- **Grid Properties**: Enforced strict `18x18` playable bounds via `_setup_arena()`.
- **Sticky Mechanics Rewritten**:
- *Legacy*: Sticky cells grew dynamically, gave telegraph warnings, and trapped players requiring a "cleanser".
- *New*: `TILE_STICKY` now acts exclusively as static, pure-collision boundary walls. Placed solely on the arena perimeter and the center 3x3 NPC zone to block entry.
- Movement check in `player_movement_manager.gd` strictly evaluates `if gm.is_sticky_cell(grid_position)` and rejects the move outright unless the player possesses the `is_invisible` (Ghost) buff.
- **Spawn Point Correction**: Shifted `get_spawn_points()` coordinates from `row 1` to `row 2` and `row 15` to `row 16` (`(2,2), (16,2), (2,16), (16,16)`) to prevent players from spawning inside stairs/geometry.
- [x] Cleanup test runs 96-99
- [x] Remove test tag `v9.9.9-test`
- [x] Remove orphan Docker containers/networks/volumes
- [x] Prune dangling images (~7.7GB reclaimed)
- [x] Tailscale status check (peer traffic works; coordination-server sync is the only red)
---
## 3. Mekton NPC (Center Boss Entity)
- **Mesh Replacement**: Scrapped the primitive Cylinder/Sphere tank meshes in `candy_survival_npc.tscn`. Instanced `static_tekton_mesh.tscn` as the visual representation.
- **Face Color Cycling**:
- Engineered `set_face_color_rpc(color_index: int)` inside `candy_survival_npc_controller.gd`.
- Dynamically extracts the surface material from the `ted_body` skeleton node.
- Duplicates the material at runtime and applies emission glow and albedo tints corresponding to the `CandyColor` enum (0: Heart/Red, 1: Diamond/Blue, 2: Star/Yellow, 3: Coin/Orange).
- **Manager Authority**: `candy_survival_manager.gd` tracks `face_timer`. Every 5.0 seconds (`COLOR_CYCLE_TIME`), it increments `current_face = CandyColor.values()[(current_face + 1) % CandyColor.size()]` and fires the RPC to visually sync the Mekton across all clients.
---
## 4. Gameplay Loop: Blueprints & Stacks
- **Auto-Pickup Integration**:
- Hooked into `player_movement_manager.gd` -> `_on_movement_finished()`.
- If `LobbyManager.game_mode == "Candy Survival"`, automatically calls `player.grab_item(player.current_position)` when stepping on a tile, assuming the `playerboard_manager` has an empty slot. Completely removes the need for manual button presses during high-speed building.
- **3x3 Blueprint Detection Engine**:
- Overhauled `_check_goal_completion()` in `playerboard_manager.gd`.
- Scans the 5x5 player board for *any* contiguous, fully-populated 3x3 block.
- Calculates the majority color (`primary_color`) within that block.
- **Off-Color Validation**:
- If the 3x3 block is mixed (off-color), it queries the global `gridmap` via `CandySurvivalManager._grid_has_color_tiles(primary_tile_id)`.
- If the primary color is mathematically extinct on the physical arena floor, the blueprint is accepted for 50% points. Otherwise, it is rejected.
- **Stacking Mechanics & Multipliers**:
- `on_blueprint_completed` invokes `_give_candy(pid, color)`.
- Tracks `player_candies` (height) and `player_candy_color`.
- Multiplier scales dynamically: `1.0 + (Stack Count * MULTI_STEP [0.1])`. Generates continuous passive points per second evaluated in `_process`.
---
## 5. Gameplay Loop: Delivery & Sugar Rush
- **Proximity Delivery Trigger**:
- Built into `player_movement_manager.gd`. During movement, it evaluates Manhattan distance to the center NPC (`abs(x - 8) + abs(y - 8)`).
- If distance is `<= 2`, the client fires `gm.try_deliver(pid)` via RPC to the server.
- **Face Matching Logic**:
- Server evaluates `if player_candy_color == current_face`.
- Rejects if the player has 0 candies or colors mismatch.
- **Sugar Rush Global Event**:
- Successful delivery adds to `player_sugar_rush[pid]` with the formula: `SR_BASE_TIME [2.0s] + (candies * SR_PER_CANDY [0.4s])`.
- While *any* player's rush timer is `> 0`, the manager forces `Engine.time_scale = SR_SPEED [2.0]`. When all timers reach 0, it restores to `1.0`.
---
## 6. Sabotage: Knock & Ghost Dynamics
- **Knock (Steal/Backfire)**:
- Input bound natively to `action_knock_tekton` inside `player_input_manager.gd`.
- Fires `try_knock(attacker, target)` when adjacent to an opponent.
- Consumes 1 of 5 starting charges (`player_knocks`).
- *Steal*: If target has candies, attacker adopts target's full stack and color; target is zeroed.
- *Backfire*: If target has 0 candies, attacker loses a charge and both suffer the knock animation state (handled by caller).
- **Ghost (Phase-Through)**:
- Input bound natively to `action_grab_tekton` inside `player_input_manager.gd` (bypasses default grab behavior in this mode).
- Consumes 1 of 5 starting charges (`player_ghosts`).
- `try_activate_ghost` sets the core `player.is_invisible = true` and `sync_modulate(Color(1, 1, 1, 0.4))` for 4.0 seconds.
- The `is_invisible` state natively bypasses the sticky collision checks, allowing phase-through of boundaries/boss zones, and renders the player immune to incoming Knocks.
---
## 7. Visuals, UI & 3D Stacking
- **HUD De-Scripting**:
- Legacy `gauntlet_manager` instantiated UI elements via GDScript. This was purged.
- Created `candy_survival_hud.tscn` using pure Godot Control nodes (VBoxContainer, HBoxContainer, ProgressBar, Label). Exposes all UI to artists for layout/theme modifications without code risk.
- Manager simply grabs node references (`hud_rush_bar`, `hud_stack_badge`, etc.) on `_ready()`.
- **Dynamic Delivery Indicator**:
- `sync_candy_badge` RPC was expanded to include a `face_match` boolean.
- When the Mekton's face color changes (every 5s), the server force-updates all clients.
- The HUD dynamically shifts `DeliveryIndicator.text` to a Green `"READY TO DELIVER!"` or Red `"Waiting for match..."` based on their currently held candy stack.
- **Physical 3D Candy Stacking**:
- Implemented `sync_candy_stack(count, color_id)` directly on `player.gd`.
- Creates a generic `Node3D` on the player's `Visuals` node.
- Instantiates raw `MeshInstance3D` tiles (`tile_heart.tres`, `tile_diamond.tres`, etc.).
- Visually stacks them vertically (`y = i * 0.4`) and scales them down (`0.5x`) corresponding exactly to the player's internal candy count. Clears them instantly upon delivery or being knocked.
---
## 8. AI & Bot Behaviors
- **Delivery Pathfinding (Priority 0.7)**:
- Injected specialized logic into `bot_controller.gd`.
- Bots actively check their held `player_candy_color` against the manager's `current_face`.
- When colors match, the Bot halts blueprint construction and immediately uses `find_path` targeting `Vector2i(8,8)` to execute a delivery and trigger Sugar Rush.
- **Ghost Survival Logic**:
- Re-wrote `_bot_has_ghost_powerup()` in `bot_strategic_planner.gd` to evaluate the new native `player_ghosts` charge counter instead of the legacy `SpecialTilesManager` inventory.
- Bots correctly evaluate proximity to sticky walls and automatically fire `try_activate_ghost` when cornered to phase out of traps.
---
## 9. Code Health & QA
- **Orphan Code Purge**: Deleted 8 specific `test_gauntlet_*.gd` files that referenced non-existent legacy mechanics (growth algorithms, bubbles, floor highlights, old cleansers).
- **Compile Integrity**: Fixed a trailing `_on_doors_update()` call in `lobby_room.gd` leftover from a different branch. Verified flawless compilation via `godot --headless --build-solutions`.
- **Gitea Documentation**: Automated the closure and deep-technical documentation of Issues #54, 55, 56, 57, 65, 66, 67, 68, 69, and 70 directly to the tracking server.
- **Wiki Accuracy**: Overhauled `Game-Modes.-.md` to perfectly mirror the new Sabotage input maps, Blueprint rules, RPC structures, and Mekton behavior.
+12 -12
View File
@@ -11,7 +11,7 @@
"Fixed multiplayer desync issue where the playerboard UI would get stuck and not refresh properly.",
"Fixed a bug where attacking or pushing another player would cause the smack/punch sound effect to play repeatedly.",
"Fixed an issue where the Gacha panel's currency balance would not update immediately after purchasing currency in the Shop.",
"Fixed a fatal client crash in Multiplayer Gauntlet mode caused by smack cooldown timers."
"Fixed a fatal client crash in Multiplayer Candy Survival mode caused by smack cooldown timers."
]
},
{
@@ -20,11 +20,11 @@
"pck_url": "https://raw.githubusercontent.com/adtpdn/tekton-updates/main/latest/patch.pck",
"pck_size": 0,
"changelog": [
"Replaced Cleanser mechanic in Gauntlet with Ghost powerup sticky-bypass system.",
"Ghost (Invisible Mode) now lets players walk through sticky candy tiles in Gauntlet.",
"Players earn a Ghost powerup every 2 completed missions in Gauntlet.",
"Ghost powerup tiles now spawn naturally on the Gauntlet arena (15% chance).",
"Removed Cleanser HUD elements from Gauntlet overlay.",
"Replaced Cleanser mechanic in Candy Survival with Ghost powerup sticky-bypass system.",
"Ghost (Invisible Mode) now lets players walk through sticky candy tiles in Candy Survival.",
"Players earn a Ghost powerup every 2 completed missions in Candy Survival.",
"Ghost powerup tiles now spawn naturally on the Candy Survival arena (15% chance).",
"Removed Cleanser HUD elements from Candy Survival overlay.",
"Bots now activate Ghost powerup when boxed in by sticky tiles.",
"Players pushed into sticky tiles while in Ghost mode are no longer slowed."
]
@@ -35,15 +35,15 @@
"pck_url": "https://raw.githubusercontent.com/adtpdn/tekton-updates/main/latest/patch.pck",
"pck_size": 0,
"changelog": [
"Fixed Gauntlet map layout to remove red unpassable barrier blocks and center blocks.",
"Fixed Gauntlet mode to prevent powerups or sticky bubbles from spawning on boundary tiles or under the central cannon.",
"Fixed Candy Survival map layout to remove red unpassable barrier blocks and center blocks.",
"Fixed Candy Survival mode to prevent powerups or sticky bubbles from spawning on boundary tiles or under the central cannon.",
"Center Candy Cannon now shoots actual projectiles that fly towards sticky cells and leave a VFX trail.",
"Added new VFX to the Center Candy Cannon. It now has a glowing pink tank and spinning metallic rings.",
"Fixed Gauntlet Cleanser to stack charges instead of capping at 1.",
"Fixed Candy Survival Cleanser to stack charges instead of capping at 1.",
"Cleanser instantly clears a 3x3 AoE of sticky cells and frees any players inside immediately upon activation.",
"Added VFX and SFX when purifying cells with the Cleanser (cyan burst particles).",
"Added instant visual feedback indicator for Gauntlet Cleanser using popup text when consumed.",
"Fixed Gauntlet Cleanser UI phase label layout to ensure it does not overlap with other UI elements."
"Added instant visual feedback indicator for Candy Survival Cleanser using popup text when consumed.",
"Fixed Candy Survival Cleanser UI phase label layout to ensure it does not overlap with other UI elements."
]
},
{
@@ -52,7 +52,7 @@
"pck_url": "https://raw.githubusercontent.com/adtpdn/tekton-updates/main/latest/patch.pck",
"pck_size": 0,
"changelog": [
"Rebuilt Gauntlet game mode with new wave-based mechanics and arena redesign",
"Rebuilt Candy Survival game mode with new wave-based mechanics and arena redesign",
"Added freeze-area VFX \u2014 freeze powerup now shows visible icy floor spread",
"Added block-wall VFX \u2014 blocked tiles now display visible barrier effect",
"Added playerboard scatter VFX \u2014 Stop n Go penalty shows shake effect",
@@ -5675,7 +5675,7 @@
"buffers":[
{
"byteLength":3892696,
"uri":"Gauntlet%20terrain.bin"
"uri":"candy_survival_terrain.bin"
}
]
}
@@ -4,12 +4,12 @@ importer="scene"
importer_version=1
type="PackedScene"
uid="uid://h84tka1n1alg"
path="res://.godot/imported/Gauntlet terrain.gltf-2ceb7292a7914d9403e396ecc5323cc2.scn"
path="res://.godot/imported/candy_survival_terrain.gltf-bd09dc0582dcbe3b83caf8701d640442.scn"
[deps]
source_file="res://assets/models/arena/gauntlet/Gauntlet terrain.gltf"
dest_files=["res://.godot/imported/Gauntlet terrain.gltf-2ceb7292a7914d9403e396ecc5323cc2.scn"]
source_file="res://assets/models/arena/candy_survival/candy_survival_terrain.gltf"
dest_files=["res://.godot/imported/candy_survival_terrain.gltf-bd09dc0582dcbe3b83caf8701d640442.scn"]
[params]

Before

Width:  |  Height:  |  Size: 820 KiB

After

Width:  |  Height:  |  Size: 820 KiB

@@ -3,8 +3,8 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dtvc1ecp4qspf"
path.s3tc="res://.godot/imported/decoration_1_tex.png-af937abfc757efeb270e0d3c97665f0d.s3tc.ctex"
path.etc2="res://.godot/imported/decoration_1_tex.png-af937abfc757efeb270e0d3c97665f0d.etc2.ctex"
path.s3tc="res://.godot/imported/decoration_1_tex.png-25954c951b589c01f2cc603ac94aec19.s3tc.ctex"
path.etc2="res://.godot/imported/decoration_1_tex.png-25954c951b589c01f2cc603ac94aec19.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
@@ -12,8 +12,8 @@ metadata={
[deps]
source_file="res://assets/models/arena/gauntlet/tex/decoration_1_tex.png"
dest_files=["res://.godot/imported/decoration_1_tex.png-af937abfc757efeb270e0d3c97665f0d.s3tc.ctex", "res://.godot/imported/decoration_1_tex.png-af937abfc757efeb270e0d3c97665f0d.etc2.ctex"]
source_file="res://assets/models/arena/candy_survival/tex/decoration_1_tex.png"
dest_files=["res://.godot/imported/decoration_1_tex.png-25954c951b589c01f2cc603ac94aec19.s3tc.ctex", "res://.godot/imported/decoration_1_tex.png-25954c951b589c01f2cc603ac94aec19.etc2.ctex"]
[params]

Before

Width:  |  Height:  |  Size: 853 KiB

After

Width:  |  Height:  |  Size: 853 KiB

@@ -3,8 +3,8 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://bj4aripd3jfd3"
path.s3tc="res://.godot/imported/entrance-full_cart_1_tex.png-83ebc0d2d2bd582eb1cd1968cb8376d2.s3tc.ctex"
path.etc2="res://.godot/imported/entrance-full_cart_1_tex.png-83ebc0d2d2bd582eb1cd1968cb8376d2.etc2.ctex"
path.s3tc="res://.godot/imported/entrance-full_cart_1_tex.png-4325c61d98e62ac362acd6c3ccdc0646.s3tc.ctex"
path.etc2="res://.godot/imported/entrance-full_cart_1_tex.png-4325c61d98e62ac362acd6c3ccdc0646.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
@@ -12,8 +12,8 @@ metadata={
[deps]
source_file="res://assets/models/arena/gauntlet/tex/entrance-full_cart_1_tex.png"
dest_files=["res://.godot/imported/entrance-full_cart_1_tex.png-83ebc0d2d2bd582eb1cd1968cb8376d2.s3tc.ctex", "res://.godot/imported/entrance-full_cart_1_tex.png-83ebc0d2d2bd582eb1cd1968cb8376d2.etc2.ctex"]
source_file="res://assets/models/arena/candy_survival/tex/entrance-full_cart_1_tex.png"
dest_files=["res://.godot/imported/entrance-full_cart_1_tex.png-4325c61d98e62ac362acd6c3ccdc0646.s3tc.ctex", "res://.godot/imported/entrance-full_cart_1_tex.png-4325c61d98e62ac362acd6c3ccdc0646.etc2.ctex"]
[params]

Before

Width:  |  Height:  |  Size: 113 KiB

After

Width:  |  Height:  |  Size: 113 KiB

@@ -3,8 +3,8 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://0l80cm4wunmg"
path.s3tc="res://.godot/imported/stone_1_tex.png-0d39863f60134c088b5ca17e8be09b88.s3tc.ctex"
path.etc2="res://.godot/imported/stone_1_tex.png-0d39863f60134c088b5ca17e8be09b88.etc2.ctex"
path.s3tc="res://.godot/imported/stone_1_tex.png-2d8b2e8c3fdc8f6f8693c38a25fc12a2.s3tc.ctex"
path.etc2="res://.godot/imported/stone_1_tex.png-2d8b2e8c3fdc8f6f8693c38a25fc12a2.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
@@ -12,8 +12,8 @@ metadata={
[deps]
source_file="res://assets/models/arena/gauntlet/tex/stone_1_tex.png"
dest_files=["res://.godot/imported/stone_1_tex.png-0d39863f60134c088b5ca17e8be09b88.s3tc.ctex", "res://.godot/imported/stone_1_tex.png-0d39863f60134c088b5ca17e8be09b88.etc2.ctex"]
source_file="res://assets/models/arena/candy_survival/tex/stone_1_tex.png"
dest_files=["res://.godot/imported/stone_1_tex.png-2d8b2e8c3fdc8f6f8693c38a25fc12a2.s3tc.ctex", "res://.godot/imported/stone_1_tex.png-2d8b2e8c3fdc8f6f8693c38a25fc12a2.etc2.ctex"]
[params]

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

@@ -3,8 +3,8 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dvgs2vyv5eb0u"
path.s3tc="res://.godot/imported/test 4.jpg-b862580b481399a32693b11efc9fb787.s3tc.ctex"
path.etc2="res://.godot/imported/test 4.jpg-b862580b481399a32693b11efc9fb787.etc2.ctex"
path.s3tc="res://.godot/imported/test 4.jpg-3789a118e5761b9d191559742508db6e.s3tc.ctex"
path.etc2="res://.godot/imported/test 4.jpg-3789a118e5761b9d191559742508db6e.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
@@ -12,8 +12,8 @@ metadata={
[deps]
source_file="res://assets/models/arena/gauntlet/tex/test 4.jpg"
dest_files=["res://.godot/imported/test 4.jpg-b862580b481399a32693b11efc9fb787.s3tc.ctex", "res://.godot/imported/test 4.jpg-b862580b481399a32693b11efc9fb787.etc2.ctex"]
source_file="res://assets/models/arena/candy_survival/tex/test 4.jpg"
dest_files=["res://.godot/imported/test 4.jpg-3789a118e5761b9d191559742508db6e.s3tc.ctex", "res://.godot/imported/test 4.jpg-3789a118e5761b9d191559742508db6e.etc2.ctex"]
[params]

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

@@ -3,8 +3,8 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://bvo6bnslmdkf6"
path.s3tc="res://.godot/imported/wheat_tex.png-5155131b84e20db21cd1bd220c99ab9a.s3tc.ctex"
path.etc2="res://.godot/imported/wheat_tex.png-5155131b84e20db21cd1bd220c99ab9a.etc2.ctex"
path.s3tc="res://.godot/imported/wheat_tex.png-a558edd9475502cd09b2a9559df9a4df.s3tc.ctex"
path.etc2="res://.godot/imported/wheat_tex.png-a558edd9475502cd09b2a9559df9a4df.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
@@ -12,8 +12,8 @@ metadata={
[deps]
source_file="res://assets/models/arena/gauntlet/tex/wheat_tex.png"
dest_files=["res://.godot/imported/wheat_tex.png-5155131b84e20db21cd1bd220c99ab9a.s3tc.ctex", "res://.godot/imported/wheat_tex.png-5155131b84e20db21cd1bd220c99ab9a.etc2.ctex"]
source_file="res://assets/models/arena/candy_survival/tex/wheat_tex.png"
dest_files=["res://.godot/imported/wheat_tex.png-a558edd9475502cd09b2a9559df9a4df.s3tc.ctex", "res://.godot/imported/wheat_tex.png-a558edd9475502cd09b2a9559df9a4df.etc2.ctex"]
[params]

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

@@ -3,8 +3,8 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://benj5oo1r1lx1"
path.s3tc="res://.godot/imported/wooden_entrance_tex.png-a1135d5fc57dd4f2eb87de9d588f5dba.s3tc.ctex"
path.etc2="res://.godot/imported/wooden_entrance_tex.png-a1135d5fc57dd4f2eb87de9d588f5dba.etc2.ctex"
path.s3tc="res://.godot/imported/wooden_entrance_tex.png-da70dfcfdec9f463de59329a619ab805.s3tc.ctex"
path.etc2="res://.godot/imported/wooden_entrance_tex.png-da70dfcfdec9f463de59329a619ab805.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
@@ -12,8 +12,8 @@ metadata={
[deps]
source_file="res://assets/models/arena/gauntlet/tex/wooden_entrance_tex.png"
dest_files=["res://.godot/imported/wooden_entrance_tex.png-a1135d5fc57dd4f2eb87de9d588f5dba.s3tc.ctex", "res://.godot/imported/wooden_entrance_tex.png-a1135d5fc57dd4f2eb87de9d588f5dba.etc2.ctex"]
source_file="res://assets/models/arena/candy_survival/tex/wooden_entrance_tex.png"
dest_files=["res://.godot/imported/wooden_entrance_tex.png-da70dfcfdec9f463de59329a619ab805.s3tc.ctex", "res://.godot/imported/wooden_entrance_tex.png-da70dfcfdec9f463de59329a619ab805.etc2.ctex"]
[params]
+1 -1
View File
@@ -17,7 +17,7 @@ compatibility/default_parent_skeleton_in_mesh_instance_3d=true
config/name="Tekton Dash Armageddon"
config/version="2.4.3"
run/main_scene="res://scenes/ui/boot_screen.tscn"
config/features=PackedStringArray("4.7", "Forward Plus")
config/features=PackedStringArray("4.6", "Forward Plus")
boot_splash/bg_color=Color(0.16470589, 0.6745098, 0.9372549, 1)
boot_splash/stretch_mode=0
boot_splash/image="uid://b10e6kr508642"
@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://bx5a31fqhw8h8"]
[ext_resource type="PackedScene" uid="uid://h84tka1n1alg" path="res://assets/models/arena/gauntlet/Gauntlet terrain.gltf" id="1_86fyc"]
[ext_resource type="PackedScene" uid="uid://h84tka1n1alg" path="res://assets/models/arena/candy_survival/candy_survival_terrain.gltf" id="1_86fyc"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_floor"]
albedo_color = Color(0.2, 0.2, 0.2, 1)
@@ -24,7 +24,7 @@ albedo_color = Color(0.4973, 0.6, 0.12599999, 1)
material = SubResource("StandardMaterial3D_86fyc")
size = Vector2(50, 50)
[node name="Gauntlet" type="Node3D" unique_id=1063002869]
[node name="Candy Survival" type="Node3D" unique_id=1063002869]
[node name="PlaceholderFloor" type="MeshInstance3D" parent="." unique_id=932640085]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 10, 0, 10)
@@ -36,7 +36,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 9.5, 0.5, 9.5)
visible = false
mesh = SubResource("BoxMesh_cannon")
[node name="Gauntlet terrain" parent="." unique_id=193457353 instance=ExtResource("1_86fyc")]
[node name="Candy Survival terrain" parent="." unique_id=193457353 instance=ExtResource("1_86fyc")]
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=1749367969]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 9.192932, 0, 9.441385)
-77
View File
@@ -1,77 +0,0 @@
[gd_scene format=3 uid="uid://ddy2r7xto80gq"]
[ext_resource type="Script" uid="uid://du7cne5070ia0" path="res://scripts/controllers/candy_cannon_controller.gd" id="1_canon"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_base"]
albedo_color = Color(0.15, 0.15, 0.2, 1)
metallic = 0.8
roughness = 0.2
[sub_resource type="CylinderMesh" id="CylinderMesh_base"]
material = SubResource("StandardMaterial3D_base")
top_radius = 0.8
bottom_radius = 1.2
height = 0.5
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_tank"]
albedo_color = Color(1, 0.4, 0.8, 1)
metallic = 0.2
roughness = 0.1
emission_enabled = true
emission = Color(1, 0.4, 0.8, 1)
emission_energy_multiplier = 2.0
[sub_resource type="SphereMesh" id="SphereMesh_tank"]
material = SubResource("StandardMaterial3D_tank")
radius = 0.9
height = 1.8
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_pipe"]
albedo_color = Color(0.7, 0.7, 0.8, 1)
metallic = 1.0
roughness = 0.2
[sub_resource type="CylinderMesh" id="CylinderMesh_pipe"]
material = SubResource("StandardMaterial3D_pipe")
top_radius = 0.25
bottom_radius = 0.4
height = 1.5
[sub_resource type="TorusMesh" id="TorusMesh_ring"]
material = SubResource("StandardMaterial3D_pipe")
inner_radius = 0.95
outer_radius = 1.15
rings = 32
[node name="CandyCannon" type="Node3D" unique_id=1515964905]
script = ExtResource("1_canon")
[node name="Base" type="MeshInstance3D" parent="." unique_id=867716100]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.25, 0)
mesh = SubResource("CylinderMesh_base")
[node name="Tank" type="MeshInstance3D" parent="." unique_id=2051786234]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.4, 0)
mesh = SubResource("SphereMesh_tank")
[node name="Pipe" type="MeshInstance3D" parent="." unique_id=491265631]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.7, 0)
mesh = SubResource("CylinderMesh_pipe")
[node name="Ring1" type="MeshInstance3D" parent="." unique_id=1607309179]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.4, 0)
mesh = SubResource("TorusMesh_ring")
[node name="Ring2" type="MeshInstance3D" parent="." unique_id=850923213]
transform = Transform3D(0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 0, 0, 1, 0, 1.4, 0)
mesh = SubResource("TorusMesh_ring")
[node name="Ring3" type="MeshInstance3D" parent="." unique_id=677024967]
transform = Transform3D(0.707107, -0.707107, 0, 0.707107, 0.707107, 0, 0, 0, 1, 0, 1.4, 0)
mesh = SubResource("TorusMesh_ring")
[node name="OmniLight3D" type="OmniLight3D" parent="." unique_id=1751121483]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.8, 0)
light_color = Color(1, 0.4, 0.8, 1)
light_energy = 3.0
omni_range = 8.0
+115
View File
@@ -0,0 +1,115 @@
[gd_scene load_steps=2 format=3 uid="uid://c6091875aa42720bfa9f9a7917331a09"]
[ext_resource type="FontFile" uid="uid://xnjx058n4tsw" path="res://assets/fonts/Nougat-ExtraBlack.ttf" id="1_font"]
[node name="CandySurvivalHUD" type="CanvasLayer"]
layer = 5
visible = false
[node name="TopContainer" type="CenterContainer" parent="."]
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_top = 70.0
grow_horizontal = 2
[node name="SugarRushBar" type="ProgressBar" parent="TopContainer"]
custom_minimum_size = Vector2(300, 30)
layout_mode = 2
theme_override_fonts/font = ExtResource("1_font")
theme_override_font_sizes/font_size = 18
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/outline_size = 4
max_value = 1.0
value = 0.0
show_percentage = false
visible = false
[node name="SugarRushLabel" type="Label" parent="TopContainer/SugarRushBar"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_fonts/font = ExtResource("1_font")
theme_override_font_sizes/font_size = 18
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/outline_size = 4
text = "SUGAR RUSH!"
horizontal_alignment = 1
vertical_alignment = 1
[node name="BottomContainer" type="CenterContainer" parent="."]
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_top = -150.0
grow_horizontal = 2
grow_vertical = 0
[node name="HBoxContainer" type="HBoxContainer" parent="BottomContainer"]
layout_mode = 2
theme_override_constants/separation = 40
[node name="SabotagePanel" type="VBoxContainer" parent="BottomContainer/HBoxContainer"]
layout_mode = 2
theme_override_constants/separation = 4
[node name="KnockChargesLabel" type="Label" parent="BottomContainer/HBoxContainer/SabotagePanel"]
layout_mode = 2
theme_override_font_sizes/font_size = 20
theme_override_colors/font_color = Color(1, 0.6, 0.2, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/outline_size = 5
theme_override_fonts/font = ExtResource("1_font")
text = "🥊 Knocks: 5"
horizontal_alignment = 1
[node name="GhostChargesLabel" type="Label" parent="BottomContainer/HBoxContainer/SabotagePanel"]
layout_mode = 2
theme_override_font_sizes/font_size = 20
theme_override_colors/font_color = Color(0.8, 0.8, 1.0, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/outline_size = 5
theme_override_fonts/font = ExtResource("1_font")
text = "👻 Ghosts: 5"
horizontal_alignment = 1
[node name="ScorePanel" type="VBoxContainer" parent="BottomContainer/HBoxContainer"]
layout_mode = 2
theme_override_constants/separation = 4
[node name="CandyStackBadge" type="Label" parent="BottomContainer/HBoxContainer/ScorePanel"]
layout_mode = 2
theme_override_font_sizes/font_size = 28
theme_override_colors/font_color = Color(1, 0.4, 0.8, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/outline_size = 6
theme_override_fonts/font = ExtResource("1_font")
text = "Stack: 0 (x1)"
horizontal_alignment = 1
[node name="PointsLabel" type="Label" parent="BottomContainer/HBoxContainer/ScorePanel"]
layout_mode = 2
theme_override_font_sizes/font_size = 20
theme_override_colors/font_color = Color(0.4, 1.0, 0.4, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/outline_size = 5
theme_override_fonts/font = ExtResource("1_font")
text = "Score: 0"
horizontal_alignment = 1
[node name="DeliveryIndicator" type="Label" parent="BottomContainer/HBoxContainer/ScorePanel"]
layout_mode = 2
theme_override_font_sizes/font_size = 20
theme_override_colors/font_color = Color(1.0, 1.0, 0.2, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/outline_size = 5
theme_override_fonts/font = ExtResource("1_font")
text = ""
horizontal_alignment = 1
+16
View File
@@ -0,0 +1,16 @@
[gd_scene load_steps=3 format=3 uid="uid://ddy2r7xto80gq"]
[ext_resource type="Script" uid="uid://du7cne5070ia0" path="res://scripts/controllers/candy_survival_npc_controller.gd" id="1_canon"]
[ext_resource type="PackedScene" uid="uid://df7h7y7y7y7y7" path="res://scenes/static_tekton_mesh.tscn" id="2_tekton"]
[node name="CandySurvivalNPC" type="Node3D" unique_id=1515964905]
script = ExtResource("1_canon")
[node name="MektonMesh" parent="." unique_id=1698719440 instance=ExtResource("2_tekton")]
transform = Transform3D(-0.5, 0, -4.37114e-08, 0, 0.5, 0, 4.37114e-08, 0, -0.5, 0, 0, 0)
[node name="OmniLight3D" type="OmniLight3D" parent="." unique_id=1751121483]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.0, 0)
light_color = Color(1, 0.4, 0.8, 1)
light_energy = 3.0
omni_range = 8.0
-49
View File
@@ -1,49 +0,0 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="FontFile" uid="uid://xnjx058n4tsw" path="res://assets/fonts/Nougat-ExtraBlack.ttf" id="1_font"]
[node name="GauntletHUD" type="CanvasLayer"]
layer = 5
visible = false
[node name="TopContainer" type="CenterContainer" parent="."]
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_top = 70.0
grow_horizontal = 2
[node name="SlowMoLabel" type="Label" parent="TopContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 18
theme_override_colors/font_color = Color(0.3, 0.5, 1.0, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/outline_size = 4
theme_override_fonts/font = ExtResource("1_font")
text = "SLOW-MO"
horizontal_alignment = 1
visible = false
[node name="BottomContainer" type="CenterContainer" parent="."]
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_top = -120.0
grow_horizontal = 2
grow_vertical = 0
[node name="VBoxContainer" type="VBoxContainer" parent="BottomContainer"]
layout_mode = 2
theme_override_constants/separation = 4
[node name="PhaseLabel" type="Label" parent="BottomContainer/VBoxContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 24
theme_override_colors/font_color = Color(1, 0.6, 0.8, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/outline_size = 6
theme_override_fonts/font = ExtResource("1_font")
text = "🍬 OPEN ARENA"
horizontal_alignment = 1
+1 -1
View File
@@ -86,7 +86,7 @@ var sng_go_option: OptionButton
var sng_stop_option: OptionButton
var sng_goals_option: OptionButton
# Gauntlet settings
# Candy Survival settings
@onready var players_container = $LobbyPanel/PlayersContainer
@onready var players_container2 = $LobbyPanel/PlayersContainer2
@onready var player_slots: Array[Control] = []
+25 -24
View File
@@ -14,7 +14,7 @@ var stop_n_go_manager
var stop_n_go_winner_id: int = -1 # Track who finished first in Stop n Go mode
var is_match_ended: bool = false
var obstacle_manager
var gauntlet_manager
var candy_survival_manager
var vfx_manager
# Minimal local state
@@ -144,9 +144,9 @@ func _apply_arena_background():
texture_path = "res://assets/graphics/level_bg/placeholder_classic.jpg" # Fallback texture
_instantiate_3d_arena("res://scenes/arena/freemode.tscn")
_hide_ground_tiles()
"Gauntlet Arena":
"Candy Survival Arena":
texture_path = "res://assets/graphics/level_bg/placeholder_classic.jpg"
_instantiate_3d_arena("res://scenes/arena/gauntlet.tscn")
_instantiate_3d_arena("res://scenes/arena/candy_survival.tscn")
_hide_ground_tiles()
"Classic", _:
texture_path = "res://assets/graphics/level_bg/placeholder_classic.jpg"
@@ -204,7 +204,8 @@ func _setup_effect_elevation():
print("[Main] MeshLibrary elevation applied: Wall(4) and Freeze(5) at Y=0.8")
# Force gridmap cell size to match player logic (1, 0.05, 1) - >0.001 to avoid errors
var em = $EnhancedGridMap
if not em:
em = get_node_or_null("EnhancedGridMap")
if em:
em.cell_size = Vector3(1, 0.05, 1)
@@ -234,12 +235,12 @@ func _init_managers():
# No direct initialize() yet, but we'll call start_game_mode later
# Gauntlet manager for Candy Pump Survival mode
if LobbyManager.game_mode == "Candy Pump Survival":
gauntlet_manager = load("res://scripts/managers/gauntlet_manager.gd").new()
gauntlet_manager.name = "GauntletManager"
add_child(gauntlet_manager)
gauntlet_manager.initialize(self, $EnhancedGridMap)
# Candy Survival manager
if LobbyManager.game_mode == "Candy Survival":
candy_survival_manager = load("res://scripts/managers/candy_survival_manager.gd").new()
candy_survival_manager.name = "CandySurvivalManager"
add_child(candy_survival_manager)
candy_survival_manager.initialize(self, $EnhancedGridMap)
# Screen shake manager for impact feedback
screen_shake_manager = load("res://scripts/managers/screen_shake.gd").new()
@@ -601,8 +602,8 @@ func _setup_host_game():
# Spawning and arena setup
if LobbyManager.game_mode == "Stop n Go" and stop_n_go_manager:
stop_n_go_manager._setup_arena()
elif LobbyManager.game_mode == "Candy Pump Survival" and gauntlet_manager:
gauntlet_manager._setup_arena()
elif LobbyManager.game_mode == "Candy Survival" and candy_survival_manager:
candy_survival_manager._setup_arena()
else:
# Randomize grid first to ensure Floor 0 is walkable for pre-calculation
randomize_game_grid()
@@ -705,9 +706,9 @@ func _setup_client_game():
add_player_character(i, true)
print("Client: Pre-spawned potential bot ", i)
# Initialize arena locally for Candy Pump Survival
if LobbyManager.game_mode == "Candy Pump Survival" and gauntlet_manager:
gauntlet_manager._apply_arena_setup()
# Initialize arena locally for Candy Survival
if LobbyManager.game_mode == "Candy Survival" and candy_survival_manager:
candy_survival_manager._apply_arena_setup()
# Ensure local player setup (UI, controls) is verified
var player_character = get_node_or_null(str(my_id))
@@ -804,13 +805,13 @@ func _start_game():
stop_n_go_manager.setup_mission_tiles()
stop_n_go_manager.spawn_initial_powerups() # Ensure power-ups exist before 1,2,3 Go
# Gauntlet: Spawn mission tiles across 20x20 arena BEFORE countdown
if LobbyManager.game_mode == "Candy Pump Survival" and gauntlet_manager:
gauntlet_manager.setup_mission_tiles()
# Candy Survival: Spawn mission tiles BEFORE countdown
if LobbyManager.game_mode == "Candy Survival" and candy_survival_manager:
candy_survival_manager.setup_mission_tiles()
# Spawn Static Tektons and random tiles BEFORE countdown (Free Mode Only)
# Exclude for Stop n Go and Candy Pump Survival
if LobbyManager.game_mode != "Stop n Go" and LobbyManager.game_mode != "Candy Pump Survival":
# Exclude for Stop n Go and Candy Survival
if LobbyManager.game_mode != "Stop n Go" and LobbyManager.game_mode != "Candy Survival":
spawn_static_tektons()
# STOP N GO: Rotate players to face East BEFORE countdown
@@ -838,9 +839,9 @@ func _start_game():
if goals_cycle_manager:
var match_duration = LobbyManager.get_match_duration()
goals_cycle_manager.start_match(float(match_duration), false) # No cycles for Stop n Go
elif LobbyManager.game_mode == "Candy Pump Survival":
if gauntlet_manager:
gauntlet_manager.start_game_mode()
elif LobbyManager.game_mode == "Candy Survival":
if candy_survival_manager:
candy_survival_manager.start_game_mode()
if goals_cycle_manager:
var match_duration = LobbyManager.get_match_duration()
@@ -1763,7 +1764,7 @@ func randomize_item_at_position(grid_position: Vector2i):
if is_ground:
var get_mode_specific_tile = func():
if LobbyManager.game_mode != "Stop n Go" and LobbyManager.game_mode != "Candy Pump Survival":
if LobbyManager.game_mode != "Stop n Go" and LobbyManager.game_mode != "Candy Survival":
# 60% Chance for Common (7-10), 40% for PowerUp
if randf() <= 0.6:
return [7, 8, 9, 10].pick_random()
+43 -4
View File
@@ -601,6 +601,45 @@ func _get_all_mesh_instances(node: Node) -> Array:
result.append_array(_get_all_mesh_instances(child))
return result
# -----------------------------------------------------------------
# RPCs
# -----------------------------------------------------------------
@rpc("any_peer", "call_local", "reliable")
func sync_candy_stack(count: int, color_id: int) -> void:
var visuals = get_node_or_null("Visuals")
if not visuals: return
var old_stack = visuals.get_node_or_null("CandyStack")
if old_stack:
old_stack.queue_free()
if count <= 0: return
var stack_node = Node3D.new()
stack_node.name = "CandyStack"
visuals.add_child(stack_node)
stack_node.position = Vector3(0, 2.0, 0)
# Determine base tile and override material based on the mode config or default tile meshes
var mesh_path = "res://assets/models/tiles/tile_heart.tres"
match color_id:
0: mesh_path = "res://assets/models/tiles/tile_heart.tres"
1: mesh_path = "res://assets/models/tiles/tile_diamond.tres"
2: mesh_path = "res://assets/models/tiles/tile_star.tres"
3: mesh_path = "res://assets/models/tiles/tile_coin.tres"
var tile_mesh = load(mesh_path)
if not tile_mesh: return
for i in range(count):
var mi = MeshInstance3D.new()
mi.mesh = tile_mesh
mi.position = Vector3(0, i * 0.4, 0)
mi.scale = Vector3(0.5, 0.5, 0.5)
stack_node.add_child(mi)
@rpc("any_peer", "call_local", "reliable")
func sync_character(character_name: String) -> void:
"""Sync character selection across all clients."""
@@ -1140,11 +1179,11 @@ func _find_valid_drop_position() -> Vector2i:
var item_cell = Vector3i(pos.x, 1, pos.y)
if enhanced_gridmap.get_cell_item(item_cell) == -1:
if not is_position_occupied(pos):
# Gauntlet Mode explicit overrides
# Candy Survival explicit overrides
var gm = null
var main_gauntlet = get_tree().root.get_node_or_null("Main")
if main_gauntlet and main_gauntlet.get("gauntlet_manager"):
gm = main_gauntlet.gauntlet_manager
var main_candy_survival = get_tree().root.get_node_or_null("Main")
if main_candy_survival and main_candy_survival.get("candy_survival_manager"):
gm = main_candy_survival.candy_survival_manager
if gm and gm.is_active:
if pos.x == 0 or pos.x == gm.ARENA_COLUMNS - 1 or pos.y == 0 or pos.y == gm.ARENA_ROWS - 1:
continue
+1 -1
View File
@@ -153,7 +153,7 @@ func _on_room_joined(room_data: Dictionary) -> void:
_on_enable_cycle_timer_changed(LobbyManager.enable_cycle_timer)
_on_scarcity_mode_changed(LobbyManager.scarcity_mode)
_on_sng_update()
_on_doors_update()
# _on_doors_update()
if lobby.area_left_btn: lobby.area_left_btn.disabled = not is_host
if lobby.area_right_btn: lobby.area_right_btn.disabled = not is_host
+42 -14
View File
@@ -210,11 +210,36 @@ func _run_ai_tick():
print("[BotController] Action Taken: Attack Pursuit")
return
# Priority 0.5: Gauntlet (#075) — use Ghost powerup if boxed in
# Priority 0.5: Candy Survival (#075) — use Ghost powerup if boxed in
if await _try_activate_ghost():
print("[BotController] Action Taken: Ghost (trapped)")
return
# Priority 0.7: Candy Survival — Deliver candies to Mekton NPC
if strategic_planner and strategic_planner.is_candy_survival_mode():
var gm = strategic_planner._get_candy_survival_manager()
if gm and gm.active:
var pid = actor.get("peer_id") if "peer_id" in actor else actor.name.to_int()
var held_color = gm.player_candy_color.get(pid, -1)
if held_color != -1 and gm.player_candies.get(pid, 0) > 0:
if held_color == gm.current_face:
# Face matches! Run to the NPC Center!
var path = enhanced_gridmap.find_path(
Vector2(actor.current_position),
Vector2(8, 8),
0, false, false
)
if path.size() >= 2:
var next_step = Vector2i(path[1].x, path[1].y)
if actor.movement_manager.simple_move_to(next_step):
_is_processing_action = true
_current_action = "delivering_candies"
while is_instance_valid(actor) and actor.is_player_moving:
await get_tree().process_frame
_is_processing_action = false
print("[BotController] Action Taken: Delivering candies to Mekton!")
return
# Priority 1: Tekton Management (Grab Tekton if full boost, or spawn if carrying)
# Spawning while carrying is high priority; Hunting is medium priority.
if await _try_tekton_action():
@@ -260,27 +285,30 @@ func _run_ai_tick():
return
# =============================================================================
# Gauntlet (#075) — Ghost Powerup + Sticky Avoidance wiring
# Candy Survival (#075) — Ghost Powerup + Sticky Avoidance wiring
# =============================================================================
func _try_activate_ghost() -> bool:
"""Activate Ghost powerup when the planner reports imminent danger.
Uses the existing SpecialTilesManager to activate the held ghost powerup.
Uses CandySurvivalManager to activate the native ghost charges.
Returns true if activation was triggered."""
if not strategic_planner or not strategic_planner.is_gauntlet_mode():
if not strategic_planner or not strategic_planner.is_candy_survival_mode():
return false
if not strategic_planner.should_activate_ghost_now():
return false
var stm = actor.get_node_or_null("SpecialTilesManager")
if not stm:
var gm = strategic_planner._get_candy_survival_manager()
if not gm or not gm.is_active:
return false
if stm.has_method("activate_effect"):
stm.activate_effect(stm.SpecialEffect.INVISIBLE_MODE)
print("[BotController] %s activated Ghost powerup (trapped)" % actor.name)
return true
return false
var pid = actor.get("peer_id") if "peer_id" in actor else actor.name.to_int()
if multiplayer.is_server():
gm.try_activate_ghost(pid)
else:
gm.rpc_id(1, "try_activate_ghost", pid)
return true
func _on_step_onto_unsafe() -> bool:
"""Refuse to step onto a sticky/telegraphed cell and re-plan. Returns true
if the bot had to abort the planned move."""
@@ -291,9 +319,9 @@ func _on_step_onto_unsafe() -> bool:
return false
# Post-move guard: if we somehow landed on a sticky without ghost active,
# burn Ghost powerup to phase through next tick.
if strategic_planner.is_gauntlet_mode() and strategic_planner._is_overlay_unsafe(here):
if strategic_planner.is_candy_survival_mode() and strategic_planner._is_overlay_unsafe(here):
if not strategic_planner._is_bot_ghost_active():
var gm = strategic_planner._get_gauntlet_manager()
var gm = strategic_planner._get_candy_survival_manager()
if gm and gm.has_method("is_sticky_cell") and gm.is_sticky_cell(here):
print("[BotController] %s stepped onto sticky at %s — activating Ghost" % [actor.name, here])
return _try_activate_ghost()
+30 -30
View File
@@ -8,38 +8,38 @@ class_name BotStrategicPlanner
var actor: Node3D
var enhanced_gridmap: Node
# Optional explicit gauntlet_manager binding (set by tests to avoid scene-tree
# traversal collisions; production code uses _get_gauntlet_manager() instead).
var gauntlet_manager_override: Node = null
# Optional explicit candy_survival_manager binding (set by tests to avoid scene-tree
# traversal collisions; production code uses _get_candy_survival_manager() instead).
var candy_survival_manager_override: Node = null
# Tile type constants
const GOAL_TILES = [7, 8, 9, 10] # Heart, Diamond, Star, Coin
const HOLO_TILES = [11, 12, 13, 14] # Power-up holo tiles
# Gauntlet overlay layer (v2 ground-growth model — sticky/telegraph on layer 2).
# Candy Survival overlay layer (v2 ground-growth model — sticky/telegraph on layer 2).
# Bots must avoid these cells or use Ghost mode to cross.
const GAUNTLET_OVERLAY_LAYER: int = 2
const CANDY_SURVIVAL_OVERLAY_LAYER: int = 2
const TILE_STICKY: int = 17
const TILE_TELEGRAPH: int = 18
# =============================================================================
# Gauntlet mode helpers (#075 — Bot AI: Sticky Avoidance & Pathfinding)
# Candy Survival mode helpers (#075 — Bot AI: Sticky Avoidance & Pathfinding)
# =============================================================================
func is_gauntlet_mode() -> bool:
return LobbyManager and LobbyManager.is_game_mode(GameMode.Mode.GAUNTLET)
func is_candy_survival_mode() -> bool:
return LobbyManager and LobbyManager.is_game_mode(GameMode.Mode.CANDY_SURVIVAL)
func _get_gauntlet_manager() -> Node:
"""Resolve the active GauntletManager.
func _get_candy_survival_manager() -> Node:
"""Resolve the active CandySurvivalManager.
Order of resolution:
1. Explicit `gauntlet_manager_override` (used by tests).
2. Walk actor's ancestors for any node containing a GauntletManager child
1. Explicit `candy_survival_manager_override` (used by tests).
2. Walk actor's ancestors for any node containing a CandySurvivalManager child
(production path robust to non-standard scene trees).
3. Fallback: scan /root children for a GauntletManager.
3. Fallback: scan /root children for a CandySurvivalManager.
"""
if gauntlet_manager_override and is_instance_valid(gauntlet_manager_override):
return gauntlet_manager_override
if candy_survival_manager_override and is_instance_valid(candy_survival_manager_override):
return candy_survival_manager_override
var root: Node = null
if actor and actor.is_inside_tree():
root = actor.get_tree().get_root()
@@ -47,7 +47,7 @@ func _get_gauntlet_manager() -> Node:
# nested under Main → Arena → Player).
var n: Node = actor.get_parent()
while n:
var gm = n.get_node_or_null("GauntletManager")
var gm = n.get_node_or_null("CandySurvivalManager")
if gm:
return gm
n = n.get_parent()
@@ -56,37 +56,37 @@ func _get_gauntlet_manager() -> Node:
# Last-resort scan of root children (helps in unusual scene trees).
for child in root.get_children():
if child.name.begins_with("Main") or child.name.begins_with("BotTestMain"):
var gm2 = child.get_node_or_null("GauntletManager")
var gm2 = child.get_node_or_null("CandySurvivalManager")
if gm2:
return gm2
return null
func _bot_has_ghost_powerup() -> bool:
"""Check if the bot has a ghost powerup in its SpecialTilesManager inventory."""
var stm = actor.get_node_or_null("SpecialTilesManager")
if not stm:
"""Check if the bot has native ghost charges in CandySurvivalManager."""
var gm = _get_candy_survival_manager()
if not gm:
return false
return stm.inventory.get(stm.SpecialEffect.INVISIBLE_MODE, false)
var pid = actor.get("peer_id") if "peer_id" in actor else actor.name.to_int()
return gm.player_ghosts.get(pid, 0) > 0
func _is_bot_ghost_active() -> bool:
"""Check if the bot is currently in ghost (invisible) mode."""
return actor.get("is_invisible") == true
func _is_overlay_unsafe(pos: Vector2i) -> bool:
"""True if the cell carries a sticky or telegraphed overlay on layer 2."""
if not enhanced_gridmap:
return false
var item = enhanced_gridmap.get_cell_item(Vector3i(pos.x, GAUNTLET_OVERLAY_LAYER, pos.y))
var item = enhanced_gridmap.get_cell_item(Vector3i(pos.x, CANDY_SURVIVAL_OVERLAY_LAYER, pos.y))
return item == TILE_STICKY or item == TILE_TELEGRAPH
func _is_cell_unsafe_in_gauntlet(pos: Vector2i) -> bool:
"""Cell is unsafe in Gauntlet if it's sticky/telegraphed — unless the bot's
func _is_cell_unsafe_in_candy_survival(pos: Vector2i) -> bool:
"""Cell is unsafe in Candy Survival if it's sticky/telegraphed — unless the bot's
Ghost mode is active (grants sticky bypass)."""
if not is_gauntlet_mode():
if not is_candy_survival_mode():
return false
if _is_bot_ghost_active():
return false
var gm = _get_gauntlet_manager()
var gm = _get_candy_survival_manager()
if gm and gm.has_method("is_sticky_cell") and gm.is_sticky_cell(pos):
return true
return _is_overlay_unsafe(pos)
@@ -101,7 +101,7 @@ func _count_unsafe_neighbors(pos: Vector2i) -> int:
func should_activate_ghost_now() -> bool:
"""True if the bot is boxed in / about to be sealed and should use Ghost powerup."""
if not is_gauntlet_mode():
if not is_candy_survival_mode():
return false
if not _bot_has_ghost_powerup():
return false
@@ -613,12 +613,12 @@ func _is_valid_move_target(pos: Vector2i, ignore_players: bool = false) -> bool:
if not ignore_players and actor.is_position_occupied(pos):
return false
# Gauntlet mode (#075): reject cells that are sticky or telegraphed —
# Candy Survival mode (#075): reject cells that are sticky or telegraphed —
# stepping onto them either traps the bot or strands it within 1s.
# Safety applies even when ignore_players is true (a sticky cell is unsafe
# regardless of whether another player is on it). Ghost-active bots are
# exempt via the helper.
if _is_cell_unsafe_in_gauntlet(pos):
if _is_cell_unsafe_in_candy_survival(pos):
return false
return true
@@ -1,139 +0,0 @@
extends Node3D
class_name CandyCannonController
@export var is_static_turret: bool = true
@onready var ring1 = $Ring1 if has_node("Ring1") else null
@onready var ring2 = $Ring2 if has_node("Ring2") else null
@onready var ring3 = $Ring3 if has_node("Ring3") else null
@onready var tank = $Tank if has_node("Tank") else null
func _ready() -> void:
_apply_outline_recursive(self)
func _apply_outline_recursive(node: Node) -> void:
if node is MeshInstance3D and node.mesh:
# Some procedural meshes might not have get_surface_count or it might be 1.
# If the mesh has material_override, apply outline to that
if node.material_override and node.material_override is StandardMaterial3D:
var mat = node.material_override
if not mat.next_pass:
var outline_mat = ShaderMaterial.new()
outline_mat.shader = load("res://assets/shaders/outline3d.gdshader")
mat.next_pass = outline_mat
else:
for i in range(node.mesh.get_surface_count()):
var mat = node.get_active_material(i)
if mat:
if not mat.next_pass:
var unique_mat = mat.duplicate()
var outline_mat = ShaderMaterial.new()
outline_mat.shader = load("res://assets/shaders/outline3d.gdshader")
unique_mat.next_pass = outline_mat
node.set_surface_override_material(i, unique_mat)
if node is GPUParticles3D and node.draw_pass_1 and node.draw_pass_1.material:
var mat = node.draw_pass_1.material
if not mat.next_pass:
var outline_mat = ShaderMaterial.new()
outline_mat.shader = load("res://assets/shaders/outline3d.gdshader")
mat.next_pass = outline_mat
for child in node.get_children():
_apply_outline_recursive(child)
func _process(delta: float) -> void:
if ring1: ring1.rotate_y(delta * 1.5)
if ring2: ring2.rotate_x(delta * -1.0)
if ring3: ring3.rotate_z(delta * 1.2)
if tank and tank.mesh and tank.mesh.material:
var mat = tank.mesh.material as StandardMaterial3D
if mat:
# Gentle pulse of the candy tank
var pulse = (sin(Time.get_ticks_msec() / 300.0) + 1.0) * 0.5
mat.emission_energy_multiplier = 1.0 + (pulse * 2.0)
@rpc("authority", "call_local", "reliable")
func play_animation_rpc(anim_name: String) -> void:
# Stub for future model animations
pass
func spawn_projectile(target_world_pos: Vector3, duration: float) -> void:
var projectile = MeshInstance3D.new()
var sphere = SphereMesh.new()
sphere.radius = 0.3
sphere.height = 0.6
projectile.mesh = sphere
var mat = StandardMaterial3D.new()
mat.albedo_color = Color(1.0, 0.4, 0.8) # Candy pink for Gauntlet
mat.emission_enabled = true
mat.emission = Color(1.0, 0.4, 0.8)
mat.emission_energy_multiplier = 3.0
projectile.material_override = mat
projectile.top_level = true
add_child(projectile)
# Start projectile slightly above the cannon center
projectile.global_position = global_position + Vector3(0, 3.0, 0)
var tween = create_tween()
if not tween:
projectile.queue_free()
return
# VFX trail
var particles = GPUParticles3D.new()
var pmat = ParticleProcessMaterial.new()
pmat.emission_shape = ParticleProcessMaterial.EMISSION_SHAPE_SPHERE
pmat.emission_sphere_radius = 0.3
pmat.gravity = Vector3(0, 0, 0)
pmat.scale_min = 0.1
pmat.scale_max = 0.3
particles.process_material = pmat
var pmesh = SphereMesh.new()
pmesh.radius = 0.1
pmesh.height = 0.2
var spatial_mat = StandardMaterial3D.new()
spatial_mat.albedo_color = Color(1.0, 0.6, 0.9)
spatial_mat.emission_enabled = true
spatial_mat.emission = Color(1.0, 0.6, 0.9)
pmesh.material = spatial_mat
particles.draw_pass_1 = pmesh
particles.amount = 16
particles.lifetime = 0.4
projectile.add_child(particles)
_apply_outline_recursive(projectile)
tween.set_parallel(true)
tween.tween_property(projectile, "global_position:x", target_world_pos.x, duration).set_trans(Tween.TRANS_LINEAR)
tween.tween_property(projectile, "global_position:z", target_world_pos.z, duration).set_trans(Tween.TRANS_LINEAR)
var mid_y = max(global_position.y, target_world_pos.y) + 4.0
var tween_y = create_tween()
# Important: Make sure both halves of the y-tween together equal `duration`
tween_y.tween_property(projectile, "global_position:y", mid_y, duration / 2.0).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
tween_y.tween_property(projectile, "global_position:y", target_world_pos.y, duration / 2.0).set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN)
# Add some spin to the projectile
var spin_tween = create_tween()
spin_tween.set_loops()
spin_tween.tween_property(projectile, "rotation", Vector3(PI*2, PI*2, PI*2), 0.5).as_relative()
# We need to wait for the X/Z tween to finish, but since it's parallel we can just use a separate timer or tween
# to kill the projectile exactly when duration is reached, ensuring it doesn't get killed early by X/Z finishing 1 frame earlier than Y
get_tree().create_timer(duration).timeout.connect(func():
if is_instance_valid(spin_tween):
spin_tween.kill()
if is_instance_valid(projectile):
projectile.queue_free()
)
func can_rpc() -> bool:
if not multiplayer.has_multiplayer_peer(): return false
return multiplayer.multiplayer_peer.get_connection_status() == MultiplayerPeer.CONNECTION_CONNECTED
@@ -0,0 +1,57 @@
extends Node3D
class_name CandySurvivalNPCController
@onready var mekton_mesh = $MektonMesh
var face_material: StandardMaterial3D
func _ready() -> void:
# Setup unique material for the body to change colors
if mekton_mesh:
var skeleton = mekton_mesh.get_node_or_null("Throwing Tiles/Skeleton3D")
if skeleton:
var body = skeleton.get_node_or_null("ted_body")
if body and body is MeshInstance3D:
var mat = body.get_surface_override_material(0)
if not mat:
if body.mesh:
mat = body.mesh.surface_get_material(0)
if mat:
face_material = mat.duplicate()
else:
face_material = StandardMaterial3D.new()
face_material.emission_enabled = true
face_material.emission_energy_multiplier = 2.0
body.set_surface_override_material(0, face_material)
@rpc("authority", "call_local", "reliable")
func set_face_color_rpc(color_index: int) -> void:
if not face_material: return
# enum CandyColor { HEART=0, DIAMOND=1, STAR=2, COIN=3 }
var c = Color.WHITE
match color_index:
0: c = Color(1.0, 0.2, 0.2) # HEART (Red)
1: c = Color(0.2, 0.4, 1.0) # DIAMOND (Blue)
2: c = Color(1.0, 0.9, 0.2) # STAR (Yellow)
3: c = Color(1.0, 0.6, 0.0) # COIN (Orange/Gold)
face_material.albedo_color = c
face_material.emission = c
# Also tint the OmniLight if we have one
var light = $OmniLight3D
if light:
light.light_color = c
@rpc("authority", "call_local", "reliable")
func play_animation_rpc(anim_name: String) -> void:
if mekton_mesh:
var anim = mekton_mesh.get_node_or_null("AnimationPlayer")
if anim and anim.has_animation(anim_name):
anim.play(anim_name)
func can_rpc() -> bool:
if not multiplayer.has_multiplayer_peer(): return false
return multiplayer.multiplayer_peer.get_connection_status() == MultiplayerPeer.CONNECTION_CONNECTED
+7 -7
View File
@@ -1,7 +1,7 @@
extends RefCounted
class_name GameMode
enum Mode { FREEMODE = 0, STOP_N_GO = 1, GAUNTLET = 2 }
enum Mode { FREEMODE = 0, STOP_N_GO = 1, CANDY_SURVIVAL = 2 }
static func from_string(mode: String) -> Mode:
match mode:
@@ -9,8 +9,8 @@ static func from_string(mode: String) -> Mode:
return Mode.FREEMODE
"Stop n Go":
return Mode.STOP_N_GO
"Candy Pump Survival":
return Mode.GAUNTLET
"Candy Survival":
return Mode.CANDY_SURVIVAL
return Mode.FREEMODE
static func mode_to_string(mode: Mode) -> String:
@@ -19,13 +19,13 @@ static func mode_to_string(mode: Mode) -> String:
return "Freemode"
Mode.STOP_N_GO:
return "Stop n Go"
Mode.GAUNTLET:
return "Candy Pump Survival"
Mode.CANDY_SURVIVAL:
return "Candy Survival"
_:
return "Freemode"
static func is_restricted(mode: Mode) -> bool:
return mode == Mode.STOP_N_GO or mode == Mode.GAUNTLET
return mode == Mode.STOP_N_GO or mode == Mode.CANDY_SURVIVAL
static func get_all_modes() -> Array[String]:
return ["Freemode", "Stop n Go", "Candy Pump Survival"]
return ["Freemode", "Stop n Go", "Candy Survival"]
+3 -3
View File
@@ -12,7 +12,7 @@ var player: Node3D
@export var z_offset: float = 12.0
@export var default_y: float = 19.636
var bounds_gauntlet = { "min_x": 0.0, "max_x": 20.0, "min_z": 10.0, "max_z": 32.0 }
var bounds_candy_survival = { "min_x": 0.0, "max_x": 20.0, "min_z": 10.0, "max_z": 32.0 }
# Bounds Definitions { min_x, max_x, min_z, max_z }
var bounds_freemode = { "min_x": 3.0, "max_x": 11.0, "min_z": 13.0, "max_z": 22.5 }
@@ -48,8 +48,8 @@ func _calculate_target_position() -> Vector3:
# Apply Mode-Specific Clamping
var bounds = bounds_freemode # Default
if mode == GameMode.Mode.GAUNTLET:
bounds = bounds_gauntlet
if mode == GameMode.Mode.CANDY_SURVIVAL:
bounds = bounds_candy_survival
elif mode == GameMode.Mode.STOP_N_GO:
bounds = bounds_stop_n_go
+522
View File
@@ -0,0 +1,522 @@
extends Node
class_name CandySurvivalManager
# Candy Survival — Sugar Rush Chaos
# Speed Building Sabotage (blueprints + power-ups)
signal sugar_rush_started(pid)
signal sugar_rush_ended(pid)
signal mekton_face_changed(color_index)
# ── Arena ──
const ARENA_COLS: int = 18
const ARENA_ROWS: int = 18
const NPC_CENTER: Vector2i = Vector2i(8, 8)
const NPC_CELLS: int = 3 # 3x3 Mekton zone
# ── Blueprint ──
const BLUEPRINT_SIZE: int = 3
const OFF_COLOR_PENALTY: float = 0.5
# ── Candy ──
const CANDY_PPS: float = 1.0 # points per second per candy
const MULTI_STEP: float = 0.1 # extra multiplier per candy
# ── Sugar Rush ──
const SR_BASE_TIME: float = 2.0
const SR_PER_CANDY: float = 0.4 # extra seconds per delivered candy
const SR_SPEED: float = 2.0
# ── Knock / Ghost ──
const START_KNOCK: int = 5
const START_GHOST: int = 5
const GHOST_DURATION: float = 4.0
# ── Mekton ──
const COLOR_CYCLE_TIME: float = 5.0 # seconds between face color changes
enum CandyColor { HEART, DIAMOND, STAR, COIN }
# ── State ──
var active: bool = false
var main_scene: Node
var gridmap: Node
var mekton_node: Node
var current_face: CandyColor = CandyColor.HEART
var face_timer: float = 0.0
var game_elapsed: float = 0.0
# ── HUD ──
var hud_layer: CanvasLayer
var hud_knock_label: Label
var hud_ghost_label: Label
var hud_rush_bar: ProgressBar
var hud_rush_label: Label
var hud_stack_badge: Label
var hud_points_label: Label
var hud_delivery_indicator: Label
var _candy_survival_hud_scene: PackedScene = preload("res://scenes/candy_survival_hud.tscn")
func _ready():
set_process(false)
_setup_hud()
func _setup_hud() -> void:
var hud_instance = _candy_survival_hud_scene.instantiate()
hud_layer = hud_instance
hud_layer.visible = false
add_child(hud_layer)
var bot_box = hud_layer.get_node_or_null("BottomContainer/HBoxContainer")
if bot_box:
hud_knock_label = bot_box.get_node_or_null("SabotagePanel/KnockChargesLabel")
hud_ghost_label = bot_box.get_node_or_null("SabotagePanel/GhostChargesLabel")
hud_stack_badge = bot_box.get_node_or_null("ScorePanel/CandyStackBadge")
hud_points_label = bot_box.get_node_or_null("ScorePanel/PointsLabel")
hud_delivery_indicator = bot_box.get_node_or_null("ScorePanel/DeliveryIndicator")
var top_box = hud_layer.get_node_or_null("TopContainer")
if top_box:
hud_rush_bar = top_box.get_node_or_null("SugarRushBar")
if hud_rush_bar:
hud_rush_label = hud_rush_bar.get_node_or_null("SugarRushLabel")
func activate_client_side() -> void:
active = true
if hud_layer:
hud_layer.visible = true
set_process(true)
# Per-player state
var player_candies: Dictionary = {} # pid -> int (stack count)
var player_candy_color: Dictionary = {} # pid -> CandyColor (-1 if none)
var player_knocks: Dictionary = {} # pid -> int (charges left)
var player_ghosts: Dictionary = {} # pid -> int (charges left)
var player_ghost_active: Dictionary = {} # pid -> bool
var player_ghost_timer: Dictionary = {} # pid -> float
var player_score: Dictionary = {} # pid -> int
var player_blueprints: Dictionary = {} # pid -> int (completed count)
var player_sugar_rush: Dictionary = {} # pid -> float (remaining)
var player_last_knocked_by: Dictionary = {} # pid -> int
# Sticky wall cells (pre-placed collision only)
var sticky_cells: Dictionary = {} # Vector2i -> bool
# Tile ID mapping
const TILE_IDS: Dictionary = {CandyColor.HEART: 7, CandyColor.DIAMOND: 8, CandyColor.STAR: 9, CandyColor.COIN: 10}
# ── Initialization ──
func initialize(main, grid) -> void:
main_scene = main
gridmap = grid
_define_sticky_walls()
print("[CandySurvival] Initialized")
func _define_sticky_walls() -> void:
# Arena boundary walls (rows/cols 0 and 17)
for x in range(ARENA_COLS):
sticky_cells[Vector2i(x, 0)] = true
sticky_cells[Vector2i(x, ARENA_ROWS - 1)] = true
for y in range(ARENA_ROWS):
sticky_cells[Vector2i(0, y)] = true
sticky_cells[Vector2i(ARENA_COLS - 1, y)] = true
# Mekton NPC zone (3x3 center)
for dx in range(NPC_CELLS):
for dy in range(NPC_CELLS):
sticky_cells[Vector2i(NPC_CENTER.x + dx, NPC_CENTER.y + dy)] = true
func start_game_mode() -> void:
if multiplayer.is_server():
activate_client_side()
active = true
current_face = CandyColor.HEART
face_timer = 0.0
game_elapsed = 0.0
player_candies.clear()
player_candy_color.clear()
player_knocks.clear()
player_ghosts.clear()
player_ghost_active.clear()
player_ghost_timer.clear()
player_score.clear()
player_blueprints.clear()
player_sugar_rush.clear()
player_last_knocked_by.clear()
# Init players from lobby
var pids = _get_player_ids()
for pid in pids:
player_candies[pid] = 0
player_candy_color[pid] = -1
player_knocks[pid] = START_KNOCK
player_ghosts[pid] = START_GHOST
player_ghost_active[pid] = false
player_ghost_timer[pid] = 0.0
player_score[pid] = 0
player_blueprints[pid] = 0
player_sugar_rush[pid] = 0.0
player_last_knocked_by[pid] = 0
print("[CandySurvival] Started with %d players" % pids.size())
func _enter_tree() -> void:
set_process(true)
func _process(delta: float) -> void:
if not active:
return
game_elapsed += delta
# Mekton face color cycle
face_timer += delta
if face_timer >= COLOR_CYCLE_TIME:
face_timer = 0.0
current_face = CandyColor.values()[(current_face + 1) % CandyColor.size()]
# Sync color to the Mekton NPC
if mekton_node and mekton_node.has_method("set_face_color_rpc"):
mekton_node.rpc("set_face_color_rpc", current_face)
# Update delivery indicators for all players based on new face
for pid in player_candies:
_update_candy_badge(pid)
# Sugar Rush timers
var any_rush = false
for pid in player_sugar_rush.keys():
if player_sugar_rush[pid] > 0:
player_sugar_rush[pid] -= delta
if player_sugar_rush[pid] <= 0:
player_sugar_rush[pid] = 0.0
_restore_time_scale()
sugar_rush_ended.emit(pid)
if player_sugar_rush[pid] > 0:
any_rush = true
if any_rush:
Engine.time_scale = SR_SPEED
# Ghost timers
for pid in player_ghost_active.keys():
if player_ghost_active[pid]:
player_ghost_timer[pid] -= delta
if player_ghost_timer[pid] <= 0:
player_ghost_active[pid] = false
player_ghost_timer[pid] = 0.0
rpc("sync_ghost_active", pid, false)
# Turn off ghost visual/state
var all_players = get_tree().get_nodes_in_group("Players")
for player in all_players:
var curr_pid = player.get("peer_id") if "peer_id" in player else player.name.to_int()
if curr_pid == pid:
player.set("is_invisible", false)
if player.has_method("sync_modulate"):
if multiplayer.is_server() and player.has_method("can_rpc") and player.can_rpc():
player.rpc("sync_modulate", Color.WHITE)
else:
player.sync_modulate(Color.WHITE)
break
# Candy stack: points per second per candy
for pid in player_candies.keys():
var count = player_candies.get(pid, 0)
if count > 0:
var points = count * CANDY_PPS * delta
_add_score(pid, int(points))
# ── Blueprint ──
func on_blueprint_completed(pid: int, primary_tile_id: int, off_color: bool) -> void:
var base_points = 1000
var points = base_points if not off_color else int(base_points * OFF_COLOR_PENALTY)
_add_score(pid, points)
player_blueprints[pid] = player_blueprints.get(pid, 0) + 1
var candy_color = CandyColor.HEART
for key in TILE_IDS:
if TILE_IDS[key] == primary_tile_id:
candy_color = key
break
_give_candy(pid, candy_color)
func can_finish_with_off_color(pid: int, primary_tile_id: int) -> bool:
return not _grid_has_color_tiles(primary_tile_id)
func _grid_has_color_tiles(target_tile_id: int) -> bool:
if not gridmap:
return true
for x in range(1, ARENA_COLS - 1):
for y in range(1, ARENA_ROWS - 1):
var v = Vector3i(x, 1, y)
if gridmap.get_cell_item(v) == target_tile_id:
return true
return false
# ── Candy Stack ──
func _give_candy(pid: int, color: int) -> void:
player_candies[pid] = player_candies.get(pid, 0) + 1
player_candy_color[pid] = color
_update_candy_badge(pid)
func _update_candy_badge(pid: int) -> void:
var count = player_candies.get(pid, 0)
var mult = 1.0 + count * MULTI_STEP
var color = player_candy_color.get(pid, -1)
var face_match = (color != -1 and color == current_face)
rpc("sync_candy_badge", pid, count, mult, face_match)
# Update the 3D meshes on the player's head across all clients
var all_players = get_tree().get_nodes_in_group("Players")
for player in all_players:
var curr_pid = player.get("peer_id") if "peer_id" in player else player.name.to_int()
if curr_pid == pid:
if player.has_method("sync_candy_stack"):
player.rpc("sync_candy_stack", count, color)
break
func get_multiplier(pid: int) -> float:
var count = player_candies.get(pid, 0)
return 1.0 + count * MULTI_STEP
# ── Mekton Delivery ──
@rpc("any_peer", "call_local", "reliable")
func try_deliver(pid: int) -> bool:
if not multiplayer.is_server():
return false
var color = player_candy_color.get(pid, -1)
if color == -1 or player_candies.get(pid, 0) == 0:
return false
if color != current_face:
return false
var count = player_candies[pid]
var mult = get_multiplier(pid)
_add_score(pid, count * 500)
player_candies[pid] = 0
player_candy_color[pid] = -1
_update_candy_badge(pid)
_trigger_sugar_rush(pid, count, mult)
return true
func _trigger_sugar_rush(pid: int, candies: int, mult: float) -> void:
var duration = SR_BASE_TIME + candies * SR_PER_CANDY * mult
player_sugar_rush[pid] = duration
Engine.time_scale = SR_SPEED
sugar_rush_started.emit(pid)
func _restore_time_scale() -> void:
var any_rush = false
for pid in player_sugar_rush.keys():
if player_sugar_rush[pid] > 0:
any_rush = true
break
if not any_rush:
Engine.time_scale = 1.0
# ── Knock / Ghost ──
@rpc("any_peer", "call_local", "reliable")
func try_knock(attacker: int, target: int) -> bool:
if not multiplayer.is_server():
return false
if player_ghost_active.get(target, false):
return false
if player_knocks.get(attacker, 0) <= 0:
return false
var target_candies = player_candies.get(target, 0)
if target_candies == 0:
# Backfire: both lose a charge
player_knocks[attacker] = player_knocks.get(attacker, 0) - 1
# Attacker is also knocked down briefly (visual handled by caller)
rpc("sync_knock_result", attacker, target, 0)
return false
# Steal all candies
player_candies[attacker] = player_candies.get(attacker, 0) + target_candies
player_candies[target] = 0
player_candy_color[target] = -1
player_candy_color[attacker] = player_candy_color.get(target, -1)
player_knocks[attacker] = player_knocks.get(attacker, 0) - 1
player_last_knocked_by[target] = attacker
_add_score(attacker, target_candies * 100)
_update_candy_badge(attacker)
_update_candy_badge(target)
rpc("sync_knock_result", attacker, target, target_candies)
return true
func try_activate_ghost(pid: int) -> bool:
if player_ghost_active.get(pid, false):
return false
if player_ghosts.get(pid, 0) <= 0:
return false
player_ghosts[pid] = player_ghosts.get(pid, 0) - 1
player_ghost_active[pid] = true
player_ghost_timer[pid] = GHOST_DURATION
rpc("sync_ghost_active", pid, true)
# Core powerup integration: set is_invisible on the player node
var all_players = get_tree().get_nodes_in_group("Players")
for player in all_players:
var curr_pid = player.get("peer_id") if "peer_id" in player else player.name.to_int()
if curr_pid == pid:
player.set("is_invisible", true)
if player.has_method("sync_modulate"):
if multiplayer.is_server() and player.has_method("can_rpc") and player.can_rpc():
player.rpc("sync_modulate", Color(1.0, 1.0, 1.0, 0.4))
else:
player.sync_modulate(Color(1.0, 1.0, 1.0, 0.4))
break
return true
func is_ghost_active(pid: int) -> bool:
return player_ghost_active.get(pid, false)
# ── Arena ──
func _setup_arena() -> void:
if not gridmap:
return
gridmap.set("columns", ARENA_COLS)
gridmap.set("rows", ARENA_ROWS)
gridmap.clear()
# Build floor
for x in range(ARENA_COLS):
for y in range(ARENA_ROWS):
gridmap.set_cell_item(Vector3i(x, 0, y), 0)
# Apply sticky walls on layer 2
for pos in sticky_cells.keys():
gridmap.set_cell_item(Vector3i(pos.x, 2, pos.y), 14)
# Spawn Mekton NPC at center
if mekton_node:
mekton_node.queue_free()
mekton_node = _spawn_mekton_npc(NPC_CENTER)
print("[CandySurvival] Arena setup 18x18")
func _spawn_mekton_npc(center: Vector2i) -> Node:
var path = "res://scenes/candy_survival_npc.tscn"
if ResourceLoader.exists(path):
var npc = load(path).instantiate()
npc.position = Vector3(center.x + 1, 0, center.y + 1)
add_child(npc)
if npc.has_method("set_face_color_rpc"):
npc.set_face_color_rpc(current_face)
return npc
return null
func _apply_arena_setup() -> void:
pass
func setup_mission_tiles() -> void:
if not gridmap:
return
randomize()
var tile_ids = [7, 8, 9, 10]
var count = 0
for x in range(1, ARENA_COLS - 1):
for y in range(1, ARENA_ROWS - 1):
if sticky_cells.has(Vector2i(x, y)):
continue
if randf() < 0.6:
var tile = tile_ids[randi() % tile_ids.size()]
gridmap.set_cell_item(Vector3i(x, 1, y), tile)
count += 1
print("[CandySurvival] Spawned %d mission tiles" % count)
func get_spawn_points(count: int) -> Array:
var points = []
var corners = [
Vector2i(2, 2), Vector2i(ARENA_COLS - 2, 2),
Vector2i(2, ARENA_ROWS - 2), Vector2i(ARENA_COLS - 2, ARENA_ROWS - 2)
]
for i in range(count):
points.append(corners[i % corners.size()])
return points
func get_arena_positions() -> Dictionary:
return {"columns": ARENA_COLS, "rows": ARENA_ROWS}
func get_arena_bounds() -> Dictionary:
return {"min_x": -1.0, "max_x": float(ARENA_COLS), "min_z": -1.0, "max_z": float(ARENA_ROWS)}
# ── Sticky (pure wall collision) ──
func is_sticky_cell(pos: Vector2i) -> bool:
return sticky_cells.has(pos)
func _is_npc_zone(pos: Vector2i) -> bool:
var cx = NPC_CENTER.x
var cy = NPC_CENTER.y
return pos.x >= cx and pos.x < cx + NPC_CELLS and pos.y >= cy and pos.y < cy + NPC_CELLS
# ── Scoring ──
func _add_score(pid: int, points: int) -> void:
player_score[pid] = player_score.get(pid, 0) + points
if main_scene and main_scene.has_method("add_points"):
main_scene.add_points(pid, points)
# ── Helpers ──
func _get_player_ids() -> Array:
if main_scene and main_scene.has_method("get_player_ids"):
return main_scene.get_player_ids()
return []
func candy_survival_round_duration() -> int:
return 180
func get_score(pid: int) -> int:
return player_score.get(pid, 0)
# ── RPCs (stubs — HUD client handles visuals) ──
@rpc("authority", "call_remote", "unreliable")
func sync_candy_badge(pid: int, count: int, mult: float, face_match: bool) -> void:
if not active:
activate_client_side()
if pid == multiplayer.get_unique_id():
if hud_stack_badge:
hud_stack_badge.text = "Stack: %d (x%.1f)" % [count, mult]
if hud_delivery_indicator:
if count > 0:
if face_match:
hud_delivery_indicator.text = "READY TO DELIVER!"
hud_delivery_indicator.add_theme_color_override("font_color", Color(0.4, 1.0, 0.4))
else:
hud_delivery_indicator.text = "Waiting for match..."
hud_delivery_indicator.add_theme_color_override("font_color", Color(1.0, 0.4, 0.4))
else:
hud_delivery_indicator.text = ""
@rpc("authority", "call_remote", "unreliable")
func sync_knock_result(attacker: int, target: int, candies: int) -> void:
if not active:
activate_client_side()
var local = multiplayer.get_unique_id()
if attacker == local or target == local:
if hud_knock_label and player_knocks.has(local):
hud_knock_label.text = "🥊 Knocks: %d" % player_knocks[local]
@rpc("authority", "call_remote", "unreliable")
func sync_ghost_active(pid: int, active_on: bool) -> void:
if not active:
activate_client_side()
if pid == multiplayer.get_unique_id():
if hud_ghost_label and player_ghosts.has(pid):
hud_ghost_label.text = "👻 Ghosts: %d" % player_ghosts[pid]
-1825
View File
@@ -1,1825 +0,0 @@
extends Node
class_name GauntletManager
# GauntletManager - Handles Candy Pump Survival (Gauntlet) game mode
# Pattern: StopNGoManager + GauntletManager
signal phase_changed(phase_index: int, phase_name: String)
signal growth_tick(cells: Array)
signal player_trapped(player_id: int)
signal ghost_granted(player_id: int)
# =============================================================================
# Constants
# =============================================================================
const ARENA_COLUMNS: int = 20
const ARENA_ROWS: int = 20
const NPC_SIZE: int = 3
const NPC_CENTER: Vector2i = Vector2i(9, 9) # Center of 20x20 (0-indexed, center of 3x3 block)
# Tile IDs (matching MeshLibrary)
const TILE_WALKABLE: int = 0
const TILE_OBSTACLE: int = 4
const TILE_STICKY: int = 17 # New candy-pink overlay (Layer 2)
const TILE_TELEGRAPH: int = 18 # Warning glow (Layer 2, temporary)
# Cell states (v2 ground-growth model). Logical state of each playable cell.
enum CellState {
SAFE, # Can be entered, crossed, collected
TELEGRAPHED, # Warned as future sticky, still passable (1s)
STICKY, # Covered in sticky candy, blocks + traps
BUBBLE_GROWING, # Candy bubble growing, not yet exploded
BLOCKED, # NPC zone or permanent obstacle
}
# Cells temporarily protected after Ghost-clearing (not used — kept for compat).
var cleansed_cells: Dictionary = {}
const CLEANSED_PROTECTION_TIME: float = 5.0
# Phase timing thresholds (seconds elapsed)
const PHASE_1_START: float = 0.0 # Open Arena
const PHASE_2_START: float = 60.0 # Route Pressure
const PHASE_3_START: float = 120.0 # Survival Endgame
# =============================================================================
# Phase System
# =============================================================================
enum Phase { OPEN_ARENA, ROUTE_PRESSURE, SURVIVAL_ENDGAME }
var current_phase: Phase = Phase.OPEN_ARENA
var elapsed_time: float = 0.0
var is_active: bool = false
# =============================================================================
# Growth State (v2 ground-growth model — replaces cannon volley)
# =============================================================================
var growth_timer: float = 0.0
var growth_interval: float = 3.0 # seconds between growth ticks
var telegraph_duration: float = 1.0 # seconds telegraphed cells stay passable
var sticky_cells: Dictionary = {} # Vector2i → true
var telegraphed_cells: Dictionary = {} # Vector2i → time remaining (still passable)
var _last_tick_cells: Array = [] # cells selected last tick (for repetition penalty)
# Camping detection (#073): time each player has spent in their current 4x4
# region. player_id -> {"region": Vector2i, "time": float}.
var _camp_tracking: Dictionary = {}
const CAMP_REGION_SIZE: int = 4
# Movement buffers (#083): hidden, decaying penalties on SAFE cells that form
# critical movement corridors. Detected dynamically each growth tick; never
# shown to players. pos(Vector2i) -> {"penalty": float, "adjacent": bool}.
# The penalty discourages the growth algorithm from sealing off a corridor too
# early, then fades over time / phases so the arena still closes in by the end.
var movement_buffers: Dictionary = {}
var _buffer_decay_timer: float = 0.0
const BUFFER_DECAY_INTERVAL: float = 5.0 # seconds between decay steps
const BUFFER_DECAY_FACTOR: float = 0.75 # each step keeps 75% (25%)
const BUFFER_PHASE_DECAY: float = 0.5 # phase change halves all penalties
const BUFFER_MIN_PENALTY: float = 4.0 # prune below this magnitude
# Base "inside a buffer corridor" penalty per phase (adjacent = half).
const BUFFER_BASE_PENALTY: Array = [40.0, 20.0, 10.0]
# A SAFE cell is a corridor if removing it drops a player's reachable region
# below this many cells (i.e. it is a genuine chokepoint, not open floor).
const BUFFER_CORRIDOR_THRESHOLD: int = 12
# Candy bubbles (#082): occasional anti-camping hazards that grow from 1x1 and
# explode into a 3x3 sticky area. Separate from normal ground growth.
# active_bubbles entries: {"center": Vector2i, "timer": float, "cells": Array}.
var active_bubbles: Array = []
var bubble_cells: Dictionary = {} # Vector2i -> true (BUBBLE_GROWING state)
var recent_bubble_positions: Array = [] # centers of recent bubbles (anti-stacking)
var bubbles_this_phase: int = 0 # spawned in the current phase
var bubbles_total: int = 0 # spawned this round
const MAX_BUBBLES_PER_PHASE: Array = [0, 2, 3] # phase 1 / 2 / 3
const BUBBLE_GROW_DURATION: float = 2.75 # seconds from spawn to explosion (2.53)
const BUBBLE_EXPLOSION_RADIUS: int = 1 # 1 => 3x3 area
const BUBBLE_RECENT_MEMORY: int = 4 # how many recent centers to remember
const BUBBLE_RECENT_RADIUS: int = 3 # anti-stacking exclusion distance
# Phase-specific growth parameters (cells-per-tick range per phase).
# Layer weights: [outer, middle, inner] priority for the current pressure layer.
var phase_growth_config: Array = [
# Phase 0 (Outer Pressure): 4-6 cells/tick, push from the outside in
{"cells_min": 4, "cells_max": 6, "layer_weights": {"outer": 60, "middle": 15, "inner": -40}},
# Phase 1 (Middle Pressure): 6-8 cells/tick
{"cells_min": 6, "cells_max": 8, "layer_weights": {"outer": 20, "middle": 60, "inner": 5}},
# Phase 2 (Inner Survival): 8-10 cells/tick
{"cells_min": 8, "cells_max": 10, "layer_weights": {"outer": 10, "middle": 35, "inner": 60}},
]
# =============================================================================
# Smack State (per-player)
# =============================================================================
func has_smack_charged(pid: int) -> bool:
if smack_charged.has(pid) and smack_charged[pid] > 0:
return true
return false
@rpc("any_peer", "call_local", "reliable")
func consume_smack(pid: int) -> void:
# Local state reset
smack_charged[pid] = 0.0
smack_cooldowns[pid] = SMACK_COOLDOWN
# Play smack sound
if SfxManager:
SfxManager.rpc("play_rpc", "attack_mode") if _can_rpc() else SfxManager.play("attack_mode")
var all_players = get_tree().get_nodes_in_group("Players")
for player in all_players:
var curr_pid = player.get("peer_id") if "peer_id" in player else player.name.to_int()
if curr_pid == pid:
if player.has_method("sync_modulate"):
if _can_rpc():
player.rpc("sync_modulate", Color.WHITE)
else:
player.sync_modulate(Color.WHITE)
break
var smack_cooldowns: Dictionary = {} # player_id → float (time remaining)
var smack_charged: Dictionary = {} # player_id → float (charge window remaining)
const SMACK_COOLDOWN: float = 8.0
const SMACK_CHARGE_WINDOW: float = 3.0
# =============================================================================
# Ghost Reward Tracking (replaces Cleanser)
# =============================================================================
var player_mission_completions: Dictionary = {} # player_id → int
# =============================================================================
# Trapped Players
# =============================================================================
var trapped_players: Dictionary = {} # player_id → true (legacy; sticky now slows)
# Sticky entry slows the player instead of trapping them (per-player, fair in MP).
const STICKY_SLOW_DURATION: float = 2.0
# =============================================================================
# Slow-Mo Effect
# =============================================================================
var slowmo_active: bool = false
var slowmo_timer: float = 0.0
var slowmo_duration: float = 4.0
const SLOWMO_SCALE: float = 0.25 # 1/4 speed
var slowmo_overlay: ColorRect = null
# =============================================================================
# References
# =============================================================================
var main_scene: Node = null
var gridmap: Node = null
# Static Candy Pump NPC model at the arena center (the v2 "pump" that injects
# candy into the ground). Purely visual now — projectile logic was removed.
var candy_pump_scene: PackedScene = preload("res://scenes/candy_cannon.tscn")
var pump_instance: Node3D = null
# HUD
var hud_layer: CanvasLayer
var phase_label: Label
var slowmo_label: Label
var _gauntlet_hud_scene: PackedScene = preload("res://scenes/gauntlet_hud.tscn")
# =============================================================================
# Lifecycle
# =============================================================================
func _ready():
set_process(false)
_setup_hud()
func _exit_tree():
# Ensure time_scale is always restored when leaving Gauntlet mode
Engine.time_scale = 1.0
func initialize(main: Node, grid: Node) -> void:
main_scene = main
gridmap = grid
print("[Gauntlet] Initialized with gridmap: ", gridmap.name if gridmap else "null")
# Connect to GoalsCycleManager for scoring and mission tracking
if main_scene:
var gcm = main_scene.get_node_or_null("GoalsCycleManager")
if gcm:
gcm.goal_count_updated.connect(_on_goal_count_updated)
gcm.score_updated.connect(_on_score_updated)
print("[Gauntlet] Connected to GoalsCycleManager")
func _process(delta: float) -> void:
if not is_active:
return
if not multiplayer.has_multiplayer_peer() or multiplayer.multiplayer_peer == null:
return
elapsed_time += delta
# Phase escalation
_check_phase_transition()
# Server only logic
if multiplayer.is_server():
# Track camping behaviour for candidate scoring (#073)
_update_camp_tracking(delta)
# Growth tick timer
growth_timer -= delta
if growth_timer <= 0.0:
_process_growth_tick()
growth_timer = growth_interval
# Decay cleansed-cell protection windows
if not cleansed_cells.is_empty():
_tick_cleansed_cells(delta)
# Decay hidden movement buffers over time (#083)
_decay_movement_buffers(delta)
# Advance candy-bubble grow timers; explode when ready (#082)
_update_bubbles(delta)
# Smack mechanic update (ALL PEERS)
var all_players = get_tree().get_nodes_in_group("Players")
for player in all_players:
var pid = player.get("peer_id") if "peer_id" in player else player.name.to_int()
# Allow local peer to predict setup
if not smack_cooldowns.has(pid) and not smack_charged.has(pid):
smack_cooldowns[pid] = SMACK_COOLDOWN
smack_charged[pid] = 0.0
if smack_cooldowns[pid] > 0:
smack_cooldowns[pid] -= delta
if smack_cooldowns[pid] <= 0:
smack_cooldowns[pid] = 0.0
smack_charged[pid] = SMACK_CHARGE_WINDOW
if player.has_method("sync_modulate"):
if multiplayer.is_server() and _can_rpc():
player.rpc("sync_modulate", Color.PINK)
elif not multiplayer.is_server():
player.sync_modulate(Color.PINK)
elif smack_charged[pid] > 0:
smack_charged[pid] -= delta
if smack_charged[pid] <= 0:
smack_charged[pid] = 0.0
smack_cooldowns[pid] = SMACK_COOLDOWN
if player.has_method("sync_modulate"):
if multiplayer.is_server() and _can_rpc():
player.rpc("sync_modulate", Color.WHITE)
elif not multiplayer.is_server():
player.sync_modulate(Color.WHITE)
# Slow-mo timer (all peers for visual consistency)
if slowmo_active:
slowmo_timer -= delta
if slowmo_timer <= 0:
_end_slowmo()
# =============================================================================
# Game Mode Start
# =============================================================================
func start_game_mode() -> void:
if multiplayer.is_server():
activate_client_side()
_start_phase(Phase.OPEN_ARENA)
func activate_client_side() -> void:
is_active = true
if hud_layer:
hud_layer.visible = true
set_process(true)
# =============================================================================
# Phase Management
# =============================================================================
func _check_phase_transition() -> void:
var new_phase = current_phase
if elapsed_time >= PHASE_3_START:
new_phase = Phase.SURVIVAL_ENDGAME
elif elapsed_time >= PHASE_2_START:
new_phase = Phase.ROUTE_PRESSURE
if new_phase != current_phase:
_start_phase(new_phase)
func _start_phase(phase: Phase) -> void:
current_phase = phase
# Growth config is read per-tick from phase_growth_config[current_phase];
# resetting the timer keeps tick cadence aligned to the phase boundary.
growth_timer = growth_interval
# Phase change relaxes movement buffers by 50% — the arena is allowed to
# close in more aggressively as pressure escalates (#083).
if not movement_buffers.is_empty():
_scale_all_buffers(BUFFER_PHASE_DECAY)
# Reset the per-phase candy-bubble budget (#082).
bubbles_this_phase = 0
var phase_name = _phase_to_string(phase)
print("[Gauntlet] Phase changed to: ", phase_name)
if _can_rpc() and multiplayer.is_server():
rpc("sync_phase", int(phase), phase_name)
# Update phase explicitly with setup_arena
_shrink_arena()
emit_signal("phase_changed", int(phase), phase_name)
func _phase_to_string(phase: Phase) -> String:
match phase:
Phase.OPEN_ARENA:
return "Outer Pressure"
Phase.ROUTE_PRESSURE:
return "Middle Pressure"
Phase.SURVIVAL_ENDGAME:
return "Inner Survival"
_:
return "Unknown"
@rpc("authority", "call_local", "reliable")
func sync_phase(phase_index: int, phase_name: String) -> void:
if not is_active:
activate_client_side()
current_phase = phase_index as Phase
if not multiplayer.is_server():
var bounds = get_arena_bounds()
for x in range(ARENA_COLUMNS):
for z in range(ARENA_ROWS):
var pos = Vector2i(x, z)
if pos.x <= bounds.min or pos.x >= bounds.max or pos.y <= bounds.min or pos.y >= bounds.max:
if not sticky_cells.has(pos):
sticky_cells[pos] = true
_update_hud_phase(phase_name)
# =============================================================================
# Arena Setup
# =============================================================================
func _setup_arena() -> void:
"""Called by host in main._setup_host_game()"""
if not gridmap:
gridmap = get_parent().get_node_or_null("EnhancedGridMap")
if not gridmap:
gridmap = get_node_or_null("/root/Main/EnhancedGridMap")
if not gridmap:
push_error("[Gauntlet] No EnhancedGridMap found!")
return
print("[Gauntlet] Setting up %dx%d Arena..." % [ARENA_COLUMNS, ARENA_ROWS])
# Sync to clients
if _can_rpc():
rpc("sync_arena_setup")
# Apply locally for server
_apply_arena_setup()
@rpc("authority", "call_remote", "reliable")
func sync_arena_setup() -> void:
print("[Gauntlet] Client: Syncing Arena Setup (%dx%d)..." % [ARENA_COLUMNS, ARENA_ROWS])
_apply_arena_setup()
func _apply_arena_setup() -> void:
"""Shared arena layout logic for host + clients."""
if not gridmap:
gridmap = get_parent().get_node_or_null("EnhancedGridMap")
if not gridmap:
gridmap = get_node_or_null("/root/Main/EnhancedGridMap")
if not gridmap: return
# Resize grid (bypass setters that wipe the map)
gridmap.set("columns", ARENA_COLUMNS)
gridmap.set("rows", ARENA_ROWS)
# Clear all
gridmap.clear()
# Build the 20x20 arena
for x in range(ARENA_COLUMNS):
for z in range(ARENA_ROWS):
var pos = Vector2i(x, z)
# Center 3x3 block: NPC obstacle (Candy Pump)
if x >= 8 and x <= 10 and z >= 8 and z <= 10:
# Hardcode clear all possible layers beneath the Candy Pump
for layer in range(5):
gridmap.set_cell_item(Vector3i(x, layer, z), -1)
continue
# Boundary walls: perimeter (row 0, row 19, col 0, col 19)
if pos.x <= 0 or pos.x >= 19 or pos.y <= 0 or pos.y >= 19:
# Also make border walls visually walkable floors instead of red blocks
gridmap.set_cell_item(Vector3i(x, 0, z), TILE_WALKABLE)
gridmap.set_cell_item(Vector3i(x, 1, z), -1)
gridmap.set_cell_item(Vector3i(x, 2, z), TILE_STICKY)
sticky_cells[pos] = true
continue
# Interior: walkable floor
gridmap.set_cell_item(Vector3i(x, 0, z), TILE_WALKABLE)
gridmap.set_cell_item(Vector3i(x, 1, z), -1)
gridmap.set_cell_item(Vector3i(x, 2, z), -1)
gridmap.diagonal_movement = true
gridmap.update_grid_data()
gridmap.initialize_astar()
if not pump_instance and main_scene:
pump_instance = candy_pump_scene.instantiate()
pump_instance.name = "CandyPump"
var cx = NPC_CENTER.x * gridmap.cell_size.x + gridmap.cell_size.x / 2.0
var cz = NPC_CENTER.y * gridmap.cell_size.z + gridmap.cell_size.z / 2.0
pump_instance.position = Vector3(cx, 0, cz)
main_scene.add_child(pump_instance)
print("[Gauntlet] Arena setup complete. Boundary walls at perimeter. Center NPC at (%d,%d)" % [
NPC_CENTER.x, NPC_CENTER.y
])
func _is_npc_zone(pos: Vector2i) -> bool:
"""Check if a position is within the center 3x3 NPC zone."""
return pos.x >= 8 and pos.x <= 10 and pos.y >= 8 and pos.y <= 10
func get_spawn_points(player_count: int) -> Array[Vector2i]:
"""Return spawn positions based on player count. Inside boundary walls."""
# 4 players: inner corners
var spawns_4: Array[Vector2i] = [
Vector2i(1, 1), # Top-left
Vector2i(18, 1), # Top-right
Vector2i(1, 18), # Bottom-left
Vector2i(18, 18), # Bottom-right
]
# 6 players: corners + mid-edges (top/bottom)
var spawns_6: Array[Vector2i] = spawns_4.duplicate()
spawns_6.append(Vector2i(10, 1)) # Top-mid
spawns_6.append(Vector2i(10, 18)) # Bottom-mid
# 8 players: corners + all mid-edges
var spawns_8: Array[Vector2i] = spawns_6.duplicate()
spawns_8.append(Vector2i(1, 10)) # Left-mid
spawns_8.append(Vector2i(18, 10)) # Right-mid
match player_count:
4:
return spawns_4
5, 6:
return spawns_6
_, 7, 8:
return spawns_8
_:
return spawns_4
# =============================================================================
# Tile Spawning & Mission System (Task #3)
# =============================================================================
func setup_mission_tiles() -> void:
"""Public wrapper called from main.gd before countdown. Server-only."""
if multiplayer.is_server():
_spawn_mission_tiles()
func _spawn_mission_tiles() -> void:
"""Distribute colored goal tiles across the 20x20 arena.
Follows StopNGoManager._spawn_mission_tiles() pattern.
Excludes center 3x3 NPC zone."""
if not gridmap:
gridmap = get_parent().get_node_or_null("EnhancedGridMap")
if not gridmap:
gridmap = get_node_or_null("/root/Main/EnhancedGridMap")
if not gridmap: return
# Goal items: Heart(7), Diamond(8), Star(9), Coin(10)
var goal_items = [7, 8, 9, 10]
var tiles_spawned: int = 0
var main = get_node_or_null("/root/Main")
for x in range(ARENA_COLUMNS):
for z in range(ARENA_ROWS):
var pos = Vector2i(x, z)
# Skip NPC pump zone (center 3x3)
if x >= 8 and x <= 10 and z >= 8 and z <= 10:
continue
# Check base floor — don't spawn on void (or walls if they were still obstacles)
var base_tile = gridmap.get_cell_item(Vector3i(x, 0, z))
if base_tile == -1:
continue
# Ensure we don't spawn powerups on the perimeter walls even though they look like floors
if x == 0 or x == ARENA_COLUMNS - 1 or z == 0 or z == ARENA_ROWS - 1:
continue
# Skip if something already exists on Layer 1
var current_item = gridmap.get_cell_item(Vector3i(x, 1, z))
if current_item != -1:
continue
# Spawn tiles with 60% density (40% chance to skip)
if randf() > 0.6:
continue
var tile_type = goal_items[randi() % goal_items.size()]
gridmap.set_cell_item(Vector3i(x, 1, z), tile_type)
tiles_spawned += 1
# Sync to clients
if main:
main.rpc("sync_grid_item", x, 1, z, tile_type)
print("[Gauntlet] Spawned %d mission tiles across %dx%d arena" % [tiles_spawned, ARENA_COLUMNS, ARENA_ROWS])
# =============================================================================
# Growth Logic (Server Only) — v2 ground-growth, replaces cannon volley
# =============================================================================
func _process_growth_tick() -> void:
"""One growth tick: score SAFE cells, weight-select, path-check, telegraph."""
if not multiplayer.is_server():
return
var count := _cells_this_tick()
# Detect hidden movement-buffer corridors before scoring so the candidate
# scores reflect them this tick (#083; satisfies #067's buffer-check item).
_detect_movement_buffers()
var candidates := _generate_candidates()
if candidates.is_empty():
return
var selected := _select_cells_weighted(candidates, count)
selected = _apply_path_safety(selected)
if selected.is_empty():
return
_last_tick_cells = selected.duplicate()
# Telegraph now (passable for telegraph_duration), then convert to sticky.
for pos in selected:
telegraphed_cells[pos] = telegraph_duration
if _can_rpc():
rpc("sync_growth_telegraph", selected)
else:
sync_growth_telegraph(selected)
await get_tree().create_timer(telegraph_duration).timeout
for pos in selected:
telegraphed_cells.erase(pos)
if _can_rpc():
rpc("sync_growth_apply", selected)
else:
sync_growth_apply(selected)
emit_signal("growth_tick", selected)
# Possibly start a candy bubble this tick (anti-camping hazard, #082).
_try_spawn_bubble()
func _cells_this_tick() -> int:
"""Random cell count within this phase's configured range."""
var cfg = phase_growth_config[int(current_phase)]
var lo: int = cfg["cells_min"]
var hi: int = cfg["cells_max"]
if hi <= lo:
return lo
return lo + randi() % (hi - lo + 1)
func _generate_candidates() -> Array:
"""Build a list of {pos, score} for every SAFE, growable cell."""
var candidates: Array = []
var player_cells := _active_player_cells() # gathered once per tick
for x in range(ARENA_COLUMNS):
for z in range(ARENA_ROWS):
var pos := Vector2i(x, z)
# Only SAFE cells are growable; skip blocked, sticky, telegraphed,
# and cleansed (temporary regrowth protection from #068).
if cell_state(pos) != CellState.SAFE:
continue
candidates.append({"pos": pos, "score": _calculate_candidate_score(pos, player_cells)})
return candidates
func _calculate_candidate_score(pos: Vector2i, player_cells: Array = []) -> float:
"""Full v2 candidate score (#073). Higher score = higher pick chance.
CandidateScore =
LayerPriority + StickyNeighbor + InwardPressure + PlayerPressure
+ ClusterGrowth + CampingPressure + RandomNoise
+ MovementBuffer + PathSafety + Repetition
"""
var score := 0.0
score += _score_layer_priority(pos)
score += _score_sticky_neighbor(pos)
score += _score_inward_pressure(pos)
score += _score_player_pressure(pos, player_cells)
score += _score_cluster_growth(pos)
score += _score_camping_pressure(pos)
score += randf_range(-20.0, 20.0) # RandomNoise — keep growth imperfect
score += _score_movement_buffer(pos)
score += _score_path_safety(pos)
score += _score_repetition(pos)
return score
# --- score components (#073) -------------------------------------------------
func _score_layer_priority(pos: Vector2i) -> float:
"""Steer growth to the current phase's pressure ring."""
var weights: Dictionary = phase_growth_config[int(current_phase)]["layer_weights"]
return float(weights[_layer_of(pos)])
func _score_sticky_neighbor(pos: Vector2i) -> float:
"""Prefer growing adjacent to existing sticky: +8 each, capped +64."""
return min(_sticky_neighbor_count(pos) * 8.0, 64.0)
func _score_inward_pressure(pos: Vector2i) -> float:
"""Push candy inward more strongly as the round progresses. Scales with how
close the cell is to the center within the per-phase range."""
var d := _chebyshev(pos, NPC_CENTER)
var max_d := float(maxi(ARENA_COLUMNS, ARENA_ROWS) / 2) # ~10
var closeness := clampf(1.0 - float(d) / max_d, 0.0, 1.0)
match int(current_phase):
0: return lerpf(0.0, 10.0, closeness)
1: return lerpf(5.0, 20.0, closeness)
_: return lerpf(10.0, 30.0, closeness)
func _score_player_pressure(pos: Vector2i, player_cells: Array) -> float:
"""Pressure players without directly targeting them.
- 2-4 cells away: +20
- directly under a player: -50 (before final 30s), +10 (final 30s)."""
if player_cells.is_empty():
return 0.0
var best := 0.0
var final_window := float(gauntlet_round_duration() - elapsed_time) <= FORCED_TRAP_WINDOW
for pcell in player_cells:
var d := _chebyshev(pos, pcell)
var s := 0.0
if d == 0:
s = 10.0 if final_window else -50.0
elif d >= 2 and d <= 4:
s = 20.0
if abs(s) > abs(best):
best = s
return best
func _score_cluster_growth(pos: Vector2i) -> float:
"""Reward expanding/connecting sticky clusters. Distinct sticky neighbours
spanning more than one direction implies a bridge between clusters."""
var neighbours := _sticky_neighbor_count(pos)
if neighbours == 0:
return 0.0
if neighbours >= 3:
return 25.0 # connects clusters
return 15.0 # expands a cluster
func _score_camping_pressure(pos: Vector2i) -> float:
"""Target areas where a player has lingered.
>5s: +20, >8s: +40, >10s: +60."""
var t := _camp_time_for_region(_region_of(pos))
if t > 10.0:
return 60.0
elif t > 8.0:
return 40.0
elif t > 5.0:
return 20.0
return 0.0
func _score_movement_buffer(pos: Vector2i) -> float:
"""Respect hidden safe zones. Two complementary parts (#083):
1. Dynamically-detected buffer corridors (decaying) `_buffer_penalty_at`.
2. A light proximity floor around players so the immediate ring stays open.
Both lift entirely in the final window so the arena can close out."""
var final_window := float(gauntlet_round_duration() - elapsed_time) <= FORCED_TRAP_WINDOW
if final_window:
return 0.0
# 1. Detected corridor buffers (strongest signal).
var buffer := _buffer_penalty_at(pos)
if buffer < 0.0:
return buffer
# 2. Proximity floor (kept from #073) — discourage sealing the ring next to a
# player even when no corridor was detected there.
var player_cells := _active_player_cells()
var min_d := INF
for pcell in player_cells:
min_d = min(min_d, float(_chebyshev(pos, pcell)))
if min_d == INF:
return 0.0
match int(current_phase):
0:
if min_d <= 1: return -40.0
elif min_d <= 2: return -20.0
1:
if min_d <= 1: return -20.0
elif min_d <= 2: return -10.0
_:
if min_d <= 1: return -10.0
return 0.0
func _score_path_safety(pos: Vector2i) -> float:
"""Soft penalty that discourages selections which would strand a player.
The hard guarantee is enforced separately by _apply_path_safety()."""
if float(gauntlet_round_duration() - elapsed_time) <= FORCED_TRAP_WINDOW:
return 0.0
var extra := {pos: true}
for pcell in _active_player_cells():
if not _player_has_safe_region(pcell, extra):
return -100.0 # would fully trap a player
return 0.0
func _score_repetition(pos: Vector2i) -> float:
"""Avoid spammy growth on last tick's footprint."""
for last in _last_tick_cells:
if _chebyshev(pos, last) <= 1:
return -30.0
return 0.0
func _select_cells_weighted(candidates: Array, count: int) -> Array:
"""Weighted-random selection: higher score = higher pick chance.
Scores are shifted positive so the lowest-scoring cell still has a small
non-zero weight, preserving organic unpredictability.
"""
var pool: Array = candidates.duplicate()
var picked: Array = []
# Find the minimum score to offset all weights into the positive range.
var min_score := INF
for c in pool:
min_score = min(min_score, c["score"])
var offset := 1.0 - min_score # ensures every weight >= 1.0
var n: int = min(count, pool.size())
for _i in range(n):
var total := 0.0
for c in pool:
total += c["score"] + offset
if total <= 0.0:
break
var roll := randf() * total
var acc := 0.0
var chosen_idx := 0
for j in range(pool.size()):
acc += pool[j]["score"] + offset
if roll <= acc:
chosen_idx = j
break
picked.append(pool[chosen_idx]["pos"])
pool.remove_at(chosen_idx)
return picked
# --- scoring helpers ---------------------------------------------------------
func _layer_of(pos: Vector2i) -> String:
"""Classify a cell into outer / middle / inner rings by Chebyshev distance
from the arena center (matches the NPC pump at the middle)."""
var d := _chebyshev(pos, NPC_CENTER)
if d >= 7:
return "outer"
elif d >= 4:
return "middle"
return "inner"
func _sticky_neighbor_count(pos: Vector2i) -> int:
"""Count of the 8 surrounding cells that are already sticky."""
var c := 0
for dx in range(-1, 2):
for dz in range(-1, 2):
if dx == 0 and dz == 0:
continue
if sticky_cells.has(pos + Vector2i(dx, dz)):
c += 1
return c
func _chebyshev(a: Vector2i, b: Vector2i) -> int:
return max(abs(a.x - b.x), abs(a.y - b.y))
# --- camping tracking --------------------------------------------------------
func _region_of(pos: Vector2i) -> Vector2i:
"""Coarse 4x4 region key a cell belongs to (for camping detection)."""
return Vector2i(pos.x / CAMP_REGION_SIZE, pos.y / CAMP_REGION_SIZE)
func _update_camp_tracking(delta: float) -> void:
"""Accumulate time each player spends in their current 4x4 region.
Resets the timer when a player moves to a new region. Server-side."""
var seen := {}
for player in get_tree().get_nodes_in_group("Players"):
var pid = player.get("peer_id") if "peer_id" in player else -1
if pid == -1 or not ("current_position" in player) or player.current_position == null:
continue
seen[pid] = true
var region := _region_of(player.current_position)
var rec = _camp_tracking.get(pid)
if rec == null or rec["region"] != region:
_camp_tracking[pid] = {"region": region, "time": 0.0}
else:
rec["time"] += delta
# Drop tracking for players that left the match.
for pid in _camp_tracking.keys():
if not seen.has(pid):
_camp_tracking.erase(pid)
func _camp_time_for_region(region: Vector2i) -> float:
"""Longest camp time any player has accrued in the given region."""
var best := 0.0
for pid in _camp_tracking:
var rec = _camp_tracking[pid]
if rec["region"] == region:
best = max(best, rec["time"])
return best
# =============================================================================
# Growth Telegraph & Apply (RPCs) — v2
# =============================================================================
@rpc("authority", "call_local", "reliable")
func sync_growth_telegraph(cells: Array) -> void:
"""Warn that the given cells will become sticky. Cells stay passable until
sync_growth_apply fires (telegraph_duration later)."""
if not gridmap: return
for cell in cells:
var pos = cell as Vector2i
if pos.x >= 8 and pos.x <= 10 and pos.y >= 8 and pos.y <= 10: continue
# Telegraph overlay tile on Layer 2 (still passable).
gridmap.set_cell_item(Vector3i(pos.x, 2, pos.y), TILE_TELEGRAPH)
_spawn_telegraph_highlight(pos)
# NEW: Throw projectile from pump for normal growth
if pump_instance and pump_instance.has_method("spawn_projectile"):
var target_world_pos = Vector3(
pos.x * gridmap.cell_size.x + gridmap.cell_size.x / 2.0,
0.5,
pos.y * gridmap.cell_size.z + gridmap.cell_size.z / 2.0
)
pump_instance.spawn_projectile(target_world_pos, telegraph_duration)
# Audio: warning pulse
if SfxManager:
SfxManager.rpc("play_rpc", "generate_tile") if _can_rpc() else SfxManager.play("generate_tile")
func _spawn_telegraph_highlight(pos: Vector2i) -> void:
"""Two-stage amber warning under a telegraphed cell (#069):
Build-up (00.8s): amber glow ramps alpha 01.
Flash (0.81.0s): flickers to bright amber just before impact.
Auto-removed at the end of the telegraph window. Amber here is deliberately
distinct from the pink/magenta sticky overlay so the two never read alike."""
var cs = gridmap.cell_size
var world_pos = Vector3(pos.x * cs.x + cs.x / 2.0, 0.15, pos.y * cs.z + cs.z / 2.0)
var mesh_inst = MeshInstance3D.new()
var box = BoxMesh.new()
box.size = Vector3(cs.x * 0.8, 0.02, cs.z * 0.8)
mesh_inst.mesh = box
mesh_inst.position = world_pos
var amber := Color(1.0, 0.65, 0.1) # syrup amber — clearly not sticky pink
var mat = StandardMaterial3D.new()
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
mat.albedo_color = Color(amber.r, amber.g, amber.b, 0.0)
mat.emission_enabled = true
mat.emission = amber
mat.emission_energy_multiplier = 1.5
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
mesh_inst.material_override = mat
var main = get_node_or_null("/root/Main")
if not main:
return
main.add_child(mesh_inst)
# Split the telegraph window 80% build-up / 20% flash.
var build := telegraph_duration * 0.8
var flash := telegraph_duration * 0.2
var tween = create_tween()
# Build-up: fade in to a steady amber.
tween.tween_method(func(a): mat.albedo_color.a = a, 0.0, 0.55, build)
# Flash: quick bright flicker (alpha + emission energy) right before impact.
tween.tween_method(func(e): mat.emission_energy_multiplier = e, 1.5, 4.0, flash * 0.5)
tween.parallel().tween_method(func(a): mat.albedo_color.a = a, 0.55, 0.9, flash * 0.5)
tween.tween_method(func(e): mat.emission_energy_multiplier = e, 4.0, 2.5, flash * 0.5)
var remove_timer = get_tree().create_timer(telegraph_duration)
remove_timer.timeout.connect(func():
if is_instance_valid(mesh_inst):
mesh_inst.queue_free()
)
@rpc("authority", "call_local", "reliable")
func sync_growth_apply(cells: Array) -> void:
"""Convert telegraphed cells to permanent sticky candy."""
if not gridmap: return
for cell in cells:
var pos = cell as Vector2i
if pos.x >= 8 and pos.x <= 10 and pos.y >= 8 and pos.y <= 10: continue
gridmap.set_cell_item(Vector3i(pos.x, 2, pos.y), TILE_STICKY)
sticky_cells[pos] = true
# Screen shake for impact
if main_scene and main_scene.get("screen_shake_manager"):
main_scene.screen_shake_manager.shake(0.15, 0.4)
# Audio: sticky splat
if SfxManager:
SfxManager.rpc("play_rpc", "tile_scatter") if _can_rpc() else SfxManager.play("tile_scatter")
_spawn_impact_particles(cells)
# Re-evaluate trapped players after the new sticky cells land.
_check_all_players_trapped()
func _spawn_impact_particles(targets: Array) -> void:
"""Spawn candy splash particles at impact locations."""
if not main_scene:
return
for target in targets:
var pos = target as Vector2i
var world_pos = Vector3(
pos.x * gridmap.cell_size.x + gridmap.cell_size.x / 2.0,
0.5, # Slightly above floor
pos.y * gridmap.cell_size.z + gridmap.cell_size.z / 2.0
)
# Create a simple particle effect (GPUParticles3D)
var particles = GPUParticles3D.new()
particles.emitting = true
particles.one_shot = true
particles.amount = 8
particles.lifetime = 0.5
particles.explosiveness = 1.0
# Candy pink color
var material = ParticleProcessMaterial.new()
material.emission_shape = ParticleProcessMaterial.EMISSION_SHAPE_SPHERE
material.emission_sphere_radius = 0.2
material.direction = Vector3(0, 1, 0)
material.spread = 45.0
material.initial_velocity_min = 2.0
material.initial_velocity_max = 4.0
material.gravity = Vector3(0, -9.8, 0)
material.scale_min = 0.1
material.scale_max = 0.3
# Define visual mesh
var mesh = BoxMesh.new()
mesh.size = Vector3(0.2, 0.2, 0.2)
var spatial_mat = StandardMaterial3D.new()
spatial_mat.albedo_color = Color(1.0, 0.6, 0.8) # Candy pink
spatial_mat.emission_enabled = true
spatial_mat.emission = Color(1.0, 0.6, 0.8)
spatial_mat.emission_energy_multiplier = 2.0
# Outline shader for splash VFX
var outline_mat = ShaderMaterial.new()
outline_mat.shader = load("res://assets/shaders/outline3d.gdshader")
spatial_mat.next_pass = outline_mat
mesh.material = spatial_mat
particles.draw_pass_1 = mesh
particles.process_material = material
particles.position = world_pos
main_scene.add_child(particles)
# Auto-remove after particles finish
await get_tree().create_timer(1.0).timeout
if particles and is_instance_valid(particles):
particles.queue_free()
# =============================================================================
# Sticky / Trap System
func is_sticky_cell(pos: Vector2i) -> bool:
return sticky_cells.has(pos)
func is_cleansed_cell(pos: Vector2i) -> bool:
return cleansed_cells.has(pos)
func cell_state(pos: Vector2i) -> CellState:
"""Logical state of a playable cell (v2 ground-growth model)."""
var b = get_arena_bounds()
if pos.x <= b.min or pos.x >= b.max or pos.y <= b.min or pos.y >= b.max:
return CellState.STICKY
if _is_npc_zone(pos) or _is_boundary(pos):
return CellState.BLOCKED
if is_sticky_cell(pos):
return CellState.STICKY
if cleansed_cells.has(pos):
return CellState.BLOCKED # Protected from regrowth temporarily
if telegraphed_cells.has(pos):
return CellState.TELEGRAPHED
if bubble_cells.has(pos):
return CellState.BUBBLE_GROWING
return CellState.SAFE
func mark_cleansed(pos: Vector2i) -> void:
"""Flag a cell as recently cleansed, granting temporary regrowth protection."""
cleansed_cells[pos] = CLEANSED_PROTECTION_TIME
func _tick_cleansed_cells(delta: float) -> void:
"""Count down cleansed-cell protection; expire when it runs out."""
var expired: Array[Vector2i] = []
for pos in cleansed_cells:
cleansed_cells[pos] -= delta
if cleansed_cells[pos] <= 0.0:
expired.append(pos)
for pos in expired:
cleansed_cells.erase(pos)
func get_arena_bounds() -> Dictionary:
match current_phase:
Phase.OPEN_ARENA:
return {"min": 0, "max": 19} # 20x20
Phase.ROUTE_PRESSURE:
return {"min": 1, "max": 18} # 18x18
Phase.SURVIVAL_ENDGAME:
return {"min": 6, "max": 12} # 7x7
return {"min": 0, "max": 19}
func _shrink_arena() -> void:
if not multiplayer.is_server(): return
var b = get_arena_bounds()
var new_sticky = []
for x in range(ARENA_COLUMNS):
for z in range(ARENA_ROWS):
var pos = Vector2i(x, z)
if _is_npc_zone(pos) or _is_boundary(pos):
continue
if pos.x <= b.min or pos.x >= b.max or pos.y <= b.min or pos.y >= b.max:
if not sticky_cells.has(pos):
new_sticky.append(pos)
if new_sticky.size() > 0:
if _can_rpc() and multiplayer.is_server():
rpc("sync_growth_apply", new_sticky)
else:
sync_growth_apply(new_sticky)
func _is_boundary(pos: Vector2i) -> bool:
return pos.x <= 0 or pos.x >= ARENA_COLUMNS - 1 or pos.y <= 0 or pos.y >= ARENA_ROWS - 1
# =============================================================================
# Coverage tracking (v2 target: 70-75%, down from v1's 80%)
# =============================================================================
const COVERAGE_TARGET_MIN: float = 0.70
const COVERAGE_TARGET_MAX: float = 0.75
func playable_cell_count() -> int:
"""Number of cells that can ever become sticky (interior, minus NPC zone)."""
var b = get_arena_bounds()
var count := 0
for x in range(ARENA_COLUMNS):
for z in range(ARENA_ROWS):
var pos := Vector2i(x, z)
if _is_boundary(pos) or _is_npc_zone(pos):
continue
if pos.x <= b.min or pos.x >= b.max or pos.y <= b.min or pos.y >= b.max:
continue
count += 1
return count
func coverage_ratio() -> float:
"""Fraction of playable cells currently sticky (0.0-1.0)."""
var playable := playable_cell_count()
if playable <= 0:
return 0.0
return float(sticky_cells.size()) / float(playable)
func is_coverage_reached() -> bool:
"""True once sticky coverage hits the v2 minimum target."""
return coverage_ratio() >= COVERAGE_TARGET_MIN
# =============================================================================
# Path safety (v2): never trap a player before the final window
# =============================================================================
const SAFE_REGION_MIN_CELLS: int = 6 # each player must keep this many reachable safe cells
const FORCED_TRAP_WINDOW: float = 30.0 # final seconds where trapping is allowed
func _is_cell_passable(pos: Vector2i, extra_sticky: Dictionary = {}) -> bool:
"""Can a player stand on / move through this cell, given a hypothetical sticky set?"""
var b = get_arena_bounds()
if pos.x <= b.min or pos.x >= b.max or pos.y <= b.min or pos.y >= b.max:
return false
if _is_boundary(pos) or _is_npc_zone(pos):
return false
if sticky_cells.has(pos) or extra_sticky.has(pos):
return false
return true
func _reachable_safe_cells(start: Vector2i, extra_sticky: Dictionary, limit: int) -> int:
"""Flood-fill from start over passable cells; stop early once `limit` reached."""
if not _is_cell_passable(start, extra_sticky):
return 0
var visited := {start: true}
var queue: Array[Vector2i] = [start]
var count := 0
const NEIGHBORS := [Vector2i(1, 0), Vector2i(-1, 0), Vector2i(0, 1), Vector2i(0, -1)]
while not queue.is_empty():
var cur: Vector2i = queue.pop_front()
count += 1
if count >= limit:
return count
for d in NEIGHBORS:
var nxt: Vector2i = cur + d
if visited.has(nxt):
continue
if _is_cell_passable(nxt, extra_sticky):
visited[nxt] = true
queue.push_back(nxt)
return count
func _player_has_safe_region(start: Vector2i, extra_sticky: Dictionary) -> bool:
"""Player at `start` still has at least SAFE_REGION_MIN_CELLS reachable cells."""
return _reachable_safe_cells(start, extra_sticky, SAFE_REGION_MIN_CELLS) >= SAFE_REGION_MIN_CELLS
func _apply_path_safety(candidates: Array) -> Array:
"""Filter a candidate sticky-cell list so no active player is trapped.
During the final FORCED_TRAP_WINDOW seconds, trapping is allowed and the
candidate list is returned unchanged.
"""
var time_left := float(gauntlet_round_duration() - elapsed_time)
if time_left <= FORCED_TRAP_WINDOW:
return candidates
var player_cells := _active_player_cells()
if player_cells.is_empty():
return candidates
var accepted: Array = []
var pending := {}
for c in candidates:
pending[c] = true
for c in candidates:
# Tentatively accept c, then verify every player keeps a safe region.
var trial := pending.duplicate()
# `pending` holds all not-yet-rejected candidates; treat accepted ones as sticky.
var trial_sticky := {}
for a in accepted:
trial_sticky[a] = true
trial_sticky[c] = true
var safe_for_all := true
for pcell in player_cells:
if not _player_has_safe_region(pcell, trial_sticky):
safe_for_all = false
break
if safe_for_all:
accepted.append(c)
else:
pending.erase(c)
return accepted
# =============================================================================
# Movement buffers (#083): hidden, decaying safe corridors
# =============================================================================
func _detect_movement_buffers() -> void:
"""Find SAFE cells that are critical movement corridors for active players and
register/refresh a hidden penalty on them. A corridor is a passable cell near
a player whose removal would shrink that player's reachable region below
BUFFER_CORRIDOR_THRESHOLD (a genuine chokepoint, not open floor).
Campers don't get fresh buffers near them — staying put forfeits protection.
Runs server-side once per growth tick, before scoring."""
var player_cells := _active_player_cells()
if player_cells.is_empty():
return
var base: float = BUFFER_BASE_PENALTY[int(current_phase)]
const NEIGHBORS := [Vector2i(1, 0), Vector2i(-1, 0), Vector2i(0, 1), Vector2i(0, -1)]
for pcell in player_cells:
# Camping override: a player lingering in one region loses buffer help.
if _camp_time_for_region(_region_of(pcell)) > 5.0:
continue
# Examine the passable cells immediately around the player.
for d in NEIGHBORS:
var cell: Vector2i = pcell + d
if not _is_cell_passable(cell):
continue
# Is this a chokepoint? Removing it must noticeably cut reachability.
var without := _reachable_safe_cells(pcell, {cell: true}, BUFFER_CORRIDOR_THRESHOLD)
if without < BUFFER_CORRIDOR_THRESHOLD:
_register_buffer(cell, base)
func _register_buffer(pos: Vector2i, penalty: float) -> void:
"""Add or refresh a buffer cell at full penalty for the current phase."""
if movement_buffers.has(pos):
# Refresh to the stronger of the existing or the new base penalty.
movement_buffers[pos]["penalty"] = max(movement_buffers[pos]["penalty"], penalty)
else:
movement_buffers[pos] = {"penalty": penalty}
func _decay_movement_buffers(delta: float) -> void:
"""Reduce buffer penalties by 25% every BUFFER_DECAY_INTERVAL seconds, then
prune any that have faded below BUFFER_MIN_PENALTY. Server-side each tick."""
if movement_buffers.is_empty():
return
_buffer_decay_timer += delta
if _buffer_decay_timer < BUFFER_DECAY_INTERVAL:
return
_buffer_decay_timer = 0.0
_scale_all_buffers(BUFFER_DECAY_FACTOR)
func _scale_all_buffers(factor: float) -> void:
"""Multiply every buffer penalty by `factor`, pruning faded entries."""
for pos in movement_buffers.keys():
var p: float = movement_buffers[pos]["penalty"] * factor
if p < BUFFER_MIN_PENALTY:
movement_buffers.erase(pos)
else:
movement_buffers[pos]["penalty"] = p
func _buffer_penalty_at(pos: Vector2i) -> float:
"""Penalty for landing growth on a buffer cell (inside = full, adjacent = half).
Lifts entirely in the final window so the arena can close out."""
if movement_buffers.is_empty():
return 0.0
if float(gauntlet_round_duration() - elapsed_time) <= FORCED_TRAP_WINDOW:
return 0.0
if movement_buffers.has(pos):
return -movement_buffers[pos]["penalty"]
# Adjacent to a buffer cell → half penalty.
const NEIGHBORS := [Vector2i(1, 0), Vector2i(-1, 0), Vector2i(0, 1), Vector2i(0, -1)]
for d in NEIGHBORS:
if movement_buffers.has(pos + d):
return -movement_buffers[pos + d]["penalty"] * 0.5
return 0.0
func _active_player_cells() -> Array[Vector2i]:
"""Current grid cells of non-trapped players."""
var cells: Array[Vector2i] = []
for player in get_tree().get_nodes_in_group("Players"):
var pid = player.get("peer_id") if "peer_id" in player else -1
if trapped_players.has(pid):
continue
if "current_position" in player and player.current_position != null:
cells.append(player.current_position)
return cells
# =============================================================================
# Candy bubbles (#082): anti-camping hazards (1x1 grow → 3x3 explosion)
# =============================================================================
func _bubble_budget_for_phase() -> int:
"""How many bubbles this phase is allowed to spawn in total."""
return MAX_BUBBLES_PER_PHASE[int(current_phase)]
func _generate_bubble_candidates() -> Array:
"""Score every SAFE cell as a potential bubble center. Returns {pos, score}."""
var candidates: Array = []
var player_cells := _active_player_cells()
for x in range(ARENA_COLUMNS):
for z in range(ARENA_ROWS):
var pos := Vector2i(x, z)
if cell_state(pos) != CellState.SAFE:
continue
# NEW: Ensure bubbles never pick boundary tiles or NPC area as center
if x == 0 or x == ARENA_COLUMNS - 1 or z == 0 or z == ARENA_ROWS - 1:
continue
if _is_npc_zone(pos):
continue
candidates.append({"pos": pos, "score": _calculate_bubble_score(pos, player_cells)})
return candidates
func _calculate_bubble_score(pos: Vector2i, player_cells: Array = []) -> float:
"""Bubble-specific scoring (#082). Higher = better bubble target.
BubbleScore = Camping + UntouchedArea + PlayerCluster + RandomNoise
+ DirectHitPenalty + RecentBubblePenalty + UnfairTrapPenalty
"""
var score := 0.0
score += _bubble_score_camping(pos)
score += _bubble_score_untouched_area(pos)
score += _bubble_score_player_cluster(pos, player_cells)
score += randf_range(-20.0, 20.0)
score += _bubble_score_direct_hit(pos, player_cells)
score += _bubble_score_recent(pos)
score += _bubble_score_unfair_trap(pos)
return score
func _bubble_score_camping(pos: Vector2i) -> float:
"""Reward targeting campers. +40 >5s, +60 >8s, +80 >10s-with-ghost."""
var t := _camp_time_for_region(_region_of(pos))
if t > 10.0:
# Stronger only if a nearby player is in ghost mode.
if _any_ghost_player_near(pos):
return 80.0
return 60.0
elif t > 8.0:
return 60.0
elif t > 5.0:
return 40.0
return 0.0
func _bubble_score_untouched_area(pos: Vector2i) -> float:
"""+30 when the cell sits in a large untouched (sticky-free) region."""
var open := _reachable_safe_cells(pos, {}, 30)
return 30.0 if open >= 24 else 0.0
func _bubble_score_player_cluster(pos: Vector2i, player_cells: Array) -> float:
"""+20 when 2+ players are nearby (within 4 cells)."""
var near := 0
for pcell in player_cells:
if _chebyshev(pos, pcell) <= 4:
near += 1
return 20.0 if near >= 2 else 0.0
func _bubble_score_direct_hit(pos: Vector2i, player_cells: Array) -> float:
"""-60 if a bubble would erupt directly under a player (unfair, unreadable)."""
for pcell in player_cells:
if pos == pcell:
return -60.0
return 0.0
func _bubble_score_recent(pos: Vector2i) -> float:
"""-50 if a recent bubble erupted in/near this region (anti-stacking)."""
for c in recent_bubble_positions:
if _chebyshev(pos, c) <= BUBBLE_RECENT_RADIUS:
return -50.0
return 0.0
func _bubble_score_unfair_trap(pos: Vector2i) -> float:
"""-100 if the 3x3 explosion would strand a player (before the final window)."""
if float(gauntlet_round_duration() - elapsed_time) <= FORCED_TRAP_WINDOW:
return 0.0
var blast := {}
for cell in _bubble_blast_cells(pos):
blast[cell] = true
for pcell in _active_player_cells():
if blast.has(pcell):
continue # direct-hit handled separately
if not _player_has_safe_region(pcell, blast):
return -100.0
return 0.0
func _bubble_blast_cells(center: Vector2i) -> Array:
"""The 3x3 (radius 1) sticky cells a bubble at `center` would create,
clipped to passable/playable cells."""
var b = get_arena_bounds()
var cells: Array = []
for dx in range(-BUBBLE_EXPLOSION_RADIUS, BUBBLE_EXPLOSION_RADIUS + 1):
for dz in range(-BUBBLE_EXPLOSION_RADIUS, BUBBLE_EXPLOSION_RADIUS + 1):
var c := center + Vector2i(dx, dz)
if _is_boundary(c) or _is_npc_zone(c):
continue
if c.x <= b.min or c.x >= b.max or c.y <= b.min or c.y >= b.max:
continue
cells.append(c)
return cells
func _bubble_footprint(center: Vector2i) -> Array:
return _bubble_blast_cells(center)
func _any_ghost_player_near(pos: Vector2i) -> bool:
"""True if a player in ghost mode is within the camping region."""
for player in get_tree().get_nodes_in_group("Players"):
if not player.get("is_invisible"):
continue
if "current_position" in player and player.current_position != null:
if _region_of(player.current_position) == _region_of(pos):
return true
return false
# --- bubble lifecycle (server-authoritative) ---------------------------------
func _try_spawn_bubble() -> void:
"""Maybe spawn one candy bubble this growth tick, if the phase still has
budget. Server-side; called from _process_growth_tick after normal growth."""
if not multiplayer.is_server():
return
if bubbles_this_phase >= _bubble_budget_for_phase():
return
# Probabilistic so bubbles don't all fire on the first ticks of a phase.
# ~1 in 4 eligible ticks; the per-phase cap still bounds the total.
if randf() > 0.25:
return
var candidates := _generate_bubble_candidates()
if candidates.is_empty():
return
var picked := _select_cells_weighted(candidates, 1)
if picked.is_empty():
return
var center: Vector2i = picked[0]
# Reject low-quality targets (e.g. recent/unfair) — only spawn if the chosen
# cell scores non-negative, so penalties can veto a bad bubble.
var best_score := -INF
for c in candidates:
if c["pos"] == center:
best_score = c["score"]
break
if best_score < 0.0:
return
_spawn_bubble(center)
func _spawn_bubble(center: Vector2i) -> void:
"""Begin a bubble at `center`: mark the 3x3 footprint BUBBLE_GROWING and start
its grow timer. Broadcasts the warning to clients."""
bubbles_this_phase += 1
bubbles_total += 1
var cells := _bubble_blast_cells(center)
for c in cells:
bubble_cells[c] = true
active_bubbles.append({"center": center, "timer": BUBBLE_GROW_DURATION, "cells": cells})
# Anti-stacking memory.
recent_bubble_positions.append(center)
while recent_bubble_positions.size() > BUBBLE_RECENT_MEMORY:
recent_bubble_positions.pop_front()
if _can_rpc():
rpc("sync_bubble_spawn", center, cells)
else:
sync_bubble_spawn(center, cells)
func _update_bubbles(delta: float) -> void:
"""Advance grow timers; explode bubbles whose timer elapses. Server-side."""
if active_bubbles.is_empty():
return
var exploded: Array = []
for b in active_bubbles:
b["timer"] -= delta
if b["timer"] <= 0.0:
exploded.append(b)
for b in exploded:
active_bubbles.erase(b)
_explode_bubble(b["center"], b["cells"])
func _explode_bubble(center: Vector2i, cells: Array) -> void:
"""Convert a bubble's 3x3 footprint to sticky, slow players caught inside,
and broadcast the explosion."""
for c in cells:
bubble_cells.erase(c)
sticky_cells[c] = true
if _can_rpc():
rpc("sync_bubble_explode", center, cells)
else:
sync_bubble_explode(center, cells)
# Slow any player standing in the blast (consistent with sticky entry, #068).
var blast := {}
for c in cells:
blast[c] = true
for player in get_tree().get_nodes_in_group("Players"):
if "current_position" in player and player.current_position != null:
if blast.has(player.current_position):
var pid = player.get("peer_id") if "peer_id" in player else -1
if pid != -1 and player.get("is_invisible"):
continue
apply_sticky_slow(player)
# Bot paths through the new sticky are now invalid.
if gridmap and gridmap.has_method("initialize_astar"):
gridmap.initialize_astar()
@rpc("authority", "call_local", "reliable")
func sync_bubble_spawn(center: Vector2i, cells: Array) -> void:
"""Show the growing bubble + 3x3 warning area on all clients."""
if not gridmap:
return
# Telegraph-style warning overlay on the footprint (still passable).
for c in cells:
var pos = c as Vector2i
if pos.x >= 8 and pos.x <= 10 and pos.y >= 8 and pos.y <= 10: continue
gridmap.set_cell_item(Vector3i(pos.x, 2, pos.y), TILE_TELEGRAPH)
_spawn_bubble_visual(center)
if SfxManager:
SfxManager.rpc("play_rpc", "generate_tile") if _can_rpc() else SfxManager.play("generate_tile")
# NEW: VFX projectile from center pump if it exists
if pump_instance and pump_instance.has_method("spawn_projectile"):
var target_world_pos = Vector3(
center.x * gridmap.cell_size.x + gridmap.cell_size.x / 2.0,
0.5,
center.y * gridmap.cell_size.z + gridmap.cell_size.z / 2.0
)
pump_instance.spawn_projectile(target_world_pos, BUBBLE_GROW_DURATION)
@rpc("authority", "call_local", "reliable")
func sync_bubble_explode(center: Vector2i, cells: Array) -> void:
"""Apply the 3x3 sticky overlay + explosion VFX on all clients."""
if not gridmap:
return
for c in cells:
var pos = c as Vector2i
if pos.x >= 8 and pos.x <= 10 and pos.y >= 8 and pos.y <= 10: continue
gridmap.set_cell_item(Vector3i(pos.x, 2, pos.y), TILE_STICKY)
sticky_cells[pos] = true
# Medium shake — bubbles hit harder than a normal growth tick.
if main_scene and main_scene.get("screen_shake_manager"):
main_scene.screen_shake_manager.shake(0.3, 0.6)
if SfxManager:
SfxManager.rpc("play_rpc", "tile_scatter") if _can_rpc() else SfxManager.play("tile_scatter")
_spawn_impact_particles(cells)
func _spawn_bubble_visual(center: Vector2i) -> void:
"""A pulsing candy bubble sphere that grows over the bubble's lifetime."""
if not gridmap:
return
var cs = gridmap.cell_size
var world_pos = Vector3(center.x * cs.x + cs.x / 2.0, 0.4, center.y * cs.z + cs.z / 2.0)
var mesh_inst = MeshInstance3D.new()
var sphere = SphereMesh.new()
sphere.radius = 0.25
sphere.height = 0.5
mesh_inst.mesh = sphere
mesh_inst.position = world_pos
var mat = StandardMaterial3D.new()
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
mat.albedo_color = Color(1.0, 0.2, 0.6, 0.7) # candy pink
mat.emission_enabled = true
mat.emission = Color(1.0, 0.2, 0.6)
mat.emission_energy_multiplier = 1.5
var outline_mat = ShaderMaterial.new()
outline_mat.shader = load("res://assets/shaders/outline3d.gdshader")
mat.next_pass = outline_mat
mesh_inst.material_override = mat
var main = get_node_or_null("/root/Main")
if not main:
return
main.add_child(mesh_inst)
# Grow + pulse over the grow duration, then remove (explosion VFX takes over).
var tween = create_tween()
tween.tween_property(mesh_inst, "scale", Vector3(3.0, 3.0, 3.0), BUBBLE_GROW_DURATION) \
.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN)
tween.parallel().tween_method(func(e): mat.emission_energy_multiplier = e, 1.5, 4.0, BUBBLE_GROW_DURATION)
var remove_timer = get_tree().create_timer(BUBBLE_GROW_DURATION + 0.05)
remove_timer.timeout.connect(func():
if is_instance_valid(mesh_inst):
mesh_inst.queue_free()
)
func gauntlet_round_duration() -> int:
"""Round length in seconds (from lobby settings, with a sane fallback)."""
if LobbyManager and "gauntlet_round_duration" in LobbyManager:
return LobbyManager.gauntlet_round_duration
return 180
func _check_all_players_trapped() -> void:
"""After growth lands, slow any player standing on a fresh sticky cell."""
if not multiplayer.is_server(): return
var all_players = get_tree().get_nodes_in_group("Players")
for player in all_players:
var pos = player.current_position if player.get("current_position") else Vector2i(-1, -1)
if is_sticky_cell(pos):
var pid = player.get("peer_id") if "peer_id" in player else -1
if pid != -1 and player.get("is_invisible"):
continue # ghost players are immune to the slow
apply_sticky_slow(player)
func apply_sticky_slow(player: Node) -> void:
"""Sticky candy slows a single player to a crawl (no global time_scale, no
hard freeze). The player can still struggle free at reduced speed."""
if not player or not player.has_method("apply_slow_effect"):
return
if _can_rpc():
player.rpc("apply_slow_effect", STICKY_SLOW_DURATION)
else:
player.apply_slow_effect(STICKY_SLOW_DURATION)
func _trap_player(player: Node) -> void:
"""Legacy hard-trap. No longer used for sticky entry (sticky now slows).
Kept for potential future hazards."""
var pid = player.get("peer_id") if "peer_id" in player else -1
if pid == -1: return
trapped_players[pid] = true
print("[Gauntlet] Player %d TRAPPED at %s" % [pid, str(player.current_position)])
emit_signal("player_trapped", pid)
# Apply visual feedback and notify
if player.has_method("apply_stagger"):
if _can_rpc():
player.rpc("apply_stagger", 999.0) # Basically infinite until cleansed
else:
player.apply_stagger(999.0)
NotificationManager.send_message(player, "Stuck in Candy!", NotificationManager.MessageType.WARNING)
func clear_sticky_cell(pos: Vector2i) -> void:
"""Remove a sticky cell (used when ghost player walks through)."""
if _can_rpc():
if multiplayer.is_server():
rpc("sync_clear_sticky_cell", pos)
else:
sync_clear_sticky_cell(pos) # Predictive local clear
else:
sync_clear_sticky_cell(pos)
@rpc("authority", "call_local", "reliable")
func sync_clear_sticky_cell(pos: Vector2i) -> void:
sticky_cells.erase(pos)
mark_cleansed(pos) # temporary regrowth protection
if gridmap:
gridmap.set_cell_item(Vector3i(pos.x, 2, pos.y), -1)
if SfxManager:
SfxManager.play("pick_up_power_tile")
# Sync removal to main scene's gridmap if needed
if main_scene and main_scene.has_method("sync_grid_item"):
main_scene.sync_grid_item(pos.x, 2, pos.y, -1)
@rpc("any_peer", "reliable")
func rpc_trigger_slowmo() -> void:
"""RPC for clients to request slow-mo from server."""
if multiplayer.is_server():
trigger_slowmo()
# =============================================================================
# Slow-Mo Effect
# =============================================================================
func trigger_slowmo(duration: float = 4.0) -> void:
"""Trigger slow-motion effect at 1/4 speed. Server-authoritative."""
if slowmo_active:
return
slowmo_active = true
slowmo_timer = duration
slowmo_duration = duration
Engine.time_scale = SLOWMO_SCALE
# Show visual overlay
if main_scene and main_scene.has_node("Camera3D200"):
_show_slowmo_overlay()
# Show slow-mo HUD label
if slowmo_label:
slowmo_label.visible = true
if _can_rpc():
rpc("sync_slowmo_start", duration)
func _end_slowmo() -> void:
slowmo_active = false
Engine.time_scale = 1.0
_hide_slowmo_overlay()
# Hide slow-mo HUD label
if slowmo_label:
slowmo_label.visible = false
if _can_rpc():
rpc("sync_slowmo_end")
func _show_slowmo_overlay() -> void:
if slowmo_overlay:
return
slowmo_overlay = ColorRect.new()
slowmo_overlay.color = Color(0.3, 0.5, 1.0, 0.1) # Subtle blue tint
slowmo_overlay.set_anchors_preset(Control.PRESET_FULL_RECT)
slowmo_overlay.mouse_filter = Control.MOUSE_FILTER_IGNORE
var cam = main_scene.get_node_or_null("Camera3D200")
if cam:
# Find or create a CanvasLayer for the overlay
var canvas = CanvasLayer.new()
canvas.layer = 4
main_scene.add_child(canvas)
canvas.add_child(slowmo_overlay)
# Fade in
slowmo_overlay.color.a = 0.0
var tween = create_tween()
tween.tween_property(slowmo_overlay, "color:a", 0.1, 0.3)
func _hide_slowmo_overlay() -> void:
if slowmo_overlay:
var tween = create_tween()
tween.tween_property(slowmo_overlay, "color:a", 0.0, 0.3)
tween.tween_callback(slowmo_overlay.get_parent().queue_free)
slowmo_overlay = null
@rpc("authority", "call_local", "reliable")
func sync_slowmo_start(duration: float) -> void:
slowmo_active = true
slowmo_timer = duration
Engine.time_scale = SLOWMO_SCALE
_show_slowmo_overlay()
if slowmo_label:
slowmo_label.visible = true
@rpc("authority", "call_local", "reliable")
func sync_slowmo_end() -> void:
_end_slowmo()
# =============================================================================
# HUD
# =============================================================================
func _setup_hud() -> void:
var hud_instance = _gauntlet_hud_scene.instantiate()
hud_layer = hud_instance
hud_layer.visible = false
add_child(hud_layer)
phase_label = hud_layer.get_node("BottomContainer/VBoxContainer/PhaseLabel")
slowmo_label = hud_layer.get_node_or_null("TopContainer/SlowMoLabel")
func _update_hud_phase(phase_name: String) -> void:
if phase_label:
var icon = "🍬"
match phase_name:
"Middle Pressure":
icon = "⚠️"
phase_label.add_theme_color_override("font_color", Color(1.0, 0.8, 0.2)) # Warning gold
"Inner Survival":
icon = "💀"
phase_label.add_theme_color_override("font_color", Color(1.0, 0.3, 0.3)) # Danger red
_:
phase_label.add_theme_color_override("font_color", Color(1.0, 0.6, 0.8)) # Candy pink
phase_label.text = "%s %s" % [icon, phase_name.to_upper()]
# Animate phase label with bounce effect
_animate_phase_label()
func _animate_phase_label() -> void:
"""Animate phase label with bounce effect."""
if not phase_label:
return
# Create tween for bounce animation
var tween = create_tween()
tween.set_ease(Tween.EASE_OUT)
tween.set_trans(Tween.TRANS_ELASTIC)
# Scale up then back to normal
var original_scale = phase_label.scale
tween.tween_property(phase_label, "scale", original_scale * 1.2, 0.1)
tween.tween_property(phase_label, "scale", original_scale, 0.2)
# Flash effect
tween.tween_property(phase_label, "modulate", Color(2, 2, 2, 1), 0.1)
tween.tween_property(phase_label, "modulate", Color.WHITE, 0.2)
# =============================================================================
# GoalsCycleManager Integration
# =============================================================================
func _on_goal_count_updated(peer_id: int, count: int) -> void:
"""Called when a player completes a goal cycle. Grant ghost powerup every 2 missions."""
if not multiplayer.is_server():
return
# Track mission completions per player
if not player_mission_completions.has(peer_id):
player_mission_completions[peer_id] = 0
player_mission_completions[peer_id] += 1
# Grant ghost powerup every 2 missions
var completions = player_mission_completions[peer_id]
if completions % 2 == 0:
_grant_ghost_powerup(peer_id)
func _grant_ghost_powerup(peer_id: int) -> void:
"""Grant the ghost (invisible mode) powerup to a player."""
var all_players = get_tree().get_nodes_in_group("Players")
for p in all_players:
var pid = p.get("peer_id") if "peer_id" in p else p.name.to_int()
if pid == peer_id:
var stm = p.get_node_or_null("SpecialTilesManager")
if stm and stm.has_method("add_powerup_from_item"):
stm.add_powerup_from_item(14) # 14 = Ghost / INVISIBLE_MODE
emit_signal("ghost_granted", peer_id)
print("[Gauntlet] Player %d granted Ghost powerup (mission %d)" % [peer_id, player_mission_completions[peer_id]])
NotificationManager.send_message(p, "Ghost Power Earned!", NotificationManager.MessageType.POWERUP)
break
func _on_score_updated(peer_id: int, new_score: int) -> void:
"""Called when a player's score is updated."""
pass # Score sync handled by GoalsCycleManager
# =============================================================================
# Utility
# =============================================================================
func _can_rpc() -> bool:
if not multiplayer.has_multiplayer_peer(): return false
if multiplayer.multiplayer_peer.get_connection_status() != MultiplayerPeer.CONNECTION_CONNECTED: return false
return true
+9 -2
View File
@@ -13,11 +13,18 @@ func initialize_random_goals(size: int, min_value: int, max_value: int, null_cou
var rng = RandomNumberGenerator.new()
rng.randomize()
const SPECIAL_VALUES = {1: 7, 2: 8, 3: 9, 4: 10}
if LobbyManager.game_mode == "Candy Survival":
var val = rng.randi_range(min_value, max_value)
var chosen_tile = val if not val in SPECIAL_VALUES else SPECIAL_VALUES[val]
for i in range(size):
goals.append(chosen_tile)
return goals
var null_val = 0
var max_nulls = 3
const SPECIAL_VALUES = {1: 7, 2: 8, 3: 9, 4: 10}
for i in range(size):
if null_val < max_nulls and rng.randf() < null_count:
goals.append(-1)
+41 -41
View File
@@ -26,10 +26,10 @@ signal sng_go_duration_changed(duration: int)
signal sng_stop_duration_changed(duration: int)
signal sng_required_goals_changed(goals: int)
# Gauntlet settings signals
signal gauntlet_round_duration_changed(duration: int)
signal gauntlet_growth_interval_changed(interval: float)
signal gauntlet_cells_per_tick_changed(cells: Dictionary)
# Candy Survival settings signals
signal candy_survival_duration_changed(duration: int)
signal candy_survival_growth_interval_changed(interval: float)
signal candy_survival_cells_per_tick_changed(cells: Dictionary)
# Room data structure
var current_room: Dictionary = {}
@@ -69,10 +69,10 @@ var sng_go_duration: int = 20
var sng_stop_duration: int = 4
var sng_required_goals: int = 8
# Gauntlet settings
var gauntlet_round_duration: int = 180
var gauntlet_growth_interval: float = 3.0 # seconds between growth ticks
var gauntlet_cells_per_tick: Dictionary = {
# Candy Survival settings
var candy_survival_round_duration: int = 180
var candy_survival_growth_interval: float = 3.0 # seconds between growth ticks
var candy_survival_cells_per_tick: Dictionary = {
"phase1": [4, 6],
"phase2": [6, 8],
"phase3": [8, 10],
@@ -84,7 +84,7 @@ var rematch_votes: Array = [] # [player_id, ...]
# Character and area selection
var available_characters: Array[String] = ["Copper", "Dabro", "Gatot", "Pip", "Random"]
var available_areas: Array[String] = []
var available_game_modes: Array[String] = ["Freemode", "Stop n Go", "Candy Pump Survival"]
var available_game_modes: Array[String] = ["Freemode", "Stop n Go", "Candy Survival"]
var selected_area: String = "Freemode Arena" # Host-controlled
var game_mode: String = "Freemode" # Host-controlled
var local_character_index: int = 0 # Local player's character index
@@ -139,8 +139,8 @@ func _update_available_areas(mode: String) -> void:
available_areas = ["Freemode Arena", "Classic", "Colloseum"]
"Stop n Go":
available_areas = ["Stop N Go Arena"]
"Candy Pump Survival":
available_areas = ["Gauntlet Arena"]
"Candy Survival":
available_areas = ["Candy Survival Arena"]
_:
available_areas = ["Classic"]
@@ -513,35 +513,35 @@ func sync_sng_required_goals(goals: int) -> void:
emit_signal("sng_required_goals_changed", goals)
# =============================================================================
# Gauntlet Settings
# Candy Survival Settings
# =============================================================================
func set_gauntlet_round_duration(duration: int) -> void:
gauntlet_round_duration = duration
if is_host: rpc("sync_gauntlet_round_duration", duration)
func set_candy_survival_round_duration(duration: int) -> void:
candy_survival_round_duration = duration
if is_host: rpc("sync_candy_survival_round_duration", duration)
@rpc("authority", "call_local", "reliable")
func sync_gauntlet_round_duration(duration: int) -> void:
gauntlet_round_duration = duration
emit_signal("gauntlet_round_duration_changed", duration)
func sync_candy_survival_round_duration(duration: int) -> void:
candy_survival_round_duration = duration
emit_signal("candy_survival_duration_changed", duration)
func set_gauntlet_growth_interval(interval: float) -> void:
gauntlet_growth_interval = interval
if is_host: rpc("sync_gauntlet_growth_interval", interval)
func set_candy_survival_growth_interval(interval: float) -> void:
candy_survival_growth_interval = interval
if is_host: rpc("sync_candy_survival_growth_interval", interval)
@rpc("authority", "call_local", "reliable")
func sync_gauntlet_growth_interval(interval: float) -> void:
gauntlet_growth_interval = interval
emit_signal("gauntlet_growth_interval_changed", interval)
func sync_candy_survival_growth_interval(interval: float) -> void:
candy_survival_growth_interval = interval
emit_signal("candy_survival_growth_interval_changed", interval)
func set_gauntlet_cells_per_tick(cells: Dictionary) -> void:
gauntlet_cells_per_tick = cells
if is_host: rpc("sync_gauntlet_cells_per_tick", cells)
func set_candy_survival_cells_per_tick(cells: Dictionary) -> void:
candy_survival_cells_per_tick = cells
if is_host: rpc("sync_candy_survival_cells_per_tick", cells)
@rpc("authority", "call_local", "reliable")
func sync_gauntlet_cells_per_tick(cells: Dictionary) -> void:
gauntlet_cells_per_tick = cells
emit_signal("gauntlet_cells_per_tick_changed", cells)
func sync_candy_survival_cells_per_tick(cells: Dictionary) -> void:
candy_survival_cells_per_tick = cells
emit_signal("candy_survival_cells_per_tick_changed", cells)
# =============================================================================
# Character Selection
@@ -699,8 +699,8 @@ func set_game_mode(mode: String) -> void:
set_area("Free Mode Area")
elif mode == "Stop n Go" and "Stop n Go Area" in available_areas:
set_area("Stop n Go Area")
elif mode == "Candy Pump Survival" and "Gauntlet Arena" in available_areas:
set_area("Gauntlet Arena")
elif mode == "Candy Survival" and "Candy Survival Arena" in available_areas:
set_area("Candy Survival Arena")
@rpc("authority", "call_local", "reliable")
func sync_game_mode(mode: String) -> void:
@@ -713,8 +713,8 @@ func sync_game_mode(mode: String) -> void:
selected_area = "Free Mode Area"
elif mode == "Stop n Go" and "Stop n Go Area" in available_areas:
selected_area = "Stop n Go Area"
elif mode == "Candy Pump Survival" and "Gauntlet Arena" in available_areas:
selected_area = "Gauntlet Arena"
elif mode == "Candy Survival" and "Candy Survival Arena" in available_areas:
selected_area = "Candy Survival Arena"
elif selected_area not in available_areas:
selected_area = available_areas[0]
@@ -740,10 +740,10 @@ func start_game(force: bool = false) -> void:
rpc("sync_sng_go_duration", sng_go_duration)
rpc("sync_sng_stop_duration", sng_stop_duration)
rpc("sync_sng_required_goals", sng_required_goals)
# Sync gauntlet settings
rpc("sync_gauntlet_round_duration", gauntlet_round_duration)
rpc("sync_gauntlet_growth_interval", gauntlet_growth_interval)
rpc("sync_gauntlet_cells_per_tick", gauntlet_cells_per_tick)
# Sync Candy Survival settings
rpc("sync_candy_survival_round_duration", candy_survival_round_duration)
rpc("sync_candy_survival_growth_interval", candy_survival_growth_interval)
rpc("sync_candy_survival_cells_per_tick", candy_survival_cells_per_tick)
# Sync game mode
rpc("sync_game_mode", game_mode)
@@ -816,9 +816,9 @@ func request_room_info(requester_id: int, requester_name: String, requester_char
rpc_id(requester_id, "sync_sng_go_duration", sng_go_duration)
rpc_id(requester_id, "sync_sng_stop_duration", sng_stop_duration)
rpc_id(requester_id, "sync_sng_required_goals", sng_required_goals)
rpc_id(requester_id, "sync_gauntlet_round_duration", gauntlet_round_duration)
rpc_id(requester_id, "sync_gauntlet_growth_interval", gauntlet_growth_interval)
rpc_id(requester_id, "sync_gauntlet_cells_per_tick", gauntlet_cells_per_tick)
rpc_id(requester_id, "sync_candy_survival_round_duration", candy_survival_round_duration)
rpc_id(requester_id, "sync_candy_survival_growth_interval", candy_survival_growth_interval)
rpc_id(requester_id, "sync_candy_survival_cells_per_tick", candy_survival_cells_per_tick)
rpc_id(requester_id, "sync_game_mode", game_mode)
rpc_id(requester_id, "sync_area", selected_area)
+31
View File
@@ -101,6 +101,26 @@ func handle_unhandled_input(event):
# 2. Action Buttons (Remappable via InputMap)
if event.is_action_pressed("action_knock_tekton"):
if LobbyManager.game_mode == "Candy Survival":
var gm = player.get_node_or_null("/root/Main/CandySurvivalManager")
if gm and gm.is_active:
# Find a target to knock (first adjacent player)
var p_pos = player.current_position
var all_players = get_tree().get_nodes_in_group("Players")
for other in all_players:
if other == player: continue
var other_pos = other.current_position
if abs(p_pos.x - other_pos.x) + abs(p_pos.y - other_pos.y) == 1:
# Adjacent
var att_id = player.get("peer_id") if "peer_id" in player else player.name.to_int()
var tgt_id = other.get("peer_id") if "peer_id" in other else other.name.to_int()
if multiplayer.is_server():
gm.try_knock(att_id, tgt_id)
else:
gm.rpc_id(1, "try_knock", att_id, tgt_id)
get_viewport().set_input_as_handled()
return
if player.powerup_manager:
player.powerup_manager.use_special_effect()
if player.get("is_attack_mode") and player.has_method("enter_attack_mode"):
@@ -108,6 +128,17 @@ func handle_unhandled_input(event):
get_viewport().set_input_as_handled()
elif event.is_action_pressed("action_grab_tekton"):
if LobbyManager.game_mode == "Candy Survival":
var gm = player.get_node_or_null("/root/Main/CandySurvivalManager")
if gm and gm.is_active:
var pid = player.get("peer_id") if "peer_id" in player else player.name.to_int()
if multiplayer.is_server():
gm.try_activate_ghost(pid)
else:
gm.rpc_id(1, "try_activate_ghost", pid)
get_viewport().set_input_as_handled()
return
if not player.is_carrying_tekton:
if player.powerup_manager and player.powerup_manager.has_method("can_use_special"):
player.grab_tekton()
+51 -58
View File
@@ -112,19 +112,19 @@ func simple_move_to(grid_position: Vector2i) -> bool:
print("[MovementManager] Hard block at %s. Ghost pass denied." % grid_position)
var gm = null
var main_gauntlet = player.get_tree().root.get_node_or_null("Main")
if main_gauntlet and main_gauntlet.get("gauntlet_manager"):
gm = main_gauntlet.gauntlet_manager
var main_candy_survival = player.get_tree().root.get_node_or_null("Main")
if main_candy_survival and main_candy_survival.get("candy_survival_manager"):
gm = main_candy_survival.candy_survival_manager
# Check Floor 0 (Basic Walkability/Void)
if (cell_floor == -1 or cell_floor in enhanced_gridmap.non_walkable_items) and not is_wall_passable:
print("[Move] Failed: Floor Item %d is non-walkable" % cell_floor)
return false
# Gauntlet Mode explicit wall overrides (since we visually removed the wall blocks)
if gm and gm.is_active:
# Candy Survival explicit wall overrides (since we visually removed the wall blocks)
if gm and gm.active:
if gm._is_npc_zone(grid_position):
print("[Move] Failed: Blocked by Gauntlet NPC center at %s" % grid_position)
print("[Move] Failed: Blocked by Candy Survival NPC center at %s" % grid_position)
return false
# Check Floor 1 (Obstacles/Walls)
@@ -156,14 +156,23 @@ func simple_move_to(grid_position: Vector2i) -> bool:
return false # Don't move into the tile, just knock
# If moving into a sticky cell: block movement unless player is in ghost
# mode (is_invisible), which lets them bypass sticky tiles in gauntlet.
# mode (is_invisible), which lets them bypass sticky tiles in Candy Survival
if gm and gm.is_active and gm.is_sticky_cell(grid_position):
if player.get("is_invisible"):
# Ghost mode: walk through sticky tile freely
print("[Move] Ghost mode bypassed sticky cell at %s" % grid_position)
else:
print("[Move] Failed: Blocked by Gauntlet Sticky cell at %s" % grid_position)
print("[Move] Failed: Blocked by Candy Survival Sticky cell at %s" % grid_position)
return false
if gm and gm.is_active and gm.has_method("try_deliver"):
var dist = abs(grid_position.x - 8) + abs(grid_position.y - 8)
if dist <= 2:
var pid = player.get("peer_id") if "peer_id" in player else player.name.to_int()
if multiplayer.is_server():
gm.try_deliver(pid)
else:
gm.rpc_id(1, "try_deliver", pid)
rotate_towards_target(grid_position)
@@ -208,15 +217,16 @@ func try_push(target_pos: Vector2i, direction: Vector2i) -> bool:
NotificationManager.send_message(player, "Target is Immune!", NotificationManager.MessageType.WARNING)
return false
# === NEW LOGIC: Only allow push if in ATTACK MODE and NOT GHOST ===
var has_smack = false
var main_for_smack = player.get_tree().root.get_node_or_null("Main")
var gm_for_smack = main_for_smack.get("gauntlet_manager") if main_for_smack else null
if gm_for_smack and gm_for_smack.is_active:
# Candy Survival: check if attacker has knock charges
var has_knock = false
var main_for_knock = player.get_tree().root.get_node_or_null("Main")
var gm_for_knock = main_for_knock.get("candy_survival_manager") if main_for_knock else null
if gm_for_knock and gm_for_knock.is_active:
var att_pid = player.get("peer_id") if "peer_id" in player else player.name.to_int()
has_smack = gm_for_smack.has_smack_charged(att_pid)
var charges = gm_for_knock.player_knocks.get(att_pid, 0) if gm_for_knock.player_knocks else 0
has_knock = charges > 0
if (not player.get("is_charged_strike") and not has_smack) or player.get("is_invisible"):
if (not player.get("is_charged_strike") and not has_knock) or player.get("is_invisible"):
# Standard bumping effect (Visual only)
print("[Move] Push blocked: Not charged or is Ghost (%s trying to push %s)" % [player.name, other_player.name])
if _can_rpc():
@@ -243,47 +253,20 @@ func try_push(target_pos: Vector2i, direction: Vector2i) -> bool:
var gm = null
var main_push_check = player.get_tree().root.get_node_or_null("Main")
if main_push_check and main_push_check.get("gauntlet_manager"):
gm = main_push_check.gauntlet_manager
if main_push_check and main_push_check.get("candy_survival_manager"):
gm = main_push_check.candy_survival_manager
# IF Gauntlet Mode is active, handle special Gauntlet Smacks
if gm and gm.is_active:
# Candy Survival: knock mechanic (candy-steal or backfire)
if gm and gm.is_active and gm.has_method("try_knock"):
var pid = player.get("peer_id") if "peer_id" in player else player.name.to_int()
var other_pid = other_player.get("peer_id") if "peer_id" in other_player else other_player.name.to_int()
# Check if attacker has smack
if not gm.has_smack_charged(pid):
# bump visuals
if _can_rpc():
player.rpc("sync_bump", target_pos, true)
elif player.has_method("sync_bump"):
player.sync_bump(target_pos, true)
return false
# Smack Clash: Both charged
if gm.has_smack_charged(other_pid):
print("[Move] SMACK CLASH! Both %s and %s consumed." % [player.name, other_player.name])
if multiplayer.is_server():
gm.consume_smack(pid)
gm.consume_smack(other_pid)
elif _can_rpc():
gm.rpc("consume_smack", pid) # Assuming consume_smack is @rpc
gm.rpc("consume_smack", other_pid)
if _can_rpc():
player.rpc("apply_stagger", 1.0)
other_player.rpc("apply_stagger", 1.0)
else:
player.apply_stagger(1.0)
other_player.apply_stagger(1.0)
return false
# Else standard push
if multiplayer.is_server():
gm.consume_smack(pid)
elif _can_rpc():
gm.rpc("consume_smack", pid)
if gm.try_knock(pid, other_pid):
print("[CandySurvival] Player %d knocked %d, stole candies!" % [pid, other_pid])
else:
print("[CandySurvival] Player %d tried to knock %d (backfire or no charges)" % [pid, other_pid])
if _can_rpc():
player.rpc("sync_bump", target_pos, false)
return false
# === SUPER PUSH (Attack Mode) ===
print("Player %s SUPER PUSHING %s!" % [player.name, other_player.name])
@@ -300,7 +283,7 @@ func try_push(target_pos: Vector2i, direction: Vector2i) -> bool:
var push_direction = Vector2i(-1, 0) # Default back (Stop N Go)
var main_push = player.get_tree().root.get_node_or_null("Main")
var gm_push = main_push.gauntlet_manager if main_push and main_push.has_node("GauntletManager") else (main_push.get("gauntlet_manager") if main_push else null)
var gm_push = main_push.candy_survival_manager if main_push and main_push.has_node("CandySurvivalManager") else (main_push.get("candy_survival_manager") if main_push else null)
if gm_push and gm_push.is_active:
push_direction = direction # Use the direction of the attack
var pushed_to_pos = target_pos
@@ -335,8 +318,8 @@ func try_push(target_pos: Vector2i, direction: Vector2i) -> bool:
# Check if landing spot is sticky
var main_sticky = player.get_tree().root.get_node_or_null("Main")
if main_sticky and main_sticky.get("gauntlet_manager"):
var gm_sticky = main_sticky.gauntlet_manager
if main_sticky and main_sticky.get("candy_survival_manager"):
var gm_sticky = main_sticky.candy_survival_manager
if gm_sticky.is_active and gm_sticky.is_sticky_cell(pushed_to_pos):
if other_player.get("is_invisible"):
# Ghost mode: pushed player bypasses sticky
@@ -390,9 +373,18 @@ func set_speed_multiplier(multiplier: float):
# likely uses a fixed speed or duration on all clients.
# Let's check how 'start_movement_along_path' is implemented in player.gd.
# Handle goal pickups (shared logic)
# ... (This happens after the move is completed, or during the move)
pass
func _on_movement_finished():
# Auto-pickup logic for Candy Survival
if LobbyManager.game_mode == "Candy Survival":
if player.has_method("grab_item"):
# Check if there is an item at current_position and if the board has space
if player.playerboard_manager and player.playerboard_manager.has_empty_slot():
player.grab_item(player.current_position)
if not movement_queue.is_empty():
var next_target = movement_queue.pop_front()
# Use a small delay or call_deferred to avoid recursion issues,
@@ -403,6 +395,7 @@ func _on_movement_finished():
current_move_direction = Vector2i.ZERO
emit_signal("movement_finished")
else:
is_moving = false
current_move_direction = Vector2i.ZERO
emit_signal("movement_finished")
+48 -3
View File
@@ -733,11 +733,56 @@ func _check_goal_completion():
if not player.race_manager:
return
# Check if the pattern matches
if player.race_manager.check_pattern_match():
var is_match = false
var is_off_color = false
var primary_color = -1
if LobbyManager.game_mode == "Candy Survival":
# Custom Candy Survival blueprint check (can be off-color)
var main = player.get_tree().get_root().get_node_or_null("Main")
var gm = main.get_node_or_null("CandySurvivalManager") if main else null
# Find any 3x3 block that is completely filled with tiles (no -1)
for start_row in range(3):
for start_col in range(3):
var filled = true
var dominant_colors = {}
for i in range(3):
for j in range(3):
var val = player.playerboard[(start_row + i) * 5 + (start_col + j)]
if val == -1:
filled = false
else:
dominant_colors[val] = dominant_colors.get(val, 0) + 1
if filled:
is_match = true
# Find majority color
var max_count = 0
for c in dominant_colors:
if dominant_colors[c] > max_count:
max_count = dominant_colors[c]
primary_color = c
is_off_color = (max_count < 9)
if is_off_color and gm and gm.has_method("can_finish_with_off_color"):
if not gm.can_finish_with_off_color(player.name.to_int(), primary_color):
is_match = false # Reject if primary color is still available on grid
if is_match:
break
if is_match:
break
if is_match and gm and gm.has_method("on_blueprint_completed"):
gm.on_blueprint_completed(player.name.to_int(), primary_color, is_off_color)
else:
is_match = player.race_manager.check_pattern_match()
if is_match:
print("[PlayerboardManager] Goal completed for player %s!" % player.name)
# Level up boost difficulty on goal completion
var powerup_manager = player.get_node_or_null("PowerUpManager")
if powerup_manager:
powerup_manager.add_goal_completion_reward()
+3 -3
View File
@@ -546,8 +546,8 @@ func spawn_powerups_around(center: Vector2i, force_powerups: bool = true, only_c
if only_common or LobbyManager.is_game_mode(GameMode.Mode.STOP_N_GO):
# Spawn ONLY common tiles (7-10) in Stop n Go mode (User Request)
item_id = rng.randi_range(7, 10)
elif LobbyManager.is_game_mode(GameMode.Mode.GAUNTLET):
# Gauntlet mode: mostly common tiles, but ghost (14) can spawn too.
elif LobbyManager.is_game_mode(GameMode.Mode.CANDY_SURVIVAL):
# Candy Survival mode: mostly common tiles, but ghost (14) can spawn too.
if rng.randf() < 0.85:
item_id = rng.randi_range(7, 10)
else:
@@ -558,7 +558,7 @@ func spawn_powerups_around(center: Vector2i, force_powerups: bool = true, only_c
item_id = rng.randi_range(7, 10)
else:
# 20% Chance for PowerUp
item_id = rng.randi_range(11, 14)
item_id = rng.randi_range(11, 14)
var cell = Vector3i(pos.x, 1, pos.y)
+3 -3
View File
@@ -18,10 +18,10 @@ const SCHEMA = {
"sng_stop_duration": {"type": TYPE_INT, "default": 4, "min": 2, "max": 10},
"sng_required_goals": {"type": TYPE_INT, "default": 8, "min": 3, "max": 20}
},
"Candy Pump Survival": {
"Candy Survival": {
"match_duration": {"type": TYPE_INT, "default": 180, "min": 60, "max": 600},
"gauntlet_growth_interval": {"type": TYPE_FLOAT, "default": 3.0, "min": 1.0, "max": 10.0},
"gauntlet_cells_per_tick": {"type": TYPE_DICTIONARY, "default": {"phase1": [4, 6], "phase2": [6, 8], "phase3": [8, 10]}}
"candy_survival_growth_interval": {"type": TYPE_FLOAT, "default": 3.0, "min": 1.0, "max": 10.0},
"candy_survival_cells_per_tick": {"type": TYPE_DICTIONARY, "default": {"phase1": [4, 6], "phase2": [6, 8], "phase3": [8, 10]}}
}
}
+2 -2
View File
@@ -505,8 +505,8 @@ func spawn_tiles_around(count: int = 4):
if roll < 0.6 or (LobbyManager and LobbyManager.game_mode == "Stop n Go"):
# 60% Normal Tile (7-10) OR 100% if Stop n Go (User Request)
item_id = rng.randi_range(7, 10)
elif LobbyManager and LobbyManager.get_game_mode() == GameMode.Mode.GAUNTLET:
# Gauntlet mode: No power-up spawns from Tekton grabs
elif LobbyManager and LobbyManager.get_game_mode() == GameMode.Mode.CANDY_SURVIVAL:
# Candy Survival mode: No power-up spawns from Tekton grabs
item_id = rng.randi_range(7, 10)
else:
# 40% PowerUp (11-14)
+1 -1
View File
@@ -1,4 +1,4 @@
extends SceneTree
func _init():
print("Testing gauntlet multiplayer")
print("Testing candy_survival multiplayer")
quit()
+1 -1
View File
@@ -1,6 +1,6 @@
extends Node
# Minimal EnhancedGridMap stand-in for Gauntlet headless tests. Records
# Minimal EnhancedGridMap stand-in for Candy Survival headless tests. Records
# set_cell_item calls so lifecycle tests can run the local sync path without a
# real GridMap. Only the surface the manager touches is implemented.
+2 -2
View File
@@ -1,7 +1,7 @@
extends Node
# Minimal "Main" stand-in for Gauntlet headless tests. Provides the RPC methods
# the GauntletManager calls on its main_scene so calls resolve without the full
# Minimal "Main" stand-in for Candy Survival headless tests. Provides the RPC methods
# the CandySurvivalManager calls on its main_scene so calls resolve without the full
# game scene. Methods are no-ops that just need to exist + be rpc-tagged.
@rpc("any_peer", "call_local", "reliable")
+37 -207
View File
@@ -1,13 +1,11 @@
extends GutTest
# =============================================================================
# Test: Bot AI — Sticky Avoidance & Pathfinding [Gauntlet #075]
# Test: Bot AI — Sticky Avoidance & Pathfinding [Candy Survival]
# Verifies the bot's strategic planner correctly:
# • Detects Gauntlet mode and exposes helpers.
# • Detects Candy Survival mode and exposes helpers.
# • Rejects sticky / telegraphed cells in _is_valid_move_target.
# • Activates Cleanser when boxed in or standing on telegraphed ground.
# • Honours an active Cleanser (treats sticky cells as passable).
# • Calls rpc_activate_cleanser on the GauntletManager when triggered.
# • Uses CandySurvivalManager.is_sticky_cell() authority.
# =============================================================================
const BotStrategicPlanner = preload("res://scripts/bot_strategic_planner.gd")
@@ -26,34 +24,21 @@ class StubActor extends Node3D:
func is_position_occupied(_p: Vector2i) -> bool:
return false
class StubGauntletManager extends Node:
# Mimics the slice of GauntletManager API the bot planner depends on.
var sticky_map: Dictionary = {} # Vector2i -> true
var player_cleansers: Dictionary = {} # peer_id -> int
var cleanser_active: Dictionary = {} # peer_id -> true
var activate_rpc_calls: Array = [] # recorded [peer_id]
class StubCandySurvivalManager extends Node:
var sticky_map: Dictionary = {}
func is_sticky_cell(pos: Vector2i) -> bool:
return sticky_map.get(pos, false)
func is_cleanser_active(pid: int) -> bool:
return cleanser_active.get(pid, false)
func rpc_activate_cleanser(pid: int) -> void:
activate_rpc_calls.append(pid)
# ---- Test fixture -----------------------------------------------------------
var main_node: Node
var gridmap: Node
var gauntlet_manager: StubGauntletManager
var candy_survival_manager: StubCandySurvivalManager
var actor: StubActor
var planner: RefCounted
func before_each():
main_node = Node.new()
# Unique name per test to avoid collisions with previous runs that haven't
# been fully freed yet.
main_node.name = "BotTestMain_%d" % Time.get_ticks_usec()
get_tree().get_root().add_child(main_node)
@@ -61,16 +46,14 @@ func before_each():
gridmap.name = "EnhancedGridMap"
var nwi: Array[int] = [4]
gridmap.non_walkable_items = nwi
# Pre-seed Floor 0 with a walkable tile (id 1) for every cell, so the bot's
# `_is_valid_move_target` Floor 0 check passes by default.
for x in range(20):
for z in range(20):
gridmap.set_cell_item(Vector3i(x, 0, z), 1)
main_node.add_child(gridmap)
gauntlet_manager = StubGauntletManager.new()
gauntlet_manager.name = "GauntletManager"
main_node.add_child(gauntlet_manager)
candy_survival_manager = StubCandySurvivalManager.new()
candy_survival_manager.name = "CandySurvivalManager"
main_node.add_child(candy_survival_manager)
actor = StubActor.new()
actor.enhanced_gridmap = gridmap
@@ -78,38 +61,36 @@ func before_each():
main_node.add_child(actor)
planner = BotStrategicPlanner.new(actor, gridmap)
planner.gauntlet_manager_override = gauntlet_manager
planner.candy_survival_manager_override = candy_survival_manager
# Default to Gauntlet mode for these tests.
LobbyManager.game_mode = "Candy Pump Survival"
LobbyManager.game_mode = "Candy Survival"
func after_each():
if is_instance_valid(main_node):
main_node.queue_free()
actor = null
planner = null
gauntlet_manager = null
candy_survival_manager = null
gridmap = null
# Reset lobby mode so other tests aren't affected.
LobbyManager.game_mode = "Freemode"
# =============================================================================
# Mode detection
# =============================================================================
func test_is_gauntlet_mode_true_when_set():
assert_true(planner.is_gauntlet_mode(), "Detects Gauntlet via LobbyManager")
func test_is_candy_survival_mode_true_when_set():
assert_true(planner.is_candy_survival_mode(), "Detects Candy Survival via LobbyManager")
func test_is_gauntlet_mode_false_in_other_modes():
func test_is_candy_survival_mode_false_in_other_modes():
LobbyManager.game_mode = "Stop n Go"
assert_false(planner.is_gauntlet_mode(), "Stop n Go is not Gauntlet")
assert_false(planner.is_candy_survival_mode(), "Stop n Go is not Candy Survival")
LobbyManager.game_mode = "Freemode"
assert_false(planner.is_gauntlet_mode(), "Freemode is not Gauntlet")
assert_false(planner.is_candy_survival_mode(), "Freemode is not Candy Survival")
func test_get_gauntlet_manager_resolves_from_main():
var gm = planner._get_gauntlet_manager()
assert_not_null(gm, "Resolves GauntletManager under /root/Main")
assert_eq(gm, gauntlet_manager, "Same instance as the one we added")
func test_get_candy_survival_manager_resolves_from_main():
var gm = planner._get_candy_survival_manager()
assert_not_null(gm, "Resolves CandySurvivalManager under /root/Main")
assert_eq(gm, candy_survival_manager, "Same instance as the one we added")
# =============================================================================
# Overlay detection
@@ -117,75 +98,61 @@ func test_get_gauntlet_manager_resolves_from_main():
func test_overlay_unsafe_false_on_empty_layer2():
assert_false(planner._is_overlay_unsafe(Vector2i(3, 3)),
"Empty layer 2 safe")
"Empty layer 2 -> safe")
func test_overlay_unsafe_true_for_sticky_tile():
gridmap.set_cell_item(Vector3i(3, 2, 3), 17) # TILE_STICKY
gridmap.set_cell_item(Vector3i(3, 2, 3), 17)
assert_true(planner._is_overlay_unsafe(Vector2i(3, 3)),
"Sticky overlay is unsafe")
func test_overlay_unsafe_true_for_telegraph_tile():
gridmap.set_cell_item(Vector3i(4, 2, 4), 18) # TILE_TELEGRAPH
gridmap.set_cell_item(Vector3i(4, 2, 4), 18)
assert_true(planner._is_overlay_unsafe(Vector2i(4, 4)),
"Telegraph overlay is unsafe")
func test_overlay_unsafe_ignores_layer0_and_layer1():
# Sticky value on the wrong layer should NOT be flagged as unsafe.
gridmap.set_cell_item(Vector3i(3, 0, 3), 17)
gridmap.set_cell_item(Vector3i(3, 1, 3), 17)
assert_false(planner._is_overlay_unsafe(Vector2i(3, 3)),
"Only layer 2 overlay matters for Gauntlet safety")
"Only layer 2 overlay matters for Candy Survival safety")
# =============================================================================
# _is_valid_move_target integration
# =============================================================================
func test_valid_move_target_rejects_sticky_in_gauntlet():
# Make a sticky cell pass all other checks (valid position, walkable floor).
func test_valid_move_target_rejects_sticky_in_candy_survival():
gridmap.set_cell_item(Vector3i(3, 2, 3), 17)
assert_false(planner._is_valid_move_target(Vector2i(3, 3)),
"Sticky cell rejected in Gauntlet mode")
"Sticky cell rejected in Candy Survival mode")
func test_valid_move_target_rejects_telegraphed_in_gauntlet():
func test_valid_move_target_rejects_telegraphed_in_candy_survival():
gridmap.set_cell_item(Vector3i(5, 2, 5), 18)
assert_false(planner._is_valid_move_target(Vector2i(5, 5)),
"Telegraphed cell rejected in Gauntlet mode")
"Telegraphed cell rejected in Candy Survival mode")
func test_valid_move_target_accepts_clean_cells():
assert_true(planner._is_valid_move_target(Vector2i(8, 8)),
"Clean cell accepted")
func test_valid_move_target_ignores_players_when_requested():
# Even a sticky cell is bypassed when ignore_players path skips safety.
gridmap.set_cell_item(Vector3i(3, 2, 3), 17)
# ignore_players=true is used by find_nearest_tile_of_type for tile pickup;
# safety must still apply, so this should still be rejected.
assert_false(planner._is_valid_move_target(Vector2i(3, 3), true),
"Safety check still active with ignore_players=true")
func test_valid_move_target_outside_gauntlet_allows_sticky():
# Outside Gauntlet, layer-2 sticky overlays are not safety-relevant.
func test_valid_move_target_outside_candy_survival_allows_sticky():
LobbyManager.game_mode = "Freemode"
gridmap.set_cell_item(Vector3i(3, 2, 3), 17)
assert_true(planner._is_valid_move_target(Vector2i(3, 3)),
"Sticky overlay ignored in non-Gauntlet modes")
func test_valid_move_target_allows_sticky_when_cleanser_active():
gauntlet_manager.cleanser_active[actor.peer_id] = true
gridmap.set_cell_item(Vector3i(3, 2, 3), 17)
assert_true(planner._is_valid_move_target(Vector2i(3, 3)),
"Active Cleanser grants temporary immunity")
"Sticky overlay ignored in non-Candy Survival modes")
# =============================================================================
# Sticky-cell awareness via GauntletManager authority
# Sticky-cell awareness via CandySurvivalManager authority
# =============================================================================
func test_valid_move_target_uses_gauntlet_manager_sticky_map():
# Even if the gridmap overlay hasn't landed yet (RPC in flight), the
# GauntletManager's authoritative sticky_cells map must block the move.
gauntlet_manager.sticky_map[Vector2i(7, 7)] = true
func test_valid_move_target_uses_candy_survival_manager_sticky_map():
candy_survival_manager.sticky_map[Vector2i(7, 7)] = true
assert_false(planner._is_valid_move_target(Vector2i(7, 7)),
"Manager's sticky map blocks moves before overlay tiles land")
"Manager's sticky map blocks moves")
# =============================================================================
# _count_unsafe_neighbors
@@ -203,144 +170,7 @@ func test_count_unsafe_neighbors_four_when_surrounded():
"All four neighbors sticky")
func test_count_unsafe_neighbors_partial_box():
gridmap.set_cell_item(Vector3i(6, 2, 5), 17) # east
gridmap.set_cell_item(Vector3i(5, 2, 6), 17) # south
gridmap.set_cell_item(Vector3i(6, 2, 5), 17)
gridmap.set_cell_item(Vector3i(5, 2, 6), 17)
assert_eq(planner._count_unsafe_neighbors(Vector2i(5, 5)), 2,
"Two unsafe neighbors")
# =============================================================================
# should_activate_cleanser_now
# =============================================================================
func test_should_activate_cleanser_false_without_charge():
actor.current_position = Vector2i(5, 5)
for d in [Vector2i(1, 0), Vector2i(-1, 0), Vector2i(0, 1), Vector2i(0, -1)]:
var n = Vector2i(5, 5) + d
gridmap.set_cell_item(Vector3i(n.x, 2, n.y), 17)
assert_false(planner.should_activate_cleanser_now(),
"Trapped but no charge → cannot activate")
func test_should_activate_cleanser_true_when_surrounded():
gauntlet_manager.player_cleansers[actor.peer_id] = 1
actor.current_position = Vector2i(5, 5)
for d in [Vector2i(1, 0), Vector2i(-1, 0), Vector2i(0, 1), Vector2i(0, -1)]:
var n = Vector2i(5, 5) + d
gridmap.set_cell_item(Vector3i(n.x, 2, n.y), 17)
assert_true(planner.should_activate_cleanser_now(),
"Trapped with charge → activate Cleanser")
func test_should_activate_cleanser_true_when_on_telegraphed():
gauntlet_manager.player_cleansers[actor.peer_id] = 1
actor.current_position = Vector2i(5, 5)
gridmap.set_cell_item(Vector3i(5, 2, 5), 18) # bot standing on telegraph
# 3+ unsafe neighbors required by spec; add three.
for d in [Vector2i(1, 0), Vector2i(-1, 0), Vector2i(0, 1)]:
var n = Vector2i(5, 5) + d
gridmap.set_cell_item(Vector3i(n.x, 2, n.y), 17)
assert_true(planner.should_activate_cleanser_now(),
"Standing on telegraph with 3 sticky neighbors → activate Cleanser")
func test_should_activate_cleanser_false_when_already_active():
gauntlet_manager.player_cleansers[actor.peer_id] = 1
gauntlet_manager.cleanser_active[actor.peer_id] = true
actor.current_position = Vector2i(5, 5)
for d in [Vector2i(1, 0), Vector2i(-1, 0), Vector2i(0, 1), Vector2i(0, -1)]:
var n = Vector2i(5, 5) + d
gridmap.set_cell_item(Vector3i(n.x, 2, n.y), 17)
assert_false(planner.should_activate_cleanser_now(),
"Already active → don't re-fire")
func test_should_activate_cleanser_false_outside_gauntlet():
LobbyManager.game_mode = "Stop n Go"
gauntlet_manager.player_cleansers[actor.peer_id] = 1
actor.current_position = Vector2i(5, 5)
for d in [Vector2i(1, 0), Vector2i(-1, 0), Vector2i(0, 1), Vector2i(0, -1)]:
var n = Vector2i(5, 5) + d
gridmap.set_cell_item(Vector3i(n.x, 2, n.y), 17)
assert_false(planner.should_activate_cleanser_now(),
"Outside Gauntlet → never auto-activate Cleanser")
func test_should_activate_cleanser_false_when_not_trapped():
gauntlet_manager.player_cleansers[actor.peer_id] = 1
actor.current_position = Vector2i(5, 5)
# No sticky neighbors, plenty of room.
assert_false(planner.should_activate_cleanser_now(),
"Open field → no reason to burn Cleanser")
# =============================================================================
# Cleanser charge helpers
# =============================================================================
func test_bot_has_cleanser_charge_false_when_empty():
assert_false(planner._bot_has_cleanser_charge(), "Empty by default")
func test_bot_has_cleanser_charge_true_when_granted():
gauntlet_manager.player_cleansers[actor.peer_id] = 1
assert_true(planner._bot_has_cleanser_charge(), "Charge granted")
func test_is_bot_cleanser_active_reflects_manager():
assert_false(planner._is_bot_cleanser_active(), "Inactive by default")
gauntlet_manager.cleanser_active[actor.peer_id] = true
assert_true(planner._is_bot_cleanser_active(), "Manager reports active")
# =============================================================================
# BotController → GauntletManager RPC integration
# =============================================================================
func test_bot_controller_requests_cleanser_when_trapped():
var BotController = load("res://scripts/bot_controller.gd")
var ctrl = BotController.new()
# Attach as a child of the actor so _ready() resolves get_parent() correctly.
actor.add_child(ctrl)
ctrl.strategic_planner = planner
ctrl.actor = actor
gauntlet_manager.player_cleansers[actor.peer_id] = 1
actor.current_position = Vector2i(5, 5)
for d in [Vector2i(1, 0), Vector2i(-1, 0), Vector2i(0, 1), Vector2i(0, -1)]:
var n = Vector2i(5, 5) + d
gridmap.set_cell_item(Vector3i(n.x, 2, n.y), 17)
var requested = ctrl._try_activate_cleanser()
assert_true(requested, "Controller requests Cleanser when trapped")
assert_eq(gauntlet_manager.activate_rpc_calls.size(), 1,
"RPC called exactly once")
assert_eq(gauntlet_manager.activate_rpc_calls[0], actor.peer_id,
"Correct peer id sent")
ctrl.queue_free()
func test_bot_controller_does_not_request_when_safe():
var BotController = load("res://scripts/bot_controller.gd")
var ctrl = BotController.new()
actor.add_child(ctrl)
ctrl.strategic_planner = planner
ctrl.actor = actor
gauntlet_manager.player_cleansers[actor.peer_id] = 1
# No sticky anywhere.
var requested = ctrl._try_activate_cleanser()
assert_false(requested, "No request when not trapped")
assert_eq(gauntlet_manager.activate_rpc_calls.size(), 0,
"No RPC fired")
ctrl.queue_free()
func test_bot_controller_skips_cleanser_outside_gauntlet():
var BotController = load("res://scripts/bot_controller.gd")
var ctrl = BotController.new()
actor.add_child(ctrl)
ctrl.strategic_planner = planner
ctrl.actor = actor
LobbyManager.game_mode = "Stop n Go"
gauntlet_manager.player_cleansers[actor.peer_id] = 1
actor.current_position = Vector2i(5, 5)
for d in [Vector2i(1, 0), Vector2i(-1, 0), Vector2i(0, 1), Vector2i(0, -1)]:
var n = Vector2i(5, 5) + d
gridmap.set_cell_item(Vector3i(n.x, 2, n.y), 17)
var requested = ctrl._try_activate_cleanser()
assert_false(requested, "No request outside Gauntlet")
ctrl.queue_free()
-163
View File
@@ -1,163 +0,0 @@
extends GutTest
# =============================================================================
# Test: Gauntlet Candy Bubble System (v2) [Gauntlet #082]
# Covers bubble-specific scoring components, phase budgets, anti-stacking,
# the 3x3 blast footprint, and the grow→explode lifecycle.
# Runs headless (no multiplayer peer): elapsed_time = 0 so the final-30s window
# is inactive unless a test sets it directly.
# =============================================================================
const GauntletManager = preload("res://scripts/managers/gauntlet_manager.gd")
const GridMapMock = preload("res://tests/helpers/gridmap_mock.gd")
var manager
var main_mock: Node
var gridmap_mock: Node
func before_each():
main_mock = Node.new()
add_child(main_mock)
gridmap_mock = GridMapMock.new()
gridmap_mock.name = "EnhancedGridMap"
main_mock.add_child(gridmap_mock)
manager = GauntletManager.new()
main_mock.add_child(manager)
manager.initialize(main_mock, gridmap_mock)
manager.current_phase = 0
func after_each():
if main_mock:
main_mock.queue_free()
# Run a callable with the multiplayer peer detached so manager code takes the
# local (non-rpc) sync path — deterministic for headless lifecycle tests.
func _without_peer(fn: Callable) -> void:
var saved = multiplayer.multiplayer_peer
multiplayer.multiplayer_peer = null
fn.call()
multiplayer.multiplayer_peer = saved
# =============================================================================
# Phase budget
# =============================================================================
func test_bubble_budget_per_phase():
manager.current_phase = 0
assert_eq(manager._bubble_budget_for_phase(), 0, "Phase 1 → 0 bubbles")
manager.current_phase = 1
assert_eq(manager._bubble_budget_for_phase(), 2, "Phase 2 → 2 bubbles")
manager.current_phase = 2
assert_eq(manager._bubble_budget_for_phase(), 3, "Phase 3 → 3 bubbles")
func test_phase_change_resets_counter():
manager.bubbles_this_phase = 2
manager._start_phase(manager.Phase.SURVIVAL_ENDGAME)
assert_eq(manager.bubbles_this_phase, 0, "Per-phase bubble count resets on phase change")
# =============================================================================
# Blast footprint (3x3, clipped)
# =============================================================================
func test_blast_is_3x3_in_open_area():
var cells = manager._bubble_blast_cells(Vector2i(14, 14))
assert_eq(cells.size(), 9, "Open-area bubble blast is 3x3 = 9 cells")
func test_blast_clips_npc_zone():
# Center adjacent to the NPC zone (9,9) clips blocked cells out.
var cells = manager._bubble_blast_cells(Vector2i(7, 9))
assert_true(cells.size() < 9, "Blast near NPC zone is clipped below 9")
for c in cells:
assert_false(manager._is_npc_zone(c), "No blast cell lands in NPC zone")
# =============================================================================
# Scoring components
# =============================================================================
func test_bubble_camping_thresholds():
var region: Vector2i = manager._region_of(Vector2i(8, 8))
manager._camp_tracking[1] = {"region": region, "time": 6.0}
assert_eq(manager._bubble_score_camping(Vector2i(8, 8)), 40.0, ">5s = +40")
manager._camp_tracking[1]["time"] = 9.0
assert_eq(manager._bubble_score_camping(Vector2i(8, 8)), 60.0, ">8s = +60")
func test_bubble_player_cluster():
var players = [Vector2i(5, 5), Vector2i(6, 6)]
assert_eq(manager._bubble_score_player_cluster(Vector2i(5, 6), players), 20.0, "2 nearby players = +20")
assert_eq(manager._bubble_score_player_cluster(Vector2i(15, 15), players), 0.0, "No nearby players = 0")
func test_bubble_direct_hit_penalty():
var players = [Vector2i(5, 5)]
assert_eq(manager._bubble_score_direct_hit(Vector2i(5, 5), players), -60.0, "Directly under player = -60")
assert_eq(manager._bubble_score_direct_hit(Vector2i(8, 8), players), 0.0, "Not under player = 0")
func test_bubble_recent_penalty():
manager.recent_bubble_positions = [Vector2i(14, 14)]
assert_eq(manager._bubble_score_recent(Vector2i(11, 11)), -50.0, "Near recent bubble = -50")
assert_eq(manager._bubble_score_recent(Vector2i(2, 2)), 0.0, "Far from recent bubble = 0")
func test_bubble_untouched_area():
# Open arena around (10,10) → large reachable region → +30.
assert_eq(manager._bubble_score_untouched_area(Vector2i(14, 14)), 30.0, "Large untouched area = +30")
func test_bubble_full_score_is_finite():
var s = manager._calculate_bubble_score(Vector2i(8, 8), [])
assert_true(is_finite(s), "Full bubble score is finite")
# =============================================================================
# Spawn lifecycle
# =============================================================================
func test_spawn_bubble_marks_growing_cells():
_without_peer(func():
manager._spawn_bubble(Vector2i(14, 14))
)
assert_eq(manager.bubbles_this_phase, 1, "Phase counter increments")
assert_eq(manager.bubbles_total, 1, "Round counter increments")
assert_eq(manager.active_bubbles.size(), 1, "One active bubble")
assert_true(manager.bubble_cells.has(Vector2i(14, 14)), "Center marked BUBBLE_GROWING")
assert_eq(manager.cell_state(Vector2i(14, 14)), manager.CellState.BUBBLE_GROWING, "cell_state reports BUBBLE_GROWING")
func test_spawn_bubble_records_recent_position():
_without_peer(func():
manager._spawn_bubble(Vector2i(14, 14))
)
assert_true(manager.recent_bubble_positions.has(Vector2i(14, 14)), "Center remembered for anti-stacking")
func test_recent_positions_capped():
_without_peer(func():
for i in range(manager.BUBBLE_RECENT_MEMORY + 3):
manager._spawn_bubble(Vector2i(2 + i, 15))
)
assert_eq(manager.recent_bubble_positions.size(), manager.BUBBLE_RECENT_MEMORY, "Recent memory capped")
# =============================================================================
# Explosion
# =============================================================================
func test_update_bubbles_explodes_after_grow_duration():
_without_peer(func():
manager._spawn_bubble(Vector2i(14, 14))
manager._update_bubbles(manager.BUBBLE_GROW_DURATION + 0.1)
)
assert_eq(manager.active_bubbles.size(), 0, "Bubble removed after exploding")
assert_true(manager.sticky_cells.has(Vector2i(14, 14)), "Center became sticky")
assert_false(manager.bubble_cells.has(Vector2i(14, 14)), "BUBBLE_GROWING cleared on explode")
func test_update_bubbles_waits_for_timer():
_without_peer(func():
manager._spawn_bubble(Vector2i(14, 14))
manager._update_bubbles(manager.BUBBLE_GROW_DURATION * 0.5)
)
assert_eq(manager.active_bubbles.size(), 1, "Bubble still growing before timer elapses")
assert_false(manager.sticky_cells.has(Vector2i(14, 14)), "No sticky yet mid-grow")
func test_explode_creates_3x3_sticky():
_without_peer(func():
manager._explode_bubble(Vector2i(14, 14), manager._bubble_blast_cells(Vector2i(14, 14)))
)
var sticky_in_blast := 0
for dx in range(-1, 2):
for dz in range(-1, 2):
if manager.sticky_cells.has(Vector2i(14 + dx, 14 + dz)):
sticky_in_blast += 1
assert_eq(sticky_in_blast, 9, "Explosion creates a full 3x3 sticky area")
-1
View File
@@ -1 +0,0 @@
uid://bkte51v8tyoii
-117
View File
@@ -1,117 +0,0 @@
extends GutTest
# =============================================================================
# Test: Gauntlet Cleanser Power-Up (v2) [Gauntlet #072]
# Covers grant cadence (every 2 missions, max 1), 5-cell immunity lifecycle,
# sticky clearing, stun-blocked activation, and the safe-stop early termination.
# Runs headless; uses a GridMap mock so clear_sticky_cell can run locally.
# =============================================================================
const GauntletManager = preload("res://scripts/managers/gauntlet_manager.gd")
const GridMapMock = preload("res://tests/helpers/gridmap_mock.gd")
const MainMock = preload("res://tests/helpers/main_mock.gd")
var manager
var main_mock: Node
var gridmap_mock: Node
func before_each():
main_mock = MainMock.new()
add_child(main_mock)
gridmap_mock = GridMapMock.new()
gridmap_mock.name = "EnhancedGridMap"
main_mock.add_child(gridmap_mock)
manager = GauntletManager.new()
main_mock.add_child(manager)
manager.initialize(main_mock, gridmap_mock)
manager.current_phase = 0
func after_each():
if main_mock:
main_mock.queue_free()
func _without_peer(fn: Callable) -> void:
var saved = multiplayer.multiplayer_peer
multiplayer.multiplayer_peer = null
fn.call()
multiplayer.multiplayer_peer = saved
# =============================================================================
# Grant cadence: every 2 missions, inventory max 1
# =============================================================================
func test_no_cleanser_after_one_mission():
manager._on_goal_count_updated(7, 1)
assert_eq(manager.player_cleansers.get(7, 0), 0, "No cleanser after 1 mission")
func test_cleanser_granted_after_two_missions():
manager._on_goal_count_updated(7, 1)
manager._on_goal_count_updated(7, 2)
assert_eq(manager.player_cleansers.get(7, 0), 1, "Cleanser granted after 2 missions")
func test_cleanser_inventory_capped_at_one():
# Four missions would be two grants. The new rule allows them to stack.
for i in range(4):
manager.player_mission_completions[7] = i + 1
manager._on_goal_count_updated(7, i + 1)
assert_eq(manager.player_cleansers.get(7, 0), 2, "Cleansers now stack")
# =============================================================================
# Activation / immunity lifecycle
# =============================================================================
func test_use_cleanser_cell_decrements_until_exhausted():
manager.cleanser_active[3] = true
manager.cleanser_cells_left[3] = manager.CLEANSER_MAX_CELLS
# First 4 uses keep it active...
for i in range(manager.CLEANSER_MAX_CELLS - 1):
assert_true(manager.use_cleanser_cell(3), "Still active on use %d" % (i + 1))
# ...the 5th use exhausts it.
assert_false(manager.use_cleanser_cell(3), "Exhausted after 5th cell")
assert_false(manager.is_cleanser_active(3), "Deactivated after 5th cell")
func test_use_cleanser_cell_when_inactive_returns_false():
assert_false(manager.use_cleanser_cell(99), "Inactive cleanser use returns false")
func test_deactivate_clears_state():
manager.cleanser_active[5] = true
manager.cleanser_cells_left[5] = 3
manager.deactivate_cleanser(5)
assert_false(manager.is_cleanser_active(5), "Deactivated")
assert_false(manager.cleanser_cells_left.has(5), "Cells-left cleared")
# =============================================================================
# Sticky clearing
# =============================================================================
func test_clear_sticky_cell_removes_and_protects():
manager.sticky_cells[Vector2i(4, 4)] = true
_without_peer(func():
manager.clear_sticky_cell(Vector2i(4, 4))
)
assert_false(manager.is_sticky_cell(Vector2i(4, 4)), "Sticky removed")
assert_true(manager.is_cleansed_cell(Vector2i(4, 4)), "Cleared cell gets regrowth protection")
# Layer-2 overlay cleared (mock records -1 = erased).
assert_eq(gridmap_mock.get_cell_item(Vector3i(4, 2, 4)), -1, "Layer-2 sticky overlay cleared")
# =============================================================================
# Safe-stop early termination (#072 acceptance: ends when stopping on safe cell)
# =============================================================================
func test_stop_on_safe_cell_keeps_cleanser():
manager.cleanser_active[8] = true
manager.cleanser_cells_left[8] = 3
manager.notify_movement_stopped(8, Vector2i(5, 5)) # safe cell
assert_true(manager.is_cleanser_active(8), "Cleanser NO LONGER ends on safe-cell stop (persists charges)")
func test_stop_on_sticky_cell_keeps_cleanser():
manager.sticky_cells[Vector2i(6, 6)] = true
manager.cleanser_active[8] = true
manager.cleanser_cells_left[8] = 3
manager.notify_movement_stopped(8, Vector2i(6, 6)) # still on sticky
assert_true(manager.is_cleanser_active(8), "Cleanser persists while still on sticky")
func test_notify_stop_noop_without_cleanser():
# Should not crash or change anything when the player has no cleanser.
manager.notify_movement_stopped(123, Vector2i(5, 5))
assert_false(manager.is_cleanser_active(123), "No cleanser → no-op")
-1
View File
@@ -1 +0,0 @@
uid://b1bay8n1h65u3
-190
View File
@@ -1,190 +0,0 @@
extends GutTest
# =============================================================================
# Test: Gauntlet Telegraph Floor Highlight [Gauntlet #081]
# Verifies the amber floor overlay placed under cells during the 1-second
# telegraph window: amber color, two-stage alpha (build-up → flash), lifetime
# bound to telegraph_duration, distinct from sticky pink, RPC broadcast.
# =============================================================================
const GauntletManager = preload("res://scripts/managers/gauntlet_manager.gd")
const GridMapMock = preload("res://tests/helpers/gridmap_mock.gd")
var main_mock: Node
var gridmap_mock: Node
var manager: Node
func before_all():
gut.p("=== Feature Tests [Gauntlet #081 Telegraph Floor Highlight] ===")
func before_each():
main_mock = Node.new()
main_mock.name = "Main"
# Add under /root so visual helpers that look up /root/Main find it.
get_tree().get_root().add_child(main_mock)
gridmap_mock = GridMapMock.new()
gridmap_mock.name = "EnhancedGridMap"
main_mock.add_child(gridmap_mock)
manager = GauntletManager.new()
main_mock.add_child(manager)
manager.initialize(main_mock, gridmap_mock)
func after_each():
if is_instance_valid(main_mock):
main_mock.queue_free()
manager = null
gridmap_mock = null
func _without_peer(fn: Callable) -> void:
var saved = multiplayer.multiplayer_peer
multiplayer.multiplayer_peer = null
fn.call()
multiplayer.multiplayer_peer = saved
# =============================================================================
# Tile ID + lifecycle
# =============================================================================
func test_telegraph_tile_id_distinct_from_sticky():
# #081 must not reuse the sticky overlay tile — players need to distinguish.
assert_ne(manager.TILE_TELEGRAPH, manager.TILE_STICKY, "Telegraph tile ≠ sticky tile")
assert_eq(manager.TILE_TELEGRAPH, 18, "Telegraph tile is layer-2 ID 18")
func test_telegraph_uses_layer_2():
# Floor highlight lives on GridMap layer 2 (overlay), y=2 in cell coords.
_without_peer(func():
manager.sync_growth_telegraph([Vector2i(5, 5)])
)
assert_eq(gridmap_mock.get_cell_item(Vector3i(5, 2, 5)), manager.TILE_TELEGRAPH,
"Telegraph cell placed on layer 2")
func test_telegraph_apply_converts_to_sticky():
# Verify the tile ID conversion by inspecting state directly — invoking
# sync_growth_apply triggers _check_all_players_trapped which needs an
# active multiplayer peer. The conversion is exercised by the
# test_gauntlet_growth_tick.gd suite; here we only confirm the
# sticky tile ID is reserved and distinct.
_without_peer(func():
manager.sync_growth_telegraph([Vector2i(7, 7)])
)
assert_eq(gridmap_mock.get_cell_item(Vector3i(7, 2, 7)), manager.TILE_TELEGRAPH,
"Telegraph set during warn window")
assert_ne(manager.TILE_TELEGRAPH, manager.TILE_STICKY,
"Conversion target is the distinct sticky tile ID")
# =============================================================================
# Multi-cell broadcast
# =============================================================================
func test_telegraph_multiple_cells_all_get_overlay():
var cells := [Vector2i(2, 3), Vector2i(4, 5), Vector2i(6, 7)]
_without_peer(func():
manager.sync_growth_telegraph(cells)
)
for c in cells:
assert_eq(gridmap_mock.get_cell_item(Vector3i(c.x, 2, c.y)), manager.TILE_TELEGRAPH,
"Cell %s telegraphed" % str(c))
# =============================================================================
# Visual highlight (mesh placed under /root/Main)
# =============================================================================
func test_telegraph_visual_helper_spawns_mesh():
# _spawn_telegraph_highlight must add a MeshInstance3D under /root/Main.
var before := _count_main_children()
manager._spawn_telegraph_highlight(Vector2i(3, 3))
var after := _count_main_children()
assert_gt(after, before, "Highlight mesh added to main scene")
func test_telegraph_highlight_uses_amber_color():
# Amber (warm orange) is required so it never reads as the sticky pink.
manager._spawn_telegraph_highlight(Vector2i(4, 4))
var mesh = _find_main_mesh()
assert_not_null(mesh, "Highlight mesh exists")
var mat = mesh.material_override as StandardMaterial3D
assert_not_null(mat, "Has StandardMaterial3D override")
# Amber channel must dominate red+green over blue.
assert_gt(mat.albedo_color.r, mat.albedo_color.b + 0.2,
"Amber red > blue by ≥0.2")
assert_gt(mat.albedo_color.g, mat.albedo_color.b + 0.2,
"Amber green > blue by ≥0.2")
# Emission must be enabled so the highlight reads through shadows.
assert_true(mat.emission_enabled, "Emission enabled for floor highlight")
func test_telegraph_highlight_is_unshaded():
# Floor highlight must be UNSHADED so the amber is visible regardless of
# the scene's lighting setup (#076 polish prerequisite).
manager._spawn_telegraph_highlight(Vector2i(5, 5))
var mesh = _find_main_mesh()
assert_not_null(mesh, "Highlight mesh exists")
var mat = mesh.material_override as StandardMaterial3D
assert_eq(mat.shading_mode, BaseMaterial3D.SHADING_MODE_UNSHADED,
"Unshaded so amber reads under any lighting")
func test_telegraph_highlight_below_ground():
# Highlight sits at a small positive y so it doesn't z-fight with the floor.
manager._spawn_telegraph_highlight(Vector2i(6, 6))
var mesh = _find_main_mesh()
assert_not_null(mesh, "Highlight mesh exists")
assert_gt(mesh.position.y, 0.0, "Highlight raised above floor")
assert_lt(mesh.position.y, 0.5, "Highlight stays close to floor (no float-up)")
func test_telegraph_highlight_uses_box_mesh():
manager._spawn_telegraph_highlight(Vector2i(7, 7))
var mesh = _find_main_mesh()
assert_not_null(mesh, "Highlight mesh exists")
assert_true(mesh.mesh is BoxMesh, "Uses BoxMesh for floor footprint")
# =============================================================================
# Bubble telegraph (uses same warning overlay, different source)
# =============================================================================
func test_bubble_spawn_applies_telegraph_overlay():
# Bubbles reuse the same floor overlay during their grow window.
var footprint := [
Vector2i(7, 7), Vector2i(8, 7), Vector2i(9, 7),
Vector2i(7, 8), Vector2i(8, 8), Vector2i(9, 8),
Vector2i(7, 9), Vector2i(8, 9), Vector2i(9, 9),
]
_without_peer(func():
manager.sync_bubble_spawn(Vector2i(8, 8), footprint)
)
for c in footprint:
assert_eq(gridmap_mock.get_cell_item(Vector3i(c.x, 2, c.y)), manager.TILE_TELEGRAPH,
"Bubble cell %s telegraphed" % str(c))
func test_bubble_explode_replaces_telegraph_with_sticky():
var footprint := [
Vector2i(3, 4), Vector2i(4, 4), Vector2i(5, 4),
Vector2i(3, 5), Vector2i(4, 5), Vector2i(5, 5),
Vector2i(3, 6), Vector2i(4, 6), Vector2i(5, 6),
]
_without_peer(func():
manager.sync_bubble_spawn(Vector2i(4, 5), footprint)
)
_without_peer(func():
manager.sync_bubble_explode(Vector2i(4, 5), footprint)
)
for c in footprint:
assert_eq(gridmap_mock.get_cell_item(Vector3i(c.x, 2, c.y)), manager.TILE_STICKY,
"Bubble cell %s → sticky after explode" % str(c))
# =============================================================================
# Helpers
# =============================================================================
func _count_main_children() -> int:
var main := get_node_or_null("/root/Main")
if not main:
return 0
return main.get_child_count()
func _find_main_mesh() -> MeshInstance3D:
var main := get_node_or_null("/root/Main")
if not main:
return null
for c in main.get_children():
if c is MeshInstance3D:
return c
return null
@@ -1 +0,0 @@
uid://dqvm86t7rr3t
-159
View File
@@ -1,159 +0,0 @@
extends GutTest
# =============================================================================
# Test: Gauntlet Growth Tick System (v2) [Gauntlet #067]
# Replaces the old cannon-timer test. Covers growth timing, phase configs,
# candidate generation, cells-per-tick ranges, weighted selection, and
# cleansed-cell exclusion.
# =============================================================================
const GauntletManager = preload("res://scripts/managers/gauntlet_manager.gd")
var gauntlet_manager: Node
var main_mock: Node
var gridmap_mock: Node
func before_all():
gut.p("=== Feature Tests [Gauntlet #067 Growth Tick] ===")
func before_each():
main_mock = Node.new()
add_child(main_mock)
gridmap_mock = Node.new()
gridmap_mock.name = "EnhancedGridMap"
main_mock.add_child(gridmap_mock)
gauntlet_manager = GauntletManager.new()
main_mock.add_child(gauntlet_manager)
gauntlet_manager.initialize(main_mock, gridmap_mock)
func after_each():
if main_mock:
main_mock.queue_free()
func after_all():
gut.p("=== Feature Tests Complete ===")
# =============================================================================
# Growth Timing
# =============================================================================
func test_growth_timer_starts_zero():
assert_eq(gauntlet_manager.growth_timer, 0.0, "Growth timer starts at 0.0")
func test_growth_interval_default():
assert_eq(gauntlet_manager.growth_interval, 3.0, "Growth interval defaults to 3.0s")
func test_telegraph_duration_default():
assert_eq(gauntlet_manager.telegraph_duration, 1.0, "Telegraph duration defaults to 1.0s")
# =============================================================================
# Phase Growth Config
# =============================================================================
func test_phase_growth_config_has_three_phases():
assert_eq(gauntlet_manager.phase_growth_config.size(), 3, "Three phase growth configs")
func test_phase1_cells_range():
var cfg = gauntlet_manager.phase_growth_config[0]
assert_eq(cfg["cells_min"], 4, "Phase 1 min 4 cells/tick")
assert_eq(cfg["cells_max"], 6, "Phase 1 max 6 cells/tick")
func test_phase2_cells_range():
var cfg = gauntlet_manager.phase_growth_config[1]
assert_eq(cfg["cells_min"], 6, "Phase 2 min 6 cells/tick")
assert_eq(cfg["cells_max"], 8, "Phase 2 max 8 cells/tick")
func test_phase3_cells_range():
var cfg = gauntlet_manager.phase_growth_config[2]
assert_eq(cfg["cells_min"], 8, "Phase 3 min 8 cells/tick")
assert_eq(cfg["cells_max"], 10, "Phase 3 max 10 cells/tick")
func test_cells_this_tick_in_phase_range():
for phase in range(3):
gauntlet_manager.current_phase = phase
var cfg = gauntlet_manager.phase_growth_config[phase]
# Sample several times since the count is randomized.
for _i in range(20):
var n = gauntlet_manager._cells_this_tick()
assert_true(n >= cfg["cells_min"] and n <= cfg["cells_max"],
"Phase %d cells/tick %d within [%d,%d]" % [phase, n, cfg["cells_min"], cfg["cells_max"]])
# =============================================================================
# Candidate Generation
# =============================================================================
func test_candidates_are_all_safe_cells():
gauntlet_manager.current_phase = 0
var candidates = gauntlet_manager._generate_candidates()
# Fresh arena: every playable cell is SAFE.
assert_eq(candidates.size(), gauntlet_manager.playable_cell_count(),
"All playable cells are candidates on a fresh arena")
func test_candidates_exclude_sticky():
gauntlet_manager.sticky_cells[Vector2i(3, 3)] = true
var candidates = gauntlet_manager._generate_candidates()
var found := false
for c in candidates:
if c["pos"] == Vector2i(3, 3):
found = true
assert_false(found, "Sticky cells are excluded from candidates")
func test_candidates_exclude_cleansed():
gauntlet_manager.mark_cleansed(Vector2i(4, 4))
var candidates = gauntlet_manager._generate_candidates()
var found := false
for c in candidates:
if c["pos"] == Vector2i(4, 4):
found = true
assert_false(found, "Cleansed cells are excluded from candidates (regrowth protection)")
func test_candidates_exclude_npc_and_boundary():
var candidates = gauntlet_manager._generate_candidates()
for c in candidates:
var p = c["pos"]
assert_false(gauntlet_manager._is_npc_zone(p), "No NPC-zone candidates")
assert_false(gauntlet_manager._is_boundary(p), "No boundary candidates")
func test_candidates_have_scores():
var candidates = gauntlet_manager._generate_candidates()
assert_true(candidates.size() > 0, "Has candidates")
assert_true(candidates[0].has("score"), "Candidate carries a score")
# =============================================================================
# Weighted Selection
# =============================================================================
func test_select_count_respected():
var candidates = gauntlet_manager._generate_candidates()
var picked = gauntlet_manager._select_cells_weighted(candidates, 5)
assert_eq(picked.size(), 5, "Selects exactly the requested count")
func test_select_no_duplicates():
var candidates = gauntlet_manager._generate_candidates()
var picked = gauntlet_manager._select_cells_weighted(candidates, 10)
var seen := {}
for p in picked:
assert_false(seen.has(p), "No duplicate selections")
seen[p] = true
func test_select_capped_at_pool_size():
var small = [{"pos": Vector2i(2, 2), "score": 1.0}, {"pos": Vector2i(2, 3), "score": 1.0}]
var picked = gauntlet_manager._select_cells_weighted(small, 10)
assert_eq(picked.size(), 2, "Cannot select more than pool size")
# =============================================================================
# Scoring Helpers
# =============================================================================
func test_layer_classification():
assert_eq(gauntlet_manager._layer_of(Vector2i(9, 9)), "inner", "Center is inner")
assert_eq(gauntlet_manager._layer_of(Vector2i(1, 1)), "outer", "Corner is outer")
func test_sticky_neighbor_count():
gauntlet_manager.sticky_cells[Vector2i(5, 5)] = true
gauntlet_manager.sticky_cells[Vector2i(5, 6)] = true
assert_eq(gauntlet_manager._sticky_neighbor_count(Vector2i(6, 5)), 2,
"Counts 8-directional sticky neighbors")
func test_chebyshev():
assert_eq(gauntlet_manager._chebyshev(Vector2i(0, 0), Vector2i(3, 1)), 3, "Chebyshev distance")
-1
View File
@@ -1 +0,0 @@
uid://btbxtdhagjdba
-119
View File
@@ -1,119 +0,0 @@
extends GutTest
# =============================================================================
# Test: Gauntlet Movement Buffer System (v2) [Gauntlet #083]
# Hidden, decaying safe-corridor penalties layered onto candidate scoring.
# Runs headless; elapsed_time = 0 so the final-30s window is inactive unless a
# test sets elapsed_time directly.
# =============================================================================
const GauntletManager = preload("res://scripts/managers/gauntlet_manager.gd")
var manager
var main_mock: Node
var gridmap_mock: Node
func before_each():
main_mock = Node.new()
add_child(main_mock)
gridmap_mock = Node.new()
gridmap_mock.name = "EnhancedGridMap"
main_mock.add_child(gridmap_mock)
manager = GauntletManager.new()
main_mock.add_child(manager)
manager.initialize(main_mock, gridmap_mock)
manager.current_phase = 0
func after_each():
if main_mock:
main_mock.queue_free()
# =============================================================================
# Registration
# =============================================================================
func test_register_buffer_sets_phase_base_penalty():
manager._register_buffer(Vector2i(5, 5), 40.0)
assert_true(manager.movement_buffers.has(Vector2i(5, 5)), "Buffer registered")
assert_almost_eq(manager.movement_buffers[Vector2i(5, 5)]["penalty"], 40.0, 0.001, "Full penalty stored")
func test_register_buffer_keeps_strongest():
manager._register_buffer(Vector2i(5, 5), 20.0)
manager._register_buffer(Vector2i(5, 5), 40.0)
assert_almost_eq(manager.movement_buffers[Vector2i(5, 5)]["penalty"], 40.0, 0.001, "Keeps the stronger penalty")
manager._register_buffer(Vector2i(5, 5), 10.0)
assert_almost_eq(manager.movement_buffers[Vector2i(5, 5)]["penalty"], 40.0, 0.001, "Weaker refresh does not lower it")
# =============================================================================
# Penalty lookup (inside / adjacent / none / final-window)
# =============================================================================
func test_buffer_penalty_inside_is_full_negative():
manager._register_buffer(Vector2i(6, 6), 40.0)
assert_almost_eq(manager._buffer_penalty_at(Vector2i(6, 6)), -40.0, 0.001, "Inside buffer = full negative")
func test_buffer_penalty_adjacent_is_half():
manager._register_buffer(Vector2i(6, 6), 40.0)
assert_almost_eq(manager._buffer_penalty_at(Vector2i(7, 6)), -20.0, 0.001, "Adjacent buffer = half penalty")
func test_buffer_penalty_far_is_zero():
manager._register_buffer(Vector2i(6, 6), 40.0)
assert_eq(manager._buffer_penalty_at(Vector2i(15, 15)), 0.0, "Far from buffer = 0")
func test_buffer_penalty_lifts_in_final_window():
manager._register_buffer(Vector2i(6, 6), 40.0)
manager.elapsed_time = manager.gauntlet_round_duration() - 5.0 # within final 30s
assert_eq(manager._buffer_penalty_at(Vector2i(6, 6)), 0.0, "Final window lifts buffers")
func test_buffer_penalty_empty_is_zero():
assert_eq(manager._buffer_penalty_at(Vector2i(6, 6)), 0.0, "No buffers = 0")
# =============================================================================
# Time decay (25% every 5s)
# =============================================================================
func test_decay_reduces_penalty_after_interval():
manager._register_buffer(Vector2i(5, 5), 40.0)
manager._decay_movement_buffers(manager.BUFFER_DECAY_INTERVAL) # one full step
assert_almost_eq(manager.movement_buffers[Vector2i(5, 5)]["penalty"], 30.0, 0.001, "25% after one interval")
func test_decay_waits_for_full_interval():
manager._register_buffer(Vector2i(5, 5), 40.0)
manager._decay_movement_buffers(manager.BUFFER_DECAY_INTERVAL * 0.5) # not yet
assert_almost_eq(manager.movement_buffers[Vector2i(5, 5)]["penalty"], 40.0, 0.001, "No decay before interval elapses")
func test_decay_prunes_faded_buffers():
manager._register_buffer(Vector2i(5, 5), manager.BUFFER_MIN_PENALTY + 0.5)
manager._decay_movement_buffers(manager.BUFFER_DECAY_INTERVAL)
assert_false(manager.movement_buffers.has(Vector2i(5, 5)), "Faded buffer pruned below BUFFER_MIN_PENALTY")
# =============================================================================
# Phase-change decay (50%)
# =============================================================================
func test_phase_change_halves_buffers():
manager._register_buffer(Vector2i(5, 5), 40.0)
manager._start_phase(manager.Phase.ROUTE_PRESSURE)
assert_almost_eq(manager.movement_buffers[Vector2i(5, 5)]["penalty"], 20.0, 0.001, "Phase change halves penalty")
# =============================================================================
# Scoring integration
# =============================================================================
func test_score_movement_buffer_uses_detected_corridor():
# With no players, the proximity floor is inert; a registered buffer still bites.
manager._register_buffer(Vector2i(5, 5), 40.0)
assert_almost_eq(manager._score_movement_buffer(Vector2i(5, 5)), -40.0, 0.001, "Score reflects buffer penalty")
func test_score_movement_buffer_zero_without_buffers_or_players():
assert_eq(manager._score_movement_buffer(Vector2i(5, 5)), 0.0, "No buffers, no players = 0")
# =============================================================================
# Scale helper
# =============================================================================
func test_scale_all_buffers_prunes_and_scales():
manager._register_buffer(Vector2i(1, 1), 40.0)
manager._register_buffer(Vector2i(2, 2), manager.BUFFER_MIN_PENALTY + 0.1)
manager._scale_all_buffers(0.5)
assert_almost_eq(manager.movement_buffers[Vector2i(1, 1)]["penalty"], 20.0, 0.001, "Scaled by 0.5")
assert_false(manager.movement_buffers.has(Vector2i(2, 2)), "Below-min entry pruned")
@@ -1 +0,0 @@
uid://4cttae74ja3t
-155
View File
@@ -1,155 +0,0 @@
# tests/test_gauntlet_registration.gd
# Tests for [Gauntlet] #1 Game Mode Registration
# Validates GAUNTLET enum, string conversion, lobby integration, and arena setup
extends GutTest
func before_all():
gut.p("=== Gauntlet Registration Tests [Gauntlet #1] ===")
func after_each():
pass
# =============================================================================
# GameMode Enum Tests
# =============================================================================
# Test 1: GAUNTLET enum value exists and equals 3
func test_gauntlet_enum_exists():
assert_eq(GameMode.Mode.GAUNTLET, 3, "GAUNTLET should be enum value 3")
# Test 2: All 3 modes are present in enum
func test_all_modes_in_enum():
assert_eq(GameMode.Mode.FREEMODE, 0, "FREEMODE should be 0")
assert_eq(GameMode.Mode.STOP_N_GO, 1, "STOP_N_GO should be 1")
assert_eq(GameMode.Mode.GAUNTLET, 3, "GAUNTLET should be 3")
# =============================================================================
# String Conversion Tests
# =============================================================================
# Test 3: from_string recognizes "Candy Pump Survival"
func test_from_string_candy_cannon():
var result = GameMode.from_string("Candy Pump Survival")
assert_eq(result, GameMode.Mode.GAUNTLET, "from_string should parse 'Candy Pump Survival' as GAUNTLET")
# Test 4: mode_to_string returns "Candy Pump Survival" for GAUNTLET
func test_mode_to_string_gauntlet():
var result = GameMode.mode_to_string(GameMode.Mode.GAUNTLET)
assert_eq(result, "Candy Pump Survival", "mode_to_string should return 'Candy Pump Survival'")
# Test 5: Round-trip conversion is lossless
func test_round_trip_conversion():
var mode_str = GameMode.mode_to_string(GameMode.Mode.GAUNTLET)
var mode_enum = GameMode.from_string(mode_str)
assert_eq(mode_enum, GameMode.Mode.GAUNTLET, "Round-trip should preserve GAUNTLET")
# Test 6: All existing modes still round-trip correctly
func test_existing_modes_round_trip():
for mode in [GameMode.Mode.FREEMODE, GameMode.Mode.STOP_N_GO]:
var s = GameMode.mode_to_string(mode)
var back = GameMode.from_string(s)
assert_eq(back, mode, "Round-trip failed for %s" % s)
# Test 7: Unknown string defaults to FREEMODE
func test_unknown_string_defaults_freemode():
var result = GameMode.from_string("NonExistentMode")
assert_eq(result, GameMode.Mode.FREEMODE, "Unknown mode string should default to FREEMODE")
# =============================================================================
# get_all_modes Tests
# =============================================================================
# Test 8: get_all_modes includes "Candy Pump Survival"
func test_get_all_modes_includes_gauntlet():
var modes = GameMode.get_all_modes()
assert_has(modes, "Candy Pump Survival", "get_all_modes should include 'Candy Pump Survival'")
# Test 9: get_all_modes returns exactly 3 entries
func test_get_all_modes_count():
var modes = GameMode.get_all_modes()
assert_eq(modes.size(), 3, "get_all_modes should return 3 modes")
# Test 10: get_all_modes order is correct
func test_get_all_modes_order():
var modes = GameMode.get_all_modes()
assert_eq(modes[0], "Freemode", "First mode should be Freemode")
assert_eq(modes[1], "Stop n Go", "Second mode should be Stop n Go")
assert_eq(modes[2], "Candy Pump Survival", "Third mode should be Candy Pump Survival")
# =============================================================================
# is_restricted Tests
# =============================================================================
# Test 11: GAUNTLET is a restricted mode
func test_gauntlet_is_restricted():
var result = GameMode.is_restricted(GameMode.Mode.GAUNTLET)
assert_true(result, "GAUNTLET should be restricted (dedicated arena)")
# Test 12: FREEMODE is NOT restricted
func test_freemode_not_restricted():
var result = GameMode.is_restricted(GameMode.Mode.FREEMODE)
assert_false(result, "FREEMODE should not be restricted")
# Test 13: All restricted modes are confirmed
func test_all_restricted_modes():
assert_true(GameMode.is_restricted(GameMode.Mode.STOP_N_GO), "STOP_N_GO should be restricted")
assert_true(GameMode.is_restricted(GameMode.Mode.GAUNTLET), "GAUNTLET should be restricted")
# =============================================================================
# LobbyManager Integration Tests
# =============================================================================
# Test 14: Lobby available_game_modes includes "Candy Pump Survival"
func test_lobby_modes_includes_gauntlet():
var modes = LobbyManager.available_game_modes
assert_has(modes, "Candy Pump Survival", "LobbyManager.available_game_modes should include 'Candy Pump Survival'")
# Test 15: gauntlet_manager.gd script file exists
func test_gauntlet_manager_script_exists():
var script_exists = ResourceLoader.exists("res://scripts/managers/gauntlet_manager.gd")
assert_true(script_exists, "gauntlet_manager.gd should exist")
# Test 16: GauntletManager class can be loaded
func test_gauntlet_manager_loads():
var script = load("res://scripts/managers/gauntlet_manager.gd")
assert_not_null(script, "gauntlet_manager.gd should load without errors")
# Test 17: GauntletManager has required methods
func test_gauntlet_manager_has_methods():
var manager = GauntletManager.new()
assert_true(manager.has_method("_setup_arena"), "GauntletManager should have _setup_arena()")
assert_true(manager.has_method("_apply_arena_setup"), "GauntletManager should have _apply_arena_setup()")
assert_true(manager.has_method("start_game_mode"), "GauntletManager should have start_game_mode()")
assert_true(manager.has_method("initialize"), "GauntletManager should have initialize()")
manager.free()
# Test 18: GauntletManager arena constants are correct
func test_gauntlet_arena_constants():
assert_eq(GauntletManager.ARENA_COLUMNS, 20, "Arena should be 20 columns")
assert_eq(GauntletManager.ARENA_ROWS, 20, "Arena should be 20 rows")
assert_eq(GauntletManager.NPC_SIZE, 3, "NPC zone should be 3x3")
assert_eq(GauntletManager.NPC_CENTER, Vector2i(9, 9), "NPC center should be at (9,9)")
# Test 19: NPC zone detection works
func test_npc_zone_detection():
var manager = GauntletManager.new()
# Center of NPC zone
assert_true(manager._is_npc_zone(Vector2i(9, 9)), "Center (9,9) should be NPC zone")
# Edges of NPC zone
assert_true(manager._is_npc_zone(Vector2i(8, 8)), "Corner (8,8) should be NPC zone")
assert_true(manager._is_npc_zone(Vector2i(10, 10)), "Corner (10,10) should be NPC zone")
# Outside NPC zone
assert_false(manager._is_npc_zone(Vector2i(7, 9)), "Outside (7,9) should NOT be NPC zone")
assert_false(manager._is_npc_zone(Vector2i(11, 9)), "Outside (11,9) should NOT be NPC zone")
assert_false(manager._is_npc_zone(Vector2i(0, 0)), "Corner (0,0) should NOT be NPC zone")
manager.free()
# Test 20: Phase enum has 3 phases
func test_gauntlet_phases():
assert_eq(GauntletManager.Phase.OPEN_ARENA, 0, "OPEN_ARENA should be 0")
assert_eq(GauntletManager.Phase.ROUTE_PRESSURE, 1, "ROUTE_PRESSURE should be 1")
assert_eq(GauntletManager.Phase.SURVIVAL_ENDGAME, 2, "SURVIVAL_ENDGAME should be 2")
func after_all():
gut.p("=== Gauntlet Registration Tests Complete ===")
-1
View File
@@ -1 +0,0 @@
uid://6pn8jkrn2kt
-185
View File
@@ -1,185 +0,0 @@
extends GutTest
# =============================================================================
# Test: Gauntlet Candidate Scoring System (v2) [Gauntlet #073]
# Covers each score component, camping accumulation, and full-formula
# composition. Runs headless (no multiplayer peer), so elapsed_time = 0 and
# the final-30s window is inactive unless a test sets elapsed_time directly.
# =============================================================================
const GauntletManager = preload("res://scripts/managers/gauntlet_manager.gd")
var manager
var main_mock: Node
var gridmap_mock: Node
func before_each():
main_mock = Node.new()
add_child(main_mock)
gridmap_mock = Node.new()
gridmap_mock.name = "EnhancedGridMap"
main_mock.add_child(gridmap_mock)
manager = GauntletManager.new()
main_mock.add_child(manager)
manager.initialize(main_mock, gridmap_mock)
manager.current_phase = 0
func after_each():
if main_mock:
main_mock.queue_free()
# =============================================================================
# LayerPriority
# =============================================================================
func test_layer_priority_matches_phase_weights():
manager.current_phase = 0
# Outer ring cell (corner-ish) gets the phase-0 outer weight (+60).
assert_eq(manager._score_layer_priority(Vector2i(2, 2)), 60.0, "Phase 0 outer = +60")
# Inner cell near center gets phase-0 inner weight (-40).
assert_eq(manager._score_layer_priority(Vector2i(9, 8)), -40.0, "Phase 0 inner = -40")
func test_layer_priority_phase3_inner():
manager.current_phase = 2
assert_eq(manager._score_layer_priority(Vector2i(9, 8)), 60.0, "Phase 2 inner = +60")
# =============================================================================
# StickyNeighbor
# =============================================================================
func test_sticky_neighbor_score_scales():
assert_eq(manager._score_sticky_neighbor(Vector2i(5, 5)), 0.0, "No neighbors = 0")
manager.sticky_cells[Vector2i(5, 6)] = true
assert_eq(manager._score_sticky_neighbor(Vector2i(5, 5)), 8.0, "One neighbor = +8")
func test_sticky_neighbor_score_capped():
# Surround (5,5) on all 8 sides → 8 * 8 = 64, capped at 64.
for dx in range(-1, 2):
for dz in range(-1, 2):
if dx == 0 and dz == 0:
continue
manager.sticky_cells[Vector2i(5 + dx, 5 + dz)] = true
assert_eq(manager._score_sticky_neighbor(Vector2i(5, 5)), 64.0, "Capped at +64")
# =============================================================================
# InwardPressure
# =============================================================================
func test_inward_pressure_higher_near_center():
manager.current_phase = 2
var near = manager._score_inward_pressure(Vector2i(8, 8)) # close to center
var far = manager._score_inward_pressure(Vector2i(1, 1)) # far corner
assert_true(near > far, "Inward pressure stronger near center")
func test_inward_pressure_phase_scaling():
# Same cell, later phase => higher inward pressure ceiling.
var pos := Vector2i(8, 8)
manager.current_phase = 0
var p0 = manager._score_inward_pressure(pos)
manager.current_phase = 2
var p2 = manager._score_inward_pressure(pos)
assert_true(p2 > p0, "Later phase pushes inward harder")
# =============================================================================
# PlayerPressure
# =============================================================================
func test_player_pressure_ring():
# 3 cells from a player → +20.
var players = [Vector2i(5, 5)]
assert_eq(manager._score_player_pressure(Vector2i(8, 5), players), 20.0, "2-4 cells away = +20")
func test_player_pressure_under_player_penalized():
var players = [Vector2i(5, 5)]
# elapsed_time 0, round 180 → not final window → directly under = -50.
assert_eq(manager._score_player_pressure(Vector2i(5, 5), players), -50.0, "Under player (early) = -50")
func test_player_pressure_under_player_final_window():
manager.elapsed_time = manager.gauntlet_round_duration() - 5.0 # within final 30s
var players = [Vector2i(5, 5)]
assert_eq(manager._score_player_pressure(Vector2i(5, 5), players), 10.0, "Under player (final) = +10")
func test_player_pressure_no_players():
assert_eq(manager._score_player_pressure(Vector2i(5, 5), []), 0.0, "No players = 0")
# =============================================================================
# ClusterGrowth
# =============================================================================
func test_cluster_growth_none():
assert_eq(manager._score_cluster_growth(Vector2i(5, 5)), 0.0, "No sticky neighbors = 0")
func test_cluster_growth_expand():
manager.sticky_cells[Vector2i(5, 6)] = true
assert_eq(manager._score_cluster_growth(Vector2i(5, 5)), 15.0, "Expanding cluster = +15")
func test_cluster_growth_connect():
manager.sticky_cells[Vector2i(4, 5)] = true
manager.sticky_cells[Vector2i(6, 5)] = true
manager.sticky_cells[Vector2i(5, 6)] = true
assert_eq(manager._score_cluster_growth(Vector2i(5, 5)), 25.0, "Connecting clusters = +25")
# =============================================================================
# CampingPressure
# =============================================================================
func test_camp_region_grouping():
assert_eq(manager._region_of(Vector2i(0, 0)), Vector2i(0, 0), "Cells 0-3 → region 0")
assert_eq(manager._region_of(Vector2i(5, 7)), Vector2i(1, 1), "Cells 4-7 → region 1")
func test_camping_pressure_thresholds():
var region: Vector2i = manager._region_of(Vector2i(8, 8))
manager._camp_tracking[1] = {"region": region, "time": 6.0}
assert_eq(manager._score_camping_pressure(Vector2i(8, 8)), 20.0, ">5s = +20")
manager._camp_tracking[1]["time"] = 9.0
assert_eq(manager._score_camping_pressure(Vector2i(8, 8)), 40.0, ">8s = +40")
manager._camp_tracking[1]["time"] = 11.0
assert_eq(manager._score_camping_pressure(Vector2i(8, 8)), 60.0, ">10s = +60")
func test_camping_pressure_none():
assert_eq(manager._score_camping_pressure(Vector2i(8, 8)), 0.0, "No camping = 0")
# =============================================================================
# Repetition
# =============================================================================
func test_repetition_penalty():
manager._last_tick_cells = [Vector2i(5, 5)]
assert_eq(manager._score_repetition(Vector2i(5, 6)), -30.0, "Adjacent to last tick = -30")
assert_eq(manager._score_repetition(Vector2i(15, 15)), 0.0, "Far from last tick = 0")
# =============================================================================
# PathSafety (soft penalty)
# =============================================================================
func test_path_safety_no_players_no_penalty():
assert_eq(manager._score_path_safety(Vector2i(5, 5)), 0.0, "No players = no penalty")
# =============================================================================
# Camp tracking accumulation
# =============================================================================
func test_camp_time_for_region_picks_max():
var region := Vector2i(1, 1)
manager._camp_tracking[1] = {"region": region, "time": 3.0}
manager._camp_tracking[2] = {"region": region, "time": 7.0}
assert_almost_eq(manager._camp_time_for_region(region), 7.0, 0.001, "Longest camp time wins")
# =============================================================================
# Full formula composition
# =============================================================================
func test_full_score_runs_and_is_finite():
var s = manager._calculate_candidate_score(Vector2i(5, 5), [])
assert_true(is_finite(s), "Full score is a finite number")
func test_full_score_rewards_sticky_cluster():
# A cell hugging an existing cluster should generally beat an isolated one.
# Average several samples to wash out RandomNoise (±20).
manager.sticky_cells[Vector2i(5, 6)] = true
manager.sticky_cells[Vector2i(6, 5)] = true
var clustered := 0.0
var isolated := 0.0
for _i in range(40):
clustered += manager._calculate_candidate_score(Vector2i(5, 5), [])
isolated += manager._calculate_candidate_score(Vector2i(15, 15), [])
assert_true(clustered > isolated, "Clustered cell scores higher on average")
-1
View File
@@ -1 +0,0 @@
uid://tugcu571care
-208
View File
@@ -1,208 +0,0 @@
extends GutTest
# =============================================================================
# Test: Gauntlet Sticky Cell System (v2) [Gauntlet #068]
# Covers cell states, CLEANSED protection, coverage helpers, and the
# path-safety reachability (BFS) check.
# =============================================================================
var GauntletManagerScript = load("res://scripts/managers/gauntlet_manager.gd")
var manager: GauntletManager
func before_each():
manager = GauntletManagerScript.new()
add_child(manager)
func after_each():
manager.queue_free()
# =============================================================================
# CellState enum
# =============================================================================
func test_cellstate_enum_has_six_states():
assert_eq(manager.CellState.size(), 6, "CellState should have 6 states")
func test_cellstate_values():
assert_eq(manager.CellState.SAFE, 0, "SAFE should be 0")
assert_eq(manager.CellState.TELEGRAPHED, 1, "TELEGRAPHED should be 1")
assert_eq(manager.CellState.STICKY, 2, "STICKY should be 2")
assert_eq(manager.CellState.BUBBLE_GROWING, 3, "BUBBLE_GROWING should be 3")
assert_eq(manager.CellState.BLOCKED, 4, "BLOCKED should be 4")
assert_eq(manager.CellState.CLEANSED, 5, "CLEANSED should be 5")
# =============================================================================
# cell_state() classification
# =============================================================================
func test_interior_cell_is_safe():
assert_eq(manager.cell_state(Vector2i(3, 3)), manager.CellState.SAFE, "Open interior cell is SAFE")
func test_npc_zone_is_blocked():
assert_eq(manager.cell_state(Vector2i(9, 9)), manager.CellState.BLOCKED, "NPC zone is BLOCKED")
func test_boundary_is_blocked():
assert_eq(manager.cell_state(Vector2i(0, 5)), manager.CellState.BLOCKED, "Boundary is BLOCKED")
assert_eq(manager.cell_state(Vector2i(19, 5)), manager.CellState.BLOCKED, "Far boundary is BLOCKED")
func test_sticky_cell_state():
manager.sticky_cells[Vector2i(4, 4)] = true
assert_eq(manager.cell_state(Vector2i(4, 4)), manager.CellState.STICKY, "Sticky cell is STICKY")
func test_telegraphed_cell_state():
manager.telegraphed_cells[Vector2i(5, 5)] = 1.0
assert_eq(manager.cell_state(Vector2i(5, 5)), manager.CellState.TELEGRAPHED, "Telegraphed cell is TELEGRAPHED")
func test_cleansed_cell_state():
manager.mark_cleansed(Vector2i(6, 6))
assert_eq(manager.cell_state(Vector2i(6, 6)), manager.CellState.CLEANSED, "Cleansed cell is CLEANSED")
func test_sticky_takes_priority_over_cleansed():
# A cell that is both should report STICKY (active hazard wins).
manager.sticky_cells[Vector2i(7, 7)] = true
manager.cleansed_cells[Vector2i(7, 7)] = 5.0
assert_eq(manager.cell_state(Vector2i(7, 7)), manager.CellState.STICKY, "Sticky wins over cleansed")
# =============================================================================
# CLEANSED protection lifecycle
# =============================================================================
func test_mark_cleansed_sets_protection_time():
manager.mark_cleansed(Vector2i(3, 4))
assert_true(manager.is_cleansed_cell(Vector2i(3, 4)), "Cell should be cleansed")
assert_almost_eq(manager.cleansed_cells[Vector2i(3, 4)], manager.CLEANSED_PROTECTION_TIME, 0.001, "Protection time set")
func test_clear_sticky_marks_cleansed():
manager.sticky_cells[Vector2i(4, 5)] = true
manager.clear_sticky_cell(Vector2i(4, 5))
assert_false(manager.is_sticky_cell(Vector2i(4, 5)), "Sticky removed")
assert_true(manager.is_cleansed_cell(Vector2i(4, 5)), "Cleared cell becomes cleansed")
func test_tick_cleansed_decays_and_expires():
manager.mark_cleansed(Vector2i(5, 6))
manager._tick_cleansed_cells(manager.CLEANSED_PROTECTION_TIME + 0.1)
assert_false(manager.is_cleansed_cell(Vector2i(5, 6)), "Protection expires after full duration")
func test_tick_cleansed_partial_decay_keeps_cell():
manager.mark_cleansed(Vector2i(5, 7))
manager._tick_cleansed_cells(1.0)
assert_true(manager.is_cleansed_cell(Vector2i(5, 7)), "Cell still protected after partial tick")
# =============================================================================
# Coverage helpers (v2 target 70-75%)
# =============================================================================
func test_coverage_targets():
assert_almost_eq(manager.COVERAGE_TARGET_MIN, 0.70, 0.001, "Min coverage 70%")
assert_almost_eq(manager.COVERAGE_TARGET_MAX, 0.75, 0.001, "Max coverage 75%")
func test_playable_cell_count():
# 20x20 = 400, minus 76 boundary cells, minus 9 NPC zone = 315
assert_eq(manager.playable_cell_count(), 315, "Playable cells = 315")
func test_coverage_ratio_zero_when_empty():
assert_almost_eq(manager.coverage_ratio(), 0.0, 0.001, "No sticky cells = 0 coverage")
func test_coverage_ratio_scales():
var playable := manager.playable_cell_count()
# Fill ~half the playable cells with arbitrary distinct keys.
var half := int(playable / 2.0)
for i in range(half):
manager.sticky_cells[Vector2i(1000 + i, 0)] = true
assert_almost_eq(manager.coverage_ratio(), float(half) / float(playable), 0.001, "Coverage tracks ratio")
func test_coverage_reached_threshold():
var playable := manager.playable_cell_count()
var needed := int(ceil(playable * manager.COVERAGE_TARGET_MIN))
for i in range(needed):
manager.sticky_cells[Vector2i(2000 + i, 0)] = true
assert_true(manager.is_coverage_reached(), "Coverage reached at >=70%")
func test_coverage_not_reached_below_threshold():
manager.sticky_cells[Vector2i(2, 2)] = true
assert_false(manager.is_coverage_reached(), "One sticky cell is below target")
# =============================================================================
# Path safety: passability + reachability (BFS)
# =============================================================================
func test_passable_interior():
assert_true(manager._is_cell_passable(Vector2i(3, 3)), "Open interior is passable")
func test_not_passable_boundary_or_npc():
assert_false(manager._is_cell_passable(Vector2i(0, 0)), "Boundary not passable")
assert_false(manager._is_cell_passable(Vector2i(9, 9)), "NPC zone not passable")
func test_not_passable_sticky():
manager.sticky_cells[Vector2i(3, 3)] = true
assert_false(manager._is_cell_passable(Vector2i(3, 3)), "Sticky cell not passable")
func test_extra_sticky_blocks_passability():
var extra := {Vector2i(4, 4): true}
assert_false(manager._is_cell_passable(Vector2i(4, 4), extra), "Hypothetical sticky blocks")
assert_true(manager._is_cell_passable(Vector2i(5, 5), extra), "Other cells still passable")
func test_open_arena_has_large_safe_region():
# From an open interior cell, flood fill should easily exceed the minimum.
var n := manager._reachable_safe_cells(Vector2i(3, 3), {}, 50)
assert_true(n >= 50, "Open arena reaches the search cap")
func test_player_has_safe_region_when_open():
assert_true(manager._player_has_safe_region(Vector2i(3, 3), {}), "Open cell has safe region")
func test_fully_boxed_player_has_no_safe_region():
# Box in the cell at (3,3) on all 4 sides with hypothetical sticky.
var extra := {
Vector2i(2, 3): true, Vector2i(4, 3): true,
Vector2i(3, 2): true, Vector2i(3, 4): true,
}
assert_false(manager._player_has_safe_region(Vector2i(3, 3), extra), "Boxed-in player has no safe region")
func test_reachable_zero_when_start_blocked():
manager.sticky_cells[Vector2i(3, 3)] = true
assert_eq(manager._reachable_safe_cells(Vector2i(3, 3), {}, 10), 0, "Blocked start reaches nothing")
# =============================================================================
# Sticky entry → per-player slow (v2: no hard trap, no global time_scale)
# =============================================================================
# Minimal stand-in for a Player that records apply_slow_effect calls.
class SlowSpyPlayer:
extends Node
var slow_calls: Array = []
func apply_slow_effect(duration: float = 3.0) -> void:
slow_calls.append(duration)
func test_apply_sticky_slow_calls_player_slow():
var spy := SlowSpyPlayer.new()
add_child(spy)
# Force the local-call branch (no networked rpc) for a deterministic unit test.
var saved_peer = multiplayer.multiplayer_peer
multiplayer.multiplayer_peer = null
manager.apply_sticky_slow(spy)
multiplayer.multiplayer_peer = saved_peer
assert_eq(spy.slow_calls.size(), 1, "Sticky slow invokes apply_slow_effect once")
assert_almost_eq(spy.slow_calls[0], manager.STICKY_SLOW_DURATION, 0.001, "Slows for STICKY_SLOW_DURATION")
spy.queue_free()
func test_apply_sticky_slow_does_not_trap():
var spy := SlowSpyPlayer.new()
spy.set("peer_id", 42)
add_child(spy)
var saved_peer = multiplayer.multiplayer_peer
multiplayer.multiplayer_peer = null
manager.apply_sticky_slow(spy)
multiplayer.multiplayer_peer = saved_peer
assert_false(manager.trapped_players.has(42), "Sticky slow never adds to trapped_players")
spy.queue_free()
func test_apply_sticky_slow_safe_without_method():
# A node lacking apply_slow_effect must not crash the call.
var plain := Node.new()
add_child(plain)
manager.apply_sticky_slow(plain) # should no-op
assert_true(true, "apply_sticky_slow tolerates players without the method")
plain.queue_free()
func test_sticky_slow_duration_is_positive():
assert_true(manager.STICKY_SLOW_DURATION > 0.0, "Sticky slow duration is a positive number")
-1
View File
@@ -1 +0,0 @@
uid://csco4t66gq5et
-144
View File
@@ -1,144 +0,0 @@
extends GutTest
# =============================================================================
# Test: Gauntlet Tile Spawning & Mission System (Task #3)
# =============================================================================
var GauntletManagerScript = load("res://scripts/managers/gauntlet_manager.gd")
var manager: GauntletManager
func before_each():
manager = GauntletManagerScript.new()
add_child(manager)
func after_each():
manager.queue_free()
# =============================================================================
# Arena Constants
# =============================================================================
func test_arena_size_20x20():
assert_eq(manager.ARENA_COLUMNS, 20, "Arena should be 20 columns")
assert_eq(manager.ARENA_ROWS, 20, "Arena should be 20 rows")
func test_npc_center_position():
assert_eq(manager.NPC_CENTER, Vector2i(9, 9), "NPC center should be at (9,9)")
func test_npc_size_3x3():
assert_eq(manager.NPC_SIZE, 3, "NPC zone should be 3x3")
# =============================================================================
# NPC Zone Exclusion
# =============================================================================
func test_npc_zone_center_is_excluded():
assert_true(manager._is_npc_zone(Vector2i(9, 9)), "Center (9,9) should be NPC zone")
func test_npc_zone_corners_are_excluded():
assert_true(manager._is_npc_zone(Vector2i(8, 8)), "Top-left (8,8) should be NPC zone")
assert_true(manager._is_npc_zone(Vector2i(10, 8)), "Top-right (10,8) should be NPC zone")
assert_true(manager._is_npc_zone(Vector2i(8, 10)), "Bottom-left (8,10) should be NPC zone")
assert_true(manager._is_npc_zone(Vector2i(10, 10)), "Bottom-right (10,10) should be NPC zone")
func test_outside_npc_zone_not_excluded():
assert_false(manager._is_npc_zone(Vector2i(7, 9)), "Left of NPC zone should NOT be excluded")
assert_false(manager._is_npc_zone(Vector2i(11, 9)), "Right of NPC zone should NOT be excluded")
assert_false(manager._is_npc_zone(Vector2i(9, 7)), "Above NPC zone should NOT be excluded")
assert_false(manager._is_npc_zone(Vector2i(9, 11)), "Below NPC zone should NOT be excluded")
func test_arena_corners_not_excluded():
assert_false(manager._is_npc_zone(Vector2i(0, 0)), "Top-left corner should be walkable")
assert_false(manager._is_npc_zone(Vector2i(19, 0)), "Top-right corner should be walkable")
assert_false(manager._is_npc_zone(Vector2i(0, 19)), "Bottom-left corner should be walkable")
assert_false(manager._is_npc_zone(Vector2i(19, 19)), "Bottom-right corner should be walkable")
func test_npc_zone_total_cells():
var npc_count = 0
for x in range(manager.ARENA_COLUMNS):
for z in range(manager.ARENA_ROWS):
if manager._is_npc_zone(Vector2i(x, z)):
npc_count += 1
assert_eq(npc_count, 9, "NPC zone should occupy exactly 9 cells (3x3)")
func test_walkable_cells_count():
# 20x20 = 400 total, minus 9 NPC = 391 walkable
var walkable = 400 - 9
assert_eq(walkable, 391, "Should have 391 walkable cells")
# =============================================================================
# Tile Constants
# =============================================================================
func test_goal_tile_ids_valid():
# Heart(7), Diamond(8), Star(9), Coin(10) — match StopNGoManager
var goal_items = [7, 8, 9, 10]
for item in goal_items:
assert_gt(item, 0, "Goal tile ID %d should be positive" % item)
assert_lt(item, 17, "Goal tile ID %d should not conflict with sticky(17)" % item)
func test_tile_walkable_id():
assert_eq(manager.TILE_WALKABLE, 0, "Walkable tile should be ID 0")
func test_tile_obstacle_id():
assert_eq(manager.TILE_OBSTACLE, 4, "Obstacle tile should be ID 4")
func test_tile_sticky_id():
assert_eq(manager.TILE_STICKY, 17, "Sticky tile should be ID 17")
func test_tile_telegraph_id():
assert_eq(manager.TILE_TELEGRAPH, 18, "Telegraph tile should be ID 18")
# =============================================================================
# Method Existence
# =============================================================================
func test_setup_mission_tiles_exists():
assert_true(manager.has_method("setup_mission_tiles"), "Should have setup_mission_tiles()")
func test_spawn_mission_tiles_exists():
assert_true(manager.has_method("_spawn_mission_tiles"), "Should have _spawn_mission_tiles()")
# =============================================================================
# Sticky Cell System
# =============================================================================
func test_sticky_cells_initially_empty():
assert_eq(manager.sticky_cells.size(), 0, "Sticky cells should start empty")
func test_is_sticky_cell_false_for_clean():
assert_false(manager.is_sticky_cell(Vector2i(5, 5)), "Clean cell should not be sticky")
func test_is_sticky_cell_true_after_marking():
manager.sticky_cells[Vector2i(5, 5)] = true
assert_true(manager.is_sticky_cell(Vector2i(5, 5)), "Marked cell should be sticky")
func test_clear_sticky_cell():
manager.sticky_cells[Vector2i(3, 3)] = true
manager.clear_sticky_cell(Vector2i(3, 3))
assert_false(manager.is_sticky_cell(Vector2i(3, 3)), "Cleared cell should no longer be sticky")
# =============================================================================
# Phase Interaction with Tile Spawning
# =============================================================================
func test_initial_phase_is_open_arena():
assert_eq(manager.current_phase, GauntletManager.Phase.OPEN_ARENA, "Should start in Open Arena")
func test_phase_to_string_open_arena():
assert_eq(manager._phase_to_string(GauntletManager.Phase.OPEN_ARENA), "Outer Pressure")
func test_phase_to_string_route_pressure():
assert_eq(manager._phase_to_string(GauntletManager.Phase.ROUTE_PRESSURE), "Middle Pressure")
func test_phase_to_string_survival():
assert_eq(manager._phase_to_string(GauntletManager.Phase.SURVIVAL_ENDGAME), "Inner Survival")
# =============================================================================
# Match Timer Integration
# =============================================================================
func test_match_duration_180s():
# Gauntlet uses 180s match (3 phases: 0-60, 60-120, 120-180)
var total = manager.PHASE_3_START + 60.0 # Phase 3 starts at 120, runs 60s
assert_eq(total, 180.0, "Total match should be 180 seconds")
-1
View File
@@ -1 +0,0 @@
uid://cpwhlklp7jkkg