8000 GitHub - dvduongth/ccn2-demo · GitHub
[go: up one dir, main page]

Skip to content
dvduongthPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

CCN2 — Hotseat Demo

Version: 1.2 · Mode: Hotseat 2–4 players (one browser tab) · Engine: Pure HTML5 Canvas


Quick Start

Open DEMO/index.html in any modern browser (Chrome, Firefox, Edge, Safari). No server required — all client-side.


CONFIG Object (src/rules.js)

Values not explicitly specified in the GDD were assigned reasonable defaults:

Key Value Source
LADDER_POINTS_PER_LANDING 100 Default (6 landings = 600 KC)
REWARD_DIAMOND_BASE 10 Default
TOKEN_MOVE_SPEED 5 (tiles/sec) Default
DICE_ROLL_DURATION 700 ms Default
END_TURN_DELAY 600 ms Default
BOARD_CX / BOARD_CY 365, 320 Isometric board centre
TILE_RADIUS 22 px Isometric tile half-size

Tile distribution

Track tiles (40 tiles, circular path):

Type Tile IDs (1-based) Count
SAFE_ZONE 1, 11, 21, 31 4
KC 5, 10, 15, 20, 25, 30, 35, 40 8
REWARD 3, 7, 9, 13, 17, 19, 23, 27, 29, 33, 37, 39 12
EMPTY All remaining 16

Ladder destination tiles (4 tiles, at board centre):

Type Tile ID Owner
LADDER_DEST 41 Green
LADDER_DEST 42 Red
LADDER_DEST 43 Blue
LADDER_DEST 44 Yellow

Token-Carried KC & DOUBLE Dice Penalty (v1.2)

Token-Carried KC

  • Each token carries its own KC individually (Token.carriedKC)
  • Player's total KC = sum of both tokens' carried KC (computed getter, not stored)
  • Landing on a KC tile adds KC to the landing token, not the player directly
  • Gate opens when player total KC >= 600

DOUBLE Dice Penalty

  • Every move in DOUBLE dice mode costs the moving token 50% of its carried KC (rounded down)
  • The penalty is applied before the token moves
  • This creates a strategic trade-off: DOUBLE gives more steps + chance for extra turn, but bleeds KC

HUD Display

  • The ladder points table shows per-token KC breakdown (A:X B:Y) for each player
  • Debug overlay (F1) shows per-token tKC and totalKC

AI Awareness

  • AI avoids DOUBLE mode when tokens carry high KC (MEDIUM: >= 200, HARD: >= 150)
  • AI penalizes moving high-KC tokens in DOUBLE mode proportionally to potential loss

GDD Compliance Checklist

