Compare commits
566 commits
game_endpo
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
08745443ca | ||
|
177d3a4c42 | ||
|
1d804694b7 | ||
|
a40253a4fd | ||
|
1c470ffec0 | ||
|
27cf281670 | ||
|
0fad98a1d0 | ||
|
14a94be59e | ||
|
0f3e7942ef | ||
|
cfec49845b | ||
|
2a84644e12 | ||
|
e1a6cd9a44 | ||
|
a3420c1152 | ||
|
c4192f2e33 | ||
|
cbf9d461ba | ||
|
5eca128110 | ||
|
dd0289439c | ||
|
9cae5ff185 | ||
|
0ec92dd5e9 | ||
|
ff3d6c2c24 | ||
|
1e6050a486 | ||
|
2f1174c21b | ||
|
ccbeddfa40 | ||
|
f8779ae887 | ||
|
a9be49c38e | ||
|
5e33e6439e | ||
|
ea951bee66 | ||
|
d7c53e7c7f | ||
|
a290ec532d | ||
|
9ed4fc0a39 | ||
|
62fe6dfcb4 | ||
|
3955f940e2 | ||
|
f14c0ce087 | ||
|
5eedd6b2e9 | ||
|
d803f55f5b | ||
|
35c51c567f | ||
|
8414d13949 | ||
|
aed378c021 | ||
|
4b507cce96 | ||
|
a8119bb194 | ||
|
692a8b1400 | ||
|
52762475f7 | ||
|
0db13d2913 | ||
|
b1d43b5b02 | ||
|
e40fa63274 | ||
|
a3aecfeadc | ||
|
0b2bfad12f | ||
|
72b93f8ff1 | ||
|
18027ec1ef | ||
|
be8cb70431 | ||
|
249789944b | ||
|
17b2e2c31f | ||
|
77ced54c6f | ||
|
97242a2235 | ||
|
f010d5d9ee | ||
|
6359089e91 | ||
|
49873aa706 | ||
|
12f9847a0e | ||
|
09b346064f | ||
|
84085dc8b2 | ||
|
934b1b7b2d | ||
|
7c2bf6416b | ||
|
d1f3459516 | ||
|
1b3dbd870a | ||
|
19a5282b73 | ||
|
55a282b5c8 | ||
|
796bb7aad9 | ||
|
8fa6e207ed | ||
|
d54d43c42c | ||
|
181554124b | ||
|
3eabf4191a | ||
|
9b419a416b | ||
|
e41d889177 | ||
|
2922be86e1 | ||
|
7eb592a397 | ||
|
572a1dcf19 | ||
|
ef0e53756e | ||
|
9f18c01839 | ||
|
8cdefa98c1 | ||
|
475db4e812 | ||
|
73ba2bb237 | ||
|
a324ece0af | ||
|
2e613daa1b | ||
|
8e25106be6 | ||
|
c43df2cd5f | ||
|
72d31cca5b | ||
|
54fd676656 | ||
|
155cca9110 | ||
|
7aed5b7bf9 | ||
|
a02576532d | ||
|
b8eb3770d9 | ||
|
a99426e03f | ||
|
d51e3f72f4 | ||
|
bdeb9c9d86 | ||
|
88e51fdbf9 | ||
|
2237e344c1 | ||
|
5ad997d276 | ||
|
9646656f7a | ||
|
1142c1d448 | ||
|
e9d94d1fad | ||
|
1a1e5121d7 | ||
|
a5fbeea929 | ||
|
13a882d212 | ||
|
96af52823d | ||
|
9164ee5987 | ||
|
4a90b933a7 | ||
|
089783c82d | ||
|
e553601af7 | ||
|
b1f29f3d2d | ||
|
bdfb6ebe85 | ||
|
a54d4bf7e4 | ||
|
37db281d08 | ||
|
41e6e662e9 | ||
|
8fb1b80cb6 | ||
|
e53a8f4f2a | ||
|
7408e409aa | ||
|
c533c7837c | ||
|
aa2c9084e5 | ||
|
dde97e2a1f | ||
|
2c39fe1156 | ||
|
a1f7c45536 | ||
|
f2c0ce62fe | ||
|
176c087599 | ||
|
0dbf0ed844 | ||
|
a35cad24df | ||
|
c03ee1020d | ||
|
c54dcb41a8 | ||
|
a9243840a6 | ||
|
a9025aca8f | ||
|
0368325199 | ||
|
bf836d50d7 | ||
|
16868aea1a | ||
|
8a60d82832 | ||
|
a69b48d238 | ||
|
f8451ce62d | ||
|
d628a8dd48 | ||
|
3768297f7f | ||
|
30f65b85b3 | ||
|
f1d480c203 | ||
|
d5fe96e0e9 | ||
|
69c59683e4 | ||
|
46f82e658c | ||
|
6a17b6b872 | ||
|
eb7adf37e1 | ||
|
c1a9fe7204 | ||
|
4d71c8fdaf | ||
|
7dffc9dbc7 | ||
|
d6cfda9d8b | ||
|
3789401918 | ||
|
45cbe56564 | ||
|
5bd9ca1de3 | ||
|
e42a300e36 | ||
|
316396f218 | ||
|
8f18d0685c | ||
|
7b63a2f76d | ||
|
7481178abd | ||
|
fbea9767e3 | ||
|
3c34b6846a | ||
|
a9dbf359fc | ||
|
d29e488354 | ||
|
22907dc7c5 | ||
|
5589b1463e | ||
|
3d20606999 | ||
|
d79151c707 | ||
|
68f8f4bf50 | ||
|
b044bb57d2 | ||
|
8b1ef3dbff | ||
|
6ce03c3449 | ||
|
3e2a956634 | ||
|
401076cd50 | ||
|
24a8a4e991 | ||
|
3f15e48eef | ||
|
bfdad6e3aa | ||
|
c3842a0589 | ||
|
bee61a1f31 | ||
|
2c5a0534d7 | ||
|
4c7fa1512d | ||
|
9cac33cef3 | ||
|
8b26417827 | ||
|
97c4f11348 | ||
|
ebf33c7337 | ||
|
4bbe50cb57 | ||
|
d1cece19d9 | ||
|
b766cdb59a | ||
|
0dc9458b93 | ||
|
89eab6b4d8 | ||
|
d5a1afaa02 | ||
|
4b609b4e28 | ||
|
d1f09a5494 | ||
|
0c93989644 | ||
|
e050f295ae | ||
|
29f3385ba8 | ||
|
e69aa9b326 | ||
|
7223d98c36 | ||
|
497db97161 | ||
|
a29431e67d | ||
|
72fb0ae243 | ||
|
72a533a285 | ||
|
9b82236283 | ||
|
23cd485cbb | ||
|
76f29cf9d3 | ||
|
be294f669c | ||
|
95724c39db | ||
|
4851f31744 | ||
|
e0830bed5c | ||
|
f37def2688 | ||
|
fb9bc0d8cf | ||
|
fd72f135dd | ||
|
d6ec6c3163 | ||
|
7bca0e9a04 | ||
|
ffda6a8164 | ||
|
45b3604fb2 | ||
|
3195a73644 | ||
|
6e0ec94676 | ||
|
a0d721ab9a | ||
|
61b13ab97a | ||
|
86a75d146e | ||
|
a4a9a72ece | ||
|
026af700df | ||
|
b8681e8ef5 | ||
|
11855c57d4 | ||
|
6757553785 | ||
|
59b5d31c35 | ||
|
8589976264 | ||
|
775e1fc050 | ||
|
38014ac497 | ||
|
f94f4fd2c0 | ||
|
695d1ea2b1 | ||
|
6467004a89 | ||
|
83d3abf188 | ||
|
661fc74df2 | ||
|
aa0c850aab | ||
|
c001b939d1 | ||
|
e8867b9634 | ||
|
464a8ffbf4 | ||
|
f3d21e0444 | ||
|
522782e3a5 | ||
|
d9edea315a | ||
|
3e8e99a816 | ||
|
1ef3adc3d7 | ||
|
0fb6a7bfb8 | ||
|
05b7f338ff | ||
|
8ad488c3ce | ||
|
6114c20e2c | ||
|
762c4d93a8 | ||
|
47856773eb | ||
|
d706a9d137 | ||
|
6669d3f16b | ||
|
cb3fb31b24 | ||
|
b06b490d6f | ||
|
9dc91de5ed | ||
|
54abeb65fc | ||
|
00757ac2d2 | ||
|
2f9cb987ba | ||
|
891ba5ab2f | ||
|
188cd0b966 | ||
|
6f86007632 | ||
|
a9a10c1adb | ||
|
18d351d698 | ||
|
2c9aca4856 | ||
|
b8b7890e4f | ||
|
465a3342f2 | ||
|
5fa43f8b7e | ||
|
080ab8a994 | ||
|
97efe2314b | ||
|
969e44e8e5 | ||
|
e4d4652d1b | ||
|
42d10a55cd | ||
|
9b02705a91 | ||
|
78ba0a035e | ||
|
9014564180 | ||
|
fee04ec269 | ||
|
34959d8e44 | ||
|
36c75e9126 | ||
|
1e706fe20f | ||
|
f35bc165fd | ||
|
98fdf6926c | ||
|
30c0f9ad97 | ||
|
8af3685cba | ||
|
9a0045d99b | ||
|
7b4b48050d | ||
|
a629225fae | ||
|
cd1273e645 | ||
|
3a5125893b | ||
|
458876a2b4 | ||
|
1661b3fe65 | ||
|
413cf63192 | ||
|
d7cf6c44eb | ||
|
7ef212643d | ||
|
18d744a7a5 | ||
|
b62458218b | ||
|
173bb8766c | ||
|
48546c9448 | ||
|
5977c686a5 | ||
|
d2fe74ffec | ||
|
f3208819c8 | ||
|
07070439f1 | ||
|
cd22eb89e1 | ||
|
328bf9128f | ||
|
56fbc34ba3 | ||
|
65bffa11a1 | ||
|
e42118d6aa | ||
|
cc6b00b72b | ||
|
2ae07a1a99 | ||
|
24c4130f7f | ||
|
6a373a1172 | ||
|
34dbdaab7b | ||
|
64dc036296 | ||
|
aeb64cb6a5 | ||
|
840fae2bf7 | ||
|
e83ca4a1b5 | ||
|
ea878c9057 | ||
|
b2d9eaca0d | ||
|
dc7b895dd6 | ||
|
edf520ba79 | ||
|
3ca3e28d45 | ||
|
baa843feeb | ||
|
d087671cf2 | ||
|
d58eb95c76 | ||
|
eb5df6069c | ||
|
ca98733365 | ||
|
2d04f40bd6 | ||
|
8310307460 | ||
|
d2d34ff658 | ||
|
b38637d3c8 | ||
|
d83a58dcb4 | ||
|
b294e009d3 | ||
|
9a20746b78 | ||
|
3ecb5889c1 | ||
|
5651e1fa4c | ||
|
e02746cb67 | ||
|
6a5ae9cc71 | ||
|
638e57dd29 | ||
|
9f5842703b | ||
|
a58c2ed04a | ||
|
c853cb2ad8 | ||
|
e1515db88c | ||
|
16468fb907 | ||
|
6f8b68a354 | ||
|
7f1386f7a7 | ||
|
c033e3558a | ||
|
07af4e7be5 | ||
|
d7c024e286 | ||
|
a3180b0bde | ||
|
f6d4ed49ca | ||
|
e3ce466bb4 | ||
|
34c3b34ada | ||
|
c21807adc8 | ||
|
9c3fbb9572 | ||
|
40dbe487e1 | ||
|
ebd76baac6 | ||
|
95e54df9fd | ||
|
16adb58cb0 | ||
|
007a5c96d6 | ||
|
b3d05639ad | ||
|
5867c0ddd9 | ||
|
603201d45c | ||
|
33141284eb | ||
|
3f8d898f43 | ||
|
99a616fe37 | ||
|
5addf9ace0 | ||
|
8aa84d4abe | ||
|
d3b3028adf | ||
|
9729d15ff2 | ||
|
cba61a78e9 | ||
|
5a7f3bc177 | ||
|
36eeb8202b | ||
|
acbc9c901b | ||
|
a30d4f3a45 | ||
|
8bd52fd993 | ||
|
8933e25156 | ||
|
2dc17a9588 | ||
|
230dadd3d2 | ||
|
101531e727 | ||
|
c0aff888f5 | ||
|
68fedb4d2f | ||
|
b69edb9182 | ||
|
ca43baf181 | ||
|
3cbba5d072 | ||
|
b1cf43d84b | ||
|
d20c070c02 | ||
|
3b868cec4e | ||
|
5fbfc28024 | ||
|
e90abc283a | ||
|
5c8da62edb | ||
|
d77216d762 | ||
|
1ee4c28d4c | ||
|
c2a0ad2ff2 | ||
|
8c6e38ec66 | ||
|
c905dd05b8 | ||
|
e0a336bd35 | ||
|
0e2fe08666 | ||
|
9d10ed4fe2 | ||
|
3068b94c5b | ||
|
8d3991ef55 | ||
|
16d5c97e3f | ||
|
fea8c9035f | ||
|
02d408adba | ||
|
add9e49bb6 | ||
|
6033a99223 | ||
|
c480d986d2 | ||
|
52b31b7fe2 | ||
|
89eca4a5c1 | ||
|
323ea5d24c | ||
|
85ebffcdcf | ||
|
118989a9cc | ||
|
a451144581 | ||
|
52e6271738 | ||
|
55104ba3ff | ||
|
d5d7121a71 | ||
|
5adf8b4690 | ||
|
5f6889439b | ||
|
6011354d67 | ||
|
f6b52000f3 | ||
|
3d81aeda5e | ||
|
9ea54db3e2 | ||
|
962d0f9bcf | ||
|
ebe945245c | ||
|
94c6a97265 | ||
|
489fde4972 | ||
|
b91f468810 | ||
|
2b74813c14 | ||
|
2f65341daa | ||
|
0356002022 | ||
|
ba1211d0d6 | ||
|
538e911b21 | ||
|
7d4ffc4cc0 | ||
|
101def1cac | ||
|
fa9b049e58 | ||
|
9f0875f483 | ||
|
397617eb34 | ||
|
395e2b1d86 | ||
|
90e078fa86 | ||
|
8a203cb096 | ||
|
c94c64b106 | ||
|
39cdef0b02 | ||
|
709220e19e | ||
|
8af1ea67d3 | ||
|
384056b3bb | ||
|
20a20cd7be | ||
|
3943d08ab6 | ||
|
08e76b33d0 | ||
|
94c40e6d07 | ||
|
0e5c18907d | ||
|
485771b8f2 | ||
|
293a574d2b | ||
|
167fee8175 | ||
|
ad8a3eaff2 | ||
|
5981daf86a | ||
|
cb56a98d27 | ||
|
607a4e13bf | ||
|
e870d45f90 | ||
|
1d8cabf5ee | ||
|
857e9e0fd5 | ||
|
1f89dbc481 | ||
|
ba8a89ee6a | ||
|
025aee43c8 | ||
|
261b5c5bbe | ||
|
ebb7ceb466 | ||
|
79daaf1461 | ||
|
e2537df697 | ||
|
0b78c78a0a | ||
|
f6b6134d5b | ||
|
67f0449963 | ||
|
5a2d5648e0 | ||
|
f0c0b9a0f6 | ||
|
eeca5480ec | ||
|
d882fe9bcf | ||
|
6aecd7d48e | ||
|
523bec7446 | ||
|
6eaf272d5d | ||
|
3ad0c9da52 | ||
|
a33fea6ba6 | ||
|
41d64135e5 | ||
|
ef165b0cff | ||
|
55b1a9bce0 | ||
|
63a9233b15 | ||
|
c992bf4b4f | ||
|
6c0d1fbc7c | ||
|
ebb23863dd | ||
|
0f507ef316 | ||
|
51bd3fb832 | ||
|
76cfbf54c3 | ||
|
d6c850cae1 | ||
|
e1e7768c08 | ||
|
a8750afa7e | ||
|
65bbeb71dd | ||
|
a5206c965c | ||
|
1b7f802013 | ||
|
d81be0b595 | ||
|
a6105973f3 | ||
|
1cd1dc87a9 | ||
|
43556e97aa | ||
|
e1e45f679b | ||
|
8622b5747f | ||
|
ba3fb61f8b | ||
|
59a1ade90a | ||
|
575cf4a77a | ||
|
e0bc32078b | ||
|
63b95b0604 | ||
|
4960a5f60d | ||
|
23daa25ca9 | ||
|
ffef145527 | ||
|
78ad0b18ec | ||
|
2a4d48d26c | ||
|
d04656762e | ||
|
9837814edb | ||
|
d10774c161 | ||
|
ff2e1e82b2 | ||
|
ca6773c18d | ||
|
ad26f1af3a | ||
|
0131183237 | ||
|
44636cf4f5 | ||
|
0ba2e2acdc | ||
|
918b2ac5cb | ||
|
285d9b7a46 | ||
|
16c10d9038 | ||
|
3f2417dd4d | ||
|
86b23bdf44 | ||
|
a7f1a16ba2 | ||
|
923879e249 | ||
|
a5bee4129b | ||
|
68ae8615f3 | ||
|
4f5c9e11a3 | ||
|
73ed98622c | ||
|
e7c2bf38cf | ||
|
f26b8ece56 | ||
|
6fef68d9ba | ||
|
af01d85945 | ||
|
4aed7bbd81 | ||
|
c59f7df174 | ||
|
83633509c2 | ||
|
5c747139be | ||
|
ef5ca1f2dd | ||
|
148808979b | ||
|
c056770a70 | ||
|
3e10f1a03c | ||
|
8912db80d7 | ||
|
dbfe5c13d0 | ||
|
cbbacc0ada | ||
|
ffff70229a | ||
|
0c433d54df | ||
|
8813b72ad2 | ||
|
cb8a308872 | ||
|
83bd12b222 | ||
|
c0d96ffdc8 | ||
|
06d1b3c63b | ||
|
cbaae4fd2c | ||
|
6486176d8f | ||
|
8e94b6d83c | ||
|
c0be13db8e | ||
|
8416a83757 | ||
|
30eca7029d | ||
|
fb30588566 | ||
|
6171fa85c5 | ||
|
c14a76e996 | ||
|
bbdc63f61c | ||
|
ae0ee5e7ef | ||
|
f17911f852 | ||
|
c8f7a7097c | ||
|
5cb00b90f6 | ||
|
ebedfae532 | ||
|
ca4b7aba04 | ||
|
64dfe54953 | ||
|
d0d4f2429c | ||
|
8999b3ab3b |
239 changed files with 18963 additions and 5887 deletions
55
.circleci/config.yml
Normal file
55
.circleci/config.yml
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
# JavaScript Node CircleCI 2.0 configuration file
|
||||||
|
#
|
||||||
|
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
|
||||||
|
#
|
||||||
|
version: 2
|
||||||
|
|
||||||
|
commands:
|
||||||
|
create_concatenated_package_lock:
|
||||||
|
description: "Concatenate all package-lock.json files recognized by lerna.js into single file. File is used as checksum source for part of caching key."
|
||||||
|
parameters:
|
||||||
|
filename:
|
||||||
|
type: string
|
||||||
|
steps:
|
||||||
|
- run:
|
||||||
|
name: Combine package-lock.json files to single file
|
||||||
|
command: npx lerna list -p -a | awk -F packages '{printf "\"packages%s/package-lock.json\" ", $2}' | xargs cat > << parameters.filename >>
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
docker:
|
||||||
|
# specify the version you desire here
|
||||||
|
- image: circleci/node:12.6
|
||||||
|
|
||||||
|
working_directory: ~/node-go
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
# - run: sudo apt-get install postgresql-client-11.4
|
||||||
|
# - run: pg_ctl -D /var/lib/postgresql/data -l logfile start
|
||||||
|
# - run: psql CREATE DATABASE circle_test
|
||||||
|
|
||||||
|
# Download and cache dependencies
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- v1-dependencies-{{ checksum "package-lock.json" }}
|
||||||
|
# fallback to using the latest cache if no exact match is found
|
||||||
|
|
||||||
|
|
||||||
|
- run: npm install
|
||||||
|
- run: npm run bootstrap
|
||||||
|
|
||||||
|
- save_cache:
|
||||||
|
paths:
|
||||||
|
- node_modules
|
||||||
|
key:
|
||||||
|
v1-dependencies-{{ checksum "package-lock.json" }}
|
||||||
|
- run: npm test
|
||||||
|
- run: npm install react
|
||||||
|
- run: npm install react-dom
|
||||||
|
|
||||||
|
# ! temporary fix for deprecated package: minimist
|
||||||
|
- run: npm audit --audit-level=moderate
|
||||||
|
|
||||||
|
# DEPLOY
|
||||||
|
- run: git subtree push --prefix packages/server https://heroku:$HEROKU_API_KEY@git.heroku.com/$HK_API.git master
|
||||||
|
- run: git subtree push --prefix packages/play-node-go https://heroku:$HEROKU_API_KEY@git.heroku.com/$HK_PLAY.git master
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2021 Sorrel
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
158
README.md
158
README.md
|
@ -1,18 +1,170 @@
|
||||||
# Node Go
|
# Node Go
|
||||||
A browser application to play Go in real time.
|
A browser application to play Go in real time.
|
||||||
|
|
||||||
## Development Demo
|
|
||||||
[The project in it's current state](https://play-node-go.herokuapp.com/)
|
[The project in it's current state](https://play-node-go.herokuapp.com/)
|
||||||
|
[Client only prototype](https://sorrelbri.github.io/browser-go-proto/)
|
||||||
|
|
||||||
|
![Screenshot of an in-progress game of Go.](public/game-in-progress.png)
|
||||||
|
|
||||||
|
[About Go](#the-game-of-go)
|
||||||
|
[Technical Challenges](#technical-challenges)
|
||||||
|
[Setup For Development](#setup)
|
||||||
|
[Known Bugs](#known-bugs)
|
||||||
|
[Roadmap](#roadmap)
|
||||||
|
[Features](#features)
|
||||||
|
[Tech](#built-with)
|
||||||
|
|
||||||
|
---
|
||||||
|
## The Game of Go
|
||||||
|
Go is a 2 player abstract strategy game of perfect information.
|
||||||
|
|
||||||
|
Players take turns placing playing pieces called stones on the intersections of a gridded board. This board is usually a square 19 points across. Stones remain on the points at which they are placed unless they are captured by the opposing player. Capture occurs when a stone or group of stones no longer has any adjascent empty points.
|
||||||
|
|
||||||
|
Play ends when both players agree that they have exhausted all advantageous moves. Scoring is determined by counting and comparing the area controlled by either player.
|
||||||
|
|
||||||
|
For a more detailed explanation of the rules, please see [my previous illustrated explanation of the game of go](https://github.com/sorrelbri/browser-go-proto#the-game-of-go) or the [American Go Association's Concise Rules of Go.](https://www.usgo.org/aga-concise-rules-go)
|
||||||
|
|
||||||
|
---
|
||||||
|
## Technical Challenges
|
||||||
|
### Modeling Game State
|
||||||
|
A go board typically consists of 361 points which can exist in a number of states. Points can influence the state of points that are orthogonal neighbors. This relationship can be thought of as an undirected graph, with each point being a vertex typically of degree 4. Special cases include 'edge' points, whose degree is 3 or, in the case of corner points, 2.
|
||||||
|
|
||||||
|
Many of the methods that manage the state of the game and of the board, make use of this graph representation. Groups are contiguous points with the same color stone which are important in determining the life or death of stones on the board. When a player makes a move, (provided that move is legal,) the point at which the move is made will utilize a breadth-first graph traversal calling a `joinGroup` method on each point with the same color stone.
|
||||||
|
|
||||||
|
Adjacent points without stones are very important to the state of a point as well. These are known as liberties, and so long as a group of stones has at least one point with at least one liberty, that group remains alive and on the board. Therefore, the `joinGroup` method also utilizes a depth first traversal to mark all of the liberties of a group. Both the stones and the liberties of the group are memoized on the Game object.
|
||||||
|
|
||||||
|
![Image of Game logic](public/game-logic.png)
|
||||||
|
|
||||||
|
### Game Records
|
||||||
|
For the moment, game records are modeled as a list where each move has the type `{player: <string: player color>, pos: {x: <integer>, y: <integer>}}`.
|
||||||
|
|
||||||
|
The database `move` table contains additional information `number`, `game_record`, and `prior_move` in addition to a foreign key for a `game` row. `number` represents the move number in a game record (for now this corresponds to list position), `game_record` is a boolean representing whether the move was 'official' or is an alternate move used in study, and `prior_move` is a reference to another `move` row allowing for the construction of a tree model for the game (see [Expanding this representation](#expanding-this-representation), below.)
|
||||||
|
|
||||||
|
There is a backend service that processes this list of moves into a current board state ([Modeling Game State](#modeling-game-state).) On the frontend, users have the option of expanding a menu to view the move order in the format below.
|
||||||
|
|
||||||
|
![Game Record: Black and white 19x19 grid with moves represented as circles filled in with stone color and marked with move number. Below the grid is an overflow area for moves made at previously played points in the format /[new move number and color at old move number and color/]](public/game-record.png)
|
||||||
|
|
||||||
|
This is a customary representation of game records printed in Go literature. A frontend service processes the list of moves and plots each move onto a `<canvas>` element drawn to resemble the grid lines on a board, with moves that are placed at prior points plotted on an additional `<canvas>` element below.
|
||||||
|
|
||||||
|
#### Expanding this representation
|
||||||
|
This representation will be expanded when support for alternate game paths is added. Alternate game paths will allow users to study completed games by playing out the consequences of moves not in the completed game. This feature will require a tree structure for the game record where moves on the main line are referred with a `main` property on each move node and alternate moves with any number of alternate references.
|
||||||
|
|
||||||
|
### Caching multiple in-progress games
|
||||||
|
![Image of Game module in context](public/game-module.png)
|
||||||
|
|
||||||
|
### Partitioning Game Rooms
|
||||||
|
Finding a game starts with joining a game room.
|
||||||
|
![Image of Home Screen with 'main' game room](public/home-screen.png)
|
||||||
|
Watch an in progress game, join a game, or study a historic game.
|
||||||
|
![Image of Room Screen with multiple games in various states](public/room-screen.png)
|
||||||
|
|
||||||
|
---
|
||||||
|
## Setup
|
||||||
|
### Local Repo
|
||||||
|
```sh
|
||||||
|
$ git clone https://github.com/sorrelbri/node-go.git
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install Deps
|
||||||
|
```sh
|
||||||
|
$ npm run bootstrap
|
||||||
|
```
|
||||||
|
Runs lerna `bootstrap` command installing dependencies for project, development and package dependencies
|
||||||
|
|
||||||
|
### Initialize Database
|
||||||
|
#### Download PostgreSQL
|
||||||
|
To verify PostgreSQL installation:
|
||||||
|
```sh
|
||||||
|
$ psql -V
|
||||||
|
```
|
||||||
|
Node Go API was built with version 11.4.
|
||||||
|
[See documentation for Postgres download.](https://www.postgresql.org/download/)
|
||||||
|
|
||||||
|
#### Create Databases
|
||||||
|
```sh
|
||||||
|
$ psql
|
||||||
|
# psql(11.4)
|
||||||
|
```
|
||||||
|
```sql
|
||||||
|
CREATE DATABASE node-go;
|
||||||
|
CREATE DATABASE node-go-test; # testing database
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configure Environment
|
||||||
|
```sh
|
||||||
|
$ touch packages/server/.env
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
# .env
|
||||||
|
NODE_ENV=development
|
||||||
|
PORT=# set development port for API
|
||||||
|
REACT_ADDRESS=http://localhost:3000 # default
|
||||||
|
PG_CONNECTION_STRING=postgresql://localhost:5432/node-go
|
||||||
|
PG_CONNECTION_STRING_TEST=postgresql://localhost:5432/node-go-test
|
||||||
|
JWT_SECRET=# generate a secret key for JWT signing algorithm
|
||||||
|
TEST_SECRET=# same as above, for test environment
|
||||||
|
SALT_ROUNDS=# set number of salt rounds for bcrypt hashing function
|
||||||
|
DOMAIN=localhost
|
||||||
|
USER_ONE_PASSWORD=# credentials for testing with
|
||||||
|
USER_ONE_EMAIL=# same as above
|
||||||
|
```
|
||||||
|
|
||||||
|
### Smoke test
|
||||||
|
```sh
|
||||||
|
$ lerna run test
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run Database Migrations
|
||||||
|
```sh
|
||||||
|
$ cd packages/server; npm run migrate; npm run seed
|
||||||
|
```
|
||||||
|
|
||||||
|
### Running in development
|
||||||
|
```sh
|
||||||
|
$ cd packages/server
|
||||||
|
$ npm start # or if you have nodemon
|
||||||
|
$ nodemon
|
||||||
|
```
|
||||||
|
```sh
|
||||||
|
$ cd packages/play-node-go
|
||||||
|
$ npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
## Known Bugs
|
||||||
|
- game end logic not implemented on front end yet
|
||||||
|
- no authorization for game moves
|
||||||
|
- websocket connections may remain open, pooling prevents runaway leaks, but tests may hang
|
||||||
|
|
||||||
|
---
|
||||||
|
## Roadmap
|
||||||
|
### 6/20
|
||||||
|
1. Frontend implementation of game end logic
|
||||||
|
2. Auth for games
|
||||||
|
3. Game request creation
|
||||||
|
### 7/20
|
||||||
|
1. Generate game records
|
||||||
|
2. Implement chat
|
||||||
|
3. Implement study mode
|
||||||
|
|
||||||
|
---
|
||||||
## Features
|
## Features
|
||||||
- [ ] Realtime communications
|
- [x] Realtime play
|
||||||
|
- [x] Account authentication
|
||||||
|
- [ ] Chat
|
||||||
|
- [ ] Study mode
|
||||||
- [ ] Multiple game settings
|
- [ ] Multiple game settings
|
||||||
- [ ] Customizable board size
|
- [ ] Customizable board size
|
||||||
|
- [ ] Download games in .sgf format
|
||||||
|
|
||||||
|
---
|
||||||
## Built with
|
## Built with
|
||||||
- [Express](https://expressjs.com)
|
- [Express](https://expressjs.com)
|
||||||
- [React](https://reactjs.org)
|
- [React](https://reactjs.org)
|
||||||
- [PostgreSQL](https://postgresql.org)
|
- [PostgreSQL](https://postgresql.org)
|
||||||
- [Socket.io](https://socket.io)
|
- [Socket.io](https://socket.io)
|
||||||
- [Sass](https://sass-lang.com)
|
- [Sass](https://sass-lang.com)
|
||||||
|
### Management & Deployment
|
||||||
|
- Lerna
|
||||||
|
- CircleCI
|
6
lerna.json
Normal file
6
lerna.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"packages": [
|
||||||
|
"packages/*"
|
||||||
|
],
|
||||||
|
"version": "independent"
|
||||||
|
}
|
8014
package-lock.json
generated
Normal file
8014
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
18
package.json
Normal file
18
package.json
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "root",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"test": "lerna run test",
|
||||||
|
"bootstrap": "lerna bootstrap --hoist"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/preset-flow": "^7.8.3",
|
||||||
|
"@testing-library/jest-dom": "^4.2.4",
|
||||||
|
"@testing-library/react": "^9.4.0",
|
||||||
|
"chai": "^4.2.0",
|
||||||
|
"chai-http": "^4.3.0",
|
||||||
|
"lerna": "^3.20.2",
|
||||||
|
"mocha": "^7.0.0",
|
||||||
|
"react-test-renderer": "^16.12.0"
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,22 +1,21 @@
|
||||||
{
|
{
|
||||||
"name": "react-boilerplate",
|
"name": "play-node-go",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mars/heroku-js-runtime-env": "^3.0.2",
|
"@mars/heroku-js-runtime-env": "^3.0.2",
|
||||||
"@testing-library/user-event": "^7.1.2",
|
"@testing-library/user-event": "^7.1.2",
|
||||||
"flow-bin": "^0.114.0",
|
"node-sass": "^4.14.1",
|
||||||
"node-sass": "^4.13.0",
|
"react": "^16.13.1",
|
||||||
"react": "^16.12.0",
|
"react-dom": "^16.13.1",
|
||||||
"react-dom": "^16.12.0",
|
|
||||||
"react-router-dom": "^5.1.2",
|
"react-router-dom": "^5.1.2",
|
||||||
"react-scripts": "3.3.0",
|
"react-scripts": "^3.4.0",
|
||||||
"socket.io-client": "^2.3.0"
|
"socket.io-client": "^2.3.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "REACT_APP_ENVIRONMENT='development' react-scripts start",
|
"start": "REACT_APP_ENVIRONMENT='development' react-scripts start",
|
||||||
"build": "react-scripts build",
|
"build": "react-scripts build",
|
||||||
"test": "react-scripts test",
|
"test": "CI=true react-scripts test",
|
||||||
"eject": "react-scripts eject",
|
"eject": "react-scripts eject",
|
||||||
"flow": "./node_modules/.bin/flow",
|
"flow": "./node_modules/.bin/flow",
|
||||||
"predeploy": "REACT_APP_ENVIRONMENT=production npm run build",
|
"predeploy": "REACT_APP_ENVIRONMENT=production npm run build",
|
||||||
|
@ -36,10 +35,5 @@
|
||||||
"last 1 firefox version",
|
"last 1 firefox version",
|
||||||
"last 1 safari version"
|
"last 1 safari version"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@testing-library/jest-dom": "^4.2.4",
|
|
||||||
"@testing-library/react": "^9.4.0",
|
|
||||||
"react-test-renderer": "^16.12.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 318 B |
|
@ -11,6 +11,7 @@
|
||||||
/>
|
/>
|
||||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||||
<link rel="stylesheet" type="text/css" href="%PUBLIC_URL%/reset.css">
|
<link rel="stylesheet" type="text/css" href="%PUBLIC_URL%/reset.css">
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Oswald&display=swap" rel="stylesheet">
|
||||||
<title>Node Go</title>
|
<title>Node Go</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
|
@ -1,3 +1,8 @@
|
||||||
|
a, a:link, a:visited, a:focus, a:active {
|
||||||
|
color: unset;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
/* http://meyerweb.com/eric/tools/css/reset/
|
/* http://meyerweb.com/eric/tools/css/reset/
|
||||||
v2.0 | 20110126
|
v2.0 | 20110126
|
||||||
License: none (public domain)
|
License: none (public domain)
|
||||||
|
@ -46,3 +51,8 @@ table {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
border-spacing: 0;
|
border-spacing: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
@mixin fullspan {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin flexAround($direction) {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: $direction;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-around;
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin gameViewLabel {
|
||||||
|
color: rgb(255,240,230);
|
||||||
|
background-color: rgba(0,0,0,0.7);
|
||||||
|
padding: 0.25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
@function place-below($grid-column, $grid-row) {
|
||||||
|
@return $grid-row + 1 + '/' + $grid-column + 2 + '/ span 1 / span 1';
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
$dev-colors: (
|
||||||
|
"a": #34dc90,
|
||||||
|
"b": #9034dc,
|
||||||
|
"c": #dc9034,
|
||||||
|
"d": #dc34dc,
|
||||||
|
"e": #34dcdc,
|
||||||
|
"f": #dcdc34
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Responsive Design */
|
||||||
|
$break-points: (
|
||||||
|
"500": "only screen and (min-width: 500px)",
|
||||||
|
"570": "only screen and (min-width: 570px)",
|
||||||
|
"590": "only screen and (min-width: 590px)",
|
||||||
|
"700": "only screen and (min-width: 700px)",
|
||||||
|
"900": "only screen and (min-width: 900px)"
|
||||||
|
);
|
||||||
|
|
||||||
|
$colors: (
|
||||||
|
"error": #aa3333,
|
||||||
|
"nav_bar": #6f3e68,
|
||||||
|
"nav_link": #dae1b7,
|
||||||
|
"sidebar": #3c013f,
|
||||||
|
"sidebar_link": #f2ce3d,
|
||||||
|
"main": #95acae,
|
||||||
|
"home": #444444
|
||||||
|
);
|
||||||
|
|
||||||
|
$backgrounds: (
|
||||||
|
"game_room": radial-gradient(farthest-corner at 55% 40%, rgb(189, 131, 100) 0%, rgb(175, 113, 80) 65%, rgb(150, 90, 65) 90%, rgb(125, 65, 40) 100%),
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Game Room Components */
|
||||||
|
$small-room: (
|
||||||
|
"roof": linear-gradient(rgb(69, 36, 19), rgb(31, 22, 18)),
|
||||||
|
"body": rgb(174, 169, 120),
|
||||||
|
"door": radial-gradient(15vh 20vh at top left, #662413,#992413 15%, #cc3423),
|
||||||
|
"door-handle": radial-gradient(circle at 40% 30%, rgb(247, 235, 183), rgb(213, 222, 41) 30%, rgb(121, 108, 7)),
|
||||||
|
"window-x": linear-gradient(rgba(67, 149, 159, 0.4), rgba(196, 249, 255, 0.4) 50%, rgba(67, 149, 159, 0.4) 50%, rgba(196, 249, 255, 0.4)),
|
||||||
|
"window-y": linear-gradient(to right, rgba(67, 149, 159, 0.5), rgba(196, 249, 255, 0.5) 50%, rgba(67, 149, 159, 0.5) 50%, rgba(196, 249, 255, 0.5)),
|
||||||
|
"frame": rgb(69, 36, 19),
|
||||||
|
"sign": rgb(188, 127, 95)
|
||||||
|
);
|
|
@ -1,6 +1,5 @@
|
||||||
import React, {useState, useEffect, useReducer} from 'react';
|
import React, { useEffect, useReducer } from 'react';
|
||||||
import config from './config';
|
import { Switch, Route, BrowserRouter as Router } from 'react-router-dom';
|
||||||
import { Switch, Route, BrowserRouter as Router, Redirect } from 'react-router-dom';
|
|
||||||
import MainWrapper from './pages/Layout/MainWrapper/MainWrapper';
|
import MainWrapper from './pages/Layout/MainWrapper/MainWrapper';
|
||||||
import { stateReducer } from './reducers/reducer';
|
import { stateReducer } from './reducers/reducer';
|
||||||
import { initState } from './reducers/init/reducer.init';
|
import { initState } from './reducers/init/reducer.init';
|
||||||
|
@ -15,6 +14,7 @@ function App() {
|
||||||
initState
|
initState
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
const fetchIndexAPI = async () => {
|
const fetchIndexAPI = async () => {
|
||||||
const response = await indexServices.indexService();
|
const response = await indexServices.indexService();
|
||||||
if (response) {
|
if (response) {
|
||||||
|
@ -26,19 +26,19 @@ function App() {
|
||||||
dispatch(action)
|
dispatch(action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fetchIndexAPI();
|
||||||
|
}, [ ])
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchIndexAPI();
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const socketConnect = () => {
|
const socketConnect = () => {
|
||||||
if (state.connect.type) return;
|
if (state.connect.type) return;
|
||||||
dispatch({type:'SOCKET', message: 'LAUNCH', body:{nsp:'', dispatch}});
|
dispatch({type:'SOCKET', message: 'LAUNCH', body:{nsp:'', dispatch}});
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
socketConnect();
|
socketConnect();
|
||||||
}, [])
|
|
||||||
|
return () => dispatch({type: 'SOCKET', message: 'DISCONNECT', body: {}});
|
||||||
|
}, [ state.connect ])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Router>
|
<Router>
|
115
packages/play-node-go/src/components/Button/Game/Game.js
Normal file
115
packages/play-node-go/src/components/Button/Game/Game.js
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import './Game.scss';
|
||||||
|
|
||||||
|
const GameButton = (props) => {
|
||||||
|
const { game, user } = props;
|
||||||
|
|
||||||
|
const setGameDisplayData = () => {
|
||||||
|
const gameData = {
|
||||||
|
playerBlack: game.playerBlack,
|
||||||
|
playerBlackRank: game.playerBlackRank,
|
||||||
|
gameId: game.id,
|
||||||
|
}
|
||||||
|
if (game.open) {
|
||||||
|
gameData.gameLinkText = 'Request to Join Game';
|
||||||
|
gameData.playerWhite = '';
|
||||||
|
gameData.playerWhiteRank = 'could be you!';
|
||||||
|
}
|
||||||
|
if (!game.open) {
|
||||||
|
gameData.playerWhite = game.playerWhite;
|
||||||
|
gameData.playerWhiteRank = game.playerWhiteRank;
|
||||||
|
gameData.gameLinkText = game.winType ? 'Study Game'
|
||||||
|
: user ? 'Rejoin Game' : 'Watch Game'
|
||||||
|
}
|
||||||
|
return gameData;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO add to open game link
|
||||||
|
// const requestJoinGame = () => {
|
||||||
|
// console.log(`request to Join Game ${game.id}!`)
|
||||||
|
// const requestAction = {
|
||||||
|
// type: 'GAMES',
|
||||||
|
// message: 'JOIN_REQUEST',
|
||||||
|
// body: {id: game.id}
|
||||||
|
// }
|
||||||
|
// dispatch(requestAction);
|
||||||
|
// }
|
||||||
|
|
||||||
|
const renderGame = () => {
|
||||||
|
const {
|
||||||
|
gameLinkText,
|
||||||
|
playerBlack,
|
||||||
|
playerBlackRank,
|
||||||
|
gameId,
|
||||||
|
playerWhite,
|
||||||
|
playerWhiteRank
|
||||||
|
} = setGameDisplayData();
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="GameButton__seat GameButton__seat--black">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="GameButton__table">
|
||||||
|
<div className="GameButton__table__meta">
|
||||||
|
<div
|
||||||
|
className="GameButton__player-data GameButton__player-data--black"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="GameButton__player-data__name GameButton__player-data__name--black"
|
||||||
|
>{playerBlack}</span>
|
||||||
|
<span
|
||||||
|
className="GameButton__player-data__rank GameButton__player-data__rank"
|
||||||
|
>{playerBlackRank}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Link
|
||||||
|
className="GameButton__link"
|
||||||
|
to={`/games/${gameId}`}
|
||||||
|
>{gameLinkText}</Link>
|
||||||
|
|
||||||
|
<div
|
||||||
|
className={`GameButton__player-data GameButton__player-data--white ${
|
||||||
|
playerWhite ? '' : 'GameButton__player-data--invisible'
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="GameButton__player-data__name GameButton__player-data__name--white"
|
||||||
|
>{playerWhite}</span>
|
||||||
|
<span
|
||||||
|
className="GameButton__player-data__rank GameButton__player-data__rank--white"
|
||||||
|
>{playerWhiteRank}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="GameButton__table__image">
|
||||||
|
<div className="table__player-area table__player-area--black">
|
||||||
|
<div className="table__player-bowl table__player-bowl--black"></div>
|
||||||
|
</div>
|
||||||
|
<div className="table__game-board">
|
||||||
|
<div className="table__game-board--grid"></div>
|
||||||
|
</div>
|
||||||
|
<div className="table__player-area table__player-area--white">
|
||||||
|
<div className="table__player-bowl table__player-bowl--white"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="GameButton__seat GameButton__seat--white">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="GameButton" data-testid="GameButton">
|
||||||
|
{renderGame()}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default GameButton;
|
|
@ -1,7 +1,7 @@
|
||||||
|
@import '../../../../public/stylesheets/partials/mixins';
|
||||||
|
|
||||||
div.GameButton {
|
div.GameButton {
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
box-shadow: -2vmin 4vmin 2vmin rgba(83, 53, 35, 0.81);
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: column nowrap;
|
flex-flow: column nowrap;
|
||||||
height: 20vh;
|
height: 20vh;
|
||||||
|
@ -11,7 +11,7 @@ div.GameButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
div.GameButton__seat {
|
div.GameButton__seat {
|
||||||
background-color: red;
|
background: linear-gradient(190deg, rgb(232, 78, 78), rgb(172, 18, 18) 40%, rgb(100, 0, 0));
|
||||||
height: 10%;
|
height: 10%;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
width: 50%;
|
width: 50%;
|
||||||
|
@ -29,6 +29,7 @@ div.GameButton__seat {
|
||||||
}
|
}
|
||||||
|
|
||||||
div.GameButton__table {
|
div.GameButton__table {
|
||||||
|
box-shadow: -2vmin 4vmin 2vmin rgba(83, 53, 35, 0.81);
|
||||||
height: 80%;
|
height: 80%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -66,15 +67,16 @@ div.GameButton__table__image {
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
|
|
||||||
div.table__game-board {
|
div.table__game-board {
|
||||||
|
align-items: center;
|
||||||
background: radial-gradient(
|
background: radial-gradient(
|
||||||
farthest-corner at 55% 40%,
|
farthest-corner at 55% 40%,
|
||||||
rgb(244, 230, 120) 0%, rgb(234, 178, 78) 65%, rgb(200, 160, 90) 90%, rgb(200, 140, 90) 100%
|
rgb(244, 230, 120) 0%, rgb(234, 178, 78) 65%, rgb(200, 160, 90) 90%, rgb(200, 140, 90) 100%
|
||||||
);
|
);
|
||||||
|
box-shadow: -0.5vh 1vh 2vh rgba(30,30,30, 0.7);
|
||||||
height: 60%;
|
height: 60%;
|
||||||
|
justify-content: center;
|
||||||
width: 60%;
|
width: 60%;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
|
|
||||||
div.table__game-board--grid {
|
div.table__game-board--grid {
|
||||||
background:
|
background:
|
||||||
|
@ -98,6 +100,7 @@ div.table__player-area {
|
||||||
rgb(100, 40, 5) 80%, rgb(80, 20, 0) 90%
|
rgb(100, 40, 5) 80%, rgb(80, 20, 0) 90%
|
||||||
);
|
);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
|
box-shadow: -0.5vh 1vh 2vh rgba(30,30,30, 0.7);
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
&--white {
|
&--white {
|
||||||
|
@ -112,11 +115,15 @@ div.table__player-area {
|
||||||
}
|
}
|
||||||
|
|
||||||
div.GameButton__player-data {
|
div.GameButton__player-data {
|
||||||
background-color: rgba(255,255,255,0.65);
|
@include gameViewLabel;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
|
||||||
|
&.GameButton__player-data--invisible {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
&.GameButton__player-data--white {
|
&.GameButton__player-data--white {
|
||||||
margin: 0 5vw 1vw 0.5vw;
|
margin: 0 5vw 1vw 0.5vw;
|
||||||
}
|
}
|
||||||
|
@ -126,8 +133,7 @@ div.GameButton__player-data {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.GameButton__link {
|
a.GameButton__link {
|
||||||
background-color: rgba(255, 255, 255, 0.95);
|
@include gameViewLabel;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: .5vw;
|
|
||||||
}
|
}
|
34
packages/play-node-go/src/components/Button/Guest/Guest.js
Normal file
34
packages/play-node-go/src/components/Button/Guest/Guest.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import React from "react";
|
||||||
|
import authServices from "../../../services/authServices";
|
||||||
|
|
||||||
|
const Guest = ({ dispatch }) => {
|
||||||
|
const handleClick = async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
// dispatch to guest endpoint
|
||||||
|
const guestResponse = await authServices.guestService();
|
||||||
|
|
||||||
|
if (guestResponse.errors) {
|
||||||
|
const authError = guestResponse.errors[0].auth;
|
||||||
|
return dispatch({
|
||||||
|
type: "ERR",
|
||||||
|
message: "AUTH_ERROR",
|
||||||
|
body: { authError },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return dispatch({
|
||||||
|
type: "AUTH",
|
||||||
|
message: "GUEST",
|
||||||
|
body: guestResponse,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<button className="nav__section__button" onClick={handleClick}>
|
||||||
|
Continue As Guest
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Guest;
|
|
@ -0,0 +1,18 @@
|
||||||
|
import React from 'react';
|
||||||
|
import './Library.scss';
|
||||||
|
|
||||||
|
const LibraryButton = () => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="nav__section"
|
||||||
|
>
|
||||||
|
<p
|
||||||
|
className="nav__section__label"
|
||||||
|
>
|
||||||
|
Library
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LibraryButton;
|
|
@ -0,0 +1,18 @@
|
||||||
|
import React from 'react';
|
||||||
|
import './NewGame.scss';
|
||||||
|
|
||||||
|
const NewGameButton = () => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="nav__section"
|
||||||
|
>
|
||||||
|
<p
|
||||||
|
className="nav__section__label"
|
||||||
|
>
|
||||||
|
New Game
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default NewGameButton;
|
|
@ -0,0 +1,18 @@
|
||||||
|
import React from 'react';
|
||||||
|
import './NewRoom.scss';
|
||||||
|
|
||||||
|
const NewRoomButton = () => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="nav__section"
|
||||||
|
>
|
||||||
|
<p
|
||||||
|
className="nav__section__label"
|
||||||
|
>
|
||||||
|
New Room
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default NewRoomButton;
|
71
packages/play-node-go/src/components/Button/Room/Room.js
Normal file
71
packages/play-node-go/src/components/Button/Room/Room.js
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import RoomDetail from '../../Display/RoomDetail/RoomDetail';
|
||||||
|
import './Room.scss';
|
||||||
|
|
||||||
|
const RoomButton = ({room, roomDetail, showRoomDetail}) => {
|
||||||
|
const smallRoom = (
|
||||||
|
<div className="small-room">
|
||||||
|
<div className="small-room__roof">
|
||||||
|
<div className="small-room__roof-top small-room__roof-top--left"></div>
|
||||||
|
<div className="small-room__roof--left"></div>
|
||||||
|
<div className="small-room__roof-top small-room__roof-top--right"></div>
|
||||||
|
<div className="small-room__roof--right"></div>
|
||||||
|
</div>
|
||||||
|
<div className="small-room__body">
|
||||||
|
<div className="small-room__trim small-room__trim--left"></div>
|
||||||
|
<div className="small-room__sign">
|
||||||
|
<div className="small-room__sign__stone small-room__sign__stone--black"></div>
|
||||||
|
<div className="small-room__sign__stone small-room__sign__stone--white"></div>
|
||||||
|
<div className="small-room__sign__stone small-room__sign__stone--white"></div>
|
||||||
|
<div className="small-room__sign__stone small-room__sign__stone--black"></div>
|
||||||
|
</div>
|
||||||
|
<div className="small-room__window small-room__window--left">
|
||||||
|
<div className="small-room__window-frame small-room__window-frame--top"></div>
|
||||||
|
<div className="small-room__window-frame small-room__window-frame--left"></div>
|
||||||
|
<div className="small-room__window-frame small-room__window-frame--middle"></div>
|
||||||
|
<div className="small-room__window-frame small-room__window-frame--center"></div>
|
||||||
|
<div className="small-room__window-frame small-room__window-frame--right"></div>
|
||||||
|
<div className="small-room__window-frame small-room__window-frame--bottom"></div>
|
||||||
|
</div>
|
||||||
|
<div className="small-room__door">
|
||||||
|
<div className="small-room__door-frame small-room__door-frame--top"></div>
|
||||||
|
<div className="small-room__door-frame small-room__door-frame--left"></div>
|
||||||
|
<div className="small-room__door-handle"></div>
|
||||||
|
<div className="small-room__door-frame small-room__door-frame--right"></div>
|
||||||
|
</div>
|
||||||
|
<div className="small-room__window small-room__window--right">
|
||||||
|
<div className="small-room__window-frame small-room__window-frame--top"></div>
|
||||||
|
<div className="small-room__window-frame small-room__window-frame--left"></div>
|
||||||
|
<div className="small-room__window-frame small-room__window-frame--middle"></div>
|
||||||
|
<div className="small-room__window-frame small-room__window-frame--center"></div>
|
||||||
|
<div className="small-room__window-frame small-room__window-frame--right"></div>
|
||||||
|
<div className="small-room__window-frame small-room__window-frame--bottom"></div>
|
||||||
|
</div>
|
||||||
|
<div className="small-room__trim small-room__trim--bottom-left"></div>
|
||||||
|
<div className="small-room__trim small-room__trim--right"></div>
|
||||||
|
<div className="small-room__trim small-room__trim--bottom-right"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="RoomButton" data-testid="RoomButton">
|
||||||
|
<h4 className="RoomButton__room-link RoomButton__room-link--action">
|
||||||
|
<Link to={`/rooms/${room.id}`}>Join {room.name}</Link>
|
||||||
|
</h4>
|
||||||
|
<h4
|
||||||
|
className="RoomButton__room-link RoomButton__room-link--info --link"
|
||||||
|
onClick={e => showRoomDetail(room.id)}
|
||||||
|
>
|
||||||
|
?
|
||||||
|
</h4>
|
||||||
|
{smallRoom}
|
||||||
|
</div>
|
||||||
|
{roomDetail ? <RoomDetail room={room} /> : <></>}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default RoomButton;
|
227
packages/play-node-go/src/components/Button/Room/Room.scss
Normal file
227
packages/play-node-go/src/components/Button/Room/Room.scss
Normal file
|
@ -0,0 +1,227 @@
|
||||||
|
@import '../../../../public/stylesheets/partials/mixins';
|
||||||
|
@import '../../../../public/stylesheets/partials/variables';
|
||||||
|
|
||||||
|
div.RoomButton {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: [left] 1fr [right];
|
||||||
|
grid-template-rows: [top] 1fr [middle] 4fr [bottom];
|
||||||
|
height: 20vh;
|
||||||
|
padding: 1vw;
|
||||||
|
width: 20vh;
|
||||||
|
|
||||||
|
.RoomButton__room-link {
|
||||||
|
@include gameViewLabel;
|
||||||
|
align-self: self-end;
|
||||||
|
grid-area: top/left/middle/right;
|
||||||
|
max-width: fit-content;
|
||||||
|
z-index: 1;
|
||||||
|
|
||||||
|
&--info {
|
||||||
|
justify-self: end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
div.small-room {
|
||||||
|
display: grid;
|
||||||
|
grid-area: top/left/bottom/right;
|
||||||
|
grid-template-rows: [sky-start] 4vh [roof-start] 5vh [body-start] 1fr [body-end];
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.small-room__roof {
|
||||||
|
display: grid;
|
||||||
|
grid-row: roof-start / body-start;
|
||||||
|
grid-template-columns: [left] 10vh [middle] 10vh [right];
|
||||||
|
grid-template-rows: 1fr;
|
||||||
|
height: 100%;
|
||||||
|
max-width: 20vh;
|
||||||
|
|
||||||
|
.small-room__roof-top {
|
||||||
|
background: map-get($small-room, "roof");
|
||||||
|
box-shadow: 0 0.35vh 0.75vh map-get($colors, "home");
|
||||||
|
grid-row: 1 / 2;
|
||||||
|
height: 0.7vh;
|
||||||
|
position: relative;
|
||||||
|
top: 3vh;
|
||||||
|
width: 12vh;
|
||||||
|
|
||||||
|
&--left {
|
||||||
|
grid-column: left / middle;
|
||||||
|
left: -1.2vh;
|
||||||
|
transform: rotate(-26deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
&--right {
|
||||||
|
grid-column: middle / right;
|
||||||
|
left: -0.8vh;
|
||||||
|
transform: rotate(26deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&--left {
|
||||||
|
border-right: map-get($small-room, "body") solid 10vh;
|
||||||
|
border-top: map-get($colors, "home") solid 5vh;
|
||||||
|
grid-column: left / middle;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--right {
|
||||||
|
border-left: map-get($small-room, "body") solid 10vh;
|
||||||
|
border-top: map-get($colors, "home") solid 5vh;
|
||||||
|
grid-column: middle / right;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.small-room__body {
|
||||||
|
background-color: map-get($small-room, "body");
|
||||||
|
display: grid;
|
||||||
|
grid-row: body-start / body-end;
|
||||||
|
grid-template-areas:
|
||||||
|
"trim-left gap-left top-left gap-mid-left top-mid gap-mid-right top-right gap-right trim-right"
|
||||||
|
"trim-left gap-left top-left gap-mid-left top-mid gap-mid-right top-right gap-right trim-right"
|
||||||
|
"trim-left gap-left window--left gap-mid-left door gap-mid-right window--right gap-right trim-right"
|
||||||
|
"trim-left trim--bottom-left trim--bottom-left trim--bottom-left door trim--bottom-right trim--bottom-right trim--bottom-right trim-right";
|
||||||
|
grid-template-columns: 0.5vh 1vh 2fr 1vh 3fr 1vh 2fr 1vh 0.5vh;
|
||||||
|
grid-template-rows: 1fr 1vh 5fr 0.75vh;
|
||||||
|
justify-self: center;
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.small-room__trim {
|
||||||
|
background-color: map-get($small-room, "frame");
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
&--left {
|
||||||
|
grid-area: trim-left;
|
||||||
|
justify-self: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--right {
|
||||||
|
grid-area: trim-right;
|
||||||
|
justify-self: end;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--bottom-left {
|
||||||
|
grid-area: trim--bottom-left;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--bottom-right {
|
||||||
|
grid-area: trim--bottom-right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.small-room__sign {
|
||||||
|
background-color: map-get($small-room, "sign");
|
||||||
|
display: grid;
|
||||||
|
gap: 0.1vh;
|
||||||
|
grid-area: top-mid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
grid-template-rows: 1fr 1fr;
|
||||||
|
height: 2vh;
|
||||||
|
justify-self: center;
|
||||||
|
padding: 0.1vh;
|
||||||
|
width: 2vh;
|
||||||
|
|
||||||
|
.small-room__sign__stone {
|
||||||
|
border-radius: 100%;
|
||||||
|
|
||||||
|
&--white {
|
||||||
|
background-color: #FFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--black {
|
||||||
|
background-color: #000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.small-room__window {
|
||||||
|
align-self: center;
|
||||||
|
background: map-get($small-room, "window-x"), map-get($small-room, "window-y");
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 5fr 1fr 5fr 1fr;
|
||||||
|
grid-template-rows: 1fr 5fr 1fr 5fr 1fr;
|
||||||
|
height: 60%;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
&--left {
|
||||||
|
grid-area: window--left;
|
||||||
|
}
|
||||||
|
&--right {
|
||||||
|
grid-area: window--right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.small-room__window-frame {
|
||||||
|
background-color: map-get($small-room, "frame");
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
&--top {
|
||||||
|
grid-area: 1/1/2/6;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--center {
|
||||||
|
grid-area: 3/1/4/6;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--bottom {
|
||||||
|
grid-area: 5/1/6/6;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--left {
|
||||||
|
grid-area: 1/1/6/2;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--middle {
|
||||||
|
grid-area: 1/3/6/4;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--right {
|
||||||
|
grid-area: 1/5/6/6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.small-room__door {
|
||||||
|
grid-area: door;
|
||||||
|
background: map-get($small-room, "door");
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 0.5vh 1fr 0.5vh;
|
||||||
|
grid-template-rows: 0.5vh 1fr;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.small-room__door-handle {
|
||||||
|
align-self: center;
|
||||||
|
background: map-get($small-room, "door-handle");
|
||||||
|
border-radius: 50%;
|
||||||
|
box-shadow: 0.1vh 0.25vh 0.4vh rgba(30, 30, 30, 0.7);
|
||||||
|
grid-area: 2/2/3/3;
|
||||||
|
height: 0.75vh;
|
||||||
|
justify-self: end;
|
||||||
|
margin: 0.5vh 0.5vh 0 0;
|
||||||
|
width: 0.75vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.small-room__door-frame {
|
||||||
|
background-color: map-get($small-room, "frame");
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
&--top {
|
||||||
|
grid-area: 1/1/2/3;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--left {
|
||||||
|
grid-area: 1/1/3/2;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--left {
|
||||||
|
grid-area: 1/3/3/4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
import React from 'react';
|
||||||
|
import './RoomArchive.scss';
|
||||||
|
|
||||||
|
const RoomArchiveButton = () => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="nav__section"
|
||||||
|
>
|
||||||
|
<p
|
||||||
|
className="nav__section__label"
|
||||||
|
>
|
||||||
|
Room Archive
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default RoomArchiveButton;
|
|
@ -3,6 +3,9 @@ div.Loading {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: row wrap;
|
flex-flow: row wrap;
|
||||||
height: 6vw;
|
height: 6vw;
|
||||||
|
left: 47vw;
|
||||||
|
position: absolute;
|
||||||
|
top: 45vh;
|
||||||
width: 6vw;
|
width: 6vw;
|
||||||
|
|
||||||
div.point {
|
div.point {
|
|
@ -0,0 +1,25 @@
|
||||||
|
import React from 'react';
|
||||||
|
import './RoomDetail.scss';
|
||||||
|
|
||||||
|
const RoomDetail = ({room}) => {
|
||||||
|
return (
|
||||||
|
<div className="RoomDetail">
|
||||||
|
<div className="RoomDetail__arrow"></div>
|
||||||
|
<div className="RoomDetail__data">
|
||||||
|
<div className="RoomDetail__heading">
|
||||||
|
<h3 className="RoomDetail__room-name">{room.name}</h3>
|
||||||
|
<div className="RoomDetail__room-lang"></div>
|
||||||
|
<p className="RoomDetail__room-description">{room.description}</p>
|
||||||
|
</div>
|
||||||
|
<div className="RoomDetail__current">
|
||||||
|
<h4 className="RoomDetail__current-header">Current:</h4>
|
||||||
|
<p className="RoomDetail__current-players"></p>
|
||||||
|
<p className="RoomDetail__current-games"></p>
|
||||||
|
<p className="RoomDetail__current-rank"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default RoomDetail;
|
|
@ -0,0 +1,32 @@
|
||||||
|
@import '../../../../public/stylesheets/partials/mixins';
|
||||||
|
@import '../../../../public/stylesheets/partials/variables';
|
||||||
|
|
||||||
|
div.RoomDetail {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: [left] 1fr [right];
|
||||||
|
grid-template-rows: [top] 1fr [middle] 9fr [bottom];
|
||||||
|
height: 20vh;
|
||||||
|
padding: 1vw;
|
||||||
|
width: 20vh;
|
||||||
|
|
||||||
|
div.RoomDetail__arrow {
|
||||||
|
border-top: map-get($colors, 'home') solid 2vh;
|
||||||
|
border-left: white solid 1.5vh;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.RoomDetail__data {
|
||||||
|
background-color: white;
|
||||||
|
height: 90%;
|
||||||
|
width: 100%;
|
||||||
|
padding: 1vh;
|
||||||
|
display: grid;
|
||||||
|
grid-template-rows: 2fr 3fr;
|
||||||
|
|
||||||
|
.RoomDetail__heading {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: row wrap;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||||
import './ActionError.scss';
|
import './ActionError.scss';
|
||||||
|
|
||||||
const ActionError = (props) => {
|
const ActionError = (props) => {
|
||||||
const errorMessage = props.error;
|
const errorMessage = props.error || '';
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className="error error--action"
|
className="error error--action"
|
|
@ -3,7 +3,7 @@ import { render } from '@testing-library/react';
|
||||||
import FormError from './FormError';
|
import FormError from './FormError';
|
||||||
|
|
||||||
test('renders FormError without crashing', () => {
|
test('renders FormError without crashing', () => {
|
||||||
const { getByTestId } = render(<FormError />);
|
const { getByTestId } = render(<FormError error={''}/>);
|
||||||
const FormErrorSpan = getByTestId('FormError');
|
const FormErrorSpan = getByTestId('FormError');
|
||||||
expect(FormErrorSpan).toBeInTheDocument();
|
expect(FormErrorSpan).toBeInTheDocument();
|
||||||
});
|
});
|
49
packages/play-node-go/src/components/Form/Auth/Auth.js
Normal file
49
packages/play-node-go/src/components/Form/Auth/Auth.js
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
import React, { useState } from "react";
|
||||||
|
|
||||||
|
import Login from "../Login/Login";
|
||||||
|
import Signup from "../Signup/Signup";
|
||||||
|
import Guest from "../../Button/Guest/Guest";
|
||||||
|
|
||||||
|
const Auth = (props) => {
|
||||||
|
const [showForm, setShowForm] = useState("login");
|
||||||
|
const { state, dispatch } = props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
className="nav__section nav__section--auth"
|
||||||
|
onClick={() => {
|
||||||
|
setShowForm("login");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<p className="nav__section__label">Login</p>
|
||||||
|
|
||||||
|
{showForm === "login" ? (
|
||||||
|
<Login dispatch={dispatch} state={state} />
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
className="nav__section nav__section--auth"
|
||||||
|
onClick={() => {
|
||||||
|
setShowForm("signup");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<p className="nav__section__label">Signup</p>
|
||||||
|
|
||||||
|
{showForm === "signup" ? (
|
||||||
|
<Signup dispatch={dispatch} state={state} />
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="nav__section nav__section--auth">
|
||||||
|
<Guest dispatch={dispatch} />
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Auth;
|
|
@ -0,0 +1,18 @@
|
||||||
|
import React from 'react';
|
||||||
|
import './FindGame.scss';
|
||||||
|
|
||||||
|
const FindGameForm = () => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="nav__section"
|
||||||
|
>
|
||||||
|
<p
|
||||||
|
className="nav__section__label"
|
||||||
|
>
|
||||||
|
Find Game
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FindGameForm;
|
|
@ -0,0 +1,18 @@
|
||||||
|
import React from 'react';
|
||||||
|
import './FindRoom.scss';
|
||||||
|
|
||||||
|
const FindRoomForm = () => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="nav__section"
|
||||||
|
>
|
||||||
|
<p
|
||||||
|
className="nav__section__label"
|
||||||
|
>
|
||||||
|
Find Room
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FindRoomForm;
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState } from 'react';
|
||||||
import './Signup.scss';
|
import './Signup.scss';
|
||||||
import authServices from '../../../services/authServices';
|
import authServices from '../../../services/authServices';
|
||||||
import FormError from '../../Error/FormError/FormError';
|
import FormError from '../../Error/FormError/FormError';
|
||||||
|
@ -22,7 +22,7 @@ const Signup = (props) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (password.length < 8) {
|
if (password.length < minimumPasswordLength) {
|
||||||
return props.dispatch({
|
return props.dispatch({
|
||||||
...errorDispatchAction,
|
...errorDispatchAction,
|
||||||
body: { authError: 'Password must be at least 8 characters'}
|
body: { authError: 'Password must be at least 8 characters'}
|
74
packages/play-node-go/src/components/GameUI/Board/Board.js
Normal file
74
packages/play-node-go/src/components/GameUI/Board/Board.js
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
import React from "react";
|
||||||
|
import "./Board.scss";
|
||||||
|
import Point from "../Point/Point";
|
||||||
|
|
||||||
|
const Board = (props) => {
|
||||||
|
const { game, user, dispatch, board, meta } = props;
|
||||||
|
const sizeFlag = `Game__board--size-${game.boardSize}`;
|
||||||
|
const hoshiPoints = {
|
||||||
|
9: { "3-3": true, "7-7": true, "3-7": true, "7-3": true },
|
||||||
|
13: {
|
||||||
|
"7-7": true,
|
||||||
|
"10-7": true,
|
||||||
|
"7-4": true,
|
||||||
|
"7-10": true,
|
||||||
|
"4-7": true,
|
||||||
|
"4-4": true,
|
||||||
|
"10-10": true,
|
||||||
|
"4-10": true,
|
||||||
|
"10-4": true,
|
||||||
|
},
|
||||||
|
19: {
|
||||||
|
"10-10": true,
|
||||||
|
"16-10": true,
|
||||||
|
"10-4": true,
|
||||||
|
"10-16": true,
|
||||||
|
"4-10": true,
|
||||||
|
"4-4": true,
|
||||||
|
"16-16": true,
|
||||||
|
"4-16": true,
|
||||||
|
"16-4": true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const isHoshi = (posX, posY) =>
|
||||||
|
hoshiPoints[game.boardSize][`${posX}-${posY}`];
|
||||||
|
|
||||||
|
const renderPoints = (boardSize) => {
|
||||||
|
let i = 0,
|
||||||
|
boardPoints = [];
|
||||||
|
while (i < boardSize * boardSize) {
|
||||||
|
const posX = Math.floor(i / boardSize) + 1;
|
||||||
|
const posY = (i % boardSize) + 1;
|
||||||
|
const pointData = board[`${posX}-${posY}`];
|
||||||
|
const dotData =
|
||||||
|
meta && meta.turn === 0 && !meta.winner && meta.territory
|
||||||
|
? meta.territory[`${posX}-${posY}`]
|
||||||
|
: game.turn || meta?.turn;
|
||||||
|
boardPoints.push(
|
||||||
|
<Point
|
||||||
|
key={`${posX}-${posY}`}
|
||||||
|
posX={posX}
|
||||||
|
posY={posY}
|
||||||
|
pointData={pointData}
|
||||||
|
dotData={dotData}
|
||||||
|
dispatch={dispatch}
|
||||||
|
user={user}
|
||||||
|
meta={meta}
|
||||||
|
hoshi={isHoshi(posX, posY)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return boardPoints;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={`Game__board ${sizeFlag}`}>
|
||||||
|
{game.id ? renderPoints(game.boardSize) : <></>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Board;
|
|
@ -2,8 +2,7 @@
|
||||||
@import '../../../../public/stylesheets/partials/variables';
|
@import '../../../../public/stylesheets/partials/variables';
|
||||||
|
|
||||||
div.Game__board {
|
div.Game__board {
|
||||||
@include fullspan;
|
// @include fullspan;
|
||||||
|
|
||||||
background: radial-gradient(farthest-corner at 55% 40%, rgb(244, 230, 120) 0%, rgb(234, 178, 78) 65%, rgb(200, 160, 90) 90%, rgb(200, 140, 90) 100%);
|
background: radial-gradient(farthest-corner at 55% 40%, rgb(244, 230, 120) 0%, rgb(234, 178, 78) 65%, rgb(200, 160, 90) 90%, rgb(200, 140, 90) 100%);
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
box-shadow: -2vmin 4vmin 3vmin rgba(145, 92, 23, 0.5);
|
box-shadow: -2vmin 4vmin 3vmin rgba(145, 92, 23, 0.5);
|
||||||
|
@ -51,8 +50,10 @@ div.Game__board {
|
||||||
height: 5vmin;
|
height: 5vmin;
|
||||||
|
|
||||||
@media #{map-get($break-points, "590")} {
|
@media #{map-get($break-points, "590")} {
|
||||||
height: 3.5vh;
|
height: 2.6vw;
|
||||||
width: 3.5vh;
|
width: 2.6vw;
|
||||||
|
max-width: 3.5vh;
|
||||||
|
max-height: 3.5vh;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
15
packages/play-node-go/src/components/GameUI/Kifu/Kifu.js
Normal file
15
packages/play-node-go/src/components/GameUI/Kifu/Kifu.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import React from "react";
|
||||||
|
import "./Kifu.scss";
|
||||||
|
|
||||||
|
const Kifu = ({ clickKifu }) => {
|
||||||
|
return (
|
||||||
|
<div className="Kifu">
|
||||||
|
<p className="Kifu__show-menu" onClick={clickKifu}>
|
||||||
|
Show Menu?
|
||||||
|
</p>
|
||||||
|
<div className="Kifu__board"></div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Kifu;
|
31
packages/play-node-go/src/components/GameUI/Kifu/Kifu.scss
Normal file
31
packages/play-node-go/src/components/GameUI/Kifu/Kifu.scss
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
@import '../../../../public/stylesheets/partials/mixins';
|
||||||
|
|
||||||
|
div.Kifu {
|
||||||
|
order: 0;
|
||||||
|
height: 10vh;
|
||||||
|
width: 8vh;
|
||||||
|
background-color: #FFF;
|
||||||
|
transform: rotate(-20deg);
|
||||||
|
|
||||||
|
p.Kifu__show-menu {
|
||||||
|
display: none;
|
||||||
|
margin: 3vh auto;
|
||||||
|
position: absolute;
|
||||||
|
transform: rotate(20deg);
|
||||||
|
width: fit-content;
|
||||||
|
}
|
||||||
|
&:hover {
|
||||||
|
p.Kifu__show-menu {
|
||||||
|
@include gameViewLabel;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
div.Kifu__board {
|
||||||
|
border: 0.25vh solid #444;
|
||||||
|
width: 5vh;
|
||||||
|
height: 5vh;
|
||||||
|
margin: 1vh 2vh 2vh auto;
|
||||||
|
}
|
||||||
|
}
|
194
packages/play-node-go/src/components/GameUI/Menu/Menu.js
Normal file
194
packages/play-node-go/src/components/GameUI/Menu/Menu.js
Normal file
|
@ -0,0 +1,194 @@
|
||||||
|
import React, { useEffect, useRef } from "react";
|
||||||
|
import "./Menu.scss";
|
||||||
|
|
||||||
|
const Menu = ({ showMenu, clickClose, ...props }) => {
|
||||||
|
const { active, meta } = props.state; // active.game.boardSize, meta.gameRecord
|
||||||
|
const boardSize = active.game.boardSize;
|
||||||
|
const handleBackgroundClick = (e) => {
|
||||||
|
if (e.target.className === "Game__Menu-container") clickClose();
|
||||||
|
};
|
||||||
|
const canvasRef = useRef();
|
||||||
|
const overflowRef = useRef();
|
||||||
|
const drawGameRecord = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<canvas ref={canvasRef} />
|
||||||
|
<canvas ref={overflowRef} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const clickPrint = () => {
|
||||||
|
const iframe = document.createElement("iframe");
|
||||||
|
const body = document.getElementsByTagName("body")[0];
|
||||||
|
const record = document.getElementById("record");
|
||||||
|
body.appendChild(iframe);
|
||||||
|
// move game record to iframe and print iframe
|
||||||
|
iframe.contentDocument.body.appendChild(canvasRef.current);
|
||||||
|
iframe.contentDocument.body.appendChild(overflowRef.current);
|
||||||
|
iframe.contentWindow.print();
|
||||||
|
// move game record back to menu and remove iframe
|
||||||
|
record.appendChild(canvasRef.current);
|
||||||
|
record.appendChild(overflowRef.current);
|
||||||
|
body.removeChild(iframe);
|
||||||
|
};
|
||||||
|
|
||||||
|
// draw canvases
|
||||||
|
useEffect(() => {
|
||||||
|
const canvas = canvasRef.current;
|
||||||
|
const ctx = canvas.getContext("2d");
|
||||||
|
const scale = Math.min(window.innerWidth * 0.75, 500);
|
||||||
|
canvas.height = scale;
|
||||||
|
canvas.width = scale;
|
||||||
|
const space = scale / boardSize;
|
||||||
|
const offset = space / 2;
|
||||||
|
for (let i = 0; i < boardSize; i++) {
|
||||||
|
const start = i * space + offset;
|
||||||
|
const end = scale - offset;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(start, offset);
|
||||||
|
ctx.lineTo(start, end);
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.stroke();
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(offset, start);
|
||||||
|
ctx.lineTo(end, start);
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
if (!meta?.gameRecord) return;
|
||||||
|
ctx.textAlign = "center";
|
||||||
|
ctx.textBaseline = "middle";
|
||||||
|
const { overflow } = meta.gameRecord.reduce(
|
||||||
|
(dict, { player, pos }, index) => {
|
||||||
|
const past = dict[`${pos.x}-${pos.y}`];
|
||||||
|
if (past) {
|
||||||
|
// overflow: [ { move:#, player:'color', subsequentMoves: [ { move: #, player: 'color' } ] } ]
|
||||||
|
if (dict.overflow) {
|
||||||
|
const indexOfPrior = dict.overflow.findIndex(
|
||||||
|
({ move }) => move === past
|
||||||
|
);
|
||||||
|
if (indexOfPrior !== -1) {
|
||||||
|
// if multiple past moves at this point exist
|
||||||
|
dict.overflow[indexOfPrior].subsequentMoves.push({
|
||||||
|
move: index + 1,
|
||||||
|
player,
|
||||||
|
});
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
// if a second move at this point has not yet been encountered
|
||||||
|
// prior move will be black if no active handicap and move is odd or if active handicap and move is even
|
||||||
|
const playerPrior =
|
||||||
|
(active.handicap && !(past % 2)) || past % 2 ? "black" : "white";
|
||||||
|
return {
|
||||||
|
...dict,
|
||||||
|
overflow: [
|
||||||
|
...dict.overflow,
|
||||||
|
{
|
||||||
|
move: past,
|
||||||
|
player: playerPrior,
|
||||||
|
subsequentMoves: [{ move: index + 1, player }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// if no move has yet been encountered at a previously made move
|
||||||
|
return {
|
||||||
|
...dict,
|
||||||
|
overflow: [
|
||||||
|
{ move: past, subsequentMoves: [{ move: index + 1, player }] },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(
|
||||||
|
(pos.y - 1) * space + offset,
|
||||||
|
(pos.x - 1) * space + offset,
|
||||||
|
offset * 0.95,
|
||||||
|
0,
|
||||||
|
Math.PI * 2,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
ctx.stroke();
|
||||||
|
ctx.fillStyle = player === "white" ? "#fff" : "#000";
|
||||||
|
ctx.fill();
|
||||||
|
ctx.fillStyle = player === "white" ? "#000" : "#fff";
|
||||||
|
|
||||||
|
ctx.fillText(
|
||||||
|
index + 1,
|
||||||
|
(pos.y - 1) * space + offset,
|
||||||
|
(pos.x - 1) * space + offset
|
||||||
|
);
|
||||||
|
return { ...dict, [`${pos.x}-${pos.y}`]: index + 1 };
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
if (!overflow?.length) return;
|
||||||
|
// Draw Overflow Moves (moves made at prior points)
|
||||||
|
const canvas2 = overflowRef.current;
|
||||||
|
const ctx2 = canvas2.getContext("2d");
|
||||||
|
canvas2.width = scale;
|
||||||
|
canvas2.height = space * overflow.length;
|
||||||
|
ctx2.textAlign = "center";
|
||||||
|
ctx2.textBaseline = "middle";
|
||||||
|
overflow.forEach(({ move, subsequentMoves, player }, index) => {
|
||||||
|
subsequentMoves.forEach(({ player, move }, subIndex) => {
|
||||||
|
ctx2.beginPath();
|
||||||
|
ctx2.arc(
|
||||||
|
subIndex * space + offset,
|
||||||
|
index * space + offset,
|
||||||
|
offset * 0.95,
|
||||||
|
0,
|
||||||
|
Math.PI * 2,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
ctx2.stroke();
|
||||||
|
ctx2.fillStyle = player === "white" ? "#fff" : "#000";
|
||||||
|
ctx2.fill();
|
||||||
|
ctx2.fillStyle = player === "white" ? "#000" : "#fff";
|
||||||
|
ctx2.fillText(move, subIndex * space + offset, index * space + offset);
|
||||||
|
});
|
||||||
|
ctx2.fillStyle = "#000";
|
||||||
|
ctx2.fillText(
|
||||||
|
"at",
|
||||||
|
subsequentMoves.length * space + offset,
|
||||||
|
index * space + offset
|
||||||
|
);
|
||||||
|
ctx2.fillStyle = player === "white" ? "#fff" : "#000";
|
||||||
|
ctx2.beginPath();
|
||||||
|
ctx2.arc(
|
||||||
|
(subsequentMoves.length + 1) * space + offset,
|
||||||
|
index * space + offset,
|
||||||
|
offset * 0.95,
|
||||||
|
0,
|
||||||
|
Math.PI * 2,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
ctx2.fill();
|
||||||
|
ctx2.stroke();
|
||||||
|
ctx2.fillStyle = player === "white" ? "#000" : "#fff";
|
||||||
|
ctx2.fillText(
|
||||||
|
move,
|
||||||
|
(subsequentMoves.length + 1) * space + offset,
|
||||||
|
index * space + offset
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}, [showMenu, meta, active.handicap, boardSize]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`Game__Menu-container${showMenu ? "" : "--hidden"}`}
|
||||||
|
onClick={(e) => handleBackgroundClick(e)}
|
||||||
|
>
|
||||||
|
<div className="Game__Menu-container__Menu">
|
||||||
|
<button onClick={clickClose}>X</button>
|
||||||
|
<button onClick={clickPrint}>Print Record</button>
|
||||||
|
<div id="record" className="Game__Menu__game-record-container">
|
||||||
|
{drawGameRecord()}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Menu;
|
29
packages/play-node-go/src/components/GameUI/Menu/Menu.scss
Normal file
29
packages/play-node-go/src/components/GameUI/Menu/Menu.scss
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
div.Game__Menu-container {
|
||||||
|
&--hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
background: rgba(0,0,0,0.5);
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column nowrap;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
position: absolute;
|
||||||
|
width: 100vw;
|
||||||
|
z-index: 2;
|
||||||
|
|
||||||
|
.Game__Menu-container__Menu {
|
||||||
|
background: #eef;
|
||||||
|
max-height: 90vh;
|
||||||
|
max-width: 80vw;
|
||||||
|
padding: 2vh;
|
||||||
|
overflow: scroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.Game__Menu__game-record-container {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column nowrap;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
import React from "react";
|
||||||
|
import "./PlayerArea.scss";
|
||||||
|
|
||||||
|
const PlayerArea = ({
|
||||||
|
handleResignClick,
|
||||||
|
handlePassClick,
|
||||||
|
playerMeta,
|
||||||
|
turn,
|
||||||
|
Kifu,
|
||||||
|
}) => {
|
||||||
|
const { stones, player, rank, captures } = playerMeta;
|
||||||
|
const isTurn =
|
||||||
|
(stones === "black" && turn === 1) || (stones === "white" && turn === -1);
|
||||||
|
const bowlAttributes = () => {
|
||||||
|
if (isTurn || turn === 0)
|
||||||
|
return {
|
||||||
|
"data-turn": true,
|
||||||
|
onClick: () => handlePassClick(stones),
|
||||||
|
};
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
const bowlText = () => {
|
||||||
|
if (isTurn) return "Pass?";
|
||||||
|
if (turn === 0) return "End Game?";
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={`player-container player-container--${stones}`}>
|
||||||
|
<div
|
||||||
|
className={`player-container__bowl player-container__bowl--${stones}`}
|
||||||
|
{...bowlAttributes()}
|
||||||
|
>
|
||||||
|
<p>{bowlText()}</p>
|
||||||
|
</div>
|
||||||
|
{Kifu}
|
||||||
|
<div
|
||||||
|
className={`player-container__name-space player-container__name-space--${stones}`}
|
||||||
|
>
|
||||||
|
<h4>
|
||||||
|
{playerMeta
|
||||||
|
? `${player || stones} ${rank || "?"}`
|
||||||
|
: "Waiting for player"}
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
<div
|
||||||
|
className={`player-container__caps-space player-container__caps-space__${stones}`}
|
||||||
|
>
|
||||||
|
<p
|
||||||
|
className={`player-container__resign-message player-container__resign-message--${stones}`}
|
||||||
|
{...(isTurn ? { onClick: () => handleResignClick(stones) } : null)}
|
||||||
|
>
|
||||||
|
Resign?
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p
|
||||||
|
className={`player-container__caps-counter player-container__caps-counter--${stones}`}
|
||||||
|
>
|
||||||
|
{playerMeta ? captures : "Captures go here"}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PlayerArea;
|
|
@ -0,0 +1,102 @@
|
||||||
|
@import '../../../../public/stylesheets/partials/variables';
|
||||||
|
@import '../../../../public/stylesheets/partials/mixins';
|
||||||
|
|
||||||
|
div.player-container {
|
||||||
|
align-items: flex-end;
|
||||||
|
display: flex;
|
||||||
|
flex: 5;
|
||||||
|
height: 9vmin;
|
||||||
|
justify-content: space-around;
|
||||||
|
margin: 1em;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
align-items: flex-start;
|
||||||
|
flex-direction: row-reverse;
|
||||||
|
justify-self: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media #{map-get($break-points, "500")} {
|
||||||
|
height: 14vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.player-container__bowl {
|
||||||
|
align-items: center;
|
||||||
|
background: radial-gradient(farthest-corner at 48% 54%, rgba(30, 5, 0, 0.25) 0%, rgba(30, 5, 0, 0.45) 2%, rgba(30, 5, 0, 0.75) 32%, rgba(0,0,0,0.85)35%, rgb(116,48,17) 48%, rgb(140, 60, 40) 52%, rgb(100, 40, 5) 55%, rgb(116, 48, 17) 58%, rgb(140,60,40) 65%, rgb(100, 40, 5) 80%, rgb(80, 20, 0) 90%);
|
||||||
|
background-color: rgb(116, 48, 17);
|
||||||
|
border-radius: 50%;
|
||||||
|
box-shadow: -1vmin 2vmin 1.5vmin rgba(83, 53, 35, 0.61);
|
||||||
|
display: flex;
|
||||||
|
height: 15vh;
|
||||||
|
justify-content: center;
|
||||||
|
margin: 4vh;
|
||||||
|
order: -1;
|
||||||
|
width: 15vh;
|
||||||
|
|
||||||
|
@media #{map-get($break-points, "570")} {
|
||||||
|
height: 10vh;
|
||||||
|
margin: 3vh;
|
||||||
|
width: 10vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-turn]:hover p {
|
||||||
|
background-color: rgba(0,0,0,0.3);
|
||||||
|
color: #FFF;
|
||||||
|
cursor: grab;
|
||||||
|
display: block;
|
||||||
|
padding: .5em;
|
||||||
|
}
|
||||||
|
&[data-turn] {
|
||||||
|
// highlight for turn
|
||||||
|
box-shadow: 0 0 3vh 3vh rgb(255, 175, 2);
|
||||||
|
|
||||||
|
& + .player-container__name-space .player-container__caps-space:hover :first-child {
|
||||||
|
background-color: rgba(0,0,0,0.7);
|
||||||
|
cursor: grab;
|
||||||
|
display: block;
|
||||||
|
padding: .5em;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
div.player-container__caps-space {
|
||||||
|
align-items: center;
|
||||||
|
background: radial-gradient(farthest-side at 49% 52%, rgb(150, 75, 50) 0%, rgb(116,48,17) 35%, rgb(116,48,17) 64%, rgb(80, 20, 0) 65%, rgb(175, 140, 95) 70%, rgb(120, 50, 40) 80%, rgb(80, 20, 0) 95%, rgb(175, 140, 95) 100%);
|
||||||
|
border-radius: 50%;
|
||||||
|
box-shadow: -0.5vmin 1vmin 1vmin rgba(83, 53, 35, 0.61);
|
||||||
|
color: #FFF;
|
||||||
|
display: flex;
|
||||||
|
height: 10vh;
|
||||||
|
justify-content: center;
|
||||||
|
margin: 1vh;
|
||||||
|
width: 10vh;
|
||||||
|
|
||||||
|
@media #{map-get($break-points, "570")} {
|
||||||
|
height: 7vh;
|
||||||
|
margin: 2vh;
|
||||||
|
width: 7vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
& :first-child {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
div.player-container__name-space {
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
display: flex;
|
||||||
|
order: 1;
|
||||||
|
|
||||||
|
h4 {
|
||||||
|
@include gameViewLabel;
|
||||||
|
font-size: 120%;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
}
|
96
packages/play-node-go/src/components/GameUI/Point/Point.js
Normal file
96
packages/play-node-go/src/components/GameUI/Point/Point.js
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
import React from "react";
|
||||||
|
import "./Point.scss";
|
||||||
|
|
||||||
|
const Point = (props) => {
|
||||||
|
const {
|
||||||
|
posX,
|
||||||
|
posY,
|
||||||
|
user,
|
||||||
|
game,
|
||||||
|
meta,
|
||||||
|
dispatch,
|
||||||
|
pointData,
|
||||||
|
dotData,
|
||||||
|
hoshi,
|
||||||
|
} = props;
|
||||||
|
const turn =
|
||||||
|
meta && meta.turn
|
||||||
|
? meta.turn > 0
|
||||||
|
? "black"
|
||||||
|
: "white"
|
||||||
|
: game.turn > 0
|
||||||
|
? "black"
|
||||||
|
: "white";
|
||||||
|
|
||||||
|
const stone = () => {
|
||||||
|
if (pointData === 1) return "black";
|
||||||
|
if (pointData === -1) return "white";
|
||||||
|
if (pointData === "k") return "ko";
|
||||||
|
return "none";
|
||||||
|
};
|
||||||
|
|
||||||
|
const xFlag = () => {
|
||||||
|
if (posX === 1) return `board__point--top`;
|
||||||
|
if (posX === game.boardSize) return `board__point--bottom`;
|
||||||
|
return "";
|
||||||
|
};
|
||||||
|
const yFlag = () => {
|
||||||
|
if (posY === 1) return `board__point--left`;
|
||||||
|
if (posY === game.boardSize) return `board__point--right`;
|
||||||
|
return "";
|
||||||
|
};
|
||||||
|
const clickHandle = (e) => {
|
||||||
|
if (meta?.turn === 0 && !meta?.winner) {
|
||||||
|
const action = {
|
||||||
|
type: "SOCKET",
|
||||||
|
message: "TOGGLE_TERRITORY",
|
||||||
|
body: { user, point: `${posX}-${posY}`, game, room: game.room },
|
||||||
|
};
|
||||||
|
return dispatch(action);
|
||||||
|
}
|
||||||
|
const action = {
|
||||||
|
type: "SOCKET",
|
||||||
|
message: "MAKE_MOVE",
|
||||||
|
body: {
|
||||||
|
user,
|
||||||
|
game,
|
||||||
|
room: game.room,
|
||||||
|
board: {},
|
||||||
|
move: { player: turn, pos: { x: posX, y: posY } },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
dispatch(action);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getDot = () => {
|
||||||
|
if (meta?.turn === 0) {
|
||||||
|
switch (dotData) {
|
||||||
|
case -1:
|
||||||
|
return "white";
|
||||||
|
case 1:
|
||||||
|
return "black";
|
||||||
|
case "d":
|
||||||
|
return "dame";
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dotData;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`board__point ${xFlag()} ${yFlag()}`}
|
||||||
|
onClick={(e) => clickHandle(e)}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className={`board__point__stone ${hoshi ? "hoshi" : ""}`}
|
||||||
|
data-stone={stone()}
|
||||||
|
>
|
||||||
|
<div className="board__point__dot" data-dot={getDot()}></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Point;
|
|
@ -5,6 +5,9 @@ div.board__point {
|
||||||
margin: auto;
|
margin: auto;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.board__point--top {
|
div.board__point--top {
|
||||||
|
@ -43,11 +46,14 @@ div.board__point__stone {
|
||||||
width: 85%;
|
width: 85%;
|
||||||
height: 85%;
|
height: 85%;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
margin: auto;
|
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
&.hoshi {
|
||||||
|
background: radial-gradient(circle farthest-corner at center, #000 0%, #000 14%, rgba(0,0,0,0) 15%);
|
||||||
|
z-index: 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
div.board__point div.board__point__stone div.board__point__dot {
|
div.board__point div.board__point__stone div.board__point__dot {
|
||||||
|
@ -58,13 +64,44 @@ div.board__point div.board__point__stone div.board__point__dot {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.board__point__stone[data-stone="white"] {
|
div.board__point__stone{
|
||||||
|
&[data-stone="white"] {
|
||||||
background: radial-gradient(farthest-side at 55% 40%, white 0%, rgb(200,200,200) 65%, rgb(100,100,100) 90%, rgb(68, 50, 0) 100%);
|
background: radial-gradient(farthest-side at 55% 40%, white 0%, rgb(200,200,200) 65%, rgb(100,100,100) 90%, rgb(68, 50, 0) 100%);
|
||||||
box-shadow: -.25vmin .5vmin .5vmin rgba(145, 92, 23, 0.5);
|
box-shadow: -.25vmin .5vmin .5vmin rgba(145, 92, 23, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
div.board__point__stone[data-stone="black"] {
|
&[data-stone="black"] {
|
||||||
background-color: black;
|
background-color: black;
|
||||||
background: radial-gradient(farthest-side at 55% 40%, rgb(220,220,220) 0%, rgb(60,60,60) 45%, rgb(15,15,15) 90%, rgb(5, 5, 0) 100%);
|
background: radial-gradient(farthest-side at 55% 40%, rgb(220,220,220) 0%, rgb(60,60,60) 45%, rgb(15,15,15) 90%, rgb(5, 5, 0) 100%);
|
||||||
box-shadow: -.25vmin .5vmin .5vmin rgba(145, 92, 23, 0.75);
|
box-shadow: -.25vmin .5vmin .5vmin rgba(145, 92, 23, 0.75);
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-stone="ko"] {
|
||||||
|
background-color: transparent;
|
||||||
|
border: .5vmin solid rgba(200,20,50,0.8);
|
||||||
|
border-radius: 0%;
|
||||||
|
height: 60%;
|
||||||
|
width: 60%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
div.board__point {
|
||||||
|
div.board__point__dot[data-dot="dame"] {
|
||||||
|
background: purple;
|
||||||
|
}
|
||||||
|
div.board__point__dot[data-dot="black"] {
|
||||||
|
background: black;
|
||||||
|
}
|
||||||
|
div.board__point__dot[data-dot="white"] {
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
div.board__point__dot[data-dot="1"] {
|
||||||
|
background: black;
|
||||||
|
}
|
||||||
|
div.board__point__dot[data-dot="-1"] {
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -3,17 +3,17 @@
|
||||||
|
|
||||||
html * {
|
html * {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
font-size: 14px;
|
||||||
|
|
||||||
@media #{map-get($break-points, "500")} {
|
@media #{map-get($break-points, "500")} {
|
||||||
font-size: 14px;
|
// font-size: 14px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
|
font-family: 'Oswald', sans-serif;
|
||||||
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
|
font-weight: 800;
|
||||||
sans-serif;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
@ -32,11 +32,12 @@ body {
|
||||||
|
|
||||||
// ! dev settings
|
// ! dev settings
|
||||||
aside {
|
aside {
|
||||||
background-color: map-get($dev-colors, "e");
|
background-color: map-get($colors, "sidebar");
|
||||||
}
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
background-color: map-get($dev-colors, "d");
|
background-color: map-get($colors, "main");
|
||||||
|
font-weight: 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,3 +45,24 @@ code {
|
||||||
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
|
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
|
||||||
monospace;
|
monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 140%;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
h4 {
|
||||||
|
font-size: 110%;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover, a:active, {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.--link {
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
56
packages/play-node-go/src/io.js
Normal file
56
packages/play-node-go/src/io.js
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
import socketIOClient from "socket.io-client";
|
||||||
|
import config from "./config";
|
||||||
|
|
||||||
|
const launch = (nsp, dispatch) => {
|
||||||
|
const socket = socketIOClient(`${config.socketAddress}/${nsp}`);
|
||||||
|
|
||||||
|
socket.on("connected", () => {
|
||||||
|
dispatch({
|
||||||
|
type: "SOCKET",
|
||||||
|
message: "CONNECTED",
|
||||||
|
body: { nsp: socket.nsp },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
socket.on("connect_error", (err) => {
|
||||||
|
dispatch({
|
||||||
|
type: "ERR",
|
||||||
|
message: "SOCKET_ERROR",
|
||||||
|
body: { socketError: err },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
socket.on("error", (err) => {
|
||||||
|
dispatch({
|
||||||
|
type: "ERR",
|
||||||
|
message: "SOCKET_ERROR",
|
||||||
|
body: { socketError: err },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on("room_connected", (data) => {
|
||||||
|
dispatch({ type: "ROOMS", message: "CONNECT_ROOM", body: data });
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on("new_user", (data) => {
|
||||||
|
dispatch({ type: "ROOMS", message: "NEW_USER", body: data });
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on("game_connected", (data) => {
|
||||||
|
dispatch({ type: "GAMES", message: "UPDATE_BOARD", body: data });
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on("update_board", (data) => {
|
||||||
|
dispatch({ type: "GAMES", message: "UPDATE_BOARD", body: data });
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on("game_resign", (data) => {
|
||||||
|
dispatch({ type: "GAMES", message: "GAME_RESIGN", body: data });
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on("end_game", (data) => {
|
||||||
|
dispatch({ type: "GAMES", message: "GAME_END", body: data });
|
||||||
|
});
|
||||||
|
|
||||||
|
return socket;
|
||||||
|
};
|
||||||
|
|
||||||
|
export { launch };
|
163
packages/play-node-go/src/pages/Game/Game.js
Normal file
163
packages/play-node-go/src/pages/Game/Game.js
Normal file
|
@ -0,0 +1,163 @@
|
||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
import gamesServices from "../../services/api/gamesServices";
|
||||||
|
import "./Game.scss";
|
||||||
|
import Logo from "../../components/Display/Logo/Logo";
|
||||||
|
import Board from "../../components/GameUI/Board/Board";
|
||||||
|
import PlayerArea from "../../components/GameUI/PlayerArea/PlayerArea";
|
||||||
|
import Kifu from "../../components/GameUI/Kifu/Kifu";
|
||||||
|
import Menu from "../../components/GameUI/Menu/Menu";
|
||||||
|
|
||||||
|
const Game = (props) => {
|
||||||
|
const { state, dispatch } = props;
|
||||||
|
const gameId = parseInt(useParams().id) || 0;
|
||||||
|
const [playerBlackMeta, setPlayerBlackMeta] = useState({});
|
||||||
|
const [playerWhiteMeta, setPlayerWhiteMeta] = useState({});
|
||||||
|
const [showMenu, setShowMenu] = useState(false);
|
||||||
|
const playerState = state?.meta?.playerState;
|
||||||
|
const game = state.active?.game;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchGameAPI = async () => {
|
||||||
|
const response = await gamesServices.getGameService(gameId);
|
||||||
|
if (response) {
|
||||||
|
const action = {
|
||||||
|
type: "GAMES",
|
||||||
|
message: "SET_ACTIVE",
|
||||||
|
body: response,
|
||||||
|
};
|
||||||
|
return dispatch(action);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fetchGameAPI();
|
||||||
|
}, [gameId, dispatch]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const roomSocketConnect = () => {
|
||||||
|
const game = state.active.game;
|
||||||
|
const user = state.user;
|
||||||
|
const action = {
|
||||||
|
type: "SOCKET",
|
||||||
|
message: "CONNECT_GAME",
|
||||||
|
body: { game, user, dispatch },
|
||||||
|
};
|
||||||
|
return dispatch(action);
|
||||||
|
};
|
||||||
|
roomSocketConnect();
|
||||||
|
}, [state.active.game, dispatch, state.user]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!game || !playerState) return;
|
||||||
|
const { playerBlack, playerBlackRank, playerWhite, playerWhiteRank } = game;
|
||||||
|
const { bCaptures, wCaptures } = playerState;
|
||||||
|
setPlayerBlackMeta({
|
||||||
|
player: playerBlack,
|
||||||
|
rank: playerBlackRank,
|
||||||
|
captures: bCaptures,
|
||||||
|
stones: "black",
|
||||||
|
});
|
||||||
|
setPlayerWhiteMeta({
|
||||||
|
player: playerWhite,
|
||||||
|
rank: playerWhiteRank,
|
||||||
|
captures: wCaptures,
|
||||||
|
stones: "white",
|
||||||
|
});
|
||||||
|
}, [playerState, game]);
|
||||||
|
|
||||||
|
const handleResignClick = (player) => {
|
||||||
|
const action = {
|
||||||
|
type: "SOCKET",
|
||||||
|
message: "RESIGN",
|
||||||
|
body: { game, player },
|
||||||
|
};
|
||||||
|
dispatch(action);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePassClick = (player) => {
|
||||||
|
if (state?.meta && state?.meta?.winner) return;
|
||||||
|
if (state?.meta && state?.meta?.turn === 0) {
|
||||||
|
const action = {
|
||||||
|
type: "SOCKET",
|
||||||
|
message: "END_GAME",
|
||||||
|
body: { game, player },
|
||||||
|
};
|
||||||
|
return dispatch(action);
|
||||||
|
}
|
||||||
|
const action = {
|
||||||
|
type: "SOCKET",
|
||||||
|
message: "PASS",
|
||||||
|
body: { game, player },
|
||||||
|
};
|
||||||
|
dispatch(action);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="Game" data-testid="Game">
|
||||||
|
<Menu
|
||||||
|
showMenu={showMenu}
|
||||||
|
clickClose={() => setShowMenu(false)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
<div className="Game__meta-container">
|
||||||
|
<span className="Game__socket-flag">{state.socket ? "✓" : " ⃠"}</span>
|
||||||
|
<Logo />
|
||||||
|
{state?.meta?.winner ? (
|
||||||
|
<p>
|
||||||
|
{`winner: ${
|
||||||
|
state.meta.winner === 1
|
||||||
|
? playerBlackMeta?.player
|
||||||
|
: playerWhiteMeta?.player
|
||||||
|
}
|
||||||
|
`}
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
|
<p>Timer</p>
|
||||||
|
<p>? Game Tree</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="Game__board-container">
|
||||||
|
<PlayerArea
|
||||||
|
handleResignClick={handleResignClick}
|
||||||
|
handlePassClick={handlePassClick}
|
||||||
|
playerMeta={
|
||||||
|
state.user &&
|
||||||
|
playerBlackMeta.playerBlack &&
|
||||||
|
state.user === playerBlackMeta.playerBlack
|
||||||
|
? playerBlackMeta
|
||||||
|
: playerWhiteMeta
|
||||||
|
}
|
||||||
|
turn={state?.meta?.turn}
|
||||||
|
/>
|
||||||
|
<Board
|
||||||
|
dispatch={dispatch}
|
||||||
|
game={state.active.game}
|
||||||
|
meta={state.meta}
|
||||||
|
user={state.user}
|
||||||
|
board={state.board}
|
||||||
|
/>
|
||||||
|
<PlayerArea
|
||||||
|
handleResignClick={handleResignClick}
|
||||||
|
handlePassClick={handlePassClick}
|
||||||
|
playerMeta={
|
||||||
|
state.user &&
|
||||||
|
playerBlackMeta.playerWhite &&
|
||||||
|
state.user === playerWhiteMeta.playerWhite
|
||||||
|
? playerWhiteMeta
|
||||||
|
: playerBlackMeta
|
||||||
|
}
|
||||||
|
Kifu={<Kifu clickKifu={() => setShowMenu(true)} />}
|
||||||
|
turn={state?.meta?.turn}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="Game__message-container">
|
||||||
|
<p>Messages</p>
|
||||||
|
<p>Message Form</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Game;
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { useEffect } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import './Home.scss';
|
import './Home.scss';
|
||||||
import roomsServices from '../../services/api/roomsServices';
|
import roomsServices from '../../services/api/roomsServices';
|
||||||
import RoomButton from '../../components/Button/Room/Room';
|
import RoomButton from '../../components/Button/Room/Room';
|
||||||
|
@ -8,6 +8,9 @@ import Loading from '../../components/Display/Loading/Loading';
|
||||||
const Home = props => {
|
const Home = props => {
|
||||||
const state = props.state || {};
|
const state = props.state || {};
|
||||||
const dispatch = props.dispatch;
|
const dispatch = props.dispatch;
|
||||||
|
const [ roomDetail, setRoomDetail ] = useState(1);
|
||||||
|
|
||||||
|
const showRoomDetail = id => roomDetail === id ? setRoomDetail(0) : setRoomDetail(id);
|
||||||
|
|
||||||
const renderRooms = () => {
|
const renderRooms = () => {
|
||||||
const rooms = state.rooms || [];
|
const rooms = state.rooms || [];
|
||||||
|
@ -16,6 +19,8 @@ const Home = props => {
|
||||||
<RoomButton
|
<RoomButton
|
||||||
key={`room-${roomData.id}`}
|
key={`room-${roomData.id}`}
|
||||||
room={roomData}
|
room={roomData}
|
||||||
|
roomDetail={roomDetail === roomData.id}
|
||||||
|
showRoomDetail={showRoomDetail}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -23,6 +28,8 @@ const Home = props => {
|
||||||
return <Loading />
|
return <Loading />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
const fetchRoomsAPI = async () => {
|
const fetchRoomsAPI = async () => {
|
||||||
const response = await roomsServices.indexService();
|
const response = await roomsServices.indexService();
|
||||||
if (response) {
|
if (response) {
|
||||||
|
@ -34,10 +41,8 @@ const Home = props => {
|
||||||
return dispatch(action)
|
return dispatch(action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
fetchRoomsAPI();
|
fetchRoomsAPI();
|
||||||
}, [])
|
}, [ dispatch ])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="Home" data-testid="Home">
|
<div className="Home" data-testid="Home">
|
11
packages/play-node-go/src/pages/Home/Home.scss
Normal file
11
packages/play-node-go/src/pages/Home/Home.scss
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
@import '../../../public/stylesheets/partials/variables';
|
||||||
|
@import '../../../public/stylesheets/partials/mixins';
|
||||||
|
|
||||||
|
div.Home {
|
||||||
|
@include fullspan;
|
||||||
|
background-color: map-get($colors, "home");
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, 22vh);
|
||||||
|
grid-template-rows: repeat(auto-fill, minmax(22vh, 1fr));
|
||||||
|
overflow: scroll;
|
||||||
|
}
|
30
packages/play-node-go/src/pages/Home/HomeSidebar.js
Normal file
30
packages/play-node-go/src/pages/Home/HomeSidebar.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import Auth from '../../components/Form/Auth/Auth';
|
||||||
|
import NewRoomButton from '../../components/Button/NewRoom/NewRoom';
|
||||||
|
import FindRoomForm from '../../components/Form/FindRoom/FindRoom';
|
||||||
|
import LibraryButton from '../../components/Button/Library/Library';
|
||||||
|
|
||||||
|
const HomeSidebar = (props) => {
|
||||||
|
const { state, dispatch } = props;
|
||||||
|
|
||||||
|
const ifUser = <>
|
||||||
|
<FindRoomForm />
|
||||||
|
<NewRoomButton />
|
||||||
|
<LibraryButton />
|
||||||
|
</>
|
||||||
|
|
||||||
|
const ifNoUser = <Auth state={state} dispatch={dispatch} />
|
||||||
|
|
||||||
|
return (
|
||||||
|
<nav>
|
||||||
|
{
|
||||||
|
state.user.username
|
||||||
|
? ifUser
|
||||||
|
: ifNoUser
|
||||||
|
}
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default HomeSidebar;
|
|
@ -0,0 +1,54 @@
|
||||||
|
import React from 'react';
|
||||||
|
import './MainWrapper.scss';
|
||||||
|
|
||||||
|
import NavBar from '../NavBar/NavBar';
|
||||||
|
import Sidebar from '../Sidebar/Sidebar';
|
||||||
|
import Account from '../../Account/Account';
|
||||||
|
import Game from '../../Game/Game';
|
||||||
|
import Home from '../../Home/Home';
|
||||||
|
import News from '../../News/News';
|
||||||
|
import Room from '../../Room/Room';
|
||||||
|
|
||||||
|
const MainWrapper = (props) => {
|
||||||
|
const { state, page, dispatch } = props;
|
||||||
|
|
||||||
|
const setWrapperWithSidebarAndPage = () => {
|
||||||
|
if (page === 'game') return selectPage()
|
||||||
|
return (
|
||||||
|
<div className="main-wrapper" data-testid="main-wrapper">
|
||||||
|
<NavBar state={state}/>
|
||||||
|
<div className="content-wrapper">
|
||||||
|
<Sidebar page={page} state={state} dispatch={dispatch}/>
|
||||||
|
<main>
|
||||||
|
{selectPage()}
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectPage = () =>{
|
||||||
|
switch (page) {
|
||||||
|
case 'account':
|
||||||
|
return <Account state={state} dispatch={dispatch}/>
|
||||||
|
case 'game':
|
||||||
|
return <Game state={state} dispatch={dispatch}/>
|
||||||
|
case 'home':
|
||||||
|
return <Home state={state} dispatch={dispatch}/>
|
||||||
|
case 'news':
|
||||||
|
return <News state={state} dispatch={dispatch}/>
|
||||||
|
case 'room':
|
||||||
|
return <Room state={state} dispatch={dispatch}/>
|
||||||
|
default:
|
||||||
|
return <></>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{ setWrapperWithSidebarAndPage() }
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MainWrapper;
|
|
@ -1,4 +1,5 @@
|
||||||
@import '../../../../public/stylesheets/partials/mixins';
|
@import '../../../../public/stylesheets/partials/mixins';
|
||||||
|
@import '../../../../public/stylesheets/partials/variables';
|
||||||
|
|
||||||
div.main-wrapper {
|
div.main-wrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -34,3 +35,14 @@ div.main-wrapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
color:map-get($colors, 'sidebar_link');
|
||||||
|
cursor: pointer;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 110%;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: .5em;
|
||||||
|
padding: 0;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
36
packages/play-node-go/src/pages/Layout/NavBar/NavBar.js
Normal file
36
packages/play-node-go/src/pages/Layout/NavBar/NavBar.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import React from "react";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import "./NavBar.scss";
|
||||||
|
import Logo from "../../../components/Display/Logo/Logo";
|
||||||
|
|
||||||
|
const NavBar = ({ state }) => {
|
||||||
|
return (
|
||||||
|
<div className="NavBar" data-testid="NavBar">
|
||||||
|
<Link to="/home">
|
||||||
|
<div className="NavBar__logo">
|
||||||
|
<Logo />
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<Link to="/home">
|
||||||
|
<div className="NavBar__menu-item NavBar__home">
|
||||||
|
<p className="--link">Find a Game</p>
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<Link to="/news">
|
||||||
|
<div className="NavBar__menu-item NavBar__news">
|
||||||
|
<p className="--link">News</p>
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<Link to="/account">
|
||||||
|
<div className="NavBar__menu-item NavBar__account">
|
||||||
|
{state.user.username ? state.user.username : <></>}
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default NavBar;
|
22
packages/play-node-go/src/pages/Layout/NavBar/NavBar.scss
Normal file
22
packages/play-node-go/src/pages/Layout/NavBar/NavBar.scss
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
@import '../../../../public/stylesheets/partials/_variables.scss';
|
||||||
|
|
||||||
|
div.NavBar {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: row nowrap;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
background-color: map-get($colors, "nav_bar");
|
||||||
|
color: map-get($colors, "nav_link");
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-size: 1.4em;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a{
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { useState } from 'react';
|
import React from 'react';
|
||||||
import './Sidebar.scss';
|
import './Sidebar.scss';
|
||||||
|
|
||||||
import AccountSidebar from '../../Account/AccountSidebar';
|
import AccountSidebar from '../../Account/AccountSidebar';
|
||||||
|
@ -7,17 +7,17 @@ import NewsSidebar from '../../News/NewsSidebar';
|
||||||
import RoomSidebar from '../../Room/RoomSidebar';
|
import RoomSidebar from '../../Room/RoomSidebar';
|
||||||
|
|
||||||
const Sidebar = (props) => {
|
const Sidebar = (props) => {
|
||||||
|
const {page, state, dispatch} = props
|
||||||
const displayComponent = props =>{
|
const displayComponent = () =>{
|
||||||
switch (props.page) {
|
switch (page) {
|
||||||
case 'account':
|
case 'account':
|
||||||
return <AccountSidebar state={props.state} dispatch={props.dispatch}/>
|
return <AccountSidebar state={state} dispatch={dispatch}/>
|
||||||
case 'home':
|
case 'home':
|
||||||
return <HomeSidebar state={props.state} dispatch={props.dispatch}/>
|
return <HomeSidebar state={state} dispatch={dispatch}/>
|
||||||
case 'news':
|
case 'news':
|
||||||
return <NewsSidebar state={props.state} dispatch={props.dispatch}/>
|
return <NewsSidebar state={state} dispatch={dispatch}/>
|
||||||
case 'room':
|
case 'room':
|
||||||
return <RoomSidebar state={props.state} dispatch={props.dispatch}/>
|
return <RoomSidebar state={state} dispatch={dispatch}/>
|
||||||
default:
|
default:
|
||||||
return <></>
|
return <></>
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ const Sidebar = (props) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<aside className="Sidebar" data-testid="Sidebar">
|
<aside className="Sidebar" data-testid="Sidebar">
|
||||||
{displayComponent(props)}
|
{displayComponent()}
|
||||||
</aside>
|
</aside>
|
||||||
);
|
);
|
||||||
}
|
}
|
41
packages/play-node-go/src/pages/Layout/Sidebar/Sidebar.scss
Normal file
41
packages/play-node-go/src/pages/Layout/Sidebar/Sidebar.scss
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
@import '../../../../public/stylesheets/partials/variables';
|
||||||
|
|
||||||
|
aside {
|
||||||
|
color: map-get($colors, "sidebar_link");
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column nowrap;
|
||||||
|
|
||||||
|
nav {
|
||||||
|
align-items: stretch;
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 130%;
|
||||||
|
margin: .2em auto;
|
||||||
|
text-transform: capitalize;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
display: block;
|
||||||
|
margin: .2em 0 .2em auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.nav__section {
|
||||||
|
border: rgba(100,100,100,0.5) solid .25em;
|
||||||
|
margin: .5em;
|
||||||
|
padding: .75em .5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.nav__section__label {
|
||||||
|
font-size: 110%;
|
||||||
|
margin-bottom: .5em;
|
||||||
|
text-decoration: none;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue