import React from 'react'; class GridField extends React.Component { constructor(props) { super(props); this.state = { currentObj: 'w', currentImage: null, active: false, lastClickedRed: false, lastClickedBlue: false, bombTargetArea: null, icons: { root: '/images/', water: { 1: 'bg-wave-1-outbg.png', 2: 'bg-wave-1-outbg.png', 3: 'bg-wave-2-outbg.png' }, flag: { red: 'bg-flag-red-outbg.png', blue: 'bg-flag-blue-outbg.png' }, target: { lastBlue: 'bg-last-blue-outbg.png', lastRed: 'bg-last-red-outbg.png', crosshair: 'bg-target-outbg.png', crosshairBomb: 'bg-target-bomb-outbg.png' }, left: 'bg-left-mine-outbg.png' } }; } componentWillMount() { var wave = Math.floor(Math.random() * 3) + 1; this.setState({ currentImage: this.state.icons.root + this.state.icons.water[wave] }); } classNameWhenActive() { return 'field' + (this.state.active === true ? ' active' : '') + (this.state.active === true && this.state.currentObj === 'm' ? ' mine' : '') + ' color-' + this.state.currentObj; } currentImage() { return isNaN(this.state.currentImage) ?
{this.createBombTarget()}
{this.currentLastClicked()}