GameData.ts 67 KB

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