@slot-engine/core 0.0.1 → 0.0.3
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 +1 -1
- package/dist/index.d.mts +7 -14
- package/dist/index.d.ts +7 -14
- package/dist/index.js +68 -90
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -90
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -1
- package/.turbo/turbo-build.log +0 -33
- package/.turbo/turbo-typecheck.log +0 -4
- package/CHANGELOG.md +0 -7
- package/dist/lib/zstd.exe +0 -0
- package/index.ts +0 -205
- package/lib/zstd.exe +0 -0
- package/optimizer-rust/Cargo.toml +0 -19
- package/optimizer-rust/src/exes.rs +0 -154
- package/optimizer-rust/src/main.rs +0 -1659
- package/src/Board.ts +0 -527
- package/src/Book.ts +0 -83
- package/src/GameConfig.ts +0 -148
- package/src/GameMode.ts +0 -86
- package/src/GameState.ts +0 -272
- package/src/GameSymbol.ts +0 -61
- package/src/ReelGenerator.ts +0 -589
- package/src/ResultSet.ts +0 -207
- package/src/Simulation.ts +0 -625
- package/src/SlotGame.ts +0 -117
- package/src/Wallet.ts +0 -203
- package/src/WinType.ts +0 -102
- package/src/analysis/index.ts +0 -198
- package/src/analysis/utils.ts +0 -128
- package/src/optimizer/OptimizationConditions.ts +0 -99
- package/src/optimizer/OptimizationParameters.ts +0 -46
- package/src/optimizer/OptimizationScaling.ts +0 -18
- package/src/optimizer/index.ts +0 -142
- package/src/utils/math-config.ts +0 -109
- package/src/utils/setup-file.ts +0 -36
- package/src/utils/zstd.ts +0 -28
- package/src/winTypes/ClusterWinType.ts +0 -3
- package/src/winTypes/LinesWinType.ts +0 -208
- package/src/winTypes/ManywaysWinType.ts +0 -3
- package/tsconfig.json +0 -19
- package/utils.ts +0 -270
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slot-engine/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/slot-engine/slot-engine"
|
|
7
7
|
},
|
|
8
|
+
"homepage": "https://slot-engine.dev/docs/core",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
8
12
|
"main": "dist/index.js",
|
|
9
13
|
"module": "dist/index.js",
|
|
10
14
|
"types": "dist/index.d.ts",
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @slot-engine/core@0.0.1 prebuild /home/runner/work/slot-engine/slot-engine/packages/core
|
|
3
|
-
> pnpm typecheck && pnpm copy-files
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
> @slot-engine/core@0.0.1 typecheck /home/runner/work/slot-engine/slot-engine/packages/core
|
|
7
|
-
> tsc --noEmit
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
> @slot-engine/core@0.0.1 copy-files /home/runner/work/slot-engine/slot-engine/packages/core
|
|
11
|
-
> tsx ../../scripts/copy-core-files.ts
|
|
12
|
-
|
|
13
|
-
✅ Files copied successfully.
|
|
14
|
-
|
|
15
|
-
> @slot-engine/core@0.0.1 build /home/runner/work/slot-engine/slot-engine/packages/core
|
|
16
|
-
> tsup ./index.ts --dts --format cjs,esm --sourcemap
|
|
17
|
-
|
|
18
|
-
[34mCLI[39m Building entry: index.ts
|
|
19
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
20
|
-
[34mCLI[39m tsup v8.5.0
|
|
21
|
-
[34mCLI[39m Target: es2022
|
|
22
|
-
[34mCJS[39m Build start
|
|
23
|
-
[34mESM[39m Build start
|
|
24
|
-
[32mCJS[39m [1mdist/index.js [22m[32m93.83 KB[39m
|
|
25
|
-
[32mCJS[39m [1mdist/index.js.map [22m[32m193.64 KB[39m
|
|
26
|
-
[32mCJS[39m ⚡️ Build success in 127ms
|
|
27
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m90.37 KB[39m
|
|
28
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[32m193.21 KB[39m
|
|
29
|
-
[32mESM[39m ⚡️ Build success in 129ms
|
|
30
|
-
[34mDTS[39m Build start
|
|
31
|
-
[32mDTS[39m ⚡️ Build success in 2038ms
|
|
32
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m42.85 KB[39m
|
|
33
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m42.85 KB[39m
|
package/CHANGELOG.md
DELETED
package/dist/lib/zstd.exe
DELETED
|
Binary file
|
package/index.ts
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { GameConfig } from "./src/GameConfig"
|
|
2
|
-
import { type SimulationContext } from "./src/Simulation"
|
|
3
|
-
import { GameMode, GameModeName } from "./src/GameMode"
|
|
4
|
-
import { GameSymbol } from "./src/GameSymbol"
|
|
5
|
-
import { ReelGenerator, Reels } from "./src/ReelGenerator"
|
|
6
|
-
import { ResultSet, EvaluationContext } from "./src/ResultSet"
|
|
7
|
-
import { StandaloneBoard } from "./src/Board"
|
|
8
|
-
import { WinType } from "./src/WinType"
|
|
9
|
-
import { LinesWinType } from "./src/winTypes/LinesWinType"
|
|
10
|
-
import { ClusterWinType } from "./src/winTypes/ClusterWinType"
|
|
11
|
-
import { ManywaysWinType } from "./src/winTypes/ManywaysWinType"
|
|
12
|
-
import { OptimizationConditions } from "./src/optimizer/OptimizationConditions"
|
|
13
|
-
import { OptimizationScaling } from "./src/optimizer/OptimizationScaling"
|
|
14
|
-
import { OptimizationParameters } from "./src/optimizer/OptimizationParameters"
|
|
15
|
-
import { SlotGame } from "./src/SlotGame"
|
|
16
|
-
export { weightedRandom } from "./utils"
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
StandaloneBoard,
|
|
20
|
-
GameConfig,
|
|
21
|
-
GameMode,
|
|
22
|
-
GameSymbol,
|
|
23
|
-
WinType,
|
|
24
|
-
LinesWinType,
|
|
25
|
-
ClusterWinType,
|
|
26
|
-
ManywaysWinType,
|
|
27
|
-
OptimizationConditions,
|
|
28
|
-
OptimizationScaling,
|
|
29
|
-
OptimizationParameters,
|
|
30
|
-
ReelGenerator,
|
|
31
|
-
ResultSet,
|
|
32
|
-
type Reels,
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
export interface CommonGameOptions<
|
|
39
|
-
TGameModes extends AnyGameModes = AnyGameModes,
|
|
40
|
-
TSymbols extends AnySymbols = AnySymbols,
|
|
41
|
-
TUserState extends AnyUserData = AnyUserData,
|
|
42
|
-
> {
|
|
43
|
-
/**
|
|
44
|
-
* The unique identifier of the game, used for configuration and identification.
|
|
45
|
-
*/
|
|
46
|
-
id: string
|
|
47
|
-
/**
|
|
48
|
-
* The name of the game, used for display purposes.
|
|
49
|
-
*/
|
|
50
|
-
name: string
|
|
51
|
-
/**
|
|
52
|
-
* An arbitrary number to identify the provider of this game.
|
|
53
|
-
*/
|
|
54
|
-
providerNumber: number
|
|
55
|
-
/**
|
|
56
|
-
* A GameMode is the core structure of a slot, defining the board,\
|
|
57
|
-
* bet cost, win type, and other properties.
|
|
58
|
-
*
|
|
59
|
-
* One-off mechanisms can also be injected into the core game logic from here.
|
|
60
|
-
*/
|
|
61
|
-
gameModes: Record<GameModeName, GameMode>
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* A list of all symbols that will appear on the reels.
|
|
65
|
-
*/
|
|
66
|
-
symbols: GameSymbol[]
|
|
67
|
-
/**
|
|
68
|
-
* A mapping from spin type to scatter counts to the number of free spins awarded.
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```ts
|
|
72
|
-
* scatterToFreespins: {
|
|
73
|
-
* [GameConfig.CONSTANTS.BASE_GAME]: {
|
|
74
|
-
* 3: 10,
|
|
75
|
-
* 4: 12,
|
|
76
|
-
* 5: 15,
|
|
77
|
-
* },
|
|
78
|
-
* [GameConfig.CONSTANTS.FREE_SPINS]: {
|
|
79
|
-
* 3: 6,
|
|
80
|
-
* 4: 8,
|
|
81
|
-
* 5: 10,
|
|
82
|
-
* },
|
|
83
|
-
* },
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
scatterToFreespins: Record<string, Record<number, number>>
|
|
87
|
-
/**
|
|
88
|
-
* If set, this will pad the board with symbols on the top and bottom of the reels.\
|
|
89
|
-
* Useful for teasing symbols right above or below the active board.
|
|
90
|
-
*
|
|
91
|
-
* Default: 1
|
|
92
|
-
*/
|
|
93
|
-
padSymbols?: number
|
|
94
|
-
/**
|
|
95
|
-
* The maximum win multiplier of the game, e.g. 5000 for a 5000x max win.
|
|
96
|
-
*/
|
|
97
|
-
maxWinX: number
|
|
98
|
-
/**
|
|
99
|
-
* Hooks are used to inject custom logic at specific points in the game flow.\
|
|
100
|
-
* Some required hooks must be implemented for certain features to work.
|
|
101
|
-
*/
|
|
102
|
-
hooks: GameHooks<TGameModes, TSymbols, TUserState>
|
|
103
|
-
/**
|
|
104
|
-
* Custom additional state that can be used in game flow logic.
|
|
105
|
-
*/
|
|
106
|
-
userState?: TUserState
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @internal
|
|
111
|
-
*/
|
|
112
|
-
export type AnyUserData = Record<string, any>
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* @internal
|
|
116
|
-
*/
|
|
117
|
-
export type AnyGameModes = Record<string, GameMode>
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* @internal
|
|
121
|
-
*/
|
|
122
|
-
export type AnySymbols = GameSymbol[]
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* @internal
|
|
126
|
-
*/
|
|
127
|
-
export interface GameHooks<
|
|
128
|
-
TGameModes extends AnyGameModes = AnyGameModes,
|
|
129
|
-
TSymbols extends AnySymbols = AnySymbols,
|
|
130
|
-
TUserState extends AnyUserData = AnyUserData,
|
|
131
|
-
> {
|
|
132
|
-
/**
|
|
133
|
-
* This hook is called after the simulation state is prepared for a spin,\
|
|
134
|
-
* and the core is ready to handle the game flow.
|
|
135
|
-
*
|
|
136
|
-
* **The developer is responsible for implementing the entire game flow here, including:**
|
|
137
|
-
* - Drawing the board
|
|
138
|
-
* - Evaluating wins
|
|
139
|
-
* - Tumbling mechanics
|
|
140
|
-
* - Updating wallet
|
|
141
|
-
* - Handling free spins
|
|
142
|
-
* - Recording events
|
|
143
|
-
* - ... and everything in between.
|
|
144
|
-
*
|
|
145
|
-
* You can access the config and state from the context.
|
|
146
|
-
*
|
|
147
|
-
* The game flow is not built into the core, because it can vary greatly between different games.\
|
|
148
|
-
* This hook provides the flexibility to implement any game flow you need.
|
|
149
|
-
*/
|
|
150
|
-
onHandleGameFlow: (ctx: SimulationContext<TGameModes, TSymbols, TUserState>) => void
|
|
151
|
-
/**
|
|
152
|
-
* This hook is called whenever a simulation is accepted, i.e. when the criteria of the current ResultSet is met.
|
|
153
|
-
*/
|
|
154
|
-
onSimulationAccepted?: (
|
|
155
|
-
ctx: SimulationContext<TGameModes, TSymbols, TUserState>,
|
|
156
|
-
) => void
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export type InferUserState<T> = T extends SlotGame<infer U> ? U : never
|
|
160
|
-
|
|
161
|
-
export type HookContext<T> =
|
|
162
|
-
T extends SlotGame<infer G, infer S, infer U> ? SimulationContext<G, S, U> : never
|
|
163
|
-
|
|
164
|
-
export { type EvaluationContext }
|
|
165
|
-
|
|
166
|
-
export type InferGameType<
|
|
167
|
-
TGameModes extends AnyGameModes,
|
|
168
|
-
TSymbols extends AnySymbols,
|
|
169
|
-
TUserState extends AnyUserData,
|
|
170
|
-
> = SlotGame<TGameModes, TSymbols, TUserState>
|
|
171
|
-
|
|
172
|
-
export interface CreateSlotGameOpts<
|
|
173
|
-
TGameModes extends AnyGameModes = AnyGameModes,
|
|
174
|
-
TSymbols extends AnySymbols = AnySymbols,
|
|
175
|
-
TUserState extends AnyUserData = AnyUserData,
|
|
176
|
-
> {
|
|
177
|
-
id: CommonGameOptions["id"]
|
|
178
|
-
name: CommonGameOptions["name"]
|
|
179
|
-
providerNumber: CommonGameOptions["providerNumber"]
|
|
180
|
-
gameModes: TGameModes
|
|
181
|
-
symbols: TSymbols
|
|
182
|
-
scatterToFreespins: CommonGameOptions["scatterToFreespins"]
|
|
183
|
-
padSymbols?: CommonGameOptions["padSymbols"]
|
|
184
|
-
maxWinX: CommonGameOptions["maxWinX"]
|
|
185
|
-
userState?: TUserState
|
|
186
|
-
hooks: CommonGameOptions<TGameModes, TSymbols, TUserState>["hooks"]
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export function createSlotGame<TGame>(
|
|
190
|
-
opts: TGame extends InferGameType<infer G, infer S, infer U>
|
|
191
|
-
? CreateSlotGameOpts<G, S, U>
|
|
192
|
-
: never,
|
|
193
|
-
) {
|
|
194
|
-
return new SlotGame(opts) as TGame
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export const defineUserState = <TUserState extends AnyUserData>(data: TUserState) => data
|
|
198
|
-
|
|
199
|
-
export const defineSymbols = <TSymbol extends GameSymbol>(symbols: TSymbol[]) => symbols
|
|
200
|
-
|
|
201
|
-
export const defineGameModes = <TGameModes extends AnyGameModes>(gameModes: TGameModes) =>
|
|
202
|
-
gameModes
|
|
203
|
-
|
|
204
|
-
export const defineReelSets = <TSymbols extends AnySymbols>(reelSets: ReelGenerator[]) =>
|
|
205
|
-
reelSets
|
package/lib/zstd.exe
DELETED
|
Binary file
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
[package]
|
|
2
|
-
name = "PigFarmRust"
|
|
3
|
-
version = "0.1.0"
|
|
4
|
-
edition = "2021"
|
|
5
|
-
|
|
6
|
-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
7
|
-
|
|
8
|
-
[dependencies]
|
|
9
|
-
serde = { version = "1.0", features = ["derive"] }
|
|
10
|
-
serde_json = "1.0"
|
|
11
|
-
csv = "1.1"
|
|
12
|
-
rust_decimal = "1.11.0"
|
|
13
|
-
rayon = "1.5"
|
|
14
|
-
rand = "0.8.4"
|
|
15
|
-
ndarray = "0.15.3"
|
|
16
|
-
rand_distr = "0.4.2"
|
|
17
|
-
rand_pcg = "0.2"
|
|
18
|
-
|
|
19
|
-
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
use csv::ReaderBuilder;
|
|
2
|
-
use serde::{Deserialize, Serialize};
|
|
3
|
-
use serde_json;
|
|
4
|
-
use std::error::Error;
|
|
5
|
-
use std::path::{Path};
|
|
6
|
-
use std::{collections::HashMap, fs::File};
|
|
7
|
-
|
|
8
|
-
////////////////////////////////////
|
|
9
|
-
/// JSON STRUCTS
|
|
10
|
-
////////////////////////////////////
|
|
11
|
-
|
|
12
|
-
// Search Key STRUCTS
|
|
13
|
-
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
14
|
-
pub struct SearchKey {
|
|
15
|
-
pub name: String,
|
|
16
|
-
pub value: String,
|
|
17
|
-
}
|
|
18
|
-
// FORCE RESULT STRUCTS
|
|
19
|
-
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
20
|
-
pub struct SearchResult {
|
|
21
|
-
// Each key maps to a vector of serde_json::Value to accommodate different types.
|
|
22
|
-
pub search: Vec<SearchKey>,
|
|
23
|
-
pub timesTriggered: u32,
|
|
24
|
-
pub bookIds: Vec<u32>,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// FORCE RESULT STRUCTS
|
|
28
|
-
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
29
|
-
pub struct IdentityCondition {
|
|
30
|
-
pub search: Vec<SearchKey>,
|
|
31
|
-
pub opposite: bool,
|
|
32
|
-
pub win_range_start: f64,
|
|
33
|
-
pub win_range_end: f64,
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// CONFIG FILE STRUCTS
|
|
37
|
-
|
|
38
|
-
#[derive(Debug, Deserialize, Serialize)]
|
|
39
|
-
pub struct BetMode {
|
|
40
|
-
pub bet_mode: String,
|
|
41
|
-
pub cost: f64,
|
|
42
|
-
pub rtp: f64,
|
|
43
|
-
pub max_win: f64,
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
47
|
-
pub struct FenceJson {
|
|
48
|
-
pub name: String,
|
|
49
|
-
pub hr: Option<String>, // Option, as it can be a number or a string "x"
|
|
50
|
-
pub rtp: Option<String>,
|
|
51
|
-
pub avg_win: Option<String>,
|
|
52
|
-
pub identity_condition: IdentityCondition,
|
|
53
|
-
pub min_mean_to_median: Option<String>,
|
|
54
|
-
pub max_mean_to_median: Option<String>,
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
#[derive(Debug, Deserialize, Serialize)]
|
|
58
|
-
pub struct FencesInfo {
|
|
59
|
-
pub bet_mode: String,
|
|
60
|
-
pub fences: Vec<FenceJson>,
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
#[derive(Debug, Deserialize, Serialize)]
|
|
64
|
-
pub struct DressJson {
|
|
65
|
-
pub fence: String,
|
|
66
|
-
pub scale_factor: String,
|
|
67
|
-
pub identity_condition_force: Option<String>, // Dynamic value (can be a string or an array)
|
|
68
|
-
pub identity_condition_win_range: Option<[f64; 2]>, // Optional field (can be a range of numbers or null)
|
|
69
|
-
pub prob: Option<f64>, // Optional field (can be a number or null)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
#[derive(Debug, Deserialize, Serialize)]
|
|
73
|
-
pub struct DressesInfo {
|
|
74
|
-
pub bet_mode: String,
|
|
75
|
-
pub dresses: Vec<DressJson>,
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
#[derive(Debug, Deserialize, Serialize)]
|
|
79
|
-
pub struct ConfigData {
|
|
80
|
-
pub game_id: String,
|
|
81
|
-
pub bet_modes: Vec<BetMode>,
|
|
82
|
-
pub fences: Vec<FencesInfo>,
|
|
83
|
-
pub dresses: Vec<DressesInfo>,
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// LOOK UP TABLE STRUCT
|
|
87
|
-
#[derive(Debug, Deserialize)]
|
|
88
|
-
pub(crate) struct LookUpTableEntry {
|
|
89
|
-
pub id: u32,
|
|
90
|
-
pub weight: u64,
|
|
91
|
-
pub win: f64,
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
//Integer payout values
|
|
95
|
-
#[derive(Debug, Deserialize)]
|
|
96
|
-
pub(crate) struct LookUpTableInput {
|
|
97
|
-
pub id: u32,
|
|
98
|
-
pub weight: u64,
|
|
99
|
-
pub win: u64,
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
////////////////////////////////////
|
|
103
|
-
/// FUNCTIONS TO LOAD CONFIG FILES
|
|
104
|
-
////////////////////////////////////
|
|
105
|
-
|
|
106
|
-
pub(crate) fn load_force_options(
|
|
107
|
-
game_name: &str,
|
|
108
|
-
bet_type: &str,
|
|
109
|
-
user_game_build_path: String,
|
|
110
|
-
) -> Vec<SearchResult> {
|
|
111
|
-
let file_path = Path::new(&user_game_build_path)
|
|
112
|
-
.join(format!("force_record_{}.json", bet_type));
|
|
113
|
-
let json_file_path = Path::new(&file_path);
|
|
114
|
-
let file = File::open(json_file_path).expect("Unable to open force file");
|
|
115
|
-
println!("json force path: {}", json_file_path.display());
|
|
116
|
-
let search_results: Vec<SearchResult> =
|
|
117
|
-
serde_json::from_reader(file).expect("error while reading or parsing");
|
|
118
|
-
return search_results;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
pub(crate) fn load_config_data(game_name: &str, user_game_build_path: String) -> ConfigData {
|
|
122
|
-
let file_path = Path::new(&user_game_build_path)
|
|
123
|
-
.join("math_config.json");
|
|
124
|
-
let json_file_path = Path::new(&file_path);
|
|
125
|
-
let file = File::open(json_file_path).expect("Unable to open force file");
|
|
126
|
-
let config_data: ConfigData =
|
|
127
|
-
serde_json::from_reader(file).expect("error while reading or parsing");
|
|
128
|
-
return config_data;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
pub(crate) fn read_look_up_table(
|
|
132
|
-
game_name: &str,
|
|
133
|
-
bet_type: &str,
|
|
134
|
-
user_game_build_path: String,
|
|
135
|
-
) -> Result<HashMap<u32, LookUpTableEntry>, Box<dyn Error>> {
|
|
136
|
-
let file_path = Path::new(&user_game_build_path)
|
|
137
|
-
.join(format!("lookUpTable_{}.csv", bet_type));
|
|
138
|
-
let csv_file_path = Path::new(&file_path);
|
|
139
|
-
let file = File::open(csv_file_path)?;
|
|
140
|
-
let mut rdr = ReaderBuilder::new().has_headers(false).from_reader(file);
|
|
141
|
-
|
|
142
|
-
let mut lookup_table: HashMap<u32, LookUpTableEntry> = HashMap::new();
|
|
143
|
-
|
|
144
|
-
for result in rdr.deserialize() {
|
|
145
|
-
let record: LookUpTableInput = result?;
|
|
146
|
-
let record_float = LookUpTableEntry{
|
|
147
|
-
id: record.id,
|
|
148
|
-
weight: record.weight,
|
|
149
|
-
win: record.win as f64 / 100.0};
|
|
150
|
-
lookup_table.insert(record.id, record_float);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
Ok(lookup_table)
|
|
154
|
-
}
|