Skip to content

Commit

Permalink
Change class generics names
Browse files Browse the repository at this point in the history
  • Loading branch information
xShadowBlade committed Jul 10, 2024
1 parent 9634ff0 commit bf112fe
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 142 deletions.
8 changes: 4 additions & 4 deletions dist/types/classes/Attribute.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ declare class Attribute {
*
* Note: This class is essentially a wrapper around {@link Boost}, and if you choose not to use boosts, you can use {@link Decimal} directly.
* It may be marked as deprecated in the future.
* @template B - Indicates whether the boost is enabled. Defaults to true.
* @template EnableBoost - Indicates whether the boost is enabled. Defaults to true.
* @example
* const health = new AttributeStatic(undefined, true, 100); // AttributeStatic<true>
* // Set a health boost that multiplies the health by 1.1
Expand All @@ -33,7 +33,7 @@ declare class Attribute {
* });
* console.log(health.value); // 110
*/
declare class AttributeStatic<B extends boolean = true> {
declare class AttributeStatic<EnableBoost extends boolean = true> {
/** The data for the attribute. */
protected readonly pointerFn: (() => Attribute);
/** @returns The data for the attribute. */
Expand All @@ -44,14 +44,14 @@ declare class AttributeStatic<B extends boolean = true> {
* The boost of the attribute.
* NOTE: This will not be used if the boost is disabled.
*/
readonly boost: B extends true ? Boost : null;
readonly boost: EnableBoost extends true ? Boost : null;
/**
* Constructs a new instance of the Attribute class.
* @param pointer - A function or an instance of the attribute class. Defaults to a new instance of the attribute class.
* @param useBoost - Indicates whether to use boost for the attribute. Defaults to true. (hint: if you don't use boost, don't use this class and use Decimal directly)
* @param initial - The initial value of the attribute. Defaults to 0.
*/
constructor(pointer?: Pointer<Attribute>, useBoost?: B, initial?: DecimalSource);
constructor(pointer?: Pointer<Attribute>, useBoost?: EnableBoost, initial?: DecimalSource);
/**
* Updates the value of the attribute.
* NOTE: This method must be called every time the boost is updated, else the value stored will not be updated.
Expand Down
24 changes: 12 additions & 12 deletions dist/types/classes/Currency.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ declare class Currency {
/**
* Represents the backend for a currency in the game.
* All the functions are here instead of the `currency` class.
* @template U - The inital upgrades
* @template S - An string union that represents the names of the upgrades.
* @template UpgradeInitArray - The inital upgrades
* @template UpgradeIds - An string union that represents the names of the upgrades.
* @example
* const currency = new CurrencyStatic();
* currency.gain();
* console.log(currency.value); // Decimal.dOne
*/
declare class CurrencyStatic<U extends Readonly<UpgradeInit>[] = [], S extends string = UpgradeInitArrayType<U>> {
declare class CurrencyStatic<UpgradeInitArray extends Readonly<UpgradeInit>[] = [], UpgradeIds extends string = UpgradeInitArrayType<UpgradeInitArray>> {
/** An array that represents upgrades */
readonly upgrades: Record<S, UpgradeStatic>;
readonly upgrades: Record<UpgradeIds, UpgradeStatic>;
/** An array that represents items and their effects. */
readonly items: Record<string, Item>;
/** A function that returns the pointer of the data */
Expand Down Expand Up @@ -82,7 +82,7 @@ declare class CurrencyStatic<U extends Readonly<UpgradeInit>[] = [], S extends s
* ] as const satisfies UpgradeInit[]);
* // CurrencyStatic<["upgId1", "upgId2"]>
*/
constructor(pointer?: Pointer<Currency>, upgrades?: U, defaults?: {
constructor(pointer?: Pointer<Currency>, upgrades?: UpgradeInitArray, defaults?: {
defaultVal: Decimal;
defaultBoost: Decimal;
});
Expand Down Expand Up @@ -131,7 +131,7 @@ declare class CurrencyStatic<U extends Readonly<UpgradeInit>[] = [], S extends s
* const upgrade = currency.getUpgrade("healthBoost");
* console.log(upgrade); // upgrade object
*/
getUpgrade<T extends S>(id: T): IsPrimitiveString<S> extends false ? UpgradeStatic : UpgradeStatic | null;
getUpgrade<T extends UpgradeIds>(id: T): IsPrimitiveString<UpgradeIds> extends false ? UpgradeStatic : UpgradeStatic | null;
/**
* Queries upgrades based on the provided id. Returns an array of upgrades that match the id.
* @param id - The id of the upgrade to query.
Expand All @@ -152,7 +152,7 @@ declare class CurrencyStatic<U extends Readonly<UpgradeInit>[] = [], S extends s
* // or
* const smallUpgrades2 = currency.queryUpgrade(/.*Small/);
*/
queryUpgrade(id: S | S[] | RegExp): UpgradeStatic[];
queryUpgrade(id: UpgradeIds | UpgradeIds[] | RegExp): UpgradeStatic[];
/**
* Creates upgrades. To update an upgrade, use {@link updateUpgrade} instead.
* @param upgrades - An array of upgrade objects.
Expand Down Expand Up @@ -194,7 +194,7 @@ declare class CurrencyStatic<U extends Readonly<UpgradeInit>[] = [], S extends s
* }
* });
*/
updateUpgrade(id: S, newUpgrade: Partial<UpgradeInit>): void;
updateUpgrade(id: UpgradeIds, newUpgrade: Partial<UpgradeInit>): void;
/**
* Runs the effect of an upgrade or item.
* @param upgrade - The upgrade to run the effect for.
Expand All @@ -218,7 +218,7 @@ declare class CurrencyStatic<U extends Readonly<UpgradeInit>[] = [], S extends s
* // Calculate how many healthBoost upgrades you can buy and the cost of the upgrades
* const [amount, cost] = currency.calculateUpgrade("healthBoost", 10);
*/
calculateUpgrade(id: S, target?: DecimalSource, mode?: MeanMode, iterations?: number): [amount: Decimal, cost: Decimal];
calculateUpgrade(id: UpgradeIds, target?: DecimalSource, mode?: MeanMode, iterations?: number): [amount: Decimal, cost: Decimal];
/**
* Calculates how much is needed for the next upgrade.
* @deprecated Use {@link getNextCostMax} instead as it is more versatile.
Expand All @@ -231,7 +231,7 @@ declare class CurrencyStatic<U extends Readonly<UpgradeInit>[] = [], S extends s
* // Calculate the cost of the next healthBoost upgrade
* const nextCost = currency.getNextCost("healthBoost");
*/
getNextCost(id: S, target?: DecimalSource, mode?: MeanMode, iterations?: number): Decimal;
getNextCost(id: UpgradeIds, target?: DecimalSource, mode?: MeanMode, iterations?: number): Decimal;
/**
* Calculates the cost of the next upgrade after the maximum affordable quantity.
* @param id - Index or ID of the upgrade
Expand All @@ -245,7 +245,7 @@ declare class CurrencyStatic<U extends Readonly<UpgradeInit>[] = [], S extends s
* console.log(currency.calculateUpgrade("healthBoost")); // The maximum affordable quantity and the cost of the upgrades. Ex. [new Decimal(100), new Decimal(1000)]
* console.log(currency.getNextCostMax("healthBoost")); // The cost of the next upgrade after the maximum affordable quantity. (The cost of the 101st upgrade)
*/
getNextCostMax(id: S, target?: DecimalSource, mode?: MeanMode, iterations?: number): Decimal;
getNextCostMax(id: UpgradeIds, target?: DecimalSource, mode?: MeanMode, iterations?: number): Decimal;
/**
* Buys an upgrade based on its ID or array position if enough currency is available.
* @param id - The ID or position of the upgrade to buy or upgrade.
Expand All @@ -257,7 +257,7 @@ declare class CurrencyStatic<U extends Readonly<UpgradeInit>[] = [], S extends s
* // Attempt to buy up to 10 healthBoost upgrades at once
* currency.buyUpgrade("healthBoost", 10);
*/
buyUpgrade(id: S, target?: DecimalSource, mode?: MeanMode, iterations?: number): boolean;
buyUpgrade(id: UpgradeIds, target?: DecimalSource, mode?: MeanMode, iterations?: number): boolean;
/**
* Adds an item to the data class.
* @param items - The items to add.
Expand Down
Loading

0 comments on commit bf112fe

Please sign in to comment.