From 16ba045bed245b549da30488580cd4114fd3b851 Mon Sep 17 00:00:00 2001 From: Yoofi Quansah Date: Tue, 2 Aug 2022 18:21:55 -0700 Subject: [PATCH 1/2] feat(client): add documentation for the urturn/client on the docs website --- docs/client-docs.md | 24 ++++++++++++++++++++++++ docusaurus.config.js | 9 +++++++++ 2 files changed, 33 insertions(+) create mode 100644 docs/client-docs.md diff --git a/docs/client-docs.md b/docs/client-docs.md new file mode 100644 index 0000000..03cc7b6 --- /dev/null +++ b/docs/client-docs.md @@ -0,0 +1,24 @@ +--- +title: urturn/client +--- + +## High level Description + +The `@urturn/client` provides a basic abstraction of communicating your frontend to the backend with a simple interface. + +## Exported Methods + +There are 3 main exported methods avaiable for frontend use: + +- `getBoardGame` +- `makeMove` +- `getLocalPlayer` + +## Example of use +Before getting into an example, it is critical to note the importance of the `makeMove` method. You can think of the method as a bridge between two states of your game, from a frontend perspective. This makes it easier to imagine the game in terms of discrete states when it comes to development work. + +`old state -> makeMove -> new state` + +In the `checkers` repo, there exists [use](https://github.com/turnbasedgames/checkers/blob/73f0f3127687935d636c13dfb84f137e365087b1/frontend/src/App.jsx#L336) of the `makeMove` method. + +The `getBoardGame` method is used to get the initial state of the game upon start up. It is up to you to perform updates to the game (via `makeMove`). diff --git a/docusaurus.config.js b/docusaurus.config.js index 4ed19b5..d001e1b 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -87,6 +87,15 @@ const config = { }, ], }, + { + title: 'Client', + items: [ + { + label: '@urturn/client', + to: '/docs/client-docs', + }, + ], + }, { title: 'More', items: [ From c994379be0ef6432e4fe8243b512a9410a7003c1 Mon Sep 17 00:00:00 2001 From: Yoofi Quansah Date: Wed, 3 Aug 2022 10:12:35 -0700 Subject: [PATCH 2/2] chore: address feedback on client docs --- docs/client-docs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/client-docs.md b/docs/client-docs.md index 03cc7b6..f5b727e 100644 --- a/docs/client-docs.md +++ b/docs/client-docs.md @@ -19,6 +19,6 @@ Before getting into an example, it is critical to note the importance of the `ma `old state -> makeMove -> new state` -In the `checkers` repo, there exists [use](https://github.com/turnbasedgames/checkers/blob/73f0f3127687935d636c13dfb84f137e365087b1/frontend/src/App.jsx#L336) of the `makeMove` method. +In the `checkers` repo, there exists [use](https://github.com/turnbasedgames/tictactoe/blob/e36ab75d5e9c9a4165b17070971b79dae93585b2/frontend/src/App.jsx#L87) of the `makeMove` method. The `getBoardGame` method is used to get the initial state of the game upon start up. It is up to you to perform updates to the game (via `makeMove`).