From 6be034ecc5bd67db13d4960671f934ce94869478 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Sat, 22 May 2021 22:33:32 +0200 Subject: [PATCH 1/4] chore: Add FUNDING.yml --- .github/FUNDING.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..a4cc8a0d4 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +# These are supported funding model platforms + +github: [boardgameio] +open_collective: boardgameio From 49c2c12fd02fd3cb4fd5872c7593beb4b3954511 Mon Sep 17 00:00:00 2001 From: Philip Shao Date: Sun, 23 May 2021 01:13:03 -0400 Subject: [PATCH 2/4] =?UTF-8?q?fix(reducer):=20Don=E2=80=99t=20crash=20whe?= =?UTF-8?q?n=20undoing=20stage=20events=20(#942)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * bugfix: Stand-alone events should be undoable. Co-authored-by: delucis --- src/core/reducer.test.ts | 25 ++++++++++++++++++++++++- src/core/reducer.ts | 18 ++++++++++-------- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/core/reducer.test.ts b/src/core/reducer.test.ts index a4f48e21a..02d946195 100644 --- a/src/core/reducer.test.ts +++ b/src/core/reducer.test.ts @@ -327,8 +327,17 @@ describe('undo / redo', () => { G.roll = ctx.random.D6(); }, }, + turn: { + stages: { + special: {}, + }, + }, }; + beforeEach(() => { + jest.clearAllMocks(); + }); + const reducer = CreateGameReducer({ game }); const initialState = InitializeGame({ game }); @@ -341,7 +350,7 @@ describe('undo / redo', () => { expect(state._undo[1].ctx.random).toBeUndefined(); }); - test('undo restores previous state', () => { + test('undo restores previous state after move', () => { let state = reducer(initialState, makeMove('move', 'A', '0')); const { G, ctx, plugins } = state; state = reducer(state, makeMove('roll', null, '0')); @@ -351,6 +360,20 @@ describe('undo / redo', () => { expect(state.plugins).toEqual(plugins); }); + test('undo restores previous state after event', () => { + let state = reducer(initialState, gameEvent('setStage', 'special', '0')); + const { G, ctx, plugins } = state; + state = reducer(state, gameEvent('endStage', undefined, '0')); + expect(error).not.toBeCalled(); + // Make sure we actually modified the stage. + expect(state.ctx.activePlayers).not.toEqual(ctx.activePlayers); + state = reducer(state, undo()); + expect(error).not.toBeCalled(); + expect(state.G).toEqual(G); + expect(state.ctx).toEqual(ctx); + expect(state.plugins).toEqual(plugins); + }); + test('redo restores undone state', () => { let state = initialState; // Make two moves. diff --git a/src/core/reducer.ts b/src/core/reducer.ts index 35c5f02b3..b10ae54f1 100644 --- a/src/core/reducer.ts +++ b/src/core/reducer.ts @@ -314,14 +314,16 @@ export function CreateGameReducer({ return state; } - // Only allow undoable moves to be undone. - const lastMove: Move = game.flow.getMove( - restore.ctx, - last.moveType, - last.playerID - ); - if (!CanUndoMove(state.G, state.ctx, lastMove)) { - return state; + // If undoing a move, check it is undoable. + if (last.moveType) { + const lastMove: Move = game.flow.getMove( + restore.ctx, + last.moveType, + last.playerID + ); + if (!CanUndoMove(state.G, state.ctx, lastMove)) { + return state; + } } state = initializeDeltalog(state, action); From bfe5aa2944648f5d217c59d0ce5ce1bb0185bf40 Mon Sep 17 00:00:00 2001 From: delucis Date: Sun, 23 May 2021 07:28:22 +0200 Subject: [PATCH 3/4] docs: Use new default branch name --- .github/pull_request_template.md | 4 ++-- .github/workflows/test.yml | 4 ++-- CONTRIBUTING.md | 4 ++-- docs/documentation/index.html | 4 ++-- docs/documentation/storage.md | 2 +- docs/index.html | 4 ++-- roadmap.md | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 78767b4e6..57ba03e5f 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,4 +1,4 @@ #### Checklist -* [ ] Use a separate branch in your local repo (not `master`). -* [ ] Test coverage is 100% (or you have a story for why it's ok). +- [ ] Use a separate branch in your local repo (not `main`). +- [ ] Test coverage is 100% (or you have a story for why it's ok). diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7ec000677..750e739b5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,9 +2,9 @@ name: Tests on: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] jobs: unit: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 19a867b37..4cb2d7ab8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,7 @@ The Issue Tracker may contain items labelled [**good first issue**][gfi] or [**h [Pull Requests](https://help.github.com/articles/about-pull-requests/) are used for contributions. Code must be well-tested and not decrease the test coverage significantly. -#### Use a separate branch (not `master`) +#### Use a separate branch (not `main`) Please commit changes to a separate branch in your fork so that we can work together making changes to it before it @@ -24,7 +24,7 @@ is ready to be merged. Name your branch something like `/feature`. Once you are ready, you can create a Pull Request for it to be -merged into the `master` branch in this repo. +merged into the `main` branch in this repo. #### Testing diff --git a/docs/documentation/index.html b/docs/documentation/index.html index a09196af8..c5108912b 100644 --- a/docs/documentation/index.html +++ b/docs/documentation/index.html @@ -10,7 +10,7 @@ - + @@ -94,7 +94,7 @@