GDD Requirement Implemented File / Function
40-tile circular track (isometric layout) ✅ rules.js::TILE_DEFS, rules.js::ISO_TILE_RAW, board.js
Safe zones at tiles 1,11,21,31 ✅ rules.js::SAFE_ZONE_TILES
Tile types: SAFE_ZONE, KC, REWARD, EMPTY, LADDER_DEST ✅ rules.js::TILE_TYPE, board.js::_drawTiles
Ladder destination tiles 41-44 at board centre ✅ rules.js::LADDER_DEST_TILES, board.js::_drawLadderDestTiles
Kicking blocked in SAFE_ZONE ✅ board.js::canKickAt, game.js::_beginLandResolution
2–4 players hotseat ✅ ui.js::_drawSetup, game.js::_initMatch
2 tokens per player ✅ entities.js::Player constructor
Tokens start in player safe zone ✅ entities.js::Token constructor
Turn sequence: WAIT_PLAYER → ROLL_DICE → MOVE → LAND_RESOLUTION → END_TURN ✅ game.js state machine
SINGLE dice mode (1d6) ✅ game.js::_rollDiceUpdate
DOUBLE dice mode (2d6) ✅ game.js::_rollDiceUpdate
Dice mode toggle in setup ✅ ui.js::_drawSetup
Dice mode toggle during game (Switch Roll Dice button) ✅ game.js::handleToggleDiceMode, ui.js::_drawHUD
In DOUBLE: total steps + 50% KC penalty per move ✅ game.js::_rollDiceUpdate, game.js::_executeMove
Doubles → exactly 1 extra turn (maxExtraPerTurn: 1) ✅ game.js::_rollDiceUpdate, game.js::_advanceTurn
Highlight valid destination tiles ✅ board.js::_drawTiles, game.js::_enterMove
Token selection + destination click ✅ game.js::_handleMoveClick
Token movement animation along isometric path ✅ entities.js::Token::updateAnim
Kick opponent token to safe zone ✅ game.js::_beginLandResolution
KC (Ladder Points) from KC tiles ✅ game.js::_beginLandResolution → token.addKC()
Token-carried KC (individual per token) ✅ entities.js::Token::carriedKC, Player::ladderPoint getter
DOUBLE dice penalty (50% KC loss per move) ✅ game.js::_executeMove
Gate opens at 600 KC ✅ entities.js::Player::checkGate, HUD indicator
Win by reaching ladder destination tile ✅ game.js::_beginLandResolution (LADDER_DEST)
Ladder entry from safe zone when gate is open ✅ game.js::_enterMove
Rankings by KC on end screen ✅ game.js::getRankings, ui.js::_drawEndGame
Title screen "CCN2 Hotseat Demo" ✅ ui.js::_drawTitle
Setup: choose players, start match ✅ ui.js::_drawSetup
In-game HUD: player indicator, dice, KC table, log ✅ ui.js::_drawHUD
"Roll Dice" button ✅ ui.js::_drawHUD
"Switch Roll Dice" button ✅ ui.js::_drawHUD
Extra turn indicator ✅ ui.js::_drawHUD
End screen: winner, KC table, restart ✅ ui.js::_drawEndGame
Space = Roll dice ✅ game.js::_waitPlayerUpdate
Esc = Pause/unpause overlay ✅ game.js::_togglePause
F1 = Debug overlay ✅ game.js + ui.js::_drawDebug
1136×640 logical resolution ✅ rules.js::CONFIG, main.js
requestAnimationFrame loop with delta time ✅ main.js::loop
Canvas scales to window ✅ main.js::resize
Deterministic restart ✅ game.js::handleRestart
Token sprite images (from studioccn2 assets) ✅ main.js::preloadAssets, entities.js::Token::draw
Board background & tile sprites (isometric) ✅ main.js::preloadAssets, board.js::_drawBoardBG, board.js::_drawTiles
Character avatars in UI ✅ main.js::preloadAssets, ui.js
Sound effects (from clientccn2/res/) ✅ utils.js::playSound
Custom font (from clientccn2/res/fonts/) ✅ style.css::@font-face

Keyboard Shortcuts

Key Action
Space Roll dice (when in WAIT_PLAYER)
Esc Toggle pause overlay
F1 Toggle debug overlay (FPS, state, token positions)

Manual Test Cases

# Test Case Steps Expected Result
1 Game start Open index.html Title screen visible; Start button clickable
2 Setup → 2 players SINGLE Click Start → choose 2, SINGLE, Start Match Match begins; Green player, Roll Dice button visible
3 Roll dice Click Roll Dice Scramble animation plays, then die shows 1–6; state moves to MOVE
4 Token selection In MOVE state, click on a token Token highlighted; destination tile highlighted with yellow border
5 Token move Click destination tile after selecting token Token animates along tiles to destination; landing effects fire
6 DOUBLE mode – use both dice Setup with DOUBLE; roll dice Two dice shown; pick first die → move; then second die → move
7 Doubles extra turn In DOUBLE mode, roll matching numbers (e.g. 3–3) "Extra turn granted!" message; same player rolls again
8 Kick Land token on tile occupied by opponent Kick sound; opponent token returns to their safe zone
9 No kick in safe zone Opponent token on a safe-zone tile; current player lands there No kick occurs
10 KC accumulation (token-carried) Land on any KC tile (🪜) +100 KC awarded to landing token; per-token KC shown in HUD
11 Gate opens at 600 KC Reach 600 total KC across both tokens "Gate is open!" message; gate indicator appears
11c DOUBLE penalty In DOUBLE mode, move a token with KC Token loses 50% KC before moving; penalty logged
11d DOUBLE penalty strategy Compare KC in SINGLE vs DOUBLE SINGLE preserves KC; DOUBLE bleeds KC each move
11b Ladder destination win With gate open, move token to safe zone, then choose ladder dest Token moves to centre tile; "🏆 wins!" message
12 4 players Setup with 4 players All 4 players cycle in order (Green→Red→Blue→Yellow→Green…)
13 Switch dice mode mid-game Click dice mode button in HUD during WAIT_PLAYER Mode toggles; next roll uses new mode
14 Pause and resume Press Esc during gameplay Pause overlay shown; Esc or Resume button restores game
15 Restart from end screen Click Play Again on end screen Returns to title screen; clean state
16 Two tokens same tile Both tokens of same player land on same tile Both tokens visible (offset); no self-kick

