Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getInterpolateObject for relics and light cones #2563

Merged
merged 3 commits into from
Dec 6, 2024
Merged

Conversation

nguyentvan7
Copy link
Collaborator

@nguyentvan7 nguyentvan7 commented Dec 5, 2024

Describe your changes

  • Add getRelicInterpolateObject and getLightConeInterpolateObject for their respective passives
  • Split sr-stats index.ts into char/relic/lightCone file for easier viewing

KNOWN ISSUE: Light cone interpolation looks at the current char's light cone superimpose for all light cone description interpolations, which isn't always correct.

Issue or discord link

Testing/validation

image
image

Checklist before requesting a review (leave this PR as draft if any part of this list is not done.)

  • I have commented my code in hard-to understand areas.
  • I have made corresponding changes to README or wiki.
  • For front-end changes, I have updated the corresponding English translations.
  • I have run yarn run mini-ci locally to validate format and lint.
  • If I have added a new library or app, I have updated the deployment scripts to ignore changes as needed

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced document evaluation with dynamic tag integration in text sections.
    • Improved interpolation for character abilities and relic effects.
    • Dynamic content generation for light cone descriptions based on ownership.
    • New functions for managing light cone and relic statistics.
  • Bug Fixes

    • Resolved issues with static text fields in relic and light cone displays.
  • Documentation

    • Clarified usage of new functions for character, light cone, and relic statistics.
  • Refactor

    • Restructured exports for better modularity in handling character-related data.

@nguyentvan7 nguyentvan7 requested a review from frzyc December 5, 2024 04:06
Copy link
Contributor

coderabbitai bot commented Dec 5, 2024

Walkthrough

The pull request introduces several enhancements across multiple files, focusing on improving the functionality of document displays and character statistics in a gaming context. Key modifications include the integration of a new TagContext in the DocumentDisplay.tsx for evaluating text documents, updates to interpolation functions in character sheets, and the introduction of new functions for managing light cone and relic statistics. Additionally, several functions related to character stats have been removed from the index.ts file, indicating a restructuring of how character-related data is handled.

Changes

File Path Change Summary
libs/pando/ui-sheet/src/components/DocumentDisplay.tsx Added TagContext to TextSectionDisplay, modifying text document evaluation logic.
libs/sr/formula-ui/src/char/sheets/RuanMei.tsx Replaced getInterpolateObject with getCharInterpolateObject for ability descriptions.
libs/sr/formula-ui/src/lightCone/sheets/PastSelfInMirror.tsx Updated light cone properties calculation to use getLightConeInterpolateObject.
libs/sr/formula-ui/src/relic/cavern/WatchmakerMasterOfDreamMachinations.tsx Introduced getRelicInterpolateObject for dynamic relic effect interpolation.
libs/sr/stats/src/char.ts Added multiple functions for character stats and skill interactions.
libs/sr/stats/src/index.ts Removed several character stat functions; re-exported from char, lightCone, and relic.
libs/sr/stats/src/lightCone.ts Added functions for retrieving light cone statistics and creating interpolation objects.
libs/sr/stats/src/relic.ts Added functions for retrieving relic statistics and creating interpolation objects.

Assessment against linked issues

Objective Addressed Explanation
Implement getInterpolateObject for relic localization (2542)

Possibly related PRs

Suggested labels

SRO

Suggested reviewers

  • frzyc
  • tiffanynwyeung

Poem

In the meadow, hopping with glee,
New tags and contexts, oh what a spree!
With relics and cones, our stats now align,
Dynamic and bright, like a fresh morning shine.
Let's celebrate changes, both big and small,
For in this code garden, we flourish for all! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

github-actions bot commented Dec 5, 2024

[sr-frontend] [Thu Dec 5 04:09:59 UTC 2024] - Deployed 67b37b5 to https://genshin-optimizer-prs.github.io/pr/2563/sr-frontend (Takes 3-5 minutes after this completes to be available)

[sr-frontend] [Fri Dec 6 01:24:32 UTC 2024] - Deployed 5556390 to https://genshin-optimizer-prs.github.io/pr/2563/sr-frontend (Takes 3-5 minutes after this completes to be available)

[Fri Dec 6 02:15:45 UTC 2024] - Deleted deployment

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (7)
libs/sr/formula-ui/src/lightCone/sheets/PastSelfInMirror.tsx (2)

