Fix: hotfix for difference in types between botjson skills (dict) and output (array)

This commit is contained in:
Dev 2023-03-21 15:58:08 +00:00
parent 0d5a07533d
commit 3232314dbd
2 changed files with 12 additions and 5 deletions

View File

@ -4,7 +4,7 @@ import { BotDifficultyHelper } from "../helpers/BotDifficultyHelper";
import { BotHelper } from "../helpers/BotHelper"; import { BotHelper } from "../helpers/BotHelper";
import { ProfileHelper } from "../helpers/ProfileHelper"; import { ProfileHelper } from "../helpers/ProfileHelper";
import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper"; import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper";
import { Health as PmcHealth, IBaseSkill, IBotBase, Info, Skills as botSkills } from "../models/eft/common/tables/IBotBase"; import { Health as PmcHealth, IBaseJsonSkills, IBaseSkill, IBotBase, Info, Skills as botSkills } from "../models/eft/common/tables/IBotBase";
import { Health, IBotType } from "../models/eft/common/tables/IBotType"; import { Health, IBotType } from "../models/eft/common/tables/IBotType";
import { Item, Upd } from "../models/eft/common/tables/IItem"; import { Item, Upd } from "../models/eft/common/tables/IItem";
import { BaseClasses } from "../models/enums/BaseClasses"; import { BaseClasses } from "../models/enums/BaseClasses";
@ -154,7 +154,7 @@ export class BotGenerator
bot.Info.Settings.StandingForKill = botJsonTemplate.experience.standingForKill; bot.Info.Settings.StandingForKill = botJsonTemplate.experience.standingForKill;
bot.Info.Voice = this.randomUtil.getArrayValue(botJsonTemplate.appearance.voice); bot.Info.Voice = this.randomUtil.getArrayValue(botJsonTemplate.appearance.voice);
bot.Health = this.generateHealth(botJsonTemplate.health, bot.Info.Side === "Savage"); bot.Health = this.generateHealth(botJsonTemplate.health, bot.Info.Side === "Savage");
bot.Skills = this.generateSkills(botJsonTemplate.skills); bot.Skills = this.generateSkills(<any>botJsonTemplate.skills); // TODO: fix bad type, bot jsons store skills in dict, output needs to be array
bot.Customization.Head = this.randomUtil.getArrayValue(botJsonTemplate.appearance.head); bot.Customization.Head = this.randomUtil.getArrayValue(botJsonTemplate.appearance.head);
bot.Customization.Body = this.weightedRandomHelper.getWeightedInventoryItem(botJsonTemplate.appearance.body); bot.Customization.Body = this.weightedRandomHelper.getWeightedInventoryItem(botJsonTemplate.appearance.body);
bot.Customization.Feet = this.weightedRandomHelper.getWeightedInventoryItem(botJsonTemplate.appearance.feet); bot.Customization.Feet = this.weightedRandomHelper.getWeightedInventoryItem(botJsonTemplate.appearance.feet);
@ -300,11 +300,11 @@ export class BotGenerator
* @param botSkills Skills that should have their progress value randomised * @param botSkills Skills that should have their progress value randomised
* @returns * @returns
*/ */
protected generateSkills(botSkills: botSkills): botSkills protected generateSkills(botSkills: IBaseJsonSkills): botSkills
{ {
const skillsToReturn: botSkills = { const skillsToReturn: botSkills = {
Common: this.getSkillsWithRandomisedProgressValue(botSkills.Common), Common: this.getSkillsWithRandomisedProgressValue(Object.values(botSkills.Common ?? [])),
Mastering: this.getSkillsWithRandomisedProgressValue(botSkills.Mastering), Mastering: this.getSkillsWithRandomisedProgressValue(Object.values(botSkills.Mastering ?? [])),
Points: 0 Points: 0
}; };

View File

@ -150,6 +150,13 @@ export interface Inventory
fastPanel: Record<string, string> fastPanel: Record<string, string>
} }
export interface IBaseJsonSkills
{
Common: Record<string, Common>
Mastering: Record<string, Mastering>
Points: number
}
export interface Skills export interface Skills
{ {
Common: Common[] Common: Common[]