Skip to content

feat: Improve consistency around “match” instead of “game”#765

Merged
nicolodavis merged 6 commits into
0.40.0from
delucis/refactor/match-consistency
Aug 14, 2020
Merged

feat: Improve consistency around “match” instead of “game”#765
nicolodavis merged 6 commits into
0.40.0from
delucis/refactor/match-consistency

Conversation

@delucis
Copy link
Copy Markdown
Member

@delucis delucis commented Jul 19, 2020

This PR addresses #763, updating client and transport implementations to use matchID, matchData, updateMatchID, subscribeMatchData, etc. instead of using “game”.

So far I didn’t include the refactoring of the Storage API as that might require some further consideration, so I’ll await feedback before doing anything about that.

Breaking changes

Clients should now be passed a matchID instead of gameID

import { Client } from 'boardgame.io/react';

const App = Client({ game });

export default () => <App matchID="xyz" />;
import { Client } from 'boardgame.io/client';

const client = Client({
  matchID: 'xyz',
  // ...
});

client.updateMatchID('abc');

React board components will receive matchData instead of gameMetadata

const Board = ({ matchData }) => {
  return <div>{matchData}</div>
};

@delucis delucis changed the base branch from master to 0.40.0 July 19, 2020 13:12
@nicolodavis
Copy link
Copy Markdown
Member

@delucis: Do you think it's worth shortening matchMetadata to matchData?

I feel like it's unambiguous enough (unlike gameData).

@delucis
Copy link
Copy Markdown
Member Author

delucis commented Jul 20, 2020

Do you think it's worth shortening matchMetadata to matchData?

Sure, I don’t see why not.

@delucis
Copy link
Copy Markdown
Member Author

delucis commented Jul 20, 2020

Done in 3cde0a7 & 15bd0ab.

@delucis delucis requested a review from nicolodavis August 11, 2020 15:30
@nicolodavis nicolodavis merged commit 6fcf695 into 0.40.0 Aug 14, 2020
@nicolodavis nicolodavis deleted the delucis/refactor/match-consistency branch August 14, 2020 11:30
@delucis delucis mentioned this pull request Aug 16, 2020
nicolodavis added a commit that referenced this pull request Sep 1, 2020
* feat(server): Expose API router (#698)

BREAKING CHANGES: Previously a custom `uuid` function used by the Lobby API to generate game IDs could be passed in the `lobbyConfig` option on `server.run`. This must now be passed directly to the server:

```js
const server = Server({
  uuid: () => 'id',
});
```

### All commits

* Expose API router
* refactor(server): Pass uuid directly to Server and createRouter
* docs(server): Move uuid from lobbyConfig on run to Server options

Co-authored-by: delucis <[email protected]>

* fix(api): Expose gameover metadata in rooms endpoints. (#666)

* fix(api): Expose gameover metadata in rooms endpoints.

This adds the `gameover` metadata, if it exists, to both the all rooms and single room query endpoints.

Fixes #665.

* Refactor game metadata redacting into a function.

Co-authored-by: Chris Swithinbank <[email protected]>

* refactor(server): Use the term "match" in the API and Lobby (#704)

Closes #703

* GameMetadata -> MatchMetadata

* rooms -> matches

* API exposes `matchID`, make Lobby use that instead of `gameID` or `roomID`.

* CreateGame -> CreateMatch

* gameID, roomID -> matchID

* Document Lobby API endpoints.

* nextRoomID -> nextMatchID

* Update error messages.

* gameList -> matchList

* Use "match" wherever it makes sense in lobby code.

* Replace "room" with "match" in documentation.

* Rename 'game' to 'match' in comments and test names.

Co-authored-by: Chris Swithinbank <[email protected]>

* doesGameRequireAuthentication -> doesMatchRequireAuthentication

* Rename gameID to matchID in database interface functions.

Co-authored-by: Chris Swithinbank <[email protected]>

* Merge branch 'master' into 0.40.0

* feat(server): allow to filter listGames query (#740)

* add createdAt, updatedAt to metadata, add listGames filters

* case-insensitive boolean parsing

* implement inmemory listGames filter

* feat: Add plain JS lobby client (#728)

* feat(server): Create types for Lobby API data

Closes #707

This creates types for data returned by the Lobby API and uses them to 
type the response bodies in the server-side router.

* refactor(types): Include min and max players options in Game interface

* refactor(lobby): Convert connection class to Typescript

* feat(lobby): Create a plain JS LobbyClient

LobbyClient is a lightweight wrapper around `fetch` calls to a 
boardgame.io Lobby API server. Apart from the server’s base URL, it is 
stateless and serves mainly to allow argument validation and to abstract 
away a few request details. Unlike plain fetch, requests will throw 
errors if they don’t return `ok` (i.e. status 2xx).

* refactor(lobby): Use new LobbyClient class in React lobby connection

* fix(lobby): Include missing import for React types

* docs(api): Update Lobby docs to convert game to match more thoroughly

* docs: Correct inline documentation block

* docs: Update Lobby docs

- Add examples with the plain JS client
- Move the server config details to the Server doc

* feat(lobby): Add support for listMatches filtering to client

#740 added the ability to pass query string parameters to the 
listMatches API endpoint to filter the matches returned. This adds 
support for building the relevant query string to the lobby client’s 
listMatches method.

* test(lobby): Fix type error in Lobby connection test

Add `createdAt` and `updatedAt` fields to mock match data

* test(db): Fix coverage for InMemory storage class

* test(master): Fix muddled updatedAt/gameover tests

Two tests for gameover & updatedAt in match metadata were 
mislabelled/mixed up a bit. This tidies up the confusion and in the 
process improves test coverage.

* test(api): Add coverage for invalid query params when listing matches

* feat: Improve consistency around “match” instead of “game” (#765)

* refactor: Rename `gameID` to `matchID` in clients & transports

* docs: Update to replace `gameID` with `matchID`

* docs: Update example code to use `matchID` instead of `gameID`

* refactor: `gameMetadata` → `matchMetadata` in clients & transports

* refactor: `matchMetadata` → `matchData`

* refactor(types): `MatchMetadata` → `MatchData`

* fix test

Co-authored-by: Clemens Wolff <[email protected]>
Co-authored-by: Adrian Gaudebert <[email protected]>
Co-authored-by: janKir <[email protected]>
Co-authored-by: Nicolo John Davis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants