public static void AddFile(string file) { Files.Add(file); ChechUpdate(); MainStats.PendingFiles(Files.Count); }
public FileUpload(TcpClient _Client, string filename, string[] p) { Client = _Client; SHA1Managed Hasher = new SHA1Managed(); string hash = BitConverter.ToString(Hasher.ComputeHash(Encoding.ASCII.GetBytes(filename))).Replace("-", "").ToLower(); string fileDir = string.Format("{0}{1}/{2}/", Settings.Cache, hash.Substring(0, 1), hash.Substring(1, 1)); if (!File.Exists(fileDir + filename) && p[1] == "r") { if (!Cache.Download(new HathUri(new string[] { Settings.RequestServer, p[2], p[3], p[4], p[5] }, HathUriType.Proxy))) { buffer = Encoding.UTF8.GetBytes("Failed downloading file."); Mime = "text/plain"; return; } } if (File.Exists(fileDir + filename)) { long numBytes = new FileInfo(fileDir + filename).Length; FileStream stream = new FileStream(fileDir + filename, FileMode.Open, FileAccess.Read); BinaryReader reader = new BinaryReader(stream); MainStats.TriggerFileUpload(filename, numBytes); buffer = reader.ReadBytes((int)numBytes); Mime = GetMime(filename); return; } buffer = Encoding.UTF8.GetBytes("File is not found..."); Mime = "text/plain"; }
private void MainForm_Load(object sender, EventArgs e) { if (Cmd.States.Silent) { this.Hide(); } Init.Start(); SqlManager.Connect(); IconManager = new TrayIconManager(TrayIcon); Log.Destination = LogBox; Log.Debug = Cmd.States.Debug; MainStats.ConnectionsChange += new MainStats.EventInt(MainStats_ConnectionsChange); MainStats.Downloaded += new MainStats.EventLong(MainStats_Downloaded); MainStats.FileDownloaded += new MainStats.EventInt(MainStats_FileDownloaded); MainStats.FileUploaded += new MainStats.EventInt(MainStats_FileUploaded); MainStats.Uploaded += new MainStats.EventLong(MainStats_Uploaded); MainStats.ConnectionsChangeTotal += new MainStats.EventInt(MainStats_ConnectionsChangeTotal); MainStats.CacheUsed += new MainStats.EventLong(MainStats_CacheUsed); MainStats.FileInCache += new MainStats.EventInt(MainStats_FileInCache); MainStats.Pendingfiles += new MainStats.EventInt(MainStats_Pendingfiles); MainStats.CacheUsedPercent += new MainStats.EventDouble(MainStats_CacheUsedPercent); MainStats.KAlive += new MainStats.EventInt(MainStats_KAlive); MainStats.Start(); GCollector.Start(); }
public void Start() { Init.Start(); SqlManager.Connect(); MainStats.Start(); GCollector.Start(); if (string.IsNullOrEmpty(IniParser.Get("useruid")) || string.IsNullOrEmpty(IniParser.Get("userkey"))) { Console.Write("Enter UserID: "); Settings.UserID = Console.ReadLine(); Console.Write("Enter UserKey: "); Settings.UserKey = Console.ReadLine(); IniParser.InsertMissing("useruid", Settings.UserID); IniParser.InsertMissing("userkey", Settings.UserKey); IniParser.Save(); } else { Settings.UserID = IniParser.Get("useruid"); Settings.UserKey = IniParser.Get("userkey"); } new Thread(new ThreadStart(Check)).Start(); }
public void ApplyItems() { itemsMain = new MainStats(); itemsSub = new SubStats(); appliedItems = new Dictionary <ItemType, Item>(); if (items == null) { return; } foreach (var itemData in items) { var item = ScriptableObject.CreateInstance <Item>(); item.SetData(itemData); appliedItems.Add(item.type, item); ApplyItemStats(item); } if (appliedItems.TryGetValue(ItemType.Weapon, out Item weapon)) { var baseItem = weapon.Base as Weapon; if (baseItem == null) { return; } var levelMult = weapon.level / 5; minPhysDamage = baseItem.MinDamage + levelMult * baseItem.MinDamageIncrease; maxPhysDamage = baseItem.MaxDamage + levelMult * baseItem.MaxDamageIncrease; } CombineMainToSub(); }
public static MainStats AddMainStatChange(this MainStats stats1, ItemMainStatValue change) { switch (change.stat) { case MainStat.Strength: stats1.str += change.value; break; case MainStat.Constitution: stats1.con += change.value; break; case MainStat.Dexterity: stats1.dex += change.value; break; case MainStat.Intelligence: stats1.intel += change.value; break; case MainStat.Luck: stats1.lck += change.value; break; } return(stats1); }
private void UpdateStats_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { this.BeginInvoke(new MethodInvoker(delegate { int upload = Convert.ToInt32(MainStats.UploadedBytes()); graphControl1.Add(upload, Convert.ToInt32(MainStats.DownloadedBytes()), (Form.ActiveForm != null ? true : false)); barControl1.Value(upload, (Form.ActiveForm != null ? true : false)); })); }
public static MainStats AddTo(this MainStats stats1, MainStats stats2) { var rv = new MainStats(); rv.con = stats1.con + stats2.con; rv.str = stats1.str + stats2.str; rv.dex = stats1.dex + stats2.dex; rv.intel = stats1.intel + stats2.intel; rv.lck = stats1.lck + stats2.lck; return(rv); }
static MainStats SetStats(FightClass cla, Rarity rar) { var points = DataHolder._data.CharCreationDict[rar].startingPoints; var stats = new MainStats(); float[] dist = CharactersService.LevelStats[cla].StatDistribution; stats.str = (int)(points * dist[0]); stats.con = (int)(points * dist[1]); stats.dex = (int)(points * dist[2]); stats.intel = (int)(points * dist[3]); stats.lck = (int)(points * dist[4]); return(stats); }
// Acquires stat bonuses earned from passive abilities public void GetPassiveAbilityStats(MainStats recipient, MainStats giver, int receivedAmount, int givenAmount) { switch (recipient) { case MainStats.ATK: atkBonus += CheckStatBonus(giver, receivedAmount, givenAmount); break; case MainStats.DEF: defBonus += CheckStatBonus(giver, receivedAmount, givenAmount); break; case MainStats.SPD: break; } }
private MainStats CreateViewModel() { var mainStats = new MainStats(); // *************** Eternal ************************* var startDate = DateTime.MinValue; var endDate = DateTime.MaxValue; mainStats.Eternal = new List <Summary> { Top3Elo("Vitas Eternal Ranking", startDate, endDate), Top3TimeNumberOne("Vitas Eternal Time Number One", startDate, endDate), Top3GoatScores("Vitas Eternal Goat", startDate, endDate), }; // *************** 2020 ************************* startDate = new DateTime(2019, 1, 1); endDate = new DateTime(2019, 12, 31); mainStats.HallOfFame = new List <Summary> { Top3Elo("Vitas 2019 Ranking", startDate, endDate), Top3TimeNumberOne("Vitas 2019 Time Number One", startDate, endDate), Top3RecordWinningStreak("Best Winning Streak 2019", startDate, endDate), Top3RecordEloStreak("Best Elo Streak 2019", startDate, endDate), Top3Fibonacci("Fibonacci 2019", startDate, endDate) }; // *************** 2020 ************************* startDate = new DateTime(2020, 1, 1); endDate = new DateTime(2020, 12, 31); mainStats.RunningBattles = new List <Summary> { PlayerOfTheYear("Average Elo Score", startDate, endDate), Top3Elo("Vitas 2020 Ranking", startDate, endDate), Top3TimeNumberOne("Vitas 2020 Time Number One", startDate, endDate), Top3GoatScores("Goat 2020", startDate, endDate), Top3RecordWinningStreak("Best Winning Streak 2020", startDate, endDate), Top3RecordEloStreak("Best Elo Streak 2020", startDate, endDate), Top3Fibonacci("Fibonacci 2020", startDate, endDate) }; mainStats.GameSummaries = _statisticsService.GameSummaries(new DateTime(2020, 1, 1), DateTime.MaxValue) .OrderByDescending(summary => summary.Score1 + summary.Score2) .Take(10); return(mainStats); }
public void GetPassiveAbilityStats(MainStats recipient, float additiveValue) { bool @bool = false; switch (recipient) { case MainStats.HP: if (currentHP == MaxHP()) { @bool = true; } HPPassives += additiveValue; if (@bool) { currentHP = MaxHP(); } break; case MainStats.TP: if (currentTP == MaxTP()) { @bool = true; } TPPassives += additiveValue; if (@bool) { currentTP = MaxTP(); } break; case MainStats.ATK: atkPassives += additiveValue; break; case MainStats.DEF: defPassives += additiveValue; break; case MainStats.SPD: spdPassives += additiveValue; break; } }
private void KeepAlive_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { KeepAliveTick++; if (KeepAliveTick <= 300) { MainStats.TriggerKeepAlive(KeepAliveTick); return; } KeepAliveTick = 0; if (HHClient.Request(Settings.StillAlive, "", true)) { Log.Add("Keep alive: OK", LogType.Info, true); } else { Log.Add("Keep alive: FAIL", LogType.Info, true); } }
public void Send() { int Sent = 0; Client.NoDelay = true; stopWatch.Start(); byte[] head = Encoding.UTF8.GetBytes("HTTP/1.1 200 OK\r\n" + Headers + "Connection: close\r\nContent-Type: " + Mime + "\r\nContent-Length: " + buffer.Length + "\r\n\r\n"); try { Client.Client.Send(head, SocketFlags.None); while (Sent < buffer.Length) { int tsent = Client.Client.Send(buffer, Sent, Math.Min(Settings.UploadBufferSize, buffer.Length - Sent), SocketFlags.None); MainStats.TriggerByteUpload(tsent); Sent += tsent; } } catch { Log.Add("Connection was force closed by client.", LogType.Debug, true); } stopWatch.Stop(); Client.Client.Disconnect(false); Client.Client.Close(); Time = stopWatch.ElapsedMilliseconds; if (stopWatch.ElapsedMilliseconds == 0) { Speed = buffer.Length; } else { Speed = buffer.Length / (stopWatch.ElapsedMilliseconds / 1000.0); } }
public int CheckStatBonus(MainStats giver, int receivedAmount, int givenAmount) { switch (giver) { case MainStats.ConsumedHP: return(receivedAmount * (((maxHP + (int)(maxHP * HPPassives)) - currentHP) / givenAmount)); case MainStats.ConsumedTP: return(receivedAmount * (((maxTP + (int)(maxTP * TPPassives)) - currentTP) / givenAmount)); case MainStats.ATK: return(receivedAmount * ((atk + (int)(atk * atkPassives)) / givenAmount)); case MainStats.DEF: return(receivedAmount * ((def + (int)(def * defPassives)) / givenAmount)); case MainStats.SPD: return(receivedAmount * ((spd + (int)(spd * spdPassives)) / givenAmount)); default: return(0); } }
/// <summary> /// Begins the data usage. Prepares the container. /// </summary> public void Begin() { Stats = ProfilingTools.Stats; _cpuEvents = null; _gpuEvents = null; }
internal static extern void Internal_GetStats(out MainStats resultAsRef);
private void RequestParser(TcpClient Client) { string sBuffer = ""; ConId++; MainStats.TriggerConnection(Client.Client.RemoteEndPoint.ToString()); string Temp = Client.Client.RemoteEndPoint.ToString(); Byte[] bReceive = new Byte[1024 * 8]; try { int i = Client.Client.Receive(bReceive, bReceive.Length, 0); } catch { } sBuffer = Encoding.UTF8.GetString(bReceive); if (sBuffer.Substring(0, 3) != "GET") { Client.Client.Disconnect(false); Client.Client.Close(); MainStats.TriggerConnectionEnd(Temp); return; } string sRequest = string.Empty; string[] UrlParts = { "", "", "", "", "" }; try { sRequest = sBuffer.Substring(0, sBuffer.IndexOf("HTTP", 1) - 1).Substring(4); UrlParts = sRequest.Split('/'); } catch { Client.Client.Disconnect(false); Client.Client.Close(); MainStats.TriggerConnectionEnd(Temp); return; } Response output; if (sRequest == "/") { output = new Stats(Client); } else if (sRequest == "/favicon.ico") { output = new Favicon(Client); } else if ((UrlParts[1] == "r" || UrlParts[1] == "h") && UrlParts.Length >= 3) { output = new FileUpload(Client, UrlParts[2], UrlParts); } else if (UrlParts[1] == "servercmd" && UrlParts.Length >= 3) { output = new ServerCMD(Client, UrlParts); } else { output = new Unknown(Client); } output.Send(); if (sRequest != "/" && sRequest != "/favicon.ico") { Log.Add(String.Format("OUT > {1,22} {0,13} bytes [ took: {3,8}s at {4,9}kb/s] -> {2}", output.Size, Temp, sRequest, Math.Round(output.Time / 1000, 3), Math.Round(output.Speed / 1024, 3)), LogType.Info, true); } MainStats.TriggerConnectionEnd(Temp); }
public static bool Download(HathUri Uri, CopyInfo CInfo = null) { SHA1Managed Hasher = new SHA1Managed(); string hash = BitConverter.ToString(Hasher.ComputeHash(Encoding.ASCII.GetBytes(Uri.FileName))).Replace("-", "").ToLower(); string fileDir = string.Format("{0}{1}/{2}/", Settings.Cache, hash.Substring(0, 1), hash.Substring(1, 1)); try { Directory.CreateDirectory(Path.GetDirectoryName(fileDir + Uri.FileName)); using (WebClient client = new WebClient()) { using (Stream streamRemote = client.OpenRead(new Uri(Uri.Url))) { int contentSize = 0; byte[] byteBuffer; int rec = 0; int iByteSize = 0; if (client.ResponseHeaders.Get("Content-Length") == "1009,1009" || client.ResponseHeaders.Get("Content-Length") == "28658,28658") { contentSize = 1009; } else { try { contentSize = int.Parse(client.ResponseHeaders.Get("Content-Length")); } catch { Log.Add("Server sent corrupt Content-Length header... " + client.BaseAddress, LogType.Warning, true); return(false); } } if (contentSize >= 0 && (contentSize != 28658 && contentSize != 1009)) { byteBuffer = new byte[contentSize]; } else { if (contentSize == 28658 || contentSize == 1009) { if (HHClient.Request(Settings.MoreFiles, "", true)) { Log.Add("Requested more files.", LogType.Info, true); if (Download(Uri)) { return(true); } } } return(false); } try { while ((iByteSize = streamRemote.Read(byteBuffer, rec, byteBuffer.Length - rec)) > 0) { rec += iByteSize; MainStats.TriggerByteDownload(iByteSize); } } catch { return(false); } using (Stream streamLocal = new FileStream(fileDir + Uri.FileName, FileMode.Create, FileAccess.ReadWrite, FileShare.Write)) { streamLocal.Write(byteBuffer, 0, byteBuffer.Length); streamLocal.Close(); } streamRemote.Close(); if (CInfo != null) { File.Copy(fileDir + Uri.FileName, CInfo.Location + CInfo.FileName); } if (Settings.CopyDlToGalleries) { HathDownloader.CopyIsMissing(fileDir + Uri.FileName, Uri.FileName); } SqlManager.InsertFile(new FileData(Uri.FileName, contentSize)); MainStats.TriggerFileDownload(Uri.FileName, contentSize); if (Uri.UriType == HathUriType.Proxy || Uri.UriType == HathUriType.HathDl) { PendingRegister.AddFile(Uri.FileName); } } } return(true); } catch { return(false); } }