GameData.ts 49 KB

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