GameData.ts 70 KB

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