GameData.ts 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012
  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. //从服务器解析配置
  88. // this.setProductMapFromJson();
  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. }
  113. /**
  114. * 保存单个数据
  115. */
  116. public async setProp(key: GameProp, value: any) {
  117. let data = {
  118. key: key + '',
  119. value: value
  120. };
  121. this.props.set(key, value);
  122. await mk.http.sendData('savePlayerProp', data);
  123. this.savePropFinish = true;
  124. }
  125. /**
  126. * 保存多个数据
  127. */
  128. public async setProps(arr: { key: GameProp, value: any }[]) {
  129. let needProp = {};
  130. for (let i = 0; i < arr.length; i++) {
  131. needProp[arr[i].key + ''] = arr[i].value;
  132. }
  133. let data = {
  134. needProp: needProp
  135. };
  136. for (let i = 0; i < arr.length; i++) {
  137. this.props.set(arr[i].key, arr[i].value);
  138. }
  139. await mk.http.sendData('saveAllPlayerProp', data);
  140. this.savePropsFinish = true;
  141. }
  142. /** 获取属性 */
  143. public getProp(key: GameProp): any {
  144. if (this.props == null) {
  145. return 0;
  146. }
  147. let value = this.props.get(key);
  148. return value;
  149. }
  150. /**
  151. * 向服务器请求所有属性后更新
  152. */
  153. public async getAllProps() {
  154. let response = await mk.http.sendData('getAllPlayerProp', {});
  155. if (response.errcode != 0) {
  156. return;
  157. }
  158. this.initProps(response.data);
  159. this.getPropsFnish = true;
  160. }
  161. private initProps(data) {
  162. if (data == null) {
  163. return;
  164. }
  165. for (let key in data) {
  166. this.props.set(parseInt(key), data[key]);
  167. }
  168. this.setFramDataMapByServer();
  169. this.setPastureDataMapByServer();
  170. this.setFactoryDataMapByServer();
  171. }
  172. /**
  173. * 第二天需要重置的数据
  174. */
  175. public resetProps() {
  176. let arr = [];
  177. arr.push({ key: GameProp.sign_can, value: 1 });
  178. arr.push({ key: GameProp.isAutoOpenPanel, value: 1 });
  179. arr.push({ key: GameProp.isOpenBankOnCloseCash, value: 0 });
  180. this.setProps(arr);
  181. }
  182. /** 是否是新用户 */
  183. public isNewPlayer(): boolean {
  184. let v = this.getProp(GameProp.newPlayer);
  185. return v == 0;
  186. }
  187. //*********** ================= 农场数据 ================== */
  188. // public needReloadData = false;
  189. // private _productingListMap: Map<number, Array<{ productID: number, ripeDate: number }>> = new Map();
  190. // /**建筑生产队列列表 */
  191. // public getProductingList(id: number): Array<{ productID: number, ripeDate: number }> {
  192. // if (!this._productingListMap.has(id)) {
  193. // this._productingListMap.set(id, []);
  194. // }
  195. // return this._productingListMap.get(id);
  196. // }
  197. // /**已激活的建筑列表 */
  198. // private buildDataMap: Map<number, number> = new Map();
  199. // public hasBuildData(id: number): boolean {
  200. // return this.buildDataMap.has(id);
  201. // }
  202. // public getBuildData(id: number): number {
  203. // return this.buildDataMap.get(id);
  204. // }
  205. // public setBuildData(id: number, userBuildID: number): void {
  206. // this.buildDataMap.set(id, userBuildID);
  207. // }
  208. // // /**设置建筑数据(生产队列,流水线数量,激活情况等) */
  209. // // public async setGameData(data: any) {
  210. // // this._productingListMap = new Map();
  211. // // this._unlockMap = new Map();
  212. // // this.buildDataMap = new Map();
  213. // // let product = ConfigData.configMap.get("product");
  214. // // for (let i = 0; i < data.length; i++) {
  215. // // const build = data[i];
  216. // // if (!this.buildDataMap.has(build.buildID)) {
  217. // // this.buildDataMap.set(build.buildID, build.userBuildID);
  218. // // this.setUnlock(build.buildID, build.addValue + 1);
  219. // // }
  220. // // if (build.productID != 0) {
  221. // // let result = product[build.productID];
  222. // // this.getProductingList(build.buildID).push({ productID: build.productID, ripeDate: build.plantTime * 1000 + result["time"] * 1000 });
  223. // // }
  224. // // }
  225. // // }
  226. // /**是否有任务可领取 */
  227. // public taskReceive = false;
  228. // /**是否有3日活动任务可领取 */
  229. // public threeDayTaskReceive = 0;
  230. // /**3日活动还需要邀请人数 */
  231. // public needChildCount: number = 0;
  232. // /**3日活动激活后结束时间 */
  233. // public threedayTaskTime: number = 0
  234. // /**种植奖励数据 */
  235. // public productPrize = null;
  236. // // /**排行榜数据*/
  237. // // public rankData: RankData;
  238. // // /**排行榜积分数据*/
  239. // // public rankScore: number = 0;
  240. // // /**是否刷新排行榜活动倒计时*/
  241. // // public isRefreshRankTime: boolean;
  242. // // /**是否可以领取排行榜奖励*/
  243. // // public isCanGetRankReward: boolean;
  244. /** 农田数据 服务器数据 */
  245. private _farmData = [];
  246. /** 农田字典 本地数据,方便操作*/
  247. private _farmDataMap: Map<number, any> = new Map();
  248. //刷新农田
  249. public needFreshArr = [];
  250. getRandomPlantConfig() {
  251. let id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
  252. return this.getProductMap(id);
  253. }
  254. public setFarmDataMap(id, data, sendToServer = true) {
  255. this._farmDataMap.set(id, data);
  256. let len = this._farmData.length;
  257. for (var i = 0; i < len; i++) {
  258. if (this._farmData[i].id == id) {
  259. this._farmData[i].state = data.state;
  260. this._farmData[i].productID = data.productID;
  261. this._farmData[i].growSpan = data.growSpan;
  262. break;
  263. }
  264. }
  265. this.needFreshArr.push(id);
  266. //更新到服务器
  267. if (sendToServer) {
  268. this.setProp(GameProp.farmData, this._farmData);
  269. }
  270. }
  271. public getFarmDataMap(id) {
  272. return this._farmDataMap.get(id);
  273. }
  274. /** 服务器数据设置到本地 */
  275. public setFramDataMapByServer() {
  276. this._farmData = this.getProp(GameProp.farmData);
  277. if (!this._farmData) {
  278. this._farmData = [];
  279. }
  280. let len = this._farmData.length;
  281. //新玩家初始化农田数据
  282. if (len < 18) {
  283. let id = 31000;
  284. let data = null;
  285. for (var i = 0; i < 18; i++) {
  286. if (i < 3) {
  287. data = { id: id, state: FarmState.Empty, productID: 0, growSpan: 0 };
  288. }
  289. else if (i == 3) {
  290. data = { id: id, state: FarmState.CanUnlock, productID: 0, growSpan: 0 };
  291. }
  292. else {
  293. data = { id: id, state: FarmState.Lock, productID: 0, growSpan: 0 };
  294. }
  295. this._farmData.push(data);
  296. this._farmDataMap.set(id, data);
  297. id++;
  298. }
  299. //第一次初始数据
  300. this.setMaxProduct(ProductType.nzw, 10003);
  301. //更新到服务器
  302. this.setProp(GameProp.farmData, this._farmData);
  303. }
  304. else {
  305. for (var i = 0; i < len; i++) {
  306. this._farmDataMap.set(this._farmData[i].id, this._farmData[i]);
  307. }
  308. }
  309. }
  310. /** puduct配置数据 <picture, config> */
  311. private _productMap: Map<number, any> = new Map();
  312. /** puduct类型配置数据 <tab, 类型数组> */
  313. private _productTypeMap: Map<string, any> = new Map();
  314. /** 设置puduct配置数据 */
  315. public setProductMapFromJson() {
  316. // let productJson = this.configs.product;
  317. //先用本地数据
  318. let productJson = gData.configData.configMap.get('product');
  319. let len = productJson.length;
  320. let product = null;
  321. let tab = '';
  322. let arr = [];
  323. for (var i = 0; i < len; i++) {
  324. product = productJson[i];
  325. this._productMap.set(product.picture, product);
  326. if (tab != product.tab) {
  327. arr = [];
  328. this._productTypeMap.set(product.tab, arr);
  329. tab = product.tab;
  330. }
  331. arr.push(product);
  332. }
  333. }
  334. /** 根据id获取单个数据 */
  335. public getProductMap(id) {
  336. return this._productMap.get(id);
  337. }
  338. /** 根据tab获取数组 */
  339. public getProductArrByType(type: ProductType) {
  340. return this._productTypeMap.get(type);
  341. }
  342. /** 产品生产/种植次数 服务器数据 */
  343. private _productMakeTimesData = [];
  344. /** 产品生产/种植次数 */
  345. private _productMakeTimesMap: Map<number, number> = new Map();
  346. addProductMakeTimesById(id: number) {
  347. let times = this._productMakeTimesMap.get(id);
  348. if (!times) {
  349. times = 0;
  350. }
  351. times++;
  352. this._productMakeTimesMap.set(id, times);
  353. //更新到服务器
  354. let has = false;
  355. let len = this._productMakeTimesData.length;
  356. for (var i = 0; i < len; i++) {
  357. if (this._productMakeTimesData[i].id == id) {
  358. this._productMakeTimesData[i].times = times;
  359. has = true;
  360. break;
  361. }
  362. }
  363. if (!has) {
  364. let data = { 'id': id, 'times': times };
  365. this._productMakeTimesData.push(data);
  366. }
  367. //设置可种植/生产最大id
  368. let nextID = id + 1;
  369. let curConfig = this.getProductMap(id);
  370. let nextConfig = this.getProductMap(nextID);
  371. if (nextConfig) {
  372. if (nextConfig.tab == curConfig.tab && nextID > this.getMaxProduct(curConfig.tab)) {
  373. if (nextConfig.unlock == 1 && nextConfig.value <= times) {
  374. this.setMaxProduct(curConfig.tab, nextID);
  375. }
  376. }
  377. }
  378. this.setProp(GameProp.productMakeTimes, this._productMakeTimesData);
  379. }
  380. getProductMakeTimesById(id: number) {
  381. let times = this._productMakeTimesMap.get(id);
  382. if (!times) {
  383. times = 0
  384. }
  385. return times;
  386. }
  387. //------------- 养殖场数据-----------
  388. /** 养殖场数据 服务器数据 */
  389. private _pastureData = [];
  390. /** 养殖场字典 本地数据,方便操作*/
  391. private _pastureDataMap: Map<number, any> = new Map();
  392. public setPastureDataMap(id, data, sendToServer = true) {
  393. this._pastureDataMap.set(id, data);
  394. let len = this._pastureData.length;
  395. for (var i = 0; i < len; i++) {
  396. if (this._pastureData[i].id == id) {
  397. this._pastureData[i].state = data.state;
  398. this._pastureData[i].productID = data.productID;
  399. this._pastureData[i].growSpan = data.growSpan;
  400. break;
  401. }
  402. }
  403. this.needFreshArr.push(id);
  404. //更新到服务器
  405. if (sendToServer) {
  406. this.setProp(GameProp.pastureData, this._pastureData);
  407. }
  408. }
  409. public getPastureDataMap(id) {
  410. return this._pastureDataMap.get(id);
  411. }
  412. /** 服务器数据设置到本地 */
  413. public setPastureDataMapByServer() {
  414. this._pastureData = this.getProp(GameProp.pastureData);
  415. if (!this._pastureData) {
  416. this._pastureData = [];
  417. }
  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. //test
  428. data = { id: id, state: PastureState.Empty, productID: arr[i].picture, growSpan: 0 };
  429. this._pastureData.push(data);
  430. this._pastureDataMap.set(id, data);
  431. id++;
  432. }
  433. //更新到服务器
  434. this.setProp(GameProp.pastureData, this._pastureData);
  435. }
  436. else {
  437. for (var i = 0; i < len; i++) {
  438. this._pastureDataMap.set(this._pastureData[i].id, this._pastureData[i]);
  439. }
  440. }
  441. }
  442. //------------- 工厂数据-----------
  443. /** 工厂数据 服务器数据 */
  444. private _factoryData = [];
  445. /** 工厂字典 本地数据,方便操作*/
  446. private _factoryDataMap: Map<number, any> = new Map();
  447. public setFactoryDataMap(id, data, sendToServer = true) {
  448. this._factoryDataMap.set(id, data);
  449. let len = this._factoryData.length;
  450. for (var i = 0; i < len; i++) {
  451. if (this._factoryData[i].id == id) {
  452. this._factoryData[i].state = data.state;
  453. this._factoryData[i].productID = data.productID;
  454. this._factoryData[i].growSpan = data.growSpan;
  455. break;
  456. }
  457. }
  458. this.needFreshArr.push(id);
  459. //更新到服务器
  460. if (sendToServer) {
  461. this.setProp(GameProp.factoryData, this._factoryData);
  462. }
  463. }
  464. public getFactoryDataMap(id) {
  465. return this._factoryDataMap.get(id);
  466. }
  467. /** 服务器数据设置到本地 */
  468. public setFactoryDataMapByServer() {
  469. this._factoryData = this.getProp(GameProp.factoryData);
  470. if (!this._factoryData) {
  471. this._factoryData = [];
  472. }
  473. let len = this._factoryData.length;
  474. //新玩家初始化农田数据
  475. if (len < 3) {
  476. let id = 30004;
  477. let data = null;
  478. for (var i = 0; i < 6; i++) {
  479. // data = { id: id, state: FactroyState.Lock, productID: 0, growSpan: 0 };
  480. //test
  481. data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
  482. this._factoryData.push(data);
  483. this._factoryDataMap.set(id, data);
  484. id++;
  485. }
  486. //更新到服务器
  487. this.setProp(GameProp.factoryData, this._factoryData);
  488. }
  489. else {
  490. for (var i = 0; i < len; i++) {
  491. this._factoryDataMap.set(this._factoryData[i].id, this._factoryData[i]);
  492. }
  493. }
  494. }
  495. /** 最大可种植/生产商品数组 */
  496. private _maxProduct = [];
  497. public getMaxProduct(tab) {
  498. if (this._maxProduct) {
  499. let len = this._maxProduct.length;
  500. let data = null;
  501. for (var i = 0; i < len; i++) {
  502. data = this._maxProduct[i];
  503. if (data.tab == tab) {
  504. return data.productID;
  505. }
  506. }
  507. }
  508. return null;
  509. }
  510. public setMaxProduct(tab, id) {
  511. if (!this._maxProduct) {
  512. this._maxProduct = [];
  513. }
  514. let len = this._maxProduct.length;
  515. let data = null;
  516. let has = false;
  517. for (var i = 0; i < len; i++) {
  518. data = this._maxProduct[i];
  519. if (data.tab == tab) {
  520. data.productID = id;
  521. has = true;
  522. break;
  523. }
  524. }
  525. if (!has) {
  526. data = { tab: tab, productID: id };
  527. this._maxProduct.push(data);
  528. }
  529. this.setProp(GameProp.maxProduct, this._maxProduct);
  530. }
  531. /** 农场升级时检查最大可种植/生产商品 */
  532. public checkMaxProduct() {
  533. for (var key in ProductType) {
  534. let tab = ProductType[key]
  535. let curmax = this.getMaxProduct(tab);
  536. if (!curmax) {
  537. let configArr = this.getProductArrByType(tab);
  538. if (gData.gameData.gameData.gradeLevel >= configArr[0].value && this.getMaxProduct(tab) <= configArr[0].value) {
  539. this.setMaxProduct(tab, configArr[0].picture);
  540. }
  541. }
  542. }
  543. }
  544. }
  545. /**
  546. * 所有模块的非校验数据
  547. */
  548. export enum GameProp {
  549. /** -------------------- 通用玩家数据 ------------------------- */
  550. /** 是否新手 0新手 1老手 */
  551. newPlayer = 1,
  552. /** 当前新手引导步骤 */
  553. guideID = 2,
  554. /** 需要自动弹界面 每次登录都弹 除首次 表示今日是否要自动开 1自动开 2不自动开 其他不处理*/
  555. isAutoOpenPanel = 3,
  556. /** 关闭常规提现时需要自动开存钱罐 每天一次 表示今日有没有开过 */
  557. isOpenBankOnCloseCash = 4,
  558. //看视频次数
  559. videoTimes = 5,
  560. //提现次数
  561. cashTimes = 6,
  562. /** ------------------ 游戏核心数据 --------------------------- */
  563. /** 农场等级 */
  564. levelNum = 10,
  565. /** 农田数据 */
  566. farmData = 11,
  567. /** 产品生产次数 */
  568. productMakeTimes = 12,
  569. /** 可生产最大产品字典 */
  570. maxProduct = 13,
  571. /** 养殖场数据 */
  572. pastureData = 14,
  573. /** 工厂数据 */
  574. factoryData = 15,
  575. /** ------------------ 转盘数据 ------------------------------ */
  576. turnable_leftTimes = 20,
  577. /** ------------------ 存钱罐数据 ----------------------------- */
  578. /** ------------------ 签到数据 ----------------------------- */
  579. /** 上次签到进度 */
  580. sign_last_bar = 120,
  581. /** 当前能否签到 */
  582. sign_can = 121,
  583. /** ------------------ 红包提现 ----------------------------- */
  584. /** 提现进度 */
  585. redBag_cash_bar = 220,
  586. }
  587. /**
  588. * 玩家数据
  589. */
  590. class PlayerProp {
  591. /** 自定义不需要校验的数据 */
  592. gameUserData = 0;
  593. _isSignInToday = 0;
  594. /**
  595. * 今日是否有签到
  596. * - 0 未签到,表示可以签到
  597. * - 1 有签到,表示不可签到
  598. */
  599. set isSignInToday(value: number) {
  600. this._isSignInToday = value;
  601. gData.sign.init_data = true;
  602. gData.gameData.init_red_point = true;
  603. }
  604. get isSignInToday(): number {
  605. return this._isSignInToday;
  606. }
  607. private _piggyBank: number = 0;
  608. /** 存钱罐存款 */
  609. set piggyBank(value: number) {
  610. if (this._piggyBank === value) return;
  611. if (gData.gameData.gameData.isWithdrawable && value > 0) return;// 存钱罐可提现状态,不能增加存钱罐金额
  612. this._piggyBank = value;
  613. gData.gameData.init_coin = true;
  614. gData.pigbank.init_data = true;
  615. gData.gameData.init_red_point = true;
  616. }
  617. get piggyBank(): number {
  618. return this._piggyBank;
  619. }
  620. /** 初始化 */
  621. initPiggyBank(v) {
  622. this._piggyBank = v;
  623. }
  624. _isWithdrawable = 0;
  625. /**
  626. * 存钱罐能否提现
  627. * - 0 不能提现
  628. * - 1 能提现
  629. */
  630. set isWithdrawable(value: number) {
  631. if (this._isWithdrawable != value) {
  632. this._isWithdrawable = value;
  633. gData.pigbank.init_data = true;
  634. gData.gameData.init_red_point = true;
  635. }
  636. }
  637. get isWithdrawable(): number {
  638. return this._isWithdrawable;
  639. }
  640. /** 存钱罐每日提现次数 */
  641. piggyBankCashTimes = 0;
  642. /** 累计存钱罐每日提现次数 */
  643. totalPiggyBankCashTimes = 0;
  644. /** 提现进度 */
  645. cashIndex = 0;
  646. /** 上次登录时间 */
  647. lastTime = 0;
  648. /** 登录天数 */
  649. loginDays = 0;
  650. newPlayer = 0;
  651. private _redMoney: number = 0;
  652. /** 红包币数量 */
  653. set redMoney(value: number) {
  654. this._redMoney = value;
  655. gData.gameData.init_coin = true;
  656. gData.gameData.init_red_point = true;
  657. }
  658. get redMoney(): number {
  659. return this._redMoney;
  660. }
  661. _signInDay = 0;
  662. /** 累计签到次数 客户端理解 上次签到天数 */
  663. set signInDay(value: number) {
  664. if (this._signInDay === value) return;
  665. this._signInDay = value;
  666. gData.sign.init_data = true;
  667. }
  668. get signInDay(): number {
  669. return this._signInDay;
  670. }
  671. /** 转盘次数 */
  672. turntableTimes = 0;
  673. /** 版本号 */
  674. versioncfg = 0;
  675. /** 福袋数据 */
  676. userTuCaoInfo = 0;
  677. /** 关卡数 */
  678. levelNum = 0;
  679. /** 锤子道具数目 */
  680. hammerPropNum = 0;
  681. /** 重设道具数目 */
  682. resetPropNum = 0;
  683. /** 变色道具数目 */
  684. changePropNum = 0;
  685. /** 能免费领红包 1 表示是新人第一次产出红包币,不用看视频*/
  686. isFirstRedMoney = 0;
  687. //玩家等级
  688. gradeLevel = 6;
  689. }
  690. /**
  691. * 奖励状态
  692. */
  693. export enum RewardState {
  694. /** 已领取 */
  695. none = 1,
  696. /** 未解锁 */
  697. lock = 2,
  698. /** 可领取 */
  699. unlock = 3
  700. }
  701. /**
  702. * 奖励类型
  703. */
  704. export enum RewardType {
  705. /** 红包币 */
  706. redBag = 1,
  707. /** 毛币 */
  708. rmb = 2,
  709. /** 金猪币 */
  710. pigRmb = 3,
  711. }
  712. /**
  713. * 音频路径
  714. */
  715. export enum AUDIO_TYPE {
  716. /**主界面背景音乐*/
  717. bgm = 'bgm',
  718. /**打开存钱罐界面播放一次*/
  719. pigBank = 'pigBank',
  720. /**关卡玩法背景音乐*/
  721. missionBg = 'missionBg',
  722. /**红包币领取界面关闭音效*/
  723. rewardClose = 'rewardClose',
  724. /**红包币领取界面开启音效*/
  725. rewardOpen = 'rewardOpen',
  726. /**红包界面打开音效*/
  727. reward = 'reward',
  728. /**提现到账界面打开播放一次*/
  729. receiptNotice = 'receiptNotice',
  730. /**通用按钮点击音效 */
  731. button = 'button',
  732. /**转盘转动音效*/
  733. turnableplay = 'turnableplay',
  734. /**转盘转动音效*/
  735. turnplateDrawEnd = 'turnplateDrawEnd',
  736. /**主页背景音乐 */
  737. music_startBg = "music_startBg",
  738. /**游戏背景音乐 */
  739. music_gameBg = "music_gameBg",
  740. /**按钮点击 */
  741. ef_button_click = "ef_button_click",
  742. /**红包打开 */
  743. ef_redPacket_open = "ef_redPacket_open",
  744. /**红包来了音效 */
  745. ef_redPacket_come = "ef_redPacket_come",
  746. /**消除4个 */
  747. ef_bonus4 = "ef_bonus4",
  748. /**消除5个 */
  749. ef_bonus5 = "ef_bonus5",
  750. /**消除6个 */
  751. ef_bonus6 = "ef_bonus6",
  752. /**消除7个 */
  753. ef_bonus7 = "ef_bonus7",
  754. /**消除8个 */
  755. ef_bonus8 = "ef_bonus8",
  756. /**普通消除音效 */
  757. ef_eliminate = "ef_eliminate",
  758. /**bouns消除音效 */
  759. ef_eliminate_bonus = "ef_eliminate_bonus",
  760. /**胜利音效 */
  761. ef_win = "ef_win",
  762. /**锤子 */
  763. ef_change = "ef_change",
  764. /**刷新 */
  765. ef_refresh = "ef_refresh",
  766. /**飞翔 */
  767. ef_fly = "ef_fly",
  768. /**关闭按钮音效*/
  769. closeButton = "closeButton",
  770. }
  771. /** ECPM */
  772. type ADShowCfg = {
  773. average_ecpm: number,
  774. insert_probability: number,
  775. is_show_banner: number,
  776. is_show_inter: number,
  777. }
  778. type PlayerInfoType = {
  779. /** 自定义不需要校验的数据 */
  780. gameUserData: object,
  781. /** 今日是否有签到 */
  782. isSignInToday: number,
  783. /** 存钱罐存款 */
  784. piggyBank: number,
  785. /** 存钱罐能否提现 */
  786. isWithdrawable: boolean,
  787. /** 存钱罐每日提现次数 */
  788. piggyBankCashTimes: number,
  789. /** 累计存钱罐每日提现次数 */
  790. totalPiggyBankCashTimes: number,
  791. /** 提现进度 */
  792. cashIndex: number,
  793. /** 上次登录时间 */
  794. lastTime: number,
  795. /** 登录天数 */
  796. loginDays: number,
  797. newPlayer: Boolean,
  798. /** 红包币数量 */
  799. redMoney: number,
  800. /** 累计签到次数 客户端理解 上次签到天数 */
  801. signInDay: number,
  802. /** 转盘次数 */
  803. turntableTimes: number,
  804. /** 版本号 */
  805. versioncfg: string,
  806. /** 福袋数据 */
  807. userTuCaoInfo: object,
  808. }
  809. /**事件类型 */
  810. export enum EVENT_TYPE {
  811. BACK_WxAuth = "BACK_WxAuth",
  812. UPDATE_CashNum = "UPDATE_CashNum",
  813. }
  814. /** 数据事件Id */
  815. export enum DataEventId {
  816. /** 点击 */
  817. guide = "guide",
  818. /** 按钮点击 */
  819. button_click = "button_click",
  820. /** 看视频 */
  821. video_init = "video_init",
  822. /** 看视频完成 */
  823. video_end = "video_end",
  824. /** 福袋功能 */
  825. fudaiFunction = "fudaiFunction",
  826. /** 互推功能 */
  827. hutuiFunction = "hutuiFunction",
  828. /** 关卡 */
  829. level = "level",
  830. /** 常规提现-红包币提现 */
  831. commonWithDrawal = "commonWithDrawl",
  832. /** 存钱罐提现 */
  833. jarWithDrawal = "jarWithDrawal",
  834. /** 签到提现 */
  835. signWithDrawal = "signWithDrawal",
  836. }
  837. /** 视频广告类型 */
  838. export enum VideoAdType {
  839. Null = "",
  840. /** 关卡积分红包 */
  841. LevelScoreRedBag = "关卡积分红包",
  842. /** 主界面气泡红包 */
  843. StartQiPaoRedBag = "主界面气泡红包",
  844. /** 关卡气泡红包 */
  845. LevelQiPaoRedBag = "关卡气泡红包",
  846. /** 转盘 */
  847. Turntable = "转盘视频",
  848. /** 福袋视频" */
  849. Fudai = "福袋视频",
  850. /** 签到视频 */
  851. Sign = "签到视频",
  852. //钱包提现新手视频
  853. CashOutNoviceWelfare = "钱包提现新手视频",
  854. //钱包提现加现金视频
  855. CashOutAddCash = "钱包提现加现金视频"
  856. }
  857. export enum FarmState {
  858. Lock,
  859. CanUnlock,
  860. Empty,
  861. Growing,
  862. Ripe,
  863. Sick
  864. }
  865. export enum PastureState {
  866. Lock,
  867. Empty,
  868. Growing,
  869. Ripe,
  870. Sick
  871. }
  872. export enum ProductType {
  873. nzw = '农作物',
  874. dw = '动物',
  875. bmhc = '爆米花厂',
  876. gdp = '糕点铺',
  877. ztc = '制糖厂',
  878. lrc = '炼乳厂',
  879. gfmg = '功夫面馆',
  880. kcd = '快餐店'
  881. }
  882. /** 动物状态 */
  883. export enum AnimalState {
  884. Hanger,
  885. Eat,
  886. Wait
  887. }
  888. export enum FactroyState {
  889. Lock,
  890. Empty,
  891. Producting,
  892. Ripe,
  893. Sick
  894. }