@@ -1791,46 +1791,49 @@ class Assistant {
17911791 let choice = Assistant . affixDB [ affix . code ] . choices [ m ] ;
17921792 // set flag true
17931793 let isMatch = true ;
1794- // Check if Add Ability
1795- if ( choice . isAddAbilityItem || affix . noEx ) {
1794+ // Check if SSA.
1795+ if ( affix . noEx ) {
1796+ // Force 100% success regardless of upslot.
17961797 abilitySuccessRates [ k ] = Math . min ( Math . max ( choice . transferRate , minRate ) , maxRate ) ;
1797- if ( affix . noEx ) {
1798- abilitySuccessRates . length ++ ;
1799- if ( fodderSuccessRate < 0 ) fodderSuccessRate = ( abilitySuccessRates [ k ] - minRate ) / ( maxRate - minRate ) ;
1800- else fodderSuccessRate *= ( abilitySuccessRates [ k ] - minRate ) / ( maxRate - minRate ) ;
1801- break ;
1798+ abilitySuccessRates . length ++ ;
1799+ if ( fodderSuccessRate < 0 ) fodderSuccessRate = ( abilitySuccessRates [ k ] - minRate ) / ( maxRate - minRate ) ;
1800+ else fodderSuccessRate *= ( abilitySuccessRates [ k ] - minRate ) / ( maxRate - minRate ) ;
1801+ break ;
1802+ }
1803+ // Check if Add Ability.
1804+ else if ( choice . isAddAbilityItem ) {
1805+ if ( fodder . addAbilityItemInUse === undefined
1806+ || fodder . addAbilityItemInUse === null
1807+ || fodder . addAbilityItemInUse . ref !== choice . ref ) {
1808+ isMatch = false ;
18021809 }
18031810 }
1804- else {
1805- // Check if affix in this fodder comes from some fodder with Special Ability Factor
1806- if ( ! fodder . affixIndicesFromFactor . includes ( k ) ) {
1807- // If affix is not from factor, but choice is for factors, it is not a match
1808- if ( choice . isAbilityFactor ) {
1809- isMatch = false ;
1810- }
1811- else {
1812- // count occurrences of each ability in choice
1813- let choiceCount = countOccurrences ( choice . materials ) ;
1814- // count occurrences of each ability in all abilities in page
1815- let abilityCount = countOccurrences ( abilities ) ;
1816- // for each different occurence in choice
1817- for ( var code in choiceCount ) {
1818- // if all bilities have less than count
1819- if ( ! abilityCount [ code ] || abilityCount [ code ] < choiceCount [ code ] ) {
1820- // does not match, so set flag false and break
1821- isMatch = false ;
1822- break ;
1823- }
1824- }
1825- }
1811+ // Check if affix in this fodder does not come from some fodder with Special Ability Factor
1812+ else if ( ! fodder . affixIndicesFromFactor . includes ( k ) ) {
1813+ // If affix is not from factor, but choice is for factors, it is not a match
1814+ if ( choice . isAbilityFactor ) {
1815+ isMatch = false ;
18261816 }
18271817 else {
1828- // If affix is from factor, but choice is not for factors, it is not a match
1829- if ( ! choice . isAbilityFactor ) {
1830- isMatch = false ;
1818+ // count occurrences of each ability in choice
1819+ let choiceCount = countOccurrences ( choice . materials ) ;
1820+ // count occurrences of each ability in all abilities in page
1821+ let abilityCount = countOccurrences ( abilities ) ;
1822+ // for each different occurence in choice
1823+ for ( var code in choiceCount ) {
1824+ // if all bilities have less than count
1825+ if ( ! abilityCount [ code ] || abilityCount [ code ] < choiceCount [ code ] ) {
1826+ // does not match, so set flag false and break
1827+ isMatch = false ;
1828+ break ;
1829+ }
18311830 }
18321831 }
18331832 }
1833+ // If affix is from factor, but choice is not for factors, it is not a match
1834+ else if ( ! choice . isAbilityFactor ) {
1835+ isMatch = false ;
1836+ }
18341837 if ( isMatch ) {
18351838 // match was found, so save the success rate for affixA
18361839 abilitySuccessRates [ k ] = Math . min ( Math . max ( Math . round ( choice . transferRate ) , minRate ) , maxRate ) ;
@@ -2513,6 +2516,47 @@ class Assistant {
25132516 } ) ;
25142517 }
25152518
2519+ /**
2520+ * Gets the quantity of each extra item needed to
2521+ * achieve the goal (such as success rate boost
2522+ * items, and Add Ability Items).
2523+ *
2524+ * @returns {Object } Containing the name of each
2525+ * item needed in its keys, and each respective
2526+ * quantity in its values.
2527+ */
2528+ getExtraItemCart ( ) {
2529+ let fodders = ASSISTANT . query ( {
2530+ dataClass : Fodder
2531+ } ) ;
2532+ let result = { } ;
2533+ fodders . forEach ( fodder => {
2534+ let i = fodder . rateBoostIdx ;
2535+ if ( i > 0 && i < Assistant . rateBoostOptions . length ) {
2536+ let name = Assistant . rateBoostOptions [ fodder . rateBoostIdx ] . id ;
2537+ if ( result [ name ] ) {
2538+ result [ name ] += 1 ;
2539+ } else {
2540+ result [ name ] = 1 ;
2541+ }
2542+ }
2543+ } ) ;
2544+ fodders . forEach ( fodder => {
2545+ if ( fodder . addAbilityItemInUse !== undefined
2546+ && fodder . addAbilityItemInUse !== null
2547+ && fodder . addAbilityItemInUse . name !== undefined
2548+ && fodder . addAbilityItemInUse . name !== null ) {
2549+ let name = fodder . addAbilityItemInUse . name ;
2550+ if ( result [ name ] ) {
2551+ result [ name ] += 1 ;
2552+ } else {
2553+ result [ name ] = 1 ;
2554+ }
2555+ }
2556+ } ) ;
2557+ return result ;
2558+ }
2559+
25162560 /**
25172561 * Gets the total transplant cost to complete the affixing formula.
25182562 * @returns {Number } The cost.
@@ -2524,6 +2568,7 @@ class Assistant {
25242568 transplantable : true
25252569 }
25262570 } ) ;
2571+ if ( transpPages . length === 0 ) return 0 ;
25272572 return transpPages . map ( a => a . transplantCost ) . reduce ( ( tot , a ) => a > 0 ? tot + a : tot ) ;
25282573 }
25292574
0 commit comments