Skip to content

Add option to auto select the highest Ex level of units in unit builder#8

Open
kristoffer-henriksson wants to merge 2 commits intosailorsben:masterfrom
kristoffer-henriksson:master
Open

Add option to auto select the highest Ex level of units in unit builder#8
kristoffer-henriksson wants to merge 2 commits intosailorsben:masterfrom
kristoffer-henriksson:master

Conversation

@kristoffer-henriksson
Copy link

No description provided.

@kristoffer-henriksson
Copy link
Author

Screenshot of option to toggle auto selecting highest Ex level:
image

@sailorsben sailorsben added the enhancement New feature or request label Mar 7, 2023
@sailorsben
Copy link
Owner

// See if they own the unit. We need to look for both the current unit as well as the braveshift to handle the case where they start with the braveshifted unit. const ownedUnit = actuallyOwnedUnits[builds[currentUnitIndex].unit.id] ?? actuallyOwnedUnits[builds[currentUnitIndex].getBraveshift().unit.id]; const exRank = $("#autoSelectHighestExLevel").prop('checked') ? ownedUnit?.exRank ?? 1 : 1; $("#unitExAwakeningLevel select").val(exRank.toString()); builds[currentUnitIndex].setExAwakeningLevel(exRank);

This code doesn't check if actuallyOwnedUnits is defined. If someone doesn't log in, actuallyOwnedUnits never is populated to anything. It also causes the default EX level to be -1, since the code fails before the exRank is set.

@kristoffer-henriksson
Copy link
Author

// See if they own the unit. We need to look for both the current unit as well as the braveshift to handle the case where they start with the braveshifted unit. const ownedUnit = actuallyOwnedUnits[builds[currentUnitIndex].unit.id] ?? actuallyOwnedUnits[builds[currentUnitIndex].getBraveshift().unit.id]; const exRank = $("#autoSelectHighestExLevel").prop('checked') ? ownedUnit?.exRank ?? 1 : 1; $("#unitExAwakeningLevel select").val(exRank.toString()); builds[currentUnitIndex].setExAwakeningLevel(exRank);

This code doesn't check if actuallyOwnedUnits is defined. If someone doesn't log in, actuallyOwnedUnits never is populated to anything. It also causes the default EX level to be -1, since the code fails before the exRank is set.

Fixed by checking for assigned actuallyOwnedUnits before attempting to index into it.

@kristoffer-henriksson
Copy link
Author

@sailorsben the fix for the problem you pointed you is available and this is ready for another review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants