aminusia

AddQuestProgress

Jan 4th, 2016
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static bool AddQuestProgress(DBQuest.MISSIONTYPE[] questType, int[] variable1, int[] variable2, int[] value){
  2.         bool anyProgress = false;
  3.         JSONNode tableQuest = DB.LoadTableFromLocal(DBQuest.TABLE_NAME, DBQuest.PASSWORD);
  4.         JSONNode tableQuestProgress = DBUser.instance.GetJson()["questProgress"];
  5.  
  6.         for(int i=0;i<3;i++){
  7.             JSONNode JSONQuest = tableQuest[((QUEST) i+1).ToString()];
  8.             JSONNode JSONQuestProgress = tableQuestProgress[i]["progress"];
  9.             for(int j=0;j<JSONQuest.Count;j++){
  10.                 JSONNode JSONQuestDetail = JSONQuest[j];
  11.                 for(int k=0;k<questType.Length;k++){
  12.                     if(JSONQuestDetail["missionType"].AsInt==(int) questType[k]){
  13.                         if(questType[k]==MISSIONTYPE.ReachPlayerLevel ||
  14.                            questType[k]==MISSIONTYPE.EvolveMonsterXTimes ||
  15.                            questType[k]==MISSIONTYPE.UpgradeEquipmentXTimes ||
  16.                            questType[k]==MISSIONTYPE.HatchEggXTimes){
  17.                             if(variable1[k]!=JSONQuestDetail["missionVariable1"].AsInt) continue;
  18.                         }else if(questType[k]==MISSIONTYPE.ClearStage){
  19.                             if(variable1[k]!=JSONQuestDetail["missionVariable1"].AsInt ||
  20.                                variable2[k]!=JSONQuestDetail["missionVariable2"].AsInt) continue;
  21.                         }
  22.                        
  23.                         if(JSONQuestProgress.Count<j+1){
  24.                             JSONQuestProgress[j]["progressValue"] = "0";
  25.                             JSONQuestProgress[j]["claimed"] = "0";
  26.                         }
  27.                        
  28.                         JSONNode JSONQuestProgressDetail = JSONQuestProgress[j];
  29.                         JSONQuestProgressDetail["progressValue"] = ""+(JSONQuestProgressDetail["progressValue"].AsInt + value[k]);
  30.                         anyProgress = true;
  31.                     }
  32.                 }
  33.             }
  34.         }
  35.  
  36.         return anyProgress;
  37.     }
Add Comment
Please, Sign In to add comment