33-33: Consider adding error handling for compute()

The compute() call might return undefined values. Consider adding error handling or providing a default value.

-calc.compute(own.lightCone.superimpose).val
+calc.compute(own.lightCone.superimpose)?.val ?? 0

Line range hint 48-48: Address TODO comments

There are two TODO comments that need attention:

  1. Translation needed for "Duration"
  2. Conditional display logic for skill point recovery based on brEffect_ threshold

Would you like me to help implement these TODOs or create GitHub issues to track them?

Also applies to: 57-57

libs/sr/stats/src/char.ts (1)

53-68: Improve error messages in getCharStatBoostStat.

Include bonusStats in the error messages for better debugging context.

For example:

- throw new Error(`No stat boost levels found for character ${ck}`)
+ throw new Error(`No stat boost levels found for character ${ck} and bonusStats ${bonusStats}`)
libs/sr/formula-ui/src/char/sheets/RuanMei.tsx (4)

Line range hint 82-95: Address TODO comments for translations

Several TODO comments indicate missing translations in the skill section:

  • "skill active" text
  • "Ally DMG Increase" title
  • "Duration" translation

Would you like me to help create a tracking issue for these missing translations?


Line range hint 146-156: Address critical TODO items in ultimate ability section

Several TODO comments indicate missing functionality:

  • Action delay percentage for Thanatoplum Rebloom trigger
  • Damage multiplier increase from e6
  • Zone duration increase from e6

These TODOs appear to be feature-related rather than just translations and might affect gameplay calculations.

Would you like me to help create detailed issues for tracking these missing features?


Line range hint 193-220: Refactor temporary visualization code

The comment "TODO: Move this to proper document" suggests this is temporary code. Consider:

  1. Moving these fields to their proper location
  2. Creating a separate component if needed
  3. Documenting the intended final structure

Would you like assistance in designing the proper structure for this visualization?


Line range hint 235-238: Standardize translation keys for stats and effects

Several TODO comments indicate missing translations for stats and effects:

  • "Ignore DEF" in Eidolon 1
  • "talent" and "ult" in Eidolon 3
  • "basic" and "skill" in Eidolon 5

Consider creating a standardized set of translation keys for these common game terms.

Would you like assistance in creating a standardized translation key structure?

Also applies to: 276-286, 333-344

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4bf2c38 and a107293.

📒 Files selected for processing (8)
  • libs/pando/ui-sheet/src/components/DocumentDisplay.tsx (2 hunks)
  • libs/sr/formula-ui/src/char/sheets/RuanMei.tsx (11 hunks)
  • libs/sr/formula-ui/src/lightCone/sheets/PastSelfInMirror.tsx (2 hunks)
  • libs/sr/formula-ui/src/relic/cavern/WatchmakerMasterOfDreamMachinations.tsx (2 hunks)
  • libs/sr/stats/src/char.ts (1 hunks)
  • libs/sr/stats/src/index.ts (1 hunks)
  • libs/sr/stats/src/lightCone.ts (1 hunks)
  • libs/sr/stats/src/relic.ts (1 hunks)
🔇 Additional comments (20)
libs/pando/ui-sheet/src/components/DocumentDisplay.tsx (2)

8-8: LGTM: Clean import addition

The addition of TagContext import is well-placed and necessary for the new tag-based evaluation functionality.


69-71: Verify tag handling in calculator context

The integration of TagContext looks good, but let's ensure proper handling of edge cases.

Let's verify the calculator's withTag implementation and tag handling:

Consider adding tag validation to handle undefined cases:

  const calculator = useContext(CalcContext)
  const tag = useContext(TagContext)
  if (!calculator) return null
+ if (!tag) return null  // Or provide a default behavior
  return <div>{evalIfFunc(textDocument.text, calculator.withTag(tag))}</div>
libs/sr/formula-ui/src/lightCone/sheets/PastSelfInMirror.tsx (2)

5-9: LGTM: Import changes align with PR objectives

The addition of own and getLightConeInterpolateObject imports supports the new interpolation functionality for light cones as described in the PR objectives.


28-35: Verify interpolation accuracy for all light cones

As mentioned in the PR objectives, there's a known issue where the light cone interpolation references the current character's light cone for all descriptions. This implementation might need adjustment to handle different light cones correctly.

Let's verify the interpolation behavior:

