From 3b69c4f5e1cdba7c899451902c96a2fb4309157e Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Sat, 1 Jun 2019 17:09:14 +1000 Subject: [PATCH] Fixed some issues --- server/equipment_statistics.json | 20 ++++++++++---------- src/components/panels/equipment.jsx | 17 +++++++++-------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/server/equipment_statistics.json b/server/equipment_statistics.json index 0c9cd43..e5a88fe 100644 --- a/server/equipment_statistics.json +++ b/server/equipment_statistics.json @@ -1,18 +1,18 @@ { "Weapons": { - "Stick": { "cost": 50, "purchasable": true, "saleable": true, "scientistsRequired": 1, "combatBoost": 0.02 }, - "Dagger": { "cost": 75, "purchasable": true, "saleable": true, "scientistsRequired": 2, "combatBoost": 0.03 }, - "Sword": { "cost": 100, "purchasable": true, "saleable": true, "scientistsRequired": 3, "combatBoost": 0.04 }, - "Longsword": { "cost": 150, "purchasable": true, "saleable": true, "scientistsRequired": 4, "combatBoost": 0.05 }, - "Frying Pan": { "cost": 200, "purchasable": true, "saleable": true, "scientistsRequired": 5, "combatBoost": 0.06 } + "Stick": { "cost": 50, "purchasable": true, "saleable": true, "scientistsRequired": 1, "visible": true, "combatBoost": 0.02 }, + "Dagger": { "cost": 75, "purchasable": true, "saleable": true, "scientistsRequired": 2, "visible": true, "combatBoost": 0.03 }, + "Sword": { "cost": 100, "purchasable": true, "saleable": true, "scientistsRequired": 3, "visible": true, "combatBoost": 0.04 }, + "Longsword": { "cost": 150, "purchasable": true, "saleable": true, "scientistsRequired": 4, "visible": true, "combatBoost": 0.05 }, + "Frying Pan": { "cost": 200, "purchasable": true, "saleable": true, "scientistsRequired": 5, "visible": true, "combatBoost": 0.06 } }, "Armour": { - "Leather": { "cost": 75, "purchasable": false, "saleable": true, "scientistsRequired": 2, "combatBoost": 0.02 }, - "Gambeson": { "cost": 100, "purchasable": false, "saleable": true, "scientistsRequired": 3, "combatBoost": 0.03 }, - "Chainmail": { "cost": 150, "purchasable": false, "saleable": true, "scientistsRequired": 4, "combatBoost": 0.04 }, - "Platemail": { "cost": 200, "purchasable": false, "saleable": true, "scientistsRequired": 5, "combatBoost": 0.05 } + "Leather": { "cost": 75, "purchasable": false, "saleable": true, "scientistsRequired": 2, "visible": true, "combatBoost": 0.02 }, + "Gambeson": { "cost": 100, "purchasable": false, "saleable": true, "scientistsRequired": 3, "visible": true, "combatBoost": 0.03 }, + "Chainmail": { "cost": 150, "purchasable": false, "saleable": true, "scientistsRequired": 4, "visible": true, "combatBoost": 0.04 }, + "Platemail": { "cost": 200, "purchasable": false, "saleable": true, "scientistsRequired": 5, "visible": true, "combatBoost": 0.05 } }, "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 } } } \ No newline at end of file diff --git a/src/components/panels/equipment.jsx b/src/components/panels/equipment.jsx index 9ea97e8..4bca395 100644 --- a/src/components/panels/equipment.jsx +++ b/src/components/panels/equipment.jsx @@ -17,8 +17,10 @@ class Equipment extends React.Component { } render() { + let display = this.flattenStructure(this.state, this.props.scientists); + //if there are no scientists - if (this.props.scientists <= 0) { + if (this.props.scientists <= 0 && display.length === 0) { return (

You have no scientists!

@@ -27,8 +29,6 @@ class Equipment extends React.Component { ); } - let display = this.flattenStructure(this.state, this.props.scientists); - return (
@@ -91,13 +91,13 @@ class Equipment extends React.Component { Object.keys(structure.statistics).map((type) => { Object.keys(structure.statistics[type]).map((name) => { - //don't render high level items - if (structure.statistics[type][name].scientistsRequired > scientists) { + //don't render high level items you don't own + if (structure.statistics[type][name].scientistsRequired > scientists && !structure.owned[name]) { return; } - //if you can't buy it and you down own it, don't render it (for legendary items) - if (!structure.statistics[type][name].purchasable && !structure.owned[name]) { + //if you can't see it and you don't own it, don't render it (for legendary items) + if (!structure.statistics[type][name].visible && !structure.owned[name]) { return; } @@ -106,7 +106,8 @@ class Equipment extends React.Component { name: name, type: type, 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 }); }); });