public static string[] fgo_battleresult(string uid, BattleInfo bi) { var table = new Hashtable { { "ac", "action" }, { "key", "battleresult" }, { "deviceid", FgoMain.get_device_id() }, { "os", FgoMain.get_os() }, { "ptype", FgoMain.get_ptype() }, { "usk", FgoMain.get_usk(uid) }, { "umk", "" }, { "rgsid", 1001 }, { "rkchannel", FgoMain.get_rkchannel() }, { "raidResult", "[]" }, { "superBossResult", "[]" }, { "result", "{\"battleId\":" + bi.battleId + ",\"battleResult\":1,\"scores\":\"\",\"action\":\"\",\"elapsedTurn\":" + new Random().Next(5, 10) + ",\"aliveUniqueIds\":[],\"battleStatus\":" + FgoMain.calc_battleStatus(uid, bi.battleId) + ",\"voicePlayedList\":\"[]\"}" }, { "userId", uid }, { "appVer", FgoMain.get_game_version() }, { "dateVer", FgoMain.get_date_ver() }, { "lastAccessTime", FgoMain.get_timestamp_fgo() }, { "try", "" }, { "developmentAuthCode", FgoMain.get_developmentAuthCode() }, { "userAgent", 1 }, { "isBattleError", 0 }, { "dataVer", FgoMain.get_data_ver() } }; var response = JObject.Parse(FgoMain.convert_response(NetworkAPI.CreatePostHttpResponse(FgoMain.get_main_address("ac"), table))); var resCode = FgoMain.parse_rescode(response); var usk = ""; if (response["response"][0]["usk"] != null) { usk = response["response"][0]["usk"].ToString(); FgoMain.calc_usk(uid, usk); } if (resCode != "00") { return(new string[3] { resCode, response["response"][0]["fail"]["title"].ToString(), response["response"][0]["fail"]["detail"].ToString() }); } return(new string[1] { "00" }); }
public static BattleInfo fgo_battlesetup(string uid, string questId, string questPhase, string deckId, string followerId, int followerClass) { var table = new Hashtable { { "activeDeckId", deckId }, { "followerId", followerId }, { "ac", "action" }, { "key", "battlesetup" }, { "deviceid", FgoMain.get_device_id() }, { "os", FgoMain.get_os() }, { "ptype", FgoMain.get_ptype() }, { "usk", FgoMain.get_usk(uid) }, { "umk", "" }, { "rgsid", 1001 }, { "rkchannel", FgoMain.get_rkchannel() }, { "userId", uid }, { "appVer", FgoMain.get_game_version() }, { "dateVer", FgoMain.get_date_ver() }, { "lastAccessTime", FgoMain.get_timestamp_fgo() }, { "try", "" }, { "developmentAuthCode", FgoMain.get_developmentAuthCode() }, { "questId", questId }, { "questPhase", questPhase }, { "followerClassId", followerClass }, { "battleMode", 1 }, { "itemId", 0 }, { "enemySelect", 1 }, { "userAgent", 1 }, { "dataVer", FgoMain.get_data_ver() } }; var response = JObject.Parse(FgoMain.convert_response(NetworkAPI.CreatePostHttpResponse(FgoMain.get_main_address("ac"), table))); var resCode = FgoMain.parse_rescode(response); var usk = ""; if (response["response"][0]["usk"] != null) { usk = response["response"][0]["usk"].ToString(); FgoMain.calc_usk(uid, usk); } var bi = new BattleInfo(); if (resCode != "00") { bi.battleResCode = resCode; bi.battleExtra = response["response"][0]["fail"].ToString(); return(bi); } bi.battleResCode = "00"; bi.battleExtra = "{}"; var cache = JObject.Parse(CryptData.ResponseCacheDecrypt(response["cache"].ToString())); bi.battleId = cache["replaced"]["battle"][0]["id"].ToString(); bi.rewardExp = int.Parse(cache["replaced"]["battle"][0]["resultInfo"]["rewardExp"].ToString()); bi.rewardQp = int.Parse(cache["replaced"]["battle"][0]["resultInfo"]["rewardQp"].ToString()); var drop = new Dictionary <string, int>(); var enemyDeck = (JArray)cache["replaced"]["battle"][0]["battleInfo"]["enemyDeck"]; foreach (var jToken in enemyDeck) { var ed = (JObject)jToken; var svts = (JArray)ed["svts"]; foreach (var jToken1 in svts) { var ed2 = (JObject)jToken1; var dropInfos = (JArray)ed2["dropInfos"]; foreach (var jToken2 in dropInfos) { var dropJO = (JObject)jToken2; var id = dropJO["objectId"].ToString(); if (drop.ContainsKey(id)) { drop[id] = int.Parse(drop[id].ToString()) + int.Parse(dropJO["num"].ToString()); } else { drop.Add(id, int.Parse(dropJO["num"].ToString())); } } } } bi.dropInfo = drop; return(bi); }
private void battlesetup() { btnRefreshInv.Enabled = false; btnRecoverAp.Enabled = false; sellExp.Enabled = false; if (resultTime.Text != "") { resultTime.Text = "30"; } startBattle.Enabled = false; battleTimes.ReadOnly = true; var bi = FgoRequest.fgo_battlesetup(ps.uid, questId.Text, questPhase.Text, deckId, ps.followerInfo[followerBox.Text], followerClass.SelectedIndex); bif = bi; if (bi.battleResCode != "00") { var jo = JObject.Parse(bi.battleExtra); if (jo["detail"].ToString().IndexOf("AP不足") != -1 && autoApple.Checked) { if (!recoverAp(apBox.SelectedIndex)) { goto sth; } battlesetup(); return; } if (jo["detail"].ToString().IndexOf("从者数量") != -1 && autoSell.Checked) { if (!sellExpFunc(0)) { goto sth; } battlesetup(); return; } logBox.AppendText(LogHelper.createFailMessageBox(new string[] { "00", jo["title"].ToString(), jo["detail"].ToString() })); sth: btnRefreshInv.Enabled = true; btnRecoverAp.Enabled = true; sellExp.Enabled = true; startBattle.Enabled = true; battleTimes.ReadOnly = false; battleTimes.Text = ScriptConst.battleTimes; return; } logBox.AppendText(LogHelper.getPrefix() + "战斗" + bi.battleId + "掉落:\r\n"); foreach (var dic in bi.dropInfo) { if (ScriptConst.mstItem.ContainsKey(dic.Key)) { logBox.AppendText(LogHelper.getPrefix() + ScriptConst.mstItem[dic.Key] + " x " + dic.Value + "\r\n"); } else { logBox.AppendText(LogHelper.getPrefix() + dic.Key + " x " + dic.Value + "\r\n"); } } ScriptConst.settingTime = resultTime.Text; battleTime = int.Parse(ScriptConst.settingTime); battleTimer.Enabled = true; resultTime.Enabled = false; }