libs/sr/stats/src/index.ts (1)

12-14: LGTM!

The exports are correctly re-exported from the respective modules.

libs/sr/stats/src/lightCone.ts (2)

4-6: LGTM!

The function getLightConeStat correctly retrieves light cone stats.


14-23: Ensure valid indices in getLightConeInterpolateObject.

To prevent potential runtime errors, consider adding checks to ensure that superimpose is within the valid range of the superimposeParams array.

If superimpose can be outside the bounds of superimposeParams, you might want to add validation or default values.

libs/sr/stats/src/relic.ts (2)

4-6: LGTM!

The function getRelicStat correctly retrieves relic stats.


14-21: Ensure valid indices in getRelicInterpolateObject.

To prevent potential runtime errors, consider adding checks to ensure that setEffects[setEffectIndex] exists before accessing it.

Ensure that numRequired corresponds to valid indices in the setEffects array.

libs/sr/formula-ui/src/relic/cavern/WatchmakerMasterOfDreamMachinations.tsx (3)

6-9: LGTM!

The import statements correctly include the necessary functions.


28-28: LGTM!

The getRelicInterpolateObject function is correctly used to interpolate 2-Set effects.


47-47: LGTM!

The getRelicInterpolateObject function is correctly used to interpolate 4-Set effects.

libs/sr/stats/src/char.ts (1)

5-7: LGTM!

The function getCharStat correctly retrieves character stats.

libs/sr/formula-ui/src/char/sheets/RuanMei.tsx (7)

11-14: LGTM! Import changes align with architecture refactoring

The change from getInterpolateObject to getCharInterpolateObject is consistent with the PR's objective to split interpolation functions for better organization.


41-44: LGTM! Basic ability interpolation properly configured

The interpolation for basic ability description is correctly implemented with appropriate parameters (character key, ability type, and calculator value).


73-76: LGTM! Skill ability interpolation properly configured

The interpolation for skill ability description is correctly implemented with appropriate parameters.


122-125: LGTM! Ultimate ability interpolation properly configured

The interpolation for ultimate ability description is correctly implemented with appropriate parameters.


177-180: LGTM! Talent ability interpolation properly configured

The interpolation for talent ability description is correctly implemented with appropriate parameters.


228-228: LGTM! Eidolon interpolations consistently implemented

The interpolation changes are consistently applied across all six eidolons with the correct parameters (character key, 'eidolon', eidolon number).

Also applies to: 249-249, 269-269, 295-295, 324-324, 350-350


Line range hint 1-354: Verify completeness of interpolation changes

Let's verify that all text interpolations have been updated to use the new getCharInterpolateObject:

✅ Verification successful

Let me try another verification script with a different approach:


All interpolation calls are properly using the new getCharInterpolateObject

The verification shows:

  • No instances of old getInterpolateObject found
  • All calculator-based text interpolations (text: (calculator) =>) use getCharInterpolateObject
  • All description texts (ranks.*.desc) use getCharInterpolateObject
  • Other chg() calls are for simple string lookups that don't require interpolation
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of old interpolation function
# and verify all text interpolations use the new function

# Check for any remaining usage of old interpolation function
rg "getInterpolateObject(?!Char)" "libs/sr/formula-ui/src/char/sheets/RuanMei.tsx"

# Verify all chg calls with desc are using the new function
rg "chg\([^)]*desc" "libs/sr/formula-ui/src/char/sheets/RuanMei.tsx"

Length of output: 883


Script:

#!/bin/bash
# Search for all text interpolation patterns in the file
rg -A 1 "text: \(calculator\) =>" "libs/sr/formula-ui/src/char/sheets/RuanMei.tsx"

# Search for any remaining getInterpolateObject using pcre2
rg --pcre2 "getInterpolateObject(?!Char)" "libs/sr/formula-ui/src/char/sheets/RuanMei.tsx"

# Search for all chg function calls
rg "chg\(" "libs/sr/formula-ui/src/char/sheets/RuanMei.tsx"

Length of output: 1565

