From 2045bf98f7ef11f5be865e4931e2441f2c4dc6f1 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Mon, 6 Oct 2025 13:45:02 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mesh_bot.py | 2 +- modules/games/tictactoe.py | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index cad44ca..a060112 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -821,7 +821,7 @@ def handleTicTacToe(message, nodeID, deviceID): index = i+1 break - if "end" in message.lower(): + if message.lower().startswith('e'): if index: tictactoe.end(nodeID) tictactoeTracker.pop(index-1) diff --git a/modules/games/tictactoe.py b/modules/games/tictactoe.py index b6f101d..9eddc44 100644 --- a/modules/games/tictactoe.py +++ b/modules/games/tictactoe.py @@ -1,7 +1,8 @@ # Tic-Tac-Toe game for Meshtastic mesh-bot - +# Human is X, bot is O +# Board positions chosen by numbers 1-9 +# 2025 import random -import time class TicTacToe: def __init__(self): @@ -152,10 +153,16 @@ class TicTacToe: # Extract just the number from the input numbers = [char for char in input_msg if char.isdigit()] if not numbers: - return "Enter 1-9:" + if input_msg.lower().startswith('q'): + self.end_game(id) + return "Game ended. To start a new game, type 'tictactoe'." + elif input_msg.lower().startswith('n'): + return self.new_game(id) + elif input_msg.lower().startswith('b'): + return self.show_board(id) + "Your turn! Pick 1-9:" position = int(numbers[0]) except: - return "Enter 1-9:" + return "Enter 1-9, or (e)nd (n)ew game, send (b)oard to see board🧩" # Make player move if not self.make_move(id, position):