add slot machine

balance, initialize, bet controller
This commit is contained in:
Nguyen Ngoc Thanh 2025-07-11 09:32:08 +07:00
parent 5139605454
commit 6311137fda
8 changed files with 477 additions and 1 deletions

View File

@ -3,6 +3,10 @@ id: intro
sidebar_position: 0
---
# Slot game API
# Slot Game API
## Slot Game Machine
* [Initialize Controller](slot-machine/initialize-controller)
* [Balance Controller](slot-machine/balance)
* [Bet Controller](slot-machine/bet-controller)
To be written

View File

@ -0,0 +1,17 @@
{
"position": 1,
"label": "Slot Game Machine",
"collapsible": true,
"collapsed": true,
"link": {
"type": "generated-index",
"title": "Slot Game Machine",
"description": "This section will guide you through the process of setting up a new project, including creating a new repository and configuring your development environment.",
"keywords": [
"controller",
"project",
"repository",
"development environment"
]
}
}

View File

@ -0,0 +1,18 @@
{
"position": 2,
"label": "Balance",
"collapsible": true,
"collapsed": true,
"link": {
"type": "generated-index",
"title": "Balance",
"description": "This section will guide you through the process of setting up a new project, including creating a new repository and configuring your development environment.",
"keywords": [
"controller",
"project",
"repository",
"model",
"balance"
]
}
}

View File

