GameData.ts 49 KB

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