libs/sr/stats/src/char.ts Show resolved Hide resolved
const sheet: UISheetElement = {
title: chg('passive.name'),
img: icon,
documents: [
{
type: 'text',
text: chg('passive.description'), // TODO: getInterpolateObject for lightcone
text: (calc) =>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (2)
libs/sr/formula-ui/src/lightCone/sheets/PastSelfInMirror.tsx (1)

Line range hint 62-62: Address TODO comments in the code.

There are two TODO items that need attention:

  1. Translation needed for "Duration"
  2. Conditional logic for showing "Skill Point recovered" based on brEffect_ threshold

Would you like me to help implement these TODOs or create GitHub issues to track them?

Also applies to: 71-71

libs/sr/stats/src/char.ts (1)

76-77: Handle cases where stat boost data may be undefined in getCharStatBoost.

The function assumes that skillTree['statBoost' + bonusStats] exists. If it does not, undefined is returned, which may lead to errors in calling functions.

Consider adding a check or default value to handle undefined cases.

Apply this diff to add validation:

 export function getCharStatBoost(
   ck: CharacterGenderedKey,
   bonusStats: StatBoostKey | `${StatBoostKey}`
 ) {
   const { skillTree } = getCharStat(ck)
+  const statBoost = skillTree[`statBoost${bonusStats}`]
+  if (!statBoost) {
+    throw new Error(`No stat boost found for character ${ck} with bonusStat ${bonusStats}`)
+  }
-  return skillTree[`statBoost${bonusStats}`]
+  return statBoost
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a107293 and 4514522.

📒 Files selected for processing (2)
  • libs/sr/formula-ui/src/lightCone/sheets/PastSelfInMirror.tsx (2 hunks)
  • libs/sr/stats/src/char.ts (1 hunks)
🔇 Additional comments (5)
libs/sr/formula-ui/src/lightCone/sheets/PastSelfInMirror.tsx (3)

6-9: LGTM! Import changes align with PR objectives.

The addition of getLightConeInterpolateObject import supports the new interpolation functionality for light cones.


28-37: Correctly implemented SuperImposeWrapper as suggested.

The implementation follows the recommended approach using SuperImposeWrapper from the light cone utilities.


31-34: Verify interpolation accuracy for different light cones.

As mentioned in the PR objectives, there's a known issue where light cone interpolation references the superimpose of the current character's light cone for all descriptions. This could lead to inaccurate descriptions.

Let's verify the interpolation behavior:

libs/sr/stats/src/char.ts (2)

8-10: Function getCharStat looks good.

The implementation correctly retrieves character statistics.


20-40: Add validation in getCharInterpolateObject to prevent runtime errors.

Consider adding checks to ensure that the accessed properties exist before using them:

  • For 'eidolon', verify that allStats.char[ck].rankMap[skLevel as Rank] exists before accessing .params.
  • For other skTypes, verify that allStats.char[ck].skillTree[skType].skillParamList[skIndex] exists before accessing it.

This will prevent potential runtime errors when invalid skLevel or skIndex values are passed.

Comment on lines +42 to +47
export function getCharStatBoostStatKey(
ck: CharacterGenderedKey,
bonusStats: StatBoostKey | `${StatBoostKey}`
) {
return getCharStatBoostStat(ck, bonusStats).statKey
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Ensure getCharStatBoostStatKey handles undefined boost data gracefully.

If getCharStatBoostStat returns undefined, accessing .statKey will cause a runtime error.

Consider adding a check to handle cases where getCharStatBoostStat may be undefined.

Apply this diff to add validation:

 export function getCharStatBoostStatKey(
   ck: CharacterGenderedKey,
   bonusStats: StatBoostKey | `${StatBoostKey}`
 ) {
+  const statBoost = getCharStatBoostStat(ck, bonusStats)
+  if (!statBoost) {
+    throw new Error(`No stat boost found for character ${ck}`)
+  }
-  return getCharStatBoostStat(ck, bonusStats).statKey
+  return statBoost.statKey
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function getCharStatBoostStatKey(
ck: CharacterGenderedKey,
bonusStats: StatBoostKey | `${StatBoostKey}`
) {
return getCharStatBoostStat(ck, bonusStats).statKey
}
export function getCharStatBoostStatKey(
ck: CharacterGenderedKey,
bonusStats: StatBoostKey | `${StatBoostKey}`
) {
const statBoost = getCharStatBoostStat(ck, bonusStats)
if (!statBoost) {
throw new Error(`No stat boost found for character ${ck}`)
}
return statBoost.statKey
}

Comment on lines +49 to +54
export function getCharStatBoostStatValue(
ck: CharacterGenderedKey,
bonusStats: StatBoostKey | `${StatBoostKey}`
) {
return getCharStatBoostStat(ck, bonusStats).value
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Ensure getCharStatBoostStatValue handles undefined boost data gracefully.

Similar to the previous function, if getCharStatBoostStat returns undefined, accessing .value will cause a runtime error.

Consider adding a check to handle cases where getCharStatBoostStat may be undefined.

Apply this diff to add validation:

 export function getCharStatBoostStatValue(
   ck: CharacterGenderedKey,
   bonusStats: StatBoostKey | `${StatBoostKey}`
 ) {
+  const statBoost = getCharStatBoostStat(ck, bonusStats)
+  if (!statBoost) {
+    throw new Error(`No stat boost found for character ${ck}`)
+  }
-  return getCharStatBoostStat(ck, bonusStats).value
+  return statBoost.value
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function getCharStatBoostStatValue(
ck: CharacterGenderedKey,
bonusStats: StatBoostKey | `${StatBoostKey}`
) {
return getCharStatBoostStat(ck, bonusStats).value
}
export function getCharStatBoostStatValue(
ck: CharacterGenderedKey,
bonusStats: StatBoostKey | `${StatBoostKey}`
) {
const statBoost = getCharStatBoostStat(ck, bonusStats)
if (!statBoost) {
throw new Error(`No stat boost found for character ${ck}`)
}
return statBoost.value
}

Comment on lines +56 to +71
export function getCharStatBoostStat(
ck: CharacterGenderedKey,
bonusStats: StatBoostKey | `${StatBoostKey}`
) {
const boost = getCharStatBoost(ck, bonusStats)
const levels = boost.levels
if (!levels?.length) {
throw new Error(`No stat boost levels found for character ${ck}`)
}
const entries = Object.entries(levels[0].stats ?? {})
if (!entries.length) {
throw new Error(`No stats found in stat boost for character ${ck}`)
}
const [statKey, value] = entries[0]
return { statKey, value }
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add null checks in getCharStatBoostStat to prevent runtime errors.

The function assumes that boost and levels[0] are defined. If getCharStatBoost returns undefined, or if levels is empty, accessing properties will cause runtime errors.

Consider adding checks to ensure boost, levels, and entries exist before accessing them.

Apply this diff to add validation:

 export function getCharStatBoostStat(
   ck: CharacterGenderedKey,
   bonusStats: StatBoostKey | `${StatBoostKey}`
 ) {
   const boost = getCharStatBoost(ck, bonusStats)
+  if (!boost) {
+    throw new Error(`No stat boost found for character ${ck}`)
+  }
   const levels = boost.levels
   if (!levels?.length) {
     throw new Error(`No stat boost levels found for character ${ck}`)
   }
   const entries = Object.entries(levels[0].stats ?? {})
   if (!entries.length) {
     throw new Error(`No stats found in stat boost for character ${ck}`)
   }
   const [statKey, value] = entries[0]
   return { statKey, value }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function getCharStatBoostStat(
ck: CharacterGenderedKey,
bonusStats: StatBoostKey | `${StatBoostKey}`
) {
const boost = getCharStatBoost(ck, bonusStats)
const levels = boost.levels
if (!levels?.length) {
throw new Error(`No stat boost levels found for character ${ck}`)
}
const entries = Object.entries(levels[0].stats ?? {})
if (!entries.length) {
throw new Error(`No stats found in stat boost for character ${ck}`)
}
const [statKey, value] = entries[0]
return { statKey, value }
}
export function getCharStatBoostStat(
ck: CharacterGenderedKey,
bonusStats: StatBoostKey | `${StatBoostKey}`
) {
const boost = getCharStatBoost(ck, bonusStats)
if (!boost) {
throw new Error(`No stat boost found for character ${ck}`)
}
const levels = boost.levels
if (!levels?.length) {
throw new Error(`No stat boost levels found for character ${ck}`)
}
const entries = Object.entries(levels[0].stats ?? {})
if (!entries.length) {
throw new Error(`No stats found in stat boost for character ${ck}`)
}
const [statKey, value] = entries[0]
return { statKey, value }
}

@frzyc frzyc merged commit 9d567aa into master Dec 6, 2024
9 checks passed
@frzyc frzyc deleted the van/sro/moreInterp branch December 6, 2024 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getInterpolateObject for relics localization from datamaine
2 participants