@urso/core 0.7.47 → 0.7.49

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urso/core",
3
- "version": "0.7.47",
3
+ "version": "0.7.49",
4
4
  "description": "HTML5 game engine",
5
5
  "main": "build/js/index.js",
6
6
  "author": "Megbrimef",
@@ -3,6 +3,12 @@ class ModulesStatesManagerConfigStates {
3
3
  this.singleton = true;
4
4
 
5
5
  this.contents = {
6
+ START_GAME: {
7
+ action: 'gameInit',
8
+ nextState: ["IDLE"], //next state to go after finish this state
9
+ callLimit: 1 //auto guard will return false, if limit is reached
10
+ },
11
+
6
12
  IDLE: { action: 'startSpin' },
7
13
 
8
14
  SPIN_START: {
@@ -18,6 +18,7 @@ class ModulesStatesManagerController {
18
18
 
19
19
  this._iterator; //will be defined after start
20
20
  this._nextState = this._nextState.bind(this);
21
+ this._statesCallStatistic = {};
21
22
  }
22
23
 
23
24
  start() {
@@ -117,6 +118,10 @@ class ModulesStatesManagerController {
117
118
 
118
119
  this._currentState = this._iterator.next();
119
120
 
121
+ //fill states call statistic
122
+ if (!this._statesCallStatistic[this._currentState]) this._statesCallStatistic[this._currentState] = 0;
123
+ this._statesCallStatistic[this._currentState]++;
124
+
120
125
  this.emit(Urso.events.MODULES_STATES_MANAGER_STATE_CHANGE, this._currentState);
121
126
 
122
127
  log('%c State ' + this._currentState, 'background: #bada55; color: #000')
@@ -176,6 +181,14 @@ class ModulesStatesManagerController {
176
181
  }
177
182
 
178
183
  checkStateGuard = (key) => {
184
+ //auto guard will check callLimit and return false, if limit is reached
185
+ const callLimit = this._configStates[key].callLimit;
186
+
187
+ if (
188
+ callLimit &&
189
+ callLimit >= (this._statesCallStatistic[key] || 0)
190
+ ) { return false; }
191
+
179
192
  const guardResult = this.statesGuards.checkGuard(key);
180
193
  log('%c State guard ' + key + ' is ' + guardResult, 'background: #DA55C4; color: #000')
181
194
  return guardResult;