Skip to content

Commit ef5ea10

Browse files
committed
feat: use board instead of complete board
1 parent 3c01264 commit ef5ea10

File tree

6 files changed

+10
-155
lines changed

6 files changed

+10
-155
lines changed

src/Components/ShowAllBoards/ShowAllBoards.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import ShowCards from "../ShowCards/ShowCards";
22
import "./index.css"
3-
import { CompleteBoard, ShowResultsContext } from "../../views/Show/ShowResults";
3+
import { ShowResultsContext } from "../../views/Show/ShowResults";
44
import { PropsWithChildren } from "react";
5+
import Board from "../../models/Board";
56

67
interface ShowAllBoardsProps extends PropsWithChildren {
78
beautify?: boolean;
@@ -15,7 +16,7 @@ export default function ShowAllBoards(props: ShowAllBoardsProps) {
1516
(context) =>
1617
(
1718
<div className="all-boards">
18-
{context.all_boards.map((board: CompleteBoard, idx: number) => <ShowCards key={idx} board={board.board} dds={context.dds} {...props} />)}
19+
{context.all_boards.map((board: Board, idx: number) => <ShowCards key={idx} board={board} dds={context.dds} {...props} />)}
1920
</div>
2021
)
2122
}

src/models/Board.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default class Board {
2626
Shand: Hand;
2727
Ehand: Hand;
2828
Whand: Hand;
29+
ddsTricks?: string | (string | number)[][];
2930

3031
constructor(boardnum: number) {
3132
this.boardnum = boardnum;

src/views/Analysis/Analysis.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ function Analysis() {
3535
useMemo(() => {
3636
async function countTricks() {
3737
for (const board of all_boards) {
38-
if (!board.ddtricks) {
39-
board.ddtricks = await analyzeOffline(board.board.getAllHands());
38+
if (!board.ddsTricks) {
39+
board.ddsTricks = await analyzeOffline(board.getAllHands());
4040
}
41-
tmp = MatrixAdd(tmp, board.ddtricks as (string | number)[][]);
41+
tmp = MatrixAdd(tmp, board.ddsTricks as (string | number)[][]);
4242
}
4343
return Promise.resolve(tmp);
4444
}

src/views/AnalysisOnline(abandoned)/DealWithAnalysis.tsx

Lines changed: 0 additions & 142 deletions
This file was deleted.

src/views/Deal/DealWithHands.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export default function DealWithHands() {
134134

135135
</div>
136136
{useMemo(
137-
() => <ShowResults all_boards={boards.map((b: Board) => { return { board: b } })} beautify={beautify} dds={DDS} />,
137+
() => <ShowResults all_boards={boards} beautify={beautify} dds={DDS} />,
138138
[DDS, beautify, boards]
139139
)}
140140
</>

src/views/Show/ShowResults.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,14 @@ import ShowAllBoards from "../../Components/ShowAllBoards/ShowAllBoards";
33
import Analysis from "../Analysis/Analysis";
44
import Board from "../../models/Board";
55

6-
export interface CompleteBoard {
7-
board: Board;
8-
ddtricks?: (string | number)[][] | string;
9-
}
10-
116
interface ShowResultsProps {
12-
all_boards: CompleteBoard[];
7+
all_boards: Board[];
138
dds: boolean;
149
beautify?: boolean;
1510
}
1611

1712
interface ShowResultsContextProps {
18-
all_boards: CompleteBoard[];
13+
all_boards: Board[];
1914
dds: boolean;
2015
}
2116

0 commit comments

Comments
 (0)