|
|
@@ -1,6 +1,7 @@
|
|
|
import Util from "../../before/util/Util";
|
|
|
import FunBtns from "../game/FunBtns";
|
|
|
import Game from "../game/Game";
|
|
|
+import { RateConfig } from "./AdData";
|
|
|
import { StorageKey } from "./StorageData";
|
|
|
|
|
|
/**
|
|
|
@@ -186,15 +187,13 @@ export class GameData {
|
|
|
this.prohibitProductionAd = this.configs.ServerConfig.ProhibitProductionAd.split(";");
|
|
|
this.productionAdMaxTimes = this.configs.ServerConfig.ProductionAdMax;
|
|
|
|
|
|
- console.log(`popIdentifySwitch=======${gData.loginData.popIdentifySwitch}`);
|
|
|
- console.log(`prohibiJBAd=======${this.prohibiJBAd}`);
|
|
|
- console.log(`prohibitProductionAd=======${this.prohibitProductionAd}`);
|
|
|
- console.log(`productionAdMaxTimes=======${this.productionAdMaxTimes}`);
|
|
|
gData.gameData.shareUrl = this.configs.ServerConfig.shareUrl;
|
|
|
gData.gameData.shareTitle = this.configs.ServerConfig.shareTitle;
|
|
|
gData.gameData.shareDes = this.configs.ServerConfig.shareDes;
|
|
|
gData.gameData.shareImgUrl = this.configs.ServerConfig.shareImgUrl;
|
|
|
gData.gameData.RawInsectArr = this.configs.ServerConfig.RawInsect.split(',');
|
|
|
+ //富翁银行
|
|
|
+ gData.safeDepositBoxData.richBankConfig = this.configs.BankTask;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -225,21 +224,15 @@ export class GameData {
|
|
|
this.playerProp.farmGradeData = res_data.userFarmGrageRewardInfo;
|
|
|
this.playerProp.userNoviceWeFareInfo = res_data.userNoviceWeFareInfo;
|
|
|
this.playerProp.redMoneyCashPayRecordList = res_data.redMoneyCashPayRecordList;
|
|
|
- mk.console.logSingle('userNoviceWeFareInfo==>', res_data.userNoviceWeFareInfo);
|
|
|
- //mk.console.logSingle('redMoneyCashPayRecordList==>', res_data.redMoneyCashPayRecordList);
|
|
|
this.playerProp.userFarmTaskInfo = res_data.userFarmTaskInfo;
|
|
|
this.playerProp.speedUpLeftTimes = res_data.speedUpLeftTimes;
|
|
|
this.playerProp.completeFarmTaskTimes = res_data.completeFarmTaskTimes;
|
|
|
this.playerProp.orderData = res_data.userOrderTaskInfo;
|
|
|
this.playerProp.lineRedMoney = res_data.lineRedMoney;
|
|
|
- console.log("==============initPlayerProp");
|
|
|
- console.log(res_data.userOrderTaskInfo);
|
|
|
- mk.console.logSingle('userOrderTaskInfo', res_data.userOrderTaskInfo);
|
|
|
+ //this.playerProp.orderData.overTimes = 3;
|
|
|
//this.cloneOrderData();
|
|
|
-
|
|
|
this.playerProp.curProductionAdTimes = res_data.dailyProductionTimes;
|
|
|
- console.log(`curProductionAdTimes=======${this.playerProp.curProductionAdTimes}`);
|
|
|
-
|
|
|
+
|
|
|
mk.data.setTAUserID(gData.loginData.uin);
|
|
|
mk.data.setTAEventUser(0, 'logindays_total', this.playerProp.loginDays);
|
|
|
if (this.playerProp.completeFarmTaskTimes == 0) {
|
|
|
@@ -266,6 +259,19 @@ export class GameData {
|
|
|
//渠道号
|
|
|
mk.data.setTAEventUserStr(0, 'channel_id', gData.appData.umengChannel);
|
|
|
|
|
|
+ //富翁银行
|
|
|
+ gData.safeDepositBoxData.richBankCashAmount = res_data.richBankCashAmount;
|
|
|
+ gData.safeDepositBoxData.currentRichBankCashTaskIndex = res_data.currentRichBankCashTaskIndex;
|
|
|
+ //gData.safeDepositBoxData.addRichBankFinishIndex = res_data.addRichBankFinishIndex;
|
|
|
+ // if (gData.safeDepositBoxData.currentRichBankCashTaskIndex > 0) {
|
|
|
+ // gData.safeDepositBoxData.addRichBankFinishIndex = gData.safeDepositBoxData.currentRichBankCashTaskIndex;
|
|
|
+ // }
|
|
|
+ gData.safeDepositBoxData.isStartBankTask = res_data.isStartRichBankTask;
|
|
|
+ gData.safeDepositBoxData.richBankDailyVideoTimes = res_data.richBankDailyVideoTimes;
|
|
|
+ gData.safeDepositBoxData.richbankLoginDays = res_data.richbankLoginDays;
|
|
|
+ gData.safeDepositBoxData.richBankDailyTotelVideoTimes = res_data.richBankDailyTotelVideoTimes;
|
|
|
+ console.log(`richBankDailyTotelVideoTimes ======== ${res_data.richBankDailyTotelVideoTimes}`);
|
|
|
+
|
|
|
// //test
|
|
|
// this.playerProp.completeFarmTaskTimes = 3;
|
|
|
}
|
|
|
@@ -415,7 +421,7 @@ export class GameData {
|
|
|
/** 增加减少生产次数
|
|
|
* @param add 增减变量
|
|
|
*/
|
|
|
- public changeLeftTimes(add, isIgnoreMaxTimes = false, isRefresh = true) {
|
|
|
+ public async changeLeftTimes(add, isIgnoreMaxTimes = false, isRefresh = true) {
|
|
|
|
|
|
gData.gameData.leftTimes += add;
|
|
|
if (add > 0 && !isIgnoreMaxTimes) {
|
|
|
@@ -425,7 +431,7 @@ export class GameData {
|
|
|
if (gData.gameData.leftTimes < 0) {
|
|
|
gData.gameData.leftTimes = 0;
|
|
|
}
|
|
|
- gData.gameData.setProp(GameProp.leftTimes, gData.gameData.leftTimes);
|
|
|
+ await gData.gameData.setProp(GameProp.leftTimes, gData.gameData.leftTimes);
|
|
|
|
|
|
if (isRefresh) {
|
|
|
gData.gameData.init_leftTimes = true;
|
|
|
@@ -471,7 +477,6 @@ export class GameData {
|
|
|
}
|
|
|
this._farmMapRewardData.push(arr);
|
|
|
needSync = true;
|
|
|
- console.log("-----add 数组数据")
|
|
|
} else {
|
|
|
let data = this._farmMapRewardData[index];
|
|
|
let len = value.length;
|
|
|
@@ -479,7 +484,6 @@ export class GameData {
|
|
|
if (i >= data.length) {
|
|
|
data.push(0);
|
|
|
needSync = true;
|
|
|
- console.log("-----add 单个数据")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -499,13 +503,11 @@ export class GameData {
|
|
|
} else {
|
|
|
this._cashOutTimes = 0;
|
|
|
}
|
|
|
- console.log(`initCashOutTimes====>${this._cashOutTimes}`);
|
|
|
}
|
|
|
|
|
|
public addCashOutTimes() {
|
|
|
this._cashOutTimes += 1;
|
|
|
this.setProp(GameProp.cashOutTimes, this._cashOutTimes);
|
|
|
- console.log(`addCashOutTimes====>${this._cashOutTimes}`);
|
|
|
}
|
|
|
|
|
|
/** 是否是新用户 */
|
|
|
@@ -537,13 +539,12 @@ export class GameData {
|
|
|
let productJson = this.configs.Product;
|
|
|
for (let i = 0; i != orderData.length; ++i) {
|
|
|
let dataE = orderData[i];
|
|
|
- //console.log(`getRandomPlantConfig======= ${this.playerProp.copyOrderData[i]}`);
|
|
|
if (dataE.completeCount < dataE.taskCount) {
|
|
|
if (dataE.Id <= productJson.length) {
|
|
|
isNoAllComplete = true;
|
|
|
let productData = productJson[dataE.Id - 1];
|
|
|
if (productData.tab == ProductType.nzw) {
|
|
|
- let max = this.getMaxProduct(ProductType.nzw);
|
|
|
+ let max = this.getMaxProductExtra(ProductType.nzw);
|
|
|
if (max && productData.picture <= max) {
|
|
|
id = productData.picture;
|
|
|
isNoHaveCurTab = false;
|
|
|
@@ -559,7 +560,6 @@ export class GameData {
|
|
|
}
|
|
|
} else {
|
|
|
isOrderDataInvalid = true;
|
|
|
- console.log("订单数据有问题,随机id");
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -572,10 +572,9 @@ export class GameData {
|
|
|
// id = picId;
|
|
|
// } else
|
|
|
{
|
|
|
- id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
|
|
|
+ id = Util.rnd(10001, this.getMaxProductExtra(ProductType.nzw));
|
|
|
this.nextType = 1
|
|
|
}
|
|
|
- console.log("订单数据没有匹配成功====1");
|
|
|
}
|
|
|
} else {
|
|
|
isOrderDataInvalid = true;
|
|
|
@@ -584,10 +583,9 @@ export class GameData {
|
|
|
// id = picId;
|
|
|
// } else
|
|
|
{
|
|
|
- id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
|
|
|
+ id = Util.rnd(10001, this.getMaxProductExtra(ProductType.nzw));
|
|
|
this.nextType = 1
|
|
|
}
|
|
|
- console.log("订单数据为null");
|
|
|
}
|
|
|
|
|
|
//选择逻辑处理
|
|
|
@@ -625,19 +623,14 @@ export class GameData {
|
|
|
}
|
|
|
|
|
|
if (isHaveEmpty) {
|
|
|
- console.log("getRandomPlantConfig====0");
|
|
|
return null;
|
|
|
-
|
|
|
} else {
|
|
|
- console.log("getRandomPlantConfig====1");
|
|
|
return this.getProductMap(id);
|
|
|
}
|
|
|
} else {
|
|
|
- console.log("getRandomPlantConfig====2");
|
|
|
return this.getProductMap(id);
|
|
|
}
|
|
|
} else {
|
|
|
- console.log("getRandomPlantConfig====3");
|
|
|
return this.getProductMap(id);
|
|
|
}
|
|
|
}
|
|
|
@@ -646,6 +639,93 @@ export class GameData {
|
|
|
//return this.getProductMap(id);
|
|
|
}
|
|
|
|
|
|
+ getRandomPlantConfigExtra(out: any) {
|
|
|
+ let id = 0;
|
|
|
+ let cropArray = [];
|
|
|
+ let factoryArray = [];
|
|
|
+ let animalArray = [];
|
|
|
+ let data = this.playerProp.orderData;
|
|
|
+ let orderData = data.orderTaskList;
|
|
|
+ if (data && orderData) {
|
|
|
+ let productJson = this.configs.Product;
|
|
|
+ for (let i = 0; i != orderData.length; ++i) {
|
|
|
+ let dataE = orderData[i];
|
|
|
+ if (dataE.completeCount < dataE.taskCount) {
|
|
|
+ if (dataE.Id <= productJson.length) {
|
|
|
+ let productData = productJson[dataE.Id - 1];
|
|
|
+ if (productData.tab == ProductType.nzw) {
|
|
|
+ let max = this.getMaxProductExtra(ProductType.nzw);
|
|
|
+ if (max && productData.picture <= max) {
|
|
|
+ cropArray.push(productData.picture);
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if (productData.tab == ProductType.dw) {
|
|
|
+ animalArray.push(productData.picture);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ factoryArray.push(productData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //从三种类型随机选择逻辑
|
|
|
+ let typeArr = [];
|
|
|
+ let matchSuccessFactorys = null;
|
|
|
+ let matchSuccessPastures = null;
|
|
|
+ if (cropArray.length > 0) {
|
|
|
+ typeArr.push(0);
|
|
|
+ }
|
|
|
+ if (factoryArray.length > 0) {
|
|
|
+ matchSuccessFactorys = gData.factorySystem.isHaveEmptyFactory(factoryArray);
|
|
|
+ if(matchSuccessFactorys.length > 0){
|
|
|
+ typeArr.push(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (animalArray.length > 0) {
|
|
|
+ matchSuccessPastures = gData.pastureSystem.isHaveEmptyPasture(animalArray);
|
|
|
+ if(matchSuccessPastures.length > 0){
|
|
|
+ typeArr.push(2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(typeArr.length > 0)
|
|
|
+ {
|
|
|
+ let rand = mk.math.random(0, typeArr.length-1);
|
|
|
+ let type = typeArr[rand];
|
|
|
+ if (type == 0) {
|
|
|
+ let randCrop = mk.math.random(0, cropArray.length-1);
|
|
|
+ id = cropArray[randCrop];
|
|
|
+ this.nextType = 1
|
|
|
+ return this.getProductMap(id);
|
|
|
+ } else if (type == 1) {
|
|
|
+ let randFactory = mk.math.random(0, matchSuccessFactorys.length-1);
|
|
|
+ let factory = matchSuccessFactorys[randFactory];
|
|
|
+ this.nextCanProduct = this.getProductMap(factory.picture);
|
|
|
+ this.nextMake = factory.key;
|
|
|
+ this.nextType = 3;
|
|
|
+ return this.nextMake;
|
|
|
+ } else if (type == 2) {
|
|
|
+ let randPasture = mk.math.random(0, matchSuccessPastures.length-1);
|
|
|
+ let pasture = matchSuccessPastures[randPasture];
|
|
|
+ this.nextCanProduct = this.getProductMap(pasture.data.productID);
|
|
|
+ this.nextMake = pasture
|
|
|
+ this.nextType = 2;
|
|
|
+ return pasture;
|
|
|
+ }
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ id = Util.rnd(10001, this.getMaxProductExtra(ProductType.nzw));
|
|
|
+ this.nextType = 1
|
|
|
+ return this.getProductMap(id);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ id = Util.rnd(10001, this.getMaxProductExtra(ProductType.nzw));
|
|
|
+ this.nextType = 1
|
|
|
+ return this.getProductMap(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public doJudgeOrderLogic(out?: any) {
|
|
|
let data = this.playerProp.orderData;
|
|
|
let orderData = data.orderTaskList;
|
|
|
@@ -659,14 +739,11 @@ export class GameData {
|
|
|
if (productData.tab == ProductType.nzw) {
|
|
|
continue;
|
|
|
} else if (productData.tab == ProductType.dw) {
|
|
|
- console.log(`doJudgeOrderLogic=====${dataE.Id}`);
|
|
|
let pastureIcon = gData.pastureSystem.pastureIcons;
|
|
|
let len = pastureIcon.length;
|
|
|
for (var j = 0; j < len; j++) {
|
|
|
if (pastureIcon[j].data.productID == productData.picture && pastureIcon[j].data.state == PastureState.Empty) {
|
|
|
out.state = 2;
|
|
|
- console.log("doJudgeOrderLogic====2");
|
|
|
- console.log("doJudgeOrderLogic====22");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
@@ -678,8 +755,6 @@ export class GameData {
|
|
|
let tab = this.getTabByConfigID(factoryIcon[j].configID);
|
|
|
if (tab == productData.tab && factoryIcon[j].data.state == FactroyState.Empty) {
|
|
|
out.state = 1;
|
|
|
- console.log("doJudgeOrderLogic====1");
|
|
|
- console.log("doJudgeOrderLogic====11");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
@@ -694,7 +769,7 @@ export class GameData {
|
|
|
getRandomFactoryConfig(configID) {
|
|
|
let tab = gData.gameData.getTabByConfigID(configID);
|
|
|
let arr = this.getProductArrByType(tab);
|
|
|
- let max = this.getMaxProduct(tab);
|
|
|
+ let max = this.getMaxProductExtra(tab);
|
|
|
let canArr = [];
|
|
|
let len = arr.length;
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
@@ -715,7 +790,7 @@ export class GameData {
|
|
|
let value = 0;
|
|
|
for (let key in ProductType) {
|
|
|
if (startIndex <= value) {
|
|
|
- let max = this.getMaxProduct(ProductType[key]);
|
|
|
+ let max = this.getMaxProductExtra(ProductType[key]);
|
|
|
if (max) {
|
|
|
let list_data = this.getProductArrByType(ProductType[key]);
|
|
|
for (let i = 0; i != list_data.length; ++i) {
|
|
|
@@ -725,7 +800,6 @@ export class GameData {
|
|
|
if (state == 0) {
|
|
|
switch (ProductType[key]) {
|
|
|
case ProductType.nzw:
|
|
|
- console.log("图鉴数据匹配成功=====1");
|
|
|
this.nextType = 1
|
|
|
return picId;
|
|
|
case ProductType.dw:
|
|
|
@@ -737,8 +811,7 @@ export class GameData {
|
|
|
if (isHaveEmpty && startIndex == value) {
|
|
|
isHaveEmpty.state = true;
|
|
|
}
|
|
|
- if (picId == pastureIconsData[index].data.productID) {
|
|
|
- console.log("图鉴数据匹配成功====2");
|
|
|
+ if (picId == pastureIconsData[index].data.productID) {
|
|
|
this.nextCanProduct = this.getProductMap(pastureIconsData[index].data.productID);
|
|
|
this.nextMake = pastureIconsData[index];
|
|
|
this.nextType = 2;
|
|
|
@@ -758,8 +831,7 @@ export class GameData {
|
|
|
isHaveEmpty.state = true;
|
|
|
}
|
|
|
let tab = this.getTabByConfigID(factoryIconsData[index].configID);
|
|
|
- if (tab == ProductType[key]) {
|
|
|
- console.log("图鉴数据匹配成功=====3");
|
|
|
+ if (tab == ProductType[key]) {
|
|
|
this.nextCanProduct = this.getProductMap(picId);
|
|
|
this.nextMake = factoryIconsData[index];
|
|
|
this.nextType = 3;
|
|
|
@@ -777,7 +849,6 @@ export class GameData {
|
|
|
}
|
|
|
++value;
|
|
|
}
|
|
|
- console.log("图鉴数据匹配不成功");
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@@ -790,12 +861,15 @@ export class GameData {
|
|
|
let haveEmpty = { state: -1 };
|
|
|
let next = gData.farmSystem.selectNextFarm(haveEmpty, sel);
|
|
|
if (!next) {
|
|
|
- if (haveEmpty.state == -1) {
|
|
|
- this.doJudgeOrderLogic(haveEmpty);
|
|
|
- }
|
|
|
- let next1 = gData.pastureSystem.nextPasture(haveEmpty);
|
|
|
+ //订单随机种植此处可注释掉
|
|
|
+ // if (haveEmpty.state == -1) {
|
|
|
+ // this.doJudgeOrderLogic(haveEmpty);
|
|
|
+ // }
|
|
|
+ //let next1 = gData.pastureSystem.nextPasture(haveEmpty);
|
|
|
+ let next1 = gData.pastureSystem.nextPastureExtra();
|
|
|
if (!next1) {
|
|
|
- let next2 = gData.factorySystem.nextFactory(haveEmpty);
|
|
|
+ //let next2 = gData.factorySystem.nextFactory(haveEmpty);
|
|
|
+ let next2 = gData.factorySystem.nextFactoryExtra();
|
|
|
if (!next2) {
|
|
|
this.nextType = 0;
|
|
|
}
|
|
|
@@ -840,16 +914,28 @@ export class GameData {
|
|
|
flyRed = false;
|
|
|
break;
|
|
|
case 1:
|
|
|
- flyRed = await gData.farmSystem.btnMake();
|
|
|
- gData.adData.checkPopRed();
|
|
|
+ if(this.popSpeedUpByRate()){
|
|
|
+ flyRed = false;
|
|
|
+ }else{
|
|
|
+ flyRed = await gData.farmSystem.btnMake();
|
|
|
+ gData.adData.checkPopRed();
|
|
|
+ }
|
|
|
break;
|
|
|
case 2:
|
|
|
- flyRed = await gData.pastureSystem.btnMake();
|
|
|
- gData.adData.checkPopRed();
|
|
|
+ if(this.popSpeedUpByRate()){
|
|
|
+ flyRed = false;
|
|
|
+ }else{
|
|
|
+ flyRed = await gData.pastureSystem.btnMake();
|
|
|
+ gData.adData.checkPopRed();
|
|
|
+ }
|
|
|
break;
|
|
|
case 3:
|
|
|
- flyRed = await gData.factorySystem.btnMake();
|
|
|
- gData.adData.checkPopRed();
|
|
|
+ if(this.popSpeedUpByRate()){
|
|
|
+ flyRed = false;
|
|
|
+ }else{
|
|
|
+ flyRed = await gData.factorySystem.btnMake();
|
|
|
+ gData.adData.checkPopRed();
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
return flyRed;
|
|
|
@@ -962,7 +1048,7 @@ export class GameData {
|
|
|
this.RawInsectCurArr[0] = sickTimes;
|
|
|
}
|
|
|
|
|
|
- this.setMaxProduct(10003, true);
|
|
|
+ //this.setMaxProduct(10003, true);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1001,25 +1087,73 @@ export class GameData {
|
|
|
return this._productTypeMap.get(type);
|
|
|
}
|
|
|
|
|
|
+ //根据tab获取最大id的数据
|
|
|
+ public getMaxProductDataByType(type: ProductType, id) {
|
|
|
+ let arr = this._productTypeMap.get(type);
|
|
|
+ let len = arr.length;
|
|
|
+ if (arr[len - 1].picture >= id) {
|
|
|
+ return this.getProductMap(id);
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/** 产品生产/种植次数 服务器数据 */
|
|
|
- private _productMakeTimesData = [];
|
|
|
+ private _productMakeTimesData: any = {};
|
|
|
/** 产品生产/种植次数 */
|
|
|
private _productMakeTimesMap: Map<number, number> = new Map();
|
|
|
|
|
|
+ //产品解锁最大id
|
|
|
+ private _productUnlockMaxId: Map<string, number> = new Map();
|
|
|
+
|
|
|
private initProductTimes() {
|
|
|
- this._productMakeTimesData = this.getProp(GameProp.productMakeTimes);
|
|
|
- if (!this._productMakeTimesData) {
|
|
|
- this._productMakeTimesData = [];
|
|
|
+ let needUpdate = false;
|
|
|
+ let value = this.getProp(GameProp.productMakeTimes);
|
|
|
+ if (!value) {
|
|
|
+ this._productMakeTimesData.makeTimes = [];
|
|
|
+ this._productMakeTimesData.productUnlockMaxId = new Map<string, number>();
|
|
|
+ this._productMakeTimesData.productUnlockMaxId.set(ProductType.nzw, 10003);
|
|
|
+ } else {
|
|
|
+ if (value instanceof Array) {
|
|
|
+
|
|
|
+ this._productMakeTimesData.makeTimes = value;
|
|
|
+ this._productMakeTimesData.productUnlockMaxId = new Map<string, number>();
|
|
|
+ this._productMakeTimesData.productUnlockMaxId.set(ProductType.nzw, 10003);
|
|
|
+
|
|
|
+ let len = value.length;
|
|
|
+ for (let i = 0; i != len; ++i) {
|
|
|
+ let data = value[i];
|
|
|
+ let config = this.getProductMap(data.id);
|
|
|
+
|
|
|
+ let v = this._productMakeTimesData.productUnlockMaxId.get(config.tab);
|
|
|
+ if (v) {
|
|
|
+ if (v < data.id) {
|
|
|
+ this._productMakeTimesData.productUnlockMaxId.set(config.tab, data.id);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this._productMakeTimesData.productUnlockMaxId.set(config.tab, data.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ needUpdate = true;
|
|
|
+ } else {
|
|
|
+ this._productMakeTimesData.makeTimes = value.makeTimes;
|
|
|
+ this._productMakeTimesData.productUnlockMaxId = this.objToMap(JSON.parse(value.productUnlockMaxId));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- let len = this._productMakeTimesData.length;
|
|
|
+ let len = this._productMakeTimesData.makeTimes.length;
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
- this._productMakeTimesMap.set(this._productMakeTimesData[i].id, this._productMakeTimesData[i].times);
|
|
|
- this.setMaxProduct(this._productMakeTimesData[i].id);
|
|
|
+ this._productMakeTimesMap.set(this._productMakeTimesData.makeTimes[i].id, this._productMakeTimesData.makeTimes[i].times);
|
|
|
+ //this.setMaxProduct(this._productMakeTimesData.makeTimes[i].id);
|
|
|
+ }
|
|
|
+
|
|
|
+ let isUpdate = this.judgeAddExtraUnlockMaxId();
|
|
|
+ if (needUpdate || isUpdate) {
|
|
|
+ this.updateDataToSever();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- addProductMakeTimesById(id: number) {
|
|
|
+ async addProductMakeTimesById(id: number) {
|
|
|
let isAddMaxProduct = false;
|
|
|
let times = this._productMakeTimesMap.get(id);
|
|
|
if (!times) {
|
|
|
@@ -1030,17 +1164,17 @@ export class GameData {
|
|
|
|
|
|
//更新到服务器
|
|
|
let has = false;
|
|
|
- let len = this._productMakeTimesData.length;
|
|
|
+ let len = this._productMakeTimesData.makeTimes.length;
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
- if (this._productMakeTimesData[i].id == id) {
|
|
|
- this._productMakeTimesData[i].times = times;
|
|
|
+ if (this._productMakeTimesData.makeTimes[i].id == id) {
|
|
|
+ this._productMakeTimesData.makeTimes[i].times = times;
|
|
|
has = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (!has) {
|
|
|
let data = { 'id': id, 'times': times };
|
|
|
- this._productMakeTimesData.push(data);
|
|
|
+ this._productMakeTimesData.makeTimes.push(data);
|
|
|
}
|
|
|
|
|
|
//设置可种植/生产最大id
|
|
|
@@ -1048,20 +1182,24 @@ export class GameData {
|
|
|
let curConfig = this.getProductMap(id);
|
|
|
let nextConfig = this.getProductMap(nextID);
|
|
|
|
|
|
- if (id == this.getMaxProduct(curConfig.tab)) {
|
|
|
+ if (id == this.getMaxProductExtra(curConfig.tab)) {
|
|
|
if (nextConfig) {
|
|
|
gData.plantData.init_itemIndex = nextID;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (nextConfig) {
|
|
|
- if (nextConfig.tab == curConfig.tab && nextID > this.getMaxProduct(curConfig.tab)) {
|
|
|
+ if (nextConfig.tab == curConfig.tab && nextID > this.getMaxProductExtra(curConfig.tab)) {
|
|
|
if (nextConfig.unlock == 1 && nextConfig.value <= times) {
|
|
|
isAddMaxProduct = true;
|
|
|
this._productMakeTimesMap.set(nextID, 0);
|
|
|
let data = { 'id': nextID, 'times': 0 };
|
|
|
- this._productMakeTimesData.push(data);
|
|
|
- this.setMaxProduct(nextID);
|
|
|
+ this._productMakeTimesData.makeTimes.push(data);
|
|
|
+ this._productMakeTimesData.productUnlockMaxId.set(nextConfig.tab, nextID);
|
|
|
+ //this.setMaxProduct(nextID);
|
|
|
+ //需要更新最大生产id
|
|
|
+ gData.farmMapData.isStateChange = true;
|
|
|
+ this.updateMaxProduct();
|
|
|
let nConfig = this.getProductMap(nextID + 1);
|
|
|
if (nConfig) {
|
|
|
gData.plantData.init_lock = nextID + 1;
|
|
|
@@ -1073,7 +1211,78 @@ export class GameData {
|
|
|
if (!isAddMaxProduct) {
|
|
|
mk.event.emit("refreshFarmMapUI");
|
|
|
}
|
|
|
- this.setProp(GameProp.productMakeTimes, this._productMakeTimesData);
|
|
|
+ let sss: any = {};
|
|
|
+ sss.makeTimes = this._productMakeTimesData.makeTimes;
|
|
|
+ let json = this.mapToObj(this._productMakeTimesData.productUnlockMaxId);
|
|
|
+ sss.productUnlockMaxId = JSON.stringify(json);
|
|
|
+
|
|
|
+ await this.setProp(GameProp.productMakeTimes, sss);
|
|
|
+ }
|
|
|
+
|
|
|
+ mapToObj(mapData) {
|
|
|
+ let obj = {};
|
|
|
+ mapData.forEach(function (value, key) {
|
|
|
+ obj[key] = value;
|
|
|
+ });
|
|
|
+ return obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ objToMap(obj) {
|
|
|
+ let map = new Map();
|
|
|
+ for (let k in obj) {
|
|
|
+ map.set(k, obj[k]);
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置解锁的最大id
|
|
|
+ addProductUnlockMaxId(tab, id) {
|
|
|
+ if (this._productMakeTimesData.productUnlockMaxId) {
|
|
|
+ let productId = this._productMakeTimesData.productUnlockMaxId.get(tab);
|
|
|
+ if (productId) {
|
|
|
+ if(id > productId){
|
|
|
+ this._productMakeTimesData.productUnlockMaxId.set(tab, id);
|
|
|
+ console.log(`addProductUnlockMaxId====${tab}====${id}`);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ console.log(`addProductUnlockMaxId22====${tab}====${id}`);
|
|
|
+ this._productMakeTimesData.productUnlockMaxId.set(tab, id);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断前面解锁需要数值大于后面解锁数值的情况
|
|
|
+ public judgeAddExtraUnlockMaxId() {
|
|
|
+ let isUpdateToSever = false;
|
|
|
+ if (this._productMakeTimesData.productUnlockMaxId) {
|
|
|
+ let data = this._productMakeTimesData.productUnlockMaxId;
|
|
|
+ data.forEach((value, key) => {
|
|
|
+ if (key != ProductType.dw) {
|
|
|
+ let product = this.getMaxProductDataByType(key, value + 1);
|
|
|
+ if (product && product.unlock == 1) {
|
|
|
+ let makeTimes = this.getProductMakeTimesById(value);
|
|
|
+ if (makeTimes >= product.value) {
|
|
|
+ this.addProductUnlockMaxId(key, product.picture);
|
|
|
+ isUpdateToSever = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return isUpdateToSever;
|
|
|
+ }
|
|
|
+
|
|
|
+ updateDataToSever() {
|
|
|
+ let sss: any = {};
|
|
|
+ sss.makeTimes = this._productMakeTimesData.makeTimes;
|
|
|
+ let json = this.mapToObj(this._productMakeTimesData.productUnlockMaxId);
|
|
|
+ sss.productUnlockMaxId = JSON.stringify(json);
|
|
|
+
|
|
|
+ this.setProp(GameProp.productMakeTimes, sss);
|
|
|
}
|
|
|
|
|
|
getProductMakeTimesById(id: number) {
|
|
|
@@ -1084,6 +1293,22 @@ export class GameData {
|
|
|
return times;
|
|
|
}
|
|
|
|
|
|
+ getProductUnlockById(tab, id: number) {
|
|
|
+ if (this._productMakeTimesData.productUnlockMaxId) {
|
|
|
+ let productId = this._productMakeTimesData.productUnlockMaxId.get(tab);
|
|
|
+ if (productId) {
|
|
|
+ if (productId >= id) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
//------------- 养殖场数据-----------
|
|
|
/** 养殖场数据 服务器数据 */
|
|
|
private _pastureData = [];
|
|
|
@@ -1190,6 +1415,7 @@ export class GameData {
|
|
|
this._factoryData = [];
|
|
|
}
|
|
|
|
|
|
+ let isUpdate = false;
|
|
|
let len = this._factoryData.length;
|
|
|
//新玩家初始化工厂数据
|
|
|
if (len < 6) {
|
|
|
@@ -1205,7 +1431,12 @@ export class GameData {
|
|
|
else {
|
|
|
data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
|
|
|
//更新最大可购买商品
|
|
|
- this.setMaxProduct(arr[0].picture, true);
|
|
|
+ //this.setMaxProduct(arr[0].picture, true);
|
|
|
+ // let is = this.addProductUnlockMaxId(tab, arr[0].picture);
|
|
|
+ // if(!isUpdate)
|
|
|
+ // {
|
|
|
+ // isUpdate = is;
|
|
|
+ // }
|
|
|
}
|
|
|
this._factoryData.push(data);
|
|
|
this._factoryDataMap.set(id, data);
|
|
|
@@ -1229,15 +1460,26 @@ export class GameData {
|
|
|
|
|
|
if (this.playerProp.orderData.overTimes >= arr[0].value) {
|
|
|
//更新最大可购买商品
|
|
|
- this.setMaxProduct(arr[0].picture, true);
|
|
|
+ //this.setMaxProduct(arr[0].picture, true);;
|
|
|
+ // let is = this.addProductUnlockMaxId(tab, arr[0].picture);
|
|
|
+ // if(!isUpdate)
|
|
|
+ // {
|
|
|
+ // isUpdate = is;
|
|
|
+ // }
|
|
|
}
|
|
|
id++;
|
|
|
}
|
|
|
|
|
|
this.RawInsectCurArr[2] = sickTimes;
|
|
|
}
|
|
|
+
|
|
|
+ // if(isUpdate)
|
|
|
+ // {
|
|
|
+ // this.updateDataToSever();
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/** 通过工厂建筑物ID获取标签 */
|
|
|
getTabByConfigID(configID: number): ProductType {
|
|
|
let tab = ProductType.bmhc;
|
|
|
@@ -1365,6 +1607,14 @@ export class GameData {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ getMaxProductExtra(tab) {
|
|
|
+ if (this._productMakeTimesData.productUnlockMaxId) {
|
|
|
+ let productId = this._productMakeTimesData.productUnlockMaxId.get(tab);
|
|
|
+ return productId;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/** 设置最大可生产商品
|
|
|
* @param id 产品id
|
|
|
* @param unlock 是否是解锁增加
|
|
|
@@ -1395,12 +1645,12 @@ export class GameData {
|
|
|
}
|
|
|
|
|
|
gData.farmMapData.isStateChange = true;
|
|
|
-
|
|
|
this.updateMaxProduct();
|
|
|
}
|
|
|
|
|
|
/** 农场升级时解锁工厂,检查最大可种植/生产商品 */
|
|
|
public checkTaskFinishUnLock() {
|
|
|
+ let isUpdateToSever = false;
|
|
|
for (var key in ProductType) {
|
|
|
let tab = ProductType[key];
|
|
|
let configArr = this.getProductArrByType(tab);
|
|
|
@@ -1428,10 +1678,14 @@ export class GameData {
|
|
|
}
|
|
|
id++;
|
|
|
}
|
|
|
-
|
|
|
+ console.log(`checkTaskFinishUnLock11=====${maxId}`);
|
|
|
if (maxId != 0) {
|
|
|
//更新最大可购买商品
|
|
|
- this.setMaxProduct(maxId, true);
|
|
|
+ //this.setMaxProduct(maxId, true);
|
|
|
+ let is = this.addProductUnlockMaxId(tab, maxId);
|
|
|
+ if (!isUpdateToSever) {
|
|
|
+ isUpdateToSever = is;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//更新到服务器
|
|
|
@@ -1452,7 +1706,12 @@ export class GameData {
|
|
|
needUpdate = true;
|
|
|
}
|
|
|
//更新最大可购买商品
|
|
|
- this.setMaxProduct(configArr[0].picture, true);
|
|
|
+ //this.setMaxProduct(configArr[0].picture, true);
|
|
|
+ console.log(`checkTaskFinishUnLock222=====${maxId}`);
|
|
|
+ let is = this.addProductUnlockMaxId(tab, configArr[0].picture);
|
|
|
+ if (!isUpdateToSever) {
|
|
|
+ isUpdateToSever = is;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (needUpdate) {
|
|
|
@@ -1462,6 +1721,15 @@ export class GameData {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (isUpdateToSever) {
|
|
|
+ console.log('===================isUpdateToSever222');
|
|
|
+ this.updateDataToSever();
|
|
|
+
|
|
|
+ //需要更新最大生产id
|
|
|
+ gData.farmMapData.isStateChange = true;
|
|
|
+ this.updateMaxProduct();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
checkCanSpeedUp(pop = false) {
|
|
|
@@ -1480,6 +1748,24 @@ export class GameData {
|
|
|
return can;
|
|
|
}
|
|
|
|
|
|
+ popSpeedUpByRate()
|
|
|
+ {
|
|
|
+ let isPop = false;
|
|
|
+ let rate = gData.adData.getPerByEcpm(RateConfig.RC_popSpeedUp);
|
|
|
+ if(rate >= Math.random())
|
|
|
+ {
|
|
|
+ isPop = gData.pastureSystem.canSpeedUp();
|
|
|
+ if (!isPop) {
|
|
|
+ isPop = gData.factorySystem.canSpeedUp();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isPop){
|
|
|
+ mk.ui.openPanel('module/speedUpUI/speedUp');
|
|
|
+ }
|
|
|
+ return isPop;
|
|
|
+ }
|
|
|
+
|
|
|
setHarvest() {
|
|
|
gData.farmSystem.setHarvest();
|
|
|
gData.pastureSystem.setHarvest();
|
|
|
@@ -1531,12 +1817,15 @@ export class GameData {
|
|
|
/** 更新最大可种植产品到服务器 */
|
|
|
async updateMaxProduct() {
|
|
|
if (this.maxProductToServer) {
|
|
|
- let data = { "unLockProductList": this._maxProduct };
|
|
|
- // for (let i = 0; i != this._maxProduct.length; ++i) {
|
|
|
- // let dataE = this._maxProduct[i];
|
|
|
- // let d = { id: dataE.productID, tab: dataE.tab };
|
|
|
- // data.unLockProductList.push(d);
|
|
|
- // }
|
|
|
+ //let data = { "unLockProductList": this._maxProduct };
|
|
|
+ let data = { "unLockProductList": [] };
|
|
|
+ let maxProductData = this._productMakeTimesData.productUnlockMaxId;
|
|
|
+ maxProductData.forEach((value, key) => {
|
|
|
+ let config = this.getProductMap(value);
|
|
|
+ let d = { tab: key, productID: value, id: config.id };
|
|
|
+ data.unLockProductList.push(d);
|
|
|
+ });
|
|
|
+
|
|
|
mk.console.logSingle("updateMaxProduct", data);
|
|
|
let respone = await mk.http.sendData('orderTask/updateUnlockProduct', data);
|
|
|
console.log("------");
|
|
|
@@ -1894,8 +2183,12 @@ export enum DataEventId {
|
|
|
loading = 'loading',
|
|
|
/** 排队 */
|
|
|
queue = 'queue',
|
|
|
- //实名认证
|
|
|
- realName = 'realName'
|
|
|
+ /** 实名认证 */
|
|
|
+ realName = 'realName',
|
|
|
+ /** 离线生产次数弹出 */
|
|
|
+ offlineProductTimes = "offlineProductTimes",
|
|
|
+ /**触发提现到达上限 */
|
|
|
+ cashLimit = "cashLimit"
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1995,4 +2288,22 @@ export enum FactroyState {
|
|
|
Producting,
|
|
|
Ripe,
|
|
|
Sick
|
|
|
+}
|
|
|
+
|
|
|
+//功能开关含义
|
|
|
+export enum FunctionSwitch{
|
|
|
+ FS_farmGrade = 0, //农场等级奖励
|
|
|
+ FS_cashOutBtn = 1, //主界面提现按钮
|
|
|
+ FS_sign = 2, //签到
|
|
|
+ FS_turntable = 3, //抽奖转盘
|
|
|
+ FS_redPacketTash = 4, //任务红包
|
|
|
+ FS_welfareBtn = 5, //福利按钮
|
|
|
+ FS_inviteBtn = 6, //邀请按钮
|
|
|
+ FS_floatRedPacket = 7, //漂浮红包
|
|
|
+ FS_electBtn = 8, //互推按钮
|
|
|
+ FS_sheepRedPacket = 9, //山羊红包
|
|
|
+ FS_addCashBtn = 10, //提现界面的加现金按钮
|
|
|
+ FS_order = 11, //订单
|
|
|
+ FS_floatFarmMap = 12, //图鉴浮窗
|
|
|
+ FS_richManBank = 13 //富翁银行
|
|
|
}
|