Compare commits
31 Commits
v57
...
Engine/boa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5425ccc5cd | ||
|
|
1104c8e6c5 | ||
|
|
274ffcf5ec | ||
|
|
5854dbc20b | ||
|
|
f36a196b2f | ||
|
|
11f26809df | ||
|
|
c88fbe68e3 | ||
|
|
7f4c53ddb7 | ||
|
|
38b38845d6 | ||
|
|
66dd2877b2 | ||
|
|
3cd53c7d70 | ||
|
|
5b3bdc750f | ||
| 83a73ed34c | |||
|
|
7c27d47935 | ||
|
|
4ffec0f05d | ||
|
|
da3b1c8c00 | ||
|
|
a497f8554f | ||
| 94b4d727a6 | |||
| 39273908ac | |||
| 5696128ac9 | |||
| c2e29415c9 | |||
| ff68d9d2d9 | |||
| 281f496c83 | |||
| 532c5a42ea | |||
| 73624baf90 | |||
| d8861b66b2 | |||
| 4123a710cf | |||
| 4daa21e8bf | |||
| 503cb23015 | |||
| 8ffbfdc63f | |||
| 8f9a48fa96 |
3
.github/workflows/dispatcher.yml
vendored
3
.github/workflows/dispatcher.yml
vendored
@@ -16,6 +16,9 @@ jobs:
|
||||
server: ${{ steps.check.outputs.server }}
|
||||
ui: ${{ steps.check.outputs.ui }}
|
||||
steps:
|
||||
- name: checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Determine which tests to run
|
||||
id: check
|
||||
run: |
|
||||
|
||||
2
.github/workflows/engine_test.yml
vendored
2
.github/workflows/engine_test.yml
vendored
@@ -9,8 +9,6 @@ jobs:
|
||||
runs-on: self-hosted
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Run Engine tests
|
||||
run: |
|
||||
bash .github/workflows/test.sh engine/
|
||||
|
||||
2
.github/workflows/server_test.yml
vendored
2
.github/workflows/server_test.yml
vendored
@@ -9,8 +9,6 @@ jobs:
|
||||
runs-on: self-hosted
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Run Server tests
|
||||
run: |
|
||||
bash .github/workflows/test.sh server/
|
||||
|
||||
2
.github/workflows/ui_test.yml
vendored
2
.github/workflows/ui_test.yml
vendored
@@ -9,8 +9,6 @@ jobs:
|
||||
runs-on: self-hosted
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Run UI tests
|
||||
run: |
|
||||
bash .github/workflows/test.sh ui/
|
||||
|
||||
BIN
Docs/Knightly rendszerterv v1.png
Normal file
BIN
Docs/Knightly rendszerterv v1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 288 KiB |
287
Docs/Knightly rendszerterv v1.xml
Normal file
287
Docs/Knightly rendszerterv v1.xml
Normal file
@@ -0,0 +1,287 @@
|
||||
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (X11; Linux x86_64; rv:144.0) Gecko/20100101 Firefox/144.0" version="28.2.9">
|
||||
<diagram name="Page-1" id="9d-IwT1pk2NoWoP7MTJv">
|
||||
<mxGraphModel dx="1534" dy="751" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="9999" pageHeight="9999" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-10" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-1" target="IaA3IaIvg4qVMEhu7ya9-36" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-1" value="App megnyitása" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="120" y="50" width="140" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-10" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-6" target="IaA3IaIvg4qVMEhu7ya9-9" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="540" y="120" />
|
||||
<mxPoint x="370" y="120" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-12" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-6" target="IaA3IaIvg4qVMEhu7ya9-11" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-13" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-6" target="IaA3IaIvg4qVMEhu7ya9-11" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-14" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-6" target="IaA3IaIvg4qVMEhu7ya9-11" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-15" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-6" target="IaA3IaIvg4qVMEhu7ya9-11" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-16" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-6" target="IaA3IaIvg4qVMEhu7ya9-18" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="670" y="180" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-21" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-6" target="IaA3IaIvg4qVMEhu7ya9-20" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-6" value="<div>főmenü</div>" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="480" y="40" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-24" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-9" target="IaA3IaIvg4qVMEhu7ya9-23" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-9" value="Lokális játék hosztolása" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="310" y="210" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-32" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-11" target="IaA3IaIvg4qVMEhu7ya9-31" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-11" value="<div>Lokális játékba csatlakozni</div><div><br></div>" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="460" y="220" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-13" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-18" target="4rzJeeoM2DMZDjvMm2AJ-12" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-18" value="Online jatek<br>(sorba allas)" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="695" y="200" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-22" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0;exitDx=0;exitDy=0;entryX=1;entryY=0;entryDx=0;entryDy=0;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-20" target="IaA3IaIvg4qVMEhu7ya9-6" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-28" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-20" target="IaA3IaIvg4qVMEhu7ya9-27" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-3" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="IaA3IaIvg4qVMEhu7ya9-20" target="IaA3IaIvg4qVMEhu7ya9-27">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-5" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="IaA3IaIvg4qVMEhu7ya9-20" target="iJwoCWMJ6fIoSaqHo3aH-4">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-6" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="IaA3IaIvg4qVMEhu7ya9-20" target="iJwoCWMJ6fIoSaqHo3aH-4">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-8" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="IaA3IaIvg4qVMEhu7ya9-20" target="iJwoCWMJ6fIoSaqHo3aH-7">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="770" y="80" />
|
||||
<mxPoint x="1000" y="80" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-10" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=1;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="IaA3IaIvg4qVMEhu7ya9-20" target="iJwoCWMJ6fIoSaqHo3aH-9">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-20" value="<div>Beallitasok</div>" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="650" y="40" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-5" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-23" target="4rzJeeoM2DMZDjvMm2AJ-4" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-23" value="<div>Szerver peldany elinditasa</div>" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="130" y="150" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-31" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-25" target="IaA3IaIvg4qVMEhu7ya9-29" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-16" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="IaA3IaIvg4qVMEhu7ya9-25" target="iJwoCWMJ6fIoSaqHo3aH-15">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-25" value="varakozas az ellenfelre" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="130" y="390" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-27" value="lokalis jatekhoz port megvaltoztatasa" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="830" y="10" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-33" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-29" target="4rzJeeoM2DMZDjvMm2AJ-32" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-29" value="<div>jatek elkezdése</div>" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="400" y="850" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-34" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-31" target="IaA3IaIvg4qVMEhu7ya9-33" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-31" value="<div>lokalis halozaton szerver ip:port megadasa</div>" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="460" y="360" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-11" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-33" target="IaA3IaIvg4qVMEhu7ya9-29" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-33" value="csatlakozás" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="290" y="360" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-38" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="IaA3IaIvg4qVMEhu7ya9-36" target="IaA3IaIvg4qVMEhu7ya9-6" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="IaA3IaIvg4qVMEhu7ya9-36" value="user struct letrehozasa a app-ban" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="340" y="40" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-9" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="4rzJeeoM2DMZDjvMm2AJ-4" target="4rzJeeoM2DMZDjvMm2AJ-7" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-4" value="hostolo kapcsolodik a szerverehez" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="130" y="230" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-8" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="4rzJeeoM2DMZDjvMm2AJ-7" target="IaA3IaIvg4qVMEhu7ya9-25" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-7" value="eszköz ip cím lekérése a csatlakozáshoz" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="130" y="310" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-21" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="4rzJeeoM2DMZDjvMm2AJ-12" target="4rzJeeoM2DMZDjvMm2AJ-20" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-12" value="<div>csatlakozás a központi szerverhez</div>(tudjuk az ip cimet)" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="690" y="300" width="130" height="70" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-24" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="4rzJeeoM2DMZDjvMm2AJ-16" target="4rzJeeoM2DMZDjvMm2AJ-23" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-27" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="4rzJeeoM2DMZDjvMm2AJ-16" target="4rzJeeoM2DMZDjvMm2AJ-26" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-16" value="sorban állás szabad játékra várva" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="695" y="480" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-22" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="4rzJeeoM2DMZDjvMm2AJ-20" target="4rzJeeoM2DMZDjvMm2AJ-16" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-20" value="a szerver eltárolja az uj jatekost mint aktiv felhasznalo a listaban" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||
<mxGeometry x="700" y="390" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-23" value="a szerveren bekerultunk a varolistaba" style="ellipse;whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="850" y="465" width="155" height="90" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-29" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="4rzJeeoM2DMZDjvMm2AJ-26" target="4rzJeeoM2DMZDjvMm2AJ-28" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-26" value="<div>megjelent meg egy jatekos a varolistan</div>" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="695" y="570" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-30" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="4rzJeeoM2DMZDjvMm2AJ-28" target="IaA3IaIvg4qVMEhu7ya9-29" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-28" value="ket jatekos ossze vonasa egy meccsbe. Kivesszuk oket a varolistabol es egy Match structba osszevonjuk oket" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="682.5" y="660" width="145" height="120" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-35" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="4rzJeeoM2DMZDjvMm2AJ-32" target="4rzJeeoM2DMZDjvMm2AJ-34" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-32" value="<div>fehér és fekete oldal eldöntése</div><div>(szerver által, érme dobással)</div>" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="390" y="950" width="140" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-37" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="4rzJeeoM2DMZDjvMm2AJ-34" target="4rzJeeoM2DMZDjvMm2AJ-36" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-34" value="játék ui megjelenítése" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="400" y="1060" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-39" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="4rzJeeoM2DMZDjvMm2AJ-36" target="4rzJeeoM2DMZDjvMm2AJ-38" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-36" value="lehetséges lépések lekérése a tábla állapot alapján a szerver / engine-től" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="390" y="1160" width="140" height="90" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-41" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="4rzJeeoM2DMZDjvMm2AJ-38" target="4rzJeeoM2DMZDjvMm2AJ-40" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-38" value="a ui lokalisan eltarolja ezt az adot a következő körig" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="400" y="1280" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-2" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="4rzJeeoM2DMZDjvMm2AJ-40" target="iJwoCWMJ6fIoSaqHo3aH-1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-19" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="4rzJeeoM2DMZDjvMm2AJ-40" target="iJwoCWMJ6fIoSaqHo3aH-18">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="4rzJeeoM2DMZDjvMm2AJ-40" value="a jatekos lep a egy babual. Ekkor ellenorizzuk hogy szabad e volt ezt a léppést megtennie" style="whiteSpace=wrap;html=1;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="390" y="1370" width="140" height="90" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-12" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="iJwoCWMJ6fIoSaqHo3aH-1" target="iJwoCWMJ6fIoSaqHo3aH-11">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-14" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="iJwoCWMJ6fIoSaqHo3aH-1" target="iJwoCWMJ6fIoSaqHo3aH-13">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-1" value="ha szabad volt elküldjük a lépést a szervernek" style="whiteSpace=wrap;html=1;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="400" y="1490" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-4" value="felbontás megváltoztatása" style="whiteSpace=wrap;html=1;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="830" y="90" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-7" value="teljes képernyő" style="whiteSpace=wrap;html=1;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="1000" y="50" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-9" value="ai api kulcs megadása" style="whiteSpace=wrap;html=1;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="1000" y="140" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-21" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="iJwoCWMJ6fIoSaqHo3aH-11" target="iJwoCWMJ6fIoSaqHo3aH-20">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-11" value="<div>ellenfél ui frissítése</div>" style="whiteSpace=wrap;html=1;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="400" y="1580" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-13" value="<div>{</div><div>from:str,</div><div>to: str</div><div>}</div>" style="rhombus;whiteSpace=wrap;html=1;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="560" y="1455" width="140" height="130" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-15" value="Ip cím megjelenítése a könnyebb csatlakozás érdekében" style="ellipse;whiteSpace=wrap;html=1;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="20" y="490" width="120" height="150" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-18" value="a ui végig megy az adatokon, amit visszakapott a szervertől a kör elején" style="ellipse;whiteSpace=wrap;html=1;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="590" y="1290" width="170" height="110" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-23" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="iJwoCWMJ6fIoSaqHo3aH-20" target="iJwoCWMJ6fIoSaqHo3aH-22">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-25" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="iJwoCWMJ6fIoSaqHo3aH-20" target="iJwoCWMJ6fIoSaqHo3aH-24">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-27" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="iJwoCWMJ6fIoSaqHo3aH-20">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="640" y="1860" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-20" value="ellenőrizzük, hogy nyert-e a játékos vagy döntetlen lett-e" style="whiteSpace=wrap;html=1;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="395" y="1670" width="130" height="70" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-22" value="a szerver megkapja a tábla állást és elküldi az enginnek ami ad egy választ" style="ellipse;whiteSpace=wrap;html=1;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="560" y="1647.5" width="200" height="115" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-26" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="iJwoCWMJ6fIoSaqHo3aH-24" target="4rzJeeoM2DMZDjvMm2AJ-36">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="360" y="1820" />
|
||||
<mxPoint x="360" y="1205" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-24" value="kör átadása az ellenfélnek" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="400" y="1790" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-30" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="iJwoCWMJ6fIoSaqHo3aH-28" target="iJwoCWMJ6fIoSaqHo3aH-29">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-28" value="játék befejezése, nyertes megjelnítése,&nbsp;" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="580" y="1860" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iJwoCWMJ6fIoSaqHo3aH-29" value="a játékosokat vissza küldjük a menübe, a szerver oldalon töröljük a meccset a listából, és töröljük&nbsp; a játékosokat a meccs közben lévő listából" style="whiteSpace=wrap;html=1;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="560" y="1940" width="160" height="120" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
@@ -1,2 +1,3 @@
|
||||
mod attackmaps;
|
||||
mod utils;
|
||||
mod utils;
|
||||
pub mod board;
|
||||
182
engine/src/bitboard/board.rs
Normal file
182
engine/src/bitboard/board.rs
Normal file
@@ -0,0 +1,182 @@
|
||||
use super::utils::try_get_square_number_from_notation;
|
||||
|
||||
pub struct Board {
|
||||
pub(in super) bitboards: [u64; 12], // 0-5 -> white pieces (P, N, B, R, Q, K), 6-11 -> black pieces (p, n, b, r, q, k)
|
||||
pub(in super) piece_board: [u8; 64], // same as board indexes, 12 -> empty square
|
||||
pub(in super) occupancy: [u64; 3], // 0 -> white, 1 -> black, 2 -> combined
|
||||
pub(in super) castling_rights: u8, // 0b0000_KQkq
|
||||
pub(in super) pinned_squares: [u8; 64], // 0 -> E-W, 1 -> NE-SW, 2 -> N-S, 3 -> SE-NW, 4 -> no pin
|
||||
pub(in super) pin_mask: u64, // 1 -> pin, 0 -> no pin
|
||||
pub(in super) en_passant_square: u64, // 1 -> ep square, 0 -> no ep square
|
||||
pub(in super) side_to_move: u8 // 0 -> white to play, 1 -> black to play
|
||||
}
|
||||
|
||||
impl Board {
|
||||
|
||||
pub fn new_clear() -> Self {
|
||||
let mut bit_board: Self = Self {
|
||||
bitboards: [0x0000_0000_0000_0000; 12],
|
||||
piece_board: [12; 64],
|
||||
occupancy: [0x0000_0000_0000_0000; 3],
|
||||
castling_rights: 0b0000_0000,
|
||||
pinned_squares: [4; 64],
|
||||
pin_mask: 0u64,
|
||||
en_passant_square: 0x0000_0000_0000_0000,
|
||||
side_to_move: 0
|
||||
};
|
||||
|
||||
return bit_board;
|
||||
}
|
||||
pub fn new() -> Self {
|
||||
let mut bit_board: Board = Self {
|
||||
bitboards: [0x0000_0000_0000_FF00,
|
||||
0x0000_0000_0000_0042,
|
||||
0x0000_0000_0000_0024,
|
||||
0x0000_0000_0000_0081,
|
||||
0x0000_0000_0000_0008,
|
||||
0x0000_0000_0000_0010,
|
||||
0x00FF_0000_0000_0000,
|
||||
0x4200_0000_0000_0000,
|
||||
0x2400_0000_0000_0000,
|
||||
0x8100_0000_0000_0000,
|
||||
0x0800_0000_0000_0000,
|
||||
0x1000_0000_0000_0000],
|
||||
piece_board: [12; 64],
|
||||
occupancy: [0; 3],
|
||||
castling_rights: 0b0000_1111,
|
||||
pinned_squares: [4; 64],
|
||||
pin_mask: 0u64,
|
||||
en_passant_square: 0x0000_0000_0000_0000,
|
||||
side_to_move: 0
|
||||
};
|
||||
bit_board.calc_occupancy();
|
||||
bit_board.calc_piece_board();
|
||||
|
||||
return bit_board;
|
||||
}
|
||||
pub fn build(fen: &str) -> Self {
|
||||
let mut board: Board = Board::new_clear();
|
||||
|
||||
let mut col: i32 = 0;
|
||||
let mut row: i32 = 7;
|
||||
let pieces: [char; 12] = ['p', 'n', 'b', 'r', 'q', 'k', 'P', 'N', 'B', 'R', 'Q', 'K'];
|
||||
let mut coming_up: &str = fen;
|
||||
|
||||
for (i, c) in coming_up.chars().enumerate() {
|
||||
if pieces.contains(&c) {
|
||||
// board.place_piece(row*8 + col, c);
|
||||
col += 1;
|
||||
}
|
||||
else if ('1'..='8').contains(&c) {
|
||||
col += c.to_string().parse::<i32>().unwrap();
|
||||
}
|
||||
else if c == '/' {
|
||||
row -= 1;
|
||||
col = 0;
|
||||
}
|
||||
else {
|
||||
coming_up = &coming_up[i+1..];
|
||||
break;
|
||||
}
|
||||
}
|
||||
board.calc_occupancy();
|
||||
|
||||
match coming_up.chars().next().unwrap() {
|
||||
'w' => board.side_to_move = 0,
|
||||
'b' => board.side_to_move = 1,
|
||||
_ => panic!("invalid fen notation / to be handled later")
|
||||
}
|
||||
coming_up = &coming_up[2..];
|
||||
|
||||
for (i, c) in coming_up.chars().enumerate() {
|
||||
match c {
|
||||
'K' => board.castling_rights |= 1 << 3,
|
||||
'Q' => board.castling_rights |= 1 << 2,
|
||||
'k' => board.castling_rights |= 1 << 1,
|
||||
'q' => board.castling_rights |= 1,
|
||||
'-' => {
|
||||
coming_up = &coming_up[i+2..];
|
||||
break;
|
||||
}
|
||||
_ => {
|
||||
coming_up = &coming_up[i+1..];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
match coming_up.chars().next().unwrap() {
|
||||
'-' => {
|
||||
coming_up = &coming_up[1..];
|
||||
}
|
||||
_ => {
|
||||
let notation = coming_up.split(' ').next().unwrap();
|
||||
if let Ok(epsq_index) = try_get_square_number_from_notation(notation) {
|
||||
board.en_passant_square = 1 << epsq_index;
|
||||
}
|
||||
}
|
||||
}
|
||||
// board.calc_pinned_squares();
|
||||
board.calc_piece_board();
|
||||
|
||||
return board;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn bitboards(&self, index: usize) -> u64 {
|
||||
return self.bitboards[index];
|
||||
}
|
||||
#[inline(always)]
|
||||
pub fn piece_board(&self, sq: u8) -> u8 {
|
||||
return self.piece_board[sq as usize];
|
||||
}
|
||||
#[inline(always)]
|
||||
pub fn occupancy(&self, side: usize) -> u64 {
|
||||
return self.occupancy[side];
|
||||
}
|
||||
#[inline(always)]
|
||||
pub fn castling_rights(&self) -> u8 {
|
||||
return self.castling_rights;
|
||||
}
|
||||
#[inline(always)]
|
||||
pub fn pinned_squares(&self, sq: usize) -> u8 {
|
||||
return self.pinned_squares[sq];
|
||||
}
|
||||
#[inline(always)]
|
||||
pub fn pin_mask(&self) -> u64 {
|
||||
return self.pin_mask;
|
||||
}
|
||||
#[inline(always)]
|
||||
pub fn en_passant_square(&self) -> u64 {
|
||||
return self.en_passant_square;
|
||||
}
|
||||
#[inline(always)]
|
||||
pub fn side_to_move(&self) -> u8 {
|
||||
return self.side_to_move;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn current_king_square(&self) -> u32 {
|
||||
return if self.side_to_move == 0 { self.bitboards[5].trailing_zeros() } else { self.bitboards[11].trailing_zeros() };
|
||||
}
|
||||
|
||||
fn calc_occupancy(&mut self) {
|
||||
self.occupancy = [0u64; 3];
|
||||
for b in 0..6 {
|
||||
self.occupancy[0] |= self.bitboards[b];
|
||||
}
|
||||
for b in 6..12 {
|
||||
self.occupancy[1] |= self.bitboards[b];
|
||||
}
|
||||
self.occupancy[2] = self.occupancy[0] | self.occupancy[1];
|
||||
}
|
||||
fn calc_piece_board(&mut self) {
|
||||
for sq in 0..64 {
|
||||
for b in 0..12 {
|
||||
if (self.bitboards[b as usize] & 1 << sq) != 0 {
|
||||
self.piece_board[sq] = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,6 +27,27 @@ pub fn notation_from_square_number(sq: u8) -> String {
|
||||
return notation;
|
||||
}
|
||||
|
||||
pub fn try_get_square_number_from_notation(notation: &str) -> Result<u8, ()> {
|
||||
|
||||
let file = match notation.chars().nth(0).unwrap() {
|
||||
'a' => 0,
|
||||
'b' => 1,
|
||||
'c' => 2,
|
||||
'd' => 3,
|
||||
'e' => 4,
|
||||
'f' => 5,
|
||||
'g' => 6,
|
||||
'h' => 7,
|
||||
_ => { return Result::Err(()); }
|
||||
};
|
||||
if let Some(rank) = notation.chars().nth(1) {
|
||||
return Result::Ok(file + 8 * (rank.to_digit(10).unwrap() as u8) - 8);
|
||||
}
|
||||
else {
|
||||
return Result::Err(());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// <----- TESTS ----->
|
||||
|
||||
|
||||
@@ -4,3 +4,13 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
tokio-tungstenite = "0.21"
|
||||
tungstenite = "0.21"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
futures-util = "0.3.31"
|
||||
url = "2.5.7"
|
||||
uuid = {version = "1.18.1", features = ["v4", "serde"] }
|
||||
anyhow = "1.0.100"
|
||||
rand = "0.9.2"
|
||||
|
||||
218
server/src/connection.rs
Normal file
218
server/src/connection.rs
Normal file
@@ -0,0 +1,218 @@
|
||||
use futures_util::{SinkExt, StreamExt};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::sync::Arc;
|
||||
use tokio::net::TcpStream;
|
||||
use tokio::sync::Mutex;
|
||||
use tokio_tungstenite::{WebSocketStream, tungstenite::Message};
|
||||
use uuid::Uuid;
|
||||
|
||||
// Type definitions
|
||||
pub type Tx = futures_util::stream::SplitSink<WebSocketStream<TcpStream>, Message>;
|
||||
pub type ConnectionMap = Arc<Mutex<HashMap<Uuid, PlayerConnection>>>;
|
||||
pub type MatchMap = Arc<Mutex<HashMap<Uuid, GameMatch>>>;
|
||||
pub type WaitingQueue = Arc<Mutex<VecDeque<Uuid>>>;
|
||||
|
||||
// Helper functions to create new instances
|
||||
pub fn new_connection_map() -> ConnectionMap {
|
||||
Arc::new(Mutex::new(HashMap::new()))
|
||||
}
|
||||
|
||||
pub fn new_match_map() -> MatchMap {
|
||||
Arc::new(Mutex::new(HashMap::new()))
|
||||
}
|
||||
|
||||
pub fn new_waiting_queue() -> WaitingQueue {
|
||||
Arc::new(Mutex::new(VecDeque::new()))
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PlayerConnection {
|
||||
pub id: Uuid,
|
||||
pub username: Option<String>,
|
||||
pub tx: Tx,
|
||||
pub current_match: Option<Uuid>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct GameMatch {
|
||||
pub id: Uuid,
|
||||
pub player_white: Uuid,
|
||||
pub player_black: Uuid,
|
||||
pub board_state: String,
|
||||
pub move_history: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Step {
|
||||
pub from: String,
|
||||
pub to: String,
|
||||
}
|
||||
|
||||
// Message sending utilities
|
||||
pub async fn send_message_to_player(
|
||||
connections: &ConnectionMap,
|
||||
player_id: Uuid,
|
||||
message: &str,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut connections_lock = connections.lock().await;
|
||||
if let Some(connection) = connections_lock.get_mut(&player_id) {
|
||||
connection
|
||||
.tx
|
||||
.send(Message::Text(message.to_string()))
|
||||
.await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn broadcast_to_all(connections: &ConnectionMap, message: &str) {
|
||||
let mut connections_lock = connections.lock().await;
|
||||
let mut dead_connections = Vec::new();
|
||||
|
||||
for (id, connection) in connections_lock.iter_mut() {
|
||||
if let Err(e) = connection.tx.send(Message::Text(message.to_string())).await {
|
||||
eprintln!("Failed to send to {}: {}", id, e);
|
||||
dead_connections.push(*id);
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up dead connections
|
||||
for dead_id in dead_connections {
|
||||
connections_lock.remove(&dead_id);
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn broadcast_to_match(
|
||||
connections: &ConnectionMap,
|
||||
matches: &MatchMap,
|
||||
match_id: Uuid,
|
||||
message: &str,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let matches_lock = matches.lock().await;
|
||||
if let Some(game_match) = matches_lock.get(&match_id) {
|
||||
send_message_to_player(connections, game_match.player_white, message).await?;
|
||||
send_message_to_player(connections, game_match.player_black, message).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Connection handler
|
||||
pub async fn handle_connection(
|
||||
stream: TcpStream,
|
||||
connections: ConnectionMap,
|
||||
matches: MatchMap,
|
||||
waiting_queue: WaitingQueue,
|
||||
event_system: crate::events::EventSystem,
|
||||
) -> anyhow::Result<()> {
|
||||
use tokio_tungstenite::accept_async;
|
||||
|
||||
let ws_stream = accept_async(stream).await?;
|
||||
let (write, mut read) = ws_stream.split();
|
||||
|
||||
let player_id = Uuid::new_v4();
|
||||
|
||||
// Store the connection
|
||||
{
|
||||
let mut conn_map = connections.lock().await;
|
||||
conn_map.insert(
|
||||
player_id,
|
||||
PlayerConnection {
|
||||
id: player_id,
|
||||
username: None,
|
||||
tx: write,
|
||||
current_match: None,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
println!("New connection: {}", player_id);
|
||||
|
||||
// Send welcome message
|
||||
let _ = send_message_to_player(
|
||||
&connections,
|
||||
player_id,
|
||||
&format!(r#"{{"type": "welcome", "player_id": "{}"}}"#, player_id),
|
||||
)
|
||||
.await;
|
||||
|
||||
// Message processing loop
|
||||
while let Some(Ok(message)) = read.next().await {
|
||||
if message.is_text() {
|
||||
let text = message.to_text()?;
|
||||
println!("Received from {}: {}", player_id, text);
|
||||
|
||||
// TODO: Parse and handle message with event system
|
||||
// This will be implemented when we integrate the event system
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup on disconnect
|
||||
cleanup_player(player_id, &connections, &matches, &waiting_queue).await;
|
||||
println!("Connection {} closed", player_id);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn cleanup_player(
|
||||
player_id: Uuid,
|
||||
connections: &ConnectionMap,
|
||||
_matches: &MatchMap,
|
||||
waiting_queue: &WaitingQueue,
|
||||
) {
|
||||
// Remove from waiting queue
|
||||
waiting_queue.lock().await.retain(|&id| id != player_id);
|
||||
|
||||
// Remove from connections
|
||||
connections.lock().await.remove(&player_id);
|
||||
|
||||
println!("Cleaned up player {}", player_id);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_send_message_to_nonexistent_player() {
|
||||
let connections = new_connection_map();
|
||||
let player_id = Uuid::new_v4();
|
||||
|
||||
let result = send_message_to_player(&connections, player_id, "test message").await;
|
||||
assert!(result.is_ok(), "Should handle missing player gracefully");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_broadcast_to_empty_connections() {
|
||||
let connections = new_connection_map();
|
||||
|
||||
broadcast_to_all(&connections, "test broadcast").await;
|
||||
|
||||
let conn_map = connections.lock().await;
|
||||
assert!(conn_map.is_empty(), "Connections should still be empty");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_connection_cleanup() {
|
||||
let connections = new_connection_map();
|
||||
let matches = new_match_map();
|
||||
let waiting_queue = new_waiting_queue();
|
||||
|
||||
let player_id = Uuid::new_v4();
|
||||
|
||||
{
|
||||
waiting_queue.lock().await.push_back(player_id);
|
||||
assert_eq!(waiting_queue.lock().await.len(), 1);
|
||||
}
|
||||
|
||||
cleanup_player(player_id, &connections, &matches, &waiting_queue).await;
|
||||
|
||||
{
|
||||
let queue = waiting_queue.lock().await;
|
||||
assert!(
|
||||
!queue.contains(&player_id),
|
||||
"Player should be removed from waiting queue"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
126
server/src/events.rs
Normal file
126
server/src/events.rs
Normal file
@@ -0,0 +1,126 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
use tokio::sync::mpsc;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Step {
|
||||
pub from: String,
|
||||
pub to: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum ClientEvent {
|
||||
Join { username: String },
|
||||
FindMatch,
|
||||
Move { from: String, to: String },
|
||||
Resign,
|
||||
Chat { text: String },
|
||||
RequestLegalMoves { fen: String },
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ServerEvent {
|
||||
PlayerJoined(Uuid, String),
|
||||
PlayerLeft(Uuid),
|
||||
PlayerJoinedQueue(Uuid),
|
||||
PlayerJoinedMatch(Uuid, Uuid), // player_id, match_id
|
||||
PlayerMove(Uuid, Step),
|
||||
PlayerResigned(Uuid),
|
||||
MatchCreated(Uuid, Uuid, Uuid), // match_id, white_id, black_id
|
||||
}
|
||||
|
||||
pub struct EventSystem {
|
||||
sender: mpsc::UnboundedSender<(Uuid, ClientEvent)>,
|
||||
receiver: Arc<Mutex<mpsc::UnboundedReceiver<(Uuid, ClientEvent)>>>,
|
||||
}
|
||||
|
||||
impl Clone for EventSystem {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
sender: self.sender.clone(),
|
||||
receiver: Arc::clone(&self.receiver),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl EventSystem {
|
||||
pub fn new() -> Self {
|
||||
let (sender, receiver) = mpsc::unbounded_channel();
|
||||
Self {
|
||||
sender,
|
||||
receiver: Arc::new(Mutex::new(receiver)),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn send_event(
|
||||
&self,
|
||||
player_id: Uuid,
|
||||
event: ClientEvent,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
self.sender.send((player_id, event))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn next_event(&self) -> Option<(Uuid, ClientEvent)> {
|
||||
let mut receiver = self.receiver.lock().await;
|
||||
receiver.recv().await
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for EventSystem {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_event_system_send_and_receive() {
|
||||
let event_system = EventSystem::new();
|
||||
let player_id = Uuid::new_v4();
|
||||
|
||||
let join_event = ClientEvent::Join {
|
||||
username: "test_user".to_string(),
|
||||
};
|
||||
|
||||
let send_result = event_system.send_event(player_id, join_event).await;
|
||||
assert!(send_result.is_ok(), "Should send event successfully");
|
||||
|
||||
let received = event_system.next_event().await;
|
||||
assert!(received.is_some(), "Should receive sent event");
|
||||
|
||||
let (received_id, received_event) = received.unwrap();
|
||||
assert_eq!(received_id, player_id, "Should receive correct player ID");
|
||||
|
||||
match received_event {
|
||||
ClientEvent::Join { username } => {
|
||||
assert_eq!(username, "test_user", "Should receive correct username");
|
||||
}
|
||||
_ => panic!("Should receive Join event"),
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_event_system_clone() {
|
||||
let event_system1 = EventSystem::new();
|
||||
let event_system2 = event_system1.clone();
|
||||
|
||||
let player_id = Uuid::new_v4();
|
||||
let event = ClientEvent::FindMatch;
|
||||
|
||||
event_system1.send_event(player_id, event).await.unwrap();
|
||||
|
||||
let received = event_system2.next_event().await;
|
||||
assert!(
|
||||
received.is_some(),
|
||||
"Cloned event system should receive events"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,54 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
mod connection;
|
||||
mod events;
|
||||
mod matchmaking;
|
||||
use tokio::net::TcpListener;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
let address = "0.0.0.0:9001";
|
||||
let listener = TcpListener::bind(address).await?;
|
||||
println!("Server running on ws://{}", address);
|
||||
|
||||
// Shared state initialization using the new helper functions
|
||||
let connections = connection::new_connection_map();
|
||||
let matches = connection::new_match_map();
|
||||
let waiting_queue = connection::new_waiting_queue();
|
||||
|
||||
// Event system for communication between components
|
||||
let event_system = events::EventSystem::new();
|
||||
|
||||
// Start matchmaking background task
|
||||
let matchmaker = matchmaking::MatchmakingSystem::new(
|
||||
connections.clone(),
|
||||
matches.clone(),
|
||||
waiting_queue.clone(),
|
||||
event_system.clone(),
|
||||
);
|
||||
tokio::spawn(async move {
|
||||
matchmaker.run().await;
|
||||
});
|
||||
|
||||
// Main connection loop
|
||||
while let Ok((stream, _)) = listener.accept().await {
|
||||
let connections = connections.clone();
|
||||
let matches = matches.clone();
|
||||
let waiting_queue = waiting_queue.clone();
|
||||
let event_system = event_system.clone();
|
||||
|
||||
tokio::spawn(async move {
|
||||
if let Err(e) = connection::handle_connection(
|
||||
stream,
|
||||
connections,
|
||||
matches,
|
||||
waiting_queue,
|
||||
event_system,
|
||||
)
|
||||
.await
|
||||
{
|
||||
eprintln!("Connection error: {}", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
202
server/src/matchmaking.rs
Normal file
202
server/src/matchmaking.rs
Normal file
@@ -0,0 +1,202 @@
|
||||
use crate::connection::{ConnectionMap, GameMatch, MatchMap, WaitingQueue};
|
||||
use crate::events::EventSystem;
|
||||
use rand::random;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub struct MatchmakingSystem {
|
||||
connections: ConnectionMap,
|
||||
matches: MatchMap,
|
||||
waiting_queue: WaitingQueue,
|
||||
event_system: EventSystem,
|
||||
}
|
||||
|
||||
impl MatchmakingSystem {
|
||||
pub fn new(
|
||||
connections: ConnectionMap,
|
||||
matches: MatchMap,
|
||||
waiting_queue: WaitingQueue,
|
||||
event_system: EventSystem,
|
||||
) -> Self {
|
||||
Self {
|
||||
connections,
|
||||
matches,
|
||||
waiting_queue,
|
||||
event_system,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn run(&self) {
|
||||
loop {
|
||||
self.try_create_match().await;
|
||||
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
|
||||
}
|
||||
}
|
||||
|
||||
async fn try_create_match(&self) {
|
||||
let mut queue = self.waiting_queue.lock().await;
|
||||
|
||||
while queue.len() >= 2 {
|
||||
let player1 = queue.pop_front().unwrap();
|
||||
let player2 = queue.pop_front().unwrap();
|
||||
|
||||
let match_id = Uuid::new_v4();
|
||||
let (white_player, black_player) = if random::<bool>() {
|
||||
(player1, player2)
|
||||
} else {
|
||||
(player2, player1)
|
||||
};
|
||||
|
||||
let game_match = GameMatch {
|
||||
id: match_id,
|
||||
player_white: white_player,
|
||||
player_black: black_player,
|
||||
board_state: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1".to_string(),
|
||||
move_history: Vec::new(),
|
||||
};
|
||||
|
||||
// Store the match
|
||||
self.matches.lock().await.insert(match_id, game_match);
|
||||
|
||||
// Update player connections
|
||||
{
|
||||
let mut conn_map = self.connections.lock().await;
|
||||
if let Some(player) = conn_map.get_mut(&white_player) {
|
||||
player.current_match = Some(match_id);
|
||||
}
|
||||
if let Some(player) = conn_map.get_mut(&black_player) {
|
||||
player.current_match = Some(match_id);
|
||||
}
|
||||
}
|
||||
|
||||
// Notify players
|
||||
self.notify_players(white_player, black_player, match_id)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
async fn notify_players(&self, white: Uuid, black: Uuid, match_id: Uuid) {
|
||||
let conn_map = self.connections.lock().await;
|
||||
|
||||
// Get opponent names
|
||||
let white_name = conn_map
|
||||
.get(&black)
|
||||
.and_then(|c| c.username.as_deref())
|
||||
.unwrap_or("Opponent");
|
||||
let black_name = conn_map
|
||||
.get(&white)
|
||||
.and_then(|c| c.username.as_deref())
|
||||
.unwrap_or("Opponent");
|
||||
|
||||
// Notify white player
|
||||
if let Some(_) = conn_map.get(&white) {
|
||||
let message = format!(
|
||||
r#"{{"type": "match_found", "match_id": "{}", "opponent": "{}", "color": "white"}}"#,
|
||||
match_id, black_name
|
||||
);
|
||||
let _ =
|
||||
crate::connection::send_message_to_player(&self.connections, white, &message).await;
|
||||
}
|
||||
|
||||
// Notify black player
|
||||
if let Some(_) = conn_map.get(&black) {
|
||||
let message = format!(
|
||||
r#"{{"type": "match_found", "match_id": "{}", "opponent": "{}", "color": "black"}}"#,
|
||||
match_id, white_name
|
||||
);
|
||||
let _ =
|
||||
crate::connection::send_message_to_player(&self.connections, black, &message).await;
|
||||
}
|
||||
|
||||
println!("Match created: {} (white) vs {} (black)", white, black);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::events::EventSystem;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::connection::new_connection_map;
|
||||
use crate::connection::new_match_map;
|
||||
use crate::connection::new_waiting_queue;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_matchmaking_creates_matches() {
|
||||
let connections = new_connection_map();
|
||||
let matches = new_match_map();
|
||||
let waiting_queue = new_waiting_queue();
|
||||
let event_system = EventSystem::new();
|
||||
|
||||
let matchmaking = MatchmakingSystem::new(
|
||||
connections.clone(),
|
||||
matches.clone(),
|
||||
waiting_queue.clone(),
|
||||
event_system.clone(),
|
||||
);
|
||||
|
||||
let player1 = Uuid::new_v4();
|
||||
let player2 = Uuid::new_v4();
|
||||
|
||||
{
|
||||
waiting_queue.lock().await.push_back(player1);
|
||||
waiting_queue.lock().await.push_back(player2);
|
||||
}
|
||||
|
||||
matchmaking.try_create_match().await;
|
||||
|
||||
{
|
||||
let matches_map = matches.lock().await;
|
||||
assert_eq!(matches_map.len(), 1, "Should create one match");
|
||||
|
||||
let game_match = matches_map.values().next().unwrap();
|
||||
assert!(game_match.player_white == player1 || game_match.player_white == player2);
|
||||
assert!(game_match.player_black == player1 || game_match.player_black == player2);
|
||||
assert_ne!(
|
||||
game_match.player_white, game_match.player_black,
|
||||
"Players should be different"
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
let queue = waiting_queue.lock().await;
|
||||
assert!(
|
||||
queue.is_empty(),
|
||||
"Waiting queue should be empty after matchmaking"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_matchmaking_with_odd_players() {
|
||||
let connections = new_connection_map();
|
||||
let matches = new_match_map();
|
||||
let waiting_queue = new_waiting_queue();
|
||||
let event_system = EventSystem::new();
|
||||
|
||||
let matchmaking = MatchmakingSystem::new(
|
||||
connections.clone(),
|
||||
matches.clone(),
|
||||
waiting_queue.clone(),
|
||||
event_system.clone(),
|
||||
);
|
||||
|
||||
let player1 = Uuid::new_v4();
|
||||
{
|
||||
waiting_queue.lock().await.push_back(player1);
|
||||
}
|
||||
|
||||
matchmaking.try_create_match().await;
|
||||
|
||||
{
|
||||
let matches_map = matches.lock().await;
|
||||
assert!(
|
||||
matches_map.is_empty(),
|
||||
"Should not create match with only one player"
|
||||
);
|
||||
|
||||
let queue = waiting_queue.lock().await;
|
||||
assert_eq!(queue.len(), 1, "Should keep single player in queue");
|
||||
}
|
||||
}
|
||||
}
|
||||
36
server/src/messages.rs
Normal file
36
server/src/messages.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum ServerMessage {
|
||||
Welcome {
|
||||
player_id: String,
|
||||
},
|
||||
MatchFound {
|
||||
match_id: String,
|
||||
opponent: String,
|
||||
color: String,
|
||||
},
|
||||
GameStart {
|
||||
fen: String,
|
||||
white_time: u32,
|
||||
black_time: u32,
|
||||
},
|
||||
MoveResult {
|
||||
valid: bool,
|
||||
from: String,
|
||||
to: String,
|
||||
new_fen: String,
|
||||
},
|
||||
OpponentMove {
|
||||
from: String,
|
||||
to: String,
|
||||
},
|
||||
GameEnd {
|
||||
result: String,
|
||||
reason: String,
|
||||
},
|
||||
Error {
|
||||
reason: String,
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user