From 8e6c162d5e7a519a5f2da19283cb105b13b12a18 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 28 Jan 2018 05:58:35 -0500 Subject: [PATCH] Auto stash before merge of "master" and "origin/master" --- googletrendsgame/src/App.js | 35 ++++++++---- googletrendsgame/src/components/GameScreen.js | 28 ++++++++++ googletrendsgame/src/components/RoomList.js | 21 +++++-- .../src/components/RoomListItem.js | 56 ++++++++++++++----- googletrendsgame/src/components/User.js | 23 ++++---- googletrendsgame/src/components/UserList.js | 26 +++++++-- .../src/components/createRoomInput.js | 4 +- .../src/components/nicknameInput.js | 1 + googletrendsgame/src/components/wordInput.js | 4 +- 9 files changed, 148 insertions(+), 50 deletions(-) diff --git a/googletrendsgame/src/App.js b/googletrendsgame/src/App.js index 2716b06..a29e512 100644 --- a/googletrendsgame/src/App.js +++ b/googletrendsgame/src/App.js @@ -5,6 +5,7 @@ import openSocket from 'socket.io-client'; import NicknameInput from './components/nicknameInput'; import CreateRoomInput from './components/createRoomInput'; import RoomList from './components/RoomList'; +import GameScreen from './components/GameScreen'; const socket = openSocket('129.21.91.149:3000'); @@ -12,20 +13,29 @@ class App extends Component { constructor(props){ super(props); - this.state={ + this.state = { progression: 'register', - roomsList: [] + roomsList: [], + roomUpdateData: {} } socket.on('sendRooms', payload => { - var rooms = payload.rooms; + console.log(payload); this.setState({ - progression: 'roomChoose', - roomsList: rooms + roomsList: payload.rooms, + progression: 'roomChoose' }) }); + + socket.on('roomUpdate', payload => { + this.setState({ + progression: 'gameScreen', + roomUpdateData: payload + }) + }) this.modifyStateToCreateRoom = this.modifyStateToCreateRoom.bind(this); this.modifyStateToRoomsScreen = this.modifyStateToRoomsScreen.bind(this); + this.modifyStateToGameScreen = this.modifyStateToGameScreen.bind(this); } modifyStateToCreateRoom() { @@ -36,17 +46,16 @@ class App extends Component { modifyStateToGameScreen() { this.setState({ - progression: '' - }) + progression: 'gameScreen' + }); } modifyStateToRoomsScreen(){ this.setState({ progression: 'roomChoose' - }) + }); } - render() { if (this.state.progression === 'register') { return( @@ -54,12 +63,16 @@ class App extends Component { ) } else if(this.state.progression === 'roomChoose') { return( - + ) } else if (this.state.progression === 'createRoom') { return( - + + ) + } else if (this.state.progression === 'gameScreen') { + return( + ) } } diff --git a/googletrendsgame/src/components/GameScreen.js b/googletrendsgame/src/components/GameScreen.js index ef867d9..e4bf34d 100644 --- a/googletrendsgame/src/components/GameScreen.js +++ b/googletrendsgame/src/components/GameScreen.js @@ -1 +1,29 @@ import React, {Component} from 'react'; +import UserList from './UserList'; + +export default class GameScreen extends Component{ + constructor(props){ + super(props); + + console.log(this.props.gameData); + + this.state={ + userScore:0, + round:1, + inputValue: '', + currentWord: '' + } + } + + setInputState(word) { + this.setState({ + input: word + }); + } + + render(){ + return( + + ) + }; + } diff --git a/googletrendsgame/src/components/RoomList.js b/googletrendsgame/src/components/RoomList.js index aa95502..4fe3e8b 100644 --- a/googletrendsgame/src/components/RoomList.js +++ b/googletrendsgame/src/components/RoomList.js @@ -3,17 +3,26 @@ import RoomListItem from './RoomListItem'; import {modifyStateToCreateRoom} from '../App' export default (props) => { - let rooms = props.roomArray; + let rooms = props.roomsArray; + console.log(props); if (rooms.length != 0) { - let roomsList = rooms.map((room) => - - ); + const roomNameArray = rooms.map(room => room.name); + const publicPrivateArray = rooms.map(room => room.passwordBool); + const capacityArray = rooms.map(room => room.capacity); + const occupancyArray = rooms.map(room => room.occupants) + + var roomsArray = []; + + for(var i = 0; i < roomNameArray.length; i++){ + roomsArray.push(); + } + return(
-
{roomsList}
+
{roomsArray}
- ); + ) } else { return (
diff --git a/googletrendsgame/src/components/RoomListItem.js b/googletrendsgame/src/components/RoomListItem.js index af2d943..d47a65f 100644 --- a/googletrendsgame/src/components/RoomListItem.js +++ b/googletrendsgame/src/components/RoomListItem.js @@ -1,17 +1,47 @@ -import React from 'react'; +import React, {Component} from 'react'; -export default (props) => { - var privateString ='' - if (props.private === false){ - privateString = "Public" +export default class RoomListItem extends Component { + constructor(props){ + super(props); + + this.state={ + term:'' + } + + this.onInputChange = this.onInputChange.bind(this); + this.buttonClickHandler = this.buttonClickHandler.bind(this); + } + + + onInputChange(event) { + this.setState( { term: event.target.value }); + } + + buttonClickHandler(event){ + this.props.socket.emit('joinRoom', {roomName: this.props.roomName, password: this.state.term}) + } + + +render(){ + if (this.props.private === 'false'){ + return( +
+

{this.props.roomName}'s Room

+

{this.props.occupancy}/{this.props.capacity}

+
Public
+ +
+ ); } else { - privateString = "Private" + return( +
+

{this.props.roomName}'s Room

+

{this.props.occupancy}/{this.props.capacity}

+
Private
+ + +
+ ) } - return( -
-

{props.roomName}'s Room

-

{props.occupancy}/{props.capacity}

-
{privateString}
-
- ) +} } diff --git a/googletrendsgame/src/components/User.js b/googletrendsgame/src/components/User.js index 4d97ebf..a5a4fdc 100644 --- a/googletrendsgame/src/components/User.js +++ b/googletrendsgame/src/components/User.js @@ -2,31 +2,32 @@ import React from 'react'; import FontAwesome from 'react-fontawesome'; export default (props) => { - const name = this.props.name; - const score = this.props.score; + console.log('entered user obj') + const name = props.name; + const score = props.score; var word; - if (this.props.word === ''){ + if (props.word === ''){ word = 'true' } else { word = 'false' } - - if (word === 'true') { + console.log('Word is true'); return( -
  • -
    {name}
    -
    {score}
    +
    +
    Name: {name}
    +
    Score: {score}
    -
  • +
    ) } else { + console.log('Word is false') return ( -
  • +
    Name: {name}
    Score: {score}
    -
  • + ) } } diff --git a/googletrendsgame/src/components/UserList.js b/googletrendsgame/src/components/UserList.js index f4f173d..80838d5 100644 --- a/googletrendsgame/src/components/UserList.js +++ b/googletrendsgame/src/components/UserList.js @@ -2,14 +2,28 @@ import React from 'react'; import User from './User' export default (props) => { - var users = props.users; + console.log(props.gameDataPassed); + + const nameArray = props.gameDataPassed.users.map(name => name.name); + const scoreArray = props.gameDataPassed.users.map(score => score.score); + const wordArray = props.gameDataPassed.users.map(word => word.word); + + console.log(nameArray); + console.log(scoreArray); + console.log(wordArray); + + var users = []; + + for(var i = 0; i < nameArray.length; i++){ + users.push(); + } - var userList = users.map((user) => - - ); return( +
    -
      {userList}
    + {users} +

    Leader: {props.gameDataPassed.roundWinner}

    +

    Current Word: {props.gameDataPassed.currentWord}

    - ); + ) } diff --git a/googletrendsgame/src/components/createRoomInput.js b/googletrendsgame/src/components/createRoomInput.js index cf51ed2..0e1c296 100644 --- a/googletrendsgame/src/components/createRoomInput.js +++ b/googletrendsgame/src/components/createRoomInput.js @@ -28,6 +28,8 @@ export default class CreateRoomInput extends Component { this.props.socket.emit('createRoom', {password: this.state.passwordFieldValue, capacity: this.state.capacityFieldValue}); this.setState({ passwordFieldValue: '', capacityFieldValue: '' }); + this.props.socket.emit('joinRoom', {}) + //this.props.goToRoom() } render(){ @@ -36,7 +38,7 @@ export default class CreateRoomInput extends Component { - + ) diff --git a/googletrendsgame/src/components/nicknameInput.js b/googletrendsgame/src/components/nicknameInput.js index ae3365f..83a66c5 100644 --- a/googletrendsgame/src/components/nicknameInput.js +++ b/googletrendsgame/src/components/nicknameInput.js @@ -19,6 +19,7 @@ export default class NicknameInput extends Component { event.preventDefault(); this.props.socket.emit('register', this.state.fieldValue); + console.log("Sent Registration.") this.setState({fieldValue: ''}) } diff --git a/googletrendsgame/src/components/wordInput.js b/googletrendsgame/src/components/wordInput.js index e57f8e4..4a72751 100644 --- a/googletrendsgame/src/components/wordInput.js +++ b/googletrendsgame/src/components/wordInput.js @@ -6,7 +6,7 @@ class wordInput extends Component { this.state={fieldValue:''} - //this.onInputChange = this.onInputChange.bind(this); - //this.onInputChange + this.onInputChange = this.onInputChange.bind(this); + this.onInputChange } }