MouseAutoModel.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**@description 自动数据模型 */
  2. export default class DFortuneAutoModel {
  3. private _isAuto: boolean = false
  4. set isAuto(b: boolean) { this._isAuto = b }
  5. get isAuto() { return this._isAuto }
  6. round: number = 0
  7. loseLimt: number = 0
  8. winLimt: number = 0
  9. winMaxLimit: number = 0 //一次赢多少钱后结束
  10. //当前输赢 / 从自动开始计算,需要减去bet的值
  11. curLoseWin: number = 0
  12. bet: number = 0
  13. constructor() {
  14. this.clear()
  15. }
  16. /**@description 转动之后调用 */
  17. updateRound() {
  18. this.round > 0 && this.round--
  19. }
  20. /**
  21. * @description 传入一次完整的转动最后获得的钱,未赢则传0
  22. * @param win
  23. */
  24. addWinScore(win: number) {
  25. if (this.winMaxLimit && win > this.winMaxLimit) {
  26. this.isAuto = false
  27. }
  28. this.curLoseWin += (win - this.bet)
  29. }
  30. /**@description 检测是否继续auto */
  31. checkAuto(userCoin: number) {
  32. cc.log('当前自动数据:', this.round, this.curLoseWin)
  33. if (!this.isAuto) return false
  34. if (userCoin < this.bet) return false
  35. if (this.round <= 0) return
  36. if (this.curLoseWin + this.loseLimt <= 0) {
  37. return false
  38. }
  39. if (this.winLimt && this.curLoseWin >= this.winLimt) {
  40. return false
  41. }
  42. return true
  43. }
  44. setAutoData(data: NSlots.IAutoData) {
  45. cc.log('自动数据:', data)
  46. if (!data) return
  47. this.bet = data?.bet || 0
  48. this.round = data?.round || 0
  49. this.loseLimt = data?.loseLimit || 0
  50. this.winLimt = data?.winLimit || 0
  51. this.winMaxLimit = data?.maxLimit || 0
  52. this.isAuto = this.round > 0 && this.loseLimt > 0
  53. }
  54. clear() {
  55. this.round = 0
  56. this.curLoseWin = 0
  57. this.loseLimt = 0
  58. this.winLimt = 0
  59. this.winMaxLimit = 0
  60. this.isAuto = false
  61. }
  62. }