Skip to content

Commit

Permalink
Merge pull request #2532 from Thorium-Sim/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
alexanderson1993 authored Sep 9, 2019
2 parents 9ad4637 + 00b824f commit b5293c5
Show file tree
Hide file tree
Showing 9 changed files with 290 additions and 144 deletions.
42 changes: 41 additions & 1 deletion client/src/components/views/DamageControl/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const SYSTEMS_SUB = gql`
report
destroyed
which
taskReportDamage
}
simulatorId
type
Expand Down Expand Up @@ -85,6 +86,9 @@ class DamageControlCore extends Component {
if (sys.damage.damaged) {
obj.color = "red";
}
if (sys.damage.taskReportDamage) {
obj.color = "orangered";
}
if (!sys.name) {
obj.color = "purple";
}
Expand All @@ -100,6 +104,40 @@ class DamageControlCore extends Component {
}
return obj;
}
systemTitle(sys) {
if (sys.damage.taskReportDamage) {
return "Task Report Damage";
}
if (sys.damage.destroyed) {
return "Destroyed";
}
if (sys.damage.which === "engineering") {
return "Engineering";
}
if (sys.damage.which === "rnd") {
return "Research & Development";
}
if (sys.damage.damaged) {
return "Damaged";
}
// Overloaded the power levels
if (
sys.power &&
sys.power.powerLevels &&
sys.power.powerLevels.length > 0 &&
sys.power.powerLevels[sys.power.powerLevels.length - 1] < sys.power.power
) {
return "Overloaded Power";
}
if (
sys.power &&
sys.power.powerLevels &&
sys.power.powerLevels.length > 0 &&
!sys.power.powerLevels.find(p => p <= sys.power.power)
) {
return "Insufficient Power";
}
}
systemName(sys) {
if (sys.type === "Shield" && sys.name !== "Shields") {
return `${sys.name} Shields`;
Expand Down Expand Up @@ -146,7 +184,7 @@ class DamageControlCore extends Component {
which
};
let mutation;
if (system.damage.damaged) {
if (system.damage.damaged || system.damage.taskReportDamage) {
// Fix it
mutation = gql`
mutation RepairSystem($systemId: ID!) {
Expand Down Expand Up @@ -298,6 +336,7 @@ class DamageControlCore extends Component {
<td
onClick={e => this.toggleDamage(e, s)}
onContextMenu={e => this.setContext(e, s)}
title={this.systemTitle(s)}
style={this.systemStyle(s)}
>
{this.systemName(s)} {this.renderEngineSpeed(s)}
Expand Down Expand Up @@ -471,6 +510,7 @@ const SYSTEMS_QUERY = gql`
report
destroyed
which
taskReportDamage
}
simulatorId
type
Expand Down
5 changes: 5 additions & 0 deletions client/src/components/views/EngineControl/engine-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import gql from "graphql-tag.macro";

import HeatBar from "./heatbar";
import EngineButtons from "./engineButtons";
import DamageOverlay from "../helpers/DamageOverlay";

export default withApollo(props => {
const { engines, setSpeed, locked } = props;
Expand Down Expand Up @@ -52,6 +53,10 @@ export default withApollo(props => {
engines={engines}
setSpeed={setSpeed}
/>
<DamageOverlay
system={engines[0]}
message={`${engines[0].displayName || engines[0].name} Offline`}
/>
</Col>
<Col sm={{ size: 2, offset: 6 }} className="flex-column">
<Row className="flex-max">
Expand Down
8 changes: 3 additions & 5 deletions client/src/components/views/Exocomps/UpgradeScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ const COMPLETE_UPGRADE = gql`
}
`;
const UpgradeScreen = React.memo(
({
exocompId,
clearUpgradeBoard,
destination: { upgradeBoard, displayName }
}) => {
({ exocompId, clearUpgradeBoard, destination }) => {
if (!destination) return;
const { upgradeBoard, displayName } = destination;
return (
<div>
<h2>Upgrading {displayName}</h2>
Expand Down
13 changes: 11 additions & 2 deletions client/src/components/views/Exocomps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ class Exocomps extends Component {
}
recall={() => {
this.recall(e.id);
this.setState({ upgrade: false });
this.setState({
upgrade: false,
upgradeExocomp: null,
selectedExocomp: null
});
}}
upgrade={ex => {
this.setState({ upgradeExocomp: ex });
Expand All @@ -179,7 +183,12 @@ class Exocomps extends Component {
<ExocompConfig
{...exocomp}
simulatorId={simulator.id}
cancel={() => this.setState({ selectedExocomp: null })}
cancel={() =>
this.setState({
selectedExocomp: null,
upgradeExocomp: null
})
}
number={exocompNum}
deploy={this.deploy}
upgrade={this.state.upgrade}
Expand Down
8 changes: 5 additions & 3 deletions client/src/components/views/PowerDistribution/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ const PowerDistribution = ({ client, simulator, clientObj }) => {
"These are the ship’s batteries, if it has any. They show how much power is remaining in the batteries. If you use more power than is being outputted by your reactor, power will draw from the batteries. If they run out of power, you will have to balance your power, and the batteries will need to be recharged. You can recharge batteries from your reactor by using less power than the current reactor output. Don’t let these run out in the middle of space. That would be...problematic."
}
].filter(Boolean);

return (
<Container fluid={!!battery} className="powerLevels">
<Row className="powerlevel-row">
Expand Down Expand Up @@ -165,8 +164,8 @@ const Systems = React.memo(
.sort((a, b) => {
if (a.type > b.type) return 1;
if (a.type < b.type) return -1;
if (a.name > b.name) return 1;
if (a.name < b.name) return -1;
if (a.displayName > b.displayName) return 1;
if (a.displayName < b.displayName) return -1;
return 0;
})
.filter(
Expand Down Expand Up @@ -199,6 +198,9 @@ const Systems = React.memo(
const prevPower = prevProps.systems.map(p => p.power.power);
const nextPower = nextProps.systems.map(p => p.power.power);
if (prevPower.join(",") !== nextPower.join(",")) return false;
const prevDisplayName = prevProps.systems.map(p => p.displayName);
const nextDisplayName = nextProps.systems.map(p => p.displayName);
if (prevDisplayName.join(",") !== nextDisplayName.join(",")) return false;
return true;
}
);
Expand Down
Loading

0 comments on commit b5293c5

Please sign in to comment.