Skip to content

Commit

Permalink
refactor: remove abandoned components
Browse files Browse the repository at this point in the history
  • Loading branch information
S-N-O-R-L-A-X committed Feb 7, 2024
1 parent 070646d commit 9b78eef
Show file tree
Hide file tree
Showing 20 changed files with 43 additions and 53 deletions.
4 changes: 2 additions & 2 deletions src/Components/HandSetting/HandSetting.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState, ChangeEvent, HTMLAttributes, forwardRef, Ref, createContext } from "react";
import { Position } from "../../Utils/maps";
import Card from "../../views/Deal/Card";
import { OneFilterProps } from "../../views/Deal/HandFilter";
import Card from "../../models/Card";
import { OneFilterProps } from "../../models/HandFilter";
import api from "../Alert";
import HandShape from "./HandShape";
import HandSolid from "./HandSolid";
Expand Down
4 changes: 2 additions & 2 deletions src/Components/PlayBoard/MyPlayBoard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Board from "../../views/Deal/Board";
import Hand from "../../views/Deal/Hand";
import Board from "../../models/Board";
import Hand from "../../models/Hand";
import ShowCards from "../ShowCards/ShowCards";
import ShowTricks from "./ShowTricks";

Expand Down
2 changes: 1 addition & 1 deletion src/Components/ShowCards/ShowCards.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Hand from "../../views/Deal/Hand";
import Hand from "../../models/Hand";
import ShowOneHand from "./ShowOneHand";

