/* 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 }, }, })