Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/wins losses #119

Open
wants to merge 107 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
e439349
add small facebook auth
Dillonjay Jul 19, 2016
76ac990
Merge pull request #1 from striking-lunatics/feature/fbAuth
mccarthyist Jul 19, 2016
8dc087c
Add login/signup templates
sxcw Jul 19, 2016
3596646
Merge pull request #2 from striking-lunatics/feature/login
Jul 19, 2016
30e9be5
store cookie with facebookb image url and facebook username
Dillonjay Jul 20, 2016
26cfcb3
Merge pull request #3 from striking-lunatics/feature/fbAuth
burtoncooke1 Jul 20, 2016
22eb40d
page works, not submitting
mccarthyist Jul 20, 2016
03ce1d0
almost working
mccarthyist Jul 20, 2016
76c83fe
Merge remote-tracking branch 'refs/remotes/GranitePapyrusShears/master'
ChrisWiles Jul 20, 2016
ef1883d
basic functionality
mccarthyist Jul 20, 2016
cc0557a
Merge pull request #4 from striking-lunatics/feature/gameChat
Jul 20, 2016
b2bf14b
fixed server socket
mccarthyist Jul 20, 2016
94cc001
add facebook image to player icon
Dillonjay Jul 20, 2016
31d505e
Merge pull request #5 from striking-lunatics/feature/addImage
mccarthyist Jul 20, 2016
91c4448
Merge branch 'master' of https://github.com/striking-lunatics/RockPap…
mccarthyist Jul 20, 2016
2ae9cce
Merge branch 'master' of https://github.com/striking-lunatics/RockPap…
ChrisWiles Jul 20, 2016
b97eea2
working
mccarthyist Jul 20, 2016
8724522
facebook name displayed in battleground
Dillonjay Jul 20, 2016
12dbe46
Merge pull request #6 from striking-lunatics/feature/fbName
burtoncooke1 Jul 20, 2016
4da772e
create Chatbox demo
ChrisWiles Jul 20, 2016
41d29ca
create chatBox demo
ChrisWiles Jul 20, 2016
1e41e0a
local chatbox working
mccarthyist Jul 20, 2016
1b4e94e
Add a dummy bar chart and WIP: piechart
sxcw Jul 20, 2016
26aa71c
Merge pull request #7 from striking-lunatics/feature/chatLobbyDemo
ChrisWiles Jul 20, 2016
0a2af95
Merge pull request #8 from striking-lunatics/feature/gameChat
ChrisWiles Jul 20, 2016
183097d
add socket.io
ChrisWiles Jul 20, 2016
3e10cdc
local chat with names
mccarthyist Jul 20, 2016
c7ed888
Merge remote-tracking branch 'refs/remotes/origin/feature/chatLobbyDemo'
ChrisWiles Jul 20, 2016
a1b42b3
Merge pull request #10 from striking-lunatics/feature/chatInGame
Jul 20, 2016
e4a0d96
add socket to server
ChrisWiles Jul 20, 2016
97c7975
fb username works
ChrisWiles Jul 20, 2016
5b05364
formating
ChrisWiles Jul 20, 2016
5eee9df
fix bind
ChrisWiles Jul 20, 2016
ff9cee0
add imageUrl colun to users table
burtoncooke1 Jul 20, 2016
0003d02
made chat in game look better
mccarthyist Jul 20, 2016
bbe2fe7
delete alert, add facebook name to create component
Dillonjay Jul 20, 2016
f75fce9
Merge pull request #11 from striking-lunatics/fix/alert
mccarthyist Jul 20, 2016
84cadda
Merge pull request #12 from striking-lunatics/feature/chatBetter
Jul 20, 2016
e416000
clean up code
ChrisWiles Jul 20, 2016
40e2464
clean up code
ChrisWiles Jul 20, 2016
ba8c2d2
Merge remote-tracking branch 'origin/master'
ChrisWiles Jul 20, 2016
d82cc8d
store facebook username in database
Dillonjay Jul 20, 2016
08bc668
Merge pull request #13 from striking-lunatics/feature/fbUser
ChrisWiles Jul 20, 2016
898fec6
Merge pull request #14 from striking-lunatics/feature/users-image-column
Jul 20, 2016
d374fa0
set up ajax request with facebook image paramater
Dillonjay Jul 20, 2016
49129b4
Merge pull request #15 from striking-lunatics/feature/addImgAjax
mccarthyist Jul 20, 2016
a3f2410
correct username bug
ChrisWiles Jul 20, 2016
7d36442
fixed fbUser
ChrisWiles Jul 20, 2016
91b2e31
Add leaderboard graph
sxcw Jul 20, 2016
abef268
Merge branch 'master' into feature/pieChart
sxcw Jul 20, 2016
7f8ca6a
fixed chat
mccarthyist Jul 20, 2016
2d95e9f
Merge pull request #16 from striking-lunatics/feature/goodChat
Jul 20, 2016
83111f7
chat in lobby
ChrisWiles Jul 20, 2016
a1e3dbb
Clean up code
sxcw Jul 21, 2016
b8e37c3
Merge pull request #17 from striking-lunatics/feature/pieChart
mccarthyist Jul 21, 2016
a59b6b6
show facebook name on join
Dillonjay Jul 21, 2016
011ac90
Merge pull request #18 from striking-lunatics/feature/fbJoin
Jul 21, 2016
5bb5f71
fix chat in mobile, needs work desktop
ChrisWiles Jul 21, 2016
0815ff6
fixed css
ChrisWiles Jul 21, 2016
13f1b31
Fix endpoint and add Stats router
sxcw Jul 21, 2016
dda5b5d
update existing users in database
burtoncooke1 Jul 21, 2016
8c84a4b
update existing users in database
burtoncooke1 Jul 21, 2016
adca60c
Merge pull request #20 from striking-lunatics/feature/pieChart
sxcw Jul 21, 2016
031413a
Add tooltip to barchart
sxcw Jul 21, 2016
5402988
update css
ChrisWiles Jul 21, 2016
bc9d770
merge
burtoncooke1 Jul 21, 2016
2c41e85
Merge pull request #21 from striking-lunatics/fix/player-name-display
mccarthyist Jul 21, 2016
ed81d3c
Merge branch 'master' into feature/pieChart
sxcw Jul 21, 2016
b7fc2f2
add user image into database
Dillonjay Jul 21, 2016
c4848c8
Merge pull request #22 from striking-lunatics/feature/addImg
mccarthyist Jul 21, 2016
5b2a179
show opponent image
Dillonjay Jul 21, 2016
296b189
convert skelton to bootstrap Lobby, Menu
ChrisWiles Jul 21, 2016
0cea13d
Merge pull request #23 from striking-lunatics/feature/addImg
ChrisWiles Jul 21, 2016
f7d28fe
Merge pull request #24 from striking-lunatics/feature/Bootstrap
Jul 21, 2016
1882731
delete broken facebook function
Dillonjay Jul 21, 2016
50d0568
Merge pull request #25 from striking-lunatics/fix/deleteFbFunction
mccarthyist Jul 21, 2016
b769e11
accesscode -> accessCode
ChrisWiles Jul 21, 2016
0786174
Merge remote-tracking branch 'origin/master'
ChrisWiles Jul 21, 2016
e9ecca5
add bootstrap table
ChrisWiles Jul 21, 2016
b918d28
Merge pull request #26 from striking-lunatics/feature/Bootstrap
Jul 21, 2016
83137ff
Sort and Limit players, WIP: tooltip message
sxcw Jul 21, 2016
054e994
adding features to database
burtoncooke1 Jul 21, 2016
a99cae9
Merge branch 'master' into feature/pieChart
sxcw Jul 21, 2016
bef9dae
update chatbox
ChrisWiles Jul 21, 2016
1e69e19
update buttons
ChrisWiles Jul 21, 2016
76292af
add 10 msgs
ChrisWiles Jul 21, 2016
0542e04
Merge pull request #27 from striking-lunatics/feature/pieChart
Jul 21, 2016
ac990f3
Merge remote-tracking branch 'refs/remotes/origin/master' into featur…
ChrisWiles Jul 21, 2016
3a4922e
Merge remote-tracking branch 'refs/remotes/origin/master' into featur…
ChrisWiles Jul 21, 2016
ae9616e
intermediary commit
burtoncooke1 Jul 21, 2016
d96d316
Merge pull request #29 from striking-lunatics/feature/Bootstrap
mccarthyist Jul 21, 2016
a3b3848
again
burtoncooke1 Jul 21, 2016
7ac2a5b
add facebook auth own file
ChrisWiles Jul 21, 2016
f4b28e2
working draft
ChrisWiles Jul 21, 2016
e62c0a2
Merge pull request #30 from striking-lunatics/feature/Bootstrap
Jul 21, 2016
1c17047
nav bar
ChrisWiles Jul 21, 2016
140d209
Merge pull request #31 from striking-lunatics/feature/Bootstrap
ChrisWiles Jul 21, 2016
6d6c39c
fix css error
Dillonjay Jul 21, 2016
40a0d58
Merge pull request #32 from striking-lunatics/fix/css
Jul 21, 2016
185944b
add rock, paper buttons
ChrisWiles Jul 21, 2016
fbd254f
fix navbar
Dillonjay Jul 21, 2016
65cd180
Merge pull request #33 from striking-lunatics/fix/css
Jul 21, 2016
79d7f78
chat display below input. add background image.
Dillonjay Jul 21, 2016
e2112da
Merge pull request #34 from striking-lunatics/fix/css
mccarthyist Jul 21, 2016
75695a1
wins and losses working
burtoncooke1 Jul 21, 2016
b3a9937
merge conflicts resolved
burtoncooke1 Jul 21, 2016
7104f79
game timestamp working
burtoncooke1 Jul 21, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions client/components/BattleContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Player from './Player'
import Mike from './Mike' // opponent
import Banner from './Banner'
import Scoreboard from './Scoreboard'
import Chat from './Chat'

