volleyballsimtypes 0.0.161 → 0.0.164
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as GeneralStat from '../../formula/stats';
|
|
2
2
|
import { PerformanceStats } from './performance-stats';
|
|
3
|
+
import { Rarity } from './rarity';
|
|
3
4
|
export declare class Trait {
|
|
4
5
|
static readonly MASTER_MIND: Trait;
|
|
5
6
|
static readonly MOVING_WALL: Trait;
|
|
@@ -16,6 +17,6 @@ export declare class Trait {
|
|
|
16
17
|
readonly weight: number;
|
|
17
18
|
private constructor();
|
|
18
19
|
static getTraits(): Trait[];
|
|
19
|
-
static assignTraits(performanceStats: PerformanceStats): Trait[];
|
|
20
|
+
static assignTraits(performanceStats: PerformanceStats, rarity: Rarity): Trait[];
|
|
20
21
|
toString(): string;
|
|
21
22
|
}
|
|
@@ -25,6 +25,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.Trait = void 0;
|
|
27
27
|
const GeneralStat = __importStar(require("../../formula/stats"));
|
|
28
|
+
const rarity_1 = require("./rarity");
|
|
29
|
+
const node_crypto_1 = require("node:crypto");
|
|
28
30
|
class Trait {
|
|
29
31
|
constructor({ id, name, modifier, chance, statThreshold, stat, weight }) {
|
|
30
32
|
this.id = id;
|
|
@@ -38,25 +40,36 @@ class Trait {
|
|
|
38
40
|
static getTraits() {
|
|
39
41
|
return [Trait.GUARDIAN, Trait.MARKSMAN, Trait.METEOR_SERVE, Trait.VIGOROUS, Trait.MOVING_WALL, Trait.MASTER_MIND];
|
|
40
42
|
}
|
|
41
|
-
static assignTraits(performanceStats) {
|
|
42
|
-
const qualifiedTraits = this.getTraits().filter(trait => {
|
|
43
|
-
return GeneralStat.calculateScore(performanceStats, trait.stat) >= trait.statThreshold;
|
|
44
|
-
});
|
|
45
|
-
const random = Math.random();
|
|
43
|
+
static assignTraits(performanceStats, rarity) {
|
|
46
44
|
let traitCount;
|
|
47
|
-
switch (
|
|
48
|
-
case
|
|
49
|
-
traitCount =
|
|
45
|
+
switch (rarity) {
|
|
46
|
+
case rarity_1.Rarity.COMMON: {
|
|
47
|
+
traitCount = 0;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
case rarity_1.Rarity.RARE: {
|
|
51
|
+
traitCount = (0, node_crypto_1.randomInt)(0, 1);
|
|
50
52
|
break;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
}
|
|
54
|
+
case rarity_1.Rarity.LEGENDARY: {
|
|
55
|
+
traitCount = (0, node_crypto_1.randomInt)(0, 2);
|
|
53
56
|
break;
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
}
|
|
58
|
+
case rarity_1.Rarity.MYTHIC: {
|
|
59
|
+
traitCount = (0, node_crypto_1.randomInt)(1, 3);
|
|
56
60
|
break;
|
|
61
|
+
}
|
|
62
|
+
case rarity_1.Rarity.SPECIAL: {
|
|
63
|
+
traitCount = (0, node_crypto_1.randomInt)(2, 3);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
57
66
|
default:
|
|
58
|
-
|
|
67
|
+
throw new Error('INVALID_RARITY');
|
|
59
68
|
}
|
|
69
|
+
if (traitCount < 1)
|
|
70
|
+
return [];
|
|
71
|
+
const qualifiedTraits = this.getTraits()
|
|
72
|
+
.filter(trait => GeneralStat.calculateScore(performanceStats, trait.stat) >= trait.statThreshold);
|
|
60
73
|
return qualifiedTraits.sort((t1, t2) => t2.weight - t1.weight)
|
|
61
74
|
.slice(0, traitCount);
|
|
62
75
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as GeneralStat from '../../formula/stats';
|
|
2
2
|
import { PerformanceStats } from './performance-stats';
|
|
3
|
+
import { Rarity } from './rarity';
|
|
3
4
|
export declare class Trait {
|
|
4
5
|
static readonly MASTER_MIND: Trait;
|
|
5
6
|
static readonly MOVING_WALL: Trait;
|
|
@@ -16,6 +17,6 @@ export declare class Trait {
|
|
|
16
17
|
readonly weight: number;
|
|
17
18
|
private constructor();
|
|
18
19
|
static getTraits(): Trait[];
|
|
19
|
-
static assignTraits(performanceStats: PerformanceStats): Trait[];
|
|
20
|
+
static assignTraits(performanceStats: PerformanceStats, rarity: Rarity): Trait[];
|
|
20
21
|
toString(): string;
|
|
21
22
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as GeneralStat from '../../formula/stats';
|
|
2
|
+
import { Rarity } from './rarity';
|
|
3
|
+
import { randomInt } from 'node:crypto';
|
|
2
4
|
export class Trait {
|
|
3
5
|
constructor({ id, name, modifier, chance, statThreshold, stat, weight }) {
|
|
4
6
|
this.id = id;
|
|
@@ -12,25 +14,36 @@ export class Trait {
|
|
|
12
14
|
static getTraits() {
|
|
13
15
|
return [Trait.GUARDIAN, Trait.MARKSMAN, Trait.METEOR_SERVE, Trait.VIGOROUS, Trait.MOVING_WALL, Trait.MASTER_MIND];
|
|
14
16
|
}
|
|
15
|
-
static assignTraits(performanceStats) {
|
|
16
|
-
const qualifiedTraits = this.getTraits().filter(trait => {
|
|
17
|
-
return GeneralStat.calculateScore(performanceStats, trait.stat) >= trait.statThreshold;
|
|
18
|
-
});
|
|
19
|
-
const random = Math.random();
|
|
17
|
+
static assignTraits(performanceStats, rarity) {
|
|
20
18
|
let traitCount;
|
|
21
|
-
switch (
|
|
22
|
-
case
|
|
23
|
-
traitCount =
|
|
19
|
+
switch (rarity) {
|
|
20
|
+
case Rarity.COMMON: {
|
|
21
|
+
traitCount = 0;
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
case Rarity.RARE: {
|
|
25
|
+
traitCount = randomInt(0, 1);
|
|
24
26
|
break;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
}
|
|
28
|
+
case Rarity.LEGENDARY: {
|
|
29
|
+
traitCount = randomInt(0, 2);
|
|
27
30
|
break;
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
}
|
|
32
|
+
case Rarity.MYTHIC: {
|
|
33
|
+
traitCount = randomInt(1, 3);
|
|
30
34
|
break;
|
|
35
|
+
}
|
|
36
|
+
case Rarity.SPECIAL: {
|
|
37
|
+
traitCount = randomInt(2, 3);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
31
40
|
default:
|
|
32
|
-
|
|
41
|
+
throw new Error('INVALID_RARITY');
|
|
33
42
|
}
|
|
43
|
+
if (traitCount < 1)
|
|
44
|
+
return [];
|
|
45
|
+
const qualifiedTraits = this.getTraits()
|
|
46
|
+
.filter(trait => GeneralStat.calculateScore(performanceStats, trait.stat) >= trait.statThreshold);
|
|
34
47
|
return qualifiedTraits.sort((t1, t2) => t2.weight - t1.weight)
|
|
35
48
|
.slice(0, traitCount);
|
|
36
49
|
}
|