websocket basic setup FE & BE && working basic game w/ react && webpack & babel config
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import React from 'react';
|
||||
import User from './user';
|
||||
|
||||
class UserControl extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
/**
|
||||
* activePlayer - red: 0, blue: 1
|
||||
* @type {{activePlayer: number, mines: number}}
|
||||
*/
|
||||
this.state = {
|
||||
activePlayer: 0,
|
||||
mines: 51
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<User ref="blue" name={this.props.blue}/>
|
||||
<User ref="red" name={this.props.red}/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default UserControl;
|
||||
@@ -0,0 +1,23 @@
|
||||
import React from 'react';
|
||||
|
||||
class User extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
name: this.props.name,
|
||||
bomb: 1,
|
||||
mines: 0
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
{this.state.name}: {this.state.mines}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default User;
|
||||
Reference in New Issue
Block a user