From 7fd1fc4f363cf1195f93b5f3365bcee02bf60d54 Mon Sep 17 00:00:00 2001 From: S-N-O-R-L-A-X Date: Sun, 3 Mar 2024 10:32:39 +0800 Subject: [PATCH] refactor: small enhancement --- architecture.drawio | 22 ++++++++++++++++++++-- src/models/HandFilter.ts | 2 +- src/views/Deal/DealWithHands.tsx | 14 ++++++++++---- src/views/Show/ShowResults.tsx | 2 +- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/architecture.drawio b/architecture.drawio index dad457d..9932036 100644 --- a/architecture.drawio +++ b/architecture.drawio @@ -1,6 +1,6 @@ - + @@ -106,12 +106,30 @@ - + + + + + + + + + + + + + + + + + + + diff --git a/src/models/HandFilter.ts b/src/models/HandFilter.ts index 8522c03..79abe5e 100644 --- a/src/models/HandFilter.ts +++ b/src/models/HandFilter.ts @@ -21,7 +21,7 @@ export interface HandFilterProps { [key: string]: OneHandFilterProps; } -function oneHandFilter(props: OneHandFilterProps) { +function oneHandFilter(props: OneHandFilterProps): boolean { const { hand, points = [0, 37], shapes = null, maxsuit = 13, minsuit = 0, havesuit = null, solid = false, maxace = 4, minace = 0, cards = [], ambiguousShape } = props; if (hand.points < points[0] || hand.points > points[1]) { return false; diff --git a/src/views/Deal/DealWithHands.tsx b/src/views/Deal/DealWithHands.tsx index 21126ca..42a2cc6 100644 --- a/src/views/Deal/DealWithHands.tsx +++ b/src/views/Deal/DealWithHands.tsx @@ -1,17 +1,23 @@ +import { useState, ChangeEvent, useRef, useCallback, useMemo } from "react"; + +// import models 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 "../../models/Card"; + +// import utils import { idx2card } from "../../Utils/utils"; import { Position, PROGRAM_POSITIONS } from "../../Utils/maps"; +// import other components +import HandSetting from "../../Components/HandSetting/HandSetting"; import { DealContext } from "./DealContext"; import ShowResults from "../Show/ShowResults"; +// import css +import "./index.css"; + function deal(boardSize: number, hand_filter: Record) { const boards: Hand[][] = []; while (boardSize--) { diff --git a/src/views/Show/ShowResults.tsx b/src/views/Show/ShowResults.tsx index 25c7d25..4b722cc 100644 --- a/src/views/Show/ShowResults.tsx +++ b/src/views/Show/ShowResults.tsx @@ -1,4 +1,4 @@ -import React, { createContext } from "react"; +import { createContext } from "react"; import ShowAllBoards from "../../Components/ShowAllBoards/ShowAllBoards"; import Hand from "../../models/Hand"; import Analysis from "../Analysis/Analysis";