Commit 3d4ea149 authored by Matthew Odle's avatar Matthew Odle

clear interval on game over

parent 80c9dd09
......@@ -396,13 +396,13 @@ export class Village extends React.Component {
}
tick = () => {
this.checkGameEndConditions();
if (this.state.gameOver) {
return;
}
const buildings = this.props.buildings.slice();
this.manageProductionBuildings(buildings);
this.manageVillagerConditions();
this.checkGameEndConditions();
if (this.state.gameOver) {
clearInterval(this.timer);
}
this.setState({
score: this.state.score + 1,
buildings: buildings,
......
......@@ -17,10 +17,10 @@ export class Villager extends React.Component {
background: 'linear-gradient(to right, aquamarine 0%, aquamarine ' + villager.energy + '%, bisque ' + villager.energy + '%, bisque 100%)'
};
return <div className={
villager.assignment === "DEAD"
? "villager terminated"
: (villager.assignment === "IDLE" ? "villager inactive" : "villager active" )
}
villager.assignment === "DEAD"
? "villager terminated"
: (villager.assignment === "IDLE" ? "villager inactive" : "villager active" )
}
>
<div className="villagerAssignment">{villager.assignment}</div>
<div>
......
......@@ -77,6 +77,7 @@ button {
margin: 2px;
display: inline-block;
border: 1px solid black;
text-align: center;
}
.terminated {
background-color: tomato;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment