@@ -103,6 +103,12 @@ export const TOOL_DEFINITIONS = [
103103 description : 'AI difficulty level' ,
104104 default : 'medium' ,
105105 } ,
106+ playerSymbol : {
107+ type : 'string' ,
108+ enum : [ 'X' , 'O' ] ,
109+ description : 'Your symbol: X (goes first) or O (goes second)' ,
110+ default : 'X' ,
111+ } ,
106112 } ,
107113 required : [ ] ,
108114 } ,
@@ -202,9 +208,12 @@ export async function handleToolCall(name: string, args: any, server?: any) {
202208 const {
203209 playerName : ticTacToePlayerName = 'Player' ,
204210 gameId : ticTacToeNewGameId ,
205- aiDifficulty : ticTacToeAiDifficulty = 'medium'
211+ aiDifficulty : ticTacToeAiDifficulty = 'medium' ,
212+ playerSymbol : ticTacToePlayerSymbol = 'X'
206213 } = args
207- return await createGame ( 'tic-tac-toe' , ticTacToePlayerName , ticTacToeNewGameId , ticTacToeAiDifficulty )
214+
215+ const ticTacToeGameOptions = ticTacToePlayerSymbol ? { playerSymbol : ticTacToePlayerSymbol } : undefined
216+ return await createGame ( 'tic-tac-toe' , ticTacToePlayerName , ticTacToeNewGameId , ticTacToeAiDifficulty , ticTacToeGameOptions )
208217
209218 case 'create_rock_paper_scissors_game' :
210219 const {
@@ -262,8 +271,17 @@ async function createGameInteractive(gameType: string, gameId?: string, server?:
262271 const finalPlayerName = playerName || 'Player'
263272 const finalDifficulty = difficulty || 'medium'
264273
274+ // Prepare game-specific options
275+ const gameSpecificOptions : Record < string , any > = { }
276+ if ( gameType === 'tic-tac-toe' && playerSymbol ) {
277+ gameSpecificOptions . playerSymbol = playerSymbol
278+ }
279+ if ( gameType === 'rock-paper-scissors' && maxRounds ) {
280+ gameSpecificOptions . maxRounds = maxRounds
281+ }
282+
265283 // Create the game with elicited preferences
266- const gameResult = await createGame ( gameType , finalPlayerName , gameId , finalDifficulty )
284+ const gameResult = await createGame ( gameType , finalPlayerName , gameId , finalDifficulty , gameSpecificOptions )
267285
268286 // Add elicitation information to the response
269287 gameResult . elicitation = {
@@ -274,6 +292,11 @@ async function createGameInteractive(gameType: string, gameId?: string, server?:
274292 // Add game-specific messages
275293 if ( gameType === 'tic-tac-toe' && playerSymbol ) {
276294 gameResult . message += ` You are playing as ${ playerSymbol } .`
295+ if ( playerSymbol === 'X' ) {
296+ gameResult . message += ' You go first!'
297+ } else {
298+ gameResult . message += ' AI goes first!'
299+ }
277300 }
278301 if ( gameType === 'rock-paper-scissors' && maxRounds ) {
279302 gameResult . message += ` Playing ${ maxRounds } rounds.`
0 commit comments