import * as Game from '../models/game'

Expand All @@ -27,7 +28,9 @@ export default class BattleContainer extends React.Component {
componentDidMount() {
this.gameId = sessionStorage.getItem('gameId');
this.userId = sessionStorage.getItem('userId');

//populate facebook photo image. either undefined or not.
this.fbPhoto = sessionStorage.getItem('imgUrl');
this.fbName = sessionStorage.getItem('fbUser')
// populate player and opponent state objects
this.updatePlayer();
this.updateOpponent();
Expand Down Expand Up @@ -84,17 +87,24 @@ export default class BattleContainer extends React.Component {
}
}


updatePlayer() {
return Game.getPlayerById(this.userId)
.then(data => {
this.setState({player: data[0]});
console.log('here is our data,', data)
//console.log(`${this.userId}: ${data}`);
// this if checker is a safety net
if (data[0] !== undefined) {
this.setState({player: data[0]});
}
return;
});
}

updateOpponent() {
return Game.getOpponentByPlayerId(this.userId, this.gameId)
.then(data => {
console.log('here is opponent data:', data)
this.setState({opponent: data[0]});
return;
});
Expand Down Expand Up @@ -202,6 +212,9 @@ export default class BattleContainer extends React.Component {
icon={this.state.opponentIcon}
/>
</div>
<Chat
player={this.state.player}
/>
</div>
);
}
Expand Down
76 changes: 76 additions & 0 deletions client/components/Chat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React from 'react';

export default class Chat extends React.Component {

constructor(){
super();
this.state = {
messages: [],
chatText: '',
username: ''
}
}

componentWillMount() {
this.gameId = sessionStorage.getItem('gameId');
this.fbUser = sessionStorage.getItem('fbUser');
this.setState({username: this.fbUser})

// this.userId = sessionStorage.getItem('userId');

socket.emit('subscribe', this.gameId);
var self = this
socket.on('chat message', function(msg){
console.log("socket.on: ", msg)
self.setState({messages: self.state.messages.concat(msg) })
});
}

_handleSubmit(e) {
var self = this

e.preventDefault()
this.gameId = sessionStorage.getItem('gameId');
console.log("uh ", this.gameId)
console.log("socket.emit: ", this.state.chatText)
socket.emit('send', {room: this.gameId, name: self.state.username ? self.state.username : self.props.player.name, message: this.state.chatText})
}

render () {
return (
<div className="chatBox">
<div className="messages">
<table className="u-full-width">
<tbody>
{this.state.messages.map(function(msg, index){return (<Message key={index} name={msg.name} message={msg.message} />)})}
</tbody>
</table>
</div>
<form onSubmit={this._handleSubmit.bind(this)}>
<input
type="text"
value={this.state.chatText}
className="u-full-width"
placeholder="chat..."
id="chatInput"
onChange={event => this.setState({chatText: event.target.value})}/>

<input type="submit" style={{visibility: 'hidden'}} ></input>
</form>
</div>
)
}
}

class Message extends React.Component {
render() {
return (

<tr className="message">
<td>{this.props.name}</td>
<td>{this.props.message}</td>
</tr>

)
}
}
97 changes: 97 additions & 0 deletions client/components/Chatbox.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import React from "react"

export default class Chatbox extends React.Component {

constructor() {
super();
this.state = {
text : "",
messages: [],
}
}

componentDidMount() {
var self = this
socket.on("Chatbox message", function (msg) {
self.setState({
messages: self.state.messages.concat(msg)
})
});
}

_handleSubmit(event) {
event.preventDefault();
socket.emit("Chatbox message", {
name : sessionStorage.getItem("fbUser") || "Anon",
message: this.state.text,
})
// send request to the socket.io
this.setState({
text: ""
})
}

render() {

return (
<div >
<form onSubmit={this._handleSubmit.bind(this)}>
<div className="input-group">
<input
type="text"
className="form-control"
onFocus={event => this.value = ""}
value={this.state.text}
placeholder="chat..."
id="chatInput"
onChange={event => this.setState({text: event.target.value})}
/>
</div>
</form>
<Messages messages={this.state.messages}/>
</div>
)
}
}

class Messages extends React.Component {

_createMessages() {
var msgTrim;
if (this.props.messages.length > 10) {
msgTrim = this.props.messages.slice(this.props.messages.length - 10);
} else {
msgTrim = this.props.messages;
}
return msgTrim.map((msg,
index) => {
return <Message
key={index}
name={msg.name.substring(0, 15)}
message={msg.message.substring(0, 31)}/>
});
}

render() {
return (
<div className="messages">
<table className="table table-hover">
<tbody>
{this._createMessages()}
</tbody>
</table>
</div>
)
}
}

class Message extends React.Component {
render() {
return (
<tr className="message">
<td className="text-left">{this.props.name}</td>
<td className="text-right">{this.props.message}</td>
</tr>
)
}
}
42 changes: 31 additions & 11 deletions client/components/Create.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export default class Join extends React.Component {
constructor(){
super();
}

// generate new access code and reroute to there
componentWillMount(){
this.fbName = sessionStorage.getItem('fbUser');
}
handleCreate(e) {
e.preventDefault();
let gameGenerated = false;
Expand All @@ -18,7 +19,7 @@ export default class Join extends React.Component {
db.gameList()
.then(gameList => {
const accessCodes = gameList.map(game => game.access_code);
// check if generated access code already exists
// check if generated access code already exists
while (!gameGenerated) {
if (!accessCodes.includes(accessCode)) {
// create new game using access code
Expand All @@ -32,9 +33,24 @@ export default class Join extends React.Component {
return gameId;
})
.then(gameId => {

var username;
sessionStorage.getItem('fbUser') ?
username = sessionStorage.getItem('fbUser')
: username = this.props.username;

var imageUrl;
sessionStorage.getItem('imgUrl') ?
imageUrl = sessionStorage.getItem('imgUrl')
: null;


console.log("showing username before insertion:", username);
console.log('showing imageurl before insertion:', imageUrl)
// create new user using new gameId
db.generateNewUser(gameId, this.props.username)
db.generateNewUser(gameId, username, imageUrl, 'create')
.then(userId => {
// console.log("showing returned user id in Create:", userId);
userId = userId[0];

// set current userId to local storage
Expand All @@ -51,20 +67,24 @@ export default class Join extends React.Component {
})
}

// show create game username input and buttons
render() {
return (
// show create game username input and buttons
render() {
return (
<form className="create-game">
<input
type="text"
{this.fbName ?
<h4>{this.fbName}</h4>
:
<input
type="text"
placeholder="Enter your name"
value={this.props.username}
onChange={this.props.handleUsernameChange}
/>
}

<div className="button-container">
<button type="submit" onClick={this.handleCreate.bind(this)}>Create Game</button>
<button onClick={this.props.handleViewChange.bind(null, 'menu')}>Back</button>
<button className="btn btn-default" type="submit" onClick={this.handleCreate.bind(this)}>Create Game</button>
<button className="btn btn-default" onClick={this.props.handleViewChange.bind(null, 'menu')}>Back</button>
</div>
</form>
);
Expand Down
21 changes: 19 additions & 2 deletions client/components/End.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
import React from 'react'
import { Link } from 'react-router'
import * as Menu from '../models/menu'
//--------------------Game Over Page-------------//
export default class End extends React.Component{

componentDidMount() {

var winner = this.props.winner;
var userId = this.props.userId;
// console.log("showing user id in end.js:", this.props);
Menu.updateGameStatus(this.props.gameId, 'completed')
.then(function(data) {
console.log("updated status to complete!:", data);
Menu.updateUserRecord(userId, winner)
.then(function(data) {

})
})
}

render() {
return (
<section className="narrative container six columns offset-by-three">
Expand All @@ -13,8 +30,8 @@ export default class End extends React.Component{
<hr />

<div className="button-container">
<button onClick={this.props.rematch}>Rematch</button>
<Link to="/"><button>Leave Game</button></Link>
<button className="btn btn-default" onClick={this.props.rematch}>Rematch</button>
<Link to="/"><button className="btn btn-default">Leave Game</button></Link>
</div>

</section>
Expand Down
2 changes: 2 additions & 0 deletions client/components/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export default class Game extends React.Component {
endGame={this.endGame.bind(this)}
/> :
<End
gameId={this.gameId}
userId={this.userId}
winner={this.state.winner}
rematch={this.rematch.bind(this)}
/>}
Expand Down
Loading