GameData.ts 70 KB

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