Skip to content

Commit

Permalink
Improved ICustomization types and matching code
Browse files Browse the repository at this point in the history
Improved  `setBotAppearance` code flow
  • Loading branch information
Chomp committed Jan 8, 2025
1 parent 929efb7 commit a7a92bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
17 changes: 8 additions & 9 deletions project/src/generators/BotGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,20 +433,19 @@ export class BotGenerator {
appearance: IAppearance,
botGenerationDetails: IBotGenerationDetails,
): void {
// Choose random values by weight
bot.Customization.Head = this.weightedRandomHelper.getWeightedValue<string>(appearance.head);
bot.Customization.Body = this.weightedRandomHelper.getWeightedValue<string>(appearance.body);
bot.Customization.Feet = this.weightedRandomHelper.getWeightedValue<string>(appearance.feet);
bot.Customization.Hands = this.weightedRandomHelper.getWeightedValue<string>(appearance.hands);
bot.Customization.Body = this.weightedRandomHelper.getWeightedValue<string>(appearance.body);

const bodyGlobalDict = this.databaseService.getGlobals().config.Customization.SavageBody;
const bodyGlobalDictDb = this.databaseService.getGlobals().config.Customization.SavageBody;
const chosenBodyTemplate = this.databaseService.getCustomization()[bot.Customization.Body];

// Find the body/hands mapping
const matchingBody: IWildBody = bodyGlobalDict[chosenBodyTemplate?._name]?.[bot.Customization.Body];
if (matchingBody?.isNotRandom) {
// Has fixed hands for this body, set them
bot.Customization.Hands = matchingBody.hands;
}
// Some bodies have matching hands, look up body to see if this is the case
const chosenBody = bodyGlobalDictDb[chosenBodyTemplate?._name.trim()];
bot.Customization.Hands = chosenBody?.isNotRandom
? chosenBody.hands // Has fixed hands for chosen body, update to match
: this.weightedRandomHelper.getWeightedValue<string>(appearance.hands); // Hands can be random, choose any from weighted dict
}

/**
Expand Down
6 changes: 3 additions & 3 deletions project/src/models/eft/common/IGlobals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,9 @@ export interface IMastering {
}

export interface ICustomization {
SavageHead: Record<string, Record<string, IWildHead>>;
SavageBody: Record<string, Record<string, IWildBody>>;
SavageFeet: Record<string, Record<string, IWildFeet>>;
SavageHead: Record<string, IWildHead>;
SavageBody: Record<string, IWildBody>;
SavageFeet: Record<string, IWildFeet>;
CustomizationVoice: ICustomizationVoice[];
BodyParts: IBodyParts;
}
Expand Down

0 comments on commit a7a92bd

Please sign in to comment.