farming-weight 0.1.0 → 0.1.2

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.
@@ -17,3 +17,4 @@ export interface CropInfo {
17
17
  drops: number;
18
18
  }
19
19
  export declare const CROP_INFO: Record<Crop, CropInfo>;
20
+ export declare const MAX_CROP_FORTUNE: Record<Crop, number>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CROP_INFO = exports.Crop = void 0;
3
+ exports.MAX_CROP_FORTUNE = exports.CROP_INFO = exports.Crop = void 0;
4
4
  var Crop;
5
5
  (function (Crop) {
6
6
  Crop["Cactus"] = "CACTUS";
@@ -72,3 +72,17 @@ exports.CROP_INFO = {
72
72
  drops: 1.5,
73
73
  },
74
74
  };
75
+ // TODO: Calculate this from a list of sources
76
+ exports.MAX_CROP_FORTUNE = {
77
+ [Crop.Cactus]: 1575,
78
+ [Crop.Carrot]: 1784,
79
+ [Crop.CocoaBeans]: 1584,
80
+ [Crop.Melon]: 1567.8,
81
+ [Crop.Mushroom]: 1603,
82
+ [Crop.NetherWart]: 1772,
83
+ [Crop.Potato]: 1772,
84
+ [Crop.Pumpkin]: 1567.5,
85
+ [Crop.SugarCane]: 1772,
86
+ [Crop.Wheat]: 1772,
87
+ [Crop.Seeds]: 1772, // Not a crop, same as wheat
88
+ };
@@ -1 +1 @@
1
- export declare function MelonPerkBonus(level: 1 | 2 | 3): number;
1
+ export declare function MelonPerkBonus(blocksBroken: number, level?: 3): number;
@@ -1,7 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MelonPerkBonus = void 0;
4
- function MelonPerkBonus(level) {
5
- return 0.05 * level;
4
+ const MELON_DICER_ROLLEM = {
5
+ 3: [
6
+ {
7
+ drops: 640,
8
+ chance: 155 / 100208,
9
+ },
10
+ {
11
+ drops: 2560,
12
+ chance: 45 / 100208,
13
+ },
14
+ {
15
+ drops: 51200,
16
+ chance: 7 / 100208,
17
+ },
18
+ {
19
+ drops: 204800,
20
+ chance: 1 / 100208,
21
+ },
22
+ ],
23
+ };
24
+ function MelonPerkBonus(blocksBroken, level = 3) {
25
+ let total = 0;
26
+ for (const { drops, chance } of MELON_DICER_ROLLEM[level]) {
27
+ total += drops * chance * blocksBroken;
28
+ }
29
+ return total;
6
30
  }
7
31
  exports.MelonPerkBonus = MelonPerkBonus;
@@ -0,0 +1 @@
1
+ export declare function PumpkinPerkBonus(blocksBroken: number, level?: 3): number;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PumpkinPerkBonus = void 0;
4
+ const PUMPKIN_DICER_ROLLEM = {
5
+ 3: [
6
+ {
7
+ drops: 480,
8
+ chance: 90 / 100141,
9
+ },
10
+ {
11
+ drops: 800,
12
+ chance: 40 / 100141,
13
+ },
14
+ {
15
+ drops: 7200,
16
+ chance: 7 / 100141,
17
+ },
18
+ {
19
+ drops: 51200,
20
+ chance: 1 / 100141,
21
+ },
22
+ ],
23
+ };
24
+ function PumpkinPerkBonus(blocksBroken, level = 3) {
25
+ let total = 0;
26
+ for (const { drops, chance } of PUMPKIN_DICER_ROLLEM[level]) {
27
+ total += drops * chance * blocksBroken;
28
+ }
29
+ return total;
30
+ }
31
+ exports.PumpkinPerkBonus = PumpkinPerkBonus;
package/lib/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- import { CalculateExpectedDrops, CalculateAverageDrops } from "./ratecalc";
2
- export { CalculateExpectedDrops, CalculateAverageDrops };
1
+ import { CalculateExpectedDrops, CalculateAverageDrops, GetCropInfo } from './ratecalc';
2
+ import { CropInfo, Crop, MAX_CROP_FORTUNE } from './constants/crops';
3
+ export { CalculateExpectedDrops, CalculateAverageDrops, GetCropInfo, CropInfo, Crop, MAX_CROP_FORTUNE };
package/lib/index.js CHANGED
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CalculateAverageDrops = exports.CalculateExpectedDrops = void 0;
3
+ exports.MAX_CROP_FORTUNE = exports.Crop = exports.GetCropInfo = exports.CalculateAverageDrops = exports.CalculateExpectedDrops = void 0;
4
4
  const ratecalc_1 = require("./ratecalc");
5
5
  Object.defineProperty(exports, "CalculateExpectedDrops", { enumerable: true, get: function () { return ratecalc_1.CalculateExpectedDrops; } });
6
6
  Object.defineProperty(exports, "CalculateAverageDrops", { enumerable: true, get: function () { return ratecalc_1.CalculateAverageDrops; } });
7
+ Object.defineProperty(exports, "GetCropInfo", { enumerable: true, get: function () { return ratecalc_1.GetCropInfo; } });
8
+ const crops_1 = require("./constants/crops");
9
+ Object.defineProperty(exports, "Crop", { enumerable: true, get: function () { return crops_1.Crop; } });
10
+ Object.defineProperty(exports, "MAX_CROP_FORTUNE", { enumerable: true, get: function () { return crops_1.MAX_CROP_FORTUNE; } });
package/lib/player.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Crop } from "./constants/crops";
1
+ import { Crop } from './constants/crops';
2
2
  interface PlayerOptions {
3
3
  collection?: Record<string, number>;
4
4
  fortuneSources?: Record<string, number>;
package/lib/player.js CHANGED
@@ -21,8 +21,7 @@ class Player {
21
21
  this.cropSpecificFortune[crop] = amount;
22
22
  return this;
23
23
  }
24
- setLotusGear() {
25
- }
24
+ setLotusGear() { }
26
25
  getFortune() {
27
26
  const general = Object.values(this.fortuneSources).reduce((a, b) => a + b, 0);
28
27
  return general;
package/lib/ratecalc.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Crop, CropInfo } from './constants/crops';
2
2
  interface CalculateDropsOptions {
3
- farmingFortune: number;
3
+ farmingFortune?: number;
4
4
  blocksBroken: number;
5
5
  }
6
6
  export declare function CalculateAverageDrops(options: CalculateDropsOptions): Record<Crop, number>;
package/lib/ratecalc.js CHANGED
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GetCropInfo = exports.CalculateExpectedDrops = exports.CalculateAverageDrops = void 0;
4
4
  const crops_1 = require("./constants/crops");
5
+ const melon_1 = require("./crops/melon");
6
+ const pumpkin_1 = require("./crops/pumpkin");
5
7
  function CalculateAverageDrops(options) {
6
8
  const { farmingFortune, blocksBroken } = options;
7
9
  const result = {
@@ -15,13 +17,13 @@ function CalculateAverageDrops(options) {
15
17
  [crops_1.Crop.Pumpkin]: 0,
16
18
  [crops_1.Crop.SugarCane]: 0,
17
19
  [crops_1.Crop.Wheat]: 0,
18
- [crops_1.Crop.Seeds]: 0
20
+ [crops_1.Crop.Seeds]: 0,
19
21
  };
20
22
  for (const crop of Object.keys(result)) {
21
23
  result[crop] = CalculateExpectedDrops({
22
24
  farmingFortune,
23
25
  crop: crop,
24
- blocksBroken
26
+ blocksBroken,
25
27
  });
26
28
  }
27
29
  return result;
@@ -29,11 +31,13 @@ function CalculateAverageDrops(options) {
29
31
  exports.CalculateAverageDrops = CalculateAverageDrops;
30
32
  function CalculateExpectedDrops(options) {
31
33
  const { farmingFortune, blocksBroken, crop } = options;
32
- if (farmingFortune <= 0 || blocksBroken < 0)
34
+ const fortune = farmingFortune ?? crops_1.MAX_CROP_FORTUNE[crop] ?? 0;
35
+ if (fortune <= 0 || blocksBroken < 0)
33
36
  return 0;
34
37
  const { drops } = GetCropInfo(crop);
35
38
  if (!drops)
36
39
  return 0;
40
+ const normal = blocksBroken * drops * (fortune * 0.1);
37
41
  switch (crop) {
38
42
  case crops_1.Crop.Cactus:
39
43
  case crops_1.Crop.Carrot:
@@ -44,11 +48,11 @@ function CalculateExpectedDrops(options) {
44
48
  case crops_1.Crop.SugarCane:
45
49
  case crops_1.Crop.Wheat:
46
50
  case crops_1.Crop.Seeds:
47
- return blocksBroken * drops * (farmingFortune * 0.1);
51
+ return normal;
48
52
  case crops_1.Crop.Pumpkin:
49
- return blocksBroken * drops * (farmingFortune * 0.1) * 0.5;
53
+ return normal + (0, pumpkin_1.PumpkinPerkBonus)(blocksBroken);
50
54
  case crops_1.Crop.Melon:
51
- return blocksBroken * drops * (farmingFortune * 0.1) * 0.5;
55
+ return normal + (0, melon_1.MelonPerkBonus)(blocksBroken);
52
56
  default:
53
57
  return 0;
54
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "farming-weight",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Tools for calculating farming weight and fortune in Hypixel Skyblock",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",