RedBagCashData.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import { Data } from "../../../mk/data/Data";
  2. import { GameProp } from "../GameData";
  3. /**
  4. * 红包提现数据
  5. * - 跨Index不可提现,提示:请按顺序提现。
  6. * @author 薛鸿潇
  7. */
  8. export class RedBagCashData extends Data {
  9. /**
  10. * 数据初始化
  11. */
  12. public init() {
  13. // 签到配置表
  14. if (gData.gameData.configs.CashCfg) {
  15. gData.gameData.configs.CashCfg.forEach(item_data => {
  16. for (const key in item_data) {
  17. item_data[key] = parseInt(item_data[key])
  18. }
  19. });
  20. this.c_data = gData.gameData.configs.CashCfg;
  21. this.sortList();
  22. this.init_list = true;
  23. }
  24. this.cash_bar = gData.gameData.getProp(GameProp.redBag_cash_bar);
  25. // this.cash_bar = gData.gameData.gameData.cashIndex;// 服务端数据
  26. }
  27. /** 标志位:初始化列表 */
  28. public init_list: boolean = false;
  29. /** 配置表数据 */
  30. public c_data: Array<CDataType> = [];
  31. /** 标志位:初始化指定列表 */
  32. public old_index = null;
  33. /** 提现进度 */
  34. cash_bar: number = 0;
  35. /**
  36. * 提现操作
  37. */
  38. public cashOP() {
  39. /** 提现档位 */
  40. const cash_index = this.cash_bar;
  41. this.old_index = cash_index;
  42. this.cash_bar++;
  43. gData.gameData.setProp(GameProp.redBag_cash_bar, this.cash_bar);
  44. // 扣除红包
  45. this.sortList();
  46. let item_data = this.getItemDataByIndex(cash_index);
  47. gData.gameData.gameData.redMoney -= item_data.type_value;
  48. }
  49. /**
  50. * 排序
  51. * - 已提条目放最后
  52. */
  53. private sortList() {
  54. const l_count = this.c_data.length;
  55. for (let i = 0; i < l_count; i++) {
  56. if (this.c_data[i].index <= gData.redBagCash.cash_bar) {
  57. let item_data = this.c_data.splice(i, 1) as any;
  58. this.c_data.push(item_data);
  59. }
  60. }
  61. }
  62. /**
  63. * 获取条目,通过index
  64. * @param cash_index 对应id
  65. * @returns
  66. */
  67. private getItemDataByIndex(cash_index: number): CDataType {
  68. const l_count = this.c_data.length;
  69. for (let i = 0; i < l_count; i++) {
  70. if (this.c_data[i].index === cash_index) {
  71. return this.c_data[i]
  72. }
  73. }
  74. }
  75. // /** 客户端造的假数据 */
  76. // private initCData() {
  77. // for (let i = 0; i < 20; i++) {
  78. // const id = i + 1;
  79. // let obj = {
  80. // index: id,
  81. // /** 毛币数量? */
  82. // money: id,
  83. // /** 红包数量 */
  84. // type_value: id * 1000,
  85. // time: id,
  86. // directVideoTime: id,
  87. // delayVideoTimes: id,
  88. // money_type: id,
  89. // num: id,
  90. // moneyshow: id,
  91. // summoney: id
  92. // };
  93. // this.c_data.push(obj)
  94. // }
  95. // this.init_list = true;
  96. // }
  97. }
  98. /** 配置表数据内容 */
  99. export type CDataType = {
  100. /** id */
  101. index: number,
  102. /** 毛币数量,单位分 */
  103. money: number,
  104. /** 红包币数量 */
  105. type_value: number,
  106. time: number,
  107. directVideoTime: number,
  108. delayVideoTimes: number,
  109. money_type: number,
  110. num: number,
  111. moneyshow: number,
  112. summoney: number
  113. }