import "./index.css";
Expand Down
2 changes: 1 addition & 1 deletion src/Components/ShowCards/ShowOneHand.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Hand from "../../views/Deal/Hand";
import Hand from "../../models/Hand";
import { HTMLAttributes, ReactNode } from "react"
import { NUMBER2COLOR, NUMBER2COLORICON, NUMBER2COLORSHORT, Position, POSITION2FULL } from "../../Utils/maps";
import { callDDSOL } from "../../Utils/callInterface";
Expand Down
3 changes: 1 addition & 2 deletions src/Components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ export default function Sidebar() {
<li><Link to="/">Home</Link></li>
{/* <li><Link to="deal">Deal With One Hand Setting</Link></li> */}
<li><Link to="deal-multi">Deal With Multi Hands Setting</Link></li>
<li><Link to="analysis">Analysis</Link></li>
<li><Link to="play-board">Play Board</Link></li>
<li><a href="https://www.ccba.org.cn/wbf20vp/" target="_blank">imp to vp</a></li>
<li>Calculate points of contract</li>
{/* <li>Calculate points of contract</li> */}
<li><a href="http://playbridge.com/pb_shuffle_project.php" target="_blank">一个其他的发牌网站</a></li>
<li><a href="https://bridge.esmarkkappel.dk/main/main.html" target="_blank">单套结构打法</a></li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/callInterface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Hand from "../views/Deal/Hand";
import Hand from "../models/Hand";
import { retryFetch, parseHand } from "./utils";

interface RequestBoard {
Expand Down
4 changes: 2 additions & 2 deletions src/Utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Card from "../views/Deal/Card";
import Hand from "../views/Deal/Hand";
import Card from "../models/Card";
import Hand from "../models/Hand";
import { COLORS, NUMBER2COLORSHORT, RANK2CARD } from "./maps";

export function idx2card(idx: number): Card {
Expand Down
14 changes: 1 addition & 13 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { RouterProvider, createHashRouter } from 'react-router-dom'
import App from './App'
import PlayBoard from './Components/PlayBoard/PlayBoard'
import './index.css'
import Analysis from './views/Analysis/Analysis'
import BridgeSolver from './views/Analysis/BridgeSolverOnline'
import DealWithAnalysis from './views/Deal/DealWithAnalysis'
import BridgeSolver from './views/AnalysisOnline(abandoned)/BridgeSolverOnline'
import DealWithHands from './views/Deal/DealWithHands'

const route_info = [
Expand All @@ -20,21 +18,11 @@ const route_info = [
title: "设置多家牌进行发牌",
element: <DealWithHands />
},
{
path: "/analysis",
title: "分析",
element: <Analysis />
},
{
path: "/solver",
title: "分析",
element: <BridgeSolver />
},
// {
// path: "/deal-analysis",
// title: "分析",
// element: <DealWithAnalysis />
// },
{
path: "/play-board",
title: "打牌面板",
Expand Down
2 changes: 1 addition & 1 deletion src/views/Deal/Board.ts → src/models/Board.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Hand from "./Hand";
import Card from "./Card";
import { card2idx } from "../../Utils/utils";
import { card2idx } from "../Utils/utils";

function shuffleAlgo(arr: any[]) {
let n = arr.length, rand;
Expand Down
2 changes: 1 addition & 1 deletion src/views/Deal/Card.ts → src/models/Card.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ColorsShort } from "../../Utils/maps";
import { ColorsShort } from "../Utils/maps";

export default class Card {
static SUIT: ColorsShort[] = ["S", "H", "D", "C"];
Expand Down
2 changes: 1 addition & 1 deletion src/views/Deal/Hand.ts → src/models/Hand.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ColorsShort } from "../../Utils/maps";
import { ColorsShort } from "../Utils/maps";
import Card from "./Card";
export default class Hand {
cards: Card[];
Expand Down
7 changes: 0 additions & 7 deletions src/views/Deal/HandFilter.ts → src/models/HandFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@ function oneHandFilter(props: OneHandFilterProps) {
return false;
}

// if (cards.length > 0) {
// for (const card of hand.cards) {
// if (!cards.some(c => c.suit === card.suit && c.rank === card.rank)) {
// return false;
// }
// }
// }
return true;

}
Expand Down
4 changes: 2 additions & 2 deletions src/views/Analysis/Analysis.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useEffect, useMemo, useState } from "react";
import React, { useContext, useMemo, useState } from "react";
import ShowTricks from "../../Components/PlayBoard/ShowTricks";
import { analyzeOffline } from "../../Utils/utils";
import { ShowResultsContext } from "../Show/ShowResults";
Expand Down Expand Up @@ -31,7 +31,7 @@ function Analysis() {
const context = useContext(ShowResultsContext);
const { all_boards } = context;

let tmp: number[][]=new Array(4).fill(0).map(() => new Array(5).fill(0))
let tmp: number[][] = new Array(4).fill(0).map(() => new Array(5).fill(0));
useMemo(() => {
async function countTricks() {
for (const board of all_boards) {
Expand Down
2 changes: 1 addition & 1 deletion src/views/Analysis/OfflineBridgeSolver.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from "react";
import ShowTricks from "../../Components/PlayBoard/ShowTricks";
import Hand from "../Deal/Hand";
import Hand from "../../models/Hand";
import { analyzeOffline } from "../../Utils/utils";

interface BridgeSolverProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Hand from "../Deal/Hand";
import Hand from "../../models/Hand";
import BridgeSolver from "./BridgeSolverOnline";

interface AllBridgeSolverOnlineProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useEffect, useState } from "react";
import ShowTricks from "../../Components/PlayBoard/ShowTricks";
import ShowCards from "../../Components/ShowCards/ShowCards";
import { callDDSOL } from "../../Utils/callInterface";
import Hand from "../Deal/Hand";
import Hand from "../../models/Hand";

interface RequestSpecificTrump {
trumps: "s" | "h" | "d" | "c" | "n";
Expand Down
9 changes: 9 additions & 0 deletions src/views/AnalysisOnline(abandoned)/DealContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createContext } from "react";

export interface DealContextProps {
contextType: string;
known_cards: number[];
changeKnown_cards: Function;
}

export const DealContext = createContext<DealContextProps>({ contextType: "analysis", known_cards: new Array(52).fill(-1), changeKnown_cards: () => {} });
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import Hand from "./Hand";
import Board from "./Board";
import handFilter, { OneFilterProps } from "./HandFilter";
import Hand from "../../models/Hand";
import Board from "../../models/Board";
import handFilter, { OneFilterProps } from "../../models/HandFilter";
import { useState, ChangeEvent, useRef, useCallback } from "react";
import HandSetting from "../../Components/HandSetting/HandSetting";

import "./index.css";
import Card from "./Card";
import Card from "../../models/Card";
import { idx2card } from "../../Utils/utils";
import { Position, PROGRAM_POSITIONS } from "../../Utils/maps";
import { DealContext } from "./DealContext";
import AllBridgeSolverOnline from "../Analysis/AllBridgeSolverOnline";
import { DealContext } from "../Deal/DealContext";
import AllBridgeSolverOnline from "./AllBridgeSolverOnline";

function deal(boardSize: number, hand_filter: Record<string, OneFilterProps>) {
const boards: Hand[][] = [];
Expand Down
15 changes: 8 additions & 7 deletions src/views/Deal/DealWithHands.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Hand from "./Hand";
import Board from "./Board";
import handFilter, { OneFilterProps } from "./HandFilter";
import Hand from "../../models/Hand";
import Board from "../../models/Board";
import handFilter, { OneFilterProps } from "../../models/HandFilter";
import { useState, ChangeEvent, useRef, useCallback, useMemo } from "react";
import HandSetting from "../../Components/HandSetting/HandSetting";

import "./index.css";
import Card from "./Card";
import Card from "../../models/Card";
import { idx2card } from "../../Utils/utils";
import { Position, PROGRAM_POSITIONS } from "../../Utils/maps";

Expand Down Expand Up @@ -127,9 +127,10 @@ export default function DealWithHands() {
<button onClick={handleClick}>Get new boards</button>

</div>
{/* <ShowResults all_boards={boards.map((x) => { return { board: x } })} beautify={beautify} dds={DDS} /> */}
{useMemo(() => <ShowResults all_boards={boards.map((x) => { return { board: x } })} beautify={beautify} dds={DDS} />
, [DDS, beautify, boards])}
{useMemo(
() => <ShowResults all_boards={boards.map((x) => { return { board: x } })} beautify={beautify} dds={DDS} />,
[DDS, beautify, boards]
)}
</>
)
}
2 changes: 1 addition & 1 deletion src/views/Show/ShowResults.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { createContext } from "react";
import ShowAllBoards from "../../Components/ShowAllBoards/ShowAllBoards";
import Hand from "../Deal/Hand";
import Hand from "../../models/Hand";
import Analysis from "../Analysis/Analysis";

export interface CompleteBoard {
Expand Down

0 comments on commit 9b78eef

Please sign in to comment.