mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-10 07:05:35 +00:00
Ensure that opponent piips are updated immediately when a new opponent is selecteD
This commit is contained in:
@@ -267,15 +267,29 @@ export default class OutfittingPage extends Page {
|
|||||||
*/
|
*/
|
||||||
_opponentUpdated(opponent, opponentBuild) {
|
_opponentUpdated(opponent, opponentBuild) {
|
||||||
const opponentShip = new Ship(opponent, Ships[opponent].properties, Ships[opponent].slots);
|
const opponentShip = new Ship(opponent, Ships[opponent].properties, Ships[opponent].slots);
|
||||||
|
let opponentSys = this.state.opponentSys;
|
||||||
|
let opponentEng = this.state.opponentEng;
|
||||||
|
let opponentWep = this.state.opponentWep;
|
||||||
if (opponentBuild && Persist.getBuild(opponent, opponentBuild)) {
|
if (opponentBuild && Persist.getBuild(opponent, opponentBuild)) {
|
||||||
// Ship is a particular build
|
// Ship is a particular build
|
||||||
opponentShip.buildFrom(Persist.getBuild(opponent, opponentBuild));
|
opponentShip.buildFrom(Persist.getBuild(opponent, opponentBuild));
|
||||||
|
// Set pips for opponent
|
||||||
|
const opponentParts = Persist.getBuild(opponent, opponentBuild).split('.');
|
||||||
|
if (opponentParts.length >= 5) {
|
||||||
|
const opponentControl = LZString.decompressFromBase64(Utils.fromUrlSafe(opponentParts[4])).split('/');
|
||||||
|
opponentSys = parseFloat(opponentControl[0]);
|
||||||
|
opponentEng = parseFloat(opponentControl[1]);
|
||||||
|
opponentWep = parseFloat(opponentControl[2]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Ship is a stock build
|
// Ship is a stock build
|
||||||
opponentShip.buildWith(Ships[opponent].defaults);
|
opponentShip.buildWith(Ships[opponent].defaults);
|
||||||
|
opponentSys = 2;
|
||||||
|
opponentEng = 2;
|
||||||
|
opponentWep = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({ opponent: opponentShip, opponentBuild }, () => this._updateRouteOnControlChange());
|
this.setState({ opponent: opponentShip, opponentBuild, opponentSys, opponentEng, opponentWep }, () => this._updateRouteOnControlChange());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user