pixi-rainman-game-engine 0.1.1 → 0.1.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 CHANGED
@@ -6,9 +6,65 @@ This repository contains all of the mechanics that used in rainMan games. This l
6
6
 
7
7
  1. To build library
8
8
  ```sh
9
- npm run build
9
+ yarn build
10
10
  ```
11
- 2. Lint project
11
+ 2. To build library during development
12
+
13
+ ```sh
14
+ yarn dev:build
15
+ ```
16
+
17
+ Modifying css files does not automatically reload server, after each change manual restart is needed.
18
+
19
+ To have live updates in one of the games, link is recommended:
20
+
21
+ ```shell
22
+ yarn dev:link
23
+ ```
24
+
25
+ After that you can use following command in one of the games. If there will be problems or the changes will not reflect in the game, uninstalling npm package may be needed.
26
+
27
+ ```sh
28
+ yarn remove pixi-rainman-game-engine
29
+ npm link pixi-rainman-game-engine
30
+ ```
31
+
32
+ By using package from npm, in vite optimizeDeps you must exclude this package, but must include each package that throws error in the console. This is probably due to problem with [excluding commonJS dependencies](https://vitejs.dev/config/dep-optimization-options#optimizedeps-exclude). An example is below.
33
+
34
+ ```ts
35
+ defineConfig({
36
+ optimizeDeps: {
37
+ include: [
38
+ "ts-money",
39
+ "adaptive-scale/lib",
40
+ "stats.js",
41
+ "url",
42
+ "eventemitter3",
43
+ "earcut",
44
+ "react",
45
+ "react-dom",
46
+ "use-sync-external-store/shim",
47
+ "classnames",
48
+ "react-is",
49
+ "react-custom-scroll",
50
+ "react-dom/client",
51
+ ],
52
+ exclude: ["pixi-rainman-game-engine"],
53
+ },
54
+ });
55
+ ```
56
+
57
+ For each error in the console, e.g.:
58
+
59
+ ```
60
+ Uncaught SyntaxError: The requested module '/node_modules/eventemitter3/index.js?v=ec22a584' does not provide an export named 'default'
61
+ ```
62
+
63
+ you must include it in the optimizeDeps.include array. Typically it is the name after /node_modules/.
64
+
65
+ **On the other hand, when linking package with npm link, the whole optimizeDeps.include an optimzieDeps.exclude should be commented out.**
66
+
67
+ 3. Lint project
12
68
  ```sh
13
69
  npm run lint
14
70
  ```
@@ -22,4 +78,4 @@ In utils directory there all of the utility functions and types.
22
78
  ### Test environment
23
79
 
24
80
  To simulate behavior of game engine mechanics, this repository contains react-pixi app, where you can test features that are included in game engine.
25
- Test environment uses local built of game engine. To setup test environment go to [README](./src/test-environment/README.md) of test environment.
81
+ Test environment uses local built of game engine. To setup test environment go to [README](./test-environment/README.md) of test environment.
@@ -8,7 +8,7 @@ import { useStores } from "../../hooks";
8
8
  const handleStyle = { width: "7px", height: "24px", bottom: "-6px", borderRadius: "4px" };
9
9
  const onChange = (newVolumeLevel) => {
10
10
  RainMan.settingsStore.setVolumeLevel(newVolumeLevel);
11
- RainMan.settingsStore.setIsSoundEnabled(newVolumeLevel > 0 && !RainMan.settingsStore.isSoundEnabled);
11
+ RainMan.settingsStore.setIsSoundEnabled(newVolumeLevel > 0);
12
12
  };
13
13
  export const VolumeSettings = observer(() => {
14
14
  const { settingStore } = useStores();
@@ -81,7 +81,7 @@ export class ButtonsEventManager {
81
81
  }
82
82
  setUpUIElementsInteractivity() {
83
83
  const animatedBackground = RainMan.componentRegistry.get(Background.registryName);
84
- animatedBackground.interactive = true;
84
+ animatedBackground.eventMode = "static";
85
85
  animatedBackground.addListener("pointerdown", () => {
86
86
  if (hideLayerIfPresent() && !RainMan.settingsStore.isAutoplayEnabled) {
87
87
  this.enableButtons();
@@ -110,8 +110,9 @@ export class ButtonsEventManager {
110
110
  ?.setOnClick(() => this.handleModalInvocation(UI_ITEMS.freeSpin));
111
111
  }
112
112
  initVolumeButtonEvent() {
113
+ RainMan.settingsStore.setUpdateVolumeButtonTexture(() => RainMan.componentRegistry.get(VolumeButton.registryName).changeTextureDependOnVolume());
113
114
  RainMan.componentRegistry.get(VolumeButton.registryName).setOnClick(() => {
114
- RainMan.settingsStore.setIsSoundEnabled(RainMan.settingsStore.volumeLevel > 0 && !RainMan.settingsStore.isSoundEnabled);
115
+ RainMan.settingsStore.setIsSoundEnabled(!RainMan.settingsStore.isSoundEnabled);
115
116
  RainMan.componentRegistry.get(VolumeButton.registryName).changeTextureDependOnVolume();
116
117
  this.handleModalInvocation(UI_ITEMS.volume);
117
118
  });
@@ -7,7 +7,7 @@ export class AbstractFreeSpinContainer extends Container {
7
7
  scaleMultiplier = 1;
8
8
  constructor() {
9
9
  super();
10
- this.interactive = true;
10
+ this.eventMode = "static";
11
11
  this.shownAt = performance.now();
12
12
  this.parentLayer = UXLayer;
13
13
  }
@@ -80,7 +80,7 @@ export class AbstractMainContainer extends Container {
80
80
  this.overlay.parentLayer = UXLayer;
81
81
  this.overlay.beginFill(0x000000, 0.5);
82
82
  this.overlay.drawRect(0, 0, width, height);
83
- this.overlay.interactive = true;
83
+ this.overlay.eventMode = "static";
84
84
  this.overlay.endFill();
85
85
  this.addChild(this.overlay);
86
86
  }
@@ -72,7 +72,7 @@ export class BaseButton extends Sprite {
72
72
  }
73
73
  flipDisabledFlag(makeDisabled) {
74
74
  this.isDisabled = makeDisabled;
75
- this.interactive = !makeDisabled;
75
+ this.eventMode = makeDisabled ? "auto" : "static";
76
76
  this.tint = makeDisabled ? TINT_DISABLED : TINT_ENABLED;
77
77
  }
78
78
  switchTexture(state) {
@@ -16,13 +16,13 @@ export class VolumeButton extends BaseButton {
16
16
  [ButtonStates.OVER]: getTexture("mute-h.png"),
17
17
  [ButtonStates.CLICKED]: getTexture("mute-c.png"),
18
18
  };
19
- const isSoundEnabled = RainMan.settingsStore.volumeLevel > 0 && RainMan.settingsStore.isSoundEnabled;
19
+ const isSoundEnabled = RainMan.settingsStore.isSoundEnabled;
20
20
  super(VolumeButton.registryName, isSoundEnabled ? normalTextureMap : muteTextureMap);
21
21
  this.normalTextureMap = normalTextureMap;
22
22
  this.muteTextureMap = muteTextureMap;
23
23
  }
24
24
  changeTextureDependOnVolume() {
25
- if (RainMan.settingsStore.volumeLevel > 0 && RainMan.settingsStore.isSoundEnabled) {
25
+ if (RainMan.settingsStore.isSoundEnabled) {
26
26
  this.texture = this.normalTextureMap.NORMAL;
27
27
  this.textures = this.normalTextureMap;
28
28
  }
@@ -16,7 +16,7 @@ export class FreeSpinBox extends ResumableContainer {
16
16
  this.spine.state.addAnimation(0, "freeBox", true, 0);
17
17
  this.spine.state.timeScale = 1;
18
18
  this.addChild(this.spine);
19
- this.interactive = true;
19
+ this.eventMode = "static";
20
20
  this.x = 0;
21
21
  this.y = 0;
22
22
  }
@@ -24,8 +24,7 @@ export class FreeSpinBox extends ResumableContainer {
24
24
  this.addListener("pointerdown", onClick);
25
25
  }
26
26
  setInteractivity(newValue) {
27
- this.interactive = newValue;
28
- this.interactiveChildren = newValue;
27
+ this.eventMode = newValue ? "static" : "auto";
29
28
  this.spine.tint = Number(newValue ? TINT_ENABLED : TINT_DISABLED);
30
29
  }
31
30
  }
@@ -25,7 +25,7 @@ export class AbstractSymbolBase extends Container {
25
25
  this.setSymbol(symbolId);
26
26
  this.spine.x = 0;
27
27
  this.spine.y = 0;
28
- this.interactive = true;
28
+ this.eventMode = "static";
29
29
  const symbolRadius = 150;
30
30
  this.hitArea = new Rectangle(-symbolRadius, -symbolRadius, 2 * symbolRadius, 2 * symbolRadius);
31
31
  this.setupClickListener();
@@ -34,7 +34,7 @@ export class AbstractSymbolBase extends Container {
34
34
  return this._id;
35
35
  }
36
36
  setInteractiveFlag(flag) {
37
- this.interactive = flag;
37
+ this.eventMode = flag ? "static" : "auto";
38
38
  }
39
39
  updateTimeScaleOfSpine(scale = 0) {
40
40
  this.animationSpeedMultiplier = scale;
@@ -4,7 +4,7 @@ import { DropTransformationDetails, SymbolReel } from "../../connectivity";
4
4
  import { AbstractColumnsContainer, AbstractFrame } from "../frame";
5
5
  import { AbstractSymbolBase } from "./AbstractSymbolBase";
6
6
  export declare abstract class AbstractSymbolsColumn extends Container implements SpeedAdapterInterface<number> {
7
- private columnsContainer;
7
+ protected columnsContainer: AbstractColumnsContainer;
8
8
  protected allSymbols: SymbolId[];
9
9
  spinning: boolean;
10
10
  speedLevelMapper: import("../../application").SpeedLevelDirectory<number>;
@@ -29,6 +29,7 @@ export declare abstract class AbstractSymbolsColumn extends Container implements
29
29
  private spinEndPromise;
30
30
  protected abstract symbolTopOffset: number;
31
31
  skipHidingMysteryFx: boolean;
32
+ protected abstract bonusSymbol: SymbolId;
32
33
  private readonly _id;
33
34
  protected constructor(id: string, columnsContainer: AbstractColumnsContainer, allSymbols: SymbolId[]);
34
35
  protected abstract get tileHeight(): number;
@@ -51,7 +52,7 @@ export declare abstract class AbstractSymbolsColumn extends Container implements
51
52
  handleMultipleSymbolDropping(transformations: DropTransformationDetails[], skipAnimation?: boolean): Promise<void>;
52
53
  private changePhase;
53
54
  private moveToTop;
54
- protected abstract shouldPlaySpecialRollStopSound(): boolean;
55
+ protected shouldPlaySpecialRollStopSound(): boolean;
55
56
  handleStopping(): void;
56
57
  protected abstract createNewSymbol(): AbstractSymbolBase;
57
58
  private initSymbolSprites;
@@ -289,12 +289,25 @@ export class AbstractSymbolsColumn extends Container {
289
289
  this.ensureTopOffset();
290
290
  this.swapSymbolFace(symbol);
291
291
  }
292
+ shouldPlaySpecialRollStopSound() {
293
+ for (let i = 0; i <= RainMan.config.numberOfColumns; i++) {
294
+ const currentColumn = this.columnsContainer.getColumnAtPosition(i);
295
+ const hasBonus = !!currentColumn.symbols
296
+ .toSpliced(RainMan.config.numberOfRows, 1)
297
+ .find((symbol) => symbol.id === this.bonusSymbol);
298
+ if (hasBonus && currentColumn === this)
299
+ return true;
300
+ if (!hasBonus)
301
+ return false;
302
+ }
303
+ return false;
304
+ }
292
305
  handleStopping() {
293
306
  if (!this.topMostSymbol || this.phase === Phase.END)
294
307
  return;
295
308
  if (this.topMostSymbol.y >= this.tileHeight / 2) {
296
309
  if (!this.columnsContainer.quickReelsStop && RainMan.settingsStore.currentSpeed !== SPEED_LEVELS.fast)
297
- SoundManager.play(this.shouldPlaySpecialRollStopSound() ? SoundTracks.rollStop : SoundTracks.rollStop);
310
+ SoundManager.play(this.shouldPlaySpecialRollStopSound() ? SoundTracks.bonus : SoundTracks.rollStop);
298
311
  this.fixStationaryPositions();
299
312
  this.doStop();
300
313
  return;
@@ -33,6 +33,7 @@ export declare class SettingsStore {
33
33
  popupPaytableData?: PaytableData[];
34
34
  currentSpeed: SpeedLevel;
35
35
  popupPaytableRepositionCallback?: () => void;
36
+ updateVolumeButtonTexture?: () => void;
36
37
  private readonly initialAutoplaySettingsState;
37
38
  private modalsAvailable;
38
39
  private paytableMap;
@@ -55,6 +56,7 @@ export declare class SettingsStore {
55
56
  setBalancedDecreased(newValue: number): void;
56
57
  setDataForSymbolPaytablePopup(symbolId: SymbolId, repositionCallback: () => void): void;
57
58
  resetDataForSymbolPaytablePopup(): void;
59
+ setUpdateVolumeButtonTexture(fn: () => void): void;
58
60
  repositionSymbolPaytablePopup(x: number, y: number): void;
59
61
  initPaytableMap(initConfigData: InitDataInterface): void;
60
62
  decreaseAutoSpinsCount(): void;
@@ -36,6 +36,7 @@ export class SettingsStore {
36
36
  popupPaytableData;
37
37
  currentSpeed = "slow";
38
38
  popupPaytableRepositionCallback;
39
+ updateVolumeButtonTexture;
39
40
  initialAutoplaySettingsState = {
40
41
  infinitySpinsEnabled: false,
41
42
  onAnyWin: false,
@@ -183,6 +184,9 @@ export class SettingsStore {
183
184
  this.popupPaytableData = undefined;
184
185
  this.popupPaytableRepositionCallback = undefined;
185
186
  }
187
+ setUpdateVolumeButtonTexture(fn) {
188
+ this.updateVolumeButtonTexture = fn;
189
+ }
186
190
  repositionSymbolPaytablePopup(x, y) {
187
191
  this.popupPaytablePosition = { x, y };
188
192
  }
@@ -254,6 +258,7 @@ export class SettingsStore {
254
258
  }
255
259
  setIsSoundEnabled(flag) {
256
260
  this.isSoundEnabled = flag;
261
+ this.updateVolumeButtonTexture?.();
257
262
  setToLocalStorage(LOCAL_STORAGE.isSoundEnabled, flag);
258
263
  }
259
264
  getMysteryPaytable(mysterySymbol, quantity = 3) {
@@ -1,6 +1,6 @@
1
- import { Graphics } from "pixi.js";
1
+ import { ColorSource, Graphics } from "pixi.js";
2
2
  export declare class PositioningFrame extends Graphics {
3
- private readonly backgroundColor;
4
- constructor(frameWidth: number, frameHeight: number, color: number);
3
+ private backgroundColor;
4
+ constructor(frameWidth: number, frameHeight: number, backgroundColor: ColorSource);
5
5
  resize(frameWidth: number, frameHeight: number): void;
6
6
  }
@@ -1,11 +1,11 @@
1
1
  import { Graphics } from "pixi.js";
2
2
  export class PositioningFrame extends Graphics {
3
3
  backgroundColor;
4
- constructor(frameWidth, frameHeight, color) {
4
+ constructor(frameWidth, frameHeight, backgroundColor) {
5
5
  super();
6
- this.backgroundColor = color;
6
+ this.backgroundColor = backgroundColor;
7
7
  this.resize(frameWidth, frameHeight);
8
- this.interactive = true;
8
+ this.eventMode = "static";
9
9
  }
10
10
  resize(frameWidth, frameHeight) {
11
11
  this.x = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixi-rainman-game-engine",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
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",
@@ -8,7 +8,7 @@
8
8
  "scripts": {
9
9
  "copyCss": "copyfiles -u 1 \"src/**/*.css\" dist/",
10
10
  "build": "rimraf dist/ && tsc && yarn copyCss",
11
- "dev:build": "tsc-watch",
11
+ "dev:build": "tsc-watch --onSuccess \"yarn copyCss\"",
12
12
  "dev:link": "npm link && cd test-environment && npm link pixi-rainman-game-engine",
13
13
  "dev:server": "cd test-environment && yarn dev",
14
14
  "lint": "eslint src/** --fix",