GameData.ts 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112
  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. //根据tab获取最大id的数据
  869. public getMaxProductDataByType(type: ProductType){
  870. let arr = this._productTypeMap.get(type);
  871. let len = arr.length;
  872. return arr[len - 1];
  873. }
  874. /** 产品生产/种植次数 服务器数据 */
  875. private _productMakeTimesData: any = {};
  876. /** 产品生产/种植次数 */
  877. private _productMakeTimesMap: Map<number, number> = new Map();
  878. //产品解锁最大id
  879. private _productUnlockMaxId: Map<string, number> = new Map();
  880. private initProductTimes() {
  881. let value = this.getProp(GameProp.productMakeTimes);
  882. if (!value) {
  883. this._productMakeTimesData.makeTimes = [];
  884. this._productMakeTimesData.productUnlockMaxId = new Map<string, number>();
  885. this._productMakeTimesData.productUnlockMaxId.set(ProductType.nzw, 10003);
  886. } else {
  887. if (value instanceof Array) {
  888. this._productMakeTimesData.makeTimes = value;
  889. this._productMakeTimesData.productUnlockMaxId = new Map<string, number>();
  890. this._productMakeTimesData.productUnlockMaxId.set(ProductType.nzw, 10003);
  891. let len = value.length;
  892. for (let i = 0; i != len; ++i) {
  893. let data = value[i];
  894. let config = this.getProductMap(data.id);
  895. let v = this._productMakeTimesData.productUnlockMaxId.get(config.tab);
  896. if (v) {
  897. if (v < data.id) {
  898. this._productMakeTimesData.productUnlockMaxId.set(config.tab, data.id);
  899. }
  900. } else {
  901. this._productMakeTimesData.productUnlockMaxId.set(config.tab, data.id);
  902. }
  903. }
  904. } else {
  905. this._productMakeTimesData.makeTimes = value.makeTimes;
  906. this._productMakeTimesData.productUnlockMaxId = this.objToMap(JSON.parse(value.productUnlockMaxId));
  907. }
  908. }
  909. let len = this._productMakeTimesData.makeTimes.length;
  910. for (var i = 0; i < len; i++) {
  911. this._productMakeTimesMap.set(this._productMakeTimesData.makeTimes[i].id, this._productMakeTimesData.makeTimes[i].times);
  912. this.setMaxProduct(this._productMakeTimesData.makeTimes[i].id);
  913. }
  914. }
  915. addProductMakeTimesById(id: number) {
  916. let isAddMaxProduct = false;
  917. let times = this._productMakeTimesMap.get(id);
  918. if (!times) {
  919. times = 0;
  920. }
  921. times++;
  922. this._productMakeTimesMap.set(id, times);
  923. //更新到服务器
  924. let has = false;
  925. let len = this._productMakeTimesData.makeTimes.length;
  926. for (var i = 0; i < len; i++) {
  927. if (this._productMakeTimesData.makeTimes[i].id == id) {
  928. this._productMakeTimesData.makeTimes[i].times = times;
  929. has = true;
  930. break;
  931. }
  932. }
  933. if (!has) {
  934. let data = { 'id': id, 'times': times };
  935. this._productMakeTimesData.makeTimes.push(data);
  936. }
  937. //设置可种植/生产最大id
  938. let nextID = id + 1;
  939. let curConfig = this.getProductMap(id);
  940. let nextConfig = this.getProductMap(nextID);
  941. if (id == this.getMaxProductExtra(curConfig.tab)) {
  942. if (nextConfig) {
  943. gData.plantData.init_itemIndex = nextID;
  944. }
  945. }
  946. if (nextConfig) {
  947. if (nextConfig.tab == curConfig.tab && nextID > this.getMaxProductExtra(curConfig.tab)) {
  948. if (nextConfig.unlock == 1 && nextConfig.value <= times) {
  949. isAddMaxProduct = true;
  950. this._productMakeTimesMap.set(nextID, 0);
  951. let data = { 'id': nextID, 'times': 0 };
  952. this._productMakeTimesData.makeTimes.push(data);
  953. this._productMakeTimesData.productUnlockMaxId.set(nextConfig.tab, nextID);
  954. this.setMaxProduct(nextID);
  955. let nConfig = this.getProductMap(nextID + 1);
  956. if (nConfig) {
  957. gData.plantData.init_lock = nextID + 1;
  958. }
  959. }
  960. }
  961. }
  962. if (!isAddMaxProduct) {
  963. mk.event.emit("refreshFarmMapUI");
  964. }
  965. let sss: any = {};
  966. sss.makeTimes = this._productMakeTimesData.makeTimes;
  967. let json = this.mapToObj(this._productMakeTimesData.productUnlockMaxId);
  968. sss.productUnlockMaxId = JSON.stringify(json);
  969. this.setProp(GameProp.productMakeTimes, sss);
  970. }
  971. mapToObj(mapData) {
  972. let obj = {};
  973. mapData.forEach(function (value, key) {
  974. obj[key] = value;
  975. });
  976. return obj;
  977. }
  978. objToMap(obj) {
  979. let map = new Map();
  980. for (let k in obj) {
  981. map.set(k, obj[k]);
  982. }
  983. return map;
  984. }
  985. //设置解锁的最大id
  986. addProductUnlockMaxId(tab, id, isUpdateSever = true) {
  987. if (this._productMakeTimesData.productUnlockMaxId) {
  988. let productId = this._productMakeTimesData.productUnlockMaxId.get(tab);
  989. if (productId && id > productId) {
  990. this._productMakeTimesData.productUnlockMaxId.set(tab, id);
  991. if(isUpdateSever)
  992. {
  993. let sss: any = {};
  994. sss.makeTimes = this._productMakeTimesData.makeTimes;
  995. let json = this.mapToObj(this._productMakeTimesData.productUnlockMaxId);
  996. sss.productUnlockMaxId = JSON.stringify(json);
  997. this.setProp(GameProp.productMakeTimes, sss);
  998. }
  999. }
  1000. }
  1001. }
  1002. //判断前面解锁需要数值大于后面解锁数值的情况
  1003. public judgeAddExtraUnlockMaxId()
  1004. {
  1005. if(this._productMakeTimesData.productUnlockMaxId)
  1006. {
  1007. let data = this._productMakeTimesData.productUnlockMaxId;
  1008. data.forEach(function (value, key) {
  1009. if(key != ProductType.dw)
  1010. {
  1011. let data = this.updateDataToSever(key);
  1012. }
  1013. });
  1014. }
  1015. }
  1016. updateDataToSever() {
  1017. let sss: any = {};
  1018. sss.makeTimes = this._productMakeTimesData.makeTimes;
  1019. let json = this.mapToObj(this._productMakeTimesData.productUnlockMaxId);
  1020. sss.productUnlockMaxId = JSON.stringify(json);
  1021. this.setProp(GameProp.productMakeTimes, sss);
  1022. }
  1023. getProductMakeTimesById(id: number) {
  1024. let times = this._productMakeTimesMap.get(id);
  1025. if (!times) {
  1026. times = 0
  1027. }
  1028. return times;
  1029. }
  1030. getProductUnlockById(tab, id: number) {
  1031. if (this._productMakeTimesData.productUnlockMaxId) {
  1032. let productId = this._productMakeTimesData.productUnlockMaxId.get(tab);
  1033. if (productId) {
  1034. if (productId >= id) {
  1035. return true;
  1036. } else {
  1037. return false;
  1038. }
  1039. } else {
  1040. return false;
  1041. }
  1042. }
  1043. return false;
  1044. }
  1045. //------------- 养殖场数据-----------
  1046. /** 养殖场数据 服务器数据 */
  1047. private _pastureData = [];
  1048. /** 养殖场字典 本地数据,方便操作*/
  1049. private _pastureDataMap: Map<number, any> = new Map();
  1050. public setPastureDataMap(id, data, sendToServer = true) {
  1051. this._pastureDataMap.set(id, data);
  1052. let len = this._pastureData.length;
  1053. for (var i = 0; i < len; i++) {
  1054. if (this._pastureData[i].id == id) {
  1055. this._pastureData[i].state = data.state;
  1056. this._pastureData[i].productID = data.productID;
  1057. this._pastureData[i].growSpan = data.growSpan;
  1058. break;
  1059. }
  1060. }
  1061. this.needFreshArr.push(id);
  1062. //更新到服务器
  1063. if (sendToServer) {
  1064. this.freshSendToServer(2);
  1065. }
  1066. }
  1067. public getPastureDataMap(id) {
  1068. return this._pastureDataMap.get(id);
  1069. }
  1070. /** 服务器数据设置到本地 */
  1071. public setPastureDataMapByServer() {
  1072. this._pastureData = this.getProp(GameProp.pastureData);
  1073. if (!this._pastureData) {
  1074. this._pastureData = [];
  1075. }
  1076. let len = this._pastureData.length;
  1077. //新玩家初始化养殖场数据
  1078. if (len < 3) {
  1079. let arr = this.getProductArrByType(ProductType.dw);
  1080. let len1 = arr.length;
  1081. let id = 30001;
  1082. let data = null;
  1083. for (var i = 0; i < len1; i++) {
  1084. if (this.playerProp.completeFarmTaskTimes < arr[i].value) {
  1085. data = { id: id, state: PastureState.Lock, productID: arr[i].picture, growSpan: 0 };
  1086. }
  1087. else {
  1088. data = { id: id, state: PastureState.Empty, productID: arr[i].picture, growSpan: 0 };
  1089. }
  1090. this._pastureData.push(data);
  1091. this._pastureDataMap.set(id, data);
  1092. id++;
  1093. }
  1094. //更新到服务器
  1095. this.setProp(GameProp.pastureData, this._pastureData);
  1096. }
  1097. else {
  1098. let sickTimes = 0;
  1099. for (var i = 0; i < len; i++) {
  1100. this._pastureDataMap.set(this._pastureData[i].id, this._pastureData[i]);
  1101. if (this._pastureData[i].state == PastureState.Sick) {
  1102. sickTimes++;
  1103. }
  1104. }
  1105. this.RawInsectCurArr[1] = sickTimes;
  1106. }
  1107. }
  1108. //------------- 工厂数据-----------
  1109. /** 工厂数据 服务器数据 */
  1110. private _factoryData = [];
  1111. /** 工厂字典 本地数据,方便操作*/
  1112. private _factoryDataMap: Map<number, any> = new Map();
  1113. public setFactoryDataMap(id, data, sendToServer = true) {
  1114. this._factoryDataMap.set(id, data);
  1115. let len = this._factoryData.length;
  1116. for (var i = 0; i < len; i++) {
  1117. if (this._factoryData[i].id == id) {
  1118. this._factoryData[i].state = data.state;
  1119. this._factoryData[i].productID = data.productID;
  1120. this._factoryData[i].growSpan = data.growSpan;
  1121. break;
  1122. }
  1123. }
  1124. this.needFreshArr.push(id);
  1125. //更新到服务器
  1126. if (sendToServer) {
  1127. this.freshSendToServer(3);
  1128. }
  1129. }
  1130. public getFactoryDataMap(id) {
  1131. return this._factoryDataMap.get(id);
  1132. }
  1133. /** 服务器数据设置到本地 */
  1134. public setFactoryDataMapByServer() {
  1135. this._factoryData = this.getProp(GameProp.factoryData);
  1136. if (!this._factoryData) {
  1137. this._factoryData = [];
  1138. }
  1139. let len = this._factoryData.length;
  1140. //新玩家初始化工厂数据
  1141. if (len < 6) {
  1142. let id = 30004;
  1143. let data = null;
  1144. let tab = null;
  1145. for (var i = 0; i < 6; i++) {
  1146. tab = this.getTabByConfigID(id);
  1147. let arr = this.getProductArrByType(tab);
  1148. if (this.playerProp.completeFarmTaskTimes < arr[0].value) {
  1149. data = { id: id, state: FactroyState.Lock, productID: 0, growSpan: 0 };
  1150. }
  1151. else {
  1152. data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
  1153. //更新最大可购买商品
  1154. this.setMaxProduct(arr[0].picture, true);
  1155. this.addProductUnlockMaxId(tab, arr[0].picture);
  1156. }
  1157. this._factoryData.push(data);
  1158. this._factoryDataMap.set(id, data);
  1159. id++;
  1160. }
  1161. //更新到服务器
  1162. this.setProp(GameProp.factoryData, this._factoryData);
  1163. }
  1164. else {
  1165. let sickTimes = 0;
  1166. let id = 30004;
  1167. let tab = null;
  1168. for (var i = 0; i < len; i++) {
  1169. tab = this.getTabByConfigID(id);
  1170. let arr = this.getProductArrByType(tab);
  1171. this._factoryDataMap.set(this._factoryData[i].id, this._factoryData[i]);
  1172. if (this._factoryData[i].state == FactroyState.Sick) {
  1173. sickTimes++;
  1174. }
  1175. if (this.playerProp.completeFarmTaskTimes >= arr[0].value) {
  1176. //更新最大可购买商品
  1177. this.setMaxProduct(arr[0].picture, true);
  1178. this.addProductUnlockMaxId(tab, arr[0].picture);
  1179. }
  1180. id++;
  1181. }
  1182. this.RawInsectCurArr[2] = sickTimes;
  1183. }
  1184. }
  1185. /** 通过工厂建筑物ID获取标签 */
  1186. getTabByConfigID(configID: number): ProductType {
  1187. let tab = ProductType.bmhc;
  1188. switch (configID) {
  1189. case 30004:
  1190. tab = ProductType.bmhc;
  1191. break;
  1192. case 30005:
  1193. tab = ProductType.gdp;
  1194. break;
  1195. case 30006:
  1196. tab = ProductType.ztc;
  1197. break;
  1198. case 30007:
  1199. tab = ProductType.lrc;
  1200. break;
  1201. case 30008:
  1202. tab = ProductType.gfmg;
  1203. break;
  1204. case 30009:
  1205. tab = ProductType.kcd;
  1206. break;
  1207. }
  1208. return tab;
  1209. }
  1210. /** 通过标签获取工厂建筑物ID */
  1211. getConfigIDByTab(tab: ProductType): number {
  1212. let configID = 0;
  1213. switch (tab) {
  1214. case ProductType.bmhc:
  1215. configID = 30004;
  1216. break;
  1217. case ProductType.gdp:
  1218. configID = 30005;
  1219. break;
  1220. case ProductType.ztc:
  1221. configID = 30006;
  1222. break;
  1223. case ProductType.lrc:
  1224. configID = 30007;
  1225. break;
  1226. case ProductType.gfmg:
  1227. configID = 30008;
  1228. break;
  1229. case ProductType.kcd:
  1230. configID = 30009;
  1231. break;
  1232. }
  1233. return configID;
  1234. }
  1235. getIndex(data) {
  1236. let index: any = {};
  1237. index.i = 0;
  1238. index.j = 0;
  1239. switch (data.tab) {
  1240. case '农作物':
  1241. index.i = 0;
  1242. index.j = data.picture - 10001;
  1243. break;
  1244. case '动物':
  1245. index.i = 1;
  1246. index.j = data.picture - 20001;
  1247. break;
  1248. case '爆米花厂':
  1249. index.i = 2;
  1250. index.j = data.picture - 20004;
  1251. break;
  1252. case '糕点铺':
  1253. index.i = 3;
  1254. index.j = data.picture - 20013;
  1255. break;
  1256. case '制糖厂':
  1257. index.i = 4;
  1258. index.j = data.picture - 20010;
  1259. break;
  1260. case '炼乳厂':
  1261. index.i = 5;
  1262. index.j = data.picture - 20007;
  1263. break;
  1264. case '功夫面馆':
  1265. index.i = 6;
  1266. index.j = data.picture - 20025;
  1267. break;
  1268. case '快餐店':
  1269. index.i = 7;
  1270. index.j = data.picture - 20019;
  1271. break;
  1272. }
  1273. return index;
  1274. }
  1275. /** 发送数据到服务器 */
  1276. freshSendToServer(type) {
  1277. switch (type) {
  1278. case 1:
  1279. this.setProp(GameProp.farmData, this._farmData);
  1280. break;
  1281. case 2:
  1282. this.setProp(GameProp.pastureData, this._pastureData);
  1283. break;
  1284. case 3:
  1285. this.setProp(GameProp.factoryData, this._factoryData);
  1286. break;
  1287. }
  1288. }
  1289. /** 最大可种植/生产商品数组 */
  1290. private _maxProduct = [];
  1291. public getMaxProduct(tab) {
  1292. if (this._maxProduct) {
  1293. let len = this._maxProduct.length;
  1294. let data = null;
  1295. for (var i = 0; i < len; i++) {
  1296. data = this._maxProduct[i];
  1297. if (data.tab == tab) {
  1298. return data.productID;
  1299. }
  1300. }
  1301. }
  1302. return null;
  1303. }
  1304. getMaxProductExtra(tab) {
  1305. if (this._productMakeTimesData.productUnlockMaxId) {
  1306. let productId = this._productMakeTimesData.productUnlockMaxId.get(tab);
  1307. return productId;
  1308. }
  1309. return null;
  1310. }
  1311. /** 设置最大可生产商品
  1312. * @param id 产品id
  1313. * @param unlock 是否是解锁增加
  1314. */
  1315. public setMaxProduct(id, unlock = false) {
  1316. let config = this.getProductMap(id);
  1317. if (!this._maxProduct) {
  1318. this._maxProduct = [];
  1319. }
  1320. let len = this._maxProduct.length;
  1321. let data = null;
  1322. let has = false;
  1323. for (var i = 0; i < len; i++) {
  1324. data = this._maxProduct[i];
  1325. if (data.tab == config.tab) {
  1326. if (data.productID < id) {
  1327. data.productID = id;
  1328. data.id = config.id;
  1329. }
  1330. has = true;
  1331. break;
  1332. }
  1333. }
  1334. if (!has && unlock) {
  1335. data = { tab: config.tab, productID: id, id: config.id };
  1336. this._maxProduct.push(data);
  1337. }
  1338. gData.farmMapData.isStateChange = true;
  1339. this.updateMaxProduct();
  1340. }
  1341. /** 农场升级时解锁工厂,检查最大可种植/生产商品 */
  1342. public checkTaskFinishUnLock() {
  1343. let isUpdateToSever = false;
  1344. for (var key in ProductType) {
  1345. let tab = ProductType[key];
  1346. let configArr = this.getProductArrByType(tab);
  1347. let len = configArr.length;
  1348. let data = null;
  1349. let needUpdate = false;
  1350. switch (tab) {
  1351. case ProductType.nzw:
  1352. break;
  1353. case ProductType.dw:
  1354. let id = 30001;
  1355. needUpdate = false;
  1356. let maxId = 0;
  1357. for (var i = 0; i < len; i++) {
  1358. data = this.getPastureDataMap(id);
  1359. if (this.playerProp.completeFarmTaskTimes >= configArr[i].value) {
  1360. if (data.state == PastureState.Lock) {
  1361. data = { id: id, state: PastureState.Empty, productID: configArr[i].picture, growSpan: 0 };
  1362. this.setPastureDataMap(id, data, false);
  1363. needUpdate = true;
  1364. }
  1365. maxId = configArr[i].picture;
  1366. }
  1367. id++;
  1368. }
  1369. if (maxId != 0) {
  1370. //更新最大可购买商品
  1371. isUpdateToSever = true;
  1372. this.setMaxProduct(maxId, true);
  1373. this.addProductUnlockMaxId(tab, maxId, false);
  1374. }
  1375. //更新到服务器
  1376. if (needUpdate) {
  1377. this.setProp(GameProp.pastureData, this._pastureData);
  1378. this.setNextProduct();
  1379. }
  1380. break;
  1381. default:
  1382. //工厂解锁根据第一个商品
  1383. needUpdate = false;
  1384. let configID = this.getConfigIDByTab(tab);
  1385. data = this.getFactoryDataMap(configID);
  1386. if (this.playerProp.completeFarmTaskTimes >= configArr[0].value) {
  1387. if (data.state == FactroyState.Lock) {
  1388. data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
  1389. this.setFactoryDataMap(configID, data, false);
  1390. needUpdate = true;
  1391. }
  1392. //更新最大可购买商品
  1393. isUpdateToSever = true;
  1394. this.setMaxProduct(configArr[0].picture, true);
  1395. this.addProductUnlockMaxId(tab, configArr[0].picture, false);
  1396. }
  1397. if (needUpdate) {
  1398. this.setProp(GameProp.factoryData, this._factoryData);
  1399. this.setNextProduct();
  1400. }
  1401. break;
  1402. }
  1403. }
  1404. if(isUpdateToSever)
  1405. {
  1406. this.updateDataToSever();
  1407. }
  1408. }
  1409. checkCanSpeedUp(pop = false) {
  1410. let can = false;
  1411. can = gData.farmSystem.canSpeedUp();
  1412. if (!can) {
  1413. can = gData.pastureSystem.canSpeedUp();
  1414. if (!can) {
  1415. can = gData.factorySystem.canSpeedUp();
  1416. }
  1417. }
  1418. if (can && pop) {
  1419. mk.ui.openPanel('module/speedUpUI/speedUp');
  1420. }
  1421. return can;
  1422. }
  1423. setHarvest() {
  1424. gData.farmSystem.setHarvest();
  1425. gData.pastureSystem.setHarvest();
  1426. gData.factorySystem.setHarvest();
  1427. }
  1428. checkCanHarvest() {
  1429. let can = false;
  1430. can = gData.farmSystem.canHarvest();
  1431. if (!can) {
  1432. can = gData.pastureSystem.canHarvest();
  1433. if (!can) {
  1434. can = gData.factorySystem.canHarvest();
  1435. }
  1436. }
  1437. return can;
  1438. }
  1439. checkCanClearSick() {
  1440. let can = false;
  1441. can = gData.farmSystem.canClearSick();
  1442. if (!can) {
  1443. can = gData.pastureSystem.canClearSick();
  1444. if (!can) {
  1445. can = gData.factorySystem.canClearSick();
  1446. }
  1447. }
  1448. return can;
  1449. }
  1450. doPointToXYLogic() {
  1451. let value = mk.storage.getStorage('cash_out');
  1452. if (!value) {
  1453. mk.storage.setStorage('cash_out', 1);
  1454. mk.data.sendXYEvent('cash_1', `第一次提现`);
  1455. } else {
  1456. if (value == 1) {
  1457. mk.storage.setStorage('cash_out', 2);
  1458. mk.data.sendXYEvent('cash_2', `第二次提现`);
  1459. } else if (value == 2) {
  1460. mk.storage.setStorage('cash_out', 3);
  1461. mk.data.sendXYEvent('cash_3', `第三次提现`);
  1462. }
  1463. }
  1464. }
  1465. /** 更新最大可种植产品到服务器 */
  1466. async updateMaxProduct() {
  1467. if (this.maxProductToServer) {
  1468. let data = { "unLockProductList": this._maxProduct };
  1469. // for (let i = 0; i != this._maxProduct.length; ++i) {
  1470. // let dataE = this._maxProduct[i];
  1471. // let d = { id: dataE.productID, tab: dataE.tab };
  1472. // data.unLockProductList.push(d);
  1473. // }
  1474. mk.console.logSingle("updateMaxProduct", data);
  1475. let respone = await mk.http.sendData('orderTask/updateUnlockProduct', data);
  1476. console.log("------");
  1477. }
  1478. }
  1479. }
  1480. /**
  1481. * 所有模块的非校验数据
  1482. */
  1483. export enum GameProp {
  1484. /** -------------------- 通用玩家数据 ------------------------- */
  1485. /** 是否新手 0新手 1老手 */
  1486. newPlayer = 1,
  1487. /** 当前新手引导步骤 */
  1488. guideID = 2,
  1489. /** 需要自动弹界面 每次登录都弹 除首次 表示今日是否要自动开 1自动开 2不自动开 其他不处理*/
  1490. isAutoOpenPanel = 3,
  1491. /** 关闭常规提现时需要自动开存钱罐 每天一次 表示今日有没有开过 */
  1492. isOpenBankOnCloseCash = 4,
  1493. //看视频次数
  1494. videoTimes = 5,
  1495. //提现次数
  1496. cashTimes = 6,
  1497. /** ------------------ 游戏核心数据 --------------------------- */
  1498. /** 农田数据 */
  1499. farmData = 11,
  1500. /** 产品生产次数 */
  1501. productMakeTimes = 12,
  1502. /** 养殖场数据 */
  1503. pastureData = 14,
  1504. /** 工厂数据 */
  1505. factoryData = 15,
  1506. /** 剩余可种植次数 */
  1507. leftTimes = 16,
  1508. /**
  1509. 图鉴领取数据*/
  1510. farmMapGetRewardData = 17,
  1511. //红包任务tag
  1512. redBagTaskRefresh = 18,
  1513. /** ------------------ 转盘数据 ------------------------------ */
  1514. turnable_leftTimes = 20,
  1515. //提现次数
  1516. cashOutTimes = 21,
  1517. }
  1518. /**
  1519. * 玩家数据
  1520. */
  1521. class PlayerProp {
  1522. /** 自定义不需要校验的数据 */
  1523. gameUserData = 0;
  1524. _isSignInToday = 0;
  1525. /**
  1526. * 今日是否有签到
  1527. * - 0 未签到,表示可以签到
  1528. * - 1 有签到,表示不可签到
  1529. */
  1530. set isSignInToday(value: number) {
  1531. this._isSignInToday = value;
  1532. gData.sign.init_data = true;
  1533. gData.gameData.init_red_point = true;
  1534. }
  1535. get isSignInToday(): number {
  1536. return this._isSignInToday;
  1537. }
  1538. private _piggyBank: number = 0;
  1539. /** 存钱罐存款 */
  1540. set piggyBank(value: number) {
  1541. if (this._piggyBank === value) return;
  1542. if (gData.gameData.playerProp.isWithdrawable && value > 0) return;// 存钱罐可提现状态,不能增加存钱罐金额
  1543. this._piggyBank = value;
  1544. gData.gameData.init_coin = true;
  1545. gData.gameData.init_red_point = true;
  1546. }
  1547. get piggyBank(): number {
  1548. return this._piggyBank;
  1549. }
  1550. /** 初始化 */
  1551. initPiggyBank(v) {
  1552. this._piggyBank = v;
  1553. }
  1554. _isWithdrawable = 0;
  1555. /**
  1556. * 存钱罐能否提现
  1557. * - 0 不能提现
  1558. * - 1 能提现
  1559. */
  1560. set isWithdrawable(value: number) {
  1561. if (this._isWithdrawable != value) {
  1562. this._isWithdrawable = value;
  1563. gData.gameData.init_red_point = true;
  1564. }
  1565. }
  1566. get isWithdrawable(): number {
  1567. return this._isWithdrawable;
  1568. }
  1569. /** 存钱罐每日提现次数 */
  1570. piggyBankCashTimes = 0;
  1571. /** 累计存钱罐每日提现次数 */
  1572. totalPiggyBankCashTimes = 0;
  1573. /** 提现进度 */
  1574. cashIndex = 0;
  1575. /** 上次登录时间 */
  1576. lastTime = 0;
  1577. /** 登录天数 */
  1578. loginDays = 0;
  1579. newPlayer = 0;
  1580. private _redMoney: number = 0;
  1581. /** 红包币数量 */
  1582. set redMoney(value: number) {
  1583. this._redMoney = value;
  1584. gData.gameData.init_coin = true;
  1585. //gData.gameData.init_red_point = true;
  1586. gData.gameData.init_wallet_redMoney = true;
  1587. mk.event.emit('refreshCoin');
  1588. mk.data.setTAEventUser(0, 'current_redmoney_stock', this._redMoney);
  1589. }
  1590. get redMoney(): number {
  1591. return this._redMoney;
  1592. }
  1593. _signInDay = 0;
  1594. /** 累计签到次数 客户端理解 上次签到天数 */
  1595. set signInDay(value: number) {
  1596. if (this._signInDay === value) return;
  1597. this._signInDay = value;
  1598. gData.sign.init_data = true;
  1599. }
  1600. get signInDay(): number {
  1601. return this._signInDay;
  1602. }
  1603. /** 转盘次数 */
  1604. turntableTimes = 0;
  1605. /** 版本号 */
  1606. versioncfg = 0;
  1607. /** 福袋数据 */
  1608. userTuCaoInfo = 0;
  1609. /** 能免费领红包 1 表示是新人第一次产出红包币,不用看视频*/
  1610. isFirstRedMoney = 0;
  1611. //农场等级
  1612. gradeLevel = 1;
  1613. //农场等级奖励数据
  1614. farmGradeData: any = {};
  1615. //农场等级名字
  1616. farmGradeName: number = 1;
  1617. //农场经验
  1618. private farmExp = 0;
  1619. set farmExpValue(value: number) {
  1620. this.farmExp = value;
  1621. gData.gameData.init_expLevel = true;
  1622. }
  1623. get farmExpValue(): number {
  1624. return this.farmExp;
  1625. }
  1626. //提现新手数据
  1627. userNoviceWeFareInfo: any = {};
  1628. //提现记录数据
  1629. redMoneyCashPayRecordList = null;
  1630. //任务红;
  1631. userFarmTaskInfo = null;
  1632. getRedMoneyCashOutTimesByIndex(index: number): number {
  1633. if (this.redMoneyCashPayRecordList) {
  1634. for (let i = 0; i != this.redMoneyCashPayRecordList.length; ++i) {
  1635. if (index === this.redMoneyCashPayRecordList[i].index) {
  1636. return this.redMoneyCashPayRecordList[i].frequency;
  1637. }
  1638. }
  1639. }
  1640. return 0;
  1641. }
  1642. /** ABTest分组id */
  1643. groupCode = 0;
  1644. //加速剩余次数
  1645. speedUpLeftTimes = 0;
  1646. /** 农场任务完成次数 */
  1647. completeFarmTaskTimes = 0;
  1648. /** 订单数据 */
  1649. orderData = null;
  1650. /** 临时订单数据, 只用于种植优先选择作用 */
  1651. copyOrderData = null;
  1652. //插队看视频次数限制
  1653. lineRedMoney = 0;
  1654. }
  1655. /**
  1656. * 奖励状态
  1657. */
  1658. export enum RewardState {
  1659. /** 已领取 */
  1660. none = 1,
  1661. /** 未解锁 */
  1662. lock = 2,
  1663. /** 可领取 */
  1664. unlock = 3
  1665. }
  1666. /**
  1667. * 奖励类型
  1668. */
  1669. export enum RewardType {
  1670. /** 红包币 */
  1671. redBag = 1,
  1672. /** 毛币 */
  1673. rmb = 2,
  1674. /** 金猪币 */
  1675. pigRmb = 3,
  1676. /** 生产次数 */
  1677. productTimes = 4,
  1678. }
  1679. /**
  1680. * 音频路径
  1681. */
  1682. export enum AUDIO_TYPE {
  1683. /**主界面背景音乐*/
  1684. bgm = 'bgm',
  1685. /**打开存钱罐界面播放一次*/
  1686. pigBank = 'pigBank',
  1687. /**关卡玩法背景音乐*/
  1688. missionBg = 'missionBg',
  1689. /**红包币领取界面关闭音效*/
  1690. rewardClose = 'rewardClose',
  1691. /**红包币领取界面开启音效*/
  1692. rewardOpen = 'rewardOpen',
  1693. /**红包界面打开音效*/
  1694. reward = 'reward',
  1695. /**提现到账界面打开播放一次*/
  1696. receiptNotice = 'receiptNotice',
  1697. /**通用按钮点击音效 */
  1698. button = 'button',
  1699. /**转盘转动音效*/
  1700. turnableplay = 'turnableplay',
  1701. /**转盘转动音效*/
  1702. turnplateDrawEnd = 'turnplateDrawEnd',
  1703. /**主页背景音乐 */
  1704. music_startBg = "music_startBg",
  1705. /**游戏背景音乐 */
  1706. music_gameBg = "music_gameBg",
  1707. /**按钮点击 */
  1708. ef_button_click = "ef_button_click",
  1709. /**红包打开 */
  1710. ef_redPacket_open = "ef_redPacket_open",
  1711. /**红包来了音效 */
  1712. ef_redPacket_come = "ef_redPacket_come",
  1713. /**消除4个 */
  1714. ef_bonus4 = "ef_bonus4",
  1715. /**消除5个 */
  1716. ef_bonus5 = "ef_bonus5",
  1717. /**消除6个 */
  1718. ef_bonus6 = "ef_bonus6",
  1719. /**消除7个 */
  1720. ef_bonus7 = "ef_bonus7",
  1721. /**消除8个 */
  1722. ef_bonus8 = "ef_bonus8",
  1723. /**普通消除音效 */
  1724. ef_eliminate = "ef_eliminate",
  1725. /**bouns消除音效 */
  1726. ef_eliminate_bonus = "ef_eliminate_bonus",
  1727. /**胜利音效 */
  1728. ef_win = "ef_win",
  1729. /**锤子 */
  1730. ef_change = "ef_change",
  1731. /**刷新 */
  1732. ef_refresh = "ef_refresh",
  1733. /**飞翔 */
  1734. ef_fly = "ef_fly",
  1735. /**关闭按钮音效*/
  1736. closeButton = "closeButton",
  1737. //红包界面打开
  1738. congratulations = 'congratulations',
  1739. //红包飞音效
  1740. redmoney = 'redmoney'
  1741. }
  1742. /** ECPM */
  1743. type ADShowCfg = {
  1744. average_ecpm: number,
  1745. insert_probability: number,
  1746. is_show_banner: number,
  1747. is_show_inter: number,
  1748. }
  1749. /**事件类型 */
  1750. export enum EVENT_TYPE {
  1751. BACK_WxAuth = "BACK_WxAuth",
  1752. UPDATE_CashNum = "UPDATE_CashNum",
  1753. }
  1754. /** 数据事件Id */
  1755. export enum DataEventId {
  1756. /** 点击 */
  1757. guide = "guide",
  1758. /** 点击跳过 */
  1759. guideSkip = "guideSkip",
  1760. /** 按钮点击 */
  1761. button_click = "button_click",
  1762. /** 看视频 */
  1763. video_init = "video_init",
  1764. /** 看视频完成 */
  1765. video_end = "video_end",
  1766. /** 成功拉取全屏视频 */
  1767. interstitial2_init = "interstitial2_init",
  1768. /** 广告点击 */
  1769. Ad_click = "Ad_click",
  1770. /** 全屏视频完成 */
  1771. interstitial2_end = "interstitial2_end",
  1772. /** 福袋功能 */
  1773. fudaiFunction = "fudaiFunction",
  1774. /** 互推功能 */
  1775. hutuiFunction = "hutuiFunction",
  1776. /** 激励视频ecpm */
  1777. ad_videoEcpm = 'ad_video',
  1778. /** 开屏ecpm */
  1779. ad_openEcpm = 'ad_open',
  1780. /** 提现 */
  1781. Sundry = 'Sundry',
  1782. /** 加载 */
  1783. loading = 'loading',
  1784. /** 排队 */
  1785. queue = 'queue'
  1786. }
  1787. /** 视频广告类型 */
  1788. export enum VideoAdType {
  1789. video_init_1 = '农场加等级经验',
  1790. video_init_2 = '提现-加进度',
  1791. video_init_3 = '提现-加现金',
  1792. video_init_4 = '签到',
  1793. video_init_5 = '抽奖',
  1794. video_init_6 = '图鉴领奖',
  1795. video_init_7 = '消灭害虫',
  1796. video_init_8 = '恢复健康',
  1797. video_init_9 = '恢复供电',
  1798. video_init_10 = '山羊红包',
  1799. video_init_11 = '拓建',
  1800. video_init_12 = '收获',
  1801. video_init_13 = '飘浮红包',
  1802. video_init_14 = '全体加速',
  1803. video_init_15 = '福利加进度',
  1804. video_init_16 = '生产加次数',
  1805. video_init_17 = '点击生产按钮',
  1806. video_init_18 = '离开游戏领红包',
  1807. video_init_19 = '定时弹出红包',
  1808. video_init_20 = '插队',
  1809. video_init_21 = '恢复生产次数',
  1810. }
  1811. export enum InterFullAdType {
  1812. interstitial2_init_1 = '点击红包的关闭按钮',
  1813. interstitial2_init_2 = '普通收获',
  1814. interstitial2_init_3 = '点击鸟和狗'
  1815. }
  1816. export enum InterAdType {
  1817. interstitial1_click_1 = '恭喜发财红包弹出后',
  1818. interstitial1_click_2 = '恭喜获得弹窗弹出后',
  1819. interstitial1_click_3 = '生虫/生病/停电弹出后'
  1820. }
  1821. export enum BannerAdType {
  1822. banner_click_1 = '恭喜获得弹窗弹出后',
  1823. banner_click_2 = '任务红包',
  1824. banner_click_3 = '恭喜发财红包',
  1825. banner_click_4 = '图鉴',
  1826. banner_click_5 = '全体加速',
  1827. banner_click_6 = '收获弹窗',
  1828. banner_click_7 = '拓建弹窗',
  1829. banner_click_8 = '三个恢复弹窗',
  1830. banner_click_9 = '抽奖'
  1831. }
  1832. export enum ExpAddType {
  1833. EAT_video = 1,
  1834. EAT_harvest = 2,
  1835. EAT_others = 3,
  1836. }
  1837. export enum FarmState {
  1838. Lock,
  1839. CanUnlock,
  1840. Empty,
  1841. Growing,
  1842. Ripe,
  1843. Sick
  1844. }
  1845. export enum PastureState {
  1846. Lock,
  1847. Empty,
  1848. Growing,
  1849. Ripe,
  1850. Sick
  1851. }
  1852. export enum ProductType {
  1853. nzw = '农作物',
  1854. dw = '动物',
  1855. bmhc = '爆米花厂',
  1856. gdp = '糕点铺',
  1857. ztc = '制糖厂',
  1858. lrc = '炼乳厂',
  1859. gfmg = '功夫面馆',
  1860. kcd = '快餐店'
  1861. }
  1862. /** 动物状态 */
  1863. export enum AnimalState {
  1864. Hanger,
  1865. Eat,
  1866. Wait
  1867. }
  1868. export enum FactroyState {
  1869. Lock,
  1870. Empty,
  1871. Producting,
  1872. Ripe,
  1873. Sick
  1874. }