Skip to content

Commit

Permalink
Merge pull request #94 from project-fika/spt-typing
Browse files Browse the repository at this point in the history
Updated to apply new SPT typing
  • Loading branch information
ArchangelWTF authored Dec 6, 2024
2 parents b0ab535 + e39c098 commit 75aa44a
Show file tree
Hide file tree
Showing 37 changed files with 461 additions and 175 deletions.
2 changes: 0 additions & 2 deletions types/callbacks/DataCallbacks.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { IHandbookBase } from "@spt/models/eft/common/tables/IHandbookBase";
import { IGetItemPricesResponse } from "@spt/models/eft/game/IGetItemPricesResponse";
import { IHideoutArea } from "@spt/models/eft/hideout/IHideoutArea";
import { IHideoutProductionData } from "@spt/models/eft/hideout/IHideoutProduction";
import { IHideoutScavCase } from "@spt/models/eft/hideout/IHideoutScavCase";
import { IHideoutSettingsBase } from "@spt/models/eft/hideout/IHideoutSettingsBase";
import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData";
import { ISettingsBase } from "@spt/models/spt/server/ISettingsBase";
Expand Down Expand Up @@ -63,7 +62,6 @@ export declare class DataCallbacks {
getHideoutSettings(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<IHideoutSettingsBase>;
getHideoutAreas(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<IHideoutArea[]>;
getHideoutProduction(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<IHideoutProductionData>;
getHideoutScavcase(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<IHideoutScavCase[]>;
/**
* Handle client/languages
*/
Expand Down
7 changes: 6 additions & 1 deletion types/callbacks/MatchCallbacks.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ export declare class MatchCallbacks {
updatePing(url: string, info: IUpdatePingRequestData, sessionID: string): INullResponseData;
exitMatch(url: string, info: IEmptyRequestData, sessionID: string): INullResponseData;
/** Handle client/match/group/exit_from_menu */
exitToMenu(url: string, info: IEmptyRequestData, sessionID: string): INullResponseData;
exitFromMenu(url: string, info: IEmptyRequestData, sessionID: string): INullResponseData;
/** Handle client/match/group/current */
groupCurrent(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<IMatchGroupCurrentResponse>;
/** Handle client/match/group/looking/start */
startGroupSearch(url: string, info: IEmptyRequestData, sessionID: string): INullResponseData;
/** Handle client/match/group/looking/stop */
stopGroupSearch(url: string, info: IEmptyRequestData, sessionID: string): INullResponseData;
/** Handle client/match/group/invite/send */
sendGroupInvite(url: string, info: IMatchGroupInviteSendRequest, sessionID: string): IGetBodyResponseData<string>;
Expand All @@ -48,7 +51,9 @@ export declare class MatchCallbacks {
transferGroup(url: string, info: IMatchGroupTransferRequest, sessionId: string): IGetBodyResponseData<boolean>;
/** Handle client/match/group/invite/cancel-all */
cancelAllGroupInvite(url: string, info: IEmptyRequestData, sessionId: string): IGetBodyResponseData<boolean>;
/** Handle client/putMetrics */
putMetrics(url: string, request: IPutMetricsRequestData, sessionId: string): INullResponseData;
/** Handle client/analytics/event-disconnect */
eventDisconnect(url: string, request: IPutMetricsRequestData, sessionId: string): INullResponseData;
serverAvailable(url: string, info: IEmptyRequestData, sessionId: string): IGetBodyResponseData<boolean>;
/** Handle match/group/start_game */
Expand Down
2 changes: 1 addition & 1 deletion types/controllers/HideoutController.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export declare class HideoutController {
protected circleOfCultistService: CircleOfCultistService;
protected cloner: ICloner;
/** Key used in TaskConditionCounters array */
protected static nameTaskConditionCountersCrafting: string;
protected static nameTaskConditionCountersCraftingId: string;
protected hideoutConfig: IHideoutConfig;
constructor(logger: ILogger, hashUtil: HashUtil, timeUtil: TimeUtil, databaseService: DatabaseService, randomUtil: RandomUtil, inventoryHelper: InventoryHelper, itemHelper: ItemHelper, saveServer: SaveServer, playerService: PlayerService, presetHelper: PresetHelper, paymentHelper: PaymentHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, profileHelper: ProfileHelper, hideoutHelper: HideoutHelper, scavCaseRewardGenerator: ScavCaseRewardGenerator, localisationService: LocalisationService, profileActivityService: ProfileActivityService, configServer: ConfigServer, fenceService: FenceService, circleOfCultistService: CircleOfCultistService, cloner: ICloner);
/**
Expand Down
3 changes: 3 additions & 0 deletions types/controllers/ProfileController.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ export declare class ProfileController {
* Handle client/profile/status
*/
getProfileStatus(sessionId: string): IGetProfileStatusResponseData;
/**
* Handle client/profile/view
*/
getOtherProfile(sessionId: string, request: IGetOtherProfileRequest): IGetOtherProfileResponse;
/**
* Handle client/profile/settings
Expand Down
5 changes: 0 additions & 5 deletions types/controllers/WeatherController.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ export declare class WeatherController {
constructor(weatherGenerator: WeatherGenerator, logger: ILogger, configServer: ConfigServer, seasonalEventService: SeasonalEventService, raidWeatherService: RaidWeatherService, weatherHelper: WeatherHelper);
/** Handle client/weather */
generate(): IWeatherData;
/**
* Get the current in-raid time (MUST HAVE PLAYER LOGGED INTO CLIENT TO WORK)
* @returns Date object
*/
getCurrentInRaidTime(): Date;
/** Handle client/localGame/weather */
generateLocal(sesssionId: string): IGetLocalWeatherResponseData;
}
3 changes: 2 additions & 1 deletion types/generators/BotEquipmentModGenerator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ export declare class BotEquipmentModGenerator {
/**
* Sort mod slots into an ordering that maximises chance of a successful weapon generation
* @param unsortedSlotKeys Array of mod slot strings to sort
* @param itemTplWithKeysToSort The Tpl of the item with mod keys being sorted
* @returns Sorted array
*/
protected sortModKeys(unsortedSlotKeys: string[]): string[];
protected sortModKeys(unsortedSlotKeys: string[], itemTplWithKeysToSort: string): string[];
/**
* Get a Slot property for an item (chamber/cartridge/slot)
* @param modSlot e.g patron_in_weapon
Expand Down
4 changes: 3 additions & 1 deletion types/generators/RagfairOfferGenerator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { IBarterScheme } from "@spt/models/eft/common/tables/ITrader";
import { IOfferRequirement, IRagfairOffer, IRagfairOfferUser } from "@spt/models/eft/ragfair/IRagfairOffer";
import { IBotConfig } from "@spt/models/spt/config/IBotConfig";
import { IArmorPlateBlacklistSettings, IBarterDetails, IDynamic, IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
import { ITraderConfig } from "@spt/models/spt/config/ITraderConfig";
import { ITplWithFleaPrice } from "@spt/models/spt/ragfair/ITplWithFleaPrice";
import { ILogger } from "@spt/models/spt/utils/ILogger";
import { ConfigServer } from "@spt/servers/ConfigServer";
Expand Down Expand Up @@ -47,6 +48,7 @@ export declare class RagfairOfferGenerator {
protected configServer: ConfigServer;
protected cloner: ICloner;
protected ragfairConfig: IRagfairConfig;
protected traderConfig: ITraderConfig;
protected botConfig: IBotConfig;
protected allowedFleaPriceItemsForBarter: {
tpl: string;
Expand Down Expand Up @@ -83,7 +85,7 @@ export declare class RagfairOfferGenerator {
* @param isTrader Is the user creating the offer a trader
* @returns IRagfairOfferUser
*/
createUserDataForFleaOffer(userID: string, isTrader: boolean): IRagfairOfferUser;
protected createUserDataForFleaOffer(userID: string, isTrader: boolean): IRagfairOfferUser;
/**
* Calculate the offer price that's listed on the flea listing
* @param offerRequirements barter requirements for offer
Expand Down
6 changes: 3 additions & 3 deletions types/generators/ScavCaseRewardGenerator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ItemHelper } from "@spt/helpers/ItemHelper";
import { PresetHelper } from "@spt/helpers/PresetHelper";
import { IItem } from "@spt/models/eft/common/tables/IItem";
import { ITemplateItem } from "@spt/models/eft/common/tables/ITemplateItem";
import { IHideoutScavCase } from "@spt/models/eft/hideout/IHideoutScavCase";
import { IScavRecipe } from "@spt/models/eft/hideout/IHideoutProduction";
import { IScavCaseConfig } from "@spt/models/spt/config/IScavCaseConfig";
import { IRewardCountAndPriceDetails, IScavCaseRewardCountsAndPrices } from "@spt/models/spt/hideout/ScavCaseRewardCountsAndPrices";
import { ILogger } from "@spt/models/spt/utils/ILogger";
Expand Down Expand Up @@ -84,10 +84,10 @@ export declare class ScavCaseRewardGenerator {
protected getFilteredItemsByPrice(dbItems: ITemplateItem[], itemFilters: IRewardCountAndPriceDetails): ITemplateItem[];
/**
* Gathers the reward min and max count params for each reward quality level from config and scavcase.json into a single object
* @param scavCaseDetails scavcase.json values
* @param scavCaseDetails production.json/scavRecipes object
* @returns ScavCaseRewardCountsAndPrices object
*/
protected getScavCaseRewardCountsAndPrices(scavCaseDetails: IHideoutScavCase): IScavCaseRewardCountsAndPrices;
protected getScavCaseRewardCountsAndPrices(scavCaseDetails: IScavRecipe): IScavCaseRewardCountsAndPrices;
/**
* Randomises the size of ammo and money stacks
* @param itemToCalculate ammo or money item
Expand Down
7 changes: 0 additions & 7 deletions types/helpers/InRaidHelper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ export declare class InRaidHelper {
* @param secureContainerSlotId Container slot id to find items for and remove FiR from
*/
removeFiRStatusFromItemsInContainer(sessionId: string, pmcData: IPmcData, secureContainerSlotId: string): void;
/**
* Deletes quest conditions from pickup tasks given a list of quest items being carried by a PMC.
* @param carriedQuestItems Items carried by PMC at death, usually gotten from "CarriedQuestItems"
* @param sessionId Current sessionId
* @param pmcProfile Pre-raid profile that is being handled with raid information
*/
removePickupQuestConditions(carriedQuestItems: string[], sessionId: string, pmcProfile: IPmcData): void;
/**
* Get an array of items from a profile that will be lost on death
* @param pmcProfile Profile to get items from
Expand Down
2 changes: 1 addition & 1 deletion types/helpers/InventoryHelper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export declare class InventoryHelper {
*/
protected removeTraderRagfairRelatedUpdProperties(upd: IUpd): void;
/**
* Can all probided items be added into player inventory
* Can all provided items be added into player inventory
* @param sessionId Player id
* @param itemsWithChildren array of items with children to try and fit
* @returns True all items fit
Expand Down
13 changes: 13 additions & 0 deletions types/helpers/ProfileHelper.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { IPmcData } from "@spt/models/eft/common/IPmcData";
import { Common, ICounterKeyValue, IStats } from "@spt/models/eft/common/tables/IBotBase";
import { IItem } from "@spt/models/eft/common/tables/IItem";
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
import { BonusType } from "@spt/models/enums/BonusType";
Expand Down Expand Up @@ -202,4 +203,16 @@ export declare class ProfileHelper {
* @param newPocketTpl New tpl to set profiles Pockets to
*/
replaceProfilePocketTpl(pmcProfile: IPmcData, newPocketTpl: string): void;
/**
* Return all quest items current in the supplied profile
* @param profile Profile to get quest items from
* @returns Array of item objects
*/
getQuestItemsInProfile(profile: IPmcData): IItem[];
/**
* Return a favorites array in the format expected by the getOtherProfile call
* @param profile
* @returns An array of IItem objects representing the favorited data
*/
getOtherProfileFavorites(profile: IPmcData): IItem[];
}
24 changes: 20 additions & 4 deletions types/helpers/QuestHelper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { IPmcData } from "@spt/models/eft/common/IPmcData";
import { Common, IQuestStatus } from "@spt/models/eft/common/tables/IBotBase";
import { IItem } from "@spt/models/eft/common/tables/IItem";
import { IQuest, IQuestCondition, IQuestReward } from "@spt/models/eft/common/tables/IQuest";
import { IHideoutProduction } from "@spt/models/eft/hideout/IHideoutProduction";
import { IItemEventRouterResponse } from "@spt/models/eft/itemEvent/IItemEventRouterResponse";
import { IAcceptQuestRequestData } from "@spt/models/eft/quests/IAcceptQuestRequestData";
import { ICompleteQuestRequestData } from "@spt/models/eft/quests/ICompleteQuestRequestData";
Expand Down Expand Up @@ -113,12 +114,12 @@ export declare class QuestHelper {
*/
protected generateArmorRewardChildSlots(originalRewardRootItem: IItem, questReward: IQuestReward): void;
/**
* Gets a flat list of reward items for the given quest at a specific state (e.g. Fail/Success)
* Gets a flat list of reward items for the given quest at a specific state for the specified game version (e.g. Fail/Success)
* @param quest quest to get rewards for
* @param status Quest status that holds the items (Started, Success, Fail)
* @returns array of items with the correct maxStack
*/
getQuestRewardItems(quest: IQuest, status: QuestStatus): IItem[];
getQuestRewardItems(quest: IQuest, status: QuestStatus, gameVersion: string): IItem[];
/**
* Look up quest in db by accepted quest id and construct a profile-ready object ready to store in profile
* @param pmcData Player profile
Expand Down Expand Up @@ -280,6 +281,13 @@ export declare class QuestHelper {
* @param response Response to send back to client
*/
protected findAndAddHideoutProductionIdToProfile(pmcData: IPmcData, craftUnlockReward: IQuestReward, questDetails: IQuest, sessionID: string, response: IItemEventRouterResponse): void;
/**
* Find hideout craft for the specified quest reward
* @param craftUnlockReward Reward item from quest with craft unlock details
* @param questDetails Quest with craft unlock reward
* @returns Hideout craft
*/
getRewardProductionMatch(craftUnlockReward: IQuestReward, questDetails: IQuest): IHideoutProduction[];
/**
* Get players money reward bonus from profile
* @param pmcData player profile
Expand Down Expand Up @@ -321,10 +329,18 @@ export declare class QuestHelper {
* @returns array of IQuest
*/
getClientQuests(sessionID: string): IQuest[];
/**
* Create a clone of the given quest array with the rewards updated to reflect the
* given game version
* @param quests List of quests to check
* @param gameVersion Game version of the profile
* @returns Array of IQuest objects with the rewards filtered correctly for the game version
*/
protected updateQuestsForGameEdition(quests: IQuest[], gameVersion: string): IQuest[];
/**
* Return a list of quests that would fail when supplied quest is completed
* @param completedQuestId quest completed id
* @returns array of IQuest objects
* @param completedQuestId Quest completed id
* @returns Array of IQuest objects
*/
protected getQuestsFromProfileFailedByCompletingQuest(completedQuestId: string, pmcProfile: IPmcData): IQuest[];
/**
Expand Down
27 changes: 17 additions & 10 deletions types/helpers/RagfairOfferHelper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ export declare class RagfairOfferHelper {
* @returns Offers the player should see
*/
getValidOffers(searchRequest: ISearchRequestData, itemsToAdd: string[], traderAssorts: Record<string, ITraderAssort>, pmcData: IPmcData): IRagfairOffer[];
/**
* Disable offer if item is flagged by tiered flea config
* @param tieredFlea Tiered flea settings from ragfair config
* @param offer Ragfair offer to check
* @param tieredFleaLimitTypes Dict of item types with player level to be viewable
* @param playerLevel Level of player viewing offer
*/
protected checkAndLockOfferFromPlayerTieredFlea(tieredFlea: ITieredFlea, offer: IRagfairOffer, tieredFleaLimitTypes: string[], playerLevel: number): void;
/**
* Get matching offers that require the desired item and filter out offers from non traders if player is below ragfair unlock level
Expand Down Expand Up @@ -99,22 +106,22 @@ export declare class RagfairOfferHelper {
*/
traderOfferItemQuestLocked(offer: IRagfairOffer, traderAssorts: Record<string, ITraderAssort>): boolean;
/**
* Has a traders offer ran out of stock to sell to player
* Has trader offer ran out of stock to sell to player
* @param offer Offer to check stock of
* @returns true if out of stock
*/
protected traderOutOfStock(offer: IRagfairOffer): boolean;
/**
* Check if trader offers' BuyRestrictionMax value has been reached
* @param offer offer to check restriction properties of
* @param offer Offer to check restriction properties of
* @returns true if restriction reached, false if no restrictions/not reached
*/
protected traderBuyRestrictionReached(offer: IRagfairOffer): boolean;
/**
* Get an array of flea offers that are inaccessible to player due to their inadequate loyalty level
* @param offers Offers to check
* @param pmcProfile Players profile with trader loyalty levels
* @returns array of offer ids player cannot see
* @returns Array of offer ids player cannot see
*/
protected getLoyaltyLockedOffers(offers: IRagfairOffer[], pmcProfile: IPmcData): string[];
/**
Expand All @@ -126,7 +133,7 @@ export declare class RagfairOfferHelper {
/**
* Count up all rootitem StackObjectsCount properties of an array of items
* @param itemsInInventoryToList items to sum up
* @returns Total count
* @returns Total stack count
*/
getTotalStackCountSize(itemsInInventoryToList: IItem[][]): number;
/**
Expand Down Expand Up @@ -164,24 +171,24 @@ export declare class RagfairOfferHelper {
protected getLocalisedOfferSoldMessage(itemTpl: string, boughtAmount: number): string;
/**
* Check an offer passes the various search criteria the player requested
* @param searchRequest
* @param offer
* @param pmcData
* @returns True
* @param searchRequest Client search request
* @param offer Offer to check
* @param pmcData Player profile
* @returns True if offer passes criteria
*/
protected passesSearchFilterCriteria(searchRequest: ISearchRequestData, offer: IRagfairOffer, pmcData: IPmcData): boolean;
/**
* Check that the passed in offer item is functional
* @param offerRootItem The root item of the offer
* @param offer The flea offer
* @param offer Flea offer to check
* @returns True if the given item is functional
*/
isItemFunctional(offerRootItem: IItem, offer: IRagfairOffer): boolean;
/**
* Should a ragfair offer be visible to the player
* @param searchRequest Search request
* @param itemsToAdd ?
* @param traderAssorts Trader assort items
* @param traderAssorts Trader assort items - used for filtering out locked trader items
* @param offer The flea offer
* @param pmcProfile Player profile
* @returns True = should be shown to player
Expand Down
14 changes: 2 additions & 12 deletions types/helpers/TraderAssortHelper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ export declare class TraderAssortHelper {
* Filter out assorts not unlocked due to level OR quest completion
* @param sessionId session id
* @param traderId traders id
* @param flea Should assorts player hasn't unlocked be returned - default false
* @param showLockedAssorts Should assorts player hasn't unlocked be returned - default false
* @returns a traders' assorts
*/
getAssort(sessionId: string, traderId: string, flea?: boolean): ITraderAssort;
getAssort(sessionId: string, traderId: string, showLockedAssorts?: boolean): ITraderAssort;
/**
* Given the blacklist provided, remove root items from assort
* @param assortToFilter Trader assort to modify
Expand Down Expand Up @@ -75,20 +75,10 @@ export declare class TraderAssortHelper {
* @returns true they need refreshing
*/
traderAssortsHaveExpired(traderID: string): boolean;
/**
* Iterate over all assorts barter_scheme values, find barters selling for money and multiply by multipler in config
* @param traderAssort Assorts to multiple price of
*/
protected multiplyItemPricesByConfigMultiplier(traderAssort: ITraderAssort): void;
/**
* Get an array of pristine trader items prior to any alteration by player (as they were on server start)
* @param traderId trader id
* @returns array of Items
*/
protected getPristineTraderAssorts(traderId: string): IItem[];
/**
* Returns generated ragfair offers in a trader assort format
* @returns Trader assort object
*/
protected getRagfairDataAsTraderAssort(): ITraderAssort;
}
Loading

0 comments on commit 75aa44a

Please sign in to comment.