-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use import instead of DB for constant achievement definitions
- Loading branch information
1 parent
5fc34b0
commit 7d001f4
Showing
9 changed files
with
101 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,30 @@ | ||
import type { GameStateMachine } from '@paima/sm'; | ||
import type { AchievementMetadata } from '@paima/utils-backend'; | ||
|
||
export class EngineService { | ||
public static INSTANCE = new EngineService(); | ||
// Useful stuff | ||
readonly stateMachine: GameStateMachine; | ||
readonly achievements: Promise<AchievementMetadata> | null; | ||
|
||
private runtime: GameStateMachine | undefined = undefined; | ||
constructor(alike: { | ||
readonly stateMachine: GameStateMachine; | ||
readonly achievements: Promise<AchievementMetadata> | null; | ||
}) { | ||
this.stateMachine = alike.stateMachine; | ||
this.achievements = alike.achievements; | ||
} | ||
|
||
getSM = (): GameStateMachine => { | ||
if (this.runtime == null) { | ||
throw new Error('EngineService: SM not initialized'); | ||
} | ||
return this.runtime; | ||
}; | ||
getSM = () => this.stateMachine; | ||
|
||
updateSM = (runtime: GameStateMachine): void => { | ||
this.runtime = runtime; | ||
}; | ||
// Singleton | ||
private static _instance?: EngineService; | ||
static get INSTANCE(): EngineService { | ||
if (!this._instance) { | ||
throw new Error('EngineService not initialized'); | ||
} | ||
return this._instance; | ||
} | ||
static set INSTANCE(value: EngineService) { | ||
this._instance = value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 0 additions & 51 deletions
51
packages/node-sdk/paima-db/src/sql/achievements.queries.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters