123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- /* Import modules. */
- import { defineStore } from 'pinia'
- import { v4 as uuidv4 } from 'uuid'
- import _newGame from './game/new.ts'
- import _rollDice from './game/rollDice.ts'
- /**
- * Game Store
- */
- export const useGameStore = defineStore('game', {
- state: () => ({
- _playid: null,
- _authHash: null,
- _address: null,
- _payout: null,
- _seed: null,
- _position: null,
- _satoshis: null,
- }),
- getters: {
- playid(_state) {
- return _state._playid
- },
- authHash(_state) {
- return _state._authHash
- },
- gameid(_state) {
- return '6b7d9eaf-9a3b-488e-bc0a-1c14d5f1aafd' // Wally Dice
- },
- /* Set Return To Player (RTP) value (as a percentage %). */
- // NOTE: Maximum RTP must not exceed 99.0%.
- // NOTE: Minimum RTP must be at least 95.0%.
- rtp(_state) {
- return 97.0 // 97% return to player
- },
- payout(_state) {
- return _state._payout
- },
- address(_state) {
- return _state._address
- },
- seed(_state) {
- return _state._seed
- },
- position(_state) {
- return _state._position
- },
- satoshis(_state) {
- return _state._satoshis
- },
- },
- actions: {
- async init() {
- /* Reset gameplay.*/
- this.resetGameplay()
- },
- newGame() {
- /* Start new game. */
- _newGame.bind(this)()
- },
- setPlayid(_playid) {
- this._playid = _playid
- },
- setAuthHash(_authHash) {
- this._authHash = _authHash
- },
- setAddress(_address) {
- this._address = _address
- },
- setSatoshis(_satoshis) {
- this._satoshis = _satoshis
- },
- rollDice() {
- /* Roll dice. */
- _rollDice.bind(this)()
- },
- resetGameplay() {
- this._authHash = null
- this._address = null
- this._playid = null
- this._payout = null
- this._seed = uuidv4()
- this._position = null
- },
- deleteSession() {
- /* Reset session. */
- this._session = null
- },
- },
- })
|