txlyre 1 day ago
parent
commit
f6f843607f
2 changed files with 9 additions and 4 deletions
  1. 7 2
      chess0.py
  2. 2 2
      commands.py

+ 7 - 2
chess0.py

@@ -125,9 +125,14 @@ class ChessManager:
 
         return str(session.board)
 
-    def moves(self, id):
+    def moves(self, id, offset=None):
         session = self.sessions.get(id)
         if not session:
             raise KeyError(id)
 
-        return " ".join(map(str, session.board.move_stack))
+        if offset is not None:
+            moves = session.board.move_stack[-offset:]
+        else:
+            moves = session.board.move_stack
+
+        return " ".join(map(str, moves))

+ 2 - 2
commands.py

@@ -746,7 +746,7 @@ async def chess_board_handler(chess, id):
 
 async def chess_moves_handler(chess, id):
     try:
-        moves = chess.moves(id)
+        moves = f"Последние два хода: {chess.moves(id, 2)}\nВсе ходы (первый ход - игрока): {chess.moves(id)}"
     except KeyError:
         return ["Нет активной игры."]
 
@@ -761,7 +761,7 @@ CHESS_COMMANDS = {
     "skip": (chess_skip_handler, "Пропустить ход", 0),
     "pass": (chess_pass_handler, "Сделать ход вместо вас", 0),
     "board": (chess_board_handler, "Показать состояние доски", 0),
-    "moves": (chess_moves_handler, "Показать историю ходов (первый ход - игрока)", 0),
+    "moves": (chess_moves_handler, "Показать историю ходов", 0),
 }