@schedule1-tools/mixer 0.2.3 → 0.2.5
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/README.md +112 -46
- package/dist/core/effectSet.d.ts +1 -27
- package/dist/core/effectSet.d.ts.map +1 -0
- package/dist/core/effectSet.js +1 -27
- package/dist/core/effectSet.js.map +1 -0
- package/dist/core/mixer.d.ts +1 -11
- package/dist/core/mixer.d.ts.map +1 -0
- package/dist/core/mixer.js +6 -71
- package/dist/core/mixer.js.map +1 -0
- package/dist/data/effects.d.ts +3 -0
- package/dist/data/effects.d.ts.map +1 -0
- package/dist/data/effects.js +159 -148
- package/dist/data/effects.js.map +1 -0
- package/dist/data/products.d.ts +1 -0
- package/dist/data/products.d.ts.map +1 -0
- package/dist/data/products.js +16 -0
- package/dist/data/products.js.map +1 -0
- package/dist/data/rules.d.ts +1 -0
- package/dist/data/rules.d.ts.map +1 -0
- package/dist/data/rules.js +2 -2
- package/dist/data/rules.js.map +1 -0
- package/dist/data/substances.d.ts +1 -0
- package/dist/data/substances.d.ts.map +1 -0
- package/dist/data/substances.js +4 -3
- package/dist/data/substances.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -6
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +6 -3
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/encoding.d.ts +1 -16
- package/dist/utils/encoding.d.ts.map +1 -0
- package/dist/utils/encoding.js +7 -62
- package/dist/utils/encoding.js.map +1 -0
- package/package.json +42 -41
- package/dist/utils/lz.d.ts +0 -5
- package/dist/utils/lz.js +0 -177
package/README.md
CHANGED
|
@@ -1,82 +1,148 @@
|
|
|
1
1
|
# Schedule1 Mixer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@schedule1-tools/mixer)
|
|
4
|
+
[](https://www.npmjs.com/package/@schedule1-tools/mixer)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
Open‑source mixing calculator for _Schedule 1_.
|
|
8
|
+
|
|
9
|
+
---
|
|
4
10
|
|
|
5
11
|
## Installation
|
|
6
12
|
|
|
7
13
|
```bash
|
|
14
|
+
# npm
|
|
8
15
|
npm install @schedule1-tools/mixer
|
|
16
|
+
|
|
17
|
+
# yarn
|
|
18
|
+
yarn add @schedule1-tools/mixer
|
|
19
|
+
|
|
20
|
+
# pnpm
|
|
21
|
+
pnpm add @schedule1-tools/mixer
|
|
9
22
|
```
|
|
10
23
|
|
|
11
|
-
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
12
27
|
|
|
13
|
-
### Calculate a mix
|
|
28
|
+
### 1. Calculate a mix
|
|
14
29
|
|
|
15
30
|
```typescript
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
import { mixSubstances } from '@schedule1-tools/mixer';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* mixSubstances(product: Product, substances: Substance[])
|
|
35
|
+
* → computes cost, effects, profit, profitMargin, addiction
|
|
36
|
+
*/
|
|
37
|
+
const result = mixSubstances(
|
|
38
|
+
'OG Kush',
|
|
39
|
+
['Cuke', 'Flu Medicine', 'Gasoline']
|
|
40
|
+
);
|
|
41
|
+
// result → {
|
|
42
|
+
// effects: ['Be','Se','Eu','To'],
|
|
43
|
+
// cost: 12,
|
|
44
|
+
// sellPrice: 64,
|
|
45
|
+
// profit: 52,
|
|
46
|
+
// profitMargin: 0.81,
|
|
47
|
+
// addiction: 0.44
|
|
48
|
+
// }
|
|
28
49
|
```
|
|
29
50
|
|
|
30
|
-
### Calculate
|
|
51
|
+
### 2. Calculate from a hash
|
|
31
52
|
|
|
32
53
|
```typescript
|
|
33
|
-
|
|
54
|
+
import { mixFromHash } from '@schedule1-tools/mixer';
|
|
34
55
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
56
|
+
/**
|
|
57
|
+
* mixFromHash(hash: string)
|
|
58
|
+
* → decode & compute a mix from its shared hash form
|
|
59
|
+
*/
|
|
60
|
+
const result = mixFromHash('T0cgS3VzaDpBQkM');
|
|
61
|
+
// result → {
|
|
62
|
+
// effects: ['Be','Se','Eu','To'],
|
|
63
|
+
// cost: 12,
|
|
64
|
+
// sellPrice: 64,
|
|
65
|
+
// profit: 52,
|
|
66
|
+
// profitMargin: 0.81,
|
|
67
|
+
// addiction: 0.44
|
|
68
|
+
// }
|
|
45
69
|
```
|
|
46
70
|
|
|
47
|
-
### Encode
|
|
71
|
+
### 3. Encode & decode mix state
|
|
48
72
|
|
|
49
73
|
```typescript
|
|
74
|
+
import {
|
|
75
|
+
encodeMixState,
|
|
76
|
+
decodeMixState
|
|
77
|
+
} from '@schedule1-tools/mixer';
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* encodeMixState(state: MixState) → string
|
|
81
|
+
* decodeMixState(hash: string) → MixState
|
|
82
|
+
*/
|
|
50
83
|
const encoded = encodeMixState({
|
|
51
|
-
product:
|
|
52
|
-
substances: ['Cuke',
|
|
84
|
+
product: 'OG Kush',
|
|
85
|
+
substances: ['Cuke','Flu Medicine','Gasoline']
|
|
53
86
|
});
|
|
87
|
+
// encoded → 'T0cgS3VzaDpBQkM'
|
|
54
88
|
|
|
55
|
-
|
|
89
|
+
const decoded = decodeMixState(encoded);
|
|
90
|
+
// decoded → { product: 'OG Kush', substances: [...] }
|
|
56
91
|
```
|
|
57
92
|
|
|
58
|
-
###
|
|
93
|
+
### 4. Migrate an old mix hash
|
|
59
94
|
|
|
60
95
|
```typescript
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
96
|
+
import { migrateMixHash } from '@schedule1-tools/mixer';
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* migrateMixHash(legacyHash: string): Promise<string|null>
|
|
100
|
+
* → upgrade legacy LZ‑String hash to the new format
|
|
101
|
+
*/
|
|
102
|
+
const newHash = await migrateMixHash('OLD_BASE64_HASH_HERE');
|
|
103
|
+
// newHash → 'T0cgS3VzaDpBQkM' (or null if invalid)
|
|
69
104
|
```
|
|
70
105
|
|
|
106
|
+
---
|
|
107
|
+
|
|
71
108
|
## Exports
|
|
72
109
|
|
|
73
|
-
|
|
110
|
+
In addition to the functions above, the package also exports data objects:
|
|
111
|
+
|
|
112
|
+
- `effects`: All effect definitions
|
|
113
|
+
- `products`: All product definitions
|
|
114
|
+
- `substances`: All substance definitions
|
|
115
|
+
- `effectRulesBySubstance`: Transformation rules for each substance
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import {
|
|
119
|
+
effects,
|
|
120
|
+
products,
|
|
121
|
+
substances,
|
|
122
|
+
effectRulesBySubstance
|
|
123
|
+
} from '@schedule1-tools/mixer';
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Contributing
|
|
129
|
+
|
|
130
|
+
1. Fork the repo
|
|
131
|
+
2. Create a branch (`git checkout -b feat/my-feature`)
|
|
132
|
+
3. Run tests & lint (`pnpm test && pnpm run format`)
|
|
133
|
+
4. Open a PR against `main`
|
|
134
|
+
|
|
135
|
+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) (if present) for more details.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## License
|
|
140
|
+
|
|
141
|
+
MIT © Schedule1 Tools
|
|
142
|
+
See [LICENSE](LICENSE) for details.
|
|
74
143
|
|
|
75
|
-
|
|
76
|
-
- `products`: Information about all products
|
|
77
|
-
- `substances`: Information about all substances
|
|
78
|
-
- `effectRulesBySubstance`: Rules for how substances transform effects
|
|
144
|
+
---
|
|
79
145
|
|
|
80
146
|
## Notice
|
|
81
147
|
|
|
82
|
-
This is a fan
|
|
148
|
+
This is a fan‑made project and is not affiliated with, authorized, maintained, sponsored, or endorsed by the developers of _Schedule I_ the game. All game‑related content (names, trademarks, etc.) belongs to its respective owners.
|
package/dist/core/effectSet.d.ts
CHANGED
|
@@ -2,37 +2,11 @@ import type { EffectCode } from '../types';
|
|
|
2
2
|
export declare class EffectSet {
|
|
3
3
|
private effects;
|
|
4
4
|
constructor(initialEffects?: EffectCode[]);
|
|
5
|
-
/**
|
|
6
|
-
* Add an effect to the set
|
|
7
|
-
* @param effect - The effect to add
|
|
8
|
-
* @returns True if the effect was added, false if it already exists
|
|
9
|
-
*/
|
|
10
5
|
add(effect: EffectCode): boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Remove an effect from the set
|
|
13
|
-
* @param effect - The effect to remove
|
|
14
|
-
* @returns True if the effect was removed, false if it didn't exist
|
|
15
|
-
*/
|
|
16
6
|
remove(effect: EffectCode): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Check if the set contains an effect
|
|
19
|
-
* @param effect - The effect to check for
|
|
20
|
-
* @returns True if the effect is in the set, false otherwise
|
|
21
|
-
*/
|
|
22
7
|
has(effect: EffectCode): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Convert the set to an array
|
|
25
|
-
* @returns An array of effects
|
|
26
|
-
*/
|
|
27
8
|
toArray(): EffectCode[];
|
|
28
|
-
/**
|
|
29
|
-
* Get the size of the set
|
|
30
|
-
* @returns The number of effects in the set
|
|
31
|
-
*/
|
|
32
9
|
size(): number;
|
|
33
|
-
/**
|
|
34
|
-
* Clone the set
|
|
35
|
-
* @returns A new set with the same effects
|
|
36
|
-
*/
|
|
37
10
|
clone(): EffectSet;
|
|
38
11
|
}
|
|
12
|
+
//# sourceMappingURL=effectSet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effectSet.d.ts","sourceRoot":"","sources":["../../src/core/effectSet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAkB;gBAErB,cAAc,GAAE,UAAU,EAAO;IAS7C,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO;IAWhC,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO;IAWnC,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO;IAQhC,OAAO,IAAI,UAAU,EAAE;IAQvB,IAAI,IAAI,MAAM;IAQd,KAAK,IAAI,SAAS;CAKnB"}
|
package/dist/core/effectSet.js
CHANGED
|
@@ -5,52 +5,25 @@ class EffectSet {
|
|
|
5
5
|
constructor(initialEffects = []) {
|
|
6
6
|
this.effects = new Set(initialEffects);
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
9
|
-
* Add an effect to the set
|
|
10
|
-
* @param effect - The effect to add
|
|
11
|
-
* @returns True if the effect was added, false if it already exists
|
|
12
|
-
*/
|
|
13
8
|
add(effect) {
|
|
14
9
|
const alreadyExists = this.effects.has(effect);
|
|
15
10
|
this.effects.add(effect);
|
|
16
11
|
return !alreadyExists;
|
|
17
12
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Remove an effect from the set
|
|
20
|
-
* @param effect - The effect to remove
|
|
21
|
-
* @returns True if the effect was removed, false if it didn't exist
|
|
22
|
-
*/
|
|
23
13
|
remove(effect) {
|
|
24
14
|
const existed = this.effects.has(effect);
|
|
25
15
|
this.effects.delete(effect);
|
|
26
16
|
return existed;
|
|
27
17
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Check if the set contains an effect
|
|
30
|
-
* @param effect - The effect to check for
|
|
31
|
-
* @returns True if the effect is in the set, false otherwise
|
|
32
|
-
*/
|
|
33
18
|
has(effect) {
|
|
34
19
|
return this.effects.has(effect);
|
|
35
20
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Convert the set to an array
|
|
38
|
-
* @returns An array of effects
|
|
39
|
-
*/
|
|
40
21
|
toArray() {
|
|
41
22
|
return Array.from(this.effects);
|
|
42
23
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Get the size of the set
|
|
45
|
-
* @returns The number of effects in the set
|
|
46
|
-
*/
|
|
47
24
|
size() {
|
|
48
25
|
return this.effects.size;
|
|
49
26
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Clone the set
|
|
52
|
-
* @returns A new set with the same effects
|
|
53
|
-
*/
|
|
54
27
|
clone() {
|
|
55
28
|
const clone = new EffectSet();
|
|
56
29
|
clone.effects = new Set(this.effects);
|
|
@@ -58,3 +31,4 @@ class EffectSet {
|
|
|
58
31
|
}
|
|
59
32
|
}
|
|
60
33
|
exports.EffectSet = EffectSet;
|
|
34
|
+
//# sourceMappingURL=effectSet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effectSet.js","sourceRoot":"","sources":["../../src/core/effectSet.ts"],"names":[],"mappings":";;;AAEA,MAAa,SAAS;IAGpB,YAAY,iBAA+B,EAAE;QAC3C,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;IACzC,CAAC;IAOD,GAAG,CAAC,MAAkB;QACpB,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACzB,OAAO,CAAC,aAAa,CAAC;IACxB,CAAC;IAOD,MAAM,CAAC,MAAkB;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC5B,OAAO,OAAO,CAAC;IACjB,CAAC;IAOD,GAAG,CAAC,MAAkB;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAMD,OAAO;QACL,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAMD,IAAI;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAMD,KAAK;QACH,MAAM,KAAK,GAAG,IAAI,SAAS,EAAE,CAAC;QAC9B,KAAK,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA/DD,8BA+DC"}
|
package/dist/core/mixer.d.ts
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import type { MixResult, Product, Substance } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Calculate the result of mixing substances with a product
|
|
4
|
-
* @param product - The product to mix
|
|
5
|
-
* @param substanceCodes - The substances to mix
|
|
6
|
-
* @returns The result of the mix
|
|
7
|
-
*/
|
|
8
2
|
export declare function mixSubstances(product: Product, substanceCodes: Substance[]): MixResult;
|
|
9
|
-
/**
|
|
10
|
-
* Mix substances from a hash
|
|
11
|
-
* @param hash - The hash to mix
|
|
12
|
-
* @returns The result of the mix
|
|
13
|
-
*/
|
|
14
3
|
export declare function mixFromHash(hash: string): MixResult;
|
|
4
|
+
//# sourceMappingURL=mixer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mixer.d.ts","sourceRoot":"","sources":["../../src/core/mixer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0B,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAiBtF,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,SAAS,CA8EtF;AAOD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAMnD"}
|
package/dist/core/mixer.js
CHANGED
|
@@ -9,12 +9,6 @@ const substances_1 = require("../data/substances");
|
|
|
9
9
|
const encoding_1 = require("../utils/encoding");
|
|
10
10
|
const effectSet_1 = require("./effectSet");
|
|
11
11
|
const MAX_EFFECTS = 8;
|
|
12
|
-
/**
|
|
13
|
-
* Calculate the result of mixing substances with a product
|
|
14
|
-
* @param product - The product to mix
|
|
15
|
-
* @param substanceCodes - The substances to mix
|
|
16
|
-
* @returns The result of the mix
|
|
17
|
-
*/
|
|
18
12
|
function mixSubstances(product, substanceCodes) {
|
|
19
13
|
if (!products_1.products[product]) {
|
|
20
14
|
throw new Error(`Unknown product: ${product}`);
|
|
@@ -33,7 +27,6 @@ function mixSubstances(product, substanceCodes) {
|
|
|
33
27
|
const processedEffects = new effectSet_1.EffectSet();
|
|
34
28
|
const removedEffects = new effectSet_1.EffectSet();
|
|
35
29
|
const appliedRules = new Set();
|
|
36
|
-
// Phase 1: Apply rules where conditions are met in the initial state
|
|
37
30
|
for (let i = 0; i < rules.length; i++) {
|
|
38
31
|
const rule = rules[i];
|
|
39
32
|
if (checkRulePreconditions(rule, initialEffects)) {
|
|
@@ -41,7 +34,6 @@ function mixSubstances(product, substanceCodes) {
|
|
|
41
34
|
appliedRules.add(i);
|
|
42
35
|
}
|
|
43
36
|
}
|
|
44
|
-
// Phase 2: Apply rules where conditions are met after phase 1
|
|
45
37
|
for (let i = 0; i < rules.length; i++) {
|
|
46
38
|
if (appliedRules.has(i))
|
|
47
39
|
continue;
|
|
@@ -53,7 +45,6 @@ function mixSubstances(product, substanceCodes) {
|
|
|
53
45
|
}
|
|
54
46
|
}
|
|
55
47
|
}
|
|
56
|
-
// Add substance effects AFTER applying rules
|
|
57
48
|
if (effectsSet.size() < MAX_EFFECTS && substance.effect) {
|
|
58
49
|
for (const effect of substance.effect) {
|
|
59
50
|
if (!effectsSet.has(effect)) {
|
|
@@ -66,7 +57,7 @@ function mixSubstances(product, substanceCodes) {
|
|
|
66
57
|
}
|
|
67
58
|
const finalEffects = effectsSet.toArray().slice(0, MAX_EFFECTS);
|
|
68
59
|
const effectValue = calculateEffectValue(finalEffects);
|
|
69
|
-
const addictionValue = calculateAddiction(finalEffects);
|
|
60
|
+
const addictionValue = calculateAddiction(product, finalEffects);
|
|
70
61
|
const addiction = Math.round(addictionValue * 100) / 100;
|
|
71
62
|
const sellPrice = Math.round(productInfo.price * (1 + effectValue));
|
|
72
63
|
const profit = sellPrice - totalCost;
|
|
@@ -80,11 +71,6 @@ function mixSubstances(product, substanceCodes) {
|
|
|
80
71
|
addiction,
|
|
81
72
|
};
|
|
82
73
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Mix substances from a hash
|
|
85
|
-
* @param hash - The hash to mix
|
|
86
|
-
* @returns The result of the mix
|
|
87
|
-
*/
|
|
88
74
|
function mixFromHash(hash) {
|
|
89
75
|
const state = (0, encoding_1.decodeMixState)(hash);
|
|
90
76
|
if (!state) {
|
|
@@ -92,45 +78,26 @@ function mixFromHash(hash) {
|
|
|
92
78
|
}
|
|
93
79
|
return mixSubstances(state.product, state.substances);
|
|
94
80
|
}
|
|
95
|
-
/**
|
|
96
|
-
* Check if a rule's preconditions are met
|
|
97
|
-
* @param rule - The rule to check
|
|
98
|
-
* @param initialEffects - The initial effects
|
|
99
|
-
* @returns True if the preconditions are met, false otherwise
|
|
100
|
-
*/
|
|
101
81
|
function checkRulePreconditions(rule, initialEffects) {
|
|
102
|
-
// Check if all required effects are present
|
|
103
82
|
for (const effect of rule.ifPresent) {
|
|
104
83
|
if (!initialEffects.has(effect))
|
|
105
84
|
return false;
|
|
106
85
|
}
|
|
107
|
-
// Check if all forbidden effects are absent
|
|
108
86
|
for (const effect of rule.ifNotPresent) {
|
|
109
87
|
if (initialEffects.has(effect))
|
|
110
88
|
return false;
|
|
111
89
|
}
|
|
112
|
-
// Check if at least one replaceable effect is present
|
|
113
90
|
for (const oldEffect of Object.keys(rule.replace)) {
|
|
114
91
|
if (initialEffects.has(oldEffect))
|
|
115
92
|
return true;
|
|
116
93
|
}
|
|
117
94
|
return false;
|
|
118
95
|
}
|
|
119
|
-
/**
|
|
120
|
-
* Check if a rule meets phase two conditions
|
|
121
|
-
* @param rule - The rule to check
|
|
122
|
-
* @param initialEffects - The initial effects
|
|
123
|
-
* @param currentEffects - The current effects
|
|
124
|
-
* @param removedEffects - The removed effects
|
|
125
|
-
* @returns True if the rule meets the conditions, false otherwise
|
|
126
|
-
*/
|
|
127
96
|
function meetsPhaseTwo(rule, initialEffects, currentEffects, removedEffects) {
|
|
128
|
-
// All required effects must have been initially present
|
|
129
97
|
for (const effect of rule.ifPresent) {
|
|
130
98
|
if (!initialEffects.has(effect))
|
|
131
99
|
return false;
|
|
132
100
|
}
|
|
133
|
-
// At least one forbidden effect must have been removed
|
|
134
101
|
let hasRemovedForbidden = false;
|
|
135
102
|
for (const effect of rule.ifNotPresent) {
|
|
136
103
|
if (removedEffects.has(effect)) {
|
|
@@ -140,21 +107,12 @@ function meetsPhaseTwo(rule, initialEffects, currentEffects, removedEffects) {
|
|
|
140
107
|
}
|
|
141
108
|
if (!hasRemovedForbidden)
|
|
142
109
|
return false;
|
|
143
|
-
// All forbidden effects must be absent from current set
|
|
144
110
|
for (const effect of rule.ifNotPresent) {
|
|
145
111
|
if (currentEffects.has(effect))
|
|
146
112
|
return false;
|
|
147
113
|
}
|
|
148
114
|
return true;
|
|
149
115
|
}
|
|
150
|
-
/**
|
|
151
|
-
* Apply effect replacements
|
|
152
|
-
* @param replace - The replacements to apply
|
|
153
|
-
* @param initialEffects - The initial effects
|
|
154
|
-
* @param effectsSet - The effects set
|
|
155
|
-
* @param processedEffects - The processed effects
|
|
156
|
-
* @param removedEffects - The removed effects
|
|
157
|
-
*/
|
|
158
116
|
function applyReplaceEffects(replace, initialEffects, effectsSet, processedEffects, removedEffects) {
|
|
159
117
|
for (const [oldEffect, newEffect] of Object.entries(replace)) {
|
|
160
118
|
if (initialEffects.has(oldEffect)) {
|
|
@@ -165,12 +123,6 @@ function applyReplaceEffects(replace, initialEffects, effectsSet, processedEffec
|
|
|
165
123
|
}
|
|
166
124
|
}
|
|
167
125
|
}
|
|
168
|
-
/**
|
|
169
|
-
* Check if a transformation can be applied
|
|
170
|
-
* @param replace - The replacements to apply
|
|
171
|
-
* @param effectsSet - The effects set
|
|
172
|
-
* @returns True if the transformation can be applied, false otherwise
|
|
173
|
-
*/
|
|
174
126
|
function canApplyTransformation(replace, effectsSet) {
|
|
175
127
|
for (const oldEffect of Object.keys(replace)) {
|
|
176
128
|
if (effectsSet.has(oldEffect))
|
|
@@ -178,12 +130,6 @@ function canApplyTransformation(replace, effectsSet) {
|
|
|
178
130
|
}
|
|
179
131
|
return false;
|
|
180
132
|
}
|
|
181
|
-
/**
|
|
182
|
-
* Apply transformations to effects
|
|
183
|
-
* @param replace - The replacements to apply
|
|
184
|
-
* @param effectsSet - The effects set
|
|
185
|
-
* @param processedEffects - The processed effects
|
|
186
|
-
*/
|
|
187
133
|
function applyTransformations(replace, effectsSet, processedEffects) {
|
|
188
134
|
for (const [oldEffect, newEffect] of Object.entries(replace)) {
|
|
189
135
|
if (effectsSet.has(oldEffect)) {
|
|
@@ -193,29 +139,18 @@ function applyTransformations(replace, effectsSet, processedEffects) {
|
|
|
193
139
|
}
|
|
194
140
|
}
|
|
195
141
|
}
|
|
196
|
-
/**
|
|
197
|
-
* Calculate the total value multiplier from effects
|
|
198
|
-
* @param effectCodes - The effects to calculate the value for
|
|
199
|
-
* @returns The total value multiplier
|
|
200
|
-
*/
|
|
201
142
|
function calculateEffectValue(effectCodes) {
|
|
202
|
-
var _a;
|
|
203
143
|
let value = 0;
|
|
204
144
|
for (const code of effectCodes) {
|
|
205
|
-
value +=
|
|
145
|
+
value += effects_1.effects[code]?.price || 0;
|
|
206
146
|
}
|
|
207
147
|
return value;
|
|
208
148
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
* @param effectCodes - The effects to calculate the value for
|
|
212
|
-
* @returns The total addiction value
|
|
213
|
-
*/
|
|
214
|
-
function calculateAddiction(effectCodes) {
|
|
215
|
-
var _a;
|
|
216
|
-
let value = 0;
|
|
149
|
+
function calculateAddiction(product, effectCodes) {
|
|
150
|
+
let value = products_1.products[product]?.addiction || 0;
|
|
217
151
|
for (const code of effectCodes) {
|
|
218
|
-
value +=
|
|
152
|
+
value += effects_1.effects[code]?.addiction || 0;
|
|
219
153
|
}
|
|
220
154
|
return value;
|
|
221
155
|
}
|
|
156
|
+
//# sourceMappingURL=mixer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mixer.js","sourceRoot":"","sources":["../../src/core/mixer.ts"],"names":[],"mappings":";;AAiBA,sCA8EC;AAOD,kCAMC;AA1GD,6CAA0C;AAC1C,+CAA4C;AAC5C,yCAAuD;AACvD,mDAAgD;AAChD,gDAAmD;AACnD,2CAAwC;AAExC,MAAM,WAAW,GAAG,CAAC,CAAC;AAQtB,SAAgB,aAAa,CAAC,OAAgB,EAAE,cAA2B;IACzE,IAAI,CAAC,mBAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,WAAW,GAAG,mBAAQ,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,UAAU,GAAG,IAAI,qBAAS,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACtD,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;QAClC,MAAM,SAAS,GAAG,uBAAU,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,SAAS;YAAE,SAAS;QAEzB,SAAS,IAAI,SAAS,CAAC,KAAK,CAAC;QAE7B,MAAM,KAAK,GAAG,8BAAsB,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,KAAK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BAAoB,CAAC,WAAyB;IACrD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;QAC/B,KAAK,IAAI,iBAAO,CAAC,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAOD,SAAS,kBAAkB,CAAC,OAAgB,EAAE,WAAyB;IACrE,IAAI,KAAK,GAAG,mBAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,IAAI,CAAC,CAAC;IAC9C,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;QAC/B,KAAK,IAAI,iBAAO,CAAC,IAAI,CAAC,EAAE,SAAS,IAAI,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/data/effects.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { EffectCode, EffectData } from '../types';
|
|
2
2
|
export declare const effects: Record<EffectCode, EffectData>;
|
|
3
|
+
export declare const effectBits: Record<EffectCode, bigint>;
|
|
4
|
+
export declare const bitToEffect: Record<string, EffectCode>;
|
|
5
|
+
//# sourceMappingURL=effects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effects.d.ts","sourceRoot":"","sources":["../../src/data/effects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEvD,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,UAAU,CAmRlD,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAQ/C,CAAC;AAEJ,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAMlD,CAAC"}
|