Fixed some issues

This commit is contained in:
2019-06-01 17:09:14 +10:00
parent bdba64aed3
commit 3b69c4f5e1
2 changed files with 19 additions and 18 deletions
+10 -10
View File
@@ -1,18 +1,18 @@
{ {
"Weapons": { "Weapons": {
"Stick": { "cost": 50, "purchasable": true, "saleable": true, "scientistsRequired": 1, "combatBoost": 0.02 }, "Stick": { "cost": 50, "purchasable": true, "saleable": true, "scientistsRequired": 1, "visible": true, "combatBoost": 0.02 },
"Dagger": { "cost": 75, "purchasable": true, "saleable": true, "scientistsRequired": 2, "combatBoost": 0.03 }, "Dagger": { "cost": 75, "purchasable": true, "saleable": true, "scientistsRequired": 2, "visible": true, "combatBoost": 0.03 },
"Sword": { "cost": 100, "purchasable": true, "saleable": true, "scientistsRequired": 3, "combatBoost": 0.04 }, "Sword": { "cost": 100, "purchasable": true, "saleable": true, "scientistsRequired": 3, "visible": true, "combatBoost": 0.04 },
"Longsword": { "cost": 150, "purchasable": true, "saleable": true, "scientistsRequired": 4, "combatBoost": 0.05 }, "Longsword": { "cost": 150, "purchasable": true, "saleable": true, "scientistsRequired": 4, "visible": true, "combatBoost": 0.05 },
"Frying Pan": { "cost": 200, "purchasable": true, "saleable": true, "scientistsRequired": 5, "combatBoost": 0.06 } "Frying Pan": { "cost": 200, "purchasable": true, "saleable": true, "scientistsRequired": 5, "visible": true, "combatBoost": 0.06 }
}, },
"Armour": { "Armour": {
"Leather": { "cost": 75, "purchasable": false, "saleable": true, "scientistsRequired": 2, "combatBoost": 0.02 }, "Leather": { "cost": 75, "purchasable": false, "saleable": true, "scientistsRequired": 2, "visible": true, "combatBoost": 0.02 },
"Gambeson": { "cost": 100, "purchasable": false, "saleable": true, "scientistsRequired": 3, "combatBoost": 0.03 }, "Gambeson": { "cost": 100, "purchasable": false, "saleable": true, "scientistsRequired": 3, "visible": true, "combatBoost": 0.03 },
"Chainmail": { "cost": 150, "purchasable": false, "saleable": true, "scientistsRequired": 4, "combatBoost": 0.04 }, "Chainmail": { "cost": 150, "purchasable": false, "saleable": true, "scientistsRequired": 4, "visible": true, "combatBoost": 0.04 },
"Platemail": { "cost": 200, "purchasable": false, "saleable": true, "scientistsRequired": 5, "combatBoost": 0.05 } "Platemail": { "cost": 200, "purchasable": false, "saleable": true, "scientistsRequired": 5, "visible": true, "combatBoost": 0.05 }
}, },
"Consumables": { "Consumables": {
"Potion": { "cost": 100, "purchasable": true, "saleable": true, "scientistsRequired": 1, "combatBoost": 0.04 } "Potion": { "cost": 100, "purchasable": true, "saleable": true, "scientistsRequired": 1, "visible": true, "combatBoost": 0.04 }
} }
} }
+9 -8
View File
@@ -17,8 +17,10 @@ class Equipment extends React.Component {
} }
render() { render() {
let display = this.flattenStructure(this.state, this.props.scientists);
//if there are no scientists //if there are no scientists
if (this.props.scientists <= 0) { if (this.props.scientists <= 0 && display.length === 0) {
return ( return (
<div className='panel'> <div className='panel'>
<p className='centered'>You have no scientists!</p> <p className='centered'>You have no scientists!</p>
@@ -27,8 +29,6 @@ class Equipment extends React.Component {
); );
} }
let display = this.flattenStructure(this.state, this.props.scientists);
return ( return (
<div className='panel'> <div className='panel'>
<div className='table'> <div className='table'>
@@ -91,13 +91,13 @@ class Equipment extends React.Component {
Object.keys(structure.statistics).map((type) => { Object.keys(structure.statistics).map((type) => {
Object.keys(structure.statistics[type]).map((name) => { Object.keys(structure.statistics[type]).map((name) => {
//don't render high level items //don't render high level items you don't own
if (structure.statistics[type][name].scientistsRequired > scientists) { if (structure.statistics[type][name].scientistsRequired > scientists && !structure.owned[name]) {
return; return;
} }
//if you can't buy it and you down own it, don't render it (for legendary items) //if you can't see it and you don't own it, don't render it (for legendary items)
if (!structure.statistics[type][name].purchasable && !structure.owned[name]) { if (!structure.statistics[type][name].visible && !structure.owned[name]) {
return; return;
} }
@@ -106,7 +106,8 @@ class Equipment extends React.Component {
name: name, name: name,
type: type, type: type,
owned: (structure.owned && structure.owned[name]) || 0, owned: (structure.owned && structure.owned[name]) || 0,
...structure.statistics[type][name] ...structure.statistics[type][name],
purchasable: structure.statistics[type][name].purchasable && structure.statistics[type][name].scientistsRequired <= scientists //negate purchasing of too-high-level items
}); });
}); });
}); });