pixi-rainman-game-engine 0.2.29 → 0.3.0
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.
|
@@ -3,7 +3,7 @@ import { Application } from "pixi.js";
|
|
|
3
3
|
import { SymbolIds, WinTypeIds } from "../application";
|
|
4
4
|
import { ComponentRegistry } from "../ComponentRegistry";
|
|
5
5
|
import { SettingsStore } from "../stores";
|
|
6
|
-
import {
|
|
6
|
+
import { AppConfigWithoutToken, Globals, OptionalAppConfig, RequiredAppConfig } from "./types";
|
|
7
7
|
/**
|
|
8
8
|
* This class represents Pixi application. Before initializing game, user has to configure following:
|
|
9
9
|
* - {@link Application}
|
|
@@ -20,5 +20,10 @@ export declare class RainMan {
|
|
|
20
20
|
static settingsStore: SettingsStore;
|
|
21
21
|
static componentRegistry: ComponentRegistry;
|
|
22
22
|
static globals: Globals;
|
|
23
|
-
constructor(app: Application, config:
|
|
23
|
+
constructor(app: Application, config: AppConfigWithoutToken, symbolIds: SymbolIds, winTypeIds: WinTypeIds);
|
|
24
|
+
/**
|
|
25
|
+
* Method for genereting a token or getting existing token for the game session.
|
|
26
|
+
* @returns {string} - token for the game session
|
|
27
|
+
*/
|
|
28
|
+
private getToken;
|
|
24
29
|
}
|
package/dist/Rainman/Rainman.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "../components/dictionary/i18n";
|
|
2
2
|
import { merge } from "lodash";
|
|
3
3
|
import { Currencies } from "ts-money";
|
|
4
|
+
import uuid4 from "uuid4";
|
|
4
5
|
import { ComponentRegistry } from "../ComponentRegistry";
|
|
5
6
|
import { settingStore } from "../SettingsUI/hooks";
|
|
6
7
|
import { defaultAppConfig } from "./appConfig";
|
|
@@ -22,7 +23,9 @@ export class RainMan {
|
|
|
22
23
|
static globals;
|
|
23
24
|
constructor(app, config, symbolIds, winTypeIds) {
|
|
24
25
|
RainMan.app = app;
|
|
25
|
-
RainMan.config = merge(defaultAppConfig, config
|
|
26
|
+
RainMan.config = merge({}, defaultAppConfig, config, {
|
|
27
|
+
gameInitToken: this.getToken()
|
|
28
|
+
});
|
|
26
29
|
RainMan.symbolIds = symbolIds;
|
|
27
30
|
RainMan.winTypeIds = winTypeIds;
|
|
28
31
|
RainMan.settingsStore = settingStore;
|
|
@@ -32,4 +35,21 @@ export class RainMan {
|
|
|
32
35
|
shouldShowModals: false
|
|
33
36
|
};
|
|
34
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Method for genereting a token or getting existing token for the game session.
|
|
40
|
+
* @returns {string} - token for the game session
|
|
41
|
+
*/
|
|
42
|
+
getToken() {
|
|
43
|
+
const url = new URL(window.location.href);
|
|
44
|
+
let token = url.searchParams.get("token");
|
|
45
|
+
if (token) {
|
|
46
|
+
return token;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
token = uuid4();
|
|
50
|
+
url.searchParams.set("token", token);
|
|
51
|
+
window.history.replaceState({}, "", url.toString());
|
|
52
|
+
return token;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
35
55
|
}
|
package/dist/Rainman/types.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ export type OptionalAppConfig = {
|
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
64
|
export type AppConfig = RequiredAppConfig & DeepPartial<OptionalAppConfig>;
|
|
65
|
+
export type AppConfigWithoutToken = Omit<RequiredAppConfig, "gameInitToken"> & DeepPartial<OptionalAppConfig>;
|
|
65
66
|
/**
|
|
66
67
|
* This interface represents global variables in pixi application. Can be extended in `engine.d.ts` in each project to provide project-wide variables.
|
|
67
68
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pixi-rainman-game-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "This repository contains all of the mechanics that used in rainman games.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"react-dom": "^18.2.0",
|
|
39
39
|
"stats.js": "^0.17.0",
|
|
40
40
|
"ts-money": "^0.4.8",
|
|
41
|
+
"uuid4": "^2.0.3",
|
|
41
42
|
"zod": "^3.22.4"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"@types/react-custom-scroll": "^5.0.3",
|
|
48
49
|
"@types/react-dom": "^18.2.22",
|
|
49
50
|
"@types/stats.js": "^0.17.3",
|
|
51
|
+
"@types/uuid4": "^2.0.3",
|
|
50
52
|
"@types/web": "^0.0.199",
|
|
51
53
|
"@typescript-eslint/eslint-plugin": "^7.0.2",
|
|
52
54
|
"@typescript-eslint/parser": "^7.0.2",
|