You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
47 lines
1.2 KiB
require('../../sass/board/grid.scss');
|
|
|
|
import { Component } from 'react';
|
|
import { connect } from 'react-redux';
|
|
import GridCell from './GridCell';
|
|
import * as creators from '../app/Creators';
|
|
import { GRID } from '../app/Settings';
|
|
|
|
export default class Grid extends Component {
|
|
componentDidMount(n) {
|
|
this.props.dispatch(creators.generateValues(GRID.W * GRID.H, 1));
|
|
// State.subscribe('level/next', this.levelNext);
|
|
};
|
|
|
|
checkComplete() {
|
|
// if (Values.checkComplete(this.state.values, State.level) === true) {
|
|
// State.publish('level/complete');
|
|
// }
|
|
};
|
|
|
|
levelNext() {
|
|
// this.setState({ values: this.generateValues() });
|
|
};
|
|
|
|
render() {
|
|
const { values, dispatch } = this.props;
|
|
const cells = [];
|
|
let i;
|
|
|
|
for (let x = 0; x < GRID.W; x++) {
|
|
for (let y = 0; y < GRID.H; y++) {
|
|
i = y * GRID.W + x;
|
|
cells.push(<GridCell value={values[i]} x={x} y={y} key={i} />);
|
|
}
|
|
}
|
|
|
|
return (<div className='grid'>{cells}</div>);
|
|
};
|
|
};
|
|
|
|
const select = (state) => {
|
|
return {
|
|
values: state.values
|
|
}
|
|
};
|
|
|
|
export default connect(select)(Grid);
|
|
|