-
Notifications
You must be signed in to change notification settings - Fork 742
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed165a8
commit 58cbd1e
Showing
13 changed files
with
373 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright 2018 The boardgame.io Authors | ||
* | ||
* Use of this source code is governed by a MIT-style | ||
* license that can be found in the LICENSE file or at | ||
* https://opensource.org/licenses/MIT. | ||
*/ | ||
|
||
.secret-state section { | ||
text-align: left; | ||
padding: 10px; | ||
margin-bottom: 20px; | ||
background: #eee; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2017 The boardgame.io Authors. | ||
* | ||
* Use of this source code is governed by a MIT-style | ||
* license that can be found in the LICENSE file or at | ||
* https://opensource.org/licenses/MIT. | ||
*/ | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import './board.css'; | ||
|
||
const Board = ({ G, ctx, moves, playerID, log }) => ( | ||
<div className="secret-state"> | ||
<section> | ||
<strong>G</strong> | ||
<pre>{JSON.stringify(G, null, 2)}</pre> | ||
|
||
<strong>log</strong> | ||
<pre>{JSON.stringify(log, null, 2)}</pre> | ||
{playerID && ( | ||
<button | ||
onClick={() => | ||
moves.clickCell({ secret: G.players[ctx.currentPlayer] }) | ||
} | ||
> | ||
Click Cell | ||
</button> | ||
)} | ||
</section> | ||
</div> | ||
); | ||
|
||
Board.propTypes = { | ||
G: PropTypes.any.isRequired, | ||
ctx: PropTypes.any.isRequired, | ||
moves: PropTypes.any.isRequired, | ||
playerID: PropTypes.any, | ||
log: PropTypes.any, | ||
}; | ||
|
||
export default Board; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2018 The boardgame.io Authors | ||
* | ||
* Use of this source code is governed by a MIT-style | ||
* license that can be found in the LICENSE file or at | ||
* https://opensource.org/licenses/MIT. | ||
*/ | ||
|
||
import { Game, PlayerView, TurnOrder } from 'boardgame.io/core'; | ||
|
||
const RedactedMoves = Game({ | ||
name: 'secret-state', | ||
|
||
setup: () => ({ | ||
other: {}, | ||
players: { | ||
0: 'player 0 state', | ||
1: 'player 1 state', | ||
}, | ||
}), | ||
|
||
moves: { | ||
/* eslint-disable no-unused-vars */ | ||
clickCell(G, ctx, secretstuff) { | ||
return { ...G }; | ||
}, | ||
/* eslint-enable no-unused-vars */ | ||
}, | ||
|
||
flow: { | ||
redactedMoves: ['clickCell'], | ||
turnOrder: TurnOrder.ANY, | ||
}, | ||
|
||
playerView: PlayerView.STRIP_SECRETS, | ||
}); | ||
|
||
export default RedactedMoves; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright 2018 The boardgame.io Authors. | ||
* | ||
* Use of this source code is governed by a MIT-style | ||
* license that can be found in the LICENSE file or at | ||
* https://opensource.org/licenses/MIT. | ||
*/ | ||
|
||
import Multiview from './multiview'; | ||
|
||
const routes = [ | ||
{ | ||
path: '/redacted_move', | ||
text: 'Example', | ||
component: Multiview, | ||
}, | ||
]; | ||
|
||
export default { routes }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2018 The boardgame.io Authors. | ||
* | ||
* Use of this source code is governed by a MIT-style | ||
* license that can be found in the LICENSE file or at | ||
* https://opensource.org/licenses/MIT. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { Client } from 'boardgame.io/react'; | ||
import Game from './game'; | ||
import Board from './board'; | ||
|
||
const App = Client({ | ||
game: Game, | ||
numPlayers: 2, | ||
board: Board, | ||
debug: false, | ||
multiplayer: { local: true }, | ||
}); | ||
|
||
const Multiview = () => ( | ||
<div style={{ padding: 50 }}> | ||
<h1>Redacted Moves</h1> | ||
<p> | ||
This examples demonstrates the use of redacted moves. Using redacted moves | ||
allows for secret information to be stripped from the log for other | ||
players. | ||
</p> | ||
<p> | ||
Clicking the button on one of the players, you should see complete log | ||
event for that player but a redacted one for everyone else. | ||
</p> | ||
<div className="runner"> | ||
<div className="run"> | ||
<App gameID="redacted-move" playerID="0" /> | ||
<App playerID="0"/> | ||
</div> | ||
<div className="run"> | ||
<App gameID="redacted-move" playerID="1" /> | ||
<App playerID="1"/> | ||
</div> | ||
<div className="run"> | ||
<App gameID="redacted-move" /> | ||
<App/> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
|
||
export default Multiview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.