import React from 'react'; class User extends React.Component { constructor(props) { super(props); this.state = { name: "...", desc: "", active: props.active, color: props.color === 'blue' ? 1 : 0, mines: 0, srcRoot: '/images/', haveBomb: true, enabledBomb: true }; } setColor(color) { return 'user-container user-' + color; } getSrc(color) { return this.state.srcRoot + 'bg-flag-' + color + '-outbg.png'; } getBombBuzzClass(webPlayer) { let activePlayer = this.state.color === 1 ? 'blue' : 'red'; return "bomb-container" + ( this.state.active && (activePlayer === webPlayer) && this.state.haveBomb && this.state.enabledBomb ? ' buzz' : '' ); } getBomb() { let src = this.state.srcRoot; if (this.state.haveBomb) { src += this.state.enabledBomb && this.state.active ? 'bg-bomb-outbg.png' : 'bg-bomb-disabled-outbg.png'; } else { src += 'bg-bomb-exploded-outbg.png'; } return src; } getFigure(color) { return this.state.srcRoot + 'bg-figure-' + color + '-outbg.png'; } getCursor(state, color) { return state ? cursor : ''; } render() { return (
{this.props.color}
{this.getCursor(this.props.active, this.props.color)} figure
{this.state.name}
{this.state.desc}
flag
{this.state.mines}
bomb
); } } export default User;