-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cell.js
29 lines (25 loc) · 1.01 KB
/
Cell.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import React, { Component } from 'react';
export default class Cell extends Component {
render() {
const { onClick, gameOver, icons} = this.props;
const { isMine, isRevealed, numNeighborMines} = this.props.cellContent;
// board status rendering logic
let boardStatus = null;
if (gameOver) {
boardStatus = isMine ? icons["explodedBomb"] :
(numNeighborMines !== 0 ? icons["bombs"][numNeighborMines] : icons["pressed"]);
}
else {
boardStatus = (isRevealed && numNeighborMines === 0) ?
icons["pressed"] : icons["bombs"][numNeighborMines];
}
// to double check the correctness
// const rendered = isMine ? icons["exposedBomb"] : icons["blank"];
return (
<div onClick={onClick}>
{/* <img className="tile" src={rendered} alt="bomb"></img> */}
<img className="tile" src={boardStatus} alt="indicator"></img>
</div>
)
}
}