@ -0,0 +1,176 @@
---
sidebar_position: 2
---
# Balance Controller
## Index
### Properties
* [savedCurrentPoint](#savedcurrentpoint) `Number` Current played bet.
* [savedFreePoint](#savedfreepoint) `Number` Current free point played bet.
* [isResume](#isresume) `Boolean` Indicates whether the game current state is resuming or not.
### Methods
* [onReplayHistoryClient](#onreplayhistoryclient) Indicates the game current state is resuming.
* [onResume](#onresume) Indicates the game current state is resuming.
* [onResumeEnd](#isresumeend) Indicates the game current state isn't resuming.
* [onDeposit](#ondeposit) Update the client balance when user deposit.
* [onConnected](#onconnected) Update the client balance when the game is connected.
* [onStartGame](#onstartgame) Show the client balance when the game is started.
* [onCollectDataReceived](#oncollectdatareceived)Update the client balance when the game is collected.
* [onBalanceDataReceived](#onbalancedatareceived) Update the client balance when get new balance data.
* [onBalanceChangeRateClicked](#onbalancechangerateclicked) Change the client balance rate.
* [updateBalance](#updatebalance) Update the client balance.
* [notifyBalance](#notifyblance) Notify the client balance.
* [placeBet](#placebet) Set current client bet.
* [clearBet](#clearbet) Clear current client bet<br/><br/>
* [onSpinStart](#onspinstart) Update the client balance when user spin.
* [onReplayHistory](#onreplayhistory) Indicates the game current state is resuming.
* [onReplayHistoryEnd](#onreplayhistoryend) Indicates the game current state isn't resuming.
* [onFastPlayDataReceived](#onfastokaydatareceived) Update the client balance when user playing Fast Play.
## Details
#### savedCurrentPoint
> Current played bet.<br/>
| meta | description |
| :--- | :---------- |
| Type | [Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) |
| Defined in | [p4f-game-core/src/controller/balance-controller.js:12](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/controller/balance-controller.js#L12)|
#### savedFreePoint
> Current free point played bet.<br/>
| meta | description |
| :--- | :---------- |
| Type | [Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) |
| Defined in | [p4f-game-core/src/controller/balance-controller.js:13](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/controller/balance-controller.js#L13)|
#### isResume
> Indicates whether the game state is not resumed.<br/>
| meta | description |
| :--- | :---------- |
| Type | [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) |
| Defined in | [p4f-game-core/src/controller/balance-controller.js:14](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/controller/balance-controller.js#L14)|
#### onReplayHistoryClient
> Indicates the game current state is resuming.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/controller/balance-controller.js:28](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/controller/balance-controller.js#L28)|
#### onResume
> Indicates the game current state is resuming.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/controller/balance-controller.js:36](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/controller/balance-controller.js#L36)|
#### onResumeEnd
> Indicates the game current state isn't resuming.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/controller/balance-controller.js:44](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/controller/balance-controller.js#L44)|
#### onDeposit
> Update the client balance when user deposit.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/controller/balance-controller.js:52](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/controller/balance-controller.js#L52)|
#### onConnected
> Update the client balance when the game is connected.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/controller/balance-controller.js:82](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/controller/balance-controller.js#L82)|
#### onStartGame
> Show the client balance when the game is started.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/controller/balance-controller.js:90](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/controller/balance-controller.js#L90)|
#### onCollectDataReceived
> Update the client balance when the game is collected.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/controller/balance-controller.js:99](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/controller/balance-controller.js#L99)|
#### onBalanceDataReceived
> Update the client balance when get new balance data.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/controller/balance-controller.js:109](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/controller/balance-controller.js#L109)|
#### onBalanceChangeRateClicked
> Change the client balance rate.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/controller/balance-controller.js:117](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/controller/balance-controller.js#L117)|
#### updateBalance
> Update the client balance.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/controller/balance-controller.js:129](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/controller/balance-controller.js#L129)|
#### notifyBalance
> Notify the client balance.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/controller/balance-controller.js:141](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/controller/balance-controller.js#L141)|
#### placeBet
> Set current client bet.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/controller/balance-controller.js:151](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/controller/balance-controller.js#L151)|
#### clearBet
> Clear current client bet.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/controller/balance-controller.js:180](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/controller/balance-controller.js#L180)|
#### onSpinStart
> Update the client balance when user spin.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-slotty-core/src/controller/balance-controller.js:17](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/balance-controller.js#L17)|
#### onReplayHistory
> Indicates the game current state is resuming.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-slotty-core/src/controller/balance-controller.js:29](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/balance-controller.js#L29)|
#### onReplayHistoryEnd
>Indicates the game current state isn't resuming.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-slotty-core/src/controller/balance-controller.js:37](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/balance-controller.js#L37)|
#### onFastPlayDataReceived
> Update the client balance.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-slotty-core/src/controller/balance-controller.js:45](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/balance-controller.js#L45)|

View File

@ -0,0 +1,80 @@
---
sidebar_position: 2
---
# Balance Model
## Index
### Properties
* [currentPoint](#currentpoint) `Number` Current point.
* [freePoint](#freepoint) `Number` Current free point.
### Methods
* [SetCurrentPoint](#setcurrentpoint) Set current point.
* [GetCurrentPoint](#getcurrentpoint) Get current point.
* [SetFreePoint](#setfreepoint) Set current free point.
* [GetFreePoint](#getfreepoint) Get current free point.
* [GetAvailablePoint](#getavalablepoint) Get current point.
* [isNumber](#isnumber) Indicates whether the value is number or not.
## Details
#### currentPoint
> Current point.<br/>
| meta | description |
| :--- | :---------- |
| Type | [Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) |
| Defined in | [p4f-game-core/src/model/balance-model.js:8](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/model/balance-model.js#L9)|
#### freePoint
> Current free point.<br/>
| meta | description |
| :--- | :---------- |
| Type | [Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) |
| Defined in | [p4f-game-core/src/model/balance-model.js:9](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/model/balance-model.js#L9)|
#### SetCurrentPoint
> Set current point.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/model/balance-model.js:14](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/model/balance-model.js#L14)|
#### GetCurrentPoint
> Get current point.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/model/balance-model.js:21](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/model/balance-model.js#L21)|
#### SetFreePoint
> Set Current free point.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/model/balance-model.js:27](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/model/balance-model.js#L27)|
#### GetFreePoint
> Get current free point.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/model/balance-model.js:34](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/model/balance-model.js#L34)|
#### GetAvailablePoint
> Get current point.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/model/balance-model.js:40](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/model/balance-model.js#L40)|
#### isNumber
> Indicates whether the value is number or not.<br/>
| meta | description |
| :--- | :---------- |
| Type | [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) |
| Defined in | [p4f-game-core/src/model/balance-model.js:46](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/model/balance-model.js#L46)|

View File

@ -0,0 +1,19 @@
---
sidebar_position: 2
---
# Balance View
## Index
### Methods
* [BalanceChangeRate](#balancechangerate)
## Details
#### BalanceChangeRate
> ...
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-game-core/src/view/balance-view.js:12](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/view/balance-view.js#L11)|

View File

@ -0,0 +1,99 @@
---
sidebar_position: 3
---
# Bet Controller
## Index
### Properties
* [isHistoryActivated](#ishistoryactivated) `Boolean` Current played bet.
* [availablePoint](#availablepoint) `Number` Current played bet.
* [waiterAutoSpin](#waiterautospin) `Timer` Current played bet.
* [betProcessorFactory](#betprocessorfactory) `BetProcessorFactory` Current played bet.
* [betProcessor](#betprocessor) `BetProcessor` Current played bet.
### Methods
* [CalculateTotalBet](#calculatetotalbet) Register events to get data from server.
* [onChangeBetMode](#onchangebetmode) Start game when connected succesfully.
* [getClampedBet](#getclampedbet) Set resume data when connected server.
* [_start](#_start) Send request data to server.
* [_registerEvent](#_registerevent) Start game when connected succesfully with resume data.
* [_complete](#_complete) Start game when connected succesfully with resume data.
* [setBetPoints](#setbetpoints) Set resume data when connected server.
* [setBetPoint](#setbetpoint) Set resume data when connected server.
* [notifyBetDataChanged](#notifybetdatachanged) Set resume data when connected server.
* [onAutoSpinDeactivated](#onautospindeactivated) Set resume data when connected server.
* [onBetMultiplierReceived](#onbetmultiplierreceived) Set resume data when connected server.
* [onFreeroundsDataReceived](#onfreeroundsdatareceived) Set resume data when connected server.
* [onMiniGameDataReceived](#onminigamedatareceived) Set resume data when connected server.
* [onResumeOrReplayGameRound](#onresumeorreplaygameround) Set resume data when connected server.
* [onBalanceChanged](#onbalancechanged) Set resume data when connected server.
* [onReplayHistoryClient](#onreplayhistoryclient) Set resume data when connected server.
* [onResume](#onresume) Indicates the game current state is resuming.
* [onReplayHistory](#onreplayhistory) Indicates the game current state is resuming.
* [onHistoryActivated](#onhistoryactivated) Indicates the game current state is resuming.
* [onHistoryDeactivated](#onhistorydeactivated) Indicates the game current state is resuming.
* [onStartGame](#onstartgame) Show the client balance when the game is started.
* [onAutoSpinActivated](#onautospinactivated) Show the client balance when the game is started.
* [onSpinClicked](#onspinclicked) Show the client balance when the game is started.
* [onOutcomeSelected](#onoutcomeselected) Show the client balance when the game is started.
* [onBetPointChanged](#onbetpointchanged) Show the client balance when the game is started.
* [onBetMultiplierChanged](#onbetmultiplierchanged) Show the client balance when the game is started.
* [onPaylineCountChanged](#onpaylinecountchanged) Show the client balance when the game is started.
* [getTotalBetPoint](#gettotalbetpoint) Show the client balance when the game is started.
* [spin](#spin) Show the client balance when the game is started.
* [onManualBuyBonusOpened](#onmanualbuybonusopened) Show the client balance when the game is started.
* [onManualBuyBonusClosed](#onmanualbuybonusclosed) Show the client balance when the game is started.
* [onManualBuyBonusChanged](#onmanualbuybonuschanged) Show the client balance when the game is started.
* [setBetByPowerPlayModel](#setbetbypowerplaymodel) Show the client balance when the game is started.
## Details
#### isHistoryActivated
> Current played bet.<br/>
| meta | description |
| :--- | :---------- |
| Type | [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) |
| Defined in | [p4f-slotty-core/src/controller/bet-controller.js:35](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/bet-controller.js#L35)|
#### availablePoint
> Register events to get data from server.<br/>
| meta | description |
| :--- | :---------- |
| Type | [Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) |
| Defined in | [p4f-slotty-core/src/controller/bet-controller.js:36](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/bet-controller.js#L36)|
#### waiterAutoSpin
> Send request data to server.<br/>
| meta | description |
| :--- | :---------- |
| Type | [Timer](https://gitea.plp19.com/cocos-core/p4f-game-core/src/branch/develop/src/helper/timer.js#L4) |
| Defined in | [p4f-slotty-core/src/controller/bet-controller.js:37](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/bet-controller.js#L37)|
#### betProcessorFactory
> Set resume data when connected server.<br/>
| meta | description |
| :--- | :---------- |
| Type | [BetProcessorFactory](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/total-bet-processor/bet-processor-factory.js#L8) |
| Defined in | [p4f-slotty-core/src/controller/bet-controller.js:38](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/bet-controller.js#L38)|
#### betProcessor
> Set resume data when connected server.<br/>
| meta | description |
| :--- | :---------- |
| Type | [BetProcessor](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/total-bet-processor/bet-processor-factory.js#L30) |
| Defined in | [p4f-slotty-core/src/controller/bet-controller.js:39](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/bet-controller.js#L39)|
#### CalculateTotalBet
> Start game when connected succesfully.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-slotty-core/src/controller/bet-controller.js:44](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/bet-controller.js#L44)|

View File

@ -0,0 +1,63 @@
---
sidebar_position: 1
---
# Initialize Controller
## Index
### Properties
* [resumeData ](#resumedata) `Object` Current played bet.
### Methods
* [_registerEvent](#_registerevent) Register events to get data from server.
* [_start](#_start) Send request data to server.
* [onConnected](#onconnected) Set resume data when connected server.
* [onStartGame](#onstartgame) Start game when connected succesfully.
* [startResumeGame](#startresumegame) Start game when connected succesfully with resume data.
## Details
#### resumeData
> Current played bet.<br/>
| meta | description |
| :--- | :---------- |
| Type | [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) |
| Defined in | [p4f-slotty-core/src/controller/initialize-controller.js:12](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/initialize-controller.js#L12)|
#### _registerEvent
> Register events to get data from server.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-slotty-core/src/controller/initialize-controller.js:17](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/initialize-controller.js#L17)|
#### _start
> Send request data to server.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-slotty-core/src/controller/initialize-controller.js:24](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/initialize-controller.js#L24)|
#### onConnected
> Set resume data when connected server.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-slotty-core/src/controller/initialize-controller.js:32](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/initialize-controller.js#L32)|
#### onStartGame
> Start game when connected succesfully.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-slotty-core/src/controller/initialize-controller.js:38](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/initialize-controller.js#L38)|
#### startResumeGame
> Start game when connected succesfully with resume data.<br/>
| meta | description |
| :--- | :---------- |
| Defined in | [p4f-slotty-core/src/controller/initialize-controller.js:50](https://gitea.plp19.com/cocos-core/p4f-slotty-core/src/branch/develop/src/controller/initialize-controller.js#L50)|