GameData.ts 67 KB

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