Skip to content

Commit

Permalink
feature: ship changes now try to resolve to the same tier
Browse files Browse the repository at this point in the history
  • Loading branch information
jcw780 committed Jul 11, 2020
1 parent 661aa3b commit feb7e5e
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/components/ShellForms/DefaultForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,31 @@ export class DefaultShips extends React.PureComponent
const targetData = this.props.defaultData[target]
let newValue = targetData[S.DefaultDataRowI.value];
if(!values.includes(newValue)){
newValue = values[0];
if(target != 'ship'){
newValue = values[0];
}else{
const oldOption = targetData[S.DefaultDataRowI.options][
targetData[S.DefaultDataRowI.values].indexOf(newValue)
];
const oldTier = parseInt(oldOption.substring(
oldOption.lastIndexOf("(") + 1, oldOption.lastIndexOf(")")
));
let found = false;
for(let i=0; i<options.length; i++) {
const option = options[i];
const tier = parseInt(option.substring(
option.lastIndexOf("(") + 1, option.lastIndexOf(")")
));
if(oldTier == tier){
found = true;
newValue = values[i];
break;
}
}
if(!found){
newValue = values[0];
}
}
}
targetData[S.DefaultDataRowI.options] = options;
targetData[S.DefaultDataRowI.values] = values;
Expand All @@ -143,7 +167,8 @@ export class DefaultShips extends React.PureComponent
}
//Aggressive length shortening
const nation = dData.nation[sDI], type = dData.shipType[sDI],
ship = dData.ship[sDI], artillery = dData.artillery[sDI];
ship = dData.ship[sDI], artillery = dData.artillery[sDI],
shellType = dData.shellType[sDI];
const queryType = () => {
const options = Object.keys(qDataS[nation]);
this.updateForm('shipType', options, options);
Expand All @@ -164,7 +189,7 @@ export class DefaultShips extends React.PureComponent
this.updateForm('shellType', options, options);
}
const sendData = () => {
const shellType = dData.shellType[sDI];
//const shellType = dData.shellType[sDI];
const shellName = qDataS[nation][type][ship].artillery[artillery][shellType];
this.props.sendDefault(dData.queriedData.shells[shellName], ship);
}
Expand Down

0 comments on commit feb7e5e

Please sign in to comment.