GameData.ts 47 KB

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