Commit e10b7f6c authored by Matthew Odle's avatar Matthew Odle

clean up messaging; add alert for villager statuses

parent 7fb24f93
......@@ -7,7 +7,7 @@ export class Buildings extends React.Component {
render(props) {
return <div className="buildingContainer">
<div className="buildings">
<h3>Buildings <label className="assignmentInstruction">(click to assign)</label></h3>
<h3>Buildings</h3>
{ this.props.buildings.map( building =>
<Building
key={building.id}
......
......@@ -93,7 +93,7 @@ export class Village extends React.Component {
);
this.updateTheVillageStore(villageStore);
building.materialsInUse = true;
this.updateLog("used by " + building.label + ": " + building.materials.map(material => material ))
this.updateLog(building.materials.map(material => material + " -1" ))
};
addProduct = (buildingName, goods) => {
......@@ -110,7 +110,7 @@ export class Village extends React.Component {
// all of this will get rewritten when good stores get moved to the buildings
let goodsMapping = {}
goods.map( good => Array.from(Object.keys(goodsMapping)).includes(good) ? goodsMapping[good] += 1 : goodsMapping[good] = 1);
this.updateLog("produced by " + buildingName + ": " + Array.from(Object.keys(goodsMapping)).map(good => good + ": " + goodsMapping[good]))
this.updateLog(Array.from(Object.keys(goodsMapping)).map(good => good + " +" + goodsMapping[good] + " "))
this.updateTheVillageStore(villageStore);
};
......@@ -193,7 +193,8 @@ export class Village extends React.Component {
villager.toolDurability = 100;
villager.hasTool = true;
villageStore['tool'].count -= 1;
villageStore['tool'].classNames.badThingHappened = true
villageStore['tool'].classNames.badThingHappened = true;
this.updateLog('tool -1');
}
}
......@@ -208,6 +209,7 @@ export class Village extends React.Component {
if (villageStore['firewood'].count > 0) {
villager.warmth += this.props.knobsAndLevers.warmthPerFirewood;
villageStore['firewood'].count -= 1;
this.updateLog('firewood -1');
}
}
......@@ -226,7 +228,6 @@ export class Village extends React.Component {
villager.warmth -= villager.clothed ? Math.ceil(baseWarmthDecayRate - clothingWarmthDecayReduction) : baseWarmthDecayRate;
villager.warmth < villagerDeathValue ? villager.warmth = villagerDeathValue : null;
this.consumeFirewoodIfNeeded(villager);
}
getClothing = (villager) => {
......@@ -236,6 +237,7 @@ export class Village extends React.Component {
villager.clothed = true;
villageStore['clothing'].count -= 1;
villageStore['clothing'].classNames.badThingHappened = true
this.updateLog('clothing -1');
}
}
......@@ -251,6 +253,7 @@ export class Village extends React.Component {
villager.energy += this.props.knobsAndLevers.energyPerFood;
villageStore['food'].count -= 1;
villageStore['food'].classNames.badThingHappened = true
this.updateLog('food -1');
}
}
......@@ -372,6 +375,14 @@ export class Village extends React.Component {
});
}
alertStatusInfo = () => {
const villagerStatus = this.state.villagerStatus;
Array.from(Object.keys(villagerStatus)).map(status => {
villagerStatus[status].count > 0 ? this.updateLog(villagerStatus[status].count + ' villagers are ' + status) : null;
console.log(status);
});
}
tick = () => {
this.resetStatusClassNames();
this.resetStoreClassNames();
......@@ -379,6 +390,9 @@ export class Village extends React.Component {
this.manageProductionBuildings(buildings);
this.manageVillagerConditions();
this.captureGameStatusInfo();
if (this.state.score % 10 === 0) {
this.alertStatusInfo();
}
this.checkGameEndConditions();
if (this.state.gameOver) {
clearInterval(this.timer);
......
......@@ -32,6 +32,9 @@ button {
height: 150px;
overflow: hidden;
}
.message {
padding: 3px 0;
}
.score {
width: 35px;
padding: 5px 0;
......@@ -57,10 +60,6 @@ button {
.buildingLabel {
font: bold 1em Georgia, serif;
}
.assignmentInstruction {
display: inline;
font: 1em Georgia, serif;
}
.management {
......@@ -113,15 +112,13 @@ button {
top: 0px;
float: right;
}
.stores {
border: 1px solid black;
}
.stores, .statuses {
position: relative;
z-index: 10;
cursor: default;
width: 140px;
padding: 5px 0px;
border: 1px solid black;
}
.resources, .infos {
display: block;
......@@ -138,7 +135,7 @@ button {
float: right;
}
.goodThingHappened {
animation: fadeOutAdded 2s;
animation: fadeOutAdded 1s;
}
@keyframes fadeOutAdded {
from { background-color: lightgreen; }
......@@ -148,7 +145,7 @@ button {
color: tomato;
}
.badThingHappened {
animation: fadeOutRemoved 2s;
animation: fadeOutRemoved 1s;
}
@keyframes fadeOutRemoved {
from { background-color: tomato; }
......
......@@ -53,7 +53,7 @@ const startingLog = [
"Firewood prevents freezing.",
"Clothing staves off freezing longer.",
"Tools significantly increase production rate.",
"If a villaer is freezing or starving for too long, the villager dies.",
"If a villager is freezing or starving for too long, the villager dies.",
]
const villageStore = {
......
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