1- import { useEffect , useState } from "react" ;
1+ import { useState } from "react" ;
22import { Link , useNavigate } from "react-router-dom" ;
33import { PieceType } from "../engine/board" ;
44import { useGame } from "../GameContext" ;
@@ -16,11 +16,6 @@ export function NewGameScreen() {
1616 const [ portalOpponentKind , setPortalOpponentKind ] = useState < "two-player" | "bot" > ( "bot" ) ;
1717 const [ portalAdjacencyRule , setPortalAdjacencyRule ] = useState < boolean > ( false ) ;
1818 const [ portalMax , setPortalMax ] = useState < 1 | 2 | 3 > ( 1 ) ;
19- const maxLevel = kind === "bot" ? 20 : 10 ;
20-
21- useEffect ( ( ) => {
22- if ( level > maxLevel ) setLevel ( maxLevel ) ;
23- } , [ level , maxLevel ] ) ;
2419
2520 const ensureProfile = ( name : string ) : string => {
2621 const trimmed = name . trim ( ) ;
@@ -34,30 +29,30 @@ export function NewGameScreen() {
3429 } ;
3530
3631 const start = ( ) => {
32+ updateSetting ( "timerSeconds" , timer ) ;
33+
3734 // Ensure white profile exists and is active — stats are tied to this name
3835 const w = ensureProfile ( whiteName || "Player 1" ) ;
3936 const wProf = store . profiles . find ( ( p ) => p . name . toLowerCase ( ) === w . toLowerCase ( ) ) ;
4037 if ( wProf ) setActiveProfile ( wProf . id ) ;
4138
4239 if ( kind === "two-player" ) {
4340 const b = ensureProfile ( blackName || "Player 2" ) ;
44- newGame ( { kind : "two-player" } , { w, b } , { timerSeconds : timer } ) ;
41+ newGame ( { kind : "two-player" } , { w, b } ) ;
4542 } else if ( kind === "bot" ) {
46- newGame ( { kind : "bot" , level } , { w, b : `Bot Lv ${ level } ` } , { timerSeconds : timer } ) ;
43+ newGame ( { kind : "bot" , level } , { w, b : `Bot Lv ${ level } ` } ) ;
4744 } else {
4845 // Portal Chess
4946 if ( portalOpponentKind === "two-player" ) {
5047 const b = ensureProfile ( blackName || "Player 2" ) ;
5148 newGame (
5249 { kind : "portal" , opponent : "two-player" , creator : portalCreator , adjacencyRule : portalAdjacencyRule , portalMax } ,
53- { w, b } ,
54- { timerSeconds : timer }
50+ { w, b }
5551 ) ;
5652 } else {
5753 newGame (
5854 { kind : "portal" , opponent : { kind : "bot" , level } , creator : portalCreator , adjacencyRule : portalAdjacencyRule , portalMax } ,
59- { w, b : `Bot Lv ${ level } ` } ,
60- { timerSeconds : timer }
55+ { w, b : `Bot Lv ${ level } ` }
6156 ) ;
6257 }
6358 }
@@ -69,7 +64,10 @@ export function NewGameScreen() {
6964
7065 return (
7166 < div className = "screen" >
72- < div className = "topbar" > < Link to = "/" > ← Home</ Link > </ div >
67+ < div className = "topbar" >
68+ < Link to = "/" > ← Home</ Link >
69+ < Link to = "/settings" > ⚙ Settings</ Link >
70+ </ div >
7371 < h2 > New Game</ h2 >
7472
7573 < section >
@@ -150,8 +148,8 @@ export function NewGameScreen() {
150148 </ label >
151149 < p className = "hint" >
152150 When ticked, teleport targets cannot be adjacent to any other piece.
153- When unticked (default), you can teleport to any empty square
154- except the portal square itself .
151+ When unticked (default), you can teleport anywhere empty — or stay
152+ on the portal square (the portal remains active) .
155153 </ p >
156154 </ section >
157155 </ >
@@ -202,34 +200,11 @@ export function NewGameScreen() {
202200 </ section >
203201 ) }
204202
205- { showBlackName && (
206- < section >
207- < h3 > Board orientation (2-player)</ h3 >
208- < label >
209- < input
210- type = "checkbox"
211- checked = { store . settings . autoFlip }
212- onChange = { ( e ) => updateSetting ( "autoFlip" , e . target . checked ) }
213- />
214- { " " } Auto-turn board after each move
215- </ label >
216- < label >
217- < input
218- type = "checkbox"
219- checked = { store . settings . rotateBlackPiecesFixedBoard }
220- onChange = { ( e ) => updateSetting ( "rotateBlackPiecesFixedBoard" , e . target . checked ) }
221- />
222- { " " } Rotate black pieces 180° when board is fixed
223- </ label >
224- < p className = "hint" > Turn off auto-turn to keep the board fixed from White's side. Optional: rotate black pieces for over-the-board seating.</ p >
225- </ section >
226- ) }
227-
228203 { showLevel && (
229204 < section >
230205 < h3 > Bot difficulty</ h3 >
231206 < div className = "difficulty" >
232- { Array . from ( { length : maxLevel } , ( _ , i ) => i + 1 ) . map ( ( lv ) => (
207+ { Array . from ( { length : 10 } , ( _ , i ) => i + 1 ) . map ( ( lv ) => (
233208 < button
234209 key = { lv }
235210 className = { lv === level ? "pill active" : "pill" }
@@ -238,9 +213,7 @@ export function NewGameScreen() {
238213 ) ) }
239214 </ div >
240215 < p className = "hint" >
241- { kind === "bot"
242- ? "Level 1 is very easy (good for a new learner). Levels 5-20 use an external chess engine for stronger play."
243- : "Portal-bot mode uses the built-in engine and supports levels 1-10." }
216+ Level 1 is very easy (good for a new learner). Levels 6+ use a stronger engine when available.
244217 </ p >
245218 </ section >
246219 ) }
0 commit comments