farming-weight 0.4.7 → 0.4.9
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/util/garden.d.ts +5 -3
- package/dist/util/garden.js +24 -11
- package/dist/util/garden.js.map +1 -1
- package/package.json +1 -1
package/dist/util/garden.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Rarity } from "../constants/reforges";
|
|
|
3
3
|
export interface LevelingStats {
|
|
4
4
|
level: number;
|
|
5
5
|
ratio: number;
|
|
6
|
+
maxed: boolean;
|
|
6
7
|
progress: number;
|
|
7
8
|
goal?: number;
|
|
8
9
|
next?: number;
|
|
@@ -13,11 +14,12 @@ export interface LevelingStats {
|
|
|
13
14
|
* @param exp Current experience/progress
|
|
14
15
|
* @param expRequired Array of the amount of experience required to reach each level, not cumulative
|
|
15
16
|
* @param maxLevel Maximum level to return
|
|
17
|
+
* @param overflow Calculate overflow levels
|
|
16
18
|
*/
|
|
17
|
-
export declare function getLevel(exp: number, expRequired: number[], maxLevel?: number): LevelingStats;
|
|
19
|
+
export declare function getLevel(exp: number, expRequired: number[], maxLevel?: number, overflow?: boolean): LevelingStats;
|
|
18
20
|
export declare function getGardenLevel(exp: number): LevelingStats;
|
|
19
|
-
export declare function getCropMilestones(crops: Record<string, number | string
|
|
20
|
-
export declare function getCropMilestoneLevels(crops: Record<string, number | string | null | undefined
|
|
21
|
+
export declare function getCropMilestones(crops: Record<string, number | string>, overflow?: boolean): Record<Crop, LevelingStats>;
|
|
22
|
+
export declare function getCropMilestoneLevels(crops: Record<string, number | string | null | undefined>, overflow?: boolean): Record<Crop, number>;
|
|
21
23
|
export declare function getCropUpgrades(upgrades: Record<string, number>): Record<Crop, number>;
|
|
22
24
|
export declare function getGardenVisitor(visitor: string): import("../constants/garden").GardenVisitor | undefined;
|
|
23
25
|
export interface GardenVisitorStats {
|
package/dist/util/garden.js
CHANGED
|
@@ -8,32 +8,45 @@ const names_1 = require("./names");
|
|
|
8
8
|
* @param exp Current experience/progress
|
|
9
9
|
* @param expRequired Array of the amount of experience required to reach each level, not cumulative
|
|
10
10
|
* @param maxLevel Maximum level to return
|
|
11
|
+
* @param overflow Calculate overflow levels
|
|
11
12
|
*/
|
|
12
|
-
function getLevel(exp, expRequired, maxLevel) {
|
|
13
|
+
function getLevel(exp, expRequired, maxLevel, overflow = false) {
|
|
13
14
|
let level = 0;
|
|
14
15
|
let xp = exp;
|
|
15
|
-
let maxed =
|
|
16
|
+
let maxed = true;
|
|
16
17
|
for (const xpRequired of expRequired) {
|
|
17
18
|
if ((xp -= xpRequired) > 0) {
|
|
18
19
|
level++;
|
|
19
20
|
if (level === maxLevel) {
|
|
20
|
-
maxed = true;
|
|
21
21
|
break;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
|
+
maxed = false;
|
|
25
26
|
xp += xpRequired;
|
|
26
27
|
break;
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
|
-
const
|
|
30
|
+
const overflowing = !maxLevel && maxed && overflow;
|
|
31
|
+
if (overflowing) {
|
|
32
|
+
const overflowReq = expRequired.at(-1) ?? 0;
|
|
33
|
+
if (overflowReq) {
|
|
34
|
+
const overflowLevels = Math.floor(xp / overflowReq);
|
|
35
|
+
level += overflowLevels;
|
|
36
|
+
xp -= overflowLevels * overflowReq;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const nextReq = (overflowing)
|
|
40
|
+
? expRequired.at(-1) ?? 0
|
|
41
|
+
: expRequired[level];
|
|
30
42
|
return {
|
|
31
43
|
total: exp,
|
|
32
44
|
level: level,
|
|
33
|
-
|
|
45
|
+
maxed: maxed,
|
|
46
|
+
ratio: maxed && !overflowing ? 1 : xp / (nextReq ?? xp),
|
|
34
47
|
progress: xp,
|
|
35
|
-
goal: maxed ? undefined : nextReq,
|
|
36
|
-
next: maxed ? undefined : level + 1,
|
|
48
|
+
goal: maxed && !overflowing ? undefined : nextReq,
|
|
49
|
+
next: maxed && !overflowing ? undefined : level + 1,
|
|
37
50
|
};
|
|
38
51
|
}
|
|
39
52
|
exports.getLevel = getLevel;
|
|
@@ -41,26 +54,26 @@ function getGardenLevel(exp) {
|
|
|
41
54
|
return getLevel(exp, garden_1.GARDEN_EXP_REQUIRED);
|
|
42
55
|
}
|
|
43
56
|
exports.getGardenLevel = getGardenLevel;
|
|
44
|
-
function getCropMilestones(crops) {
|
|
57
|
+
function getCropMilestones(crops, overflow = false) {
|
|
45
58
|
const milestones = {};
|
|
46
59
|
for (const [cropName, collection] of Object.entries(crops)) {
|
|
47
60
|
const crop = (0, names_1.getCropFromName)(cropName);
|
|
48
61
|
const col = typeof collection === 'string' ? parseInt(collection) : collection;
|
|
49
62
|
if (isNaN(col) || !crop)
|
|
50
63
|
continue;
|
|
51
|
-
milestones[crop] = getLevel(col, garden_1.CROP_MILESTONES[crop]);
|
|
64
|
+
milestones[crop] = getLevel(col, garden_1.CROP_MILESTONES[crop], undefined, overflow);
|
|
52
65
|
}
|
|
53
66
|
return milestones;
|
|
54
67
|
}
|
|
55
68
|
exports.getCropMilestones = getCropMilestones;
|
|
56
|
-
function getCropMilestoneLevels(crops) {
|
|
69
|
+
function getCropMilestoneLevels(crops, overflow = false) {
|
|
57
70
|
const milestones = {};
|
|
58
71
|
for (const [cropName, collection] of Object.entries(crops)) {
|
|
59
72
|
const crop = (0, names_1.getCropFromName)(cropName);
|
|
60
73
|
const col = typeof collection === 'string' ? parseInt(collection) : collection ?? NaN;
|
|
61
74
|
if (isNaN(col) || !crop)
|
|
62
75
|
continue;
|
|
63
|
-
milestones[crop] = getLevel(col, garden_1.CROP_MILESTONES[crop]).level;
|
|
76
|
+
milestones[crop] = getLevel(col, garden_1.CROP_MILESTONES[crop], undefined, overflow).level;
|
|
64
77
|
}
|
|
65
78
|
return milestones;
|
|
66
79
|
}
|
package/dist/util/garden.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"garden.js","sourceRoot":"","sources":["../../src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