@ianlucas/cs2-lib 5.7.2 → 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/economy.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CS2RarityColorValues } from "./economy-container.js";
1
+ import { CS2RarityColorValues, CS2_RARITY_ORDER } from "./economy-container.js";
2
2
  import { CS2ContainerTypeValues, CS2Item, CS2ItemLocalization, CS2ItemLocalizationMap, CS2ItemTeamValues, CS2ItemTypeValues, CS2ItemWearValues, CS2UnlockedItem } from "./economy-types.js";
3
3
  import { CS2TeamValues } from "./teams.js";
4
4
  import { Interface } from "./utils.js";
@@ -144,7 +144,9 @@ export declare class CS2EconomyItem implements Interface<Omit<CS2Item, "contents
144
144
  getMaximumWear(): number;
145
145
  groupContents(): Record<string, CS2EconomyItem[]>;
146
146
  listContents(hideSpecials?: boolean): CS2EconomyItem[];
147
- unlockContainer(): CS2UnlockedItem;
147
+ unlockContainer(options?: {
148
+ computeOdds?: (rarities: (typeof CS2_RARITY_ORDER)[number][]) => number[] | undefined;
149
+ }): CS2UnlockedItem;
148
150
  }
149
151
  export declare const CS2Economy: CS2EconomyInstance;
150
152
  export {};
package/dist/economy.js CHANGED
@@ -473,12 +473,12 @@ export class CS2EconomyItem {
473
473
  (CS2RarityColorOrder[b.rarity] ?? CS2_RARITY_COLOR_DEFAULT));
474
474
  });
475
475
  }
476
- unlockContainer() {
476
+ unlockContainer(options) {
477
477
  // @see https://www.csgo.com.cn/news/gamebroad/20170911/206155.shtml
478
478
  const contents = this.groupContents();
479
479
  const keys = Object.keys(contents);
480
480
  const rarities = CS2_RARITY_ORDER.filter((rarity) => keys.includes(rarity));
481
- const odds = rarities.map((_, index) => CS2_BASE_ODD / Math.pow(5, index));
481
+ const odds = options?.computeOdds?.(rarities) ?? rarities.map((_, index) => CS2_BASE_ODD / Math.pow(5, index));
482
482
  const total = odds.reduce((acc, cur) => acc + cur, 0);
483
483
  const entries = rarities.map((rarity, index) => [rarity, odds[index] / total]);
484
484
  const roll = Math.random();
package/package.json CHANGED
@@ -39,5 +39,5 @@
39
39
  "typescript": "^5.6.3",
40
40
  "vitest": "^2.1.2"
41
41
  },
42
- "version": "5.7.2"
42
+ "version": "5.8.0"
43
43
  }