@kitten-science/kitten-scientists
Version:
Add-on for the wonderful incremental browser game: https://kittensgame.com/web/
102 lines • 5.53 kB
TypeScript
import type { KittenScientists } from "../KittenScientists.js";
import type { BonfireItem } from "../settings/BonfireSettings.js";
import type { UnsafeBuilding, UnsafeStagingBldButtonOptions, UnsafeUnstagedBuildingButtonOptions } from "../types/buildings.js";
import type { BuildingStackableBtnController, UnsafeBuildingBtnModernModel, UnsafeBuildingStackableBtnModel } from "../types/core.js";
import { type AllBuildings, type Building, type Price, type TabId, type TimeItemVariant, type UnicornItemVariant } from "../types/index.js";
import type { UnsafeReligionBtnModel, UnsafeReligionButtonOptions, UnsafeReligionUpgrade, UnsafeTranscendenceBtnModel, UnsafeTranscendenceButtonOptions, UnsafeTranscendenceUpgrade, UnsafeZigguratBtnModel, UnsafeZigguratButtonOptions, UnsafeZigguratUpgrade } from "../types/religion.js";
import type { UnsafePlanetBuildingButtonOptions, UnsafeSpaceBuilding, UnsafeSpaceProgramButtonOptions } from "../types/space.js";
import type { UnsafeChronoForgeUpgrade, UnsafeChronoforgeUpgradeButtonOptions, UnsafeVoidSpaceUpgrade, UnsafeVoidSpaceUpgradeButtonOptions } from "../types/time.js";
import type { WorkshopManager } from "../WorkshopManager.js";
export type BulkBuildListItem = {
count: number;
id: AllBuildings;
label?: string;
name?: AllBuildings;
stage?: number;
variant?: TimeItemVariant | UnicornItemVariant;
};
export type BuildRequest = {
id: AllBuildings;
limit: number;
val: number;
name: AllBuildings | null;
stage: number | null;
variant: TimeItemVariant | UnicornItemVariant | null;
};
export type ConcreteBuild = {
id: AllBuildings;
limit: number;
val: number;
count: number;
builder: (build: ConcreteBuild) => void;
name: AllBuildings | null;
stage: number | null;
variant: TimeItemVariant | UnicornItemVariant | null;
};
export declare class BulkPurchaseHelper {
private readonly _host;
private readonly _workshopManager;
private _priceCache;
cacheHits: number;
cacheMisses: number;
constructor(host: KittenScientists, workshopManager: WorkshopManager);
resetPriceCache(): void;
_getPriceForBuild(build: AllBuildings, atValue?: number): Array<Price>;
/**
* Take a hash of potential builds and determine how many of them can be built.
*
* @param builds - All potential builds.
* @param metaData - The metadata for the potential builds.
* @param sectionTrigger - The configured trigger threshold for the section of these builds.
* @param sourceTab - The tab these builds originate from.
* @returns All the possible builds.
*/
bulk(builds: Partial<Record<AllBuildings, {
enabled: boolean;
label?: string;
max: number;
baseBuilding?: Building;
building?: AllBuildings | BonfireItem;
stage?: number;
trigger: number;
sectionTrigger: number;
variant?: TimeItemVariant | UnicornItemVariant;
builder: (build: ConcreteBuild) => void;
}>>, metaData: Partial<Record<AllBuildings, Required<UnsafeBuilding | UnsafeChronoForgeUpgrade | UnsafeReligionUpgrade | UnsafeSpaceBuilding | UnsafeTranscendenceUpgrade | UnsafeVoidSpaceUpgrade | UnsafeZigguratUpgrade>>>): Array<ConcreteBuild>;
/**
* Calculate how many of a given build item build be built with the given resources.
*
* @param buildCacheItem The item to build.
* @param metaData The metadata for the potential builds.
* @param resources The currently available resources.
* @returns The number of items that could be built, and the amount of resources that would be left, after buying them.
*/
private _precalculateBuilds;
/**
* Try to trigger the build for a given button.
*
* @param model The model associated with the button.
* @param button The build button.
* @param amount How many items to build.
* @returns How many items were built.
*/
construct<TModel extends UnsafeBuildingBtnModernModel<UnsafeStagingBldButtonOptions> | UnsafeBuildingBtnModernModel<UnsafeUnstagedBuildingButtonOptions> | UnsafeBuildingStackableBtnModel<UnsafeChronoforgeUpgradeButtonOptions> | UnsafeBuildingStackableBtnModel<UnsafePlanetBuildingButtonOptions> | UnsafeBuildingStackableBtnModel<UnsafeSpaceProgramButtonOptions> | UnsafeBuildingStackableBtnModel<UnsafeVoidSpaceUpgradeButtonOptions> | UnsafeReligionBtnModel<UnsafeReligionButtonOptions> | UnsafeTranscendenceBtnModel<UnsafeTranscendenceButtonOptions> | UnsafeZigguratBtnModel<UnsafeZigguratButtonOptions>, TController extends BuildingStackableBtnController<TModel>>(model: TModel, controller: TController, amount: number): number;
private _isStagedBuild;
/**
* Determine the price modifier for the given building.
*
* @param data The building metadata.
* @param source The tab the building belongs to.
* @returns The price modifier for this building.
* @see `getPriceRatioWithAccessor`@`buildings.js`
*/
getPriceRatio(data: UnsafeBuilding | UnsafeChronoForgeUpgrade | UnsafeReligionUpgrade | UnsafeSpaceBuilding | UnsafeTranscendenceUpgrade | UnsafeVoidSpaceUpgrade | UnsafeZigguratUpgrade, source?: TabId): number;
/**
* Check if a given build could be performed.
*
* @param build The build that should be checked.
* @returns `true` if the build is possible; `false` otherwise.
*/
singleBuildPossible(build: AllBuildings): boolean;
}
//# sourceMappingURL=BulkPurchaseHelper.d.ts.map