GameData.ts 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594
  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. //是否触摸屏幕
  14. public isTouchScreen: boolean = false;
  15. public configs: any = {};
  16. public adShowConfig: ADShowCfg;
  17. /** 功能开启 */
  18. public funOpenData: string[] = [];
  19. public playerProp: PlayerProp = null;
  20. /** 标志位:刷新主界面货币 */
  21. public init_coin: boolean = false;
  22. public addHb: number = 0;
  23. public updatePiggyBankValue: boolean = false;
  24. /** 标志位:刷新主界面头像 */
  25. public init_head: boolean = false;
  26. public init_add: boolean = false;
  27. /** 标志位:刷新主界面红点 */
  28. public init_red_point: boolean = true;
  29. //标志位,刷新提现界面的红包币
  30. public init_wallet_redMoney = false;
  31. /** 属性存储字典 */
  32. public props: Map<number, any> = new Map<number, any>();
  33. public pools = [
  34. { url: "game/prefab/tips", num: 20 },
  35. { url: "game/prefab/coin", num: 20 }
  36. ];
  37. /** 主页样式脚本 */
  38. public gameStyle: Game = null;
  39. /** 入口按钮 */
  40. public funBtns: FunBtns = null;
  41. /** 剩余可种植次数 */
  42. public leftTimes: number = -1;
  43. /** 最大可种植次数 */
  44. public maxTimes: number = -1;
  45. /** 恢复种植次数间隔 */
  46. public ProductionRecovery: number = 15;
  47. public init_leftTimes: boolean = false;
  48. /** 可生产商品配置 */
  49. public nextCanProduct = null;
  50. /** 按钮生产选中的农田、牧场或工厂 */
  51. public nextMake = null;
  52. /** 类型标识 */
  53. private nextType = 0;
  54. /** 刷新生产按钮信息 */
  55. public init_makeInfo = false;
  56. /** 正在生产 */
  57. public isProducting = false;
  58. /** 标志位 刷新任务描述 */
  59. public init_task = false;
  60. public init_expLevel = false;
  61. //标志位任务跟新
  62. public init_redBagTask = false;
  63. //标志位 生产奖励的任务ui刷新
  64. public init_productTask = false;
  65. public init_speedup = false;
  66. 标志位
  67. public init_hideRedBag = false;
  68. public shareUrl = '';
  69. public shareTitle = '';
  70. public shareDes = '';
  71. public shareImgUrl = '';
  72. /** 生虫/生病/停电最多个数 */
  73. public RawInsectArr = [];
  74. /** 生虫/生病/停电当前个数 */
  75. public RawInsectCurArr = [0, 0, 0];
  76. /**
  77. * 初始化游戏数据:网络配置信息,用户信息
  78. * @returns
  79. */
  80. public async init() {
  81. let data: any = { "versionCode": gData.appData.version };
  82. let response = await mk.http.sendData('getAllConfigInfo', data);
  83. if (response.errcode != 0) {
  84. if (response.errcode == -10003 || response.errcode == -20003) {
  85. //清除缓存
  86. gData.loginData.reload();
  87. }
  88. return;
  89. }
  90. mk.console.logSingle("getAllConfigInfo", response.data);
  91. this.initConfigs(response.data);
  92. //初始化topon
  93. mk.ad.init();
  94. data = {};
  95. response = await mk.http.sendData('getInfoCrypt', data);
  96. if (response.errcode != 0) {
  97. return;
  98. }
  99. mk.console.logSingle("getInfoCrypt", response.data);
  100. this.initPlayerProp(response.data)
  101. this.initProps(response.data.gameUserData);
  102. data = {};
  103. response = await mk.http.sendData('user/adShowConfig', data);
  104. if (response.errcode != 0) {
  105. return;
  106. }
  107. this.adShowConfig = response.data;
  108. mk.console.logSingle("user/adShowConfig", response.data);
  109. gData.adData.initEcpmData();
  110. // data = {};
  111. // response = await mk.http.sendData('noviceWeFare/getNoviceWeFareInfo', data);
  112. // if (response.errcode != 0) {
  113. // return;
  114. // }
  115. // this.playerProp.userTuCaoInfo = response.data.userWelFareTaskInfo;
  116. // mk.console.logSingle("welFare/getUserWelFareTaskInfo", response.data);
  117. gData.guideData.init();
  118. gData.guideWeakData.init();
  119. gData.moduleData.forEach(element => {
  120. element.init();
  121. });
  122. this.dataFinish = true;
  123. }
  124. private initConfigs(data) {
  125. // console.log('config ', data);
  126. this.configs = data;
  127. this.funOpenData = this.configs.ServerConfig.Functionswitch.split(",");
  128. //从服务器解析配置
  129. this.setProductMapFromJson();
  130. gData.loginData.popIdentifySwitch = this.configs.ServerConfig.popIdentifySwitch == '1';
  131. gData.gameData.shareUrl = this.configs.ServerConfig.shareUrl;
  132. gData.gameData.shareTitle = this.configs.ServerConfig.shareTitle;
  133. gData.gameData.shareDes = this.configs.ServerConfig.shareDes;
  134. gData.gameData.shareImgUrl = this.configs.ServerConfig.shareImgUrl;
  135. gData.gameData.RawInsectArr = this.configs.ServerConfig.RawInsect.split(',');
  136. }
  137. /**
  138. * 初始化玩家数据
  139. */
  140. private initPlayerProp(res_data) {
  141. this.playerProp = new PlayerProp();
  142. this.playerProp.cashIndex = res_data.cashIndex;
  143. this.playerProp.gameUserData = res_data.gameUserData;
  144. this.playerProp.isSignInToday = res_data.isSignInToday;
  145. this.playerProp.isWithdrawable = res_data.isWithdrawable;
  146. this.playerProp.lastTime = res_data.lastTime;
  147. this.playerProp.loginDays = res_data.loginDays;
  148. this.playerProp.newPlayer = res_data.newPlayer;
  149. this.playerProp.initPiggyBank(res_data.piggyBank);
  150. this.playerProp.piggyBankCashTimes = res_data.piggyBankCashTimes;
  151. this.playerProp.redMoney = res_data.redMoney == null ? 0 : res_data.redMoney;
  152. this.playerProp.signInDay = res_data.signInDay;
  153. this.playerProp.totalPiggyBankCashTimes = res_data.totalPiggyBankCashTimes;
  154. this.playerProp.turntableTimes = res_data.turntableTimes;
  155. this.playerProp.versioncfg = res_data.versioncfg;
  156. this.playerProp.isFirstRedMoney = res_data.isFirstRedMoney;
  157. gData.adData.watchNumToday = res_data.dayVideoTimesForRedMoney == null ? 0 : res_data.dayVideoTimesForRedMoney;
  158. this.playerProp.gradeLevel = res_data.farmLevel
  159. this.playerProp.userTuCaoInfo = res_data.userWelFareTaskInfo;
  160. this.playerProp.farmExpValue = res_data.userExp;
  161. this.playerProp.farmGradeData = res_data.userFarmGrageRewardInfo;
  162. this.playerProp.userNoviceWeFareInfo = res_data.userNoviceWeFareInfo;
  163. this.playerProp.redMoneyCashPayRecordList = res_data.redMoneyCashPayRecordList;
  164. mk.console.logSingle('userNoviceWeFareInfo==>', res_data.userNoviceWeFareInfo);
  165. //mk.console.logSingle('redMoneyCashPayRecordList==>', res_data.redMoneyCashPayRecordList);
  166. this.playerProp.userFarmTaskInfo = res_data.userFarmTaskInfo;
  167. this.playerProp.speedUpLeftTimes = res_data.speedUpLeftTimes;
  168. this.playerProp.completeFarmTaskTimes = res_data.completeFarmTaskTimes;
  169. mk.data.setTAUserID(gData.loginData.uin);
  170. mk.data.setTAEventUser(0, 'logindays_total', this.playerProp.loginDays);
  171. if (this.playerProp.completeFarmTaskTimes == 0) {
  172. mk.data.setTAEventUser(0, 'Cumulative_task', gData.gameData.playerProp.completeFarmTaskTimes);
  173. }
  174. if (gData.loginData.isFirstIn) {
  175. gData.loginData.isFirstIn = false;
  176. mk.data.setTAEventRegister();
  177. mk.data.sendDataEvent('ABTest', `触发${this.playerProp.groupCode}方案`);
  178. //注册时版本号
  179. mk.data.setTAEventUserStr(0, 'regtime_app_id', gData.appData.appVersion);
  180. //星云uid
  181. mk.data.setTAEventUserStr(0, 'xy_uid', gData.loginData.uin);
  182. mk.data.setTAEventUser(0, 'farm_lv', gData.gameData.playerProp.gradeLevel);
  183. }
  184. //当前版本号
  185. mk.data.setTAEventUserStr(0, 'now_app_id', gData.appData.appVersion);
  186. //渠道号
  187. mk.data.setTAEventUserStr(0, 'channel_id', gData.appData.umengChannel);
  188. // //test
  189. // this.playerProp.completeFarmTaskTimes = 3;
  190. }
  191. /**
  192. * 保存单个数据
  193. */
  194. public async setProp(key: GameProp, value: any) {
  195. let data = {
  196. key: key + '',
  197. value: value
  198. };
  199. this.props.set(key, value);
  200. await mk.http.sendData('savePlayerProp', data);
  201. this.savePropFinish = true;
  202. }
  203. /**
  204. * 保存多个数据
  205. */
  206. public async setProps(arr: { key: GameProp, value: any }[]) {
  207. let needProp = {};
  208. for (let i = 0; i < arr.length; i++) {
  209. needProp[arr[i].key + ''] = arr[i].value;
  210. }
  211. let data = {
  212. needProp: needProp
  213. };
  214. for (let i = 0; i < arr.length; i++) {
  215. this.props.set(arr[i].key, arr[i].value);
  216. }
  217. await mk.http.sendData('saveAllPlayerProp', data);
  218. this.savePropsFinish = true;
  219. }
  220. /** 获取属性 */
  221. public getProp(key: GameProp): any {
  222. if (this.props == null) {
  223. return 0;
  224. }
  225. let value = this.props.get(key);
  226. return value;
  227. }
  228. /**
  229. * 向服务器请求所有属性后更新
  230. */
  231. public async getAllProps() {
  232. let response = await mk.http.sendData('getAllPlayerProp', {});
  233. if (response.errcode != 0) {
  234. return;
  235. }
  236. this.initProps(response.data);
  237. this.getPropsFnish = true;
  238. }
  239. private initProps(data) {
  240. if (data == null) {
  241. return;
  242. }
  243. for (let key in data) {
  244. this.props.set(parseInt(key), data[key]);
  245. }
  246. this.setFramDataMapByServer();
  247. this.setPastureDataMapByServer();
  248. this.setFactoryDataMapByServer();
  249. this.initProductTimes();
  250. this.initLeftTimes();
  251. this.initFarmMapGetRewardData();
  252. this.initCashOutTimes();
  253. // let isNewTask = this.getProp(GameProp.redBagTaskRefresh);
  254. // if (isNewTask != undefined) {
  255. // this.init_redBagTask = isNewTask;
  256. // }
  257. }
  258. private initLeftTimes() {
  259. let lefttimes = this.getProp(GameProp.leftTimes);
  260. if (lefttimes == undefined) {
  261. this.leftTimes = parseInt(this.configs.ServerConfig.FreeProduction);
  262. this.setProp(GameProp.leftTimes, this.leftTimes);
  263. }
  264. else {
  265. this.leftTimes = lefttimes;
  266. }
  267. this.maxTimes = parseInt(this.configs.ServerConfig.ProductionMax);
  268. this.ProductionRecovery = parseInt(this.configs.ServerConfig.ProductionRecovery);
  269. // //test
  270. // this.leftTimes = 1;
  271. // this.maxTimes = 20;
  272. // this.ProductionRecovery = 1;
  273. }
  274. /** 增加减少生产次数
  275. * @param add 增减变量
  276. */
  277. public changeLeftTimes(add, isIgnoreMaxTimes = false) {
  278. gData.gameData.leftTimes += add;
  279. if (add > 0 && !isIgnoreMaxTimes) {
  280. gData.gameData.leftTimes = (gData.gameData.leftTimes > gData.gameData.maxTimes ? gData.gameData.maxTimes : gData.gameData.leftTimes);
  281. }
  282. if (gData.gameData.leftTimes < 0) {
  283. gData.gameData.leftTimes = 0;
  284. }
  285. gData.gameData.setProp(GameProp.leftTimes, gData.gameData.leftTimes);
  286. gData.gameData.init_leftTimes = true;
  287. }
  288. //图鉴领取数据
  289. private _farmMapRewardData = [];
  290. public getFarmMapRewardState(index) {
  291. if (index.i < this._farmMapRewardData.length) {
  292. if (index.j < this._farmMapRewardData[index.i].length) {
  293. return this._farmMapRewardData[index.i][index.j];
  294. }
  295. }
  296. return 1;
  297. }
  298. public setFarmMapRewardState(index, state) {
  299. if (index.i < this._farmMapRewardData.length) {
  300. if (index.j < this._farmMapRewardData[index.i].length) {
  301. this._farmMapRewardData[index.i][index.j] = state;
  302. this.setProp(GameProp.farmMapGetRewardData, this._farmMapRewardData);
  303. }
  304. }
  305. }
  306. private initFarmMapGetRewardData() {
  307. this._farmMapRewardData = this.getProp(GameProp.farmMapGetRewardData);
  308. if (!this._farmMapRewardData) {
  309. this._farmMapRewardData = [];
  310. }
  311. let needSync = false;
  312. let index = 0;
  313. this._productTypeMap.forEach((value, key) => {
  314. if (this._farmMapRewardData.length <= index) {
  315. let len = value.length;
  316. let arr = [];
  317. for (let i = 0; i != len; ++i) {
  318. arr.push(0);
  319. }
  320. this._farmMapRewardData.push(arr);
  321. needSync = true;
  322. console.log("-----add 数组数据")
  323. } else {
  324. let data = this._farmMapRewardData[index];
  325. let len = value.length;
  326. for (let i = 0; i != len; ++i) {
  327. if (i >= data.length) {
  328. data.push(0);
  329. needSync = true;
  330. console.log("-----add 单个数据")
  331. }
  332. }
  333. }
  334. ++index;
  335. });
  336. if (needSync) {
  337. this.setProp(GameProp.farmMapGetRewardData, this._farmMapRewardData);
  338. }
  339. }
  340. //提现次数
  341. public _cashOutTimes = 0;
  342. public initCashOutTimes()
  343. {
  344. let v= this.getProp(GameProp.cashOutTimes);
  345. if(v)
  346. {
  347. this._cashOutTimes = v;
  348. }else{
  349. this._cashOutTimes = 0;
  350. }
  351. console.log(`initCashOutTimes====>${this._cashOutTimes }`);
  352. }
  353. public addCashOutTimes()
  354. {
  355. this._cashOutTimes += 1;
  356. this.setProp(GameProp.cashOutTimes, this._cashOutTimes);
  357. console.log(`addCashOutTimes====>${this._cashOutTimes }`);
  358. }
  359. /** 是否是新用户 */
  360. public isNewPlayer(): boolean {
  361. let v = this.getProp(GameProp.newPlayer);
  362. return v == 0;
  363. }
  364. //*********** ================= 农场数据 ================== */
  365. /** 农田数据 服务器数据 */
  366. private _farmData = [];
  367. /** 农田字典 本地数据,方便操作*/
  368. private _farmDataMap: Map<number, any> = new Map();
  369. //刷新农田
  370. public needFreshArr = [];
  371. /** 随机获取可种植物品 */
  372. getRandomPlantConfig() {
  373. let id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
  374. return this.getProductMap(id);
  375. }
  376. /** 随机获取可生产产品 */
  377. getRandomFactoryConfig(configID) {
  378. let tab = gData.gameData.getTabByConfigID(configID);
  379. let arr = this.getProductArrByType(tab);
  380. let max = this.getMaxProduct(tab);
  381. let canArr = [];
  382. let len = arr.length;
  383. for (var i = 0; i < len; i++) {
  384. if (arr[i].picture <= max) {
  385. canArr.push(arr[i].picture);
  386. if (arr[i].picture == max) {
  387. break;
  388. }
  389. }
  390. }
  391. let index = Util.rnd(0, canArr.length - 1);
  392. let id = canArr[index];
  393. return this.getProductMap(id);
  394. }
  395. /** 自动生产选中下一个 */
  396. setNextProduct(sel = true) {
  397. if (this.nextMake) {
  398. return;
  399. }
  400. let next = gData.farmSystem.selectNextFarm(sel);
  401. if (!next) {
  402. let next1 = gData.pastureSystem.nextPasture();
  403. if (!next1) {
  404. let next2 = gData.factorySystem.nextFactory();
  405. if (!next2) {
  406. this.nextType = 0;
  407. }
  408. else {
  409. this.nextType = 3;
  410. }
  411. }
  412. else {
  413. this.nextType = 2;
  414. }
  415. }
  416. else {
  417. this.nextType = 1;
  418. }
  419. this.init_makeInfo = true;
  420. }
  421. hasFirstCheck = false;
  422. firstCheckNext() {
  423. if (!this.hasFirstCheck && gData.farmSystem.farms.length >= 18
  424. && gData.pastureSystem.pastureIcons.length >= 3 && gData.factorySystem.factoryIcons.length >= 6) {
  425. this.hasFirstCheck = true;
  426. Util.objSortByKey(gData.farmSystem.farms, 'sortID');
  427. Util.objSortByKey(gData.pastureSystem.pastureIcons, 'sortID');
  428. Util.objSortByKey(gData.factorySystem.factoryIcons, 'sortID');
  429. gData.gameData.setNextProduct(false);
  430. }
  431. }
  432. async makeProduct() {
  433. let flyRed = true;
  434. switch (this.nextType) {
  435. case 0:
  436. mk.tip.pop('农场已满,无法继续生产');
  437. //弹出收获、生虫、加速
  438. if (!this.checkCanHarvest()) {
  439. if (!this.checkCanClearSick()) {
  440. this.checkCanSpeedUp(true);
  441. }
  442. }
  443. flyRed = false;
  444. break;
  445. case 1:
  446. flyRed = await gData.farmSystem.btnMake();
  447. gData.adData.checkPopRed();
  448. break;
  449. case 2:
  450. flyRed = await gData.pastureSystem.btnMake();
  451. gData.adData.checkPopRed();
  452. break;
  453. case 3:
  454. flyRed = await gData.factorySystem.btnMake();
  455. gData.adData.checkPopRed();
  456. break;
  457. }
  458. return flyRed;
  459. }
  460. public async updateNewTaskProgress(isNeedRefresh = false) {
  461. // if (gData.gameData.init_redBagTask) {
  462. // return;
  463. // }
  464. if (this.playerProp.userFarmTaskInfo) {
  465. let com = this.playerProp.userFarmTaskInfo.completeCount;
  466. let count = this.playerProp.userFarmTaskInfo.taskCount;
  467. if (com >= count) {
  468. mk.tip.pop('任务红包进度已满,快去提现');
  469. return false;
  470. }
  471. }
  472. let data = {};
  473. let response = await mk.http.sendData('farmTask/updateUserFarmTaskInfo', data);
  474. mk.console.logSingle('refrehTask=>', response);
  475. if (response.errcode != 0) {
  476. return false;
  477. }
  478. gData.gameData.init_task = true;
  479. this.playerProp.userFarmTaskInfo = response.data.userFarmTaskInfo;
  480. if (this.playerProp.userFarmTaskInfo.completeCount >= this.playerProp.userFarmTaskInfo.taskCount) {
  481. mk.ui.closeAllUI();
  482. mk.guide.curDes = '';
  483. mk.guide.open(3);
  484. }
  485. // if (isNeedRefresh) {
  486. // gData.gameData.init_task = true;
  487. // }
  488. return true;
  489. }
  490. public setFarmDataMap(id, data, sendToServer = true) {
  491. this._farmDataMap.set(id, data);
  492. let len = this._farmData.length;
  493. for (var i = 0; i < len; i++) {
  494. if (this._farmData[i].id == id) {
  495. this._farmData[i].state = data.state;
  496. this._farmData[i].productID = data.productID;
  497. this._farmData[i].growSpan = data.growSpan;
  498. break;
  499. }
  500. }
  501. this.needFreshArr.push(id);
  502. //更新到服务器
  503. if (sendToServer) {
  504. this.freshSendToServer(1);
  505. }
  506. }
  507. public getFarmDataMap(id) {
  508. return this._farmDataMap.get(id);
  509. }
  510. /** 服务器数据设置到本地 */
  511. public setFramDataMapByServer() {
  512. this._farmData = this.getProp(GameProp.farmData);
  513. if (!this._farmData) {
  514. this._farmData = [];
  515. }
  516. let len = this._farmData.length;
  517. //新玩家初始化农田数据
  518. if (len < 18) {
  519. let id = 31000;
  520. let data = null;
  521. let unluckNum = parseInt(gData.gameData.configs.ServerConfig.unluckNum);
  522. for (var i = 0; i < 18; i++) {
  523. if (i < unluckNum) {
  524. data = { id: id, state: FarmState.Empty, productID: 0, growSpan: 0 };
  525. }
  526. else if (i == unluckNum) {
  527. data = { id: id, state: FarmState.CanUnlock, productID: 0, growSpan: 0 };
  528. }
  529. else {
  530. data = { id: id, state: FarmState.Lock, productID: 0, growSpan: 0 };
  531. }
  532. this._farmData.push(data);
  533. this._farmDataMap.set(id, data);
  534. id++;
  535. }
  536. //第一次初始数据
  537. // this.setMaxProduct(10003);
  538. //更新到服务器
  539. this.setProp(GameProp.farmData, this._farmData);
  540. }
  541. else {
  542. let sickTimes = 0;
  543. for (var i = 0; i < len; i++) {
  544. this._farmDataMap.set(this._farmData[i].id, this._farmData[i]);
  545. if (this._farmData[i].state == FarmState.Sick) {
  546. sickTimes++;
  547. }
  548. }
  549. this.RawInsectCurArr[0] = sickTimes;
  550. }
  551. this.setMaxProduct(10003, true);
  552. }
  553. /** puduct配置数据 <picture, config> */
  554. private _productMap: Map<number, any> = new Map();
  555. /** puduct类型配置数据 <tab, 类型数组> */
  556. private _productTypeMap: Map<string, any> = new Map();
  557. /** 设置puduct配置数据 */
  558. public setProductMapFromJson() {
  559. let productJson = this.configs.Product;
  560. // // 先用本地数据
  561. // let productJson = gData.configData.configMap.get('product');
  562. let len = productJson.length;
  563. let product = null;
  564. let tab = '';
  565. let arr = [];
  566. for (var i = 0; i < len; i++) {
  567. product = productJson[i];
  568. this._productMap.set(product.picture, product);
  569. if (tab != product.tab) {
  570. arr = [];
  571. this._productTypeMap.set(product.tab, arr);
  572. tab = product.tab;
  573. }
  574. arr.push(product);
  575. }
  576. }
  577. /** 根据id获取单个数据 */
  578. public getProductMap(id) {
  579. return this._productMap.get(id);
  580. }
  581. /** 根据tab获取数组 */
  582. public getProductArrByType(type: ProductType) {
  583. return this._productTypeMap.get(type);
  584. }
  585. /** 产品生产/种植次数 服务器数据 */
  586. private _productMakeTimesData = [];
  587. /** 产品生产/种植次数 */
  588. private _productMakeTimesMap: Map<number, number> = new Map();
  589. private initProductTimes() {
  590. this._productMakeTimesData = this.getProp(GameProp.productMakeTimes);
  591. if (!this._productMakeTimesData) {
  592. this._productMakeTimesData = [];
  593. }
  594. let len = this._productMakeTimesData.length;
  595. for (var i = 0; i < len; i++) {
  596. this._productMakeTimesMap.set(this._productMakeTimesData[i].id, this._productMakeTimesData[i].times);
  597. this.setMaxProduct(this._productMakeTimesData[i].id);
  598. }
  599. }
  600. addProductMakeTimesById(id: number) {
  601. let times = this._productMakeTimesMap.get(id);
  602. if (!times) {
  603. times = 0;
  604. }
  605. times++;
  606. this._productMakeTimesMap.set(id, times);
  607. //更新到服务器
  608. let has = false;
  609. let len = this._productMakeTimesData.length;
  610. for (var i = 0; i < len; i++) {
  611. if (this._productMakeTimesData[i].id == id) {
  612. this._productMakeTimesData[i].times = times;
  613. has = true;
  614. break;
  615. }
  616. }
  617. if (!has) {
  618. let data = { 'id': id, 'times': times };
  619. this._productMakeTimesData.push(data);
  620. }
  621. //设置可种植/生产最大id
  622. let nextID = id + 1;
  623. let curConfig = this.getProductMap(id);
  624. let nextConfig = this.getProductMap(nextID);
  625. if (id == this.getMaxProduct(curConfig.tab)) {
  626. if (nextConfig) {
  627. gData.plantData.init_itemIndex = nextID;
  628. }
  629. }
  630. if (nextConfig) {
  631. if (nextConfig.tab == curConfig.tab && nextID > this.getMaxProduct(curConfig.tab)) {
  632. if (nextConfig.unlock == 1 && nextConfig.value <= times) {
  633. this._productMakeTimesMap.set(nextID, 0);
  634. let data = { 'id': nextID, 'times': 0 };
  635. this._productMakeTimesData.push(data);
  636. this.setMaxProduct(nextID);
  637. let nConfig = this.getProductMap(nextID + 1);
  638. if (nConfig) {
  639. gData.plantData.init_lock = nextID + 1;
  640. }
  641. }
  642. }
  643. }
  644. this.setProp(GameProp.productMakeTimes, this._productMakeTimesData);
  645. }
  646. getProductMakeTimesById(id: number) {
  647. let times = this._productMakeTimesMap.get(id);
  648. if (!times) {
  649. times = 0
  650. }
  651. return times;
  652. }
  653. //------------- 养殖场数据-----------
  654. /** 养殖场数据 服务器数据 */
  655. private _pastureData = [];
  656. /** 养殖场字典 本地数据,方便操作*/
  657. private _pastureDataMap: Map<number, any> = new Map();
  658. public setPastureDataMap(id, data, sendToServer = true) {
  659. this._pastureDataMap.set(id, data);
  660. let len = this._pastureData.length;
  661. for (var i = 0; i < len; i++) {
  662. if (this._pastureData[i].id == id) {
  663. this._pastureData[i].state = data.state;
  664. this._pastureData[i].productID = data.productID;
  665. this._pastureData[i].growSpan = data.growSpan;
  666. break;
  667. }
  668. }
  669. this.needFreshArr.push(id);
  670. //更新到服务器
  671. if (sendToServer) {
  672. this.freshSendToServer(2);
  673. }
  674. }
  675. public getPastureDataMap(id) {
  676. return this._pastureDataMap.get(id);
  677. }
  678. /** 服务器数据设置到本地 */
  679. public setPastureDataMapByServer() {
  680. this._pastureData = this.getProp(GameProp.pastureData);
  681. if (!this._pastureData) {
  682. this._pastureData = [];
  683. }
  684. let len = this._pastureData.length;
  685. //新玩家初始化养殖场数据
  686. if (len < 3) {
  687. let arr = this.getProductArrByType(ProductType.dw);
  688. let len1 = arr.length;
  689. let id = 30001;
  690. let data = null;
  691. for (var i = 0; i < len1; i++) {
  692. if (this.playerProp.completeFarmTaskTimes < arr[i].value) {
  693. data = { id: id, state: PastureState.Lock, productID: arr[i].picture, growSpan: 0 };
  694. }
  695. else {
  696. data = { id: id, state: PastureState.Empty, productID: arr[i].picture, growSpan: 0 };
  697. }
  698. this._pastureData.push(data);
  699. this._pastureDataMap.set(id, data);
  700. id++;
  701. }
  702. //更新到服务器
  703. this.setProp(GameProp.pastureData, this._pastureData);
  704. }
  705. else {
  706. let sickTimes = 0;
  707. for (var i = 0; i < len; i++) {
  708. this._pastureDataMap.set(this._pastureData[i].id, this._pastureData[i]);
  709. if (this._pastureData[i].state == PastureState.Sick) {
  710. sickTimes++;
  711. }
  712. }
  713. this.RawInsectCurArr[1] = sickTimes;
  714. }
  715. }
  716. //------------- 工厂数据-----------
  717. /** 工厂数据 服务器数据 */
  718. private _factoryData = [];
  719. /** 工厂字典 本地数据,方便操作*/
  720. private _factoryDataMap: Map<number, any> = new Map();
  721. public setFactoryDataMap(id, data, sendToServer = true) {
  722. this._factoryDataMap.set(id, data);
  723. let len = this._factoryData.length;
  724. for (var i = 0; i < len; i++) {
  725. if (this._factoryData[i].id == id) {
  726. this._factoryData[i].state = data.state;
  727. this._factoryData[i].productID = data.productID;
  728. this._factoryData[i].growSpan = data.growSpan;
  729. break;
  730. }
  731. }
  732. this.needFreshArr.push(id);
  733. //更新到服务器
  734. if (sendToServer) {
  735. this.freshSendToServer(3);
  736. }
  737. }
  738. public getFactoryDataMap(id) {
  739. return this._factoryDataMap.get(id);
  740. }
  741. /** 服务器数据设置到本地 */
  742. public setFactoryDataMapByServer() {
  743. this._factoryData = this.getProp(GameProp.factoryData);
  744. if (!this._factoryData) {
  745. this._factoryData = [];
  746. }
  747. let len = this._factoryData.length;
  748. //新玩家初始化工厂数据
  749. if (len < 6) {
  750. let id = 30004;
  751. let data = null;
  752. let tab = null;
  753. for (var i = 0; i < 6; i++) {
  754. tab = this.getTabByConfigID(id);
  755. let arr = this.getProductArrByType(tab);
  756. if (this.playerProp.completeFarmTaskTimes < arr[0].value) {
  757. data = { id: id, state: FactroyState.Lock, productID: 0, growSpan: 0 };
  758. }
  759. else {
  760. data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
  761. //更新最大可购买商品
  762. this.setMaxProduct(arr[0].picture, true);
  763. }
  764. this._factoryData.push(data);
  765. this._factoryDataMap.set(id, data);
  766. id++;
  767. }
  768. //更新到服务器
  769. this.setProp(GameProp.factoryData, this._factoryData);
  770. }
  771. else {
  772. let sickTimes = 0;
  773. let id = 30004;
  774. let tab = null;
  775. for (var i = 0; i < len; i++) {
  776. tab = this.getTabByConfigID(id);
  777. let arr = this.getProductArrByType(tab);
  778. this._factoryDataMap.set(this._factoryData[i].id, this._factoryData[i]);
  779. if (this._factoryData[i].state == FactroyState.Sick) {
  780. sickTimes++;
  781. }
  782. if (this.playerProp.completeFarmTaskTimes >= arr[0].value) {
  783. //更新最大可购买商品
  784. this.setMaxProduct(arr[0].picture, true);
  785. }
  786. id++;
  787. }
  788. this.RawInsectCurArr[2] = sickTimes;
  789. }
  790. }
  791. /** 通过工厂建筑物ID获取标签 */
  792. getTabByConfigID(configID: number): ProductType {
  793. let tab = ProductType.bmhc;
  794. switch (configID) {
  795. case 30004:
  796. tab = ProductType.bmhc;
  797. break;
  798. case 30005:
  799. tab = ProductType.gdp;
  800. break;
  801. case 30006:
  802. tab = ProductType.ztc;
  803. break;
  804. case 30007:
  805. tab = ProductType.lrc;
  806. break;
  807. case 30008:
  808. tab = ProductType.gfmg;
  809. break;
  810. case 30009:
  811. tab = ProductType.kcd;
  812. break;
  813. }
  814. return tab;
  815. }
  816. /** 通过标签获取工厂建筑物ID */
  817. getConfigIDByTab(tab: ProductType): number {
  818. let configID = 0;
  819. switch (tab) {
  820. case ProductType.bmhc:
  821. configID = 30004;
  822. break;
  823. case ProductType.gdp:
  824. configID = 30005;
  825. break;
  826. case ProductType.ztc:
  827. configID = 30006;
  828. break;
  829. case ProductType.lrc:
  830. configID = 30007;
  831. break;
  832. case ProductType.gfmg:
  833. configID = 30008;
  834. break;
  835. case ProductType.kcd:
  836. configID = 30009;
  837. break;
  838. }
  839. return configID;
  840. }
  841. /** 发送数据到服务器 */
  842. freshSendToServer(type) {
  843. switch (type) {
  844. case 1:
  845. this.setProp(GameProp.farmData, this._farmData);
  846. break;
  847. case 2:
  848. this.setProp(GameProp.pastureData, this._pastureData);
  849. break;
  850. case 3:
  851. this.setProp(GameProp.factoryData, this._factoryData);
  852. break;
  853. }
  854. }
  855. /** 最大可种植/生产商品数组 */
  856. private _maxProduct = [];
  857. public getMaxProduct(tab) {
  858. if (this._maxProduct) {
  859. let len = this._maxProduct.length;
  860. let data = null;
  861. for (var i = 0; i < len; i++) {
  862. data = this._maxProduct[i];
  863. if (data.tab == tab) {
  864. return data.productID;
  865. }
  866. }
  867. }
  868. return null;
  869. }
  870. /** 设置最大可生产商品
  871. * @param id 产品id
  872. * @param unlock 是否是解锁增加
  873. */
  874. public setMaxProduct(id, unlock = false) {
  875. let config = this.getProductMap(id);
  876. if (!this._maxProduct) {
  877. this._maxProduct = [];
  878. }
  879. let len = this._maxProduct.length;
  880. let data = null;
  881. let has = false;
  882. for (var i = 0; i < len; i++) {
  883. data = this._maxProduct[i];
  884. if (data.tab == config.tab) {
  885. if (data.productID < id) {
  886. data.productID = id;
  887. }
  888. has = true;
  889. break;
  890. }
  891. }
  892. if (!has && unlock) {
  893. data = { tab: config.tab, productID: id };
  894. this._maxProduct.push(data);
  895. }
  896. gData.farmMapData.isStateChange = true;
  897. }
  898. /** 农场升级时解锁工厂,检查最大可种植/生产商品 */
  899. public checkTaskFinishUnLock() {
  900. for (var key in ProductType) {
  901. let tab = ProductType[key];
  902. let configArr = this.getProductArrByType(tab);
  903. let len = configArr.length;
  904. let data = null;
  905. let needUpdate = false;
  906. switch (tab) {
  907. case ProductType.nzw:
  908. break;
  909. case ProductType.dw:
  910. let id = 30001;
  911. needUpdate = false;
  912. let maxId = 0;
  913. for (var i = 0; i < len; i++) {
  914. data = this.getPastureDataMap(id);
  915. if (this.playerProp.completeFarmTaskTimes >= configArr[i].value) {
  916. if (data.state == PastureState.Lock) {
  917. data = { id: id, state: PastureState.Empty, productID: configArr[i].picture, growSpan: 0 };
  918. this.setPastureDataMap(id, data, false);
  919. needUpdate = true;
  920. }
  921. maxId = configArr[i].picture;
  922. }
  923. id++;
  924. }
  925. if (maxId != 0) {
  926. //更新最大可购买商品
  927. this.setMaxProduct(maxId, true);
  928. }
  929. //更新到服务器
  930. if (needUpdate) {
  931. this.setProp(GameProp.pastureData, this._pastureData);
  932. this.setNextProduct();
  933. }
  934. break;
  935. default:
  936. //工厂解锁根据第一个商品
  937. needUpdate = false;
  938. let configID = this.getConfigIDByTab(tab);
  939. data = this.getFactoryDataMap(configID);
  940. if (this.playerProp.completeFarmTaskTimes >= configArr[0].value) {
  941. if (data.state == FactroyState.Lock) {
  942. data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
  943. this.setFactoryDataMap(configID, data, false);
  944. needUpdate = true;
  945. }
  946. //更新最大可购买商品
  947. this.setMaxProduct(configArr[0].picture, true);
  948. }
  949. if (needUpdate) {
  950. this.setProp(GameProp.factoryData, this._factoryData);
  951. this.setNextProduct();
  952. }
  953. break;
  954. }
  955. }
  956. }
  957. checkCanSpeedUp(pop = false) {
  958. let can = false;
  959. can = gData.farmSystem.canSpeedUp();
  960. if (!can) {
  961. can = gData.pastureSystem.canSpeedUp();
  962. if (!can) {
  963. can = gData.factorySystem.canSpeedUp();
  964. }
  965. }
  966. if (can && pop) {
  967. mk.ui.openPanel('module/speedUpUI/speedUp');
  968. }
  969. return can;
  970. }
  971. setHarvest() {
  972. gData.farmSystem.setHarvest();
  973. gData.pastureSystem.setHarvest();
  974. gData.factorySystem.setHarvest();
  975. }
  976. checkCanHarvest() {
  977. let can = false;
  978. can = gData.farmSystem.canHarvest();
  979. if (!can) {
  980. can = gData.pastureSystem.canHarvest();
  981. if (!can) {
  982. can = gData.factorySystem.canHarvest();
  983. }
  984. }
  985. return can;
  986. }
  987. checkCanClearSick() {
  988. let can = false;
  989. can = gData.farmSystem.canClearSick();
  990. if (!can) {
  991. can = gData.pastureSystem.canClearSick();
  992. if (!can) {
  993. can = gData.factorySystem.canClearSick();
  994. }
  995. }
  996. return can;
  997. }
  998. doPointToXYLogic() {
  999. let value = mk.storage.getStorage('cash_out');
  1000. if (!value) {
  1001. mk.storage.setStorage('cash_out', 1);
  1002. mk.data.sendXYEvent('cash_1', `第一次提现`);
  1003. } else {
  1004. if (value == 1) {
  1005. mk.storage.setStorage('cash_out', 2);
  1006. mk.data.sendXYEvent('cash_2', `第二次提现`);
  1007. } else if (value == 2) {
  1008. mk.storage.setStorage('cash_out', 3);
  1009. mk.data.sendXYEvent('cash_3', `第三次提现`);
  1010. }
  1011. }
  1012. }
  1013. }
  1014. /**
  1015. * 所有模块的非校验数据
  1016. */
  1017. export enum GameProp {
  1018. /** -------------------- 通用玩家数据 ------------------------- */
  1019. /** 是否新手 0新手 1老手 */
  1020. newPlayer = 1,
  1021. /** 当前新手引导步骤 */
  1022. guideID = 2,
  1023. /** 需要自动弹界面 每次登录都弹 除首次 表示今日是否要自动开 1自动开 2不自动开 其他不处理*/
  1024. isAutoOpenPanel = 3,
  1025. /** 关闭常规提现时需要自动开存钱罐 每天一次 表示今日有没有开过 */
  1026. isOpenBankOnCloseCash = 4,
  1027. //看视频次数
  1028. videoTimes = 5,
  1029. //提现次数
  1030. cashTimes = 6,
  1031. /** ------------------ 游戏核心数据 --------------------------- */
  1032. /** 农田数据 */
  1033. farmData = 11,
  1034. /** 产品生产次数 */
  1035. productMakeTimes = 12,
  1036. /** 养殖场数据 */
  1037. pastureData = 14,
  1038. /** 工厂数据 */
  1039. factoryData = 15,
  1040. /** 剩余可种植次数 */
  1041. leftTimes = 16,
  1042. /**
  1043. 图鉴领取数据*/
  1044. farmMapGetRewardData = 17,
  1045. //红包任务tag
  1046. redBagTaskRefresh = 18,
  1047. /** ------------------ 转盘数据 ------------------------------ */
  1048. turnable_leftTimes = 20,
  1049. //提现次数
  1050. cashOutTimes = 21,
  1051. }
  1052. /**
  1053. * 玩家数据
  1054. */
  1055. class PlayerProp {
  1056. /** 自定义不需要校验的数据 */
  1057. gameUserData = 0;
  1058. _isSignInToday = 0;
  1059. /**
  1060. * 今日是否有签到
  1061. * - 0 未签到,表示可以签到
  1062. * - 1 有签到,表示不可签到
  1063. */
  1064. set isSignInToday(value: number) {
  1065. this._isSignInToday = value;
  1066. gData.sign.init_data = true;
  1067. gData.gameData.init_red_point = true;
  1068. }
  1069. get isSignInToday(): number {
  1070. return this._isSignInToday;
  1071. }
  1072. private _piggyBank: number = 0;
  1073. /** 存钱罐存款 */
  1074. set piggyBank(value: number) {
  1075. if (this._piggyBank === value) return;
  1076. if (gData.gameData.playerProp.isWithdrawable && value > 0) return;// 存钱罐可提现状态,不能增加存钱罐金额
  1077. this._piggyBank = value;
  1078. gData.gameData.init_coin = true;
  1079. gData.gameData.init_red_point = true;
  1080. }
  1081. get piggyBank(): number {
  1082. return this._piggyBank;
  1083. }
  1084. /** 初始化 */
  1085. initPiggyBank(v) {
  1086. this._piggyBank = v;
  1087. }
  1088. _isWithdrawable = 0;
  1089. /**
  1090. * 存钱罐能否提现
  1091. * - 0 不能提现
  1092. * - 1 能提现
  1093. */
  1094. set isWithdrawable(value: number) {
  1095. if (this._isWithdrawable != value) {
  1096. this._isWithdrawable = value;
  1097. gData.gameData.init_red_point = true;
  1098. }
  1099. }
  1100. get isWithdrawable(): number {
  1101. return this._isWithdrawable;
  1102. }
  1103. /** 存钱罐每日提现次数 */
  1104. piggyBankCashTimes = 0;
  1105. /** 累计存钱罐每日提现次数 */
  1106. totalPiggyBankCashTimes = 0;
  1107. /** 提现进度 */
  1108. cashIndex = 0;
  1109. /** 上次登录时间 */
  1110. lastTime = 0;
  1111. /** 登录天数 */
  1112. loginDays = 0;
  1113. newPlayer = 0;
  1114. private _redMoney: number = 0;
  1115. /** 红包币数量 */
  1116. set redMoney(value: number) {
  1117. this._redMoney = value;
  1118. gData.gameData.init_coin = true;
  1119. //gData.gameData.init_red_point = true;
  1120. gData.gameData.init_wallet_redMoney = true;
  1121. mk.event.emit('refreshCoin');
  1122. mk.data.setTAEventUser(0, 'current_redmoney_stock', this._redMoney);
  1123. }
  1124. get redMoney(): number {
  1125. return this._redMoney;
  1126. }
  1127. _signInDay = 0;
  1128. /** 累计签到次数 客户端理解 上次签到天数 */
  1129. set signInDay(value: number) {
  1130. if (this._signInDay === value) return;
  1131. this._signInDay = value;
  1132. gData.sign.init_data = true;
  1133. }
  1134. get signInDay(): number {
  1135. return this._signInDay;
  1136. }
  1137. /** 转盘次数 */
  1138. turntableTimes = 0;
  1139. /** 版本号 */
  1140. versioncfg = 0;
  1141. /** 福袋数据 */
  1142. userTuCaoInfo = 0;
  1143. /** 能免费领红包 1 表示是新人第一次产出红包币,不用看视频*/
  1144. isFirstRedMoney = 0;
  1145. //农场等级
  1146. gradeLevel = 1;
  1147. //农场等级奖励数据
  1148. farmGradeData: any = {};
  1149. //农场等级名字
  1150. farmGradeName: number = 1;
  1151. //农场经验
  1152. private farmExp = 0;
  1153. set farmExpValue(value: number) {
  1154. this.farmExp = value;
  1155. gData.gameData.init_expLevel = true;
  1156. }
  1157. get farmExpValue(): number {
  1158. return this.farmExp;
  1159. }
  1160. //提现新手数据
  1161. userNoviceWeFareInfo: any = {};
  1162. //提现记录数据
  1163. redMoneyCashPayRecordList = null;
  1164. //任务红;
  1165. userFarmTaskInfo = null;
  1166. getRedMoneyCashOutTimesByIndex(index: number): number {
  1167. if (this.redMoneyCashPayRecordList) {
  1168. for (let i = 0; i != this.redMoneyCashPayRecordList.length; ++i) {
  1169. if (index === this.redMoneyCashPayRecordList[i].index) {
  1170. return this.redMoneyCashPayRecordList[i].frequency;
  1171. }
  1172. }
  1173. }
  1174. return 0;
  1175. }
  1176. /** ABTest分组id */
  1177. groupCode = 0;
  1178. //加速剩余次数
  1179. speedUpLeftTimes = 0;
  1180. /** 农场任务完成次数 */
  1181. completeFarmTaskTimes = 0;
  1182. }
  1183. /**
  1184. * 奖励状态
  1185. */
  1186. export enum RewardState {
  1187. /** 已领取 */
  1188. none = 1,
  1189. /** 未解锁 */
  1190. lock = 2,
  1191. /** 可领取 */
  1192. unlock = 3
  1193. }
  1194. /**
  1195. * 奖励类型
  1196. */
  1197. export enum RewardType {
  1198. /** 红包币 */
  1199. redBag = 1,
  1200. /** 毛币 */
  1201. rmb = 2,
  1202. /** 金猪币 */
  1203. pigRmb = 3,
  1204. /** 生产次数 */
  1205. productTimes = 4,
  1206. }
  1207. /**
  1208. * 音频路径
  1209. */
  1210. export enum AUDIO_TYPE {
  1211. /**主界面背景音乐*/
  1212. bgm = 'bgm',
  1213. /**打开存钱罐界面播放一次*/
  1214. pigBank = 'pigBank',
  1215. /**关卡玩法背景音乐*/
  1216. missionBg = 'missionBg',
  1217. /**红包币领取界面关闭音效*/
  1218. rewardClose = 'rewardClose',
  1219. /**红包币领取界面开启音效*/
  1220. rewardOpen = 'rewardOpen',
  1221. /**红包界面打开音效*/
  1222. reward = 'reward',
  1223. /**提现到账界面打开播放一次*/
  1224. receiptNotice = 'receiptNotice',
  1225. /**通用按钮点击音效 */
  1226. button = 'button',
  1227. /**转盘转动音效*/
  1228. turnableplay = 'turnableplay',
  1229. /**转盘转动音效*/
  1230. turnplateDrawEnd = 'turnplateDrawEnd',
  1231. /**主页背景音乐 */
  1232. music_startBg = "music_startBg",
  1233. /**游戏背景音乐 */
  1234. music_gameBg = "music_gameBg",
  1235. /**按钮点击 */
  1236. ef_button_click = "ef_button_click",
  1237. /**红包打开 */
  1238. ef_redPacket_open = "ef_redPacket_open",
  1239. /**红包来了音效 */
  1240. ef_redPacket_come = "ef_redPacket_come",
  1241. /**消除4个 */
  1242. ef_bonus4 = "ef_bonus4",
  1243. /**消除5个 */
  1244. ef_bonus5 = "ef_bonus5",
  1245. /**消除6个 */
  1246. ef_bonus6 = "ef_bonus6",
  1247. /**消除7个 */
  1248. ef_bonus7 = "ef_bonus7",
  1249. /**消除8个 */
  1250. ef_bonus8 = "ef_bonus8",
  1251. /**普通消除音效 */
  1252. ef_eliminate = "ef_eliminate",
  1253. /**bouns消除音效 */
  1254. ef_eliminate_bonus = "ef_eliminate_bonus",
  1255. /**胜利音效 */
  1256. ef_win = "ef_win",
  1257. /**锤子 */
  1258. ef_change = "ef_change",
  1259. /**刷新 */
  1260. ef_refresh = "ef_refresh",
  1261. /**飞翔 */
  1262. ef_fly = "ef_fly",
  1263. /**关闭按钮音效*/
  1264. closeButton = "closeButton",
  1265. //红包界面打开
  1266. congratulations = 'congratulations',
  1267. //红包飞音效
  1268. redmoney = 'redmoney'
  1269. }
  1270. /** ECPM */
  1271. type ADShowCfg = {
  1272. average_ecpm: number,
  1273. insert_probability: number,
  1274. is_show_banner: number,
  1275. is_show_inter: number,
  1276. }
  1277. /**事件类型 */
  1278. export enum EVENT_TYPE {
  1279. BACK_WxAuth = "BACK_WxAuth",
  1280. UPDATE_CashNum = "UPDATE_CashNum",
  1281. }
  1282. /** 数据事件Id */
  1283. export enum DataEventId {
  1284. /** 点击 */
  1285. guide = "guide",
  1286. /** 点击跳过 */
  1287. guideSkip = "guideSkip",
  1288. /** 按钮点击 */
  1289. button_click = "button_click",
  1290. /** 看视频 */
  1291. video_init = "video_init",
  1292. /** 看视频完成 */
  1293. video_end = "video_end",
  1294. /** 成功拉取全屏视频 */
  1295. interstitial2_init = "interstitial2_init",
  1296. /** 广告点击 */
  1297. Ad_click = "Ad_click",
  1298. /** 全屏视频完成 */
  1299. interstitial2_end = "interstitial2_end",
  1300. /** 福袋功能 */
  1301. fudaiFunction = "fudaiFunction",
  1302. /** 互推功能 */
  1303. hutuiFunction = "hutuiFunction",
  1304. /** 激励视频ecpm */
  1305. ad_videoEcpm = 'ad_video',
  1306. /** 开屏ecpm */
  1307. ad_openEcpm = 'ad_open',
  1308. /** 提现 */
  1309. Sundry = 'Sundry',
  1310. /** 加载 */
  1311. loading = 'loading'
  1312. }
  1313. /** 视频广告类型 */
  1314. export enum VideoAdType {
  1315. video_init_1 = '农场加等级经验',
  1316. video_init_2 = '提现-加进度',
  1317. video_init_3 = '提现-加现金',
  1318. video_init_4 = '签到',
  1319. video_init_5 = '抽奖',
  1320. video_init_6 = '图鉴领奖',
  1321. video_init_7 = '消灭害虫',
  1322. video_init_8 = '恢复健康',
  1323. video_init_9 = '恢复供电',
  1324. video_init_10 = '山羊红包',
  1325. video_init_11 = '拓建',
  1326. video_init_12 = '收获',
  1327. video_init_13 = '飘浮红包',
  1328. video_init_14 = '全体加速',
  1329. video_init_15 = '福利加进度',
  1330. video_init_16 = '生产加次数',
  1331. video_init_17 = '点击生产按钮',
  1332. video_init_18 = '离开游戏领红包',
  1333. video_init_19 = '定时弹出红包',
  1334. video_init_20 = '插队',
  1335. }
  1336. export enum InterFullAdType {
  1337. interstitial2_init_1 = '点击红包的关闭按钮',
  1338. interstitial2_init_2 = '普通收获',
  1339. interstitial2_init_3 = '点击鸟和狗'
  1340. }
  1341. export enum InterAdType {
  1342. interstitial1_click_1 = '恭喜发财红包弹出后',
  1343. interstitial1_click_2 = '恭喜获得弹窗弹出后',
  1344. interstitial1_click_3 = '生虫/生病/停电弹出后'
  1345. }
  1346. export enum BannerAdType {
  1347. banner_click_1 = '恭喜获得弹窗弹出后',
  1348. banner_click_2 = '任务红包',
  1349. banner_click_3 = '恭喜发财红包',
  1350. banner_click_4 = '图鉴',
  1351. banner_click_5 = '全体加速',
  1352. banner_click_6 = '收获弹窗',
  1353. banner_click_7 = '拓建弹窗',
  1354. banner_click_8 = '三个恢复弹窗',
  1355. banner_click_9 = '抽奖'
  1356. }
  1357. export enum ExpAddType {
  1358. EAT_video = 1,
  1359. EAT_harvest = 2,
  1360. EAT_others = 3,
  1361. }
  1362. export enum FarmState {
  1363. Lock,
  1364. CanUnlock,
  1365. Empty,
  1366. Growing,
  1367. Ripe,
  1368. Sick
  1369. }
  1370. export enum PastureState {
  1371. Lock,
  1372. Empty,
  1373. Growing,
  1374. Ripe,
  1375. Sick
  1376. }
  1377. export enum ProductType {
  1378. nzw = '农作物',
  1379. dw = '动物',
  1380. bmhc = '爆米花厂',
  1381. gdp = '糕点铺',
  1382. ztc = '制糖厂',
  1383. lrc = '炼乳厂',
  1384. gfmg = '功夫面馆',
  1385. kcd = '快餐店'
  1386. }
  1387. /** 动物状态 */
  1388. export enum AnimalState {
  1389. Hanger,
  1390. Eat,
  1391. Wait
  1392. }
  1393. export enum FactroyState {
  1394. Lock,
  1395. Empty,
  1396. Producting,
  1397. Ripe,
  1398. Sick
  1399. }