GameData.ts 49 KB

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