GameData.ts 31 KB

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