1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- /**@description 自动数据模型 */
- export default class DFortuneAutoModel {
- private _isAuto: boolean = false
- set isAuto(b: boolean) { this._isAuto = b }
- get isAuto() { return this._isAuto }
- round: number = 0
- loseLimt: number = 0
- winLimt: number = 0
- winMaxLimit: number = 0 //一次赢多少钱后结束
- //当前输赢 / 从自动开始计算,需要减去bet的值
- curLoseWin: number = 0
- bet: number = 0
- constructor() {
- this.clear()
- }
- /**@description 转动之后调用 */
- updateRound() {
- this.round > 0 && this.round--
- }
- /**
- * @description 传入一次完整的转动最后获得的钱,未赢则传0
- * @param win
- */
- addWinScore(win: number) {
- if (this.winMaxLimit && win > this.winMaxLimit) {
- this.isAuto = false
- }
- this.curLoseWin += (win - this.bet)
- }
- /**@description 检测是否继续auto */
- checkAuto(userCoin: number) {
- cc.log('当前自动数据:', this.round, this.curLoseWin)
- if (!this.isAuto) return false
- if (userCoin < this.bet) return false
- if (this.round <= 0) return
- if (this.curLoseWin + this.loseLimt <= 0) {
- return false
- }
- if (this.winLimt && this.curLoseWin >= this.winLimt) {
- return false
- }
- return true
- }
- setAutoData(data: NSlots.IAutoData) {
- cc.log('自动数据:', data)
- if (!data) return
- this.bet = data?.bet || 0
- this.round = data?.round || 0
- this.loseLimt = data?.loseLimit || 0
- this.winLimt = data?.winLimit || 0
- this.winMaxLimit = data?.maxLimit || 0
- this.isAuto = this.round > 0 && this.loseLimt > 0
- }
- clear() {
- this.round = 0
- this.curLoseWin = 0
- this.loseLimt = 0
- this.winLimt = 0
- this.winMaxLimit = 0
- this.isAuto = false
- }
- }
|