Out of Scope / Simplifications

Feature Status Note
Full Ladder Lane (private 6-tile track) ⛔ Simplified Simplified to single destination tile per player at board centre
Final Tile exact-roll requirement ⛔ Out of scope Token moves directly from safe zone to destination tile
Skill cards / Passive abilities ⛔ Out of scope Cards system not implemented
Diamond economy / theft ⛔ Simplified Diamonds tracked but not stolen on kick (only token returns)
Round Events ⛔ Out of scope No periodic global events
Server-authoritative validation ⛔ N/A Client-only demo; no server
Both dice used in DOUBLE mode ✅ Player makes 2 moves per turn, one per die
Auto-play / AI ✅ Implemented 3 levels (Easy/Medium/Hard) via ai.js::BotController; setup toggle per player
Consumable boosters / re-roll ⛔ Out of scope Not implemented
Background music ⛔ Out of scope Sound effects only

Project File Structure

DEMO/
├── index.html          — HTML shell, script load order
├── style.css           — Dark background, @font-face, canvas scaling
├── README.md           — This file
└── src/
    ├── rules.js        — CONFIG, TILE_TYPE, GAME_STATE, DICE_MODE, TILE_DEFS
    ├── utils.js        — Math, geometry, canvas helpers, sound manager
    ├── entities.js     — Token class (carriedKC, animation, rendering), Player class (computed KC)
    ├── board.js        — Board class: tile data, path building, rendering
    ├── input.js        — InputHandler: mouse/touch/keyboard → logical coords
    ├── ai.js           — BotController: AI decision-making (3 difficulty levels)
    ├── game.js         — Game state machine (all 9 states, DOUBLE penalty)
    ├── ui.js           — All screen rendering + button registration/handling
    └── main.js         — Canvas setup, asset preloading, requestAnimationFrame loop

External resources used (relative paths from DEMO/):

  • ../clientccn2/res/fonts/font_game_bold.ttf — In-game font
  • ../clientccn2/res/audio/sound/sound_*.mp3 — Sound effects
  • ../studioccn2/cocosstudio/high/game/ — Token flags, character avatars, board BG, tile sprites, UI sprites

All external resources gracefully fall back (procedural rendering, sans-serif font) if not found.


Publishing Instructions

GitHub Pages

# From D:\PROJECT\CCN2\
git init
git add DEMO/
git commit -m "Add CCN2 Hotseat Demo"
git branch -M main
git remote add origin https://github.com/<your-username>/ccn2-demo.git
git push -u origin main

# In GitHub → Settings → Pages → Source: main / root (or /DEMO)
# Game URL: https://<your-username>.github.io/ccn2-demo/DEMO/

Note: Token images and audio reference ../clientccn2/res/ — these paths will only resolve if you also commit clientccn2/res/ to the same repo. The demo works without them (canvas fallbacks are active).

Vercel (recommended)

# From D:\PROJECT\CCN2\
bash DEMO/build-deploy.sh       # Build self-contained deploy folder
cd deploy && npx vercel --prod --yes

The build script copies DEMO source + all referenced assets (fonts, audio, sprites) into deploy/ so relative ../ paths resolve correctly. Root / redirects to /DEMO/.

Live URL: https://deploy-eight-beta-49.vercel.app

Netlify (drag-and-drop)

  1. Go to netlify.com → Add new site → Deploy manually
  2. Drag the entire DEMO/ folder into the deploy dropzone
  3. Netlify publishes at a random .netlify.app URL instantly
  4. (Token images and audio will be missing unless clientccn2/res/ is included)

Local (simplest)

Just open DEMO/index.html directly in Chrome/Edge. Firefox may block local file:// audio; use Chrome or a local web server.

# Quick local server (Python 3):
cd D:/PROJECT/CCN2
python -m http.server 8080
# Then open: http://localhost:8080/DEMO/

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0