/*public void explore_cancel(string expID) * { * if (MessageBox.Show(getLangStr("PVEBackSubtitle"), * getLangStr("PVEBackToPort"), * MessageBoxButton.YesNo) * == MessageBoxResult.Yes) * { * JsonText Res = CreateJsonText(StdGetRequest($"explore/cancel/{expID}/")); * //status? * gameinfo["pveExploreVo"] = Res["pveExploreVo"]; * gameinfo["fleetVo"] = Res["fleetVo"]; * } * }*/ public void explore_start(string expID, string fleetID) { JsonText Res = CreateJsonText(StdPostRequest($"explore/start/{fleetID}/{expID}/")); gameinfo["pveExploreVo"] = Res["pveExploreVo"]; gameinfo["fleetVo"] = Res["fleetVo"]; }
public bool checkDownload() { if (File.Exists(@"documents\proj.manifest")) { proj_manifest = CreateJsonText(File.ReadAllText("documents/proj.manifest")); packageUrl = (string)proj_manifest["packageUrl"]; if ((string)proj_manifest["version"] == (string)version_txt["ResVersion"]) { return(false); } } return(true); }
public void explore_cancel(string expID) { if (MessageBox.Show(getLangStr("PVEBackSubtitle"), getLangStr("PVEBackToPort"), MessageBoxButton.YesNo) == MessageBoxResult.Yes) { JsonText Res = CreateJsonText(StdGetRequest($"explore/cancel/{expID}/")); //status? gameinfo["pveExploreVo"] = Res["pveExploreVo"]; gameinfo["fleetVo"] = Res["fleetVo"]; } }
public void passportLogin() { client.BaseAddress = loginServer; passportLogin_txt = CreateJsonText( client.UploadValues( $"index/passportLogin/&t={DateTime.Now.ToUTC()}&e={GetNewUDID()}&gz=1{uriend()}", new NameValueCollection { { "username", username.Base64Encode() }, { "pwd", password.Base64Encode() } } ).decompressZlibData() ); hf_skey = (string)passportLogin_txt["hf_skey"]; }
public void checkVer() { client.BaseAddress = firstSever; version_txt = CreateJsonText(client.DownloadString($"index/checkVer/{version}/{channel}/{market}{uriend()}")); loginServer = (string)version_txt["loginServer"]; if (version_txt["ResUrlWu"] != null) { ResUrlWu = (string)version_txt["ResUrlWu"]; } else { ResUrlWu = (string)version_txt["ResUrl"]; } }
private JsonText CreateJsonText(string text) { var result = new JsonText(text); if (result["eid"] == null) { return(result); } if (init_txt != null && (string)init_txt["errorCode"][(string)result["eid"]] != null) { throw new Exception((string)init_txt["errorCode"][(string)result["eid"]]); } else { throw new Exception("eid:" + result["eid"]); } }
public void getInitConfigs() { if (File.Exists(@"documents\init.txt")) { init_txt = CreateJsonText(File.ReadAllText("documents/init.txt")); if ((string)init_txt["DataVersion"] == (string)version_txt["DataVersion"]) { return; } } client.BaseAddress = loginServer; init_txt = CreateJsonText( client.DownloadData( $"index/getInitConfigs/&t={DateTime.Now.ToUTC()}&e={helper.GetNewUDID()}&gz=1{uriend()}" ).decompressZlibData() ); File.WriteAllText("documents/init.txt", init_txt.text); }
public void boat_renameship(int shipid, string newname) { JsonText Res = CreateJsonText(StdGetRequest($"boat/renameShip/{shipid}/{WebUtility.UrlEncode(newname)}/")); //TODO:更新数据 }
public string explore_getResult(string expID, bool messagebox = true) { JsonText Res = CreateJsonText(StdGetRequest($"explore/getResult/{expID}/")); if (Res["updateTaskVo"] != null) { foreach (var taskUpdate in Res["updateTaskVo"]) { var taskCondition = from task in gameinfo["taskVo"] where (string)task["taskCid"] == (string)taskUpdate["taskCid"] select task; taskCondition.First()["condition"] = taskUpdate["condition"]; } } //loveChange //$intimacyOther ???? //rewardItems var mergeSettings = new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Union }; ((JObject)gameinfo["userVo"]).Merge(Res["userLevelVo"], mergeSettings); //((JObject)gameinfo["detailInfo"]).Merge(Res["userLevelVo"], mergeSettings); JToken packageVo; if (Res.obj.TryGetValue("packageVo", out packageVo)) { foreach (var itemnew in packageVo) { var iteminfo = from itemold in gameinfo["packageVo"] where (string)itemold["itemCid"] == (string)itemnew["itemCid"] select itemold; if (iteminfo.Any()) { iteminfo.First()["num"] = itemnew["num"]; } else { ((JArray)gameinfo["packageVo"]).Add(itemnew); } } } ((JObject)gameinfo["userVo"]).Merge(Res["userResVo"], mergeSettings); //newAward gameinfo["pveExploreVo"] = Res["pveExploreVo"]; gameinfo["detailInfo"] = Res["detailInfo"]; //shipVO gameinfo["fleetVo"] = Res["fleetVo"]; /////////////////////////////////////////////////////////////////// string expTitle = (from expinfo in init_txt["pveExplore"] where (string)expinfo["id"] == expID select(string) expinfo["title"]).First(); string resStr = string.Format(getLangStr("ExpeditionCompleted") .Replace("%d", "{0}").Replace("%s", "{1}"), Res["shipVO"]["id"], expTitle); if ((string)Res["bigSuccess"] == "1") { resStr += Environment.NewLine + "大成功!"; } resStr += Environment.NewLine + "获得:" + Environment.NewLine; foreach (var award in (JObject)Res["newAward"]) { resStr += "\t" + getCidText(int.Parse(award.Key)) + "x" + (string)award.Value + Environment.NewLine; } resStr += "舰队成员:" + Environment.NewLine; int shipIndex = 0; //int intimacyOtherIndex = 0; foreach (var shipID in (JArray)Res["shipVO"]["ships"]) { int shipCid = (from ship in gameinfo["userShipVO"] where ship["id"].ToString() == (string)shipID select(int) ship["shipCid"]).First(); resStr += "\t" + getCidText(shipCid) + "\t"; if (Res["loveChange"].HasValues && Res["loveChange"][shipIndex].ToString().ToLower() != "false") { resStr += "好感度:+" + Res["loveChange"][shipIndex] + Environment.NewLine; var shipinfo = from ship in gameinfo["userShipVO"] where ship["id"].ToString() == (string)shipID select ship; shipinfo.First()["love"] = (int)shipinfo.First()["love"] + (int)Res["loveChange"][shipIndex]; } else { resStr += Environment.NewLine; } shipIndex++; } if (messagebox) { ;//MessageBox.Show(resStr, getLangStr("HasFinishedPVEExplore")); } return(resStr); }
public void initGame() { gameinfo = CreateJsonText(StdGetRequest(@"api/initGame/?&crazy=1")); }
public void login(int server) { gameServer = passportLogin_txt["serverList"][server]["host"].ToString(); login_txt = CreateJsonText(StdGetRequest(@"/index/login/" + hf_skey.Split('.')[0])); }
public void downloadRes(DownloadProcessDelegate callback) { #if (DEBUG) #else try #endif { JsonText old_proj_manifest = proj_manifest; client.BaseAddress = ""; client.DownloadString(ResUrlWu); proj_manifest = CreateJsonText(client.DownloadData(ResUrlWu).decompressGZipData()); packageUrl = (string)proj_manifest["packageUrl"]; File.WriteAllText("documents/proj.manifest", proj_manifest.text); //接下来比较检查每个需要下载的文件 var filefilter = new string[] { }; Dictionary <string, DownloadFileTask> oldlist; if (old_proj_manifest != null) { oldlist = old_proj_manifest["hot"].ToDictionary( file => (string)file["name"], file => new DownloadFileTask { uri = $"{file["name"]}?md5={file["md5"]}", name = (string)file["name"], size = (long)file["size"], md5 = (string)file["md5"] } ); } else { oldlist = new Dictionary <string, DownloadFileTask>(); } long current = 0; long filenum = proj_manifest["hot"].Count(); var toDownload = new List <DownloadFileTask>(); foreach (var file2chk in proj_manifest["hot"]) { callback(ResDownloadStage.Checking, (string)file2chk["name"], ++current, filenum); if (!(//不在过滤列表中 from file in filefilter where file2chk["name"].ToString().ToLower().StartsWith(file.ToLower()) select file ).Any() ) { if ( //文件不存在 (!File.Exists($"documents/hot/{file2chk["name"]}")) || //文件存在,但新旧文件列表中可看到文件信息并不一致 ( oldlist.ContainsKey((string)file2chk["name"]) && (string)file2chk["md5"] != oldlist[(string)file2chk["name"]].md5 ) || //文件存在,但旧文件列表中没有该文件,验证该文件信息发现并不相符 ( !oldlist.ContainsKey((string)file2chk["name"]) && ( (long)file2chk["size"] != GetFileLength($"documents/hot/{file2chk["name"]}") || (string)file2chk["md5"] != GetMD5FromFile($"documents/hot/{file2chk["name"]}") ) ) ) { toDownload.Add(new DownloadFileTask { uri = $"{file2chk["name"]}?md5={file2chk["md5"]}", name = (string)file2chk["name"], size = (long)file2chk["size"], md5 = (string)file2chk["md5"] }); } } } long totalSize = toDownload.Sum(f => f.size); //开始下载 //此处无法使用多线程并行下载:辣鸡幼明会强制断开连接 long downloadedSize = 0; client.BaseAddress = packageUrl; foreach (var file in toDownload) { Directory.CreateDirectory(Path.GetDirectoryName(file.filename)); client.DownloadFile(file.uri, file.filename); downloadedSize += file.size; callback(ResDownloadStage.Downloading, file.name, downloadedSize, totalSize); } //imageFinder.reset(); } #if (DEBUG) #else catch (Exception e) { Debug.Fail(e.Message); } #endif }