From feb7e5e63085e8005c256fc141b42f2ed0e3e5a1 Mon Sep 17 00:00:00 2001 From: jwc780 Date: Sat, 11 Jul 2020 15:48:38 -0400 Subject: [PATCH] feature: ship changes now try to resolve to the same tier --- src/components/ShellForms/DefaultForms.tsx | 31 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/components/ShellForms/DefaultForms.tsx b/src/components/ShellForms/DefaultForms.tsx index bd3e557..53fe245 100644 --- a/src/components/ShellForms/DefaultForms.tsx +++ b/src/components/ShellForms/DefaultForms.tsx @@ -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 { const options = Object.keys(qDataS[nation]); this.updateForm('shipType', options, options); @@ -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); }