wuwangdong il y a 4 ans
Parent
commit
5fa40a4c55
1 fichiers modifiés avec 9 ajouts et 7 suppressions
  1. 9 7
      assets/script/game/data/GameData.ts

+ 9 - 7
assets/script/game/data/GameData.ts

@@ -1000,6 +1000,7 @@ export class GameData {
     private _productUnlockMaxId: Map<string, number> = new Map();
 
     private initProductTimes() {
+        let needUpdate = false;
         let value = this.getProp(GameProp.productMakeTimes);
         if (!value) {
             this._productMakeTimesData.makeTimes = [];
@@ -1026,6 +1027,7 @@ export class GameData {
                         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));
@@ -1038,7 +1040,11 @@ export class GameData {
             this.setMaxProduct(this._productMakeTimesData.makeTimes[i].id);
         }
 
-        this.judgeAddExtraUnlockMaxId();
+        let isUpdate = this.judgeAddExtraUnlockMaxId();
+        if(needUpdate || isUpdate)
+        {
+            this.updateDataToSever();
+        }
     }
 
     addProductMakeTimesById(id: number) {
@@ -1143,10 +1149,10 @@ export class GameData {
     //判断前面解锁需要数值大于后面解锁数值的情况
     public judgeAddExtraUnlockMaxId()
     {
+        let isUpdateToSever = false;
         if(this._productMakeTimesData.productUnlockMaxId)
         {
             let data = this._productMakeTimesData.productUnlockMaxId;
-            let isUpdateToSever = false;
             data.forEach((value, key) => {
                 if(key != ProductType.dw)
                 {
@@ -1162,12 +1168,8 @@ export class GameData {
                     }
                 }    
             });
-
-            if(isUpdateToSever)
-            {
-                this.updateDataToSever();
-            }
         }
+        return isUpdateToSever;
     }
 
     updateDataToSever() {