|
|
@@ -216,6 +216,11 @@ export class GameData {
|
|
|
|
|
|
//注册时版本号
|
|
|
mk.data.setTAEventUserStr(0, 'regtime_app_id', gData.appData.appVersion);
|
|
|
+
|
|
|
+ //星云uid
|
|
|
+ mk.data.setTAEventUserStr(0, 'xy_uid', gData.loginData.uin);
|
|
|
+
|
|
|
+ mk.data.setTAEventUser(0, 'farm_lv', gData.gameData.playerProp.gradeLevel);
|
|
|
}
|
|
|
|
|
|
//当前版本号
|
|
|
@@ -290,7 +295,6 @@ export class GameData {
|
|
|
this.setFramDataMapByServer();
|
|
|
this.setPastureDataMapByServer();
|
|
|
this.setFactoryDataMapByServer();
|
|
|
- this.initSetMaxProduct();
|
|
|
this.initProductTimes();
|
|
|
this.initLeftTimes();
|
|
|
this.initFarmMapGetRewardData();
|
|
|
@@ -599,7 +603,7 @@ export class GameData {
|
|
|
}
|
|
|
|
|
|
//第一次初始数据
|
|
|
- this.setMaxProduct(ProductType.nzw, 10003);
|
|
|
+ // this.setMaxProduct(10003);
|
|
|
//更新到服务器
|
|
|
this.setProp(GameProp.farmData, this._farmData);
|
|
|
}
|
|
|
@@ -657,6 +661,19 @@ export class GameData {
|
|
|
/** 产品生产/种植次数 */
|
|
|
private _productMakeTimesMap: Map<number, number> = new Map();
|
|
|
|
|
|
+ private initProductTimes() {
|
|
|
+ this._productMakeTimesData = this.getProp(GameProp.productMakeTimes);
|
|
|
+ if (!this._productMakeTimesData) {
|
|
|
+ this._productMakeTimesData = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ let len = this._productMakeTimesData.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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
addProductMakeTimesById(id: number) {
|
|
|
let times = this._productMakeTimesMap.get(id);
|
|
|
if (!times) {
|
|
|
@@ -694,7 +711,7 @@ export class GameData {
|
|
|
if (nextConfig) {
|
|
|
if (nextConfig.tab == curConfig.tab && nextID > this.getMaxProduct(curConfig.tab)) {
|
|
|
if (nextConfig.unlock == 1 && nextConfig.value <= times) {
|
|
|
- this.setMaxProduct(curConfig.tab, nextID);
|
|
|
+ this.setMaxProduct(nextID);
|
|
|
let nConfig = this.getProductMap(nextID + 1);
|
|
|
if (nConfig) {
|
|
|
gData.plantData.init_lock = nextID + 1;
|
|
|
@@ -829,13 +846,13 @@ export class GameData {
|
|
|
for (var i = 0; i < 6; i++) {
|
|
|
tab = this.getTabByConfigID(id);
|
|
|
let arr = this.getProductArrByType(tab);
|
|
|
- if (this.playerProp.gradeLevel < arr[0].value) {
|
|
|
+ if (this.playerProp.completeFarmTaskTimes < arr[0].value) {
|
|
|
data = { id: id, state: FactroyState.Lock, productID: 0, growSpan: 0 };
|
|
|
}
|
|
|
else {
|
|
|
data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
|
|
|
//更新最大可购买商品
|
|
|
- this.setMaxProduct(tab, arr[0].picture, false);
|
|
|
+ // this.setMaxProduct(arr[0].picture);
|
|
|
}
|
|
|
this._factoryData.push(data);
|
|
|
this._factoryDataMap.set(id, data);
|
|
|
@@ -843,7 +860,6 @@ export class GameData {
|
|
|
}
|
|
|
|
|
|
//更新到服务器
|
|
|
- this.setProp(GameProp.maxProduct, this._maxProduct);
|
|
|
this.setProp(GameProp.factoryData, this._factoryData);
|
|
|
}
|
|
|
else {
|
|
|
@@ -944,7 +960,12 @@ export class GameData {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public setMaxProduct(tab, id, sendToServer = true) {
|
|
|
+ /** 设置最大可生产商品
|
|
|
+ * @param id 产品id
|
|
|
+ * @param unlock 是否是解锁增加
|
|
|
+ */
|
|
|
+ public setMaxProduct(id, unlock = false) {
|
|
|
+ let config = this.getProductMap(id);
|
|
|
if (!this._maxProduct) {
|
|
|
this._maxProduct = [];
|
|
|
}
|
|
|
@@ -953,38 +974,19 @@ export class GameData {
|
|
|
let has = false;
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
data = this._maxProduct[i];
|
|
|
- if (data.tab == tab) {
|
|
|
- data.productID = id;
|
|
|
+ if (data.tab == config.tab) {
|
|
|
+ if (data.productID < id) {
|
|
|
+ data.productID = id;
|
|
|
+ }
|
|
|
has = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!has) {
|
|
|
- data = { tab: tab, productID: id };
|
|
|
+ if (!has && unlock) {
|
|
|
+ data = { tab: config.tab, productID: id };
|
|
|
this._maxProduct.push(data);
|
|
|
}
|
|
|
-
|
|
|
- if (sendToServer) {
|
|
|
- this.setProp(GameProp.maxProduct, this._maxProduct);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public initSetMaxProduct() {
|
|
|
- if (this._maxProduct.length <= 0) {
|
|
|
- this._maxProduct = this.getProp(GameProp.maxProduct);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private initProductTimes() {
|
|
|
- this._productMakeTimesData = this.getProp(GameProp.productMakeTimes);
|
|
|
- if (!this._productMakeTimesData) {
|
|
|
- this._productMakeTimesData = [];
|
|
|
- }
|
|
|
- let len = this._productMakeTimesData.length;
|
|
|
- for (var i = 0; i < len; i++) {
|
|
|
- this._productMakeTimesMap.set(this._productMakeTimesData[i].id, this._productMakeTimesData[i].times);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
/** 农场升级时解锁工厂,检查最大可种植/生产商品 */
|
|
|
@@ -997,7 +999,7 @@ export class GameData {
|
|
|
let needUpdate = false;
|
|
|
switch (tab) {
|
|
|
case ProductType.nzw:
|
|
|
- //不做处理,游戏最开始已解锁
|
|
|
+ this.setMaxProduct(10003, true);
|
|
|
break;
|
|
|
case ProductType.dw:
|
|
|
let id = 30001;
|
|
|
@@ -1005,19 +1007,25 @@ export class GameData {
|
|
|
let maxId = 0;
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
data = this.getPastureDataMap(id);
|
|
|
- if (data.state == PastureState.Lock && this.playerProp.completeFarmTaskTimes >= configArr[i].value) {
|
|
|
- data = { id: id, state: PastureState.Empty, productID: configArr[i].picture, growSpan: 0 };
|
|
|
- this.setPastureDataMap(id, data, false);
|
|
|
- needUpdate = true;
|
|
|
+ if (this.playerProp.completeFarmTaskTimes >= configArr[i].value) {
|
|
|
+ if (data.state == PastureState.Lock) {
|
|
|
+ data = { id: id, state: PastureState.Empty, productID: configArr[i].picture, growSpan: 0 };
|
|
|
+ this.setPastureDataMap(id, data, false);
|
|
|
+ needUpdate = true;
|
|
|
+ }
|
|
|
+
|
|
|
maxId = configArr[i].picture;
|
|
|
}
|
|
|
id++;
|
|
|
}
|
|
|
- //更新到服务器
|
|
|
- if (needUpdate) {
|
|
|
+
|
|
|
+ if (maxId != 0) {
|
|
|
//更新最大可购买商品
|
|
|
- this.setMaxProduct(ProductType.dw, maxId);
|
|
|
+ this.setMaxProduct(maxId, true);
|
|
|
+ }
|
|
|
|
|
|
+ //更新到服务器
|
|
|
+ if (needUpdate) {
|
|
|
this.setProp(GameProp.pastureData, this._pastureData);
|
|
|
this.setNextProduct();
|
|
|
}
|
|
|
@@ -1027,12 +1035,14 @@ export class GameData {
|
|
|
needUpdate = false;
|
|
|
let configID = this.getConfigIDByTab(tab);
|
|
|
data = this.getFactoryDataMap(configID);
|
|
|
- if (data.state == FactroyState.Lock && this.playerProp.completeFarmTaskTimes >= configArr[0].value) {
|
|
|
- data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
|
|
|
- this.setFactoryDataMap(configID, data, false);
|
|
|
- needUpdate = true;
|
|
|
+ if (this.playerProp.completeFarmTaskTimes >= configArr[0].value) {
|
|
|
+ if (data.state == FactroyState.Lock) {
|
|
|
+ data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
|
|
|
+ this.setFactoryDataMap(configID, data, false);
|
|
|
+ needUpdate = true;
|
|
|
+ }
|
|
|
//更新最大可购买商品
|
|
|
- this.setMaxProduct(tab, configArr[0].picture);
|
|
|
+ this.setMaxProduct(configArr[0].picture, true);
|
|
|
}
|
|
|
|
|
|
if (needUpdate) {
|
|
|
@@ -1117,9 +1127,6 @@ export enum GameProp {
|
|
|
/** 产品生产次数 */
|
|
|
productMakeTimes = 12,
|
|
|
|
|
|
- /** 可生产最大产品字典 */
|
|
|
- maxProduct = 13,
|
|
|
-
|
|
|
/** 养殖场数据 */
|
|
|
pastureData = 14,
|
|
|
|