diff --git a/src/App.js b/src/App.js
index fa82e62..2c6b4cb 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,194 +1,28 @@
-import { useState } from "react";
-import { useLocation } from 'react-router-dom';
+import React from 'react';
+import { Link } from 'react-router-dom';
-function Square({ row, column, value, clickHandler }) {
- let buttonClass = ""
- switch (value){
- case "X":
- buttonClass = "square bg-amber-200 "
- break;
- case "O":
- buttonClass = "square bg-violet-300"
- break;
- default:
- buttonClass = "square bg-white"
- break;
- }
- return (
-
- );
-}
-
-function SquareRow({ rowId, rows, clickHandler }) {
- const items =
- rows.map((ele, index) =>
-
- );
-
- return <>{items}>;
-}
-
-function Map({ mapSize }) {
- // Config Here
- const ticTacToeMaxMapSize = 6
-
- if (mapSize == undefined) {
- mapSize = 3;
- }
- const [map, setMap] = useState(
- Array(mapSize).fill(null)
- .map(() => Array(mapSize).fill(null))
- );
- const [currentMove, setCurrentMove] = useState(0);
- const xIsNext = currentMove % 2 == 0;
- const [winner, setWinner] = useState(null);
- const [history, setHistory] = useState([Array(mapSize).fill(null)
- .map(() => Array(mapSize).fill(null))])
-
- function updateMap(nextMap) {
- setHistory([...history, nextMap])
- setMap(nextMap)
- }
-
- function handleClick(row, column) {
- if (map[row][column] != null || winner != null) {
- return
- }
- const nextMap = map.map(row => [...row]);
- if (xIsNext) {
- nextMap[row][column] = 'X'
- } else {
- nextMap[row][column] = 'O'
- }
- updateMap(nextMap)
- setCurrentMove(currentMove + 1)
- if (calculateWinner(row, column,nextMap)) {
- setWinner(nextMap[row][column])
- }
- }
-
- function calculateWinner(row, column,map) {
- const who = map[row][column]; // 当前玩家标记
- const winNeed = mapSize > ticTacToeMaxMapSize ? 5 : mapSize; // 棋盘大小(>5五子棋)
-
- // 横向检查
- let horizontal = 1;
- for (let hLeft = column - 1; hLeft >= 0; hLeft--) {
- if (map[row][hLeft] !== who) break;
- horizontal++;
- }
- for (let hRight = column + 1; hRight < mapSize; hRight++) {
- if (map[row][hRight] !== who) break;
- horizontal++;
- }
- if (horizontal >= winNeed) return true;
-
- // 纵向检查
- let vertical = 1;
- for (let vUp = row - 1; vUp >= 0; vUp--) {
- if (map[vUp][column] !== who) break;
- vertical++;
- }
- for (let vDown = row + 1; vDown < mapSize; vDown++) {
- if (map[vDown][column] !== who) break;
- vertical++;
- }
- if (vertical >= winNeed) return true;
-
- // 主对角线 (左上到右下)
- let mainDiagonal = 1;
- for (let dUp = 1; row - dUp >= 0 && column - dUp >= 0; dUp++) {
- if (map[row - dUp][column - dUp] !== who) break;
- mainDiagonal++;
- }
- for (let dDown = 1; row + dDown < mapSize && column + dDown < mapSize; dDown++) {
- if (map[row + dDown][column + dDown] !== who) break;
- mainDiagonal++;
- }
- if (mainDiagonal >= winNeed) return true;
-
- // 副对角线 (右上到左下)
- let antiDiagonal = 1;
- for (let dUp = 1; row - dUp >= 0 && column + dUp < mapSize; dUp++) {
- if (map[row - dUp][column + dUp] !== who) break;
- antiDiagonal++;
- }
- for (let dDown = 1; row + dDown < mapSize && column - dDown >= 0; dDown++) {
- if (map[row + dDown][column - dDown] !== who) break;
- antiDiagonal++;
- }
- if (antiDiagonal >= winNeed) return true;
-
- // 如果没有满足条件,返回 false
- return false;
- }
-
- const mapEle = map.map((ele, index) => (
-
{/* Unique key for each row */}
-
-
- ));
-
- function handleLeftClick() {
- if (currentMove > 0) {
- setMap(history[currentMove - 1]);
- setCurrentMove(currentMove - 1);
- setHistory(history.slice(0, -1));
- setWinner(null);
- }
- }
+const NameList = () => {
+ const names = ['tictactoe'];
return (
-
-
{mapSize > ticTacToeMaxMapSize ? "五子棋" : "井字棋"}模式
-
现在是 {xIsNext ? "X" : "O"} 移动
-
-
- {mapEle}
-
+
+
+
想看看什么
+
+ {names.map((name) => (
+ -
+
+ {name.toUpperCase()}
+
+
+ ))}
+
-
-
-
-
{winner != null ? winner + "赢了" : ""}
);
-}
+};
-export default function Game(){
- const location = useLocation();
- const params = new URLSearchParams(location.search);
- const useSize = params.get('mapSize');
- let realSize = parseInt(useSize)
- if (realSize == NaN || realSize < 3 || realSize > 20){
- realSize = 3
- }
- return(
- <>
-