summaryrefslogtreecommitdiff
path: root/frontend/src/components/game
diff options
context:
space:
mode:
authorjbion <joffrey.bion@amadeus.com>2019-02-22 23:09:40 +0100
committerjbion <joffrey.bion@amadeus.com>2019-02-22 23:09:40 +0100
commit27990fcba5a47252df617db1bc98e2276b326e7e (patch)
tree7fba886ae83379ee9d76e6540efae7b0e7ce2a25 /frontend/src/components/game
parentFix websocket value when no message body is received (diff)
downloadseven-wonders-27990fcba5a47252df617db1bc98e2276b326e7e.tar.gz
seven-wonders-27990fcba5a47252df617db1bc98e2276b326e7e.tar.bz2
seven-wonders-27990fcba5a47252df617db1bc98e2276b326e7e.zip
Implement Game start
Diffstat (limited to 'frontend/src/components/game')
-rw-r--r--frontend/src/components/game/GameScene.jsx64
1 files changed, 64 insertions, 0 deletions
diff --git a/frontend/src/components/game/GameScene.jsx b/frontend/src/components/game/GameScene.jsx
new file mode 100644
index 00000000..fb5763db
--- /dev/null
+++ b/frontend/src/components/game/GameScene.jsx
@@ -0,0 +1,64 @@
+import { Button, Classes, Intent } from '@blueprintjs/core';
+import { List } from 'immutable';
+import React, { Component } from 'react';
+import { connect } from 'react-redux';
+import type { ApiPlayerTurnInfo } from '../../api/model';
+import { Game } from '../../models/games';
+import { Player } from '../../models/players';
+import { actions } from '../../redux/actions/game';
+import { getCurrentTurnInfo } from '../../redux/currentGame';
+import { getCurrentGame } from '../../redux/games';
+
+import { getCurrentPlayer, getPlayers } from '../../redux/players';
+import { PlayerList } from '../lobby/PlayerList';
+
+type GameSceneProps = {
+ game: Game,
+ currentPlayer: Player,
+ players: List<Player>,
+ turnInfo: ApiPlayerTurnInfo,
+ sayReady: () => void
+}
+
+class GameScenePresenter extends Component<GameSceneProps> {
+ getTitle() {
+ if (this.props.game) {
+ return this.props.game.name + ' — Game';
+ } else {
+ return 'What are you doing here? You haven\'t joined a game yet!';
+ }
+ }
+
+ render() {
+ return (
+ <div>
+ <h2>{this.getTitle()}</h2>
+ <PlayerList players={this.props.players} currentPlayer={this.props.currentPlayer} owner={this.props.game.owner}/>
+ <Button text="READY" className={Classes.LARGE} intent={Intent.PRIMARY} icon='play' onClick={this.props.sayReady} />
+
+ <h3>Turn Info</h3>
+ <div>
+ <pre>{JSON.stringify(this.props.turnInfo, null, 2) }</pre>
+ </div>
+ </div>
+ );
+ }
+}
+
+const mapStateToProps: (state) => GameSceneProps = state => {
+ const game = getCurrentGame(state.get('games'));
+ console.info(game);
+
+ return {
+ game: game,
+ currentPlayer: getCurrentPlayer(state),
+ players: game ? getPlayers(state.get('players'), game.players) : new List(),
+ turnInfo: getCurrentTurnInfo(state.get('currentGame'))
+ };
+};
+
+const mapDispatchToProps = {
+ sayReady: actions.sayReady,
+};
+
+export const GameScene = connect(mapStateToProps, mapDispatchToProps)(GameScenePresenter);
bgstack15