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