Skip to content

Commit

Permalink
refactor: small enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
S-N-O-R-L-A-X committed Mar 3, 2024
1 parent 9b78eef commit 7fd1fc4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
22 changes: 20 additions & 2 deletions architecture.drawio
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<mxfile host="65bd71144e">
<diagram id="YeBg9FEWrei1k_hzMAZt" name="第 1 页">
<mxGraphModel dx="880" dy="515" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<mxGraphModel dx="880" dy="492" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
Expand Down Expand Up @@ -106,12 +106,30 @@
<mxCell id="29" value="ShowResults" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="400" y="420" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="33" style="edgeStyle=none;html=1;exitX=0.75;exitY=1;exitDx=0;exitDy=0;entryX=0.25;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="31" target="9">
<mxCell id="33" style="edgeStyle=none;html=1;exitX=0.75;exitY=1;exitDx=0;exitDy=0;entryX=0.25;entryY=0;entryDx=0;entryDy=0;" parent="1" source="31" target="9" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="31" value="Analysis" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="591" y="525" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="40" style="edgeStyle=none;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;fontSize=12;" edge="1" parent="1" source="34" target="38">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="34" value="DealWithAnalysis" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="70" y="870" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="35" value="&lt;font style=&quot;font-size: 14px;&quot;&gt;Abandoned&lt;br&gt;(online version)&lt;/font&gt;" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="70" y="800" width="120" height="50" as="geometry"/>
</mxCell>
<mxCell id="41" style="edgeStyle=none;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;fontSize=12;" edge="1" parent="1" source="38" target="39">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="38" value="AllBridgeSolverOnline" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="260" y="870" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="39" value="BridgeSolverOnline" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="440" y="870" width="120" height="60" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
Expand Down
2 changes: 1 addition & 1 deletion src/models/HandFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 10 additions & 4 deletions src/views/Deal/DealWithHands.tsx
Original file line number Diff line number Diff line change
@@ -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<string, OneFilterProps>) {
const boards: Hand[][] = [];
while (boardSize--) {
Expand Down
2 changes: 1 addition & 1 deletion src/views/Show/ShowResults.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down

0 comments on commit 7fd1fc4

Please sign in to comment.