|
|
@@ -407,8 +407,7 @@ export class GameData {
|
|
|
}
|
|
|
gData.gameData.setProp(GameProp.leftTimes, gData.gameData.leftTimes);
|
|
|
|
|
|
- if(isRefresh)
|
|
|
- {
|
|
|
+ if (isRefresh) {
|
|
|
gData.gameData.init_leftTimes = true;
|
|
|
}
|
|
|
}
|
|
|
@@ -524,7 +523,7 @@ export class GameData {
|
|
|
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;
|
|
|
@@ -552,7 +551,7 @@ export class GameData {
|
|
|
if (picId) {
|
|
|
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");
|
|
|
@@ -563,7 +562,7 @@ export class GameData {
|
|
|
if (picId) {
|
|
|
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,8 +624,7 @@ export class GameData {
|
|
|
//return this.getProductMap(id);
|
|
|
}
|
|
|
|
|
|
- public doJudgeOrderLogic(out?: any)
|
|
|
- {
|
|
|
+ public doJudgeOrderLogic(out?: any) {
|
|
|
let data = this.playerProp.orderData;
|
|
|
let orderData = data.orderTaskList;
|
|
|
if (data && orderData) {
|
|
|
@@ -638,8 +636,7 @@ export class GameData {
|
|
|
let productData = productJson[dataE.Id - 1];
|
|
|
if (productData.tab == ProductType.nzw) {
|
|
|
continue;
|
|
|
- }else if(productData.tab == ProductType.dw)
|
|
|
- {
|
|
|
+ } else if (productData.tab == ProductType.dw) {
|
|
|
console.log(`doJudgeOrderLogic=====${dataE.Id}`);
|
|
|
let pastureIcon = gData.pastureSystem.pastureIcons;
|
|
|
let len = pastureIcon.length;
|
|
|
@@ -652,7 +649,7 @@ export class GameData {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
let factoryIcon = gData.factorySystem.factoryIcons;
|
|
|
let len = factoryIcon.length;
|
|
|
for (var j = 0; j < len; j++) {
|
|
|
@@ -675,7 +672,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++) {
|
|
|
@@ -696,7 +693,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) {
|
|
|
@@ -771,8 +768,7 @@ export class GameData {
|
|
|
let haveEmpty = { state: -1 };
|
|
|
let next = gData.farmSystem.selectNextFarm(haveEmpty, sel);
|
|
|
if (!next) {
|
|
|
- if(haveEmpty.state == -1)
|
|
|
- {
|
|
|
+ if (haveEmpty.state == -1) {
|
|
|
this.doJudgeOrderLogic(haveEmpty);
|
|
|
}
|
|
|
let next1 = gData.pastureSystem.nextPasture(haveEmpty);
|
|
|
@@ -849,7 +845,7 @@ export class GameData {
|
|
|
if (com >= count) {
|
|
|
if (!this.gameStyle.getIsCanGetOrderReward()) {
|
|
|
mk.tip.pop('任务红包进度已满,快去提现');
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
mk.tip.pop("订单已完成,快领奖吧!");
|
|
|
}
|
|
|
return false;
|
|
|
@@ -984,20 +980,50 @@ export class GameData {
|
|
|
}
|
|
|
|
|
|
/** 产品生产/种植次数 服务器数据 */
|
|
|
- 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 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } 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);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1012,17 +1038,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
|
|
|
@@ -1030,19 +1056,20 @@ 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._productMakeTimesData.makeTimes.push(data);
|
|
|
+ this._productMakeTimesData.productUnlockMaxId.set(nextConfig.tab, nextID);
|
|
|
this.setMaxProduct(nextID);
|
|
|
let nConfig = this.getProductMap(nextID + 1);
|
|
|
if (nConfig) {
|
|
|
@@ -1055,7 +1082,45 @@ 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);
|
|
|
+
|
|
|
+ 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 && id > productId) {
|
|
|
+ this._productMakeTimesData.productUnlockMaxId.set(tab, id);
|
|
|
+
|
|
|
+ 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) {
|
|
|
@@ -1066,6 +1131,25 @@ 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 = [];
|
|
|
@@ -1188,6 +1272,7 @@ export class GameData {
|
|
|
data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
|
|
|
//更新最大可购买商品
|
|
|
this.setMaxProduct(arr[0].picture, true);
|
|
|
+ this.addProductUnlockMaxId(tab, arr[0].picture);
|
|
|
}
|
|
|
this._factoryData.push(data);
|
|
|
this._factoryDataMap.set(id, data);
|
|
|
@@ -1212,14 +1297,17 @@ export class GameData {
|
|
|
if (this.playerProp.completeFarmTaskTimes >= arr[0].value) {
|
|
|
//更新最大可购买商品
|
|
|
this.setMaxProduct(arr[0].picture, true);
|
|
|
+ this.addProductUnlockMaxId(tab, arr[0].picture);
|
|
|
}
|
|
|
id++;
|
|
|
}
|
|
|
|
|
|
this.RawInsectCurArr[2] = sickTimes;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/** 通过工厂建筑物ID获取标签 */
|
|
|
getTabByConfigID(configID: number): ProductType {
|
|
|
let tab = ProductType.bmhc;
|
|
|
@@ -1347,6 +1435,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 是否是解锁增加
|
|
|
@@ -1414,6 +1510,7 @@ export class GameData {
|
|
|
if (maxId != 0) {
|
|
|
//更新最大可购买商品
|
|
|
this.setMaxProduct(maxId, true);
|
|
|
+ this.addProductUnlockMaxId(tab, maxId);
|
|
|
}
|
|
|
|
|
|
//更新到服务器
|
|
|
@@ -1435,6 +1532,7 @@ export class GameData {
|
|
|
}
|
|
|
//更新最大可购买商品
|
|
|
this.setMaxProduct(configArr[0].picture, true);
|
|
|
+ this.addProductUnlockMaxId(tab, configArr[0].picture);
|
|
|
}
|
|
|
|
|
|
if (needUpdate) {
|