GameData.ts 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
  1. import Util from "../../before/util/Util";
  2. import FunBtns from "../game/FunBtns";
  3. import Game from "../game/Game";
  4. /**
  5. * @description 游戏核心玩法数据
  6. * @author 邹勇
  7. */
  8. export class GameData {
  9. public dataFinish: boolean = false;
  10. public savePropFinish: boolean = false;
  11. public savePropsFinish: boolean = false;
  12. public getPropsFnish: boolean = false;
  13. public configs: any = {};
  14. public adShowConfig: ADShowCfg;
  15. /** 功能开启 */
  16. public funOpenData: string[] = [];
  17. public gameData: PlayerProp = null;
  18. /** 标志位:刷新主界面货币 */
  19. public init_coin: boolean = false;
  20. public updatePiggyBankValue: boolean = false;
  21. /** 标志位:刷新主界面头像 */
  22. public init_head: boolean = false;
  23. /** 标志位:刷新主界面红点 */
  24. public init_red_point: boolean = true;
  25. /** 属性存储字典 */
  26. public props: Map<number, any> = new Map<number, any>();
  27. public pools = [
  28. { url: "game/prefab/tips", num: 20 },
  29. { url: "game/prefab/coin", num: 20 }
  30. ];
  31. /** 主页样式脚本 */
  32. public gameStyle: Game = null;
  33. /** 入口按钮 */
  34. public funBtns: FunBtns = null;
  35. /**
  36. * 初始化游戏数据:网络配置信息,用户信息
  37. * @returns
  38. */
  39. public async init() {
  40. let data: any = { "versionCode": gData.appData.version };
  41. let response = await mk.http.sendData('getAllConfigInfo', data);
  42. if (response.errcode != 0) {
  43. if (response.errcode == -10003 || response.errcode == -20003) {
  44. //清除缓存
  45. gData.loginData.reload();
  46. }
  47. return;
  48. }
  49. mk.console.logSingle("getAllConfigInfo", response.data);
  50. this.initConfigs(response.data);
  51. //初始化topon
  52. mk.ad.init();
  53. data = {};
  54. response = await mk.http.sendData('getInfoCrypt', data);
  55. if (response.errcode != 0) {
  56. return;
  57. }
  58. mk.console.logSingle("getInfoCrypt", response.data);
  59. this.initPlayerProp(response.data)
  60. this.initProps(response.data.gameUserData);
  61. data = {};
  62. response = await mk.http.sendData('user/adShowConfig', data);
  63. if (response.errcode != 0) {
  64. return;
  65. }
  66. this.adShowConfig = response.data;
  67. mk.console.logSingle("user/adShowConfig", response.data);
  68. data = {};
  69. response = await mk.http.sendData('welFare/getUserWelFareTaskInfo', data);
  70. if (response.errcode != 0) {
  71. return;
  72. }
  73. this.gameData.userTuCaoInfo = response.data.userWelFareTaskInfo;
  74. mk.console.logSingle("welFare/getUserWelFareTaskInfo", response.data);
  75. gData.guideData.init();
  76. gData.guideWeakData.init();
  77. gData.moduleData.forEach(element => {
  78. element.init();
  79. });
  80. gData.adData.setFullInterShowStr();
  81. this.dataFinish = true;
  82. }
  83. private initConfigs(data) {
  84. // console.log('config ', data);
  85. this.configs = data;
  86. this.funOpenData = this.configs.ServerConfig.Functionswitch.split(",");
  87. // this.setProductMapFromJson();
  88. gData.configData.loadConfig();
  89. }
  90. /**
  91. * 初始化玩家数据
  92. */
  93. private initPlayerProp(res_data) {
  94. this.gameData = new PlayerProp();
  95. this.gameData.cashIndex = res_data.cashIndex;
  96. this.gameData.gameUserData = res_data.gameUserData;
  97. this.gameData.isSignInToday = res_data.isSignInToday;
  98. this.gameData.isWithdrawable = res_data.isWithdrawable;
  99. this.gameData.lastTime = res_data.lastTime;
  100. this.gameData.loginDays = res_data.loginDays;
  101. this.gameData.newPlayer = res_data.newPlayer;
  102. this.gameData.initPiggyBank(res_data.piggyBank);
  103. this.gameData.piggyBankCashTimes = res_data.piggyBankCashTimes;
  104. this.gameData.redMoney = res_data.redMoney == null ? 0 : res_data.redMoney;
  105. this.gameData.signInDay = res_data.signInDay;
  106. this.gameData.totalPiggyBankCashTimes = res_data.totalPiggyBankCashTimes;
  107. this.gameData.turntableTimes = res_data.turntableTimes;
  108. this.gameData.userTuCaoInfo = res_data.userTuCaoInfo;
  109. this.gameData.versioncfg = res_data.versioncfg;
  110. this.gameData.isFirstRedMoney = res_data.isFirstRedMoney;
  111. gData.adData.watchNumToday = res_data.dayVideoTimesForRedMoney == null ? 0 : res_data.dayVideoTimesForRedMoney;
  112. this.setFramDataMapByServer();
  113. this.setPastureDataMapByServer();
  114. }
  115. /**
  116. * 保存单个数据
  117. */
  118. public async setProp(key: GameProp, value: any) {
  119. let data = {
  120. key: key + '',
  121. value: value
  122. };
  123. this.props.set(key, value);
  124. await mk.http.sendData('savePlayerProp', data);
  125. this.savePropFinish = true;
  126. }
  127. /**
  128. * 保存多个数据
  129. */
  130. public async setProps(arr: { key: GameProp, value: any }[]) {
  131. let needProp = {};
  132. for (let i = 0; i < arr.length; i++) {
  133. needProp[arr[i].key + ''] = arr[i].value;
  134. }
  135. let data = {
  136. needProp: needProp
  137. };
  138. for (let i = 0; i < arr.length; i++) {
  139. this.props.set(arr[i].key, arr[i].value);
  140. }
  141. await mk.http.sendData('saveAllPlayerProp', data);
  142. this.savePropsFinish = true;
  143. }
  144. /** 获取属性 */
  145. public getProp(key: GameProp): number {
  146. if (this.props == null) {
  147. return 0;
  148. }
  149. let value = this.props.get(key);
  150. return value;
  151. }
  152. /**
  153. * 向服务器请求所有属性后更新
  154. */
  155. public async getAllProps() {
  156. let response = await mk.http.sendData('getAllPlayerProp', {});
  157. if (response.errcode != 0) {
  158. return;
  159. }
  160. this.initProps(response.data);
  161. this.getPropsFnish = true;
  162. }
  163. private initProps(data) {
  164. if (data == null) {
  165. return;
  166. }
  167. for (let key in data) {
  168. this.props.set(parseInt(key), data[key]);
  169. }
  170. }
  171. /**
  172. * 第二天需要重置的数据
  173. */
  174. public resetProps() {
  175. let arr = [];
  176. arr.push({ key: GameProp.sign_can, value: 1 });
  177. arr.push({ key: GameProp.isAutoOpenPanel, value: 1 });
  178. arr.push({ key: GameProp.isOpenBankOnCloseCash, value: 0 });
  179. this.setProps(arr);
  180. }
  181. /** 是否是新用户 */
  182. public isNewPlayer(): boolean {
  183. let v = this.getProp(GameProp.newPlayer);
  184. return v == 0;
  185. }
  186. //*********** ================= 农场数据 ================== */
  187. // public needReloadData = false;
  188. // private _productingListMap: Map<number, Array<{ productID: number, ripeDate: number }>> = new Map();
  189. // /**建筑生产队列列表 */
  190. // public getProductingList(id: number): Array<{ productID: number, ripeDate: number }> {
  191. // if (!this._productingListMap.has(id)) {
  192. // this._productingListMap.set(id, []);
  193. // }
  194. // return this._productingListMap.get(id);
  195. // }
  196. // /**已激活的建筑列表 */
  197. // private buildDataMap: Map<number, number> = new Map();
  198. // public hasBuildData(id: number): boolean {
  199. // return this.buildDataMap.has(id);
  200. // }
  201. // public getBuildData(id: number): number {
  202. // return this.buildDataMap.get(id);
  203. // }
  204. // public setBuildData(id: number, userBuildID: number): void {
  205. // this.buildDataMap.set(id, userBuildID);
  206. // }
  207. // // /**设置建筑数据(生产队列,流水线数量,激活情况等) */
  208. // // public async setGameData(data: any) {
  209. // // this._productingListMap = new Map();
  210. // // this._unlockMap = new Map();
  211. // // this.buildDataMap = new Map();
  212. // // let product = ConfigData.configMap.get("product");
  213. // // for (let i = 0; i < data.length; i++) {
  214. // // const build = data[i];
  215. // // if (!this.buildDataMap.has(build.buildID)) {
  216. // // this.buildDataMap.set(build.buildID, build.userBuildID);
  217. // // this.setUnlock(build.buildID, build.addValue + 1);
  218. // // }
  219. // // if (build.productID != 0) {
  220. // // let result = product[build.productID];
  221. // // this.getProductingList(build.buildID).push({ productID: build.productID, ripeDate: build.plantTime * 1000 + result["time"] * 1000 });
  222. // // }
  223. // // }
  224. // // }
  225. // /**是否有任务可领取 */
  226. // public taskReceive = false;
  227. // /**是否有3日活动任务可领取 */
  228. // public threeDayTaskReceive = 0;
  229. // /**3日活动还需要邀请人数 */
  230. // public needChildCount: number = 0;
  231. // /**3日活动激活后结束时间 */
  232. // public threedayTaskTime: number = 0
  233. // /**种植奖励数据 */
  234. // public productPrize = null;
  235. // // /**排行榜数据*/
  236. // // public rankData: RankData;
  237. // // /**排行榜积分数据*/
  238. // // public rankScore: number = 0;
  239. // // /**是否刷新排行榜活动倒计时*/
  240. // // public isRefreshRankTime: boolean;
  241. // // /**是否可以领取排行榜奖励*/
  242. // // public isCanGetRankReward: boolean;
  243. /** 农田数据 服务器数据 */
  244. private _farmData = [];
  245. /** 农田字典 本地数据,方便操作*/
  246. private _farmDataMap: Map<number, any> = new Map();
  247. //刷新农田
  248. public needFreshArr = [];
  249. /** 最大可种植植物ID */
  250. private _maxCanPlantID = 10003;
  251. /** 设置最大可种植id 用于判断随机种植植物*/
  252. setMaxPlantID(id) {
  253. this._maxCanPlantID = id;
  254. this.setProp(GameProp.maxCanPlantID, this._maxCanPlantID);
  255. }
  256. getMaxPlantID() {
  257. return this._maxCanPlantID;
  258. }
  259. getRandomPlantConfig() {
  260. let id = Util.rnd(10001, this._maxCanPlantID);
  261. return this.getProductMap(id);
  262. }
  263. public setFarmDataMap(id, data, sendToServer = true) {
  264. this._farmDataMap.set(id, data);
  265. let len = this._farmData.length;
  266. for (var i = 0; i < len; i++) {
  267. if (this._farmData[i].id == id) {
  268. this._farmData[i].state = data.state;
  269. this._farmData[i].productID = data.productID;
  270. this._farmData[i].growSpan = data.growSpan;
  271. break;
  272. }
  273. }
  274. this.needFreshArr.push(id);
  275. //更新到服务器
  276. if (sendToServer) {
  277. this.setProp(GameProp.farmData, this._farmData);
  278. }
  279. }
  280. public getFarmDataMap(id) {
  281. return this._farmDataMap.get(id);
  282. }
  283. /** 服务器数据设置到本地 */
  284. public setFramDataMapByServer() {
  285. let len = this._farmData.length;
  286. //新玩家初始化农田数据
  287. if (len < 18) {
  288. let id = 31000;
  289. let data = null;
  290. for (var i = 0; i < 18; i++) {
  291. if (i < 3) {
  292. data = { id: id, state: FarmState.Empty, productID: 0, growSpan: 0 };
  293. }
  294. else if (i == 3) {
  295. data = { id: id, state: FarmState.CanUnlock, productID: 0, growSpan: 0 };
  296. }
  297. else {
  298. data = { id: id, state: FarmState.Lock, productID: 0, growSpan: 0 };
  299. }
  300. this._farmData.push(data);
  301. this._farmDataMap.set(id, data);
  302. id++;
  303. }
  304. //第一次初始数据
  305. this.setMaxPlantID(this._maxCanPlantID);
  306. //更新到服务器
  307. this.setProp(GameProp.farmData, this._farmData);
  308. }
  309. else {
  310. for (var i = 0; i < len; i++) {
  311. this._farmDataMap.set(this._farmData[i].id, this._farmData[i]);
  312. }
  313. }
  314. }
  315. /** puduct配置数据 <picture, config> */
  316. private _productMap: Map<number, any> = new Map();
  317. /** puduct类型配置数据 <tab, 类型数组> */
  318. private _productTypeMap: Map<string, any> = new Map();
  319. /** 设置puduct配置数据 */
  320. public setProductMapFromJson() {
  321. // let productJson = this.configs.product;
  322. //先用本地数据
  323. let productJson = gData.configData.configMap.get('product');
  324. let len = productJson.length;
  325. let product = null;
  326. for (var i = 0; i < len; i++) {
  327. product = productJson[i];
  328. this._productMap.set(product['picture'], product);
  329. let arr = [];
  330. if (this.getProductArrByType(product['tab'])) {
  331. arr = this.getProductArrByType(product['tab']);
  332. }
  333. else {
  334. this._productTypeMap.set(product['tab'], arr);
  335. }
  336. arr.push(product);
  337. }
  338. }
  339. /** 根据id获取单个数据 */
  340. public getProductMap(id) {
  341. return this._productMap.get(id);
  342. }
  343. /** 根据tab获取数组 */
  344. public getProductArrByType(type: ProductType) {
  345. return this._productTypeMap.get(type);
  346. }
  347. /** 产品生产/种植次数 服务器数据 */
  348. private _productMakeTimesData = [];
  349. /** 产品生产/种植次数 */
  350. private _productMakeTimesMap: Map<number, number> = new Map();
  351. addProductMakeTimesById(id: number) {
  352. let times = this._productMakeTimesMap.get(id);
  353. if (!times) {
  354. times = 0;
  355. }
  356. times++;
  357. this._productMakeTimesMap.set(id, times);
  358. //更新到服务器
  359. let has = false;
  360. let len = this._productMakeTimesData.length;
  361. for (var i = 0; i < len; i++) {
  362. if (this._productMakeTimesData[i].id == id) {
  363. this._productMakeTimesData[i].times = times;
  364. has = true;
  365. break;
  366. }
  367. }
  368. if (!has) {
  369. let data = { 'id': id, 'times': times };
  370. this._productMakeTimesData.push(data);
  371. }
  372. //设置可种植植物最大id
  373. let nextID = id + 1;
  374. let nextConfig = this.getProductMap(nextID);
  375. if (nextConfig) {
  376. if (nextConfig.tab == '农作物' && nextID > this.getMaxPlantID()) {
  377. if (nextConfig.unlock == 1 && nextConfig.value <= times) {
  378. this.setMaxPlantID(nextID);
  379. }
  380. }
  381. }
  382. this.setProp(GameProp.productMakeTimes, this._productMakeTimesData);
  383. }
  384. getProductMakeTimesById(id: number) {
  385. let times = this._productMakeTimesMap.get(id);
  386. if (!times) {
  387. times = 0
  388. }
  389. return times;
  390. }
  391. //------------- 养殖场数据-----------
  392. /** 养殖场数据 服务器数据 */
  393. private _pastureData = [];
  394. /** 养殖场字典 本地数据,方便操作*/
  395. private _pastureDataMap: Map<number, any> = new Map();
  396. public setPastureDataMap(id, data, sendToServer = true) {
  397. this._pastureDataMap.set(id, data);
  398. let len = this._pastureData.length;
  399. for (var i = 0; i < len; i++) {
  400. if (this._pastureData[i].id == id) {
  401. this._pastureData[i].state = data.state;
  402. this._pastureData[i].productID = data.productID;
  403. this._pastureData[i].growSpan = data.growSpan;
  404. break;
  405. }
  406. }
  407. this.needFreshArr.push(id);
  408. //更新到服务器
  409. if (sendToServer) {
  410. this.setProp(GameProp.pastureData, this._pastureData);
  411. }
  412. }
  413. public getPastureDataMap(id) {
  414. return this._pastureDataMap.get(id);
  415. }
  416. /** 服务器数据设置到本地 */
  417. public setPastureDataMapByServer() {
  418. let len = this._pastureData.length;
  419. //新玩家初始化农田数据
  420. if (len < 3) {
  421. let arr = this.getProductArrByType(ProductType.dw);
  422. let len1 = arr.length;
  423. let id = 30001;
  424. let data = null;
  425. for (var i = 0; i < len1; i++) {
  426. data = { id: id, state: PastureState.Lock, productID: arr[i].picture, growSpan: 0 };
  427. this._pastureData.push(data);
  428. this._pastureDataMap.set(id, data);
  429. id++;
  430. }
  431. //更新到服务器
  432. this.setProp(GameProp.pastureData, this._pastureData);
  433. }
  434. else {
  435. for (var i = 0; i < len; i++) {
  436. this._pastureDataMap.set(this._pastureData[i].id, this._pastureData[i]);
  437. }
  438. }
  439. }
  440. }
  441. /**
  442. * 所有模块的非校验数据
  443. */
  444. export enum GameProp {
  445. /** -------------------- 通用玩家数据 ------------------------- */
  446. /** 是否新手 0新手 1老手 */
  447. newPlayer = 1,
  448. /** 当前新手引导步骤 */
  449. guideID = 2,
  450. /** 需要自动弹界面 每次登录都弹 除首次 表示今日是否要自动开 1自动开 2不自动开 其他不处理*/
  451. isAutoOpenPanel = 3,
  452. /** 关闭常规提现时需要自动开存钱罐 每天一次 表示今日有没有开过 */
  453. isOpenBankOnCloseCash = 4,
  454. //看视频次数
  455. videoTimes = 5,
  456. //提现次数
  457. cashTimes = 6,
  458. /** ------------------ 游戏核心数据 --------------------------- */
  459. /** 农场等级 */
  460. levelNum = 10,
  461. /** 农田数据 */
  462. farmData = 11,
  463. /** 产品生产次数 */
  464. productMakeTimes = 12,
  465. /** 最大可种植id */
  466. maxCanPlantID = 13,
  467. /** 养殖场数据 */
  468. pastureData = 14,
  469. /** ------------------ 转盘数据 ------------------------------ */
  470. turnable_leftTimes = 20,
  471. /** ------------------ 存钱罐数据 ----------------------------- */
  472. /** ------------------ 签到数据 ----------------------------- */
  473. /** 上次签到进度 */
  474. sign_last_bar = 120,
  475. /** 当前能否签到 */
  476. sign_can = 121,
  477. /** ------------------ 红包提现 ----------------------------- */
  478. /** 提现进度 */
  479. redBag_cash_bar = 220,
  480. }
  481. /**
  482. * 玩家数据
  483. */
  484. class PlayerProp {
  485. /** 自定义不需要校验的数据 */
  486. gameUserData = 0;
  487. _isSignInToday = 0;
  488. /**
  489. * 今日是否有签到
  490. * - 0 未签到,表示可以签到
  491. * - 1 有签到,表示不可签到
  492. */
  493. set isSignInToday(value: number) {
  494. this._isSignInToday = value;
  495. gData.sign.init_data = true;
  496. gData.gameData.init_red_point = true;
  497. }
  498. get isSignInToday(): number {
  499. return this._isSignInToday;
  500. }
  501. private _piggyBank: number = 0;
  502. /** 存钱罐存款 */
  503. set piggyBank(value: number) {
  504. if (this._piggyBank === value) return;
  505. if (gData.gameData.gameData.isWithdrawable && value > 0) return;// 存钱罐可提现状态,不能增加存钱罐金额
  506. this._piggyBank = value;
  507. gData.gameData.init_coin = true;
  508. gData.pigbank.init_data = true;
  509. gData.gameData.init_red_point = true;
  510. }
  511. get piggyBank(): number {
  512. return this._piggyBank;
  513. }
  514. /** 初始化 */
  515. initPiggyBank(v) {
  516. this._piggyBank = v;
  517. }
  518. _isWithdrawable = 0;
  519. /**
  520. * 存钱罐能否提现
  521. * - 0 不能提现
  522. * - 1 能提现
  523. */
  524. set isWithdrawable(value: number) {
  525. if (this._isWithdrawable != value) {
  526. this._isWithdrawable = value;
  527. gData.pigbank.init_data = true;
  528. gData.gameData.init_red_point = true;
  529. }
  530. }
  531. get isWithdrawable(): number {
  532. return this._isWithdrawable;
  533. }
  534. /** 存钱罐每日提现次数 */
  535. piggyBankCashTimes = 0;
  536. /** 累计存钱罐每日提现次数 */
  537. totalPiggyBankCashTimes = 0;
  538. /** 提现进度 */
  539. cashIndex = 0;
  540. /** 上次登录时间 */
  541. lastTime = 0;
  542. /** 登录天数 */
  543. loginDays = 0;
  544. newPlayer = 0;
  545. private _redMoney: number = 0;
  546. /** 红包币数量 */
  547. set redMoney(value: number) {
  548. this._redMoney = value;
  549. gData.gameData.init_coin = true;
  550. gData.gameData.init_red_point = true;
  551. }
  552. get redMoney(): number {
  553. return this._redMoney;
  554. }
  555. _signInDay = 0;
  556. /** 累计签到次数 客户端理解 上次签到天数 */
  557. set signInDay(value: number) {
  558. if (this._signInDay === value) return;
  559. this._signInDay = value;
  560. gData.sign.init_data = true;
  561. }
  562. get signInDay(): number {
  563. return this._signInDay;
  564. }
  565. /** 转盘次数 */
  566. turntableTimes = 0;
  567. /** 版本号 */
  568. versioncfg = 0;
  569. /** 福袋数据 */
  570. userTuCaoInfo = 0;
  571. /** 关卡数 */
  572. levelNum = 0;
  573. /** 锤子道具数目 */
  574. hammerPropNum = 0;
  575. /** 重设道具数目 */
  576. resetPropNum = 0;
  577. /** 变色道具数目 */
  578. changePropNum = 0;
  579. /** 能免费领红包 1 表示是新人第一次产出红包币,不用看视频*/
  580. isFirstRedMoney = 0;
  581. //玩家等级
  582. gradeLevel = 1;
  583. }
  584. /**
  585. * 奖励状态
  586. */
  587. export enum RewardState {
  588. /** 已领取 */
  589. none = 1,
  590. /** 未解锁 */
  591. lock = 2,
  592. /** 可领取 */
  593. unlock = 3
  594. }
  595. /**
  596. * 奖励类型
  597. */
  598. export enum RewardType {
  599. /** 红包币 */
  600. redBag = 1,
  601. /** 毛币 */
  602. rmb = 2,
  603. /** 金猪币 */
  604. pigRmb = 3,
  605. }
  606. /**
  607. * 音频路径
  608. */
  609. export enum AUDIO_TYPE {
  610. /**主界面背景音乐*/
  611. bgm = 'bgm',
  612. /**打开存钱罐界面播放一次*/
  613. pigBank = 'pigBank',
  614. /**关卡玩法背景音乐*/
  615. missionBg = 'missionBg',
  616. /**红包币领取界面关闭音效*/
  617. rewardClose = 'rewardClose',
  618. /**红包币领取界面开启音效*/
  619. rewardOpen = 'rewardOpen',
  620. /**红包界面打开音效*/
  621. reward = 'reward',
  622. /**提现到账界面打开播放一次*/
  623. receiptNotice = 'receiptNotice',
  624. /**通用按钮点击音效 */
  625. button = 'button',
  626. /**转盘转动音效*/
  627. turnableplay = 'turnableplay',
  628. /**转盘转动音效*/
  629. turnplateDrawEnd = 'turnplateDrawEnd',
  630. /**主页背景音乐 */
  631. music_startBg = "music_startBg",
  632. /**游戏背景音乐 */
  633. music_gameBg = "music_gameBg",
  634. /**按钮点击 */
  635. ef_button_click = "ef_button_click",
  636. /**红包打开 */
  637. ef_redPacket_open = "ef_redPacket_open",
  638. /**红包来了音效 */
  639. ef_redPacket_come = "ef_redPacket_come",
  640. /**消除4个 */
  641. ef_bonus4 = "ef_bonus4",
  642. /**消除5个 */
  643. ef_bonus5 = "ef_bonus5",
  644. /**消除6个 */
  645. ef_bonus6 = "ef_bonus6",
  646. /**消除7个 */
  647. ef_bonus7 = "ef_bonus7",
  648. /**消除8个 */
  649. ef_bonus8 = "ef_bonus8",
  650. /**普通消除音效 */
  651. ef_eliminate = "ef_eliminate",
  652. /**bouns消除音效 */
  653. ef_eliminate_bonus = "ef_eliminate_bonus",
  654. /**胜利音效 */
  655. ef_win = "ef_win",
  656. /**锤子 */
  657. ef_change = "ef_change",
  658. /**刷新 */
  659. ef_refresh = "ef_refresh",
  660. /**飞翔 */
  661. ef_fly = "ef_fly",
  662. /**关闭按钮音效*/
  663. closeButton = "closeButton",
  664. }
  665. /** ECPM */
  666. type ADShowCfg = {
  667. average_ecpm: number,
  668. insert_probability: number,
  669. is_show_banner: number,
  670. is_show_inter: number,
  671. }
  672. type PlayerInfoType = {
  673. /** 自定义不需要校验的数据 */
  674. gameUserData: object,
  675. /** 今日是否有签到 */
  676. isSignInToday: number,
  677. /** 存钱罐存款 */
  678. piggyBank: number,
  679. /** 存钱罐能否提现 */
  680. isWithdrawable: boolean,
  681. /** 存钱罐每日提现次数 */
  682. piggyBankCashTimes: number,
  683. /** 累计存钱罐每日提现次数 */
  684. totalPiggyBankCashTimes: number,
  685. /** 提现进度 */
  686. cashIndex: number,
  687. /** 上次登录时间 */
  688. lastTime: number,
  689. /** 登录天数 */
  690. loginDays: number,
  691. newPlayer: Boolean,
  692. /** 红包币数量 */
  693. redMoney: number,
  694. /** 累计签到次数 客户端理解 上次签到天数 */
  695. signInDay: number,
  696. /** 转盘次数 */
  697. turntableTimes: number,
  698. /** 版本号 */
  699. versioncfg: string,
  700. /** 福袋数据 */
  701. userTuCaoInfo: object,
  702. }
  703. /**事件类型 */
  704. export enum EVENT_TYPE {
  705. BACK_WxAuth = "BACK_WxAuth",
  706. UPDATE_CashNum = "UPDATE_CashNum",
  707. }
  708. /** 数据事件Id */
  709. export enum DataEventId {
  710. /** 点击 */
  711. guide = "guide",
  712. /** 按钮点击 */
  713. button_click = "button_click",
  714. /** 看视频 */
  715. video_init = "video_init",
  716. /** 看视频完成 */
  717. video_end = "video_end",
  718. /** 福袋功能 */
  719. fudaiFunction = "fudaiFunction",
  720. /** 互推功能 */
  721. hutuiFunction = "hutuiFunction",
  722. /** 关卡 */
  723. level = "level",
  724. /** 常规提现-红包币提现 */
  725. commonWithDrawal = "commonWithDrawl",
  726. /** 存钱罐提现 */
  727. jarWithDrawal = "jarWithDrawal",
  728. /** 签到提现 */
  729. signWithDrawal = "signWithDrawal",
  730. }
  731. /** 视频广告类型 */
  732. export enum VideoAdType {
  733. Null = "",
  734. /** 关卡积分红包 */
  735. LevelScoreRedBag = "关卡积分红包",
  736. /** 主界面气泡红包 */
  737. StartQiPaoRedBag = "主界面气泡红包",
  738. /** 关卡气泡红包 */
  739. LevelQiPaoRedBag = "关卡气泡红包",
  740. /** 转盘 */
  741. Turntable = "转盘视频",
  742. /** 福袋视频" */
  743. Fudai = "福袋视频",
  744. /** 签到视频 */
  745. Sign = "签到视频",
  746. //钱包提现新手视频
  747. CashOutNoviceWelfare = "钱包提现新手视频",
  748. //钱包提现加现金视频
  749. CashOutAddCash = "钱包提现加现金视频"
  750. }
  751. export enum FarmState {
  752. Lock,
  753. CanUnlock,
  754. Empty,
  755. Growing,
  756. Ripe,
  757. Sick
  758. }
  759. export enum PastureState {
  760. Lock,
  761. Empty,
  762. Growing,
  763. Ripe,
  764. Sick
  765. }
  766. export enum ProductType {
  767. nzw = '农作物',
  768. dw = '动物',
  769. bmhc = '爆米花厂',
  770. gdp = '糕点铺',
  771. ztc = '制糖厂',
  772. gfmg = '功夫面馆',
  773. kcd = '快餐店'
  774. }
  775. /** 动物状态 */
  776. export enum AnimalState {
  777. Hanger,
  778. Eat,
  779. Wait
  780. }